[Bojangles-cvs] cvs: bojangles / MainWindow.java testAppPrefsDlg.java
Status: Alpha
Brought to you by:
nehresma
From: kai5263499 <boj...@li...> - 2002-09-04 21:03:07
|
kai5263499 Wed Sep 4 14:03:05 2002 EDT Modified files: /bojangles MainWindow.java testAppPrefsDlg.java Log: Finally figured out how to remove widgets (I think) we'll see if this last until i get home and play with it. Index: bojangles/MainWindow.java diff -u bojangles/MainWindow.java:1.27 bojangles/MainWindow.java:1.28 --- bojangles/MainWindow.java:1.27 Tue Sep 3 14:01:53 2002 +++ bojangles/MainWindow.java Wed Sep 4 14:02:58 2002 @@ -63,7 +63,7 @@ private String prefHost, prefPort, prefPath, prefBrowser, prefLastFile; private Element prefRootEle, tlFileSaved, tBrowse, tHost, tPort, tPath, sizeEle, ptheight, ptwidth; private Document prefDocument = null; - private int prefPT_h, prefPT_w; + private int prefPT_h, prefPT_w, selectedRow; /** Creates new form MainWindow */ public MainWindow() { @@ -324,6 +324,8 @@ // get the TreePath for the where the menu was clicked -- this will // decide what menu items are enabled and disabled int row = widgetTree.getRowForLocation(evt.getX(), evt.getY()); + //System.out.println(row); + selectedRow= row; TreePath tp = widgetTree.getPathForRow(row); curSelectedItem = tp; if (-1 == row) { @@ -383,15 +385,12 @@ try { testAppPrefsDlg testappprefsdlg = new testAppPrefsDlg(); - while(!testappprefsdlg.ready) { - this.wait(); - } + this.wait(); } catch (InterruptedException e) { e.printStackTrace(); } - // Write it to pref.xml! System.out.println("URL af is: http://" + prefHost + ":" + prefPort + "/" + prefPath + "/" + sdir.getName()); @@ -424,14 +423,11 @@ private void treeDelMenuItemActionPerformed(MouseEvent evt) { // Kill de widget! - //int row = widgetTree.getRowForLocation(evt.getX(), evt.getY()); + int row = selectedRow; String who = curSelectedItem.toString(); - - // get the TreePath for the where the menu was clicked -- this will - // decide what menu items are enabled and disabled - int row = widgetTree.getRowForLocation(evt.getX(), evt.getY()); - TreePath tp = widgetTree.getPathForRow(row); - curSelectedItem = tp; + //System.out.println(row); + TreePath tp = widgetTree.getPathForRow(row); + curSelectedItem = tp; if (-1 == row) { if (xmlHandler.doesPathExist(null)) { JOptionPane.showMessageDialog(null, "You can't have less than 0 components...", "Error", JOptionPane.ERROR_MESSAGE); @@ -446,7 +442,7 @@ System.out.println(path); // get outer_type String outerType = xmlHandler.getOuterType(path); - + if (null == outerType) return; // now for what we've really been wanting to get -- the widget's defined class @@ -460,7 +456,7 @@ } //treePopup.show((Component)evt.getSource(), evt.getX(), evt.getY()); - //System.out.println("I think: " + curSelectedItem.getPath().toString() + " has " + curSelectedItem.getLastPathComponent().toString() + " children..."); + System.out.println("I think: " + curSelectedItem.getPath().toString() + " has " + curSelectedItem.getLastPathComponent().toString() + " children..."); System.out.println("There is no spoon..."); appModified(true); } @@ -698,13 +694,15 @@ File[] files = new File("widget_definitions").listFiles(); if (null == files) { System.out.println("Unable to find the widget definitions. " + System.getProperty("os.name")); - doExit(1); + JFileChooser fc = new JFileChooser(); + files = fc.getSelectedFiles(); + if(null==files) doExit(1); } for (int i=0;i<files.length;i++) { String name = files[i].getName(); // Loop through the widget definition XML files. But exclude the example widget file. - if (name.endsWith(".xml") && !name.equalsIgnoreCase("EXAMPLE.xml")) { + if (name.endsWith(".xml") && !name.equals("EXAMPLE.xml")) { try { System.out.println("Loading widget definition from " + name); Document document = new SAXReader().read("widget_definitions/" + name); @@ -847,7 +845,6 @@ private void loadXML() { JFileChooser fc = new JFileChooser(); - // Try to read in prefrences from the prefs.xml doc... if(sdir != null) fc.setCurrentDirectory(sdir); int returnVal = fc.showSaveDialog(this); @@ -860,17 +857,16 @@ int choice = JOptionPane.showConfirmDialog(this,"File \"" + file.getName() + "\" does not exist!.",alertmsg,JOptionPane.OK_OPTION); return; } - // file to save as and wether or not to compress it, now thats hard coded because i havent added a checkbox to the above filechooser xmlHandler.loadXML(file); } else { - System.out.println("Save canceled"); + System.out.println("Load canceled"); return; } } public void initGUI() { - if(sdir != null) this.setTitle(sdir.getName()); + if(sdir != null && sdir.getName() != "null" && sdir.getName() != "") this.setTitle(sdir.getName()); else this.setTitle("New App"); // something is going to be done with this... ImageIcon bjImage = new ImageIcon("bojangles.png"); Index: bojangles/testAppPrefsDlg.java diff -u bojangles/testAppPrefsDlg.java:1.6 bojangles/testAppPrefsDlg.java:1.7 --- bojangles/testAppPrefsDlg.java:1.6 Tue Sep 3 14:01:53 2002 +++ bojangles/testAppPrefsDlg.java Wed Sep 4 14:02:59 2002 @@ -144,6 +144,7 @@ pathStr = path.getText(); browserStr = browser.getText(); ready = true; + super.notifyAll(); } // Variables declaration - do not modify |