List of usage examples for javax.swing AbstractAction AbstractAction
public AbstractAction(String name)
From source file:net.pandoragames.far.ui.swing.component.UndoHistory.java
/** * Registers the specified text component for the snapshot history. * This enables the <code>alt + ←</code> and <code>ctrl + →</code> shortcuts. * @param component to be registered for snapshots. *///from w w w . j a v a 2s . c om public void registerSnapshotHistory(JTextComponent component) { snapshots = new SnapshotHistory(component); // Create a previous action and add it to the text component previousAction = new AbstractAction("Previous") { public void actionPerformed(ActionEvent evt) { UndoHistory.this.previous(); } }; previousAction.setEnabled(false); component.getActionMap().put(ACTION_KEY_PREVIOUS, previousAction); // Create a next action and add it to the text component nextAction = new AbstractAction("Next") { public void actionPerformed(ActionEvent evt) { UndoHistory.this.next(); } }; nextAction.setEnabled(false); component.getActionMap().put(ACTION_KEY_NEXT, nextAction); // Bind the actions to alt-left-arrow and alt-right arrow previousAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("alt LEFT")); component.getInputMap().put(KeyStroke.getKeyStroke("alt LEFT"), ACTION_KEY_PREVIOUS); component.getInputMap().put(KeyStroke.getKeyStroke("alt KP_LEFT"), ACTION_KEY_PREVIOUS); nextAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("alt RIGHT")); component.getInputMap().put(KeyStroke.getKeyStroke("alt RIGHT"), ACTION_KEY_NEXT); component.getInputMap().put(KeyStroke.getKeyStroke("alt KP_RIGHT"), ACTION_KEY_NEXT); }
From source file:captureplugin.CapturePlugin.java
/** * Update the TreeNode/*from w w w .j a v a 2s. c o m*/ */ private void updateTreeNode() { mRootNode.removeAllChildren(); mRootNode.removeAllActions(); for (Object o : mConfig.getDevices()) { final DeviceIf device = (DeviceIf) o; PluginTreeNode node; if (mConfig.getDevices().size() > 1) { node = new PluginTreeNode(device.getName()); mRootNode.add(node); } else { node = mRootNode; } if (device.isAbleToAddAndRemovePrograms()) { node.getMutableTreeNode().setProgramReceiveTarget(new ProgramReceiveTarget(this, device.getName() + " - " + mLocalizer.msg("record", "record"), device.getId() + RECORD)); } Program[] programs = device.getProgramList(); if (programs != null) { for (Program program : programs) { node.addProgram(program); } } node.addAction(new AbstractAction(mLocalizer.msg("configure", "Configure '{0}'", device.getName())) { @Override public void actionPerformed(ActionEvent e) { device.configDevice(UiUtilities.getBestDialogParent(getParentFrame())); updateTreeNode(); } }); } mRootNode.update(); }
From source file:org.jax.maanova.test.gui.VolcanoPlotPanel.java
@SuppressWarnings("serial") private JMenuBar createMenu() { JMenuBar menuBar = new JMenuBar(); // the file menu JMenu fileMenu = new JMenu("File"); fileMenu.add(this.saveGraphImageAction); menuBar.add(fileMenu);//from w ww . j a va 2 s .c o m // the tools menu JMenu toolsMenu = new JMenu("Tools"); JMenuItem configureGraphItem = new JMenuItem("Configure Graph..."); configureGraphItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.chartConfigurationDialog.setVisible(true); } }); toolsMenu.add(configureGraphItem); toolsMenu.addSeparator(); toolsMenu.add(new AbstractAction("Clear Selections") { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.setSelectedIndices(new int[0]); } }); toolsMenu.addSeparator(); ButtonGroup dragButtonGroup = new ButtonGroup(); JCheckBoxMenuItem selectModeCheckBox = new JCheckBoxMenuItem("Drag Cursor to Select"); selectModeCheckBox.setSelected(true); this.dragToSelect = true; selectModeCheckBox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.dragToSelect = e.getStateChange() == ItemEvent.SELECTED; } }); dragButtonGroup.add(selectModeCheckBox); toolsMenu.add(selectModeCheckBox); JCheckBoxMenuItem zoomModeCheckBox = new JCheckBoxMenuItem("Drag Cursor to Zoom"); zoomModeCheckBox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.dragToZoom = e.getStateChange() == ItemEvent.SELECTED; } }); dragButtonGroup.add(zoomModeCheckBox); toolsMenu.add(zoomModeCheckBox); toolsMenu.addSeparator(); toolsMenu.add(new AbstractAction("Zoom Out") { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.autoRangeChart(); } }); toolsMenu.addSeparator(); JCheckBoxMenuItem showTooltipCheckbox = new JCheckBoxMenuItem("Show Info Popup for Nearest Point"); showTooltipCheckbox.setSelected(true); this.showTooltip = true; showTooltipCheckbox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.showTooltip = e.getStateChange() == ItemEvent.SELECTED; VolcanoPlotPanel.this.clearProbePopup(); } }); toolsMenu.add(showTooltipCheckbox); toolsMenu.addSeparator(); toolsMenu.add(this.displayTestResultsAction); toolsMenu.addSeparator(); toolsMenu.add(this.saveSelectedPointsMenuItem); JMenu selectPointsFromLisMenu = new JMenu("Select Points From Gene List"); List<String> geneListNames = this.maanovaTestResult.getParentExperiment().getGeneListNames(); if (geneListNames.isEmpty()) { JMenuItem noListsMenuItem = new JMenuItem("No Gene Lists Available"); noListsMenuItem.setEnabled(false); selectPointsFromLisMenu.add(noListsMenuItem); } else { for (final String geneListName : geneListNames) { JMenuItem currGeneListMenuItem = new JMenuItem( RUtilities.fromRIdentifierToReadableName(geneListName)); currGeneListMenuItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.selectedIndicesFromGeneList(geneListName); } }); selectPointsFromLisMenu.add(currGeneListMenuItem); } } toolsMenu.add(selectPointsFromLisMenu); menuBar.add(toolsMenu); // the help menu JMenu helpMenu = new JMenu("Help"); JMenuItem helpMenuItem = new JMenuItem("Help..."); Icon helpIcon = new ImageIcon(VolcanoPlotPanel.class.getResource("/images/action/help-16x16.png")); helpMenuItem.setIcon(helpIcon); helpMenuItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { Maanova.getInstance().showHelp("volcano-plot", VolcanoPlotPanel.this); } }); helpMenu.add(helpMenuItem); menuBar.add(helpMenu); return menuBar; }
From source file:idontwant2see.IDontWant2See.java
private AbstractAction getActionInputTitle(final Program p, final String part) { return new AbstractAction(mLocalizer.msg("menu.userEntered", "User entered value")) { public void actionPerformed(final ActionEvent e) { final JCheckBox caseSensitive = new JCheckBox(mLocalizer.msg("caseSensitive", "case sensitive")); String title = p.getTitle(); ArrayList<String> items = new ArrayList<String>(); if (!StringUtils.isEmpty(part)) { String shortTitle = title.trim().substring(0, title.length() - part.length()).trim(); shortTitle = StringUtils.removeEnd(shortTitle, "-").trim(); shortTitle = StringUtils.removeEnd(shortTitle, "(").trim(); items.add(shortTitle + "*"); }//from w w w .j ava 2 s. c o m int index = title.indexOf(" - "); if (index > 0) { items.add(title.substring(0, index).trim() + "*"); } items.add(title); index = title.lastIndexOf(':'); if (index > 0) { items.add(title.substring(0, index).trim() + "*"); } final JComboBox input = new JComboBox(items.toArray(new String[items.size()])); input.setEditable(true); input.addAncestorListener(new AncestorListener() { public void ancestorAdded(final AncestorEvent event) { event.getComponent().requestFocus(); } public void ancestorMoved(final AncestorEvent event) { } public void ancestorRemoved(final AncestorEvent event) { } }); if (JOptionPane.showConfirmDialog(UiUtilities.getLastModalChildOf(getParentFrame()), new Object[] { mLocalizer.msg("exclusionText", "What should be excluded? (You can use the wildcard *)"), input, caseSensitive }, mLocalizer.msg("exclusionTitle", "Exclusion value entering"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { String test = ""; String result = (String) input.getSelectedItem(); if (result != null) { test = result.replaceAll("\\*+", "\\*").trim(); if (test.length() >= 0 && !test.equals("*")) { mSettings.getSearchList() .add(new IDontWant2SeeListEntry(result, caseSensitive.isSelected())); mSettings.setLastEnteredExclusionString(result); updateFilter(!mSettings.isSwitchToMyFilter()); } } if (test.trim().length() <= 1) { JOptionPane.showMessageDialog(UiUtilities.getLastModalChildOf(getParentFrame()), mLocalizer.msg("notValid", "The entered text is not valid."), Localizer.getLocalization(Localizer.I18N_ERROR), JOptionPane.ERROR_MESSAGE); } } } }; }
From source file:org.openconcerto.erp.core.finance.accounting.ui.EtatJournauxPanel.java
private JPanel creerJournalMoisPanel(final Date date, long debit, long credit, final Journal jrnl) { final JPanel panelMoisCompte = new JPanel(); panelMoisCompte.setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 1, 2); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; c.gridx = 0;/* www . j a v a 2s . com*/ c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 1; c.weighty = 0; panelMoisCompte.setBorder(BorderFactory.createTitledBorder(dateFormat.format(date))); // Date du mois panelMoisCompte.add(new JLabel(dateFormat.format(date)), c); // Totaux du mois c.gridx++; panelMoisCompte.add(new JLabel(" dbit : " + GestionDevise.currencyToString(debit)), c); c.gridx++; panelMoisCompte.add(new JLabel(" crdit : " + GestionDevise.currencyToString(credit)), c); // Bouton dtails JButton boutonShow = new JButton("+/-"); boutonShow.setOpaque(false); boutonShow.setHorizontalAlignment(SwingConstants.LEFT); c.weightx = 0; c.gridx++; panelMoisCompte.add(boutonShow, c); boutonShow.addActionListener(new ActionListener() { private boolean isShow = false; private ListPanelEcritures listEcriture; public void actionPerformed(ActionEvent e) { System.err.println(this.isShow); // Afficher la JTable du compte if (!this.isShow) { final SQLElement element = Configuration.getInstance().getDirectory().getElement("ECRITURE"); final SQLTable ecrTable = element.getTable(); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.DATE, 1); Date inf = cal.getTime(); cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE)); Date sup = cal.getTime(); System.out.println("Inf : " + inf + " Sup : " + sup); Where w = new Where(ecrTable.getField("ID_JOURNAL"), "=", jrnl.getId()); Where w2 = new Where(ecrTable.getField("DATE"), inf, sup); if (!UserManager.getInstance().getCurrentUser().getRights() .haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) { // TODO Show Restricted acces in UI w = w.and(new Where(ecrTable.getField("COMPTE_NUMERO"), "LIKE", "411%")); } this.listEcriture = new ListPanelEcritures(element, w.and(w2)); this.listEcriture.setModificationVisible(false); this.listEcriture.setAjoutVisible(false); this.listEcriture.setSuppressionVisible(false); this.listEcriture.getListe().setSQLEditable(false); Dimension d; // Taille limite 200 maximum if (this.listEcriture.getListe().getPreferredSize().height > 200) { d = new Dimension(this.listEcriture.getListe().getPreferredSize().width, 200); } else { d = new Dimension(this.listEcriture.getListe().getPreferredSize().width, this.listEcriture.getListe().getPreferredSize().height + 30); } this.listEcriture.getListe().setPreferredSize(d); // c.gridy = 2; c.gridx = 0; c.gridy = 1; c.gridwidth = 4; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; this.listEcriture.getListe().setSQLEditable(false); panelMoisCompte.add(this.listEcriture, c); this.listEcriture.getListe().getJTable().addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { JPopupMenu menu = new JPopupMenu(); menu.add(new AbstractAction("Voir la source") { public void actionPerformed(ActionEvent e) { SQLRow row = base.getTable("ECRITURE") .getRow(listEcriture.getListe().getSelectedId()); MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT")); } }); menu.show(e.getComponent(), e.getPoint().x, e.getPoint().y); } } }); } else { panelMoisCompte.remove(this.listEcriture); System.out.println("Hide ListEcriture"); panelMoisCompte.repaint(); panelMoisCompte.revalidate(); } this.isShow = !this.isShow; SwingUtilities.getRoot(panelMoisCompte).repaint(); } }); return panelMoisCompte; }
From source file:com.AandR.beans.plotting.imagePlotPanel.CanvasPanel.java
/** * Add action bindings/* w w w .ja v a2s. c o m*/ * */ private void addBindings() { // Bind First Frame getActionMap().put("FirstFrame", new AbstractAction("FirstFrame") { public void actionPerformed(ActionEvent evt) { canvasListener.actionPlotFirstFrame(); } }); getInputMap().put(KeyStroke.getKeyStroke("control F"), "FirstFrame"); // Bind Next Frame getActionMap().put("NextFrame", new AbstractAction("NextFrame") { public void actionPerformed(ActionEvent evt) { canvasListener.actionPlotNextFrame(); } }); getInputMap().put(KeyStroke.getKeyStroke("control N"), "NextFrame"); // Bind Choose Frame getActionMap().put("ChooseFrame", new AbstractAction("ChooseFrame") { public void actionPerformed(ActionEvent evt) { canvasListener.actionChooseFrame(); } }); getInputMap().put(KeyStroke.getKeyStroke("control C"), "ChooseFrame"); // Bind Previous Frame getActionMap().put("PreviousFrame", new AbstractAction("PreviousFrame") { public void actionPerformed(ActionEvent evt) { canvasListener.actionPlotPreviousFrame(); } }); getInputMap().put(KeyStroke.getKeyStroke("control P"), "PreviousFrame"); // Bind Last Frame getActionMap().put("LastFrame", new AbstractAction("LastFrame") { public void actionPerformed(ActionEvent evt) { canvasListener.actionPlotLastFrame(); } }); getInputMap().put(KeyStroke.getKeyStroke("control L"), "LastFrame"); // Bind Toggle Log Plot getActionMap().put("LogPlot", new AbstractAction("LogPlot") { public void actionPerformed(ActionEvent evt) { canvasListener.actionToggleLogPlot(); } }); getInputMap().put(KeyStroke.getKeyStroke("L"), "LogPlot"); // Bind SLice Plot getActionMap().put("SlicePlot", new AbstractAction("SlicePlot") { public void actionPerformed(ActionEvent evt) { canvasListener.actionSlicePlot(); } }); getInputMap().put(KeyStroke.getKeyStroke("control alt C"), "SlicePlot"); // Bind Recenter On Viewport getActionMap().put("RecenterOnViewport", new AbstractAction("RecenterOnViewport") { public void actionPerformed(ActionEvent evt) { canvasListener.actionCenterOnViewport(); } }); getInputMap().put(KeyStroke.getKeyStroke("C"), "RecenterOnViewport"); // Bind Flip Horizontally getActionMap().put("FlipHorz", new AbstractAction("FlipHorz") { public void actionPerformed(ActionEvent evt) { canvasListener.actionFlipHorizontally(); } }); getInputMap().put(KeyStroke.getKeyStroke("control alt H"), "FlipHorz"); // Bind Flip Vertically getActionMap().put("FlipVert", new AbstractAction("FlipVert") { public void actionPerformed(ActionEvent evt) { canvasListener.actionFlipVertically(); } }); getInputMap().put(KeyStroke.getKeyStroke("control alt V"), "FlipVert"); // Bind Rotate Right getActionMap().put("RotateRight", new AbstractAction("RotateRight") { public void actionPerformed(ActionEvent evt) { canvasListener.actionRotate(90.0f); } }); getInputMap().put(KeyStroke.getKeyStroke("control alt R"), "RotateRight"); // Bind Rotate Left getActionMap().put("RotateLeft", new AbstractAction("RotateLeft") { public void actionPerformed(ActionEvent evt) { canvasListener.actionRotate(-90.0f); } }); getInputMap().put(KeyStroke.getKeyStroke("control alt L"), "RotateLeft"); // Bind Export Viewport getActionMap().put("ExportViewport", new AbstractAction("ExportViewport") { public void actionPerformed(ActionEvent evt) { canvasListener.actionSaveImageFile(true); } }); getInputMap().put(KeyStroke.getKeyStroke("control S"), "ExportViewport"); // Bind Export Original getActionMap().put("ExportOriginal", new AbstractAction("ExportOriginal") { public void actionPerformed(ActionEvent evt) { canvasListener.actionSaveImageFile(false); } }); getInputMap().put(KeyStroke.getKeyStroke("control alt S"), "ExportOriginal"); // Bind Zoom Dialog getActionMap().put("ZoomDialog", new AbstractAction("ZoomDialog") { public void actionPerformed(ActionEvent evt) { canvasListener.actionShowZoomDialog(); } }); getInputMap().put(KeyStroke.getKeyStroke("control Z"), "ZoomDialog"); // Bind export image series getActionMap().put("ExportSeries", new AbstractAction("ExportSeries") { public void actionPerformed(ActionEvent e) { canvasListener.actionExportSeries(); } }); getInputMap().put(KeyStroke.getKeyStroke("alt S"), "ExportSeries"); // Bind export image to pdf getActionMap().put("ExportToPDF", new AbstractAction("ExportToPDF") { public void actionPerformed(ActionEvent e) { canvasListener.actionExportToPDF(false); } }); getInputMap().put(KeyStroke.getKeyStroke("control shift P"), "ExportToPDF"); // Bind export image to pdf getActionMap().put("ExportToPDF2", new AbstractAction("ExportToPDF2") { public void actionPerformed(ActionEvent e) { canvasListener.actionExportToPDF(true); } }); getInputMap().put(KeyStroke.getKeyStroke("control alt P"), "ExportToPDF2"); // Bind Range Dialog getActionMap().put("RangeDialog", new AbstractAction("RangeDialog") { public void actionPerformed(ActionEvent evt) { canvasListener.actionShowRangeDialog(); } }); getInputMap().put(KeyStroke.getKeyStroke("control R"), "RangeDialog"); // Bind View Extend Dialog getActionMap().put("PhysicalExtentDialog", new AbstractAction("PhysicalExtentDialog") { public void actionPerformed(ActionEvent evt) { canvasListener.actionShowPhysicalDialog(); } }); getInputMap().put(KeyStroke.getKeyStroke("control E"), "PhysicalExtentDialog"); // Bind Add Basic Shape Overlay getActionMap().put("AddBasicShape", new AbstractAction("AddBasicShape") { public void actionPerformed(ActionEvent evt) { canvasListener.actionAddShapeOverlay(); } }); getInputMap().put(KeyStroke.getKeyStroke("control O"), "AddBasicShape"); // Bind Add Basic Shape Overlay getActionMap().put("AddAnnulusShape", new AbstractAction("AddAnnulusShape") { public void actionPerformed(ActionEvent evt) { canvasListener.actionAddAnnulusOverlay(); } }); getInputMap().put(KeyStroke.getKeyStroke("control U"), "AddAnnulusShape"); // Bind Add Text Overlay getActionMap().put("AddTextOverlay", new AbstractAction("AddTextOverlay") { public void actionPerformed(ActionEvent evt) { canvasListener.actionAddTextOverlay(); } }); getInputMap().put(KeyStroke.getKeyStroke("control T"), "AddTextOverlay"); // Bind Arrow Overlay getActionMap().put("AddArrowOverlay", new AbstractAction("AddArrowOverlay") { public void actionPerformed(ActionEvent evt) { canvasListener.actionAddArrowOverlay(); } }); getInputMap().put(KeyStroke.getKeyStroke("control A"), "AddArrowOverlay"); // Bind Colormap Chooser getActionMap().put("ColorMapChooser", new AbstractAction("ColorMapChooser") { public void actionPerformed(ActionEvent e) { canvasListener.actionColormapChooser(); } }); getInputMap().put(KeyStroke.getKeyStroke("control M"), "ColorMapChooser"); // Bind Refresh Action getActionMap().put("ReloadFile", new AbstractAction("ReloadFile") { public void actionPerformed(ActionEvent e) { canvasListener.actionReloadFile(); } }); getInputMap().put(KeyStroke.getKeyStroke("F5"), "ReloadFile"); }
From source file:org.geopublishing.atlasStyler.swing.AtlasStylerGUI.java
/** * This method initializes jToolBar/* www. ja v a 2 s.c om*/ * * @return javax.swing.JToolBar */ private JToolBar getJToolBar() { JToolBar jToolBar = new JToolBar(); jToolBar.setFloatable(false); AbstractAction importWiazrdAction = new AbstractAction( AtlasStylerVector.R("MenuBar.FileMenu.ImportWizard")) { @Override public void actionPerformed(ActionEvent e) { ImportWizard.showWizard(AtlasStylerGUI.this, AtlasStylerGUI.this); } }; importWiazrdAction.putValue(Action.LONG_DESCRIPTION, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.CTRL_MASK, true)); jToolBar.add(importWiazrdAction); jToolBar.add(getJTButtonShowXML()); jToolBar.add(getJTButtonExportAsSLD()); return jToolBar; }
From source file:mondrian.gui.Workbench.java
/** * This method is called from within the constructor to * initialize the form./* www . j av a 2 s. c o 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:nz.ac.massey.cs.gql4jung.browser.ResultBrowser.java
private void initBuildInQuery(String name, final String file) { final File f = new File(file); if (f.exists()) { AbstractAction act = new AbstractAction(name) { @Override/*from w ww . j av a2 s.c o m*/ public void actionPerformed(ActionEvent e) { loadQuery(f); } }; this.actLoadBuiltInQueries.add(act); log("added action to load query from file " + f); } else { log("cannot add action to load query from file " + f); } }
From source file:net.schweerelos.parrot.CombinedParrotApp.java
@SuppressWarnings("serial") private JToggleButton setupNavigatorButton(final String name, final String accelerator, final NavigatorComponent navigator) { final Component component = navigator.asJComponent(); AbstractAction showNavigatorAction = new AbstractAction(name) { @Override//from ww w.java 2 s . c o m public void actionPerformed(ActionEvent e) { if (!(e.getSource() instanceof JToggleButton)) { return; } final Window window; if (component instanceof Window) { window = (Window) component; } else { window = SwingUtilities.getWindowAncestor(component); } JToggleButton button = (JToggleButton) e.getSource(); boolean show = button.isSelected(); if (show) { if (window != CombinedParrotApp.this && preferredFrameLocations.containsKey(window)) { window.setLocation(preferredFrameLocations.get(window)); } } if (navigator.tellSelectionWhenShown()) { Collection<NodeWrapper> selectedNodes = activeMainView.getSelectedNodes(); navigator.setSelectedNodes(selectedNodes); } component.setVisible(show); if (show) { window.setVisible(true); } else if (window != CombinedParrotApp.this) { window.setVisible(false); } } }; showNavigatorAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control " + accelerator)); final JToggleButton button = new JToggleButton(showNavigatorAction); button.setToolTipText("Show " + name.toLowerCase()); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button.setToolTipText((button.isSelected() ? "Hide " : "Show ") + name.toLowerCase()); } }); final Window window; if (component instanceof Window) { window = (Window) component; } else { window = SwingUtilities.getWindowAncestor(component); } if (window != null) { window.addComponentListener(new ComponentAdapter() { @Override public void componentHidden(ComponentEvent e) { button.setSelected(false); if (window != CombinedParrotApp.this) { preferredFrameLocations.put(window, window.getLocation()); } } @Override public void componentShown(ComponentEvent e) { button.setSelected(true); } }); } return button; }