List of usage examples for javax.swing Action getValue
public Object getValue(String key);
From source file:ro.nextreports.designer.querybuilder.QueryBuilderPanel.java
private void initUI() { JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.setDividerLocation(250);//ww w . ja va2 s . c o m split.setOneTouchExpandable(true); JToolBar toolBar = new JToolBar(); toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // hide buttons borders toolBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); toolBar.setBorderPainted(false); // add refresh action toolBar.add(new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("refresh"); } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) { return I18NSupport.getString("querybuilder.refresh"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { try { if (Globals.getConnection() == null) { return; } // refresh tables, views, procedures TreeUtil.refreshDatabase(); // add new queries to tree TreeUtil.refreshQueries(); // add new reports to tree TreeUtil.refreshReports(); // add new charts to tree TreeUtil.refreshCharts(); } catch (Exception ex) { Show.error(ex); } } }); // add expand action toolBar.add(new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("expandall"); } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) { return I18NSupport.getString("querybuilder.expand.all"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { TreeUtil.expandAll(dbBrowserTree); } }); // add collapse action toolBar.add(new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("collapseall"); } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) { return I18NSupport.getString("querybuilder.collapse.all"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { TreeUtil.collapseAll(dbBrowserTree); } }); // add properties button /* JButton propButton = new MagicButton(new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("properties"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { DBBrowserPropertiesPanel joinPanel = new DBBrowserPropertiesPanel(); JDialog dlg = new DBBrowserPropertiesDialog(joinPanel); dlg.pack(); dlg.setResizable(false); Show.centrateComponent(Globals.getMainFrame(), dlg); dlg.setVisible(true); } }); propButton.setToolTipText(I18NSupport.getString("querybuilder.properties")); */ //browserButtonsPanel.add(propButton); // ro.nextreports.designer.util.SwingUtil.registerButtonsForFocus(browserButtonsPanel); browserPanel = new JXPanel(new BorderLayout()); browserPanel.add(toolBar, BorderLayout.NORTH); // browser tree JScrollPane scroll = new JScrollPane(dbBrowserTree); browserPanel.add(scroll, BorderLayout.CENTER); split.setLeftComponent(browserPanel); tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM); // tabbedPane.putClientProperty(Options.EMBEDDED_TABS_KEY, Boolean.TRUE); // look like eclipse JSplitPane split2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split2.setResizeWeight(0.66); split2.setOneTouchExpandable(true); // desktop pane desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); desktop.setDropTarget( new DropTarget(desktop, DnDConstants.ACTION_MOVE, new DesktopPaneDropTargetListener(), true)); // create the toolbar JToolBar toolBar2 = new JToolBar(); toolBar2.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // hide buttons borders toolBar2.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); toolBar2.setBorderPainted(false); Action distinctAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (distinctButton.isSelected()) { selectQuery.setDistinct(true); } else { selectQuery.setDistinct(false); } } }; distinctAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("query.distinct")); distinctAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("querybuilder.distinct")); toolBar2.add(distinctButton = new JToggleButton(distinctAction)); Action groupByAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { groupBy = groupByButton.isSelected(); Globals.getEventBus().publish(new GroupByEvent(QueryBuilderPanel.this.desktop, groupBy)); } }; groupByAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("query.group_by")); groupByAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("querybuilder.group.by")); toolBar2.add(groupByButton = new JToggleButton(groupByAction)); Action clearAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { clear(false); } }; clearAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("clear")); clearAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("querybuilder.clear")); toolBar2.add(clearAction); // add separator SwingUtil.addCustomSeparator(toolBar2); // add run button Action runQueryAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { selectSQLViewTab(); sqlView.doRun(); } }; runQueryAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("run")); KeyStroke ks = KeyStroke.getKeyStroke(ShortcutsUtil.getShortcut("query.run.accelerator", "control 4")); runQueryAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("run.query") + " (" + ShortcutsUtil.getShortcut("query.run.accelerator.display", "Ctrl 4") + ")"); runQueryAction.putValue(Action.ACCELERATOR_KEY, ks); toolBar2.add(runQueryAction); // register run query shortcut GlobalHotkeyManager hotkeyManager = GlobalHotkeyManager.getInstance(); InputMap inputMap = hotkeyManager.getInputMap(); ActionMap actionMap = hotkeyManager.getActionMap(); inputMap.put((KeyStroke) runQueryAction.getValue(Action.ACCELERATOR_KEY), "runQueryAction"); actionMap.put("runQueryAction", runQueryAction); JScrollPane scroll2 = new JScrollPane(desktop, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scroll2.setPreferredSize(DBTablesDesktopPane.PREFFERED_SIZE); DecoratedScrollPane.decorate(scroll2); JPanel topPanel = new JPanel(); topPanel.setLayout(new GridBagLayout()); topPanel.add(toolBar2, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); topPanel.add(scroll2, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); split2.setTopComponent(topPanel); designPanel = new DesignerTablePanel(selectQuery); split2.setBottomComponent(designPanel); split2.setDividerLocation(400); tabbedPane.addTab(I18NSupport.getString("querybuilder.query.designer"), ImageUtil.getImageIcon("designer"), split2); tabbedPane.setMnemonicAt(0, 'D'); sqlView = new SQLViewPanel(); sqlView.getEditorPane().setDropTarget(new DropTarget(sqlView.getEditorPane(), DnDConstants.ACTION_MOVE, new SQLViewDropTargetListener(), true)); tabbedPane.addTab(I18NSupport.getString("querybuilder.query.editor"), ImageUtil.getImageIcon("sql"), sqlView); tabbedPane.setMnemonicAt(1, 'E'); split.setRightComponent(tabbedPane); // register a change listener tabbedPane.addChangeListener(new ChangeListener() { // this method is called whenever the selected tab changes public void stateChanged(ChangeEvent ev) { if (ev.getSource() == QueryBuilderPanel.this.tabbedPane) { // get current tab int sel = QueryBuilderPanel.this.tabbedPane.getSelectedIndex(); if (sel == 1) { // sql view String query; if (!synchronizedPanels) { query = sqlView.getQueryString(); synchronizedPanels = true; } else { if (Globals.getConnection() != null) { query = getSelectQuery().toString(); } else { query = ""; } // if (query.equals("")) { // query = sqlView.getQueryString(); // } } if (resetTable) { sqlView.clear(); resetTable = false; } //System.out.println("query="+query); sqlView.setQueryString(query); } else if (sel == 0) { // design view if (queryWasModified(false)) { Object[] options = { I18NSupport.getString("optionpanel.yes"), I18NSupport.getString("optionpanel.no") }; String m1 = I18NSupport.getString("querybuilder.lost"); String m2 = I18NSupport.getString("querybuilder.continue"); int option = JOptionPane.showOptionDialog(Globals.getMainFrame(), "<HTML>" + m1 + "<BR>" + m2 + "</HTML>", I18NSupport.getString("querybuilder.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); if (option != JOptionPane.YES_OPTION) { synchronizedPanels = false; tabbedPane.setSelectedIndex(1); } else { resetTable = true; } } } else if (sel == 2) { // report view } } } }); // this.add(split, BorderLayout.CENTER); parametersPanel = new ParametersPanel(); }
From source file:se.trixon.jota.client.ui.MainFrame.java
private void loadClientOption(ClientOptionsEvent clientOptionEvent) { switch (clientOptionEvent) { case LOOK_AND_FEEL: if (mOptions.isForceLookAndFeel()) { SwingUtilities.invokeLater(() -> { try { UIManager.setLookAndFeel(SwingHelper.getLookAndFeelClassName(mOptions.getLookAndFeel())); SwingUtilities.updateComponentTreeUI(MainFrame.this); SwingUtilities.updateComponentTreeUI(sPopupMenu); if (mOptions.getLookAndFeel().equalsIgnoreCase("Darcula")) { int iconSize = 32; UIDefaults uiDefaults = UIManager.getLookAndFeelDefaults(); uiDefaults.put("OptionPane.informationIcon", MaterialIcon.Action.INFO_OUTLINE.get(iconSize, IconColor.WHITE)); uiDefaults.put("OptionPane.errorIcon", MaterialIcon.Alert.ERROR_OUTLINE.get(iconSize, IconColor.WHITE)); uiDefaults.put("OptionPane.questionIcon", MaterialIcon.Action.HELP_OUTLINE.get(iconSize, IconColor.WHITE)); uiDefaults.put("OptionPane.warningIcon", MaterialIcon.Alert.WARNING.get(iconSize, IconColor.WHITE)); }// w ww. j ava 2 s . c o m } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { //Xlog.timedErr(ex.getMessage()); } }); } break; case MENU_ICONS: ActionMap actionMap = getRootPane().getActionMap(); for (Object allKey : actionMap.allKeys()) { Action action = actionMap.get(allKey); Icon icon = null; if (mOptions.isDisplayMenuIcons()) { icon = (Icon) action.getValue(ActionManager.JOTA_SMALL_ICON_KEY); } action.putValue(Action.SMALL_ICON, icon); } break; default: throw new AssertionError(); } }
From source file:storybook.action.ActionHandler.java
public void handleRenameCity() { RenameCityDialog dlg = new RenameCityDialog(mainFrame); ActionManager actMngr = mainFrame.getSbActionManager().getActionManager(); Action act = actMngr.getAction("rename-city-command"); Object obj = act.getValue(SbConstants.ActionKey.CATEGORY.toString()); if (obj != null) { dlg.setSelectedItem(obj);/* ww w. j av a 2s . c o m*/ } SwingUtil.showModalDialog(dlg, mainFrame); act.putValue(SbConstants.ActionKey.CATEGORY.toString(), null); }
From source file:storybook.action.ActionHandler.java
public void handleRenameCountry() { RenameCountryDialog dlg = new RenameCountryDialog(mainFrame); ActionManager actMngr = mainFrame.getSbActionManager().getActionManager(); Action act = actMngr.getAction("rename-country-command"); Object obj = act.getValue(SbConstants.ActionKey.CATEGORY.toString()); if (obj != null) { dlg.setSelectedItem(obj);// www .j a v a 2s . co m } SwingUtil.showModalDialog(dlg, mainFrame); act.putValue(SbConstants.ActionKey.CATEGORY.toString(), null); }
From source file:storybook.action.ActionHandler.java
public void handleRenameTagCategory() { RenameTagCategoryDialog dlg = new RenameTagCategoryDialog(mainFrame); ActionManager actMngr = mainFrame.getSbActionManager().getActionManager(); Action act = actMngr.getAction("rename-tag-category-command"); Object obj = act.getValue(SbConstants.ActionKey.CATEGORY.toString()); if (obj != null) { dlg.setSelectedItem(obj);//from ww w . j a v a2 s .c om } SwingUtil.showModalDialog(dlg, mainFrame); act.putValue(SbConstants.ActionKey.CATEGORY.toString(), null); }
From source file:storybook.action.ActionHandler.java
public void handleRenameItemCategory() { RenameItemCategoryDialog dlg = new RenameItemCategoryDialog(mainFrame); ActionManager actMngr = mainFrame.getSbActionManager().getActionManager(); Action act = actMngr.getAction("rename-item-category-command"); Object obj = act.getValue(SbConstants.ActionKey.CATEGORY.toString()); if (obj != null) { dlg.setSelectedItem(obj);/*from w ww . j av a2s . c o m*/ } SwingUtil.showModalDialog(dlg, mainFrame); act.putValue(SbConstants.ActionKey.CATEGORY.toString(), null); }
From source file:tk.tomby.tedit.services.ActionManager.java
/** * DOCUMENT ME!//from ww w . j a va2 s. com * * @param action DOCUMENT ME! */ public static void addAction(Action action) { actions.put((String) action.getValue("name"), action); }
From source file:us.daveread.basicquery.BasicQuery.java
/** * Copy the selected data cells to the clipboard *///from w w w . j av a 2 s. co m private void copySelectionToClipboard() { Action objlCopy; try { objlCopy = TransferHandler.getCopyAction(); objlCopy.actionPerformed(new ActionEvent(table, ActionEvent.ACTION_PERFORMED, (String) objlCopy.getValue(Action.NAME), EventQueue.getMostRecentEventTime(), 0)); } catch (Throwable any) { LOGGER.error("Failed to copy data to clipboard", any); JOptionPane.showMessageDialog(this, Resources.getString("errClipboardCopyDataText", any.getClass().getName(), any.getMessage() != null ? any.getMessage() : ""), Resources.getString("errClipboardCopyDataTitle"), JOptionPane.ERROR_MESSAGE); } }