Thread: [Bojangles-cvs] cvs: bojangles / MainWindow.java
Status: Alpha
Brought to you by:
nehresma
From: kai5263499 <boj...@li...> - 2002-08-14 14:52:37
|
kai5263499 Wed Aug 14 07:52:36 2002 EDT Modified files: /bojangles MainWindow.java Log: Added the actual save function to the save XML button. Still need to check for pre-existing file and confirm overwrite and nit-picky things like that. Index: bojangles/MainWindow.java diff -u bojangles/MainWindow.java:1.9 bojangles/MainWindow.java:1.10 --- bojangles/MainWindow.java:1.9 Sun Aug 11 16:39:42 2002 +++ bojangles/MainWindow.java Wed Aug 14 07:52:36 2002 @@ -35,11 +35,12 @@ private DefaultTreeModel treeModel = null; private DisplayPanel displayPanel; private Hashtable widgetDefinitions = new Hashtable(); - private JButton jButton1, addProperty; + private JButton jButton1, jButton2, addProperty; private JComboBox propertiesComboBox; - private JMenu treeAddMenu, fileMenu, containerMenu, componentMenu; + private JMenu treeAddMenu, fileMenu, helpMenu, containerMenu, componentMenu; private JMenuBar jMenuBar1; private JMenuItem exitMenuItem; + private JMenuItem genhelpMenuItem; private JPopupMenu treePopup; private JScrollPane jScrollPane1; private JSplitPane jSplitPane1, jSplitPane2; @@ -53,6 +54,11 @@ private String currentElement = null; private XmlHandler xmlHandler = new XmlHandler(); + /** + * File variables for opening/closing a previously designed app + */ + private File selectedfile; + /** Creates new form MainWindow */ public MainWindow() { loadWidgetDefinitions(); @@ -96,6 +102,10 @@ } } + private void initFileBrowser() { + + } + private void initComponents() { treePopup = new javax.swing.JPopupMenu(); treeAddMenu = new javax.swing.JMenu(); @@ -109,12 +119,15 @@ propertiesTable = new javax.swing.JTable(); jToolBar1 = new javax.swing.JToolBar(); jButton1 = new javax.swing.JButton(); + jButton2 = new javax.swing.JButton(); addProperty = new javax.swing.JButton("Add"); propertiesComboBox = new javax.swing.JComboBox(); jMenuBar1 = new javax.swing.JMenuBar(); fileMenu = new javax.swing.JMenu(); + helpMenu = new javax.swing.JMenu(); exitMenuItem = new javax.swing.JMenuItem(); - + genhelpMenuItem = new javax.swing.JMenuItem(); + treePopup.addPopupMenuListener(new javax.swing.event.PopupMenuListener() { public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) { } public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) { } @@ -210,8 +223,17 @@ } }); - jToolBar1.add(jButton1); + jButton2.setBackground(new java.awt.Color(153, 153, 255)); + jButton2.setText("save XML"); + jButton2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton2ActionPerformed(evt); + } + }); + jToolBar1.add(jButton1); + jToolBar1.add(jButton2); + getContentPane().add(jToolBar1, java.awt.BorderLayout.NORTH); fileMenu.setText("File"); @@ -222,8 +244,18 @@ } }); + helpMenu.setText("Help"); + genhelpMenuItem.setText("General Help"); + genhelpMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + genhelpMenuItemActionPerformed(evt); + } + }); + fileMenu.add(exitMenuItem); + helpMenu.add(genhelpMenuItem); jMenuBar1.add(fileMenu); + jMenuBar1.add(helpMenu); setJMenuBar(jMenuBar1); pack(); @@ -274,11 +306,27 @@ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { xmlHandler.printXML(); -System.out.println(propertiesTable.getColumnModel().getColumn(0).getCellRenderer()); + System.out.println(propertiesTable.getColumnModel().getColumn(0).getCellRenderer()); } + private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { + try { + FileDialog fb = new FileDialog(this, "Save as", FileDialog.SAVE); + fb.setVisible(true); + String file = new String(fb.getDirectory() + fb.getFile()); + xmlHandler.saveXML(file); + } + catch (Exception e) { + e.printStackTrace(); + } + } + private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) { System.exit(0); + } + + private void genhelpMenuItemActionPerformed(java.awt.event.ActionEvent evt) { + // TODO here... } public void elementFocusChanged(String path) { |
From: kai5263499 <boj...@li...> - 2002-08-20 12:32:44
Attachments:
kai5263499-20020820053242.txt
|
kai5263499 Tue Aug 20 05:32:42 2002 EDT Modified files: /bojangles MainWindow.java Log: Stuff I forgot yesterday... (I thought i comitted it when I comitted XmlHandler)Oh well... |
From: kai5263499 <boj...@li...> - 2002-08-20 16:38:35
|
kai5263499 Tue Aug 20 09:38:33 2002 EDT Modified files: /bojangles MainWindow.java Log: Lunch update... Added window naming stuff. Index: bojangles/MainWindow.java diff -u bojangles/MainWindow.java:1.12 bojangles/MainWindow.java:1.13 --- bojangles/MainWindow.java:1.12 Tue Aug 20 05:32:41 2002 +++ bojangles/MainWindow.java Tue Aug 20 09:38:30 2002 @@ -39,7 +39,7 @@ private JComboBox propertiesComboBox; private JMenu treeAddMenu, fileMenu, helpMenu, containerMenu, componentMenu; private JMenuBar jMenuBar1; - private JMenuItem exitMenuItem, treeDelMenuItem, genhelpMenuItem; + private JMenuItem exitMenuItem, saveMenuItem, treeDelMenuItem, genhelpMenuItem; private JPopupMenu treePopup; private JScrollPane jScrollPane1; private JSplitPane jSplitPane1, jSplitPane2; @@ -60,6 +60,7 @@ private boolean prefsSet = false; private File sdir = null; private boolean appModified = false; + private String curTitle= "New Window"; /** Creates new form MainWindow */ public MainWindow() { @@ -126,6 +127,7 @@ fileMenu = new javax.swing.JMenu(); helpMenu = new javax.swing.JMenu(); exitMenuItem = new javax.swing.JMenuItem(); + saveMenuItem = new javax.swing.JMenuItem(); genhelpMenuItem = new javax.swing.JMenuItem(); treePopup.addPopupMenuListener(new javax.swing.event.PopupMenuListener() { @@ -258,7 +260,13 @@ exitMenuItemActionPerformed(evt); } }); - + saveMenuItem.setText("Save"); + saveMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + saveMenuItemActionPerformed(evt); + } + }); + helpMenu.setText("Help"); genhelpMenuItem.setText("General Help"); genhelpMenuItem.addActionListener(new java.awt.event.ActionListener() { @@ -268,6 +276,7 @@ }); fileMenu.add(exitMenuItem); + fileMenu.add(saveMenuItem); helpMenu.add(genhelpMenuItem); jMenuBar1.add(fileMenu); jMenuBar1.add(helpMenu); @@ -334,7 +343,7 @@ saveXML(); } // Redundant? Redundant? - if(this.appModified == false) { + if(!this.appModified) { if(this.prefsSet) { return; } @@ -346,9 +355,15 @@ } private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) { + if(this.appModified) { + } System.exit(0); } + private void saveMenuItemActionPerformed(java.awt.event.ActionEvent evt) { + saveXML(); + } + private void genhelpMenuItemActionPerformed(java.awt.event.ActionEvent evt) { // TODO here... } @@ -357,7 +372,7 @@ // Kill de widget! System.out.println(evt.toString()); System.out.println("There is no spoon..."); - this.appModified = true; + appModified(true); } public void elementFocusChanged(String path) { @@ -386,7 +401,7 @@ public void tableChanged(TableModelEvent e) { if (null == currentElement) return; if (null == e) return; - this.appModified = true; + appModified(true); int row = e.getFirstRow(); String propertyName = (String)propertiesTableModel.getValueAt(row, 1); @@ -494,8 +509,8 @@ String parentPath = (String)h.get("path"); treeNode = new DefaultMutableTreeNode(name); treeModel.insertNodeInto(treeNode, parentTreeNode, parentTreeNode.getChildCount()); - path = xmlHandler.addElement(parentPath, name, null); + appModified(true); } // add the widget's defined properties to the application's XML document @@ -599,7 +614,7 @@ String name = files[i].getName(); if (name.endsWith(".xml")) { try { - System.out.println("loading widget definition from " + name); + System.out.println("Loading widget definition from " + name); Document document = new SAXReader().read("widget_definitions/" + name); String outerType = document.selectSingleNode("/widget/outer_type").getText(); widgetDefinitions.put(outerType, document); @@ -626,9 +641,15 @@ } } + private void appModified(boolean moded) { + appModified = moded; + if(moded) this.setTitle(curTitle + "*"); + else this.setTitle(curTitle); + } + private void saveXML() { JFileChooser fc = new JFileChooser(); - if(this.sdir != null) fc.setCurrentDirectory(this.sdir); + if(sdir != null) fc.setCurrentDirectory(sdir); // Try to read in prefrences from the prefs.xml doc... /* else { @@ -640,13 +661,14 @@ int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); - this.sdir = file.getAbsoluteFile(); + sdir = file.getAbsoluteFile(); if (file.exists()) { - String suremsg = "Are you sure you want to overwrite " + file + " ?"; - int choice = JOptionPane.showConfirmDialog(this,"File will be overwritten.",suremsg,JOptionPane.YES_NO_OPTION); + String suremsg = "Are you sure you want to overwrite?"; + int choice = JOptionPane.showConfirmDialog(this,"File \"" + file.getName() + "\" will be overwritten.",suremsg,JOptionPane.YES_NO_OPTION); if(choice == JOptionPane.NO_OPTION) return; - this.appModified = false; - System.out.println("Saved " + file); + System.out.println("Saved " + file.getName()); + curTitle = file.getName(); + appModified(false); } xmlHandler.saveXML(file); } else { @@ -657,6 +679,7 @@ public static void main(String[] args) { MainWindow win = new MainWindow(); + win.setTitle("New App"); win.show(); } } |
From: kai5263499 <boj...@li...> - 2002-08-20 22:32:26
|
kai5263499 Tue Aug 20 15:32:24 2002 EDT Modified files: /bojangles MainWindow.java Log: Prefrences addition... Index: bojangles/MainWindow.java diff -u bojangles/MainWindow.java:1.13 bojangles/MainWindow.java:1.14 --- bojangles/MainWindow.java:1.13 Tue Aug 20 09:38:30 2002 +++ bojangles/MainWindow.java Tue Aug 20 15:32:24 2002 @@ -61,9 +61,12 @@ private File sdir = null; private boolean appModified = false; private String curTitle= "New Window"; + private String lastfile, prefHost, prefPort, prefPath, prefBrowser; + private Document prefDocument = null; /** Creates new form MainWindow */ public MainWindow() { + loadPrefrences(); loadWidgetDefinitions(); initComponents(); initPopupMenus(); @@ -275,8 +278,8 @@ } }); - fileMenu.add(exitMenuItem); fileMenu.add(saveMenuItem); + fileMenu.add(exitMenuItem); helpMenu.add(genhelpMenuItem); jMenuBar1.add(fileMenu); jMenuBar1.add(helpMenu); @@ -476,7 +479,7 @@ } Container parent = null; - // if we are the first thing in the tree, then set the parent equal to the displayPanel + // if we are the first thing in the tree, t hen set the parent equal to the displayPanel if (null == popupOnTreeNode) parent = displayPanel; else { @@ -603,7 +606,6 @@ } private void loadWidgetDefinitions() { - File[] files = new File("widget_definitions").listFiles(); if (null == files) { System.out.println("Unable to find the widget definitions."); @@ -612,7 +614,8 @@ for (int i=0;i<files.length;i++) { String name = files[i].getName(); - if (name.endsWith(".xml")) { + // Loop through the widget definition XML files. But exclude the example widget file. + if (name.endsWith(".xml") && !name.equalsIgnoreCase("EXAMPLE.xml")) { try { System.out.println("Loading widget definition from " + name); Document document = new SAXReader().read("widget_definitions/" + name); @@ -627,17 +630,29 @@ } private void loadPrefrences() { - File files = new File("prefs.xml"); - if (null == files) { - System.out.println("No saved prefrences..."); - } try { + File prefFile = new File("prefs.xml"); + if (null == prefFile) { + System.out.println("No saved prefrences..."); + // Lets make a document anyway to write collected prefrences to... + // Document prefDocument = new SAXDocument(); + prefDocument = DocumentHelper.createDocument(); + } + else { System.out.println("Loading prefrences from prefs.xml"); - Document document = new SAXReader().read("prefs.xml"); - } - catch (DocumentException e) { + prefDocument = new SAXReader().read("prefs.xml"); + sdir = new File(prefDocument.selectSingleNode("/prefrences/prefSaveDir").getText()); + lastfile = prefDocument.selectSingleNode("/prefrences/lastFileSaved").getText(); + prefBrowser = prefDocument.selectSingleNode("/prefrences/browser").getText(); + prefHost = prefDocument.selectSingleNode("/prefrences/testHost").getText(); + prefPort = prefDocument.selectSingleNode("/prefrences/testPort").getText(); + prefPath = prefDocument.selectSingleNode("/prefrences/testPath").getText(); + System.out.println("URL: http://" + prefHost + ":" + prefPort + "/" + prefPath + "/" + lastfile); + System.out.println("Load ok!"); + } + } + catch (Exception e) { e.printStackTrace(); - System.exit(1); } } @@ -649,19 +664,14 @@ private void saveXML() { JFileChooser fc = new JFileChooser(); - if(sdir != null) fc.setCurrentDirectory(sdir); // Try to read in prefrences from the prefs.xml doc... - /* - else { - if(System.getProperty("os.name").equalsIgnoreCase("Linux")) { - fc.setCurrentDirectory(); - } - }*/ + if(sdir != null) fc.setCurrentDirectory(sdir); int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); sdir = file.getAbsoluteFile(); + //prefDocument if (file.exists()) { String suremsg = "Are you sure you want to overwrite?"; int choice = JOptionPane.showConfirmDialog(this,"File \"" + file.getName() + "\" will be overwritten.",suremsg,JOptionPane.YES_NO_OPTION); |
From: nehresma <boj...@li...> - 2002-08-22 02:51:31
|
nehresma Wed Aug 21 19:51:30 2002 EDT Modified files: /bojangles MainWindow.java Log: check to make sure the preferences file exists before attempting to read from it. Index: bojangles/MainWindow.java diff -u bojangles/MainWindow.java:1.14 bojangles/MainWindow.java:1.15 --- bojangles/MainWindow.java:1.14 Tue Aug 20 15:32:24 2002 +++ bojangles/MainWindow.java Wed Aug 21 19:51:30 2002 @@ -16,16 +16,6 @@ import org.dom4j.io.*; -/* - * MainWindow.java - * - * Created on June 24, 2002, 8:46 PM - */ - -/** - * - * @author Nathan Ehresman - */ public class MainWindow extends javax.swing.JFrame implements ElementFocusListener, TableModelListener { /** * The correlation table linking JTreeNode, Widget, and XML path. @@ -630,36 +620,36 @@ } private void loadPrefrences() { - try { - File prefFile = new File("prefs.xml"); - if (null == prefFile) { - System.out.println("No saved prefrences..."); - // Lets make a document anyway to write collected prefrences to... - // Document prefDocument = new SAXDocument(); - prefDocument = DocumentHelper.createDocument(); - } - else { - System.out.println("Loading prefrences from prefs.xml"); - prefDocument = new SAXReader().read("prefs.xml"); - sdir = new File(prefDocument.selectSingleNode("/prefrences/prefSaveDir").getText()); - lastfile = prefDocument.selectSingleNode("/prefrences/lastFileSaved").getText(); - prefBrowser = prefDocument.selectSingleNode("/prefrences/browser").getText(); - prefHost = prefDocument.selectSingleNode("/prefrences/testHost").getText(); - prefPort = prefDocument.selectSingleNode("/prefrences/testPort").getText(); - prefPath = prefDocument.selectSingleNode("/prefrences/testPath").getText(); - System.out.println("URL: http://" + prefHost + ":" + prefPort + "/" + prefPath + "/" + lastfile); - System.out.println("Load ok!"); - } - } - catch (Exception e) { - e.printStackTrace(); + try { + File prefFile = new File("prefs.xml"); + if (null == prefFile) + return; + else if (!prefFile.exists()) { + System.out.println("No saved prefrences..."); + // Lets make a document anyway to write collected prefrences to... + // Document prefDocument = new SAXDocument(); + prefDocument = DocumentHelper.createDocument(); + } else { + System.out.println("Loading prefrences from prefs.xml"); + prefDocument = new SAXReader().read("prefs.xml"); + sdir = new File(prefDocument.selectSingleNode("/prefrences/prefSaveDir").getText()); + lastfile = prefDocument.selectSingleNode("/prefrences/lastFileSaved").getText(); + prefBrowser = prefDocument.selectSingleNode("/prefrences/browser").getText(); + prefHost = prefDocument.selectSingleNode("/prefrences/testHost").getText(); + prefPort = prefDocument.selectSingleNode("/prefrences/testPort").getText(); + prefPath = prefDocument.selectSingleNode("/prefrences/testPath").getText(); + System.out.println("URL: http://" + prefHost + ":" + prefPort + "/" + prefPath + "/" + lastfile); + System.out.println("Load ok!"); + } + } catch (Exception e) { + e.printStackTrace(); } } private void appModified(boolean moded) { - appModified = moded; - if(moded) this.setTitle(curTitle + "*"); - else this.setTitle(curTitle); + appModified = moded; + if(moded) this.setTitle(curTitle + "*"); + else this.setTitle(curTitle); } private void saveXML() { |
From: nehresma <boj...@li...> - 2002-08-22 03:24:34
|
nehresma Wed Aug 21 20:24:33 2002 EDT Modified files: /bojangles MainWindow.java Log: removed some debug code Index: bojangles/MainWindow.java diff -u bojangles/MainWindow.java:1.15 bojangles/MainWindow.java:1.16 --- bojangles/MainWindow.java:1.15 Wed Aug 21 19:51:30 2002 +++ bojangles/MainWindow.java Wed Aug 21 20:24:32 2002 @@ -324,7 +324,6 @@ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { xmlHandler.printXML(); - System.out.println(propertiesTable.getColumnModel().getColumn(0).getCellRenderer()); } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { @@ -333,16 +332,16 @@ private void testAppBtnActionPerformed(java.awt.event.ActionEvent evt) { if(this.appModified){ - saveXML(); + saveXML(); } // Redundant? Redundant? if(!this.appModified) { - if(this.prefsSet) { - return; - } - else { - //testAppPrefsDlg testappprefsdlg = new testAppPrefsDlg(); - } + if(this.prefsSet) { + return; + } + else { + //testAppPrefsDlg testappprefsdlg = new testAppPrefsDlg(); + } } else return; } |
From: kai5263499 <boj...@li...> - 2002-08-22 21:08:27
Attachments:
kai5263499-20020822140827.txt
|
kai5263499 Thu Aug 22 14:08:27 2002 EDT Modified files: /bojangles MainWindow.java Log: Cleaned up some things (added a doExit function that should handle all exits) and tried to start making a prefs.xml file if one didnt exist... |
From: nehresma <boj...@li...> - 2002-08-25 01:02:13
|
nehresma Sat Aug 24 18:02:12 2002 EDT Modified files: /bojangles MainWindow.java Log: added handling of windowClosing back in (thanks to dman to pointing this out) Index: bojangles/MainWindow.java diff -u bojangles/MainWindow.java:1.19 bojangles/MainWindow.java:1.20 --- bojangles/MainWindow.java:1.19 Sat Aug 24 17:26:31 2002 +++ bojangles/MainWindow.java Sat Aug 24 18:02:11 2002 @@ -155,6 +155,11 @@ treeDelMenuItemActionPerformed(evt); } }); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + System.exit(0); + } + }); jSplitPane1.setDividerLocation(680); jSplitPane1.setDividerSize(6); |
From: kai5263499 <boj...@li...> - 2002-08-26 18:27:20
|
kai5263499 Mon Aug 26 11:27:19 2002 EDT Modified files: /bojangles MainWindow.java Log: Post-lunch update... Changed the window close listner to go through doExit to exit. Index: bojangles/MainWindow.java diff -u bojangles/MainWindow.java:1.20 bojangles/MainWindow.java:1.21 --- bojangles/MainWindow.java:1.20 Sat Aug 24 18:02:11 2002 +++ bojangles/MainWindow.java Mon Aug 26 11:27:19 2002 @@ -157,7 +157,7 @@ }); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { - System.exit(0); + doExit(0); } }); @@ -729,8 +729,8 @@ } // Add custom size settings to document (this one is for Nathan ;-) - //prefDocument.selectSingleNode("/prefrences/sizes/PTHeight").setText(String.valueOf(propertiesTable.getPreferredScrollableViewportSize().height)); - //prefDocument.selectSingleNode("/prefrences/sizes/PTWidth").setText(String.valueOf(propertiesTable.getPreferredScrollableViewportSize().width)); + prefDocument.selectSingleNode("/prefrences/sizes/PTHeight").setText(String.valueOf(propertiesTable.getPreferredScrollableViewportSize().height)); + prefDocument.selectSingleNode("/prefrences/sizes/PTWidth").setText(String.valueOf(propertiesTable.getPreferredScrollableViewportSize().width)); // Save prefs.xml file try { |
From: kai5263499 <boj...@li...> - 2002-09-12 03:20:12
|
kai5263499 Wed Sep 11 20:20:11 2002 EDT Modified files: /bojangles MainWindow.java Log: Added a statusbar to display information we want the user to see without interrupting their workflow (like the "only one page" thing) WW Index: bojangles/MainWindow.java diff -u bojangles/MainWindow.java:1.30 bojangles/MainWindow.java:1.31 --- bojangles/MainWindow.java:1.30 Fri Sep 6 07:49:05 2002 +++ bojangles/MainWindow.java Wed Sep 11 20:20:10 2002 @@ -45,6 +45,7 @@ private JTree widgetTree; private PropertiesTableModel propertiesTableModel = null; private TreePath curSelectedItem; + private JLabel statusBar; /** * The XML path to the currently selected widget. */ @@ -144,6 +145,7 @@ jScrollPane1 = new javax.swing.JScrollPane(); propertiesTable = new javax.swing.JTable(); jToolBar1 = new javax.swing.JToolBar(); + JLabel statusBar = new JLabel("Welcome to the jungle."); jButton1 = new javax.swing.JButton(); openBtn = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); @@ -254,7 +256,8 @@ jSplitPane1.setRightComponent(jScrollPane1); getContentPane().add(jSplitPane1, java.awt.BorderLayout.CENTER); - + getContentPane().add(statusBar, java.awt.BorderLayout.SOUTH); + jButton1.setBackground(new java.awt.Color(153, 153, 255)); jButton1.setText("print XML"); jButton1.addActionListener(new java.awt.event.ActionListener() { @@ -360,7 +363,7 @@ curSelectedItem = tp; if (-1 == row) { if (xmlHandler.doesPathExist(null)) { - JOptionPane.showMessageDialog(null, "This application already contains a top level widget.", "Error", JOptionPane.ERROR_MESSAGE); + statusBar.setText("This application already contains a top level widget."); return; } // menu was clicked on no particular row -- only enable the containers |
From: kai5263499 <boj...@li...> - 2002-09-12 20:26:13
Attachments:
kai5263499-20020912132609.txt
|
kai5263499 Thu Sep 12 13:26:09 2002 EDT Modified files: /bojangles MainWindow.java Log: Fixed the prefs dialog thing. Next I'll work on getting more prefrences to set (I'm thinking about using tabs). |
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); } |
From: kai5263499 <boj...@li...> - 2002-09-30 21:05:04
|
kai5263499 Mon Sep 30 14:05:01 2002 EDT Modified files: /bojangles MainWindow.java Log: Just need to get it out of the JTree and we will be set... Index: bojangles/MainWindow.java diff -u bojangles/MainWindow.java:1.34 bojangles/MainWindow.java:1.35 --- bojangles/MainWindow.java:1.34 Wed Sep 25 13:54:44 2002 +++ bojangles/MainWindow.java Mon Sep 30 14:05:00 2002 @@ -509,12 +509,16 @@ JPanel parent_widget = (JPanel)p.get("widget"); JPanel com_widget = (JPanel)h.get("widget"); - // KILL DE WIDGET! + // KILL DE WIDGET! and repaint + //widgetTree.remove(row); + widgetTree.toString(); parent_widget.remove(com_widget); - // remove rest here + parent_widget.repaint(); + widgetTree.repaint(); + + xmlHandler.removeElement(path); + System.out.println("I want to kill " + row); - // 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); |
From: kai5263499 <boj...@li...> - 2002-10-02 18:59:04
|
kai5263499 Wed Oct 2 11:59:03 2002 EDT Modified files: /bojangles MainWindow.java Log: Finally got the entire deleting of a widget working... Now on to opening a document! Index: bojangles/MainWindow.java diff -u bojangles/MainWindow.java:1.35 bojangles/MainWindow.java:1.36 --- bojangles/MainWindow.java:1.35 Mon Sep 30 14:05:00 2002 +++ bojangles/MainWindow.java Wed Oct 2 11:59:02 2002 @@ -45,7 +45,6 @@ private JTree widgetTree; private PropertiesTableModel propertiesTableModel = null; private TreePath curSelectedItem; - protected JLabel statusBar; /** * The XML path to the currently selected widget. */ @@ -148,7 +147,6 @@ jScrollPane1 = new javax.swing.JScrollPane(); propertiesTable = new javax.swing.JTable(); jToolBar1 = new javax.swing.JToolBar(); - JLabel statusBar = new JLabel("Welcome to the jungle."); jButton1 = new javax.swing.JButton(); openBtn = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); @@ -260,7 +258,6 @@ jSplitPane1.setRightComponent(jScrollPane1); getContentPane().add(jSplitPane1, java.awt.BorderLayout.CENTER); - getContentPane().add(statusBar, java.awt.BorderLayout.SOUTH); jButton1.setBackground(new java.awt.Color(153, 153, 255)); jButton1.setText("print XML"); @@ -375,7 +372,7 @@ curSelectedItem = tp; if (-1 == row) { if (xmlHandler.doesPathExist(null)) { - statusBar.setText("This application already contains a top level widget."); + JOptionPane.showMessageDialog(null, "This application already contains a top level widget.", "Error", JOptionPane.ERROR_MESSAGE); return; } // menu was clicked on no particular row -- only enable the containers @@ -510,8 +507,7 @@ JPanel com_widget = (JPanel)h.get("widget"); // KILL DE WIDGET! and repaint - //widgetTree.remove(row); - widgetTree.toString(); + treeModel.removeNodeFromParent(n); parent_widget.remove(com_widget); parent_widget.repaint(); widgetTree.repaint(); @@ -651,7 +647,7 @@ path = xmlHandler.addElement(null, rootText, null); } else { if (!(parent instanceof Widget)) { - System.out.println("Attempt to add child widget to a parent that is not a widget!"); + JOptionPane.showMessageDialog(null, "Attempt to add child widget to a parent that is not a widget!", "Error", JOptionPane.ERROR_MESSAGE); return; } name = name+System.currentTimeMillis(); @@ -661,6 +657,7 @@ String parentPath = (String)h.get("path"); treeNode = new DefaultMutableTreeNode(name); treeModel.insertNodeInto(treeNode, parentTreeNode, parentTreeNode.getChildCount()); + //widgetTree.expandPath(; path = xmlHandler.addElement(parentPath, name, null); } @@ -959,8 +956,6 @@ TD_port = new javax.swing.JTextField(); TD_path = new javax.swing.JTextField(); JLabel jLabel5 = new javax.swing.JLabel(); - JLabel statusBar = new javax.swing.JLabel(); - dlgFrame.getContentPane().setLayout(null); jLabel1.setFont(new java.awt.Font("Dialog", 1, 18)); @@ -1024,8 +1019,6 @@ dlgFrame.getContentPane().add(jLabel5); jLabel5.setBounds(50, 50, 280, 16); - dlgFrame.getContentPane().add(statusBar); - statusBar.setBounds(0, 230, 400, 20); pack(); dlgFrame.setSize(407,269); dlgFrame.setResizable(false); |
From: kai5263499 <boj...@li...> - 2002-10-04 21:05:11
|
kai5263499 Fri Oct 4 14:05:08 2002 EDT Modified files: /bojangles MainWindow.java Log: Cleaned up some things and started work on the file->open stuff... Index: bojangles/MainWindow.java diff -u bojangles/MainWindow.java:1.36 bojangles/MainWindow.java:1.37 --- bojangles/MainWindow.java:1.36 Wed Oct 2 11:59:02 2002 +++ bojangles/MainWindow.java Fri Oct 4 14:05:06 2002 @@ -909,26 +909,40 @@ } private void loadXML() { - - JFileChooser fc = new JFileChooser(); - if(sdir != null) fc.setCurrentDirectory(sdir); - - int returnVal = fc.showSaveDialog(this); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - sdir = file.getAbsoluteFile(); - - if (!file.exists()) { - String alertmsg = "File doesn't exist!"; - int choice = JOptionPane.showConfirmDialog(this,"File \"" + file.getName() + "\" does not exist!.",alertmsg,JOptionPane.OK_OPTION); - return; - } - xmlHandler.loadXML(file); - } else { - System.out.println("Load canceled"); - return; + try{ + JFileChooser fc = new JFileChooser(); + if(sdir != null) fc.setCurrentDirectory(sdir); + int returnVal = fc.showSaveDialog(this); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = fc.getSelectedFile(); + sdir = file.getAbsoluteFile(); + + if (!file.exists()) { + String alertmsg = "File doesn't exist!"; + int choice = JOptionPane.showConfirmDialog(this,"File \"" + file.getAbsolutePath() + "\" does not exist!.",alertmsg,JOptionPane.OK_OPTION); + return; + } + // Make a psudo document to create our main document from + Document tempdoc = new SAXReader().read(file.getAbsolutePath()); + List list = tempdoc.selectNodes("/"); + ListIterator li = list.listIterator(); + while (li.hasNext()) { + Node thinge = (Node)li.next(); + if(thingie.SelectSingleNode("/widget/class") == "container") { + //DIG! + } + else { + //add it... + } + } + } else { + System.out.println("Load canceled"); + return; + } + } + catch (Exception e) { + e.printStackTrace(); } - } public void initGUI() { |