[Bojangles-cvs] cvs: bojangles / MainWindow.java
Status: Alpha
Brought to you by:
nehresma
From: kai5263499 <boj...@li...> - 2002-09-25 20:54:46
|
kai5263499 Wed Sep 25 13:54:44 2002 EDT Modified files: /bojangles MainWindow.java Log: Happy-dance time, i got the widget to go away from the screen (now for the tree and XML and it's children... Index: bojangles/MainWindow.java diff -u bojangles/MainWindow.java:1.33 bojangles/MainWindow.java:1.34 --- bojangles/MainWindow.java:1.33 Mon Sep 23 14:19:45 2002 +++ bojangles/MainWindow.java Wed Sep 25 13:54:44 2002 @@ -483,42 +483,42 @@ } private void treeDelMenuItemActionPerformed(MouseEvent evt) { - // Kill de widget! + // First we setup treepaths and other information we'll need later int row = selectedRow; String who = curSelectedItem.toString(); //System.out.println(row); TreePath tp = widgetTree.getPathForRow(row); curSelectedItem = tp; - if (-1 == row) { - if (xmlHandler.doesPathExist(null)) { - // We can't delete nothing... - return; - } - } - else { - // retrieve the clicked on DefaultMutableTreeNode - Object pathArray[] = tp.getPath(); - DefaultMutableTreeNode n = (DefaultMutableTreeNode)pathArray[pathArray.length-1]; - Hashtable h = correlations.getCorrelation(n); - String path = (String)h.get("path"); - Component com_widget = (Container)h.get("widget"); - Container parent = null; - - // if we are the first thing in the tree, then set the parent equal to the displayPanel - if (null == popupOnTreeNode) - parent = displayPanel; - else { - Hashtable hip = correlations.getCorrelation(popupOnTreeNode); - parent = (Container)hip.get("widget"); - } - - // remove this component from the parent container and then the document's xml then the correlation's file - System.out.println("Parent: " + parent.getName()); - parent.remove(com_widget); - //doc. - //correlations.removeCorrelation(path); - System.out.println("Path: " + path); - } + // retrieve the clicked on DefaultMutableTreeNode + Object pathArray[] = tp.getPath(); + DefaultMutableTreeNode n = (DefaultMutableTreeNode)pathArray[pathArray.length-1]; + Hashtable h = correlations.getCorrelation(n); + String path = (String)h.get("path"); + StringTokenizer st = new StringTokenizer(path,"/"); + + // This is a hack to get the parent's XML path in the document + int roadkill = st.countTokens() - 1; + String parent_path = "/"; + for(int i = 1;i<=roadkill;i++) { + if(i + 1 > roadkill) parent_path = parent_path + st.nextToken(); + else parent_path = parent_path + st.nextToken() + "/"; + } + + // Now we take that and extract the parent and child widgets + Hashtable p = correlations.getCorrelation(parent_path); + JPanel parent_widget = (JPanel)p.get("widget"); + JPanel com_widget = (JPanel)h.get("widget"); + + // KILL DE WIDGET! + parent_widget.remove(com_widget); + // remove rest here + + // Redraw the parent + parent_widget.invalidate(); + // remove this component from the parent container and then the document's xml then the correlation's file + //System.out.println("parent: " + parent_widget.validate()); + System.out.println("parent: " + parent_path); + System.out.println("path: " + path); appModified(true); } |