Edgardo Palza 7 years ago
parent
commit
ce0d8ec6c8
3 changed files with 15 additions and 12 deletions
  1. 1 1
      src/classes/HolonElement.java
  2. 1 0
      src/ui/view/AddElementPopUp.java
  3. 13 11
      src/ui/view/GUI.java

+ 1 - 1
src/classes/HolonElement.java

@@ -59,7 +59,7 @@ public class HolonElement {
 		setActive(true);
 		setSign(energy);
 		setEnergyAt(energy);
-		// setId(idCounterElem.nextId());
+		setId(idCounterElem.nextId());
 	}
 
 	/**

+ 1 - 0
src/ui/view/AddElementPopUp.java

@@ -169,6 +169,7 @@ public class AddElementPopUp extends JDialog {
 				});
 			}
 		}
+
 	}
 
 	public void setActualCps(CpsObject cps) {

+ 13 - 11
src/ui/view/GUI.java

@@ -105,7 +105,7 @@ public class GUI<E> implements CategoryListener {
 	private final JLabel elementGraph = new JLabel("None ");
 	private final ArrayList<HolonElement> selectedElements = new ArrayList<HolonElement>();
 	private String holonEleNamesDisplayed = "None ";
-	HashMap<Integer, ArrayList<HolonElement>> eleToDelete = new HashMap<Integer, ArrayList<HolonElement>>();
+	private HashMap<Integer, ArrayList<HolonElement>> eleToDelete = new HashMap<Integer, ArrayList<HolonElement>>();
 	private final JTree tree = new JTree();
 	/******************************************
 	 ************* Right Container*************
@@ -655,8 +655,10 @@ public class GUI<E> implements CategoryListener {
 						addElementPopUp.setActualCps(getActualCps());
 						addElementPopUp.setVisible(true);
 						HolonElement ele = addElementPopUp.getElement();
-						controller.addElementCanvasObject(tempCpsObject.getID(), ele.getEleName(), ele.getAmount(),
-								ele.getEnergy());
+						if (ele != null) {
+							controller.addElementCanvasObject(tempCpsObject.getID(), ele.getEleName(), ele.getAmount(),
+									ele.getEnergy());
+						}
 						refreshTableHolonElement();
 						refreshTableProperties();
 						controller.calculateStateForTimeStep(model.getCurIteration());
@@ -848,7 +850,7 @@ public class GUI<E> implements CategoryListener {
 		 **********************/
 
 		/*
-		 * Update of the mouse coord
+		 * Update of the mouse coord for Edit-Mode
 		 */
 		tableProperties.addMouseListener(new MouseAdapter() {
 			public void mousePressed(MouseEvent e) {
@@ -1621,7 +1623,7 @@ public class GUI<E> implements CategoryListener {
 	 * 
 	 * @return selected CpsObject
 	 */
-	public CpsObject getActualCps() {
+	private CpsObject getActualCps() {
 		int tempID = model.getSelectedObjectID();
 		CpsObject tempCps = controller.searchByID(tempID);
 		return tempCps;
@@ -1640,7 +1642,7 @@ public class GUI<E> implements CategoryListener {
 	 *            Control, 2 means MultiSelection with Control
 	 * @return the selected HolonElement
 	 */
-	public HolonElement getActualHolonElement(HolonObject obj, int yValue, int toMultiHash) {
+	private HolonElement getActualHolonElement(HolonObject obj, int yValue, int toMultiHash) {
 		final int yTemp = (int) Math.floor(yValue / 16);
 		int rowsTotal = 0;
 		// Filter for search --> single and multi selection
@@ -1700,7 +1702,7 @@ public class GUI<E> implements CategoryListener {
 	 * @param yValue
 	 * @return clicked HolonObject
 	 */
-	public HolonObject getHolonObj(int yValue) {
+	private HolonObject getHolonObj(int yValue) {
 		final int yTemp = (int) Math.floor(yValue / 16);
 		HolonObject obtTemp = null;
 		String temp = tableModelHolonElementMulti.getValueAt(yTemp, 0).toString();
@@ -1713,7 +1715,7 @@ public class GUI<E> implements CategoryListener {
 	 * Update the HolonElement Table, that means erase all rows and add the new
 	 * rows with new data
 	 */
-	public void refreshTableHolonElement() {
+	private void refreshTableHolonElement() {
 		// Update of the Information about the HolonElements - only for
 		// HolonObjects
 
@@ -1731,7 +1733,7 @@ public class GUI<E> implements CategoryListener {
 	/**
 	 * Erase all information of the HolonElement Model
 	 */
-	public void deleteRows(PropertyTable t) {
+	private void deleteRows(PropertyTable t) {
 		if (t.getRowCount() > 0) {
 			for (int i = t.getRowCount() - 1; i > -1; i--) {
 				t.removeRow(i);
@@ -1746,7 +1748,7 @@ public class GUI<E> implements CategoryListener {
 	 * @param elements
 	 *            ArrayList to be displayed
 	 */
-	public void fillElementTable(ArrayList<CpsObject> objects) {
+	private void fillElementTable(ArrayList<CpsObject> objects) {
 		if (objects.size() > 1) {
 			for (CpsObject o : objects) {
 				if (o instanceof HolonObject) {
@@ -1771,7 +1773,7 @@ public class GUI<E> implements CategoryListener {
 	/**
 	 * Update the information concerning properties of the selected CpsObject
 	 */
-	public void refreshTableProperties() {
+	private void refreshTableProperties() {
 		if (model.getSelectedCpsObjects().size() == 1) {
 			CpsObject tempCps = getActualCps();
 			if (tempCps != null && tempCps.getClass() == HolonObject.class) {