Search in sources :

Example 1 with JCommandButton

use of org.pushingpixels.flamingo.api.common.JCommandButton in project gephi by gephi.

the class DataTableTopComponent method preparePluginGeneralActionsButton.

/**
     * Prepare a button for the popup panel for plugin general actions.
     *
     * @param m PluginGeneralActionsManipulator for the button
     * @return JCommandButton for the manipulator
     */
private JCommandButton preparePluginGeneralActionsButton(final PluginGeneralActionsManipulator m) {
    //Convert icon to Image if it is not null
    JCommandButton button = new JCommandButton(m.getName(), m.getIcon() != null ? ImageWrapperResizableIcon.getIcon(ImageUtilities.icon2Image(m.getIcon()), new Dimension(16, 16)) : null);
    button.setDisplayState(CommandButtonDisplayState.BIG);
    button.setCommandButtonKind(JCommandButton.CommandButtonKind.ACTION_ONLY);
    if (m.getDescription() != null && !m.getDescription().isEmpty()) {
        button.setPopupRichTooltip(new RichTooltip(NbBundle.getMessage(DataTableTopComponent.class, "DataTableTopComponent.RichToolTip.title.text"), m.getDescription()));
    }
    if (m.canExecute()) {
        button.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                DataLaboratoryHelper.getDefault().executeManipulator(m);
            }
        });
    } else {
        button.setEnabled(false);
    }
    return button;
}
Also used : RichTooltip(org.pushingpixels.flamingo.api.common.RichTooltip) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JCommandButton(org.pushingpixels.flamingo.api.common.JCommandButton) Dimension(java.awt.Dimension)

Example 2 with JCommandButton

use of org.pushingpixels.flamingo.api.common.JCommandButton in project gephi by gephi.

the class DataTableTopComponent method prepareAddColumnButton.

/**
     * Create the special Add new column button.
     */
private void prepareAddColumnButton() {
    JCommandButtonStrip strip = new JCommandButtonStrip(JCommandButtonStrip.StripOrientation.HORIZONTAL);
    strip.setDisplayState(CommandButtonDisplayState.BIG);
    JCommandButton button = new JCommandButton(NbBundle.getMessage(DataTableTopComponent.class, "DataTableTopComponent.addColumnButton.text"), ImageWrapperResizableIcon.getIcon(ImageUtilities.loadImage("org/gephi/desktop/datalab/resources/table-insert-column.png", true), new Dimension(16, 16)));
    button.setCommandButtonKind(JCommandButton.CommandButtonKind.ACTION_ONLY);
    button.setDisplayState(CommandButtonDisplayState.BIG);
    if (isShowingNodesTable()) {
        button.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                showAddColumnUI(AddColumnUI.Mode.NODES_TABLE);
            }
        });
    } else {
        button.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                showAddColumnUI(AddColumnUI.Mode.EDGES_TABLE);
            }
        });
    }
    strip.add(button);
    columnManipulatorsPanel.add(strip);
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JCommandButton(org.pushingpixels.flamingo.api.common.JCommandButton) Dimension(java.awt.Dimension) JCommandButtonStrip(org.pushingpixels.flamingo.api.common.JCommandButtonStrip)

Example 3 with JCommandButton

use of org.pushingpixels.flamingo.api.common.JCommandButton in project gephi by gephi.

the class DataTableTopComponent method prepareJCommandButton.

/**
     * Creates a JCommandButton for the specified columns of a table and
     * AttributeColumnsManipulator
     *
     * @param graphModel graph model
     * @param table table
     * @param columns Columns
     * @param acm AttributeColumnsManipulator
     * @return Prepared JCommandButton
     */
private JCommandButton prepareJCommandButton(final GraphModel graphModel, final Table table, final Column[] columns, final AttributeColumnsManipulator acm) {
    JCommandButton manipulatorButton;
    if (acm.getIcon() != null) {
        manipulatorButton = new JCommandButton(acm.getName(), ImageWrapperResizableIcon.getIcon(acm.getIcon(), new Dimension(16, 16)));
    } else {
        manipulatorButton = new JCommandButton(acm.getName());
    }
    manipulatorButton.setCommandButtonKind(JCommandButton.CommandButtonKind.POPUP_ONLY);
    manipulatorButton.setDisplayState(CommandButtonDisplayState.MEDIUM);
    if (acm.getDescription() != null && !acm.getDescription().isEmpty()) {
        manipulatorButton.setPopupRichTooltip(new RichTooltip(NbBundle.getMessage(DataTableTopComponent.class, "DataTableTopComponent.RichToolTip.title.text"), acm.getDescription()));
    }
    final ArrayList<Column> availableColumns = new ArrayList<>();
    for (final Column column : columns) {
        if (acm.canManipulateColumn(table, column)) {
            availableColumns.add(column);
        }
    }
    if (!availableColumns.isEmpty()) {
        manipulatorButton.setPopupCallback(new PopupPanelCallback() {

            @Override
            public JPopupPanel getPopupPanel(JCommandButton jcb) {
                JCommandPopupMenu popup = new JCommandPopupMenu();
                JCommandMenuButton button;
                for (final Column column : availableColumns) {
                    button = new JCommandMenuButton(column.getTitle(), ImageWrapperResizableIcon.getIcon(ImageUtilities.loadImage("org/gephi/desktop/datalab/resources/column.png"), new Dimension(16, 16)));
                    button.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            DataLaboratoryHelper.getDefault().executeAttributeColumnsManipulator(acm, graphModel, table, column);
                        }
                    });
                    popup.addMenuButton(button);
                }
                return popup;
            }
        });
    } else {
        manipulatorButton.setEnabled(false);
    }
    return manipulatorButton;
}
Also used : ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) PopupPanelCallback(org.pushingpixels.flamingo.api.common.popup.PopupPanelCallback) JPopupPanel(org.pushingpixels.flamingo.api.common.popup.JPopupPanel) JCommandButton(org.pushingpixels.flamingo.api.common.JCommandButton) Dimension(java.awt.Dimension) RichTooltip(org.pushingpixels.flamingo.api.common.RichTooltip) JCommandMenuButton(org.pushingpixels.flamingo.api.common.JCommandMenuButton) ActionListener(java.awt.event.ActionListener) Column(org.gephi.graph.api.Column) JCommandPopupMenu(org.pushingpixels.flamingo.api.common.popup.JCommandPopupMenu)

Example 4 with JCommandButton

use of org.pushingpixels.flamingo.api.common.JCommandButton in project gephi by gephi.

the class DataTableTopComponent method prepareMergeColumnsButton.

/**
     * Create the special merge columns button.
     */
private void prepareMergeColumnsButton() {
    JCommandButtonStrip strip = new JCommandButtonStrip(JCommandButtonStrip.StripOrientation.HORIZONTAL);
    strip.setDisplayState(CommandButtonDisplayState.BIG);
    JCommandButton button = new JCommandButton(NbBundle.getMessage(DataTableTopComponent.class, "DataTableTopComponent.mergeColumnsButton.text"), ImageWrapperResizableIcon.getIcon(ImageUtilities.loadImage("org/gephi/desktop/datalab/resources/merge.png", true), new Dimension(16, 16)));
    button.setCommandButtonKind(JCommandButton.CommandButtonKind.ACTION_ONLY);
    button.setDisplayState(CommandButtonDisplayState.BIG);
    if (isShowingNodesTable()) {
        button.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                showMergeColumnsUI(MergeColumnsUI.Mode.NODES_TABLE);
            }
        });
    } else {
        button.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                showMergeColumnsUI(MergeColumnsUI.Mode.EDGES_TABLE);
            }
        });
    }
    strip.add(button);
    columnManipulatorsPanel.add(strip);
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JCommandButton(org.pushingpixels.flamingo.api.common.JCommandButton) Dimension(java.awt.Dimension) JCommandButtonStrip(org.pushingpixels.flamingo.api.common.JCommandButtonStrip)

Example 5 with JCommandButton

use of org.pushingpixels.flamingo.api.common.JCommandButton in project gephi by gephi.

the class DataTableTopComponent method prepareGeneralActionsButtons.

/**
     * Adds the buttons for the GeneralActionsManipulators.
     */
public void prepareGeneralActionsButtons() {
    //Figure out the index to place the buttons, in order to put them between separator 2 and the boxGlue.
    int index = controlToolbar.getComponentIndex(boxGlue);
    final DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
    JButton button;
    for (final GeneralActionsManipulator m : dlh.getGeneralActionsManipulators()) {
        button = new JButton(m.getName(), m.getIcon());
        if (m.getDescription() != null && !m.getDescription().isEmpty()) {
            button.setToolTipText(m.getDescription());
        }
        if (m.canExecute()) {
            button.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    dlh.executeManipulator(m);
                }
            });
        } else {
            button.setEnabled(false);
        }
        controlToolbar.add(button, index);
        index++;
        generalActionsButtons.add(button);
    }
    //Add plugin general actions as a drop down list:
    final PluginGeneralActionsManipulator[] plugins = dlh.getPluginGeneralActionsManipulators();
    if (plugins != null && plugins.length > 0) {
        JCommandButton pluginsButton = new JCommandButton(NbBundle.getMessage(DataTableTopComponent.class, "DataTableTopComponent.general.actions.plugins.button.text"), ImageWrapperResizableIcon.getIcon(ImageUtilities.loadImage("org/gephi/desktop/datalab/resources/puzzle--arrow.png", true), new Dimension(16, 16)));
        pluginsButton.setDisplayState(CommandButtonDisplayState.MEDIUM);
        pluginsButton.setCommandButtonKind(JCommandButton.CommandButtonKind.POPUP_ONLY);
        pluginsButton.setPopupCallback(new PopupPanelCallback() {

            @Override
            public JPopupPanel getPopupPanel(JCommandButton jcb) {
                JCommandButtonPanel pluginsPanel = new JCommandButtonPanel(CommandButtonDisplayState.BIG);
                Integer lastManipulatorType = null;
                int group = 1;
                pluginsPanel.addButtonGroup(NbBundle.getMessage(DataTableTopComponent.class, "DataTableTopComponent.general.actions.plugins.group.name", group));
                for (final PluginGeneralActionsManipulator m : plugins) {
                    if (lastManipulatorType == null) {
                        lastManipulatorType = m.getType();
                    }
                    if (lastManipulatorType != m.getType()) {
                        group++;
                        pluginsPanel.addButtonGroup(NbBundle.getMessage(DataTableTopComponent.class, "DataTableTopComponent.general.actions.plugins.group.name", group));
                    }
                    lastManipulatorType = m.getType();
                    pluginsPanel.addButtonToLastGroup(preparePluginGeneralActionsButton(m));
                }
                JCommandPopupMenu popup = new JCommandPopupMenu(pluginsPanel, 4, 20);
                return popup;
            }
        });
        controlToolbar.add(pluginsButton, index);
        generalActionsButtons.add(pluginsButton);
    }
    controlToolbar.updateUI();
}
Also used : ActionEvent(java.awt.event.ActionEvent) GeneralActionsManipulator(org.gephi.datalab.spi.general.GeneralActionsManipulator) PluginGeneralActionsManipulator(org.gephi.datalab.spi.general.PluginGeneralActionsManipulator) JButton(javax.swing.JButton) PopupPanelCallback(org.pushingpixels.flamingo.api.common.popup.PopupPanelCallback) JPopupPanel(org.pushingpixels.flamingo.api.common.popup.JPopupPanel) JCommandButton(org.pushingpixels.flamingo.api.common.JCommandButton) Dimension(java.awt.Dimension) DataLaboratoryHelper(org.gephi.datalab.api.DataLaboratoryHelper) PluginGeneralActionsManipulator(org.gephi.datalab.spi.general.PluginGeneralActionsManipulator) ActionListener(java.awt.event.ActionListener) JCommandButtonPanel(org.pushingpixels.flamingo.api.common.JCommandButtonPanel) JCommandPopupMenu(org.pushingpixels.flamingo.api.common.popup.JCommandPopupMenu)

Aggregations

Dimension (java.awt.Dimension)5 ActionEvent (java.awt.event.ActionEvent)5 ActionListener (java.awt.event.ActionListener)5 JCommandButton (org.pushingpixels.flamingo.api.common.JCommandButton)5 JCommandButtonStrip (org.pushingpixels.flamingo.api.common.JCommandButtonStrip)2 RichTooltip (org.pushingpixels.flamingo.api.common.RichTooltip)2 JCommandPopupMenu (org.pushingpixels.flamingo.api.common.popup.JCommandPopupMenu)2 JPopupPanel (org.pushingpixels.flamingo.api.common.popup.JPopupPanel)2 PopupPanelCallback (org.pushingpixels.flamingo.api.common.popup.PopupPanelCallback)2 ArrayList (java.util.ArrayList)1 JButton (javax.swing.JButton)1 DataLaboratoryHelper (org.gephi.datalab.api.DataLaboratoryHelper)1 GeneralActionsManipulator (org.gephi.datalab.spi.general.GeneralActionsManipulator)1 PluginGeneralActionsManipulator (org.gephi.datalab.spi.general.PluginGeneralActionsManipulator)1 Column (org.gephi.graph.api.Column)1 JCommandButtonPanel (org.pushingpixels.flamingo.api.common.JCommandButtonPanel)1 JCommandMenuButton (org.pushingpixels.flamingo.api.common.JCommandMenuButton)1