use of org.eclipse.core.expressions.IEvaluationContext in project linuxtools by eclipse.
the class PerfStatsQuickDiffHandler method execute.
@Override
public Object execute(ExecutionEvent event) {
// get default files
PerfPlugin plugin = PerfPlugin.getDefault();
IPath curStatData = plugin.getPerfFile(PerfPlugin.PERF_DEFAULT_STAT);
IPath prevStatData = plugin.getPerfFile(PerfPlugin.PERF_DEAFULT_OLD_STAT);
IResource curStatFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(curStatData);
IResource prevStatFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(prevStatData);
// Inject our own selections into the context
IEvaluationContext ctx = (IEvaluationContext) event.getApplicationContext();
ctx.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, new StructuredSelection(new IResource[] { prevStatFile, curStatFile }));
ICommandService cmdService = PlatformUI.getWorkbench().getService(ICommandService.class);
// $NON-NLS-1$
Command cmd = cmdService.getCommand("org.eclipse.linuxtools.perf.CompareAction");
try {
cmd.executeWithChecks(event);
} catch (Exception e) {
}
return null;
}
use of org.eclipse.core.expressions.IEvaluationContext in project netxms by netxms.
the class ToggleAlarmStatusColorsHandler method execute.
/* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Object object = event.getApplicationContext();
if (object instanceof IEvaluationContext) {
// $NON-NLS-1$
Object tab = ((IEvaluationContext) object).getVariable("org.netxms.ui.eclipse.objectview.ActiveTab");
if ((tab != null) && (tab instanceof AlarmTab)) {
boolean isChecked = !Activator.getDefault().getPreferenceStore().getBoolean("SHOW_ALARM_STATUS_COLORS");
((AlarmTab) tab).setShowColors(isChecked);
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
service.refreshElements(event.getCommand().getId(), null);
}
}
return null;
}
use of org.eclipse.core.expressions.IEvaluationContext in project netxms by netxms.
the class HideSubInterfacesHandler method execute.
/* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Object object = event.getApplicationContext();
if (object instanceof IEvaluationContext) {
// $NON-NLS-1$
Object tab = ((IEvaluationContext) object).getVariable("org.netxms.ui.eclipse.objectview.ActiveTab");
if ((tab != null) && (tab instanceof InterfacesTab)) {
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
// $NON-NLS-1$
Command command = service.getCommand("org.netxms.ui.eclipse.objectview.commands.hideSubInterfaces");
// $NON-NLS-1$
State state = command.getState("org.netxms.ui.eclipse.objectview.commands.hideSubInterfaces.state");
boolean isChecked = !(Boolean) state.getValue();
state.setValue(isChecked);
((InterfacesTab) tab).hideSubInterfaces(isChecked);
service.refreshElements(event.getCommand().getId(), null);
}
}
return null;
}
use of org.eclipse.core.expressions.IEvaluationContext in project netxms by netxms.
the class ToggleFilterHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Object object = event.getApplicationContext();
if (object instanceof IEvaluationContext) {
// $NON-NLS-1$
Object tab = ((IEvaluationContext) object).getVariable("org.netxms.ui.eclipse.objectview.ActiveTab");
if ((tab != null) && (tab instanceof InterfacesTab)) {
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
// $NON-NLS-1$
Command command = service.getCommand("org.netxms.ui.eclipse.objectview.commands.show_filter");
// $NON-NLS-1$
State state = command.getState("org.netxms.ui.eclipse.objectview.commands.show_filter.state");
boolean isChecked = !(Boolean) state.getValue();
state.setValue(isChecked);
((InterfacesTab) tab).enableFilter(isChecked);
service.refreshElements(event.getCommand().getId(), null);
}
}
return null;
}
use of org.eclipse.core.expressions.IEvaluationContext in project liferay-ide by liferay.
the class ProjectExplorerLayoutUtil method setNested.
public static void setNested(boolean nested) {
String commandId = "org.eclipse.ui.navigator.resources.nested.changeProjectPresentation";
try {
IWorkbench workbench = PlatformUI.getWorkbench();
ICommandService commandService = (ICommandService) workbench.getService(ICommandService.class);
Command command = commandService.getCommand(commandId);
IHandler hanlder = command.getHandler();
IViewPart projectExplorer = workbench.getWorkbenchWindows()[0].getActivePage().findView(IPageLayout.ID_PROJECT_EXPLORER);
if ((hanlder != null) && (projectExplorer != null)) {
Map<String, String> map = new HashMap<>();
map.put(_nestParameter, Boolean.toString(nested));
IEvaluationContext applicationContext = new EvaluationContext(null, new Object());
applicationContext.addVariable(ISources.ACTIVE_PART_NAME, projectExplorer);
ExecutionEvent event = new ExecutionEvent(command, map, null, applicationContext);
_execute(event);
}
} catch (ExecutionException ee) {
// ignore errors this is best effort.
}
}
Aggregations