public ObjectEditor(final EnvObjectLogic obj) {
this.object = obj;
oldName = object.getPojo().getName();
EnvObject pojo = obj.getPojo();
//AVOID the paint of the value over sliders that will conflic with double values
UIManager.put("Slider.paintValue", false);
initComponents();
setSize(600, 400);
if (obj.getPojo().getActAs().equalsIgnoreCase("virtual")) {
btnVirtual.setSelected(true);
}
UUIDtxt.setText(object.getPojo().getUUID());
checkIfVirtual();
txtName.setText(pojo.getName());
txtDescription.setText(pojo.getDescription());
txtTags.setText(pojo.getTagsString());
populateProtocol();
populateEnvironment();
txtAddress.setText(pojo.getPhisicalAddress());
Integer x = (int) pojo.getCurrentRepresentation().getOffset().getX();
Integer y = (int) pojo.getCurrentRepresentation().getOffset().getY();
Integer rotation = (int) pojo.getCurrentRepresentation().getRotation();
SpinnerModel modelX =
new SpinnerNumberModel(0, //initial value
-100, //min
(int) obj.getEnvironment().getPojo().getWidth() + 100, //max= env dimension + 1 meter
1); //step
SpinnerModel modelY =
new SpinnerNumberModel(0, //initial value
-100, //min
(int) obj.getEnvironment().getPojo().getWidth() + 100, //max
1); //step
spnX.setModel(modelX);
spnY.setModel(modelY);
spnX.setValue((Integer) x);
spnY.setValue((Integer) y);
SpinnerModel scaleWidthModel =
new SpinnerNumberModel(new Double(pojo.getCurrentRepresentation().getScaleX()), //initial value
new Double(0.1), //min
new Double(10.0), //max
new Double(0.1)); //step
spnScaleWidth.setModel(scaleWidthModel);
SpinnerModel scaleHeightModel =
new SpinnerNumberModel(new Double(pojo.getCurrentRepresentation().getScaleY()), //initial value
new Double(0.1), //min
new Double(10.0), //max
new Double(0.1)); //step
spnScaleHeight.setModel(scaleHeightModel);
spnRotation.setValue(rotation);
tabObjectEditor.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
if (tabObjectEditor.getSelectedComponent().equals(tabAutomations)) {
populateAutomationsTab();
}
}
});
//population combo box representation
DefaultComboBoxModel representationsModel = new DefaultComboBoxModel();
for (EnvObjectLogic object : EnvObjectPersistence.getObjectList()) {
for (Representation rep : object.getPojo().getRepresentations()) {
representationsModel.addElement(rep);
}
}
if ((pojo.getActAs() != null)
&& !pojo.getActAs().isEmpty()
&& !pojo.getActAs().equalsIgnoreCase("unimplemented")) {
setTitle(pojo.getName() + " (" + pojo.getActAs() + " " + pojo.getSimpleType() + ")");
} else {
setTitle(pojo.getName() + " (" + pojo.getSimpleType() + ")");
}
// controlPanel = new PropertiesPanel_1(0, 1);
// tabControls.add(controlPanel);
tabControls.setLayout(new BoxLayout(tabControls, BoxLayout.PAGE_AXIS));