use of org.eclipse.ui.handlers.IHandlerService in project org.csstudio.display.builder by kasemir.
the class RCPUtil method doExecuteEclipseCommand.
private static final void doExecuteEclipseCommand(String commandId, String... parameters) {
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
final IHandlerService handlerService = window.getService(IHandlerService.class);
try {
if (parameters.length % 2 != 0)
throw new IllegalArgumentException("Parameterized commands must have " + "an equal number of keys and values");
if (parameters.length == 0)
handlerService.executeCommand(commandId, null);
else {
final ICommandService commandService = window.getService(ICommandService.class);
final Parameterization[] params = new Parameterization[parameters.length / 2];
final Command c = commandService.getCommand(commandId);
for (int i = 0; i < parameters.length / 2; i++) {
final String key = parameters[2 * i];
final String value = parameters[2 * i + 1];
final IParameter p = c.getParameter(key);
final Parameterization pp = new Parameterization(p, value);
params[i] = pp;
}
final ParameterizedCommand pc = new ParameterizedCommand(c, params);
handlerService.executeCommand(pc, null);
}
} catch (Exception ex) {
logger.log(Level.WARNING, "Failed to execute eclipse command '" + commandId + "' " + Arrays.toString(parameters), ex);
}
}
use of org.eclipse.ui.handlers.IHandlerService in project netxms by netxms.
the class NXFindAndReplaceAction method getFindReplaceAction.
public static FindReplaceAction getFindReplaceAction(ViewPart wp) {
FindReplaceAction action = null;
try {
// $NON-NLS-1$
action = new FindReplaceAction(getResourceBundle(wp), "actions.find_and_replace.", wp);
IHandlerService hs = (IHandlerService) wp.getSite().getService(IHandlerService.class);
// $NON-NLS-1$
hs.activateHandler("org.eclipse.ui.edit.findReplace", new ActionHandler(action));
} catch (IOException e) {
e.printStackTrace();
}
return action;
}
use of org.eclipse.ui.handlers.IHandlerService in project netxms by netxms.
the class EventObjectList method createActions.
/**
* Create actions
*/
private void createActions() {
actionNew = new Action(Messages.get().EventConfigurator_NewEvent, SharedIcons.ADD_OBJECT) {
@Override
public void run() {
createNewEventTemplate();
}
};
// $NON-NLS-1$
actionNew.setActionDefinitionId("org.netxms.ui.eclipse.eventmanager.commands.new_event_template");
actionEdit = new // $NON-NLS-1$
Action(// $NON-NLS-1$
Messages.get().EventConfigurator_Properties, // $NON-NLS-1$
SharedIcons.EDIT) {
@Override
public void run() {
editEventTemplate();
}
};
actionEdit.setEnabled(false);
actionDelete = new Action(Messages.get().EventConfigurator_Delete, SharedIcons.DELETE_OBJECT) {
@Override
public void run() {
deleteEventTemplate();
}
};
actionDelete.setEnabled(false);
actionShowFilter = new Action(Messages.get().EventConfigurator_ShowFilter, Action.AS_CHECK_BOX) {
@Override
public void run() {
enableFilter(actionShowFilter.isChecked());
}
};
actionRemove = new Action("&Remove from group") {
@Override
public void run() {
removeFromGroup();
}
};
actionShowGroups = new Action("&Show event groups", Action.AS_CHECK_BOX) {
@Override
public void run() {
showEventGroups();
}
};
actionShowGroups.setChecked(showGroups);
actionNewGroup = new Action("&Add new event group") {
@Override
public void run() {
createNewEventGroup();
}
};
actionShowFilter.setImageDescriptor(SharedIcons.FILTER);
actionShowFilter.setChecked(filterEnabled);
// $NON-NLS-1$
actionShowFilter.setActionDefinitionId("org.netxms.ui.eclipse.eventmanager.commands.show_filter");
if (viewPart != null) {
final IHandlerService handlerService = (IHandlerService) viewPart.getSite().getService(IHandlerService.class);
// $NON-NLS-1$
actionNew.setActionDefinitionId("org.netxms.ui.eclipse.eventmanager.commands.new_event_template");
handlerService.activateHandler(actionNew.getActionDefinitionId(), new ActionHandler(actionNew));
// $NON-NLS-1$
actionShowFilter.setActionDefinitionId("org.netxms.ui.eclipse.eventmanager.commands.show_filter");
handlerService.activateHandler(actionShowFilter.getActionDefinitionId(), new ActionHandler(actionShowFilter));
actionRefresh = new RefreshAction(viewPart) {
@Override
public void run() {
refreshView();
}
};
} else {
actionRefresh = new RefreshAction() {
@Override
public void run() {
refreshView();
}
};
}
}
use of org.eclipse.ui.handlers.IHandlerService in project netxms by netxms.
the class AgentFileViewer method createActions.
/**
* Create actions
*/
private void createActions() {
final IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
actionClear = new Action(Messages.get().FileViewer_ClearOutput, SharedIcons.CLEAR_LOG) {
@Override
public void run() {
viewer.clear();
}
};
// $NON-NLS-1$
actionClear.setActionDefinitionId("org.netxms.ui.eclipse.filemanager.commands.clear_output");
handlerService.activateHandler(actionClear.getActionDefinitionId(), new ActionHandler(actionClear));
actionScrollLock = new Action(Messages.get().FileViewer_ScrollLock, Action.AS_CHECK_BOX) {
@Override
public void run() {
viewer.setScrollLock(actionScrollLock.isChecked());
}
};
// $NON-NLS-1$
actionScrollLock.setImageDescriptor(Activator.getImageDescriptor("icons/scroll_lock.gif"));
actionScrollLock.setChecked(false);
// $NON-NLS-1$
actionScrollLock.setActionDefinitionId("org.netxms.ui.eclipse.objecttools.commands.scroll_lock");
handlerService.activateHandler(actionScrollLock.getActionDefinitionId(), new ActionHandler(actionScrollLock));
actionCopy = new Action(Messages.get().AgentFileViewer_Copy) {
@Override
public void run() {
viewer.copy();
}
};
actionCopy.setEnabled(false);
// $NON-NLS-1$
actionCopy.setActionDefinitionId("org.netxms.ui.eclipse.filemanager.commands.copy");
handlerService.activateHandler(actionCopy.getActionDefinitionId(), new ActionHandler(actionCopy));
actionSelectAll = new Action(Messages.get().AgentFileViewer_SelectAll) {
@Override
public void run() {
viewer.selectAll();
}
};
// $NON-NLS-1$
actionSelectAll.setActionDefinitionId("org.netxms.ui.eclipse.filemanager.commands.select_all");
handlerService.activateHandler(actionSelectAll.getActionDefinitionId(), new ActionHandler(actionSelectAll));
actionFind = new Action(Messages.get().AgentFileViewer_Find, SharedIcons.FIND) {
@Override
public void run() {
viewer.showSearchBar();
}
};
// $NON-NLS-1$
actionFind.setActionDefinitionId("org.netxms.ui.eclipse.filemanager.commands.find");
handlerService.activateHandler(actionFind.getActionDefinitionId(), new ActionHandler(actionFind));
}
use of org.eclipse.ui.handlers.IHandlerService in project netxms by netxms.
the class ScriptEditorView method createActions.
/**
* Create actions
*/
private void createActions() {
final IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
actionRefresh = new RefreshAction(this) {
@Override
public void run() {
reloadScript();
}
};
actionSave = new Action(Messages.get().ScriptEditorView_Save, SharedIcons.SAVE) {
@Override
public void run() {
saveScript();
}
};
// $NON-NLS-1$
actionSave.setActionDefinitionId("org.netxms.ui.eclipse.nxsl.commands.save");
handlerService.activateHandler(actionSave.getActionDefinitionId(), new ActionHandler(actionSave));
actionCompile = new // $NON-NLS-2$
Action(// $NON-NLS-2$
Messages.get().ScriptEditorView_Compile, // $NON-NLS-2$
Activator.getImageDescriptor("icons/compile.gif")) {
@Override
public void run() {
compileScript();
}
};
// $NON-NLS-1$
actionCompile.setActionDefinitionId("org.netxms.ui.eclipse.nxsl.commands.compile");
handlerService.activateHandler(actionCompile.getActionDefinitionId(), new ActionHandler(actionCompile));
}
Aggregations