Search in sources :

Example 1 with CyAction

use of org.cytoscape.application.swing.CyAction in project cytoscape-impl by cytoscape.

the class CytoscapeMenus method createViewFrameToolBar.

public JToolBar createViewFrameToolBar() {
    JToolBar viewToolBar = null;
    final int total = toolBar.getComponentCount();
    boolean addSeparator = false;
    int buttonsAfterSeparator = 0;
    for (int i = 0; i < total; i++) {
        final Component c = toolBar.getComponent(i);
        if (c instanceof JButton && ((JButton) c).getAction() instanceof CyAction) {
            final JButton btn = ((JButton) c);
            final CyAction action = (CyAction) btn.getAction();
            if (viewFrameActions.contains(action)) {
                if (viewToolBar == null) {
                    viewToolBar = new JToolBar();
                    viewToolBar.setBorder(toolBar.getBorder());
                }
                if (addSeparator) {
                    viewToolBar.addSeparator();
                    addSeparator = false;
                    buttonsAfterSeparator = 0;
                }
                final JButton newBtn = CytoscapeToolBar.createToolBarButton(action);
                viewToolBar.add(newBtn);
                buttonsAfterSeparator++;
            }
        } else if (c instanceof JSeparator && buttonsAfterSeparator > 0) {
            addSeparator = true;
        }
    }
    if (viewToolBar != null && viewToolBar.getComponentCount() > 0 && viewToolBar.getComponentAtIndex(viewToolBar.getComponentCount() - 1) instanceof JSeparator)
        viewToolBar.remove(viewToolBar.getComponentCount() - 1);
    return viewToolBar;
}
Also used : JButton(javax.swing.JButton) CyAction(org.cytoscape.application.swing.CyAction) JToolBar(javax.swing.JToolBar) Component(java.awt.Component) JSeparator(javax.swing.JSeparator)

Example 2 with CyAction

use of org.cytoscape.application.swing.CyAction in project cytoscape-impl by cytoscape.

the class CytoscapeMenuPopulator method addFactory.

private void addFactory(TaskFactory factory, Map<String, String> props) {
    CyAction action;
    if (props.containsKey(ServiceProperties.ENABLE_FOR))
        action = new TaskFactoryTunableAction(factory, props, serviceRegistrar);
    else
        action = new TaskFactoryTunableAction(serviceRegistrar, factory, props);
    addAction(action, factory, props);
}
Also used : CytoPanelTaskFactoryTunableAction(org.cytoscape.internal.task.CytoPanelTaskFactoryTunableAction) TaskFactoryTunableAction(org.cytoscape.internal.task.TaskFactoryTunableAction) CyAction(org.cytoscape.application.swing.CyAction)

Example 3 with CyAction

use of org.cytoscape.application.swing.CyAction in project cytoscape-impl by cytoscape.

the class NetworkMediator method addFactory.

// // Private Methods // //
@SuppressWarnings({ "unchecked", "rawtypes" })
private void addFactory(final TaskFactory factory, final Map props) {
    final CyAction action;
    if (props.containsKey(ServiceProperties.ENABLE_FOR))
        action = new TaskFactoryTunableAction(factory, props, serviceRegistrar);
    else
        action = new TaskFactoryTunableAction(serviceRegistrar, factory, props);
    popupActionMap.put(factory, action);
}
Also used : TaskFactoryTunableAction(org.cytoscape.internal.task.TaskFactoryTunableAction) AbstractCyAction(org.cytoscape.application.swing.AbstractCyAction) CyAction(org.cytoscape.application.swing.CyAction)

Example 4 with CyAction

use of org.cytoscape.application.swing.CyAction in project cytoscape-impl by cytoscape.

the class NVLTFActionSupport method registerAction.

public void registerAction(NetworkViewLocationTaskFactory nvltf, Map<String, String> props) {
    // If the user requests this action to be in the menu bar, create and register a CyAction for it
    if (props.containsKey(ServiceProperties.IN_MENU_BAR) && Boolean.valueOf(props.get(ServiceProperties.IN_MENU_BAR)) == Boolean.TRUE) {
        CyAction action = new NVLTFAction(nvltf, props);
        registrar.registerService(action, CyAction.class, new Properties());
    }
}
Also used : CyAction(org.cytoscape.application.swing.CyAction) AbstractCyAction(org.cytoscape.application.swing.AbstractCyAction) Properties(java.util.Properties) ServiceProperties(org.cytoscape.work.ServiceProperties)

Aggregations

CyAction (org.cytoscape.application.swing.CyAction)4 AbstractCyAction (org.cytoscape.application.swing.AbstractCyAction)2 TaskFactoryTunableAction (org.cytoscape.internal.task.TaskFactoryTunableAction)2 Component (java.awt.Component)1 Properties (java.util.Properties)1 JButton (javax.swing.JButton)1 JSeparator (javax.swing.JSeparator)1 JToolBar (javax.swing.JToolBar)1 CytoPanelTaskFactoryTunableAction (org.cytoscape.internal.task.CytoPanelTaskFactoryTunableAction)1 ServiceProperties (org.cytoscape.work.ServiceProperties)1