List of usage examples for javax.swing JInternalFrame getContentPane
public Container getContentPane()
From source file:mondrian.gui.Workbench.java
private void aboutMenuItemActionPerformed(ActionEvent evt) { try {/*from ww w .j a va2s. c o m*/ JEditorPane jEditorPane = new JEditorPane( myClassLoader.getResource(getResourceConverter().getGUIReference("version")).toString()); jEditorPane.setEditable(false); JScrollPane jScrollPane = new JScrollPane(jEditorPane); JPanel jPanel = new JPanel(); jPanel.setLayout(new java.awt.BorderLayout()); jPanel.add(jScrollPane, java.awt.BorderLayout.CENTER); JInternalFrame jf = new JInternalFrame(); jf.setTitle("About"); jf.getContentPane().add(jPanel); Dimension screenSize = this.getSize(); int aboutW = 400; int aboutH = 300; int width = (screenSize.width / 2) - (aboutW / 2); int height = (screenSize.height / 2) - (aboutH / 2) - 100; jf.setBounds(width, height, aboutW, aboutH); jf.setClosable(true); desktopPane.add(jf); jf.setVisible(true); jf.show(); } catch (Exception ex) { LOGGER.error("aboutMenuItemActionPerformed", ex); } }
From source file:mondrian.gui.Workbench.java
private void viewXMLMenuItemActionPerformed(ActionEvent evt) { JInternalFrame jf = desktopPane.getSelectedFrame(); boolean oldValue = viewXmlMenuItem.getState(); if (jf != null && jf.getContentPane().getComponent(0) instanceof SchemaExplorer) { SchemaExplorer se = (SchemaExplorer) jf.getContentPane().getComponent(0); // Call schema explorer's view xml event and update the workbench's // view menu accordingly' ((JCheckBoxMenuItem) evt.getSource()).setSelected(se.editMode(evt)); return;//from w w w.ja v a2 s . com } viewXmlMenuItem.setSelected(!oldValue); }
From source file:mondrian.gui.Workbench.java
private void saveAsMenuItemActionPerformed(ActionEvent evt) { JInternalFrame jf = desktopPane.getSelectedFrame(); if (jf != null && jf.getContentPane().getComponent(0) instanceof SchemaExplorer) { SchemaExplorer se = (SchemaExplorer) jf.getContentPane().getComponent(0); java.io.File schemaFile = se.getSchemaFile(); java.io.File oldSchemaFile = schemaFile; java.io.File suggSchemaFile = new File( schemaFile == null ? se.getSchema().name.trim() + ".xml" : schemaFile.getName()); MondrianGuiDef.Schema schema = se.getSchema(); JFileChooser jfc = new JFileChooser(); MondrianProperties.instance();/* ww w . j av a2s . co m*/ jfc.setSelectedFile(suggSchemaFile); if (!isSchemaValid(schema)) { // the schema would not be re-loadable. Abort save. return; } if (jfc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { try { schemaFile = jfc.getSelectedFile(); if (!oldSchemaFile.equals(schemaFile) && schemaFile.exists()) { // new file already exists, check for overwrite int answer = JOptionPane.showConfirmDialog(null, getResourceConverter().getFormattedString("workbench.saveAs.schema.confirm", "{0} schema file already exists. Do you want to replace it?", schemaFile.getAbsolutePath()), getResourceConverter().getString("workbench.saveAs.schema.confirm.title", "Save As"), JOptionPane.YES_NO_OPTION); if (answer == 1) { // no=1 ; yes=0 return; } } if (se.isNewFile() && !oldSchemaFile.equals(schemaFile)) { oldSchemaFile.delete(); } if (se.isNewFile()) { se.setNewFile(false); } se.setDirty(false); se.setDirtyFlag(false); XMLOutput out = new XMLOutput(new java.io.FileWriter(jfc.getSelectedFile())); out.setAlwaysQuoteCData(true); out.setIndentString(" "); schema.displayXML(out); se.setSchemaFile(schemaFile); se.setTitle(); // sets title of iframe setLastUsed(jfc.getSelectedFile().getName(), jfc.getSelectedFile().toURI().toURL().toString()); // Update menu item with new file name, then update catalog // list for mdx queries JMenuItem sMenuItem = schemaWindowMap.get(jf); String mtexttokens[] = sMenuItem.getText().split(" "); sMenuItem.setText(mtexttokens[0] + " " + se.getSchemaFile().getName()); // Schema menu item updated, now update mdx query windows // with updated catalog list. updateMDXCatalogList(); } catch (Exception ex) { LOGGER.error(ex); } } } }
From source file:mondrian.gui.Workbench.java
/** * Updates the JdbcMetaData for each SchemaExplorer contained in each Schema * Frame currently opened based on the JDBC preferences entered. */// w w w . j a v a 2 s. c o m private void resetWorkbench() { getNewJdbcMetadata(); Iterator<JInternalFrame> theSchemaFrames = schemaWindowMap.keySet().iterator(); while (theSchemaFrames.hasNext()) { JInternalFrame theSchemaFrame = theSchemaFrames.next(); SchemaExplorer theSchemaExplorer = (SchemaExplorer) theSchemaFrame.getContentPane().getComponent(0); File theFile = theSchemaExplorer.getSchemaFile(); checkSchemaFile(theFile); theSchemaExplorer.resetMetaData(jdbcMetaData); theSchemaExplorer.getTreeUpdater().update(); theSchemaFrame.updateUI(); } // EC: If the JDBC preferences entered then display a warning. displayWarningOnFailedConnection(); for (JInternalFrame jdbcFrame : jdbcWindows) { JdbcExplorer explorer = (JdbcExplorer) jdbcFrame.getContentPane().getComponent(0); explorer.resetMetaData(jdbcMetaData); jdbcFrame.setTitle(getResourceConverter().getFormattedString("workbench.new.JDBCExplorer.title", "JDBC Explorer - {0} {1}", jdbcMetaData.getDatabaseProductName(), jdbcMetaData.getJdbcConnectionUrl())); explorer.getTreeUpdater().update(); explorer.updateUI(); } }
From source file:mondrian.gui.Workbench.java
public void saveMenuItemActionPerformed(ActionEvent evt) { JInternalFrame jf = desktopPane.getSelectedFrame(); // Don't save if nothing there if (jf == null || jf.getContentPane() == null) { return;//from www .j ava 2s. c om } if (jf.getContentPane().getComponent(0) instanceof SchemaExplorer) { SchemaExplorer se = (SchemaExplorer) jf.getContentPane().getComponent(0); java.io.File schemaFile = se.getSchemaFile(); if (se.isNewFile()) { saveAsMenuItemActionPerformed(evt); return; } se.setDirty(false); se.setDirtyFlag(false); se.setTitle(); // sets title of iframe MondrianGuiDef.Schema schema = se.getSchema(); if (!isSchemaValid(schema)) { // the schema would not be re-loadable. Abort save. return; } MondrianProperties.instance(); try { XMLOutput out = new XMLOutput(new FileWriter(schemaFile)); out.setAlwaysQuoteCData(true); out.setIndentString(" "); schema.displayXML(out); setLastUsed(schemaFile.getName(), schemaFile.toURI().toURL().toString()); } catch (Exception ex) { LOGGER.error("saveMenuItemActionPerformed", ex); } } }
From source file:mondrian.gui.Workbench.java
private void closeAllSchemaFrames(boolean exitAfterClose) { try {/*from ww w. j a v a 2 s .c o m*/ for (JInternalFrame sf : getAllFrames()) { if (sf == null) { continue; } if (sf.getContentPane().getComponent(0) instanceof SchemaExplorer) { SchemaExplorer se = (SchemaExplorer) sf.getContentPane().getComponent(0); sf.setSelected(true); int response = confirmFrameClose(sf, se); switch (response) { case 2: // cancel return; case 3: // not dirty sf.setClosed(true); break; } } else { sf.setClosed(true); } } // exit Schema Workbench if no files are open if (((schemaWindowMap.keySet().size()) == 0) && exitAfterClose) { System.exit(0); } } catch (Exception ex) { LOGGER.error("closeAllSchemaFrames", ex); } }
From source file:mondrian.gui.Workbench.java
private void newQueryMenuItemActionPerformed(ActionEvent evt) { JMenuItem schemaMenuItem = schemaWindowMap.get(desktopPane.getSelectedFrame()); final JInternalFrame jf = new JInternalFrame(); jf.setTitle(getResourceConverter().getString("workbench.new.MDXQuery.title", "MDX Query")); QueryPanel qp = new QueryPanel(this); jf.getContentPane().add(qp); jf.setBounds(0, 0, 500, 480);/*w w w . ja v a 2 s. c o m*/ jf.setClosable(true); jf.setIconifiable(true); jf.setMaximizable(true); jf.setResizable(true); jf.setVisible(true); desktopPane.add(jf); jf.show(); try { jf.setSelected(true); } catch (Exception ex) { // do nothing LOGGER.error("newQueryMenuItemActionPerformed.setSelected", ex); } // add the mdx frame to this set of mdx frames for cascading method mdxWindows.add(jf); // create mdx menu item final javax.swing.JMenuItem queryMenuItem = new javax.swing.JMenuItem(); queryMenuItem.setText(getResourceConverter().getFormattedString("workbench.new.MDXQuery.menuitem", "{0} MDX", Integer.toString(windowMenuMapIndex))); queryMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { if (jf.isIcon()) { jf.setIcon(false); } else { jf.setSelected(true); } } catch (Exception ex) { LOGGER.error("queryMenuItem", ex); } } }); // disable mdx frame close operation to provide our handler // to remove frame object from mdxframeset before closing jf.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); jf.addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) { mdxWindows.remove(jf); jf.dispose(); // follow this by removing file from schemaWindowMap windowMenu.remove(queryMenuItem); return; } }); windowMenu.add(queryMenuItem, -1); windowMenu.add(jSeparator3, -1); windowMenu.add(cascadeMenuItem, -1); windowMenu.add(tileMenuItem, -1); windowMenu.add(minimizeMenuItem, -1); windowMenu.add(maximizeMenuItem, -1); windowMenu.add(closeAllMenuItem, -1); qp.setMenuItem(queryMenuItem); qp.setSchemaWindowMap(schemaWindowMap); qp.setWindowMenuIndex(windowMenuMapIndex++); if (schemaMenuItem != null) { qp.initConnection(schemaMenuItem.getText()); } else { JOptionPane.showMessageDialog(this, getResourceConverter().getString("workbench.new.MDXQuery.no.selection", "No Mondrian connection. Select a Schema to connect."), getResourceConverter().getString("workbench.new.MDXQuery.no.selection.title", "Alert"), JOptionPane.WARNING_MESSAGE); } }
From source file:mondrian.gui.Workbench.java
private void openSchemaFrame(File file, boolean newFile) { try {//w ww .j a va 2 s .c o m setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (!newFile) { // check if file not already open if (checkFileOpen(file)) { return; } // check if schema file exists if (!file.exists()) { JOptionPane.showMessageDialog(this, getResourceConverter().getFormattedString("workbench.open.schema.not.found", "{0} File not found.", file.getAbsolutePath()), getResourceConverter().getString("workbench.open.schema.not.found.title", "Alert"), JOptionPane.WARNING_MESSAGE); return; } // check if file is writable if (!file.canWrite()) { JOptionPane.showMessageDialog(this, getResourceConverter().getFormattedString("workbench.open.schema.not.writeable", "{0} is not writeable.", file.getAbsolutePath()), getResourceConverter().getString("workbench.open.schema.not.writeable.title", "Alert"), JOptionPane.WARNING_MESSAGE); return; } checkSchemaFile(file); } final JInternalFrame schemaFrame = new JInternalFrame(); schemaFrame.setTitle(getResourceConverter().getFormattedString("workbench.open.schema.title", "Schema - {0}", file.getName())); getNewJdbcMetadata(); schemaFrame.getContentPane().add(new SchemaExplorer(this, file, jdbcMetaData, newFile, schemaFrame)); String errorOpening = ((SchemaExplorer) schemaFrame.getContentPane().getComponent(0)).getErrMsg(); if (errorOpening != null) { JOptionPane.showMessageDialog(this, getResourceConverter().getFormattedString("workbench.open.schema.error", "Error opening schema - {0}.", errorOpening), getResourceConverter().getString("workbench.open.schema.error.title", "Error"), JOptionPane.ERROR_MESSAGE); schemaFrame.setClosed(true); return; } schemaFrame.setBounds(0, 0, 1000, 650); schemaFrame.setClosable(true); schemaFrame.setIconifiable(true); schemaFrame.setMaximizable(true); schemaFrame.setResizable(true); schemaFrame.setVisible(true); desktopPane.add(schemaFrame, javax.swing.JLayeredPane.DEFAULT_LAYER); schemaFrame.show(); schemaFrame.setMaximum(true); displayWarningOnFailedConnection(); final javax.swing.JMenuItem schemaMenuItem = new javax.swing.JMenuItem(); schemaMenuItem.setText(windowMenuMapIndex++ + " " + file.getName()); schemaMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { if (schemaFrame.isIcon()) { schemaFrame.setIcon(false); } else { schemaFrame.setSelected(true); } } catch (Exception ex) { LOGGER.error("schemaMenuItem", ex); } } }); windowMenu.add(schemaMenuItem, 0); windowMenu.setEnabled(true); windowMenu.add(jSeparator3, -1); windowMenu.add(cascadeMenuItem, -1); windowMenu.add(tileMenuItem, -1); windowMenu.add(minimizeMenuItem, -1); windowMenu.add(maximizeMenuItem, -1); windowMenu.add(closeAllMenuItem, -1); // add the file details in menu map schemaWindowMap.put(schemaFrame, schemaMenuItem); updateMDXCatalogList(); schemaFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); schemaFrame.addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) { if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) { SchemaExplorer se = (SchemaExplorer) schemaFrame.getContentPane().getComponent(0); int response = confirmFrameClose(schemaFrame, se); if (response == 3) { // not dirty if (se.isNewFile()) { se.getSchemaFile().delete(); } // default case for no save and not dirty schemaWindowMap.remove(schemaFrame); updateMDXCatalogList(); schemaFrame.dispose(); windowMenu.remove(schemaMenuItem); } } } }); schemaFrame.setFocusable(true); schemaFrame.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) { SchemaExplorer se = (SchemaExplorer) schemaFrame.getContentPane().getComponent(0); // update view menu based on schemaframe who gained // focus viewXmlMenuItem.setSelected(se.isEditModeXML()); } } public void focusLost(FocusEvent e) { if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) { SchemaExplorer se = (SchemaExplorer) schemaFrame.getContentPane().getComponent(0); // update view menu based on viewXmlMenuItem.setSelected(se.isEditModeXML()); } } }); viewXmlMenuItem.setSelected(false); } catch (Exception ex) { LOGGER.error("openSchemaFrame", ex); } finally { setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }
From source file:mondrian.gui.Workbench.java
/** * This method is called from within the constructor to * initialize the form.// ww w.jav a2 s. co m */ private void initComponents() { desktopPane = new javax.swing.JDesktopPane(); jToolBar1 = new javax.swing.JToolBar(); jToolBar2 = new javax.swing.JToolBar(); toolbarNewPopupMenu = new JPopupMenu(); toolbarNewButton = new javax.swing.JButton(); toolbarOpenButton = new javax.swing.JButton(); toolbarSaveButton = new javax.swing.JButton(); toolbarSaveAsButton = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); toolbarPreferencesButton = new javax.swing.JButton(); requireSchemaCheckboxMenuItem = new javax.swing.JCheckBoxMenuItem(); menuBar = new javax.swing.JMenuBar(); fileMenu = new javax.swing.JMenu(); newMenu = new javax.swing.JMenu(); newSchemaMenuItem = new javax.swing.JMenuItem(); newQueryMenuItem = new javax.swing.JMenuItem(); newJDBCExplorerMenuItem = new javax.swing.JMenuItem(); newSchemaMenuItem2 = new javax.swing.JMenuItem(); newQueryMenuItem2 = new javax.swing.JMenuItem(); newJDBCExplorerMenuItem2 = new javax.swing.JMenuItem(); openMenuItem = new javax.swing.JMenuItem(); preferencesMenuItem = new javax.swing.JMenuItem(); lastUsed1MenuItem = new javax.swing.JMenuItem(); lastUsed2MenuItem = new javax.swing.JMenuItem(); lastUsed3MenuItem = new javax.swing.JMenuItem(); lastUsed4MenuItem = new javax.swing.JMenuItem(); saveMenuItem = new javax.swing.JMenuItem(); saveAsMenuItem = new javax.swing.JMenuItem(); jSeparator1 = new javax.swing.JSeparator(); jSeparator2 = new javax.swing.JSeparator(); jSeparator3 = new javax.swing.JSeparator(); exitMenuItem = new javax.swing.JMenuItem(); windowMenu = new javax.swing.JMenu(); helpMenu = new javax.swing.JMenu(); editMenu = new javax.swing.JMenu(); cutMenuItem = new javax.swing.JMenuItem(new DefaultEditorKit.CutAction()); copyMenuItem = new javax.swing.JMenuItem(new DefaultEditorKit.CopyAction()); pasteMenuItem = new javax.swing.JMenuItem(new DefaultEditorKit.PasteAction()); deleteMenuItem = new javax.swing.JMenuItem( new AbstractAction(getResourceConverter().getString("workbench.menu.delete", "Delete")) { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { JInternalFrame jf = desktopPane.getSelectedFrame(); if (jf != null && jf.getContentPane().getComponent(0) instanceof SchemaExplorer) { SchemaExplorer se = (SchemaExplorer) jf.getContentPane().getComponent(0); TreePath tpath = se.tree.getSelectionPath(); se.delete(tpath); } } }); aboutMenuItem = new javax.swing.JMenuItem(); toolsMenu = new javax.swing.JMenu(); viewMenu = new javax.swing.JMenu(); viewXmlMenuItem = new javax.swing.JCheckBoxMenuItem(); setTitle(getResourceConverter().getString("workbench.panel.title", "Schema Workbench")); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { storeWorkbenchProperties(); storeDatabaseMeta(); closeAllSchemaFrames(true); } }); getContentPane().add(desktopPane, java.awt.BorderLayout.CENTER); newSchemaMenuItem2.setText(getResourceConverter().getString("workbench.menu.newSchema", "Schema")); newSchemaMenuItem2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { newSchemaMenuItemActionPerformed(evt); } }); newQueryMenuItem2.setText(getResourceConverter().getString("workbench.menu.newQuery", "MDX Query")); newQueryMenuItem2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { newQueryMenuItemActionPerformed(evt); } }); newJDBCExplorerMenuItem2 .setText(getResourceConverter().getString("workbench.menu.newJDBC", "JDBC Explorer")); newJDBCExplorerMenuItem2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { newJDBCExplorerMenuItemActionPerformed(evt); } }); toolbarNewPopupMenu.add(newSchemaMenuItem2); toolbarNewPopupMenu.add(newQueryMenuItem2); toolbarNewPopupMenu.add(newJDBCExplorerMenuItem2); jPanel2.setLayout(new java.awt.BorderLayout()); jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder()); jPanel2.setMaximumSize(new java.awt.Dimension(50, 28)); toolbarNewButton.setIcon( new javax.swing.ImageIcon(getClass().getResource(getResourceConverter().getGUIReference("new")))); toolbarNewButton.setToolTipText(getResourceConverter().getString("workbench.toolbar.new", "New")); toolbarNewButton.setBorderPainted(false); toolbarNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { toolbarNewPopupMenu.show(jPanel2, 0, jPanel2.getSize().height); } }); jToolBar2.setFloatable(false); jToolBar2.add(toolbarNewButton); jPanel2.add(jToolBar2, java.awt.BorderLayout.CENTER); toolbarNewArrowButton = new BasicArrowButton(SwingConstants.SOUTH); toolbarNewArrowButton.setToolTipText(getResourceConverter().getString("workbench.toolbar.newArrow", "New")); toolbarNewArrowButton.setBorderPainted(false); toolbarNewArrowButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { toolbarNewPopupMenu.show(jPanel2, 0, jPanel2.getSize().height); } }); jPanel2.add(toolbarNewArrowButton, java.awt.BorderLayout.EAST); jToolBar1.add(jPanel2, 0); toolbarOpenButton.setIcon( new javax.swing.ImageIcon(getClass().getResource(getResourceConverter().getGUIReference("open")))); toolbarOpenButton.setToolTipText(getResourceConverter().getString("workbench.toolbar.open", "Open")); toolbarOpenButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { openMenuItemActionPerformed(evt); } }); jToolBar1.add(toolbarOpenButton); toolbarSaveButton.setIcon( new javax.swing.ImageIcon(getClass().getResource(getResourceConverter().getGUIReference("save")))); toolbarSaveButton.setToolTipText(getResourceConverter().getString("workbench.toolbar.save", "Save")); toolbarSaveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveMenuItemActionPerformed(evt); } }); jToolBar1.add(toolbarSaveButton); toolbarSaveAsButton.setIcon(new javax.swing.ImageIcon( getClass().getResource(getResourceConverter().getGUIReference("saveAs")))); toolbarSaveAsButton.setToolTipText(getResourceConverter().getString("workbench.toolbar.saveAs", "Save As")); toolbarSaveAsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveAsMenuItemActionPerformed(evt); } }); jToolBar1.add(toolbarSaveAsButton); jPanel1.setMaximumSize(new java.awt.Dimension(8, 8)); jToolBar1.add(jPanel1); toolbarPreferencesButton.setIcon(new javax.swing.ImageIcon( getClass().getResource(getResourceConverter().getGUIReference("preferences")))); toolbarPreferencesButton .setToolTipText(getResourceConverter().getString("workbench.toolbar.connection", "Connection")); toolbarPreferencesButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { connectionButtonActionPerformed(evt); } }); jToolBar1.add(toolbarPreferencesButton); getContentPane().add(jToolBar1, java.awt.BorderLayout.NORTH); fileMenu.setText(getResourceConverter().getString("workbench.menu.file", "File")); fileMenu.setMnemonic(KeyEvent.VK_F); newMenu.setText(getResourceConverter().getString("workbench.menu.new", "New")); newSchemaMenuItem.setText(getResourceConverter().getString("workbench.menu.newSchema", "Schema")); newSchemaMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { newSchemaMenuItemActionPerformed(evt); } }); newMenu.add(newSchemaMenuItem); newQueryMenuItem.setText(getResourceConverter().getString("workbench.menu.newQuery", "MDX Query")); newQueryMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { newQueryMenuItemActionPerformed(evt); } }); newMenu.add(newQueryMenuItem); newJDBCExplorerMenuItem .setText(getResourceConverter().getString("workbench.menu.newJDBC", "JDBC Explorer")); newJDBCExplorerMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { newJDBCExplorerMenuItemActionPerformed(evt); } }); newMenu.add(newJDBCExplorerMenuItem); fileMenu.add(newMenu); openMenuItem.setText(getResourceConverter().getString("workbench.menu.open", "Open")); openMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { openMenuItemActionPerformed(evt); } }); fileMenu.add(openMenuItem); saveMenuItem.setText(getResourceConverter().getString("workbench.menu.save", "Save")); saveMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveMenuItemActionPerformed(evt); } }); fileMenu.add(saveMenuItem); saveAsMenuItem.setText(getResourceConverter().getString("workbench.menu.saveAsDot", "Save As ...")); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveAsMenuItemActionPerformed(evt); } }); fileMenu.add(saveAsMenuItem); // add last used fileMenu.add(jSeparator2); lastUsed1MenuItem.setText(getWorkbenchProperty("lastUsed1")); lastUsed1MenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { lastUsed1MenuItemActionPerformed(evt); } }); fileMenu.add(lastUsed1MenuItem); lastUsed2MenuItem.setText(getWorkbenchProperty("lastUsed2")); lastUsed2MenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { lastUsed2MenuItemActionPerformed(evt); } }); fileMenu.add(lastUsed2MenuItem); lastUsed3MenuItem.setText(getWorkbenchProperty("lastUsed3")); lastUsed3MenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { lastUsed3MenuItemActionPerformed(evt); } }); fileMenu.add(lastUsed3MenuItem); lastUsed4MenuItem.setText(getWorkbenchProperty("lastUsed4")); lastUsed4MenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { lastUsed4MenuItemActionPerformed(evt); } }); fileMenu.add(lastUsed4MenuItem); updateLastUsedMenu(); fileMenu.add(jSeparator1); exitMenuItem.setText(getResourceConverter().getString("workbench.menu.exit", "Exit")); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { exitMenuItemActionPerformed(evt); } }); fileMenu.add(exitMenuItem); menuBar.add(fileMenu); editMenu.setText(getResourceConverter().getString("workbench.menu.edit", "Edit")); editMenu.setMnemonic(KeyEvent.VK_E); cutMenuItem.setText(getResourceConverter().getString("workbench.menu.cut", "Cut")); editMenu.add(cutMenuItem); copyMenuItem.setText(getResourceConverter().getString("workbench.menu.copy", "Copy")); editMenu.add(copyMenuItem); pasteMenuItem.setText(getResourceConverter().getString("workbench.menu.paste", "Paste")); editMenu.add(pasteMenuItem); editMenu.add(deleteMenuItem); menuBar.add(editMenu); viewMenu.setText(getResourceConverter().getString("workbench.menu.view", "View")); viewMenu.setMnemonic(KeyEvent.VK_V); viewXmlMenuItem.setText(getResourceConverter().getString("workbench.menu.viewXML", "View XML")); viewXmlMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { viewXMLMenuItemActionPerformed(evt); } }); viewMenu.add(viewXmlMenuItem); menuBar.add(viewMenu); toolsMenu.setText(getResourceConverter().getString("workbench.menu.options", "Options")); toolsMenu.setMnemonic(KeyEvent.VK_O); preferencesMenuItem.setText(getResourceConverter().getString("workbench.menu.connection", "Connection")); preferencesMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { connectionButtonActionPerformed(evt); } }); toolsMenu.add(preferencesMenuItem); requireSchemaCheckboxMenuItem .setText(getResourceConverter().getString("workbench.menu.requireSchema", "Require Schema")); requireSchemaCheckboxMenuItem.setSelected(requireSchema); requireSchemaCheckboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { requireSchemaActionPerformed(e); } }); toolsMenu.add(requireSchemaCheckboxMenuItem); menuBar.add(toolsMenu); windowMenu.setText(getResourceConverter().getString("workbench.menu.windows", "Windows")); windowMenu.setMnemonic(KeyEvent.VK_W); cascadeMenuItem = new javax.swing.JMenuItem(); cascadeMenuItem .setText(getResourceConverter().getString("workbench.menu.cascadeWindows", "Cascade Windows")); cascadeMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { cascadeMenuItemActionPerformed(evt); } }); tileMenuItem = new javax.swing.JMenuItem(); tileMenuItem.setText(getResourceConverter().getString("workbench.menu.tileWindows", "Tile Windows")); tileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { tileMenuItemActionPerformed(evt); } }); closeAllMenuItem = new javax.swing.JMenuItem(); closeAllMenuItem.setText(getResourceConverter().getString("workbench.menu.closeAll", "Close All")); closeAllMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { closeAllMenuItemActionPerformed(evt); } }); minimizeMenuItem = new javax.swing.JMenuItem(); minimizeMenuItem.setText(getResourceConverter().getString("workbench.menu.minimizeAll", "Minimize All")); minimizeMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { minimizeMenuItemActionPerformed(evt); } }); maximizeMenuItem = new javax.swing.JMenuItem(); maximizeMenuItem.setText(getResourceConverter().getString("workbench.menu.maximizeAll", "Maximize All")); maximizeMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { maximizeMenuItemActionPerformed(evt); } }); menuBar.add(windowMenu); aboutMenuItem.setText(getResourceConverter().getString("workbench.menu.about", "About")); aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { aboutMenuItemActionPerformed(evt); } }); helpMenu.add(aboutMenuItem); helpMenu.setText(getResourceConverter().getString("workbench.menu.help", "Help")); helpMenu.setMnemonic(KeyEvent.VK_H); menuBar.add(helpMenu); setJMenuBar(menuBar); pack(); }
From source file:mondrian.gui.Workbench.java
private void newJDBCExplorerMenuItemActionPerformed(ActionEvent evt) { try {/*ww w . j ava2s .c o m*/ if (jdbcMetaData == null) { getNewJdbcMetadata(); } final JInternalFrame jf = new JInternalFrame(); jf.setTitle(getResourceConverter().getFormattedString("workbench.new.JDBCExplorer.title", "JDBC Explorer - {0} {1}", jdbcMetaData.getDatabaseProductName(), jdbcMetaData.getJdbcConnectionUrl())); getNewJdbcMetadata(); JdbcExplorer jdbce = new JdbcExplorer(jdbcMetaData, this); jf.getContentPane().add(jdbce); jf.setBounds(0, 0, 500, 480); jf.setClosable(true); jf.setIconifiable(true); jf.setMaximizable(true); jf.setResizable(true); jf.setVisible(true); // create jdbc menu item final javax.swing.JMenuItem jdbcMenuItem = new javax.swing.JMenuItem(); jdbcMenuItem.setText(getResourceConverter().getFormattedString("workbench.new.JDBCExplorer.menuitem", "{0} JDBC Explorer", Integer.toString(windowMenuMapIndex++))); jdbcMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { if (jf.isIcon()) { jf.setIcon(false); } else { jf.setSelected(true); } } catch (Exception ex) { LOGGER.error("queryMenuItem", ex); } } }); jf.addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) { jdbcWindows.remove(jf); jf.dispose(); // follow this by removing file from schemaWindowMap windowMenu.remove(jdbcMenuItem); return; } }); desktopPane.add(jf); jf.setVisible(true); jf.show(); try { jf.setSelected(true); } catch (Exception ex) { // do nothing LOGGER.error("newJDBCExplorerMenuItemActionPerformed.setSelected", ex); } jdbcWindows.add(jf); windowMenu.add(jdbcMenuItem, -1); windowMenu.add(jSeparator3, -1); windowMenu.add(cascadeMenuItem, -1); windowMenu.add(tileMenuItem, -1); windowMenu.add(minimizeMenuItem, -1); windowMenu.add(maximizeMenuItem, -1); windowMenu.add(closeAllMenuItem, -1); } catch (Exception ex) { JOptionPane.showMessageDialog(this, getResourceConverter().getFormattedString("workbench.new.JDBCExplorer.exception", "Database connection not successful.\n{0}", ex.getLocalizedMessage()), getResourceConverter().getString("workbench.new.JDBCExplorer.exception.title", "Database Connection Error"), JOptionPane.ERROR_MESSAGE); LOGGER.error("newJDBCExplorerMenuItemActionPerformed", ex); } }