Procházet zdrojové kódy

delete exeptions behoben

dominik.rieder před 8 roky
rodič
revize
9d10587ecf
34 změnil soubory, kde provedl 28 přidání a 12 odebrání
  1. 1 0
      bin/.gitignore
  2. binární
      bin/Interfaces/CategoryListener.class
  3. binární
      bin/Interfaces/ComparableObject.class
  4. binární
      bin/Interfaces/ObjectListener.class
  5. binární
      bin/classes/Category.class
  6. binární
      bin/classes/CpsObject.class
  7. binární
      bin/classes/HolonElement.class
  8. binární
      bin/classes/HolonObject.class
  9. binární
      bin/classes/HolonSwitch.class
  10. binární
      bin/classes/HolonTransformer.class
  11. binární
      bin/classes/Position.class
  12. binární
      bin/exceptions/newException1.class
  13. binární
      bin/tests/Tests1.class
  14. binární
      bin/tests/praktikumHolonsTestMinimal.class
  15. binární
      bin/ui/controller/CategoryController.class
  16. binární
      bin/ui/controller/Control$command.class
  17. binární
      bin/ui/controller/Control.class
  18. binární
      bin/ui/controller/ObjectControl.class
  19. binární
      bin/ui/model/IdCounter.class
  20. binární
      bin/ui/model/Model.class
  21. binární
      bin/ui/model/tests.class
  22. binární
      bin/ui/view/AddElementPopUp.class
  23. binární
      bin/ui/view/AddObjectPopUp.class
  24. binární
      bin/ui/view/GUI$1.class
  25. binární
      bin/ui/view/GUI$2.class
  26. binární
      bin/ui/view/GUI$3.class
  27. binární
      bin/ui/view/GUI$4.class
  28. binární
      bin/ui/view/GUI$5.class
  29. binární
      bin/ui/view/GUI$6.class
  30. binární
      bin/ui/view/GUI.class
  31. binární
      bin/ui/view/Main$1.class
  32. binární
      bin/ui/view/Main.class
  33. binární
      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/

binární
bin/Interfaces/CategoryListener.class


binární
bin/Interfaces/ComparableObject.class


binární
bin/Interfaces/ObjectListener.class


binární
bin/classes/Category.class


binární
bin/classes/CpsObject.class


binární
bin/classes/HolonElement.class


binární
bin/classes/HolonObject.class


binární
bin/classes/HolonSwitch.class


binární
bin/classes/HolonTransformer.class


binární
bin/classes/Position.class


binární
bin/exceptions/newException1.class


binární
bin/tests/Tests1.class


binární
bin/tests/praktikumHolonsTestMinimal.class


binární
bin/ui/controller/CategoryController.class


binární
bin/ui/controller/Control$command.class


binární
bin/ui/controller/Control.class


binární
bin/ui/controller/ObjectControl.class


binární
bin/ui/model/IdCounter.class


binární
bin/ui/model/Model.class


binární
bin/ui/model/tests.class


binární
bin/ui/view/AddElementPopUp.class


binární
bin/ui/view/AddObjectPopUp.class


binární
bin/ui/view/GUI$1.class


binární
bin/ui/view/GUI$2.class


binární
bin/ui/view/GUI$3.class


binární
bin/ui/view/GUI$4.class


binární
bin/ui/view/GUI$5.class


binární
bin/ui/view/GUI$6.class


binární
bin/ui/view/GUI.class


binární
bin/ui/view/Main$1.class


binární
bin/ui/view/Main.class


binární
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.");
 				}
 
 			}