Browse Source

small inconsistency in the switches manipulation through the PropertyTable fixed

Edgardo Palza 7 years ago
parent
commit
9d870e4cae
1 changed files with 9 additions and 8 deletions
  1. 9 8
      src/ui/view/GUI.java

+ 9 - 8
src/ui/view/GUI.java

@@ -1234,12 +1234,13 @@ public class GUI<E> implements CategoryListener {
 					int selValueX = (int) Math.floor(xProThis / (tableProperties.getWidth() / 2));
 					int selValueYBool = (int) Math.floor(yProThisOneClick / 16);
 					int selValueXBool = (int) Math.floor(xProThisOneClick / (tableProperties.getWidth() / 2));
-					if (updCon.getActualCps() != null && selValueX != 0) {
+					if (updCon.getActualCps() != null) {
 						temp = model.getPropertyTable().getValueAt(selValueY, selValueX);
 						btemp = model.getPropertyTable().getValueAt(selValueYBool, selValueXBool);
 						// Case: Switch selected
+
 						if (updCon.getActualCps() instanceof HolonSwitch) {
-							if (selValueY == 0) {
+							if (selValueY == 0 && selValueX != 0) {
 								updCon.getActualCps().setName(temp.toString());
 							}
 							if (selValueYBool == 2) {
@@ -1253,12 +1254,12 @@ public class GUI<E> implements CategoryListener {
 							} else if (selValueYBool == 3) {
 								if (((HolonSwitch) updCon.getActualCps()).getManualMode()) {
 									model.getPropertyTable().setCellEditable(3, 1, true);
-									Boolean bTemp = Boolean.parseBoolean(temp.toString());
+									Boolean bTemp = Boolean.parseBoolean(btemp.toString());
 									((HolonSwitch) updCon.getActualCps()).setManualState(bTemp);
 								}
 							}
 						} // Case: UpperNode selected
-						else if (updCon.getActualCps() instanceof CpsUpperNode) {
+						else if (updCon.getActualCps() instanceof CpsUpperNode && selValueX != 0) {
 							// Name edition through double click
 							updCon.getActualCps().setName(temp.toString());
 							// Update of name on the tab in the tab section
@@ -1275,7 +1276,7 @@ public class GUI<E> implements CategoryListener {
 								}
 							}
 						} // Case: HolonObject is selected
-						else if (updCon.getActualCps() instanceof HolonObject) {
+						else if (updCon.getActualCps() instanceof HolonObject && selValueX != 0) {
 							// Name edition through double click
 							updCon.getActualCps().setName(temp.toString());
 						}
@@ -1986,18 +1987,18 @@ public class GUI<E> implements CategoryListener {
 
 		frmCyberPhysical.getContentPane().add(timePanel, BorderLayout.SOUTH);
 
-		//focus canvas so copy/paste/cut and select all works
+		// focus canvas so copy/paste/cut and select all works
 		MouseAdapter focusCanvas = new MouseAdapter() {
 			@Override
 			public void mouseExited(MouseEvent e) {
 				contentPane.requestFocus();
 			}
 		};
-		
+
 		model.getTableHolonElement().addMouseListener(focusCanvas);
 		tableProperties.addMouseListener(focusCanvas);
 		console.getConsoleText().addMouseListener(focusCanvas);
-		
+
 		try {
 			controller.loadAutoSave(System.getProperty("user.home") + "/.config/HolonGUI/Category/Category.json");
 		} catch (IOException e1) {