use of org.netxms.client.events.EventObject 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;
}
use of org.netxms.client.events.EventObject in project netxms by netxms.
the class NXCSession method syncEventObjects.
/**
* Synchronize event templates configuration. After call to this method
* session object will maintain internal list of configured event templates.
*
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public void syncEventObjects() throws IOException, NXCException {
List<EventObject> objects = getEventObjects();
synchronized (eventObjects) {
eventObjects.clear();
for (EventObject o : objects) {
eventObjects.put(o.getCode(), o);
}
eventObjectsNeedSync = true;
}
}
use of org.netxms.client.events.EventObject in project netxms by netxms.
the class NXCSession method getEventObjects.
/**
* Get event objects from server
*
* @return List of configured event objects
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public List<EventObject> getEventObjects() throws IOException, NXCException {
NXCPMessage msg = newMessage(NXCPCodes.CMD_LOAD_EVENT_DB);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_EVENTS);
long base = NXCPCodes.VID_ELEMENT_LIST_BASE;
ArrayList<EventObject> list = new ArrayList<EventObject>();
for (int i = 0; i < count; i++) {
list.add(EventObject.createFromMessage(response, base));
base += 10;
}
return list;
}
use of org.netxms.client.events.EventObject in project netxms by netxms.
the class EventConditionEditor method createContent.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.logviewer.widgets.ConditionEditor#createContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createContent(Composite parent, ColumnFilter initialFilter) {
Composite group = new Composite(this, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.horizontalSpacing = WidgetHelper.INNER_SPACING;
layout.numColumns = 2;
group.setLayout(layout);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
group.setLayoutData(gd);
objectName = new CLabel(group, SWT.NONE);
toolkit.adapt(objectName);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.TOP;
objectName.setLayoutData(gd);
objectName.setText(EMPTY_SELECTION_TEXT);
final ImageHyperlink selectionLink = toolkit.createImageHyperlink(group, SWT.NONE);
selectionLink.setImage(SharedIcons.IMG_FIND);
selectionLink.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
selectEvent();
}
});
if ((initialFilter != null) && (initialFilter.getType() == ColumnFilterType.EQUALS)) {
setSelectedOperation(initialFilter.isNegated() ? 1 : 0);
eventCode = initialFilter.getNumericValue();
EventObject o = ConsoleSharedData.getSession().findEventObjectByCode(eventCode);
if (o != null && o instanceof EventObject) {
objectName.setText(o.getName());
objectName.setImage(labelProvider.getImage(o));
} else {
objectName.setImage(StatusDisplayInfo.getStatusImage(Severity.UNKNOWN));
// $NON-NLS-1$ //$NON-NLS-2$
objectName.setText("[" + eventCode + "]");
}
}
}
use of org.netxms.client.events.EventObject in project netxms by netxms.
the class EventObjectList method removeFromGroup.
/**
* Remove event object from group
*/
@SuppressWarnings("unchecked")
protected void removeFromGroup() {
ITreeSelection selection = (ITreeSelection) viewer.getSelection();
List<EventObject> list = selection.toList();
for (int i = 0; i < selection.size(); i++) {
EventGroup parent = (EventGroup) selection.getPathsFor(list.get(i))[0].getParentPath().getLastSegment();
EventObject child = list.get(i);
parent.removeChild(child.getCode());
modifyEventObject(parent, false);
}
}
Aggregations