Search in sources :

Example 1 with TrapListLabelProvider

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);
        }
    });
}
Also used : HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) ObjectLabelComparator(org.netxms.ui.eclipse.tools.ObjectLabelComparator) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) Section(org.eclipse.ui.forms.widgets.Section) TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) GridLayout(org.eclipse.swt.layout.GridLayout) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TrapListLabelProvider(org.netxms.ui.eclipse.serverconfig.dialogs.helpers.TrapListLabelProvider) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) TableViewer(org.eclipse.jface.viewers.TableViewer) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 2 with TrapListLabelProvider

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;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) SnmpTrapFilter(org.netxms.ui.eclipse.serverconfig.dialogs.helpers.SnmpTrapFilter) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) TrapListLabelProvider(org.netxms.ui.eclipse.serverconfig.dialogs.helpers.TrapListLabelProvider) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SnmpTrapComparator(org.netxms.ui.eclipse.serverconfig.dialogs.helpers.SnmpTrapComparator) FilterText(org.netxms.ui.eclipse.widgets.FilterText)

Aggregations

ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 TrapListLabelProvider (org.netxms.ui.eclipse.serverconfig.dialogs.helpers.TrapListLabelProvider)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 HyperlinkAdapter (org.eclipse.ui.forms.events.HyperlinkAdapter)1 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)1 ImageHyperlink (org.eclipse.ui.forms.widgets.ImageHyperlink)1 Section (org.eclipse.ui.forms.widgets.Section)1 TableWrapData (org.eclipse.ui.forms.widgets.TableWrapData)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1 SnmpTrapComparator (org.netxms.ui.eclipse.serverconfig.dialogs.helpers.SnmpTrapComparator)1 SnmpTrapFilter (org.netxms.ui.eclipse.serverconfig.dialogs.helpers.SnmpTrapFilter)1 ObjectLabelComparator (org.netxms.ui.eclipse.tools.ObjectLabelComparator)1 FilterText (org.netxms.ui.eclipse.widgets.FilterText)1