Search in sources :

Example 1 with AlarmTab

use of org.netxms.ui.eclipse.alarmviewer.objecttabs.AlarmTab in project netxms by netxms.

the class ToggleAlarmFilterHandler 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)) {
            ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
            // $NON-NLS-1$
            Command command = service.getCommand("org.netxms.ui.eclipse.alarmviewer.commands.show_filter_alarm_list");
            // $NON-NLS-1$
            State state = command.getState("org.netxms.ui.eclipse.alarmviewer.commands.show_filter_alarm_list.state");
            boolean isChecked = !(Boolean) state.getValue();
            state.setValue(isChecked);
            ((AlarmTab) 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) AlarmTab(org.netxms.ui.eclipse.alarmviewer.objecttabs.AlarmTab) ICommandService(org.eclipse.ui.commands.ICommandService)

Example 2 with AlarmTab

use of org.netxms.ui.eclipse.alarmviewer.objecttabs.AlarmTab 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)

Aggregations

IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)2 ICommandService (org.eclipse.ui.commands.ICommandService)2 AlarmTab (org.netxms.ui.eclipse.alarmviewer.objecttabs.AlarmTab)2 Command (org.eclipse.core.commands.Command)1 State (org.eclipse.core.commands.State)1