use of org.netxms.ui.eclipse.alarmviewer.widgets.AlarmCategorySelector 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;
}
Aggregations