use of org.netxms.client.events.EventObject in project netxms by netxms.
the class RuleEditor method createConditionControl.
/**
* Create condition summary control
*
* @param parent
* @param rule
* @return
*/
private Control createConditionControl(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);
boolean needAnd = false;
if (((rule.getSources().size() > 0) && rule.isSourceInverted()) || ((rule.getSources().size() == 0) && (rule.getEvents().size() > 0) && rule.isEventsInverted()))
createLabel(clientArea, 0, true, Messages.get().RuleEditor_IF_NOT, null);
else
createLabel(clientArea, 0, true, Messages.get().RuleEditor_IF, null);
/* source */
if (rule.getSources().size() > 0) {
// $NON-NLS-1$
final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleSourceObjects#0");
addConditionGroupLabel(clientArea, Messages.get().RuleEditor_SourceIs, needAnd, rule.isSourceInverted(), listener);
for (Long id : rule.getSources()) {
CLabel clabel = createCLabel(clientArea, 2, false);
clabel.addMouseListener(listener);
AbstractObject object = session.findObjectById(id);
if (object != null) {
clabel.setText(object.getObjectName());
clabel.setImage(labelProvider.getImage(object));
} else {
// $NON-NLS-1$ //$NON-NLS-2$
clabel.setText("[" + id.toString() + "]");
clabel.setImage(SharedIcons.IMG_UNKNOWN_OBJECT);
}
}
needAnd = true;
}
/* events */
if (rule.getEvents().size() > 0) {
// $NON-NLS-1$
final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleEvents#10");
addConditionGroupLabel(clientArea, Messages.get().RuleEditor_EventIs, needAnd, rule.isEventsInverted(), listener);
List<EventObject> sortedEvents = new ArrayList<EventObject>(rule.getEvents().size());
for (Long code : rule.getEvents()) {
EventObject event = session.findEventObjectByCode(code);
if (event == null) {
event = new EventTemplate(code);
((EventTemplate) event).setSeverity(Severity.UNKNOWN);
// $NON-NLS-1$ //$NON-NLS-2$
event.setName("<" + code.toString() + ">");
}
sortedEvents.add(event);
}
Collections.sort(sortedEvents, new Comparator<EventObject>() {
@Override
public int compare(EventObject t1, EventObject t2) {
return t1.getName().compareToIgnoreCase(t2.getName());
}
});
for (EventObject e : sortedEvents) {
CLabel clabel = createCLabel(clientArea, 2, false);
clabel.addMouseListener(listener);
clabel.setText(e.getName());
if (e instanceof EventTemplate)
clabel.setImage(StatusDisplayInfo.getStatusImage(((EventTemplate) e).getSeverity()));
else
clabel.setImage(SharedIcons.IMG_CONTAINER);
}
needAnd = true;
}
/* severity */
if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_ANY) != EventProcessingPolicyRule.SEVERITY_ANY) {
// $NON-NLS-1$
final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleSeverityFilter#20");
addConditionGroupLabel(clientArea, Messages.get().RuleEditor_SeverityIs, needAnd, false, listener);
if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_NORMAL) != 0)
addSeverityLabel(clientArea, Severity.NORMAL, listener);
if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_WARNING) != 0)
addSeverityLabel(clientArea, Severity.WARNING, listener);
if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_MINOR) != 0)
addSeverityLabel(clientArea, Severity.MINOR, listener);
if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_MAJOR) != 0)
addSeverityLabel(clientArea, Severity.MAJOR, listener);
if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_CRITICAL) != 0)
addSeverityLabel(clientArea, Severity.CRITICAL, listener);
needAnd = true;
}
/* script */
if ((rule.getScript() != null) && !rule.getScript().isEmpty()) {
// $NON-NLS-1$
final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleFilterScript#30");
addConditionGroupLabel(clientArea, Messages.get().RuleEditor_ScriptIs, needAnd, false, listener);
ScriptEditor scriptEditor = new ScriptEditor(clientArea, SWT.BORDER, SWT.NONE);
GridData gd = new GridData();
gd.horizontalIndent = INDENT * 2;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
scriptEditor.setLayoutData(gd);
scriptEditor.setText(rule.getScript());
scriptEditor.getTextWidget().setEditable(false);
scriptEditor.getTextWidget().addMouseListener(listener);
}
return clientArea;
}
use of org.netxms.client.events.EventObject in project netxms by netxms.
the class EventSelector method selectionButtonHandler.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.widgets.AbstractSelector#selectionButtonHandler()
*/
@Override
protected void selectionButtonHandler() {
EventSelectionDialog dlg = new EventSelectionDialog(getShell(), false);
dlg.enableMultiSelection(false);
if (dlg.open() == Window.OK) {
long prevEventCode = eventCode;
EventObject[] events = dlg.getSelectedEvents();
if (events.length > 0) {
eventCode = events[0].getCode();
setText(events[0].getName());
if (events[0] instanceof EventTemplate)
setImage(StatusDisplayInfo.getStatusImage(((EventTemplate) events[0]).getSeverity()));
else
setImage(SharedIcons.IMG_CONTAINER);
getTextControl().setToolTipText(generateToolTipText(events[0]));
} else {
eventCode = 0;
setText(Messages.get().EventSelector_None);
setImage(null);
getTextControl().setToolTipText(null);
}
if (prevEventCode != eventCode)
fireModifyListeners();
}
}
use of org.netxms.client.events.EventObject in project netxms by netxms.
the class EventConditionEditor method selectEvent.
/**
* Select event
*/
private void selectEvent() {
EventSelectionDialog dlg = new EventSelectionDialog(getShell(), false);
dlg.enableMultiSelection(false);
if (dlg.open() == Window.OK) {
EventObject[] events = dlg.getSelectedEvents();
if (events.length > 0) {
eventCode = events[0].getCode();
objectName.setText(events[0].getName());
objectName.setImage(labelProvider.getImage(events[0]));
} else {
eventCode = 0;
objectName.setText(EMPTY_SELECTION_TEXT);
objectName.setImage(null);
}
}
}
use of org.netxms.client.events.EventObject in project netxms by netxms.
the class EventObjectList method refreshView.
/**
* Refresh view
*/
private void refreshView() {
new ConsoleJob(Messages.get().EventConfigurator_OpenJob_Title, null, Activator.PLUGIN_ID, JOB_FAMILY) {
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.jobs.ConsoleJob#getErrorMessage()
*/
@Override
protected String getErrorMessage() {
return Messages.get().EventConfigurator_OpenJob_Error;
}
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.jobs.ConsoleJob#runInternal(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final List<EventObject> list = session.getEventObjects();
runInUIThread(new Runnable() {
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
eventObjects = new HashMap<Long, EventObject>(list.size());
for (final EventObject o : list) {
if ((o instanceof EventGroup) && !showGroups)
continue;
eventObjects.put(o.getCode(), o);
}
viewer.setInput(eventObjects.values().toArray());
}
});
}
}.start();
}
use of org.netxms.client.events.EventObject in project netxms by netxms.
the class RuleEvents method addEvent.
/**
* Add new event
*/
private void addEvent() {
EventSelectionDialog dlg = new EventSelectionDialog(getShell(), true);
dlg.enableMultiSelection(true);
if (dlg.open() == Window.OK) {
for (EventObject e : dlg.getSelectedEvents()) events.put(e.getCode(), e);
}
viewer.setInput(events.values().toArray());
}
Aggregations