Search in sources :

Example 76 with IAction

use of org.eclipse.jface.action.IAction in project linuxtools by eclipse.

the class DockerContainersView method createAction.

private IAction createAction(String label, final String id, ImageDescriptor img) {
    IAction ret = new Action(label, img) {

        @Override
        public void run() {
            IStructuredSelection sel = getStructuredSelection();
            CommandUtils.execute(id, sel);
        }
    };
    ret.setEnabled(false);
    return ret;
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 77 with IAction

use of org.eclipse.jface.action.IAction in project linuxtools by eclipse.

the class GmonView method createExportToCSVAction.

@Override
protected IAction createExportToCSVAction() {
    IAction action = new STExportToCSVAction(this.getSTViewer()) {

        @Override
        public void run() {
            Object o = getSTViewer().getInput();
            if (o instanceof GmonDecoder) {
                GmonDecoder gd = (GmonDecoder) o;
                // $NON-NLS-1$
                getExporter().setFilePath(gd.getGmonFile() + ".csv");
            }
            super.run();
        }
    };
    return action;
}
Also used : STExportToCSVAction(org.eclipse.linuxtools.dataviewers.actions.STExportToCSVAction) IAction(org.eclipse.jface.action.IAction) GmonDecoder(org.eclipse.linuxtools.internal.gprof.parser.GmonDecoder) IBinaryObject(org.eclipse.cdt.core.IBinaryParser.IBinaryObject)

Example 78 with IAction

use of org.eclipse.jface.action.IAction in project knime-core by knime.

the class ExecuteAndOpenViewAction method executeAndOpen.

private void executeAndOpen(final NodeContainer cont) {
    boolean hasView = cont.getNrViews() > 0;
    final InteractiveWebViewsResult interactiveWebViews = cont.getInteractiveWebViews();
    hasView |= cont.hasInteractiveView() || interactiveWebViews.size() > 0;
    hasView |= OpenSubnodeWebViewAction.hasContainerView(cont);
    if (hasView) {
        // another listener must be registered at the workflow manager to
        // receive also those events from nodes that have just been queued
        cont.addNodeStateChangeListener(new NodeStateChangeListener() {

            @Override
            public void stateChanged(final NodeStateEvent state) {
                NodeContainerState ncState = cont.getNodeContainerState();
                // removed from the queue)
                if ((state.getSource() == cont.getID()) && ncState.isExecuted()) {
                    // if the node was successfully executed
                    // start the view
                    Display.getDefault().asyncExec(new Runnable() {

                        @Override
                        public void run() {
                            // run open view action
                            IAction viewAction;
                            if (cont.hasInteractiveView()) {
                                viewAction = new OpenInteractiveViewAction(cont);
                            } else if (cont instanceof SubNodeContainer) {
                                viewAction = new OpenSubnodeWebViewAction((SubNodeContainer) cont);
                            } else if (interactiveWebViews.size() > 0) {
                                viewAction = new OpenInteractiveWebViewAction(cont, interactiveWebViews.get(0));
                            } else {
                                viewAction = new OpenViewAction(cont, 0);
                            }
                            viewAction.run();
                        }
                    });
                }
                if (!ncState.isExecutionInProgress()) {
                    // in those cases remove the listener
                    cont.removeNodeStateChangeListener(this);
                }
            }
        });
    }
    getManager().executeUpToHere(cont.getID());
}
Also used : IAction(org.eclipse.jface.action.IAction) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainerState(org.knime.core.node.workflow.NodeContainerState) InteractiveWebViewsResult(org.knime.core.node.workflow.action.InteractiveWebViewsResult) NodeStateChangeListener(org.knime.core.node.workflow.NodeStateChangeListener) NodeStateEvent(org.knime.core.node.workflow.NodeStateEvent)

Example 79 with IAction

use of org.eclipse.jface.action.IAction in project dbeaver by dbeaver.

the class DebugUIInternals method createShortcutActions.

public static Map<IAction, String> createShortcutActions(Object[] selected, String mode, int accelerator) {
    Map<IAction, String> result = new LinkedHashMap<IAction, String>();
    if (selected == null) {
        return result;
    }
    List<Object> selection = Arrays.asList(selected);
    IEvaluationContext context = DebugUIPlugin.createEvaluationContext(selection);
    context.setAllowPluginActivation(true);
    // $NON-NLS-1$
    context.addVariable("selection", selection);
    List<LaunchShortcutExtension> allShortCuts = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchShortcuts();
    List<LaunchShortcutExtension> filteredShortCuts = new ArrayList<LaunchShortcutExtension>();
    Iterator<LaunchShortcutExtension> iter = allShortCuts.iterator();
    while (iter.hasNext()) {
        LaunchShortcutExtension ext = iter.next();
        if (WorkbenchActivityHelper.filterItem(ext)) {
            continue;
        }
        try {
            Expression expr = ext.getContextualLaunchEnablementExpression();
            if (ext.evalEnablementExpression(context, expr)) {
                filteredShortCuts.add(ext);
            }
        } catch (CoreException e) {
            IStatus status = new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), // $NON-NLS-1$
            "Launch shortcut '" + ext.getId() + "' enablement expression caused exception. Shortcut was removed.", // $NON-NLS-1$
            e);
            DebugUIPlugin.log(status);
            iter.remove();
        }
    }
    for (LaunchShortcutExtension ext : filteredShortCuts) {
        for (String supported : ext.getModes()) {
            if (supported.equals(mode)) {
                LaunchShortcutAction action = new LaunchShortcutAction(supported, ext);
                // $NON-NLS-1$
                action.setActionDefinitionId(ext.getId() + "." + supported);
                String helpContextId = ext.getHelpContextId();
                if (helpContextId != null) {
                    PlatformUI.getWorkbench().getHelpSystem().setHelp(action, helpContextId);
                }
                StringBuffer label = new StringBuffer();
                if (accelerator >= 0 && accelerator < 10) {
                    // add the numerical accelerator
                    label.append('&');
                    label.append(accelerator);
                    label.append(' ');
                }
                String contextLabel = ext.getContextLabel(supported);
                // replace default action label with context label if
                // specified.
                label.append((contextLabel != null) ? contextLabel : action.getText());
                action.setText(label.toString());
                String category = ext.getCategory();
                result.put(action, category);
                accelerator++;
            }
        }
    }
    return result;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IStatus(org.eclipse.core.runtime.IStatus) IAction(org.eclipse.jface.action.IAction) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) LaunchShortcutExtension(org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension) LaunchShortcutAction(org.eclipse.debug.internal.ui.actions.LaunchShortcutAction) CoreException(org.eclipse.core.runtime.CoreException) Expression(org.eclipse.core.expressions.Expression)

Example 80 with IAction

use of org.eclipse.jface.action.IAction in project dbeaver by dbeaver.

the class QueryLogViewer method createContextMenu.

private void createContextMenu() {
    MenuManager menuMgr = new MenuManager();
    Menu menu = menuMgr.createContextMenu(logTable);
    menuMgr.addMenuListener(manager -> {
        IAction editorAction = new Action("Open in SQL console", DBeaverIcons.getImageDescriptor(UIIcon.SQL_CONSOLE)) {

            @Override
            public void run() {
                openSelectionInEditor();
            }
        };
        IAction copyAction = new Action(CoreMessages.controls_querylog_action_copy) {

            @Override
            public void run() {
                copySelectionToClipboard(false);
            }
        };
        copyAction.setEnabled(logTable.getSelectionCount() > 0);
        copyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
        IAction copyAllAction = new Action(CoreMessages.controls_querylog_action_copy_all_fields) {

            @Override
            public void run() {
                copySelectionToClipboard(true);
            }
        };
        copyAllAction.setEnabled(logTable.getSelectionCount() > 0);
        copyAllAction.setActionDefinitionId(CoreCommands.CMD_COPY_SPECIAL);
        IAction selectAllAction = new Action(CoreMessages.controls_querylog_action_select_all) {

            @Override
            public void run() {
                selectAll();
            }
        };
        selectAllAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_SELECT_ALL);
        IAction clearLogAction = new Action(CoreMessages.controls_querylog_action_clear_log) {

            @Override
            public void run() {
                clearLog();
            }
        };
        boolean hasStatements = false;
        for (TableItem item : logTable.getSelection()) {
            if (((QMMetaEvent) item.getData()).getObject() instanceof QMMStatementExecuteInfo) {
                hasStatements = true;
                break;
            }
        }
        if (hasStatements) {
            manager.add(editorAction);
            manager.add(new Separator());
        }
        manager.add(copyAction);
        manager.add(copyAllAction);
        manager.add(selectAllAction);
        manager.add(clearLogAction);
    // manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    });
    menuMgr.setRemoveAllWhenShown(true);
    logTable.setMenu(menu);
    site.registerContextMenu(menuMgr, this);
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) MenuManager(org.eclipse.jface.action.MenuManager) Separator(org.eclipse.jface.action.Separator)

Aggregations

IAction (org.eclipse.jface.action.IAction)387 Action (org.eclipse.jface.action.Action)147 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)79 IWorkbenchAction (org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)57 Separator (org.eclipse.jface.action.Separator)55 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)50 MenuManager (org.eclipse.jface.action.MenuManager)39 IMenuManager (org.eclipse.jface.action.IMenuManager)37 ArrayList (java.util.ArrayList)36 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)35 IContributionItem (org.eclipse.jface.action.IContributionItem)31 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)26 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)22 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)18 ActionRegistry (org.eclipse.gef.ui.actions.ActionRegistry)16 IToolBarManager (org.eclipse.jface.action.IToolBarManager)16 IEditorPart (org.eclipse.ui.IEditorPart)15 Point (org.eclipse.swt.graphics.Point)14 Iterator (java.util.Iterator)13 Menu (org.eclipse.swt.widgets.Menu)13