Search in sources :

Example 1 with EventSelector

use of org.netxms.ui.eclipse.eventmanager.widgets.EventSelector in project netxms by netxms.

the class RuleAlarm method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    editor = (RuleEditor) getElement().getAdapter(RuleEditor.class);
    rule = editor.getRule();
    alarmAction = calculateAlarmAction();
    dialogArea = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING * 2;
    dialogArea.setLayout(layout);
    Composite radioGroup = new Composite(dialogArea, SWT.NONE);
    RowLayout rbLayout = new RowLayout(SWT.VERTICAL);
    rbLayout.marginBottom = 0;
    rbLayout.marginTop = 0;
    rbLayout.marginLeft = 0;
    rbLayout.marginRight = 0;
    radioGroup.setLayout(rbLayout);
    GridData gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    radioGroup.setLayoutData(gd);
    alarmNoAction = new Button(radioGroup, SWT.RADIO);
    alarmNoAction.setText(Messages.get().RuleAlarm_DoNotChange);
    alarmNoAction.setSelection(alarmAction == ALARM_NO_ACTION);
    alarmNoAction.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            changeAlarmAction(ALARM_NO_ACTION);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    alarmCreate = new Button(radioGroup, SWT.RADIO);
    alarmCreate.setText(Messages.get().RuleAlarm_CreateNew);
    alarmCreate.setSelection(alarmAction == ALARM_CREATE);
    alarmCreate.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            changeAlarmAction(ALARM_CREATE);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    alarmResolve = new Button(radioGroup, SWT.RADIO);
    alarmResolve.setText(Messages.get().RuleAlarm_Resolve);
    alarmResolve.setSelection(alarmAction == ALARM_RESOLVE);
    alarmResolve.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            changeAlarmAction(ALARM_RESOLVE);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    alarmTerminate = new Button(radioGroup, SWT.RADIO);
    alarmTerminate.setText(Messages.get().RuleAlarm_Terminate);
    alarmTerminate.setSelection(alarmAction == ALARM_TERMINATE);
    alarmTerminate.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            changeAlarmAction(ALARM_TERMINATE);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    alarmCreationGroup = new Composite(dialogArea, SWT.NONE);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.TOP;
    gd.exclude = (alarmAction != ALARM_CREATE);
    alarmCreationGroup.setLayoutData(gd);
    alarmCreationGroup.setVisible(alarmAction == ALARM_CREATE);
    layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    alarmCreationGroup.setLayout(layout);
    alarmMessage = new LabeledText(alarmCreationGroup, SWT.NONE);
    alarmMessage.setLabel(Messages.get().RuleAlarm_Message);
    alarmMessage.setText(rule.getAlarmMessage());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    alarmMessage.setLayoutData(gd);
    alarmKeyCreate = new LabeledText(alarmCreationGroup, SWT.NONE);
    alarmKeyCreate.setLabel(Messages.get().RuleAlarm_Key);
    alarmKeyCreate.setText(rule.getAlarmKey());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    alarmKeyCreate.setLayoutData(gd);
    Composite alarmCreationSubgroup = new Composite(alarmCreationGroup, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.makeColumnsEqualWidth = true;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    alarmCreationSubgroup.setLayout(layout);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    alarmCreationSubgroup.setLayoutData(gd);
    Composite severityGroup = new Composite(alarmCreationSubgroup, SWT.NONE);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = WidgetHelper.INNER_SPACING;
    severityGroup.setLayout(layout);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    severityGroup.setLayoutData(gd);
    new Label(severityGroup, SWT.NONE).setText(Messages.get().RuleAlarm_Severity);
    alarmSeverity = new Combo(severityGroup, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
    for (int i = 0; i < Severity.UNKNOWN.getValue(); i++) alarmSeverity.add(StatusDisplayInfo.getStatusText(i));
    alarmSeverity.add(Messages.get().RuleAlarm_FromEvent);
    alarmSeverity.select(rule.getAlarmSeverity().getValue());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    alarmSeverity.setLayoutData(gd);
    alarmTimeout = new LabeledText(alarmCreationSubgroup, SWT.NONE);
    alarmTimeout.setLabel(Messages.get().RuleAlarm_Timeout);
    alarmTimeout.getTextControl().setTextLimit(5);
    alarmTimeout.setText(Integer.toString(rule.getAlarmTimeout()));
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    alarmTimeout.setLayoutData(gd);
    timeoutEvent = new EventSelector(alarmCreationGroup, SWT.NONE);
    timeoutEvent.setLabel(Messages.get().RuleAlarm_TimeoutEvent);
    timeoutEvent.setEventCode(rule.getAlarmTimeoutEvent());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    timeoutEvent.setLayoutData(gd);
    alarmCategory = new AlarmCategorySelector(alarmCreationGroup, SWT.NONE);
    alarmCategory.setLabel("Alarm category");
    alarmCategory.setCategoryId(rule.getAlarmCategories());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    alarmCategory.setLayoutData(gd);
    checkCreateHelpdeskTicket = new Button(alarmCreationGroup, SWT.CHECK);
    checkCreateHelpdeskTicket.setText("Create helpdesk ticket on alarm creation");
    checkCreateHelpdeskTicket.setSelection((rule.getFlags() & EventProcessingPolicyRule.CREATE_TICKET) != 0);
    gd = new GridData();
    gd.horizontalAlignment = SWT.LEFT;
    checkCreateHelpdeskTicket.setLayoutData(gd);
    alarmTerminationGroup = new Composite(dialogArea, SWT.NONE);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.TOP;
    gd.exclude = ((alarmAction != ALARM_TERMINATE) && (alarmAction != ALARM_RESOLVE));
    alarmTerminationGroup.setLayoutData(gd);
    alarmTerminationGroup.setVisible((alarmAction == ALARM_TERMINATE) || (alarmAction == ALARM_RESOLVE));
    layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    alarmTerminationGroup.setLayout(layout);
    alarmKeyTerminate = new LabeledText(alarmTerminationGroup, SWT.NONE);
    alarmKeyTerminate.setLabel((alarmAction == ALARM_TERMINATE) ? Messages.get().RuleAlarm_TerminateAll : Messages.get().RuleAlarm_ResolveAll);
    alarmKeyTerminate.setText(rule.getAlarmKey());
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    alarmKeyTerminate.setLayoutData(gd);
    checkTerminateWithRegexp = new Button(alarmTerminationGroup, SWT.CHECK);
    checkTerminateWithRegexp.setText((alarmAction == ALARM_TERMINATE) ? Messages.get().RuleAlarm_UseRegexpForTerminate : Messages.get().RuleAlarm_UseRegexpForResolve);
    checkTerminateWithRegexp.setSelection((rule.getFlags() & EventProcessingPolicyRule.TERMINATE_BY_REGEXP) != 0);
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) EventSelector(org.netxms.ui.eclipse.eventmanager.widgets.EventSelector) Label(org.eclipse.swt.widgets.Label) AlarmCategorySelector(org.netxms.ui.eclipse.alarmviewer.widgets.AlarmCategorySelector) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 2 with EventSelector

use of org.netxms.ui.eclipse.eventmanager.widgets.EventSelector in project netxms by netxms.

the class ConditionEvents method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    Composite dialogArea = new Composite(parent, SWT.NONE);
    object = (Condition) getElement().getAdapter(Condition.class);
    if (// Paranoid check
    object == null)
        return dialogArea;
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
    dialogArea.setLayout(layout);
    /* event group */
    Group eventGroup = new Group(dialogArea, SWT.NONE);
    eventGroup.setText(Messages.get().ConditionEvents_Events);
    GridData gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    eventGroup.setLayoutData(gd);
    layout = new GridLayout();
    eventGroup.setLayout(layout);
    activationEvent = new EventSelector(eventGroup, SWT.NONE);
    activationEvent.setLabel(Messages.get().ConditionEvents_ActivationEvent);
    activationEvent.setEventCode(object.getActivationEvent());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    activationEvent.setLayoutData(gd);
    deactivationEvent = new EventSelector(eventGroup, SWT.NONE);
    deactivationEvent.setLabel(Messages.get().ConditionEvents_DeactivationEvent);
    deactivationEvent.setEventCode(object.getDeactivationEvent());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    deactivationEvent.setLayoutData(gd);
    sourceObject = new ObjectSelector(eventGroup, SWT.NONE, true);
    sourceObject.setLabel(Messages.get().ConditionEvents_SourceObject);
    sourceObject.setEmptySelectionName(Messages.get().ConditionEvents_SelectionServer);
    sourceObject.setObjectId(object.getEventSourceObject());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    sourceObject.setLayoutData(gd);
    /* status group */
    Group statusGroup = new Group(dialogArea, SWT.NONE);
    statusGroup.setText(Messages.get().ConditionEvents_Status);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    statusGroup.setLayoutData(gd);
    layout = new GridLayout();
    layout.numColumns = 2;
    statusGroup.setLayout(layout);
    activeStatus = new StatusSelector(statusGroup, SWT.NONE, Severity.CRITICAL.getValue());
    activeStatus.setLabel(Messages.get().ConditionEvents_ActiveStatus);
    activeStatus.setSelection(object.getActiveStatus());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    activeStatus.setLayoutData(gd);
    inactiveStatus = new StatusSelector(statusGroup, SWT.NONE, Severity.CRITICAL.getValue());
    inactiveStatus.setLabel(Messages.get().ConditionEvents_InactiveStatus);
    inactiveStatus.setSelection(object.getInactiveStatus());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    inactiveStatus.setLayoutData(gd);
    return dialogArea;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) ObjectSelector(org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector) Composite(org.eclipse.swt.widgets.Composite) EventSelector(org.netxms.ui.eclipse.eventmanager.widgets.EventSelector) StatusSelector(org.netxms.ui.eclipse.widgets.StatusSelector) GridData(org.eclipse.swt.layout.GridData)

Example 3 with EventSelector

use of org.netxms.ui.eclipse.eventmanager.widgets.EventSelector in project netxms by netxms.

the class LogParserRuleEditor method createActionArea.

/**
 * Create action area
 */
private Composite createActionArea(Composite parent) {
    Composite area = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    area.setLayout(layout);
    long eventCode = 0;
    if (rule.getEvent() != null) {
        try {
            eventCode = Long.parseLong(rule.getEvent().getEvent());
        } catch (NumberFormatException e) {
            EventObject o = ((NXCSession) ConsoleSharedData.getSession()).findEventObjectByName(rule.getEvent().getEvent());
            if (o != null)
                eventCode = o.getCode();
        }
    }
    event = new EventSelector(area, SWT.NONE, true);
    toolkit.adapt(event);
    event.setLabel(Messages.get().LogParserRuleEditor_GenerateEvent);
    event.setEventCode(eventCode);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    event.setLayoutData(gd);
    event.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            eventParamCount.setEnabled(event.getEventCode() != 0);
            editor.fireModifyListeners();
        }
    });
    final WidgetFactory factory = new WidgetFactory() {

        @Override
        public Control createControl(Composite parent, int style) {
            return new Spinner(parent, style);
        }
    };
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    eventParamCount = (Spinner) WidgetHelper.createLabeledControl(area, SWT.BORDER, factory, Messages.get().LogParserRuleEditor_Parameters, gd);
    toolkit.adapt(eventParamCount);
    eventParamCount.setMinimum(0);
    eventParamCount.setMaximum(32);
    if (rule.getEvent() != null) {
        eventParamCount.setSelection(rule.getEvent().getParameterCount());
    } else {
        eventParamCount.setSelection(0);
        eventParamCount.setEnabled(false);
    }
    eventParamCount.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            editor.fireModifyListeners();
        }
    });
    final LogParserContext contextDefinition = rule.getContextDefinition();
    context = new LabeledText(area, SWT.NONE);
    toolkit.adapt(context);
    context.setLabel(Messages.get().LogParserRuleEditor_ChangeContext);
    // $NON-NLS-1$
    context.setText((contextDefinition != null) ? contextDefinition.getData() : "");
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    context.setLayoutData(gd);
    context.getTextControl().addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            boolean contextSet = !context.getText().trim().isEmpty();
            contextAction.setEnabled(contextSet);
            contextResetMode.setEnabled(contextSet && (contextAction.getSelectionIndex() == 0));
            editor.fireModifyListeners();
        }
    });
    final Composite contextOptions = new Composite(area, SWT.NONE);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;
    layout.makeColumnsEqualWidth = true;
    contextOptions.setLayout(layout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    contextOptions.setLayoutData(gd);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    contextAction = WidgetHelper.createLabeledCombo(contextOptions, SWT.READ_ONLY, Messages.get().LogParserRuleEditor_ContextAction, gd);
    toolkit.adapt(contextAction);
    contextAction.add(Messages.get().LogParserRuleEditor_CtxActionActivate);
    contextAction.add(Messages.get().LogParserRuleEditor_CtxActionClear);
    if (contextDefinition != null) {
        contextAction.select(contextDefinition.getAction());
    } else {
        contextAction.select(0);
        contextAction.setEnabled(false);
    }
    contextAction.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            contextResetMode.setEnabled(contextAction.getSelectionIndex() == 0);
            editor.fireModifyListeners();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    contextResetMode = WidgetHelper.createLabeledCombo(contextOptions, SWT.READ_ONLY, Messages.get().LogParserRuleEditor_ContextResetMode, gd);
    toolkit.adapt(contextResetMode);
    contextResetMode.add(Messages.get().LogParserRuleEditor_CtxModeAuto);
    contextResetMode.add(Messages.get().LogParserRuleEditor_CtxModeManual);
    if (contextDefinition != null) {
        contextResetMode.select(contextDefinition.getReset());
        contextResetMode.setEnabled(contextDefinition.getAction() == 0);
    } else {
        contextResetMode.select(0);
        contextResetMode.setEnabled(false);
    }
    contextResetMode.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            editor.fireModifyListeners();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    checkboxBreak = toolkit.createButton(area, "Process all", SWT.CHECK);
    checkboxBreak.setText("Break");
    checkboxBreak.setSelection(rule.isBreakProcessing());
    return area;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) DashboardComposite(org.netxms.ui.eclipse.widgets.DashboardComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) Spinner(org.eclipse.swt.widgets.Spinner) EventSelector(org.netxms.ui.eclipse.eventmanager.widgets.EventSelector) EventObject(org.netxms.client.events.EventObject) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) WidgetFactory(org.netxms.ui.eclipse.tools.WidgetFactory) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 4 with EventSelector

use of org.netxms.ui.eclipse.eventmanager.widgets.EventSelector in project netxms by netxms.

the class EditTableThresholdDialog method createDialogArea.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite dialogArea = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
    dialogArea.setLayout(layout);
    activationEvent = new EventSelector(dialogArea, SWT.NONE);
    activationEvent.setLabel(Messages.get().EditTableThresholdDialog_ActivationEvent);
    activationEvent.setEventCode(threshold.getActivationEvent());
    activationEvent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    deactivationEvent = new EventSelector(dialogArea, SWT.NONE);
    deactivationEvent.setLabel(Messages.get().EditTableThresholdDialog_DeactivationEvent);
    deactivationEvent.setEventCode(threshold.getDeactivationEvent());
    deactivationEvent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    sampleCount = new LabeledSpinner(dialogArea, SWT.NONE);
    sampleCount.setLabel("Sample count");
    sampleCount.setRange(1, 100000);
    sampleCount.setSelection(threshold.getSampleCount());
    new Label(dialogArea, SWT.NONE).setText(Messages.get().EditTableThresholdDialog_Conditions);
    conditionsEditor = new TableConditionsEditor(dialogArea, SWT.BORDER, columnCallback);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 700;
    gd.heightHint = 400;
    conditionsEditor.setLayoutData(gd);
    conditionsEditor.setConditions(threshold.getConditions());
    return dialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) EventSelector(org.netxms.ui.eclipse.eventmanager.widgets.EventSelector) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) TableConditionsEditor(org.netxms.ui.eclipse.datacollection.widgets.TableConditionsEditor) LabeledSpinner(org.netxms.ui.eclipse.widgets.LabeledSpinner)

Example 5 with EventSelector

use of org.netxms.ui.eclipse.eventmanager.widgets.EventSelector in project netxms by netxms.

the class EditThresholdDialog method createDialogArea.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createDialogArea(final Composite parent) {
    final Composite dialogArea = (Composite) super.createDialogArea(parent);
    GridLayout dialogLayout = new GridLayout();
    dialogArea.setLayout(dialogLayout);
    // Condition area
    conditionGroup = new Group(dialogArea, SWT.NONE);
    conditionGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    conditionGroup.setText(Messages.get().EditThresholdDialog_Condition);
    GridLayout condLayout = new GridLayout();
    condLayout.numColumns = 2;
    conditionGroup.setLayout(condLayout);
    function = WidgetHelper.createLabeledCombo(conditionGroup, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY, Messages.get().EditThresholdDialog_Function, WidgetHelper.DEFAULT_LAYOUT_DATA);
    function.add(Messages.get().EditThresholdDialog_LastValue);
    function.add(Messages.get().EditThresholdDialog_AvgValue);
    function.add(Messages.get().EditThresholdDialog_MeanDeviation);
    function.add(Messages.get().EditThresholdDialog_Diff);
    function.add(Messages.get().EditThresholdDialog_DCError);
    function.add(Messages.get().EditThresholdDialog_Sum);
    function.add(Messages.get().EditThresholdDialog_Script);
    function.select(threshold.getFunction());
    function.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            int f = function.getSelectionIndex();
            if ((f != Threshold.F_SCRIPT) && (selectedFunction == Threshold.F_SCRIPT)) {
                disposeScriptGroup();
                createOperGroup();
                parent.getParent().layout(true, true);
            } else if ((f == Threshold.F_SCRIPT) && (selectedFunction != Threshold.F_SCRIPT)) {
                disposeOperGroup();
                createScriptGroup();
                parent.getParent().layout(true, true);
            }
            if (f == Threshold.F_ERROR && selectedFunction != Threshold.F_ERROR) {
                if (!operation.isDisposed())
                    operation.setEnabled(false);
                value.setEnabled(false);
            } else if (f != Threshold.F_ERROR && selectedFunction == Threshold.F_ERROR) {
                if (!operation.isDisposed())
                    operation.setEnabled(true);
                value.setEnabled(true);
            }
            selectedFunction = f;
        }
    });
    samples = WidgetHelper.createLabeledText(conditionGroup, SWT.BORDER, 60, Messages.get().EditThresholdDialog_Samples, Integer.toString(threshold.getSampleCount()), WidgetHelper.DEFAULT_LAYOUT_DATA);
    samples.setTextLimit(5);
    if (threshold.getFunction() == Threshold.F_SCRIPT)
        createScriptGroup();
    else
        createOperGroup();
    // Event area
    Group eventGroup = new Group(dialogArea, SWT.NONE);
    eventGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    eventGroup.setText(Messages.get().EditThresholdDialog_Event);
    GridLayout eventLayout = new GridLayout();
    eventGroup.setLayout(eventLayout);
    activationEvent = new EventSelector(eventGroup, SWT.NONE);
    activationEvent.setLabel(Messages.get().EditThresholdDialog_ActEvent);
    activationEvent.setEventCode(threshold.getFireEvent());
    GridData gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.widthHint = 550;
    activationEvent.setLayoutData(gd);
    deactivationEvent = new EventSelector(eventGroup, SWT.NONE);
    deactivationEvent.setLabel(Messages.get().EditThresholdDialog_DeactEvent);
    deactivationEvent.setEventCode(threshold.getRearmEvent());
    deactivationEvent.setLayoutData(gd);
    // Repeat area
    Group repeatGroup = new Group(dialogArea, SWT.NONE);
    repeatGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    repeatGroup.setText(Messages.get().EditThresholdDialog_RepeatEvent);
    GridLayout repeatLayout = new GridLayout();
    repeatLayout.numColumns = 3;
    repeatGroup.setLayout(repeatLayout);
    repeatDefault = new Button(repeatGroup, SWT.RADIO);
    repeatDefault.setText(Messages.get().EditThresholdDialog_UseDefault);
    gd = new GridData();
    gd.horizontalAlignment = SWT.LEFT;
    gd.horizontalSpan = 3;
    repeatDefault.setLayoutData(gd);
    repeatDefault.setSelection(threshold.getRepeatInterval() == -1);
    repeatNever = new Button(repeatGroup, SWT.RADIO);
    repeatNever.setText(Messages.get().EditThresholdDialog_Never);
    gd = new GridData();
    gd.horizontalAlignment = SWT.LEFT;
    gd.horizontalSpan = 3;
    repeatNever.setLayoutData(gd);
    repeatNever.setSelection(threshold.getRepeatInterval() == 0);
    repeatCustom = new Button(repeatGroup, SWT.RADIO);
    repeatCustom.setText(Messages.get().EditThresholdDialog_Every);
    repeatCustom.setSelection(threshold.getRepeatInterval() > 0);
    repeatCustom.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            repeatInterval.setEnabled(repeatCustom.getSelection());
        }
    });
    repeatInterval = new Text(repeatGroup, SWT.BORDER);
    repeatInterval.setTextLimit(5);
    // $NON-NLS-1$
    repeatInterval.setText((threshold.getRepeatInterval() > 0) ? Integer.toString(threshold.getRepeatInterval()) : "3600");
    repeatInterval.setEnabled(threshold.getRepeatInterval() > 0);
    new Label(repeatGroup, SWT.NONE).setText(Messages.get().EditThresholdDialog_Seconds);
    return dialogArea;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) EventSelector(org.netxms.ui.eclipse.eventmanager.widgets.EventSelector) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText)

Aggregations

GridData (org.eclipse.swt.layout.GridData)6 GridLayout (org.eclipse.swt.layout.GridLayout)6 Composite (org.eclipse.swt.widgets.Composite)6 EventSelector (org.netxms.ui.eclipse.eventmanager.widgets.EventSelector)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Label (org.eclipse.swt.widgets.Label)4 SelectionListener (org.eclipse.swt.events.SelectionListener)3 Button (org.eclipse.swt.widgets.Button)3 LabeledText (org.netxms.ui.eclipse.widgets.LabeledText)3 RowLayout (org.eclipse.swt.layout.RowLayout)2 Group (org.eclipse.swt.widgets.Group)2 TableViewer (org.eclipse.jface.viewers.TableViewer)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 RowData (org.eclipse.swt.layout.RowData)1 Combo (org.eclipse.swt.widgets.Combo)1 Spinner (org.eclipse.swt.widgets.Spinner)1 Text (org.eclipse.swt.widgets.Text)1 EventObject (org.netxms.client.events.EventObject)1