List of usage examples for javax.swing.text DefaultEditorKit pasteAction
String pasteAction
To view the source code for javax.swing.text DefaultEditorKit pasteAction.
Click Source Link
From source file:TextCutPaste.java
/** * Create an Edit menu to support cut/copy/paste. *//*from w ww.jav a 2s .co m*/ public JMenuBar createMenuBar() { JMenuItem menuItem = null; JMenuBar menuBar = new JMenuBar(); JMenu mainMenu = new JMenu("Edit"); mainMenu.setMnemonic(KeyEvent.VK_E); menuItem = new JMenuItem(new DefaultEditorKit.CutAction()); menuItem.setText("Cut"); menuItem.setMnemonic(KeyEvent.VK_T); mainMenu.add(menuItem); menuItem = new JMenuItem(new DefaultEditorKit.CopyAction()); menuItem.setText("Copy"); menuItem.setMnemonic(KeyEvent.VK_C); mainMenu.add(menuItem); menuItem = new JMenuItem(new DefaultEditorKit.PasteAction()); menuItem.setText("Paste"); menuItem.setMnemonic(KeyEvent.VK_P); mainMenu.add(menuItem); menuBar.add(mainMenu); return menuBar; }
From source file:com.mirth.connect.client.ui.Mirth.java
/** * Create the alternate key bindings for the menu shortcut key mask. This is called if the menu * shortcut key mask is not the CTRL key (i.e. COMMAND on OSX) *//*from ww w . j a v a 2 s . com*/ private static void createAlternateKeyBindings() { int acceleratorKey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); // Add the common KeyBindings for macs KeyBinding[] defaultBindings = { new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_C, acceleratorKey), DefaultEditorKit.copyAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_V, acceleratorKey), DefaultEditorKit.pasteAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_X, acceleratorKey), DefaultEditorKit.cutAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_A, acceleratorKey), DefaultEditorKit.selectAllAction), // deleteNextWordAction and deletePrevWordAction were not available in Java 1.5 new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, acceleratorKey), DefaultEditorKit.deleteNextWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, acceleratorKey), DefaultEditorKit.deletePrevWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, acceleratorKey), DefaultEditorKit.nextWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, acceleratorKey), DefaultEditorKit.nextWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, acceleratorKey), DefaultEditorKit.previousWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, acceleratorKey), DefaultEditorKit.previousWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, acceleratorKey | InputEvent.SHIFT_MASK), DefaultEditorKit.selectionNextWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, acceleratorKey | InputEvent.SHIFT_MASK), DefaultEditorKit.selectionNextWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, acceleratorKey | InputEvent.SHIFT_MASK), DefaultEditorKit.selectionPreviousWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, acceleratorKey | InputEvent.SHIFT_MASK), DefaultEditorKit.selectionPreviousWordAction) }; keyMapBindings(new javax.swing.JTextField(), defaultBindings); keyMapBindings(new javax.swing.JPasswordField(), defaultBindings); keyMapBindings(new javax.swing.JTextPane(), defaultBindings); keyMapBindings(new javax.swing.JTextArea(), defaultBindings); keyMapBindings(new com.mirth.connect.client.ui.components.MirthTextField(), defaultBindings); keyMapBindings(new com.mirth.connect.client.ui.components.MirthPasswordField(), defaultBindings); keyMapBindings(new com.mirth.connect.client.ui.components.MirthTextPane(), defaultBindings); keyMapBindings(new com.mirth.connect.client.ui.components.MirthTextArea(), defaultBindings); }
From source file:DragColorTextFieldDemo.java
public JMenuBar createMenuBar() { JMenuItem menuItem = null;/* w ww . j a v a2s. com*/ JMenuBar menuBar = new JMenuBar(); JMenu mainMenu = new JMenu("Edit"); mainMenu.setMnemonic(KeyEvent.VK_E); menuItem = new JMenuItem(new DefaultEditorKit.CutAction()); menuItem.setText("Cut"); menuItem.setMnemonic(KeyEvent.VK_T); mainMenu.add(menuItem); menuItem = new JMenuItem(new DefaultEditorKit.CopyAction()); menuItem.setText("Copy"); menuItem.setMnemonic(KeyEvent.VK_C); mainMenu.add(menuItem); menuItem = new JMenuItem(new DefaultEditorKit.PasteAction()); menuItem.setText("Paste"); menuItem.setMnemonic(KeyEvent.VK_P); mainMenu.add(menuItem); menuBar.add(mainMenu); return menuBar; }
From source file:uk.ac.lkl.cram.ui.ModuleFrame.java
/** * Creates new form ModuleFrame/*from www . j a v a 2s. com*/ * @param module the module that this window displays * @param file */ public ModuleFrame(final Module module, File file) { this.module = module; this.moduleFile = file; this.setTitle(module.getModuleName()); initComponents(); //Add undo mechanism undoHandler = new UndoHandler(); JMenuItem undoMI = editMenu.add(undoHandler.getUndoAction()); JMenuItem redoMI = editMenu.add(undoHandler.getRedoAction()); //Listen to the undo handler for when there is something to undo undoHandler.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { //We're assuming there's only one property //If the new value is true, then there's something to undo //And thus the save menu item should be enabled Boolean newValue = (Boolean) evt.getNewValue(); if (moduleFile != null) { saveMI.setEnabled(newValue); } } }); editMenu.addSeparator(); //Add cut, copy & paste menu items JMenuItem cutMI = editMenu.add(new JMenuItem(new DefaultEditorKit.CutAction())); cutMI.setText("Cut"); JMenuItem copyMI = editMenu.add(new JMenuItem(new DefaultEditorKit.CopyAction())); copyMI.setText("Copy"); JMenuItem pasteMI = editMenu.add(new JMenuItem(new DefaultEditorKit.PasteAction())); pasteMI.setText("Paste"); //Listen for changes to the shared selection model sharedSelectionModel.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { //Update the menu items modifyLineItemMI.setEnabled(evt.getNewValue() != null); removeLineItemMI.setEnabled(evt.getNewValue() != null); } }); doubleClickListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { //If the user double clicks, then treat this as a shortcut to modify the selected line item if (e.getClickCount() == 2) { modifySelectedLineItem(); } } }; //Set Accelerator keys undoMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); redoMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_Y, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); cutMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); copyMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); pasteMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); newMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); openMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); saveMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); quitMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); //Remove quit menu item and separator from file menu on Mac if (Utilities.isMac()) { fileMenu.remove(quitSeparator); fileMenu.remove(quitMI); } leftTaskPaneContainer.add(createCourseDataPane()); leftTaskPaneContainer.add(createLineItemPane()); leftTaskPaneContainer.add(createTutorHoursPane()); leftTaskPaneContainer.add(createTutorCostPane()); rightTaskPaneContainer.add(createLearningTypeChartPane()); rightTaskPaneContainer.add(createLearningExperienceChartPane()); rightTaskPaneContainer.add(createLearnerFeedbackChartPane()); rightTaskPaneContainer.add(createHoursChartPane()); rightTaskPaneContainer.add(createTotalCostsPane()); }
From source file:dmh.kuebiko.view.NoteStackFrame.java
/** * Create the frame./* w w w . j a v a 2 s . c o m*/ */ public NoteStackFrame(NoteManager noteMngr) { this.noteMngr = noteMngr; // Setup the various actions for the frame. noteMngr.addObserver(new Observer() { @Override public void update(Observable o, Object arg) { boolean stackChanged = (Boolean) arg; toggleUnsavedChangeIndicator(stackChanged); if (!stackChanged) { notePanel.getHuxleyUiManager().resetTextChanged(); } } }); ActionObserverUtil.registerEnMass(actionMngr, observable, new NewNoteAction(this), new OpenNoteAction(this), new DeleteNoteAction(this), new RenameNoteAction(this), new SaveStackAction(this)); // Build the menus. menuBar = new JMenuBar(); setJMenuBar(menuBar); fileMenu = new JMenu("File"); menuBar.add(fileMenu); newNoteMenuItem = new JMenuItem(actionMngr.getAction(NewNoteAction.class)); fileMenu.add(newNoteMenuItem); JMenuItem openNoteMenuItem = new JMenuItem(actionMngr.getAction(OpenNoteAction.class)); fileMenu.add(openNoteMenuItem); deleteNoteMenuItem = new JMenuItem(actionMngr.getAction(DeleteNoteAction.class)); fileMenu.add(deleteNoteMenuItem); renameNoteMenuItem = new JMenuItem(actionMngr.getAction(RenameNoteAction.class)); fileMenu.add(renameNoteMenuItem); fileMenu.addSeparator(); newStackMenuItem = new JMenuItem(actionMngr.getAction(NewStackAction.class)); fileMenu.add(newStackMenuItem); openStackMenuItem = new JMenuItem(actionMngr.getAction(OpenStackAction.class)); fileMenu.add(openStackMenuItem); fileMenu.addSeparator(); closeMenuItem = new JMenuItem("Close"); closeMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); closeMenuItem.setEnabled(false); fileMenu.add(closeMenuItem); closeAllMenuItem = new JMenuItem("Close All"); closeAllMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.SHIFT_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); closeAllMenuItem.setEnabled(false); fileMenu.add(closeAllMenuItem); fileMenu.addSeparator(); saveMenuItem = new JMenuItem(actionMngr.getAction(SaveStackAction.class)); fileMenu.add(saveMenuItem); saveAllMenuItem = new JMenuItem("Save All"); saveAllMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.SHIFT_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); saveAllMenuItem.setEnabled(false); fileMenu.add(saveAllMenuItem); editMenu = new JMenu("Edit"); menuBar.add(editMenu); undoMenuItem = new JMenuItem("Undo"); undoMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); editMenu.add(undoMenuItem); redoMenuItem = new JMenuItem("Redo"); // FIXME mac-specific keyboard shortcut redoMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.SHIFT_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); editMenu.add(redoMenuItem); editMenu.addSeparator(); cutMenuItem = new JMenuItem(actionMngr.getAction(DefaultEditorKit.CutAction.class)); cutMenuItem.setText("Cut"); cutMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); editMenu.add(cutMenuItem); copyMenuItem = new JMenuItem(actionMngr.getAction(DefaultEditorKit.CopyAction.class)); copyMenuItem.setText("Copy"); copyMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); editMenu.add(copyMenuItem); pasteMenuItem = new JMenuItem(actionMngr.getAction(DefaultEditorKit.PasteAction.class)); pasteMenuItem.setText("Paste"); pasteMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); editMenu.add(pasteMenuItem); textMenu = new JMenu("Text"); menuBar.add(textMenu); JMenu windowMenu = new JMenu("Window"); menuBar.add(windowMenu); initialize(); additionalSetup(); }
From source file:TextComponentDemo.java
protected JMenu createEditMenu() { JMenu menu = new JMenu("Edit"); // Undo and redo are actions of our own creation. undoAction = new UndoAction(); menu.add(undoAction);//w w w.jav a2 s.c o m redoAction = new RedoAction(); menu.add(redoAction); menu.addSeparator(); // These actions come from the default editor kit. // Get the ones we want and stick them in the menu. menu.add(getActionByName(DefaultEditorKit.cutAction)); menu.add(getActionByName(DefaultEditorKit.copyAction)); menu.add(getActionByName(DefaultEditorKit.pasteAction)); menu.addSeparator(); menu.add(getActionByName(DefaultEditorKit.selectAllAction)); return menu; }
From source file:TextComponentDemo.java
protected JMenu createEditMenu() { JMenu menu = new JMenu("Edit"); //Undo and redo are actions of our own creation. undoAction = new UndoAction(); menu.add(undoAction);//from www . j a v a 2s. com redoAction = new RedoAction(); menu.add(redoAction); menu.addSeparator(); //These actions come from the default editor kit. //Get the ones we want and stick them in the menu. menu.add(getActionByName(DefaultEditorKit.cutAction)); menu.add(getActionByName(DefaultEditorKit.copyAction)); menu.add(getActionByName(DefaultEditorKit.pasteAction)); menu.addSeparator(); menu.add(getActionByName(DefaultEditorKit.selectAllAction)); return menu; }
From source file:edu.harvard.mcz.imagecapture.encoder.UnitTrayLabelBrowser.java
/** * This method initializes jMenuItem1 * //from w w w . j a va2s . c o m * @return javax.swing.JMenuItem */ private JMenuItem getJMenuItem1() { if (jMenuItemPaste == null) { jMenuItemPaste = new JMenuItem(new DefaultEditorKit.PasteAction()); jMenuItemPaste.setText("Paste"); jMenuItemPaste.setMnemonic(KeyEvent.VK_P); jMenuItemPaste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK)); jMenuItemPaste.setEnabled(true); } return jMenuItemPaste; }
From source file:mondrian.gui.Workbench.java
/** * This method is called from within the constructor to * initialize the form./*w ww .ja v a 2 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:com.itemanalysis.jmetrik.gui.Jmetrik.java
private JMenuBar createMenuBar() { final JMenuBar menuBar = new JMenuBar(); JMenuItem mItem = null;//from w ww . j av a 2 s . c o m String urlString; URL url; //============================================================================================ // File Menu //============================================================================================ JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('f'); menuBar.add(fileMenu); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-new.png"; url = this.getClass().getResource(urlString); ImageIcon iconNew = new ImageIcon(url, "New"); mItem = new JMenuItem(new NewTextFileAction("New", iconNew)); fileMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-open.png"; url = this.getClass().getResource(urlString); ImageIcon iconOpen = new ImageIcon(url, "Open"); mItem = new JMenuItem(new OpenFileAction("Open...", iconOpen, new Integer(KeyEvent.VK_A))); fileMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-save.png"; url = this.getClass().getResource(urlString); ImageIcon iconSave = new ImageIcon(url, "Save"); mItem = new JMenuItem(new SaveAction("Save", iconSave, new Integer(KeyEvent.VK_S))); fileMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-save-as.png"; url = this.getClass().getResource(urlString); ImageIcon iconSaveAs = new ImageIcon(url, "Save As"); mItem = new JMenuItem(new SaveAsAction("Save As...", iconSaveAs)); fileMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/status/folder-visiting.png"; url = this.getClass().getResource(urlString); ImageIcon iconClose = new ImageIcon(url, "Close All Tabs"); mItem = new JMenuItem(new CloseAllTabsAction("Close All Tabs...", iconClose, new Integer(KeyEvent.VK_C))); fileMenu.add(mItem); fileMenu.addSeparator(); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-print.png"; url = this.getClass().getResource(urlString); ImageIcon iconPrint = new ImageIcon(url, "Print"); mItem = new JMenuItem(new PrintAction("Print...", iconPrint)); fileMenu.add(mItem); fileMenu.addSeparator(); // exit menu item urlString = "/org/tango-project/tango-icon-theme/16x16/actions/system-log-out.png"; url = this.getClass().getResource(urlString); ImageIcon iconExit = new ImageIcon(url, "Exit"); mItem = new JMenuItem(new ExitAction("Exit", iconExit)); fileMenu.add(mItem); //============================================================================================ // Edit Menu //============================================================================================ JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic(KeyEvent.VK_E); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-cut.png"; url = this.getClass().getResource(urlString); ImageIcon iconCut = new ImageIcon(url, "Cut"); mItem = new JMenuItem(new DefaultEditorKit.CutAction()); mItem.setText("Cut"); mItem.setIcon(iconCut); mItem.setMnemonic(KeyEvent.VK_X); editMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-copy.png"; url = this.getClass().getResource(urlString); ImageIcon iconCopy = new ImageIcon(url, "Copy"); mItem = new JMenuItem(new DefaultEditorKit.CopyAction()); mItem.setText("Copy"); mItem.setIcon(iconCopy); mItem.setMnemonic(KeyEvent.VK_C); editMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-paste.png"; url = this.getClass().getResource(urlString); ImageIcon iconPaste = new ImageIcon(url, "Paste"); mItem = new JMenuItem(new DefaultEditorKit.PasteAction()); mItem.setText("Paste"); mItem.setIcon(iconPaste); mItem.setMnemonic(KeyEvent.VK_V); editMenu.add(mItem); editMenu.addSeparator(); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-undo.png"; url = this.getClass().getResource(urlString); ImageIcon iconUndo = new ImageIcon(url, "Undo"); mItem = new JMenuItem(new UndoAction("Undo", iconUndo, new Integer(KeyEvent.VK_Z))); editMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-redo.png"; url = this.getClass().getResource(urlString); ImageIcon iconRedo = new ImageIcon(url, "Redo"); mItem = new JMenuItem(new RedoAction("Redo", iconRedo, new Integer(KeyEvent.VK_Y))); editMenu.add(mItem); editMenu.addSeparator(); urlString = "/org/tango-project/tango-icon-theme/16x16/categories/preferences-system.png"; url = this.getClass().getResource(urlString); ImageIcon iconView = new ImageIcon(url, "Preferences"); mItem = new JMenuItem("Preferences"); mItem.setIcon(iconView); mItem.setToolTipText("Edit jMetrik preferences"); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JmetrikPreferencesManager prefs = new JmetrikPreferencesManager(); prefs.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener()); prefs.addPropertyChangeListener(statusBar.getStatusListener()); JmetrikPreferencesDialog propDialog = new JmetrikPreferencesDialog(Jmetrik.this, prefs); // propDialog.loadPreferences(); propDialog.setVisible(true); } }); editMenu.setMnemonic('e'); editMenu.add(mItem); menuBar.add(editMenu); //============================================================================================ // Log Menu //============================================================================================ JMenu logMenu = new JMenu("Log"); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-properties.png"; url = this.getClass().getResource(urlString); ImageIcon iconLog = new ImageIcon(url, "View Log"); mItem = new JMenuItem(new ViewLogAction("View Log", iconLog)); logMenu.setMnemonic('l'); logMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/mimetypes/text-x-generic.png"; url = this.getClass().getResource(urlString); ImageIcon iconCommand = new ImageIcon(url, "Script Log"); mItem = new JMenuItem(new ViewScriptLogAction("Script Log", iconCommand)); logMenu.setMnemonic('c'); logMenu.add(mItem); menuBar.add(logMenu); //============================================================================================ // Manage Menu //============================================================================================ JMenu manageMenu = new JMenu("Manage"); manageMenu.setMnemonic('m'); mItem = new JMenuItem("New Database...");//create db mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NewDatabaseDialog newDatabaseDialog = new NewDatabaseDialog(Jmetrik.this); newDatabaseDialog.setVisible(true); if (newDatabaseDialog.canRun()) { if (workspace == null) { // workspace = new Workspace(workspaceTree, tabbedPane, dataTable, variableTable); workspace = new Workspace(workspaceList, tabbedPane, dataTable, variableTable); workspace.addPropertyChangeListener(statusBar.getStatusListener()); workspace.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener()); } workspace.runProcess(newDatabaseDialog.getCommand()); // workspace.createDatabase(newDatabaseDialog.getCommand()); } } }); manageMenu.add(mItem); mItem = new JMenuItem("Open Database..."); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OpenDatabaseDialog openDbDialog = new OpenDatabaseDialog(Jmetrik.this, "Open"); JList l = openDbDialog.getDatabaseList(); workspace.setDatabaseListModel(l); openDbDialog.setVisible(true); if (openDbDialog.canRun()) { openWorkspace(openDbDialog.getDatabaseName()); } } }); manageMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png"; url = this.getClass().getResource(urlString); ImageIcon iconDelete = new ImageIcon(url, "Delete"); mItem = new JMenuItem("Delete Database..."); mItem.setIcon(iconDelete); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OpenDatabaseDialog selectDialog = new OpenDatabaseDialog(Jmetrik.this, "Delete"); JList l = selectDialog.getDatabaseList(); workspace.setDatabaseListModel(l); selectDialog.setVisible(true); if (selectDialog.canRun()) { int answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete " + selectDialog.getDatabaseName() + " and all of its contents? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); if (answer == JOptionPane.YES_OPTION) { DatabaseCommand command = new DatabaseCommand(); DatabaseName dbName = new DatabaseName(selectDialog.getDatabaseName()); command.getFreeOption("name").add(dbName.getName()); command.getSelectOneOption("action").setSelected("delete-db"); DatabaseName currentDb = workspace.getDatabaseName(); if (currentDb.getName().equals(dbName.getName())) { JOptionPane.showMessageDialog(Jmetrik.this, "You cannot delete the current database.\n" + "Close the database before attempting to delete it.", "Database Delete Error", JOptionPane.WARNING_MESSAGE); } else { workspace.runProcess(command); } } } } }); manageMenu.add(mItem); manageMenu.addSeparator(); urlString = "/org/tango-project/tango-icon-theme/16x16/apps/accessories-text-editor.png"; url = this.getClass().getResource(urlString); ImageIcon iconDesc = new ImageIcon(url, "Descriptions"); mItem = new JMenuItem("Table Descriptions..."); mItem.setIcon(iconDesc); mItem.addActionListener(new TableDescriptionActionListener()); manageMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/list-add.png"; url = this.getClass().getResource(urlString); ImageIcon iconImport = new ImageIcon(url, "Import"); mItem = new JMenuItem("Import Data..."); mItem.setIcon(iconImport); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (workspace.databaseOpened()) { ImportDialog importDialog = new ImportDialog(Jmetrik.this, workspace.getDatabaseName(), importExportPath); importDialog.setVisible(true); if (importDialog.canRun()) { importExportPath = importDialog.getCurrentDirectory(); workspace.runProcess(importDialog.getCommand()); } } else { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before importing data.", "No Open Database", JOptionPane.ERROR_MESSAGE); } } }); manageMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/format-indent-less.png"; url = this.getClass().getResource(urlString); ImageIcon iconExport = new ImageIcon(url, "Export"); mItem = new JMenuItem("Export Data..."); mItem.setIcon(iconExport); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DataTableName tableName = (DataTableName) workspaceList.getSelectedValue(); if (!workspace.databaseOpened()) { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before exporting data.", "No Open Database", JOptionPane.ERROR_MESSAGE); } else if (tableName == null) { JOptionPane.showMessageDialog(Jmetrik.this, "You must select a table in the workspace list. \n " + "Select a table to continue the export.", "No Table Selected", JOptionPane.ERROR_MESSAGE); } else { ExportDataDialog exportDialog = new ExportDataDialog(Jmetrik.this, workspace.getDatabaseName(), tableName, importExportPath); if (exportDialog.canRun()) { importExportPath = exportDialog.getCurrentDirectory(); workspace.runProcess(exportDialog.getCommand()); } } } }); manageMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png"; url = this.getClass().getResource(urlString); ImageIcon iconDeleteTable = new ImageIcon(url, "Delete"); mItem = new JMenuItem("Delete Table..."); mItem.setIcon(iconDeleteTable); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (workspace.databaseOpened()) { DeleteTableDialog deleteDialog = new DeleteTableDialog(Jmetrik.this, workspace.getDatabaseName(), (SortedListModel<DataTableName>) workspaceList.getModel()); deleteDialog.setVisible(true); if (deleteDialog.canRun()) { int nSelected = deleteDialog.getNumberOfSelectedTables(); int answer = JOptionPane.NO_OPTION; if (nSelected > 1) { answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete these " + nSelected + " tables? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); } else { ArrayList<DataTableName> dList = deleteDialog.getSelectedTables(); answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete the table " + dList.get(0).getTableName() + "? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); } if (answer == JOptionPane.YES_OPTION) { workspace.runProcess(deleteDialog.getCommand()); } } } else { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before deleting a table.", "No Open Database", JOptionPane.ERROR_MESSAGE); } } }); manageMenu.add(mItem); manageMenu.addSeparator(); SubsetCasesProcess subsetCasesProcess = new SubsetCasesProcess(); subsetCasesProcess.addMenuItem(Jmetrik.this, manageMenu, dialogs, workspace, workspaceList); SubsetVariablesProcess subsetVariablesProcess = new SubsetVariablesProcess(); subsetVariablesProcess.addMenuItem(Jmetrik.this, manageMenu, dialogs, workspace, workspaceList); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png"; url = this.getClass().getResource(urlString); ImageIcon iconDeleteVariables = new ImageIcon(url, "Delete Variables"); mItem = new JMenuItem("Delete Variables..."); mItem.setIcon(iconDeleteVariables); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DataTableName tableName = (DataTableName) workspaceList.getSelectedValue(); if (!workspace.databaseOpened()) { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before subsetting data.", "No Open Database", JOptionPane.ERROR_MESSAGE); } else if (tableName == null) { JOptionPane.showMessageDialog(Jmetrik.this, "You must select a table in the workspace list. \n " + "Select a table to continue.", "No Table Selected", JOptionPane.ERROR_MESSAGE); } else if (workspace.tableOpen()) { DeleteVariableDialog deleteVariableDialog = new DeleteVariableDialog(Jmetrik.this, workspace.getDatabaseName(), workspace.getCurrentDataTable(), workspace.getVariables()); deleteVariableDialog.setVisible(true); if (deleteVariableDialog.canRun()) { int nSelected = deleteVariableDialog.getNumberOfSelectedVariables(); int answer = JOptionPane.NO_OPTION; if (nSelected > 1) { answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete these " + nSelected + " variables? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Variables", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); } else { VariableAttributes v = deleteVariableDialog.getSelectedVariable(); answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete the variable " + v.getName().toString() + "? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); } if (answer == JOptionPane.YES_OPTION) { workspace.runProcess(deleteVariableDialog.getCommand()); } } } } }); manageMenu.add(mItem); menuBar.add(manageMenu); //============================================================================================ // Transform Menu //============================================================================================ JMenu transformMenu = new JMenu("Transform"); transformMenu.setMnemonic('t'); BasicScoringProcess basicScoringProcess = new BasicScoringProcess(); basicScoringProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); ScoringProcess scoringProcess = new ScoringProcess(); scoringProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); transformMenu.addSeparator(); RankingProcess rankingProcess = new RankingProcess(); rankingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); TestScalingProcess testScalingProcess = new TestScalingProcess(); testScalingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); LinearTransformationProcess linearTransformationProcess = new LinearTransformationProcess(); linearTransformationProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); transformMenu.addSeparator(); IrtLinkingProcess irtLinkingProcess = new IrtLinkingProcess(); irtLinkingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); IrtEquatingProcess irtEquatingProcess = new IrtEquatingProcess(); irtEquatingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); menuBar.add(transformMenu); //============================================================================================ // Analyze Menu //============================================================================================ JMenu analyzeMenu = new JMenu("Analyze"); analyzeMenu.setMnemonic('a'); FrequencyProcess frequencyProcess = new FrequencyProcess(); frequencyProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); DescriptiveProcess descriptiveProcess = new DescriptiveProcess(); descriptiveProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); CorrelationProcess correlationProcess = new CorrelationProcess(); correlationProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); analyzeMenu.addSeparator(); ItemAnalysisProcess itemAnalysisProcess = new ItemAnalysisProcess(); itemAnalysisProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); CmhProcess cmhProcess = new CmhProcess(); cmhProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); analyzeMenu.addSeparator(); RaschAnalysisProcess raschAnalysisProcess = new RaschAnalysisProcess(); raschAnalysisProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); IrtItemCalibrationProcess irtItemCalibrationProcess = new IrtItemCalibrationProcess(); irtItemCalibrationProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); IrtPersonScoringProcess irtPersonScoringProcess = new IrtPersonScoringProcess(); irtPersonScoringProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); menuBar.add(analyzeMenu); //============================================================================================ // Graph Menu //============================================================================================ JMenu graphMenu = new JMenu("Graph"); graphMenu.setMnemonic('g'); BarChartProcess barchartProcess = new BarChartProcess(); barchartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); PieChartProcess piechartProcess = new PieChartProcess(); piechartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); graphMenu.addSeparator(); HistogramProcess histogramProcess = new HistogramProcess(); histogramProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); DensityProcess densityProcess = new DensityProcess(); densityProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); LineChartProcess lineChartProcess = new LineChartProcess(); lineChartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); ScatterplotProcess scatterplotProcess = new ScatterplotProcess(); scatterplotProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); graphMenu.addSeparator(); NonparametricCurveProcess nonparametricCurveProcess = new NonparametricCurveProcess(); nonparametricCurveProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); mItem = new JMenuItem("Irt Plot..."); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DataTableName tableName = (DataTableName) workspaceList.getSelectedValue(); if (tableName == null) { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database and select a table. \n " + "Select a table to continue scoring.", "No Table Selected", JOptionPane.ERROR_MESSAGE); } else { if (irtPlotDialog == null && workspace.tableOpen()) { //Note that starting this dialog is different because variables //names must be obtained from the rows of a table. DatabaseAccessObject dao = workspace.getDatabaseFactory().getDatabaseAccessObject(); try { ArrayList<VariableAttributes> tempVar = dao.getVariableAttributesFromColumn( workspace.getConnection(), workspace.getCurrentDataTable(), new VariableName("name")); irtPlotDialog = new IrtPlotDialog(Jmetrik.this, workspace.getDatabaseName(), tableName, tempVar, (SortedListModel<DataTableName>) workspaceList.getModel()); } catch (SQLException ex) { logger.fatal(ex.getMessage(), ex); firePropertyChange("error", "", "Error - Check log for details."); } } if (irtPlotDialog != null) irtPlotDialog.setVisible(true); } if (irtPlotDialog != null && irtPlotDialog.canRun()) { workspace.runProcess(irtPlotDialog.getCommand()); } } }); graphMenu.add(mItem); ItemMapProcess itemMapProcess = new ItemMapProcess(); itemMapProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); menuBar.add(graphMenu); //============================================================================================ // Command Menu //============================================================================================ JMenu commandMenu = new JMenu("Commands"); commandMenu.setMnemonic('c'); mItem = new JMenuItem("Run command"); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JScrollPane pain = (JScrollPane) tabbedPane.getSelectedComponent(); JViewport vp = pain.getViewport(); Component c = vp.getComponent(0); if (c instanceof JmetrikTextFile) { JmetrikTab tempTab = (JmetrikTab) tabbedPane.getTabComponentAt(tabbedPane.getSelectedIndex()); JmetrikTextFile textFile = (JmetrikTextFile) c; workspace.runFromSyntax(textFile.getText()); } } }); commandMenu.add(mItem); mItem = new JMenuItem("Stop command"); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //add something } }); mItem.setEnabled(false); commandMenu.add(mItem); mItem = new JMenuItem("Command Reference..."); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //add something } }); mItem.setEnabled(false); commandMenu.add(mItem); menuBar.add(commandMenu); //============================================================================================ // Help Menu //============================================================================================ JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic('h'); mItem = new JMenuItem("Quick Start Guide"); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Desktop deskTop = Desktop.getDesktop(); try { URI uri = new URI("http://www.itemanalysis.com/quick-start-guide.php"); deskTop.browse(uri); } catch (URISyntaxException ex) { logger.fatal(ex.getMessage(), ex); firePropertyChange("error", "", "Error - Check log for details."); } catch (IOException ex) { logger.fatal(ex.getMessage(), ex); firePropertyChange("error", "", "Error - Check log for details."); } } }); helpMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/apps/help-browser.png"; url = this.getClass().getResource(urlString); ImageIcon iconAbout = new ImageIcon(url, "About"); mItem = new JMenuItem("About"); mItem.setIcon(iconAbout); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JmetrikAboutDialog aboutDialog = new JmetrikAboutDialog(Jmetrik.this, APP_NAME, VERSION, AUTHOR, RELEASE_DATE, COPYRIGHT_YEAR, BETA_VERSION); aboutDialog.setVisible(true); } }); helpMenu.add(mItem); menuBar.add(helpMenu); return menuBar; }