ソースを参照

Fix Elements if Object edited

Teh-Hai Julian Zheng 7 年 前
コミット
f1d5eae9f4

+ 0 - 8
src/ui/controller/CategoryController.java

@@ -52,17 +52,9 @@ public class CategoryController {
 
 	/**
 	 * Adds Category into Model if a Category with the same name already exists
-<<<<<<< HEAD
-	 * Add Category_+1
-	 *  
-	 * @param toAdd
-	 *            neue Kategorie
-=======
-	 * Add Category_+1.
 	 * 
 	 * @param category
 	 *            the new Category
->>>>>>> 90bc29b29bece3f981eca7b6bd629093b2c90382
 	 */
 	public void addCategory(Category category) {
 		// int number = 0;

+ 1 - 0
src/ui/controller/Control.java

@@ -190,6 +190,7 @@ public class Control {
 	 */
 	public void resetCategorys() throws IOException {
 		categoryController.initCategories();
+		objectController.initHolonElements();
 		saveCategory();
 	}
 

+ 9 - 6
src/ui/view/AddObjectPopUp.java

@@ -201,10 +201,10 @@ public class AddObjectPopUp extends JDialog {
 					addElement.setVisible(true);
 					HolonElement hl = addElement.getElement();
 					hl.setSaving(new Pair<String, String>(givenCategory, objectName.getText()));
-//					if (hl != null) {
-//						hl.setSav(givenCategory);
-//					}
-//					hl.setObj(objectName.getText());
+					// if (hl != null) {
+					// hl.setSav(givenCategory);
+					// }
+					// hl.setObj(objectName.getText());
 					addElement(hl);
 				}
 			});
@@ -271,22 +271,25 @@ public class AddObjectPopUp extends JDialog {
 								try {
 									if (editState) {
 										controller.delObjectCategory(givenCategory, toEdit.getName());
+										hElements.forEach(ele -> ele
+												.setSaving(new Pair<>(ele.getSaving().getKey(), objectName.getText())));
 										controller.addObject(controller.searchCategory(givenCategory),
 												objectName.getText(), hElements, imagePath);
+
 									} else {
 										controller.addObject(controller.searchCategory(givenCategory),
 												objectName.getText(), hElements, imagePath);
 									}
 								} catch (Exception e2) {
 									// TODO: handle exception
-									
+
 								}
 
 								// controller.addObjectCategory(controller.searchCategory(givenCategory),
 								// theObject);
 								//
 								// System.out.println(theObject.getImage());
-								System.out.println(givenCategory);
+
 								dispose();
 							} else {
 								sourcePath.setBackground(new Color(255, 50, 50));