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;
}
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;
}
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());
}
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;
}
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);
}
Aggregations