Search in sources :

Example 1 with LastValues

use of org.netxms.ui.eclipse.datacollection.objecttabs.LastValues in project netxms by netxms.

the class ToggleDCIFilterHandler 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 LastValues)) {
            ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
            // $NON-NLS-1$
            Command command = service.getCommand("org.netxms.ui.eclipse.datacollection.commands.show_dci_filter");
            // $NON-NLS-1$
            State state = command.getState("org.netxms.ui.eclipse.datacollection.commands.show_dci_filter.state");
            boolean isChecked = !(Boolean) state.getValue();
            state.setValue(isChecked);
            ((LastValues) tab).setFilterEnabled(isChecked);
            service.refreshElements(event.getCommand().getId(), null);
        }
    }
    return null;
}
Also used : Command(org.eclipse.core.commands.Command) State(org.eclipse.core.commands.State) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) LastValues(org.netxms.ui.eclipse.datacollection.objecttabs.LastValues) ICommandService(org.eclipse.ui.commands.ICommandService)

Aggregations

Command (org.eclipse.core.commands.Command)1 State (org.eclipse.core.commands.State)1 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)1 ICommandService (org.eclipse.ui.commands.ICommandService)1 LastValues (org.netxms.ui.eclipse.datacollection.objecttabs.LastValues)1