Search in sources :

Example 31 with IEvaluationContext

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;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Command(org.eclipse.core.commands.Command) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) PerfPlugin(org.eclipse.linuxtools.internal.perf.PerfPlugin) IResource(org.eclipse.core.resources.IResource) ICommandService(org.eclipse.ui.commands.ICommandService) URISyntaxException(java.net.URISyntaxException) CoreException(org.eclipse.core.runtime.CoreException)

Example 32 with IEvaluationContext

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;
}
Also used : IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) AlarmTab(org.netxms.ui.eclipse.alarmviewer.objecttabs.AlarmTab) ICommandService(org.eclipse.ui.commands.ICommandService)

Example 33 with IEvaluationContext

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;
}
Also used : InterfacesTab(org.netxms.ui.eclipse.objectview.objecttabs.InterfacesTab) Command(org.eclipse.core.commands.Command) State(org.eclipse.core.commands.State) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) ICommandService(org.eclipse.ui.commands.ICommandService)

Example 34 with IEvaluationContext

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;
}
Also used : InterfacesTab(org.netxms.ui.eclipse.objectview.objecttabs.InterfacesTab) Command(org.eclipse.core.commands.Command) State(org.eclipse.core.commands.State) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) ICommandService(org.eclipse.ui.commands.ICommandService)

Example 35 with IEvaluationContext

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.
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) HashMap(java.util.HashMap) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) ICommandService(org.eclipse.ui.commands.ICommandService) IWorkbench(org.eclipse.ui.IWorkbench) Command(org.eclipse.core.commands.Command) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) IHandler(org.eclipse.core.commands.IHandler) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) EvaluationContext(org.eclipse.core.expressions.EvaluationContext) ExecutionException(org.eclipse.core.commands.ExecutionException)

Aggregations

IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)49 ICommandService (org.eclipse.ui.commands.ICommandService)22 Command (org.eclipse.core.commands.Command)21 EvaluationContext (org.eclipse.core.expressions.EvaluationContext)19 IHandlerService (org.eclipse.ui.handlers.IHandlerService)19 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)11 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)11 ISelection (org.eclipse.jface.viewers.ISelection)10 ExecutionException (org.eclipse.core.commands.ExecutionException)9 Expression (org.eclipse.core.expressions.Expression)9 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)7 CoreException (org.eclipse.core.runtime.CoreException)7 ArrayList (java.util.ArrayList)6 AdaptExpression (org.eclipse.core.internal.expressions.AdaptExpression)6 IterateExpression (org.eclipse.core.internal.expressions.IterateExpression)6 WithExpression (org.eclipse.core.internal.expressions.WithExpression)6 NotDefinedException (org.eclipse.core.commands.common.NotDefinedException)5 AndExpression (org.eclipse.core.internal.expressions.AndExpression)5 CountExpression (org.eclipse.core.internal.expressions.CountExpression)5 EnablementExpression (org.eclipse.core.internal.expressions.EnablementExpression)5