use of org.netxms.client.events.AlarmCategory in project netxms by netxms.
the class AlarmCategorySelector method setCategoryId.
/**
* Set category Id
*
* @param categoryId
*/
public void setCategoryId(List<Long> categoryId) {
if (this.categoryId.equals(categoryId))
// Nothing to change
return;
if (categoryId != null && !categoryId.isEmpty()) {
if (categoryId.get(0) == 0) {
setText("<none>");
} else {
List<AlarmCategory> categories = ((NXCSession) ConsoleSharedData.getSession()).findMultipleAlarmCategories(categoryId);
if (categories != null) {
StringBuilder sb = new StringBuilder();
this.categoryId.clear();
for (AlarmCategory c : categories) {
sb.append(c.getName() + ";");
this.categoryId.add(c.getId());
}
setText(sb.toString());
} else {
setText("<unknown>");
}
}
} else {
setText("<none>");
}
fireModifyListeners();
}
use of org.netxms.client.events.AlarmCategory in project netxms by netxms.
the class AlarmCategoryList method createCategory.
/**
* Create new category
*/
public void createCategory() {
AlarmCategoryEditor editor = new AlarmCategoryEditor(new AlarmCategory());
PropertyDialog dlg = PropertyDialog.createDialogOn(getShell(), null, editor);
dlg.open();
}
use of org.netxms.client.events.AlarmCategory in project netxms by netxms.
the class AlarmCategoryList method refreshView.
/**
* Refresh dialog
*/
public void refreshView() {
new ConsoleJob("Open alarm category list", null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final List<AlarmCategory> list = session.getAlarmCategories();
runInUIThread(new Runnable() {
@Override
public void run() {
alarmCategories = new HashMap<Long, AlarmCategory>(list.size());
for (final AlarmCategory c : list) {
alarmCategories.put(c.getId(), c);
}
viewer.setInput(alarmCategories.values().toArray());
}
});
}
@Override
protected String getErrorMessage() {
return "Cannot open alarm category list";
}
}.start();
}
use of org.netxms.client.events.AlarmCategory in project netxms by netxms.
the class RuleEditor method createActionControl.
/**
* Create action summary control
*
* @param parent
* @param rule
* @return
*/
private Control createActionControl(Composite parent, final EventProcessingPolicyRule rule) {
Composite clientArea = new Composite(parent, SWT.NONE);
clientArea.setBackground(SharedColors.getColor(SharedColors.RULE_EDITOR_BACKGROUND, getDisplay()));
GridLayout layout = new GridLayout();
layout.verticalSpacing = 0;
clientArea.setLayout(layout);
/* alarm */
if ((rule.getFlags() & EventProcessingPolicyRule.GENERATE_ALARM) != 0) {
// $NON-NLS-1$
final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleAlarm#10");
if (rule.getAlarmSeverity().compareTo(Severity.TERMINATE) < 0) {
addActionGroupLabel(clientArea, Messages.get().RuleEditor_GenerateAlarm, editor.getImageAlarm(), listener);
CLabel clabel = createCLabel(clientArea, 1, false);
clabel.setImage(StatusDisplayInfo.getStatusImage(rule.getAlarmSeverity()));
clabel.setText(rule.getAlarmMessage());
clabel.addMouseListener(listener);
if ((rule.getAlarmKey() != null) && !rule.getAlarmKey().isEmpty()) {
createLabel(clientArea, 1, false, String.format(Messages.get().RuleEditor_WithKey, rule.getAlarmKey()), null);
}
} else if (rule.getAlarmSeverity() == Severity.TERMINATE) {
addActionGroupLabel(clientArea, Messages.get().RuleEditor_TerminateAlarms, editor.getImageTerminate(), listener);
createLabel(clientArea, 1, false, String.format(Messages.get().RuleEditor_WithKey, rule.getAlarmKey()), listener);
if ((rule.getFlags() & EventProcessingPolicyRule.TERMINATE_BY_REGEXP) != 0)
createLabel(clientArea, 1, false, Messages.get().RuleEditor_UserRegexpForTerminate, listener);
} else if (rule.getAlarmSeverity() == Severity.RESOLVE) {
addActionGroupLabel(clientArea, Messages.get().RuleEditor_ResolveAlarms, editor.getImageTerminate(), listener);
createLabel(clientArea, 1, false, String.format(Messages.get().RuleEditor_WithKey, rule.getAlarmKey()), listener);
if ((rule.getFlags() & EventProcessingPolicyRule.TERMINATE_BY_REGEXP) != 0)
createLabel(clientArea, 1, false, Messages.get().RuleEditor_UseRegexpForResolve, listener);
}
if (rule.getAlarmCategories().size() > 0) {
createLabel(clientArea, 1, false, rule.getAlarmCategories().size() == 1 ? "with category: " : "with categories: ", null);
for (Long id : rule.getAlarmCategories()) {
AlarmCategory category = editor.findAlarmCategoryById(id);
if (category != null) {
createLabel(clientArea, 2, false, category.getName(), null);
}
}
}
if ((rule.getFlags() & EventProcessingPolicyRule.CREATE_TICKET) != 0) {
createLabel(clientArea, 1, false, "creates helpdesk ticket", null);
}
}
/* persistent storage */
if (rule.getPStorageSet().size() != 0 || rule.getPStorageDelete().size() != 0) {
// $NON-NLS-1$
final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RulePStorage#20");
addActionGroupLabel(clientArea, "Update persistent storage entries", editor.getImageSituation(), listener);
if (rule.getPStorageSet().size() != 0) {
// $NON-NLS-1$ //$NON-NLS-2$
createLabel(clientArea, 1, false, "Set Persistent storage values", listener);
for (Entry<String, String> e : rule.getPStorageSet().entrySet()) {
// $NON-NLS-1$ //$NON-NLS-2$
createLabel(clientArea, 2, false, e.getKey() + " = \"" + e.getValue() + "\"", listener);
}
}
if (rule.getPStorageDelete().size() != 0) {
createLabel(clientArea, 1, false, "Delete persistent storage values", listener);
List<String> pStorageList = rule.getPStorageDelete();
for (int i = 0; i < pStorageList.size(); i++) {
createLabel(clientArea, 2, false, pStorageList.get(i), listener);
}
}
}
/* actions */
if (rule.getActions().size() > 0) {
// $NON-NLS-1$
final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleServerActions#30");
addActionGroupLabel(clientArea, Messages.get().RuleEditor_ExecuteActions, editor.getImageExecute(), listener);
for (Long id : rule.getActions()) {
CLabel clabel = createCLabel(clientArea, 1, false);
clabel.addMouseListener(listener);
ServerAction action = editor.findActionById(id);
if (action != null) {
clabel.setText(action.getName());
clabel.setImage(labelProvider.getImage(action));
} else {
// $NON-NLS-1$ //$NON-NLS-2$
clabel.setText("<" + id.toString() + ">");
}
}
}
/* flags */
if ((rule.getFlags() & EventProcessingPolicyRule.STOP_PROCESSING) != 0) {
// $NON-NLS-1$
final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleAction#1");
addActionGroupLabel(clientArea, Messages.get().RuleEditor_StopProcessing, editor.getImageStop(), listener);
}
return clientArea;
}
Aggregations