Example usage for javax.swing Action SMALL_ICON

List of usage examples for javax.swing Action SMALL_ICON

Introduction

In this page you can find the example usage for javax.swing Action SMALL_ICON.

Prototype

String SMALL_ICON

To view the source code for javax.swing Action SMALL_ICON.

Click Source Link

Document

The key used for storing a small Icon, such as ImageIcon.

Usage

From source file:ro.nextreports.designer.querybuilder.SQLViewPanel.java

private void initUI() {
    sqlEditor = new Editor() {
        public void afterCaretMove() {
            removeHighlightErrorLine();//from  w w  w.ja v a 2s  .co  m
        }
    };
    this.queryArea = sqlEditor.getEditorPanel().getEditorPane();
    queryArea.setText(DEFAULT_QUERY);

    errorPainter = new javax.swing.text.Highlighter.HighlightPainter() {
        @Override
        public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c) {
            try {
                Rectangle r = c.modelToView(c.getCaretPosition());
                g.setColor(Color.RED.brighter().brighter());
                g.fillRect(0, r.y, c.getWidth(), r.height);
            } catch (BadLocationException e) {
                // ignore
            }
        }
    };

    ActionMap actionMap = sqlEditor.getEditorPanel().getEditorPane().getActionMap();

    // create the toolbar
    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 cut action
    Action cutAction = actionMap.get(BaseEditorKit.cutAction);
    cutAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("cut"));
    cutAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.cut"));
    toolBar.add(cutAction);

    // add copy action
    Action copyAction = actionMap.get(BaseEditorKit.copyAction);
    copyAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("copy"));
    copyAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.copy"));
    toolBar.add(copyAction);

    // add paste action
    Action pasteAction = actionMap.get(BaseEditorKit.pasteAction);
    pasteAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("paste"));
    pasteAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.paste"));
    toolBar.add(pasteAction);

    // add separator
    SwingUtil.addCustomSeparator(toolBar);

    // add undo action
    Action undoAction = actionMap.get(BaseEditorKit.undoAction);
    undoAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("undo"));
    undoAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("undo"));
    toolBar.add(undoAction);

    // add redo action
    Action redoAction = actionMap.get(BaseEditorKit.redoAction);
    redoAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("redo"));
    redoAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("redo"));
    toolBar.add(redoAction);

    // add separator
    SwingUtil.addCustomSeparator(toolBar);

    // add find action
    Action findReplaceAction = actionMap.get(BaseEditorKit.findReplaceAction);
    findReplaceAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("find"));
    findReplaceAction.putValue(Action.SHORT_DESCRIPTION,
            I18NSupport.getString("sqleditor.findReplaceActionName"));
    toolBar.add(findReplaceAction);

    // add separator
    SwingUtil.addCustomSeparator(toolBar);

    // add run action
    runAction = new SQLRunAction();
    runAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("run"));
    runAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(ShortcutsUtil.getShortcut("query.run.accelerator", "control 4")));
    runAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("run.query") + " ("
            + ShortcutsUtil.getShortcut("query.run.accelerator.display", "Ctrl 4") + ")");
    // runAction is globally registered in QueryBuilderPanel !
    toolBar.add(runAction);

    //        ro.nextreports.designer.util.SwingUtil.registerButtonsForFocus(buttonsPanel);

    // create the table
    resultTable = new JXTable();
    resultTable.setDefaultRenderer(Integer.class, new ToStringRenderer()); // to remove thousand separators
    resultTable.setDefaultRenderer(Long.class, new ToStringRenderer());
    resultTable.setDefaultRenderer(Date.class, new DateRenderer());
    resultTable.setDefaultRenderer(Double.class, new DoubleRenderer());
    resultTable.addMouseListener(new CopyTableMouseAdapter(resultTable));
    TableUtil.setRowHeader(resultTable);
    resultTable.setColumnControlVisible(true);
    //        resultTable.getTableHeader().setReorderingAllowed(false);
    resultTable.setHorizontalScrollEnabled(true);

    // highlight table
    Highlighter alternateHighlighter = HighlighterFactory.createAlternateStriping(Color.WHITE,
            ColorUtil.PANEL_BACKROUND_COLOR);
    Highlighter nullHighlighter = new TextHighlighter(ResultSetTableModel.NULL_VALUE, Color.YELLOW.brighter());
    Highlighter blobHighlighter = new TextHighlighter(ResultSetTableModel.BLOB_VALUE, Color.GRAY.brighter());
    Highlighter clobHighlighter = new TextHighlighter(ResultSetTableModel.CLOB_VALUE, Color.GRAY.brighter());
    resultTable.setHighlighters(alternateHighlighter, nullHighlighter, blobHighlighter, clobHighlighter);
    resultTable.setBackground(ColorUtil.PANEL_BACKROUND_COLOR);
    resultTable.setGridColor(Color.LIGHT_GRAY);

    resultTable.setRolloverEnabled(true);
    resultTable.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.RED));

    JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    split.setResizeWeight(0.66);
    split.setOneTouchExpandable(true);

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new GridBagLayout());
    topPanel.add(toolBar, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    topPanel.add(sqlEditor, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new GridBagLayout());
    JScrollPane scrPanel = new JScrollPane(resultTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    statusPanel = new SQLStatusPanel();
    bottomPanel.add(scrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    bottomPanel.add(statusPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));

    split.setTopComponent(topPanel);
    split.setBottomComponent(bottomPanel);
    split.setDividerLocation(400);

    setLayout(new BorderLayout());
    this.add(split, BorderLayout.CENTER);
}

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));
                    }//from ww  w.j  av  a2s .  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:tvbrowser.extras.favoritesplugin.dlgs.FavoriteTreeModel.java

public void updatePluginTree(final PluginTreeNode node, final ArrayList<Program> allPrograms,
        FavoriteNode parentFavorite) {/*from   w ww.  j  a  v  a  2 s .c  o m*/
    if (parentFavorite == null) {
        parentFavorite = (FavoriteNode) getRoot();
    }

    if (parentFavorite.isDirectoryNode()) {
        @SuppressWarnings("unchecked")
        Enumeration<FavoriteNode> e = parentFavorite.children();

        while (e.hasMoreElements()) {
            final FavoriteNode child = e.nextElement();

            if (child.isDirectoryNode()) {
                PluginTreeNode newNode = new PluginTreeNode(child.toString());
                newNode.setGroupingByWeekEnabled(true);

                updatePluginTree(newNode, allPrograms, child);
                if (!newNode.isEmpty()) {
                    node.add(newNode);
                }
            } else {
                Program[] progArr = child.getFavorite().getWhiteListPrograms();
                if (progArr.length > 0) {
                    PluginTreeNode newNode = new PluginTreeNode(child.toString());
                    newNode.setGroupingByWeekEnabled(true);
                    newNode.getMutableTreeNode().setIcon(FavoritesPlugin.getFavoritesIcon(16));
                    node.add(newNode);
                    Action editFavorite = new AbstractAction() {
                        public void actionPerformed(ActionEvent e) {
                            FavoritesPlugin.getInstance().editFavorite(child.getFavorite());
                        }
                    };
                    editFavorite.putValue(Action.NAME, mLocalizer.ellipsisMsg("editTree", "Edit"));
                    editFavorite.putValue(Action.SMALL_ICON, TVBrowserIcons.edit(TVBrowserIcons.SIZE_SMALL));

                    Action deleteFavorite = new AbstractAction() {
                        public void actionPerformed(ActionEvent e) {
                            FavoritesPlugin.getInstance().askAndDeleteFavorite(child.getFavorite());
                        }
                    };
                    deleteFavorite.putValue(Action.NAME, mLocalizer.ellipsisMsg("deleteTree", "Delete"));
                    deleteFavorite.putValue(Action.SMALL_ICON,
                            TVBrowserIcons.delete(TVBrowserIcons.SIZE_SMALL));
                    deleteFavorite.putValue(ContextMenuIf.ACTIONKEY_KEYBOARD_EVENT, KeyEvent.VK_DELETE);

                    newNode.addAction(editFavorite);
                    newNode.addAction(deleteFavorite);

                    if (progArr.length <= 10) {
                        newNode.setGroupingByDateEnabled(false);
                    }
                    boolean episodeOnly = progArr.length > 1;
                    for (Program program : progArr) {
                        String episode = program.getTextField(ProgramFieldType.EPISODE_TYPE);
                        if (StringUtils.isBlank(episode)) {
                            episodeOnly = false;
                            break;
                        }
                    }

                    for (Program program : progArr) {
                        PluginTreeNode pNode = newNode.addProgramWithoutCheck(program);
                        allPrograms.add(program);
                        if (episodeOnly || progArr.length <= 10) {
                            pNode.setNodeFormatter(new NodeFormatter() {
                                public String format(ProgramItem pitem) {
                                    Program p = pitem.getProgram();
                                    return FavoriteTreeModel.getFavoriteLabel(child.getFavorite(), p);
                                }
                            });
                        }
                    }
                }
            }
        }
    }
}

From source file:tvbrowser.extras.reminderplugin.ReminderPlugin.java

/**
 * Updates the plugin tree entry for this plugin.
 * <p>/*  ww w  . ja  v  a  2s . com*/
 *
 * @param save
 *          <code>True</code> if the reminder entries should be saved.
 */
public void updateRootNode(boolean save) {
    mRootNode.removeAllActions();
    mRootNode.getMutableTreeNode()
            .setIcon(IconLoader.getInstance().getIconFromTheme("apps", "appointment", 16));

    Action editReminders = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            ReminderListDialog dlg = new ReminderListDialog(MainFrame.getInstance(), mReminderList);
            UiUtilities.centerAndShow(dlg);
        }
    };
    editReminders.putValue(Action.SMALL_ICON,
            IconLoader.getInstance().getIconFromTheme("apps", "appointment", 16));
    editReminders.putValue(Action.NAME, mLocalizer.ellipsisMsg("buttonText", "Edit reminder list"));

    Action openSettings = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            MainFrame.getInstance().showSettingsDialog(SettingsItem.REMINDER);
        }
    };
    openSettings.putValue(Action.SMALL_ICON, TVBrowserIcons.preferences(TVBrowserIcons.SIZE_SMALL));
    openSettings.putValue(Action.NAME, Localizer.getLocalization(Localizer.I18N_SETTINGS));

    mRootNode.addAction(editReminders);
    mRootNode.addAction(null);
    mRootNode.addAction(openSettings);

    mRootNode.removeAllChildren();

    ReminderListItem[] items = mReminderList.getReminderItems();
    ArrayList<Program> listNewPrograms = new ArrayList<Program>(items.length);
    for (ReminderListItem reminderItem : items) {
        listNewPrograms.add(reminderItem.getProgram());
    }
    mRootNode.addPrograms(listNewPrograms);

    mRootNode.update();

    if (save && mHasRightToSave) {
        saveReminders();
    }
}

From source file:tvbrowser.extras.reminderplugin.ReminderPlugin.java

protected static ActionMenu getButtonAction() {
    AbstractAction action = new AbstractAction() {
        public void actionPerformed(ActionEvent evt) {
            getInstance().showManageRemindersDialog();
        }/*from  www  .  j  ava  2 s  .co m*/
    };

    action.putValue(Action.NAME, getName());
    action.putValue(Action.SMALL_ICON, IconLoader.getInstance().getIconFromTheme("apps", "appointment", 16));
    action.putValue(Plugin.BIG_ICON, IconLoader.getInstance().getIconFromTheme("apps", "appointment", 22));
    action.putValue(Action.SHORT_DESCRIPTION,
            mLocalizer.msg("description", "Reminds you of programs to not miss them."));

    return new ActionMenu(action);
}