Selaa lähdekoodia

New Button --> correct reset ID

Edgardo Palza 7 vuotta sitten
vanhempi
commit
c3fd8ce8e8
3 muutettua tiedostoa jossa 18 lisäystä ja 7 poistoa
  1. 6 3
      src/ui/model/idCounter.java
  2. 7 3
      src/ui/model/idCounterElem.java
  3. 5 1
      src/ui/view/GUI.java

+ 6 - 3
src/ui/model/idCounter.java

@@ -3,12 +3,11 @@ package ui.model;
 public class idCounter {
 	private static int counter = 1;
 
-
 	public static synchronized int nextId() {
 		return counter++;
 
 	}
-	
+
 	/**
 	 * @return the counter
 	 */
@@ -17,10 +16,14 @@ public class idCounter {
 	}
 
 	/**
-	 * @param counter the counter to set
+	 * @param counter
+	 *            the counter to set
 	 */
 	public static void setCounter(int counter) {
 		idCounter.counter = counter;
 	}
 
+	public static void resetCounter() {
+		counter = 1;
+	}
 }

+ 7 - 3
src/ui/model/idCounterElem.java

@@ -3,12 +3,11 @@ package ui.model;
 public class idCounterElem {
 	private static int counter = 1;
 
-
 	public static synchronized int nextId() {
 		return counter++;
 
 	}
-	
+
 	/**
 	 * @return the counter
 	 */
@@ -17,10 +16,15 @@ public class idCounterElem {
 	}
 
 	/**
-	 * @param counter the counter to set
+	 * @param counter
+	 *            the counter to set
 	 */
 	public static void setCounter(int counter) {
 		idCounterElem.counter = counter;
 	}
 
+	public static void resetCounter() {
+		counter = 1;
+	}
+
 }

+ 5 - 1
src/ui/view/GUI.java

@@ -69,7 +69,9 @@ import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.HolonTransformer;
 import ui.controller.Control;
-import ui.model.Model;;
+import ui.model.Model;
+import ui.model.idCounter;
+import ui.model.idCounterElem;;
 
 public class GUI<E> implements CategoryListener {
 
@@ -1351,6 +1353,8 @@ public class GUI<E> implements CategoryListener {
 				canvas.tempCps = null;
 				canvas.objectSelectionHighlighting();
 				canvas.repaint();
+				idCounter.resetCounter();
+				idCounterElem.resetCounter();
 			}
 		});