use of org.netxms.client.events.EventTemplate in project netxms by netxms.
the class ThresholdLabelProvider method getColumnText.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
*/
@Override
public String getColumnText(Object element, int columnIndex) {
switch(columnIndex) {
case Thresholds.COLUMN_OPERATION:
int f = ((Threshold) element).getFunction();
StringBuilder text = new StringBuilder(FUNCTIONS[f]);
text.append(((Threshold) element).getSampleCount());
// $NON-NLS-1$
text.append(") ");
if (f != Threshold.F_SCRIPT) {
text.append(OPERATIONS[((Threshold) element).getOperation()]);
text.append(' ');
text.append(((Threshold) element).getValue());
}
return text.toString();
case Thresholds.COLUMN_EVENT:
final EventTemplate event = (EventTemplate) session.findEventObjectByCode(((Threshold) element).getFireEvent());
return eventLabelProvider.getText(event);
}
return null;
}
use of org.netxms.client.events.EventTemplate in project netxms by netxms.
the class EventObjectList method editEventTemplate.
/**
* Edit currently selected event template
*/
protected void editEventTemplate() {
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
if (selection.getFirstElement() instanceof EventGroup) {
final EventGroup group = new EventGroup((EventGroup) selection.getFirstElement());
EditEventGroupDialog dlg = new EditEventGroupDialog(getShell().getShell(), group);
if (dlg.open() == Window.OK)
modifyEventObject(group, false);
else
return;
}
final EventTemplate etmpl = new EventTemplate((EventTemplate) selection.getFirstElement());
EditEventTemplateDialog dlg = new EditEventTemplateDialog(getShell().getShell(), etmpl, false);
if (dlg.open() == Window.OK)
modifyEventObject(etmpl, false);
}
use of org.netxms.client.events.EventTemplate in project netxms by netxms.
the class EventSelector method setEventCode.
/**
* Set event code
* @param eventCode
*/
public void setEventCode(long eventCode) {
if (this.eventCode == eventCode)
// nothing to change
return;
this.eventCode = eventCode;
if (eventCode != 0) {
EventObject object = ((NXCSession) ConsoleSharedData.getSession()).findEventObjectByCode(eventCode);
if (object != null) {
setText(object.getName());
if (object instanceof EventTemplate)
setImage(StatusDisplayInfo.getStatusImage(((EventTemplate) object).getSeverity()));
else
setImage(SharedIcons.IMG_CONTAINER);
getTextControl().setToolTipText(generateToolTipText(object));
} else {
setText(Messages.get().EventSelector_Unknown);
setImage(null);
getTextControl().setToolTipText(null);
}
} else {
setText(Messages.get().EventSelector_None);
setImage(null);
getTextControl().setToolTipText(null);
}
fireModifyListeners();
}
use of org.netxms.client.events.EventTemplate in project netxms by netxms.
the class ExportFileBuilder method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
// Initiate loading of required plugins if they was not loaded yet
try {
// $NON-NLS-1$
Platform.getAdapterManager().loadAdapter(new EventTemplate(0), "org.eclipse.ui.model.IWorkbenchAdapter");
// $NON-NLS-1$
Platform.getAdapterManager().loadAdapter(session.getTopLevelObjects()[0], "org.eclipse.ui.model.IWorkbenchAdapter");
} catch (Exception e) {
}
toolkit = new FormToolkit(getSite().getShell().getDisplay());
form = toolkit.createScrolledForm(parent);
form.setText(Messages.get().ExportFileBuilder_FormTitle);
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = 3;
form.getBody().setLayout(layout);
createFileSection();
createTemplateSection();
createEventSection();
createTrapSection();
createRuleSection();
createScriptSection();
createToolsSection();
createSummaryTablesSection();
createActionsSection();
form.reflow(true);
activateContext();
createActions();
contributeToActionBars();
}
use of org.netxms.client.events.EventTemplate in project netxms by netxms.
the class Thresholds method createContents.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
// Initiate loading of event manager plugin if it was not loaded before
// $NON-NLS-1$
Platform.getAdapterManager().loadAdapter(new EventTemplate(0), "org.eclipse.ui.model.IWorkbenchAdapter");
Composite dialogArea = (Composite) super.createContents(parent);
dci = editor.getObjectAsItem();
thresholds = new ArrayList<Threshold>(dci.getThresholds().size());
for (Threshold t : dci.getThresholds()) thresholds.add(new Threshold(t));
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
instance = new LabeledText(dialogArea, SWT.NONE);
instance.setLabel(Messages.get().Thresholds_Instance);
instance.setText(dci.getInstance());
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
instance.setLayoutData(gd);
if (// DCI created by instance discovery
dci.getTemplateId() == dci.getNodeId())
instance.getTextControl().setEditable(false);
checkAllThresholds = new Button(dialogArea, SWT.CHECK);
checkAllThresholds.setText(Messages.get().Thresholds_ProcessAll);
checkAllThresholds.setSelection(dci.isProcessAllThresholds());
Composite thresholdArea = new Composite(dialogArea, SWT.NONE);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.horizontalSpan = 2;
thresholdArea.setLayoutData(gd);
layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.INNER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.numColumns = 2;
thresholdArea.setLayout(layout);
new Label(thresholdArea, SWT.NONE).setText(Messages.get().Thresholds_Thresholds);
thresholdList = new TableViewer(thresholdArea, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.horizontalSpan = 2;
thresholdList.getControl().setLayoutData(gd);
setupThresholdList();
thresholdList.setInput(thresholds.toArray());
Composite leftButtons = new Composite(thresholdArea, SWT.NONE);
gd = new GridData();
gd.horizontalAlignment = SWT.LEFT;
leftButtons.setLayoutData(gd);
RowLayout buttonsLayout = new RowLayout(SWT.HORIZONTAL);
buttonsLayout.marginBottom = 0;
buttonsLayout.marginLeft = 0;
buttonsLayout.marginRight = 0;
buttonsLayout.marginTop = 0;
buttonsLayout.spacing = WidgetHelper.OUTER_SPACING;
buttonsLayout.fill = true;
buttonsLayout.pack = false;
leftButtons.setLayout(buttonsLayout);
upButton = new Button(leftButtons, SWT.PUSH);
upButton.setText(Messages.get().Thresholds_Up);
upButton.setEnabled(false);
upButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
moveUp();
}
});
downButton = new Button(leftButtons, SWT.PUSH);
downButton.setText(Messages.get().Thresholds_Down);
downButton.setEnabled(false);
downButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
moveDown();
}
});
Composite buttons = new Composite(thresholdArea, SWT.NONE);
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
buttons.setLayoutData(gd);
buttonsLayout = new RowLayout(SWT.HORIZONTAL);
buttonsLayout.marginBottom = 0;
buttonsLayout.marginLeft = 0;
buttonsLayout.marginRight = 0;
buttonsLayout.marginTop = 0;
buttonsLayout.spacing = WidgetHelper.OUTER_SPACING;
buttonsLayout.fill = true;
buttonsLayout.pack = false;
buttons.setLayout(buttonsLayout);
addButton = new Button(buttons, SWT.PUSH);
addButton.setText(Messages.get().Thresholds_Add);
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
addButton.setLayoutData(rd);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
addThreshold();
}
});
duplicateButton = new Button(buttons, SWT.PUSH);
duplicateButton.setText("Duplicate");
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
duplicateButton.setLayoutData(rd);
duplicateButton.setEnabled(false);
duplicateButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
duplicateThreshold();
}
});
modifyButton = new Button(buttons, SWT.PUSH);
modifyButton.setText(Messages.get().Thresholds_Edit);
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
modifyButton.setLayoutData(rd);
modifyButton.setEnabled(false);
modifyButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
editThreshold();
}
});
deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText(Messages.get().Thresholds_Delete);
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
deleteButton.setLayoutData(rd);
deleteButton.setEnabled(false);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
deleteThresholds();
}
});
/**
* Selection change listener for thresholds list **
*/
thresholdList.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
int index = thresholds.indexOf(selection.getFirstElement());
upButton.setEnabled((selection.size() == 1) && (index > 0));
downButton.setEnabled((selection.size() == 1) && (index >= 0) && (index < thresholds.size() - 1));
modifyButton.setEnabled(selection.size() == 1);
deleteButton.setEnabled(selection.size() > 0);
duplicateButton.setEnabled(selection.size() > 0);
}
});
thresholdList.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
editThreshold();
}
});
return dialogArea;
}
Aggregations