Jelajahi Sumber

delete exeptions behoben

dominik.rieder 8 tahun lalu
induk
melakukan
9d10587ecf
34 mengubah file dengan 28 tambahan dan 12 penghapusan
  1. 1 0
      bin/.gitignore
  2. TEMPAT SAMPAH
      bin/Interfaces/CategoryListener.class
  3. TEMPAT SAMPAH
      bin/Interfaces/ComparableObject.class
  4. TEMPAT SAMPAH
      bin/Interfaces/ObjectListener.class
  5. TEMPAT SAMPAH
      bin/classes/Category.class
  6. TEMPAT SAMPAH
      bin/classes/CpsObject.class
  7. TEMPAT SAMPAH
      bin/classes/HolonElement.class
  8. TEMPAT SAMPAH
      bin/classes/HolonObject.class
  9. TEMPAT SAMPAH
      bin/classes/HolonSwitch.class
  10. TEMPAT SAMPAH
      bin/classes/HolonTransformer.class
  11. TEMPAT SAMPAH
      bin/classes/Position.class
  12. TEMPAT SAMPAH
      bin/exceptions/newException1.class
  13. TEMPAT SAMPAH
      bin/tests/Tests1.class
  14. TEMPAT SAMPAH
      bin/tests/praktikumHolonsTestMinimal.class
  15. TEMPAT SAMPAH
      bin/ui/controller/CategoryController.class
  16. TEMPAT SAMPAH
      bin/ui/controller/Control$command.class
  17. TEMPAT SAMPAH
      bin/ui/controller/Control.class
  18. TEMPAT SAMPAH
      bin/ui/controller/ObjectControl.class
  19. TEMPAT SAMPAH
      bin/ui/model/IdCounter.class
  20. TEMPAT SAMPAH
      bin/ui/model/Model.class
  21. TEMPAT SAMPAH
      bin/ui/model/tests.class
  22. TEMPAT SAMPAH
      bin/ui/view/AddElementPopUp.class
  23. TEMPAT SAMPAH
      bin/ui/view/AddObjectPopUp.class
  24. TEMPAT SAMPAH
      bin/ui/view/GUI$1.class
  25. TEMPAT SAMPAH
      bin/ui/view/GUI$2.class
  26. TEMPAT SAMPAH
      bin/ui/view/GUI$3.class
  27. TEMPAT SAMPAH
      bin/ui/view/GUI$4.class
  28. TEMPAT SAMPAH
      bin/ui/view/GUI$5.class
  29. TEMPAT SAMPAH
      bin/ui/view/GUI$6.class
  30. TEMPAT SAMPAH
      bin/ui/view/GUI.class
  31. TEMPAT SAMPAH
      bin/ui/view/Main$1.class
  32. TEMPAT SAMPAH
      bin/ui/view/Main.class
  33. TEMPAT SAMPAH
      bin/ui/view/MyCanvas.class
  34. 27 12
      src/ui/view/GUI.java

+ 1 - 0
bin/.gitignore

@@ -1,3 +1,4 @@
+/Images/
 /Interfaces/
 /classes/
 /exceptions/

TEMPAT SAMPAH
bin/Interfaces/CategoryListener.class


TEMPAT SAMPAH
bin/Interfaces/ComparableObject.class


TEMPAT SAMPAH
bin/Interfaces/ObjectListener.class


TEMPAT SAMPAH
bin/classes/Category.class


TEMPAT SAMPAH
bin/classes/CpsObject.class


TEMPAT SAMPAH
bin/classes/HolonElement.class


TEMPAT SAMPAH
bin/classes/HolonObject.class


TEMPAT SAMPAH
bin/classes/HolonSwitch.class


TEMPAT SAMPAH
bin/classes/HolonTransformer.class


TEMPAT SAMPAH
bin/classes/Position.class


TEMPAT SAMPAH
bin/exceptions/newException1.class


TEMPAT SAMPAH
bin/tests/Tests1.class


TEMPAT SAMPAH
bin/tests/praktikumHolonsTestMinimal.class


TEMPAT SAMPAH
bin/ui/controller/CategoryController.class


TEMPAT SAMPAH
bin/ui/controller/Control$command.class


TEMPAT SAMPAH
bin/ui/controller/Control.class


TEMPAT SAMPAH
bin/ui/controller/ObjectControl.class


TEMPAT SAMPAH
bin/ui/model/IdCounter.class


TEMPAT SAMPAH
bin/ui/model/Model.class


TEMPAT SAMPAH
bin/ui/model/tests.class


TEMPAT SAMPAH
bin/ui/view/AddElementPopUp.class


TEMPAT SAMPAH
bin/ui/view/AddObjectPopUp.class


TEMPAT SAMPAH
bin/ui/view/GUI$1.class


TEMPAT SAMPAH
bin/ui/view/GUI$2.class


TEMPAT SAMPAH
bin/ui/view/GUI$3.class


TEMPAT SAMPAH
bin/ui/view/GUI$4.class


TEMPAT SAMPAH
bin/ui/view/GUI$5.class


TEMPAT SAMPAH
bin/ui/view/GUI$6.class


TEMPAT SAMPAH
bin/ui/view/GUI.class


TEMPAT SAMPAH
bin/ui/view/Main$1.class


TEMPAT SAMPAH
bin/ui/view/Main.class


TEMPAT SAMPAH
bin/ui/view/MyCanvas.class


+ 27 - 12
src/ui/view/GUI.java

@@ -270,18 +270,33 @@ public class GUI implements CategoryListener {
 			public void actionPerformed(ActionEvent arg0) {
 
 				Object nodeInfo = tree.getLastSelectedPathComponent();
-				DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) nodeInfo;
-				String nodeName = selectedNode.getUserObject().toString();
-				int depthOfNode = selectedNode.getLevel();
-
-				switch (depthOfNode) {
-				case 1:
-					controller.deleteCategory(nodeName);
-					break;
-				case 2:
-					DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selectedNode.getParent();
-					controller.deleteObjectInCat(nodeName, parent.getUserObject().toString());
-					break;
+				if(nodeInfo != null){
+					DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) nodeInfo;
+					String nodeName = selectedNode.getUserObject().toString();
+					int depthOfNode = selectedNode.getLevel();
+
+					switch (depthOfNode) {
+					case 1:
+						int dialogResult = JOptionPane.showConfirmDialog (null, "Do you realy want to delete the Category " + nodeName + "?","Warning", JOptionPane.YES_NO_OPTION);
+						if(dialogResult == JOptionPane.YES_OPTION){
+							controller.deleteCategory(nodeName);
+							break;
+						}
+						else{
+						break;
+						}
+					case 2:
+						DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selectedNode.getParent();
+						controller.deleteObjectInCat(nodeName, parent.getUserObject().toString());
+						break;
+				
+					default :
+						JOptionPane.showMessageDialog(new JFrame(),
+							"Please select a Category or an Object in order to delete something.");
+					}
+				}else{
+					JOptionPane.showMessageDialog(new JFrame(),
+							"Please select a Category or an Object in order to delete something.");
 				}
 
 			}