[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) { |