Search in sources :

Example 16 with JCheckBoxMenuItem

use of javax.swing.JCheckBoxMenuItem in project jgnash by ccavanaugh.

the class ActionParser method createMenuItem.

private JMenuItem createMenuItem(final ActionNode node) {
    JMenuItem menu;
    Action a = actionMap.get(node.idref);
    if (node.size() > 0) {
        menu = new JMenu(a);
        for (int i = 0; i < node.size(); i++) {
            ActionNode n = node.getChildAt(i);
            if (n.id == null && n.idref == null) {
                // detect a separator
                ((JMenu) menu).addSeparator();
            } else {
                JMenuItem item = createMenuItem(n);
                menu.add(item);
            }
        }
    } else {
        if (node.type == null || node.type.isEmpty()) {
            menu = new JMenuItem(a);
        } else {
            switch(node.type) {
                case "single":
                    menu = new JCheckBoxMenuItem(a);
                    break;
                case "toggle":
                    menu = new JRadioButtonMenuItem(a);
                    if (node.group != null) {
                        // create a group
                        ButtonGroup bGroup;
                        if (buttonGroups.get(node.group) != null) {
                            bGroup = buttonGroups.get(node.group);
                        } else {
                            bGroup = new ButtonGroup();
                            buttonGroups.put(node.group, bGroup);
                        }
                        bGroup.add(menu);
                    }
                    break;
                default:
                    menu = new JMenuItem(a);
                    break;
            }
        }
    }
    menuItemMap.put(node.idref, menu);
    // store the idref in the JMenuItem
    menu.putClientProperty(ID_REF_ATTRIBUTE, node.idref);
    return menu;
}
Also used : Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ButtonGroup(javax.swing.ButtonGroup) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Example 17 with JCheckBoxMenuItem

use of javax.swing.JCheckBoxMenuItem in project GCViewer by chewiebug.

the class GCViewerGuiInternalFrameController method internalFrameOpened.

@Override
public void internalFrameOpened(InternalFrameEvent e) {
    JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(new WindowMenuItemAction(e));
    getMenuBar(e).addToWindowMenuGroup(menuItem);
}
Also used : WindowMenuItemAction(com.tagtraum.perf.gcviewer.ctrl.action.WindowMenuItemAction) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Example 18 with JCheckBoxMenuItem

use of javax.swing.JCheckBoxMenuItem in project GCViewer by chewiebug.

the class GCViewerGuiInternalFrameController method updateMenuItemState.

private void updateMenuItemState(InternalFrameEvent e) {
    getToolBar(e).getZoomComboBox().setSelectedItem((int) (getSelectedGCDocument(e).getModelChart().getScaleFactor() * 1000.0) + "%");
    GCPreferences preferences = getSelectedGCDocument(e).getPreferences();
    for (Entry<String, JCheckBoxMenuItem> menuEntry : getMenuBar(e).getViewMenuItems().entrySet()) {
        JCheckBoxMenuItem item = menuEntry.getValue();
        item.setState(preferences.getGcLineProperty(menuEntry.getKey()));
    }
}
Also used : GCPreferences(com.tagtraum.perf.gcviewer.view.model.GCPreferences) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Example 19 with JCheckBoxMenuItem

use of javax.swing.JCheckBoxMenuItem in project EnrichmentMapApp by BaderLab.

the class ControlPanelMediator method getOptionsMenu.

private JPopupMenu getOptionsMenu() {
    final JPopupMenu menu = new JPopupMenu();
    {
        final JMenuItem mi = new JCheckBoxMenuItem("Show Legend");
        mi.addActionListener(evt -> {
            if (legendPanelMediatorProvider.get().getDialog().isVisible()) {
                legendPanelMediatorProvider.get().hideDialog();
            } else {
                CyNetworkView netView = getCurrentEMView();
                EMViewControlPanel viewPanel = getControlPanel().getViewControlPanel(netView);
                legendPanelMediatorProvider.get().showDialog(createStyleOptions(netView), getFilteredDataSets(viewPanel));
            }
        });
        mi.setSelected(legendPanelMediatorProvider.get().getDialog().isVisible());
        menu.add(mi);
    }
    menu.addSeparator();
    for (FilterMode mode : FilterMode.values()) {
        final JMenuItem mi = new JCheckBoxMenuItem(mode.toString());
        mi.addActionListener(evt -> setFilterMode(mode));
        mi.setSelected(filterMode == mode);
        menu.add(mi);
    }
    return menu;
}
Also used : ViewParams(org.baderlab.csplugins.enrichmentmap.view.control.io.ViewParams) ChartType(org.baderlab.csplugins.enrichmentmap.style.ChartType) EMViewControlPanel(org.baderlab.csplugins.enrichmentmap.view.control.ControlPanel.EMViewControlPanel) Inject(com.google.inject.Inject) AfterInjection(org.baderlab.csplugins.enrichmentmap.AfterInjection) SliderBarPanel(org.baderlab.csplugins.enrichmentmap.view.util.SliderBarPanel) CyCustomGraphics2(org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) CyNetwork(org.cytoscape.model.CyNetwork) Map(java.util.Map) SetCurrentNetworkViewEvent(org.cytoscape.application.events.SetCurrentNetworkViewEvent) LegendPanelMediator(org.baderlab.csplugins.enrichmentmap.view.legend.LegendPanelMediator) FinishStatus(org.cytoscape.work.FinishStatus) JComboBox(javax.swing.JComboBox) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) EDGE_DATASET_VALUE_COMPOUND(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.EDGE_DATASET_VALUE_COMPOUND) Timer(javax.swing.Timer) EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) ChartData(org.baderlab.csplugins.enrichmentmap.style.ChartData) Columns(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns) ItemEvent(java.awt.event.ItemEvent) EMStyleOptions(org.baderlab.csplugins.enrichmentmap.style.EMStyleOptions) NetworkViewAboutToBeDestroyedListener(org.cytoscape.view.model.events.NetworkViewAboutToBeDestroyedListener) Collection(java.util.Collection) SetCurrentNetworkViewListener(org.cytoscape.application.events.SetCurrentNetworkViewListener) Set(java.util.Set) CyNetworkManager(org.cytoscape.model.CyNetworkManager) FilterMode(org.baderlab.csplugins.enrichmentmap.task.FilterNodesEdgesTask.FilterMode) Collectors(java.util.stream.Collectors) NODE_GS_TYPE(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.NODE_GS_TYPE) ColorScheme(org.baderlab.csplugins.enrichmentmap.style.ColorScheme) AbstractDataSet(org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet) ColumnDescriptor(org.baderlab.csplugins.enrichmentmap.style.ColumnDescriptor) List(java.util.List) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) CyApplicationManager(org.cytoscape.application.CyApplicationManager) CySwingApplication(org.cytoscape.application.swing.CySwingApplication) RemoveSignatureDataSetsTask(org.baderlab.csplugins.enrichmentmap.task.postanalysis.RemoveSignatureDataSetsTask) TaskObserver(org.cytoscape.work.TaskObserver) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) ApplyEMStyleTask(org.baderlab.csplugins.enrichmentmap.task.ApplyEMStyleTask) ObservableTask(org.cytoscape.work.ObservableTask) Singleton(com.google.inject.Singleton) ActionListener(java.awt.event.ActionListener) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) EDGE_INTERACTION_VALUE_SIG(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.EDGE_INTERACTION_VALUE_SIG) CyNode(org.cytoscape.model.CyNode) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) NetworkViewAboutToBeDestroyedEvent(org.cytoscape.view.model.events.NetworkViewAboutToBeDestroyedEvent) HashMap(java.util.HashMap) Action(javax.swing.Action) TaskIterator(org.cytoscape.work.TaskIterator) HashSet(java.util.HashSet) FilterNodesEdgesTask(org.baderlab.csplugins.enrichmentmap.task.FilterNodesEdgesTask) CyRow(org.cytoscape.model.CyRow) JMenuItem(javax.swing.JMenuItem) PostAnalysisPanelMediator(org.baderlab.csplugins.enrichmentmap.view.postanalysis.PostAnalysisPanelMediator) ShowEnrichmentMapDialogAction(org.baderlab.csplugins.enrichmentmap.actions.ShowEnrichmentMapDialogAction) ChartOptions(org.baderlab.csplugins.enrichmentmap.style.ChartOptions) NetworkViewAddedListener(org.cytoscape.view.model.events.NetworkViewAddedListener) CyTable(org.cytoscape.model.CyTable) NetworkViewAddedEvent(org.cytoscape.view.model.events.NetworkViewAddedEvent) Properties(java.util.Properties) CyCustomGraphics2Factory(org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2Factory) JPopupMenu(javax.swing.JPopupMenu) CyColumnIdentifier(org.cytoscape.view.presentation.property.values.CyColumnIdentifier) EnrichmentMapManager(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapManager) JOptionPane(javax.swing.JOptionPane) CutoffParam(org.baderlab.csplugins.enrichmentmap.view.control.io.ViewParams.CutoffParam) ActionEvent(java.awt.event.ActionEvent) CytoPanel(org.cytoscape.application.swing.CytoPanel) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) CytoPanelComponent(org.cytoscape.application.swing.CytoPanelComponent) Provider(com.google.inject.Provider) EdgeWidthDialog(org.baderlab.csplugins.enrichmentmap.view.postanalysis.EdgeWidthDialog) NODE_GS_TYPE_ENRICHMENT(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.NODE_GS_TYPE_ENRICHMENT) ForkJoinPool(java.util.concurrent.ForkJoinPool) ChartUtil(org.baderlab.csplugins.enrichmentmap.view.util.ChartUtil) ChartFactoryManager(org.baderlab.csplugins.enrichmentmap.style.ChartFactoryManager) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyColumnIdentifierFactory(org.cytoscape.view.presentation.property.values.CyColumnIdentifierFactory) EMSignatureDataSet(org.baderlab.csplugins.enrichmentmap.model.EMSignatureDataSet) CyEdge(org.cytoscape.model.CyEdge) WidthFunction(org.baderlab.csplugins.enrichmentmap.style.WidthFunction) Collections(java.util.Collections) SwingUtil.invokeOnEDT(org.baderlab.csplugins.enrichmentmap.view.util.SwingUtil.invokeOnEDT) EMViewControlPanel(org.baderlab.csplugins.enrichmentmap.view.control.ControlPanel.EMViewControlPanel) FilterMode(org.baderlab.csplugins.enrichmentmap.task.FilterNodesEdgesTask.FilterMode) JMenuItem(javax.swing.JMenuItem) CyNetworkView(org.cytoscape.view.model.CyNetworkView) JPopupMenu(javax.swing.JPopupMenu) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Example 20 with JCheckBoxMenuItem

use of javax.swing.JCheckBoxMenuItem in project zaproxy by zaproxy.

the class TableColumnManager method showPopup.

/*
	 * Show a popup containing items for all the columns found in the table
	 * column manager. The popup will be displayed below the table header
	 * columns that was clicked.
	 * 
	 * @param index index of the table header column that was clicked
	 */
private void showPopup(int index) {
    Object headerValue = columnModel.getColumn(index).getHeaderValue();
    int columnCount = columnModel.getColumnCount();
    JPopupMenu popup = new SelectPopupMenu();
    for (TableColumn tableColumn : allColumns) {
        Object value = tableColumn.getHeaderValue();
        JCheckBoxMenuItem item = new JCheckBoxMenuItem(value.toString());
        item.addActionListener(this);
        try {
            columnModel.getColumnIndex(value);
            item.setSelected(true);
            if (columnCount == 1) {
                item.setEnabled(false);
            }
        } catch (IllegalArgumentException e) {
            item.setSelected(false);
        }
        popup.add(item);
        if (value == headerValue) {
            popup.setSelected(item);
        }
    }
    // Display the popup below the TableHeader
    JTableHeader header = table.getTableHeader();
    Rectangle r = header.getHeaderRect(index);
    popup.show(header, r.x, r.height);
}
Also used : Rectangle(java.awt.Rectangle) JTableHeader(javax.swing.table.JTableHeader) TableColumn(javax.swing.table.TableColumn) JPopupMenu(javax.swing.JPopupMenu) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Aggregations

JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)41 ActionEvent (java.awt.event.ActionEvent)16 JMenuItem (javax.swing.JMenuItem)15 ActionListener (java.awt.event.ActionListener)13 JMenu (javax.swing.JMenu)12 JPopupMenu (javax.swing.JPopupMenu)11 AbstractAction (javax.swing.AbstractAction)8 JMenuBar (javax.swing.JMenuBar)6 JSeparator (javax.swing.JSeparator)5 JTableHeader (javax.swing.table.JTableHeader)4 TableColumn (javax.swing.table.TableColumn)4 Action (javax.swing.Action)3 JButton (javax.swing.JButton)3 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)3 Component (java.awt.Component)2 ItemEvent (java.awt.event.ItemEvent)2 HashMap (java.util.HashMap)2 ButtonGroup (javax.swing.ButtonGroup)2 JFrame (javax.swing.JFrame)2 JOptionPane (javax.swing.JOptionPane)2