use of org.netxms.ui.eclipse.serverconfig.dialogs.helpers.TrapListLabelProvider in project netxms by netxms.
the class ExportFileBuilder method createTrapSection.
/**
* Create "SNMP Traps" section
*/
private void createTrapSection() {
Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
section.setText(Messages.get().ExportFileBuilder_SectionTraps);
TableWrapData td = new TableWrapData();
td.align = TableWrapData.FILL;
td.grabHorizontal = true;
section.setLayoutData(td);
Composite clientArea = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
clientArea.setLayout(layout);
section.setClient(clientArea);
trapViewer = new TableViewer(clientArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
toolkit.adapt(trapViewer.getTable());
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 200;
gd.verticalSpan = 2;
trapViewer.getTable().setLayoutData(gd);
trapViewer.setContentProvider(new ArrayContentProvider());
trapViewer.setLabelProvider(new TrapListLabelProvider());
trapViewer.setComparator(new ObjectLabelComparator((ILabelProvider) eventViewer.getLabelProvider()));
trapViewer.getTable().setSortDirection(SWT.UP);
final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);
linkAdd.setText(Messages.get().ExportFileBuilder_Add);
linkAdd.setImage(SharedIcons.IMG_ADD_OBJECT);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
linkAdd.setLayoutData(gd);
linkAdd.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
if (snmpTrapCache == null) {
new ConsoleJob(Messages.get().ExportFileBuilder_TrapsLoadJobName, ExportFileBuilder.this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
snmpTrapCache = session.getSnmpTrapsConfigurationSummary();
runInUIThread(new Runnable() {
@Override
public void run() {
addTraps();
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().ExportFileBuilder_TrapsLoadJobError;
}
}.start();
} else {
addTraps();
}
}
});
final ImageHyperlink linkRemove = toolkit.createImageHyperlink(clientArea, SWT.NONE);
linkRemove.setText(Messages.get().ExportFileBuilder_Remove);
linkRemove.setImage(SharedIcons.IMG_DELETE_OBJECT);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
linkRemove.setLayoutData(gd);
linkRemove.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
removeObjects(trapViewer, traps);
}
});
}
use of org.netxms.ui.eclipse.serverconfig.dialogs.helpers.TrapListLabelProvider in project netxms by netxms.
the class SelectSnmpTrapDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
final Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
dialogArea.setLayout(layout);
filterText = new FilterText(dialogArea, SWT.NONE, null, false);
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
filterText.setLayoutData(gd);
final String[] names = { Messages.get().SelectSnmpTrapDialog_ColOID, Messages.get().SelectSnmpTrapDialog_ColEvent, Messages.get().SelectSnmpTrapDialog_ColDescription };
final int[] widths = { 350, 250, 400 };
viewer = new SortableTableViewer(dialogArea, names, widths, COLUMN_OID, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new TrapListLabelProvider());
viewer.setComparator(new SnmpTrapComparator());
viewer.setInput(trapList.toArray());
filter = new SnmpTrapFilter();
viewer.addFilter(filter);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 450;
viewer.getControl().setLayoutData(gd);
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
filter.setFilterString(filterText.getText());
viewer.refresh();
}
});
return dialogArea;
}
Aggregations