Search in sources :

Example 1 with EventTreeComparator

use of org.netxms.ui.eclipse.alarmviewer.views.helpers.EventTreeComparator in project netxms by netxms.

the class AlarmDetails method createEventsSection.

/**
 * Create events section
 */
private void createEventsSection() {
    final Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR | Section.EXPANDED | Section.TWISTIE | Section.COMPACT);
    section.setText(Messages.get().AlarmDetails_RelatedEvents);
    final GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    section.setLayoutData(gd);
    section.addExpansionListener(new IExpansionListener() {

        @Override
        public void expansionStateChanging(ExpansionEvent e) {
            gd.grabExcessVerticalSpace = e.getState();
        }

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
        }
    });
    final Composite content = toolkit.createComposite(section);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    content.setLayout(layout);
    section.setClient(content);
    final String[] names = { Messages.get().AlarmDetails_Column_Severity, Messages.get().AlarmDetails_Column_Source, Messages.get().AlarmDetails_Column_Name, Messages.get().AlarmDetails_Column_Message, Messages.get().AlarmDetails_Column_Timestamp };
    final int[] widths = { 130, 160, 160, 400, 150 };
    eventViewer = new SortableTreeViewer(content, names, widths, EV_COLUMN_TIMESTAMP, SWT.DOWN, SWT.BORDER | SWT.FULL_SELECTION);
    eventViewer.setContentProvider(new EventTreeContentProvider());
    eventViewer.setLabelProvider(new EventTreeLabelProvider());
    eventViewer.setComparator(new EventTreeComparator());
    eventViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    final IDialogSettings settings = Activator.getDefault().getDialogSettings();
    // $NON-NLS-1$
    WidgetHelper.restoreTreeViewerSettings(eventViewer, settings, "AlarmDetails.Events");
    eventViewer.getControl().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            // $NON-NLS-1$
            WidgetHelper.saveTreeViewerSettings(eventViewer, settings, "AlarmDetails.Events");
        }
    });
}
Also used : SortableTreeViewer(org.netxms.ui.eclipse.widgets.SortableTreeViewer) DisposeListener(org.eclipse.swt.events.DisposeListener) IExpansionListener(org.eclipse.ui.forms.events.IExpansionListener) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) EventTreeContentProvider(org.netxms.ui.eclipse.alarmviewer.views.helpers.EventTreeContentProvider) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Section(org.eclipse.ui.forms.widgets.Section) GridLayout(org.eclipse.swt.layout.GridLayout) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) GridData(org.eclipse.swt.layout.GridData) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) EventTreeLabelProvider(org.netxms.ui.eclipse.alarmviewer.views.helpers.EventTreeLabelProvider) EventTreeComparator(org.netxms.ui.eclipse.alarmviewer.views.helpers.EventTreeComparator)

Aggregations

IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)1 IExpansionListener (org.eclipse.ui.forms.events.IExpansionListener)1 Section (org.eclipse.ui.forms.widgets.Section)1 EventTreeComparator (org.netxms.ui.eclipse.alarmviewer.views.helpers.EventTreeComparator)1 EventTreeContentProvider (org.netxms.ui.eclipse.alarmviewer.views.helpers.EventTreeContentProvider)1 EventTreeLabelProvider (org.netxms.ui.eclipse.alarmviewer.views.helpers.EventTreeLabelProvider)1 SortableTreeViewer (org.netxms.ui.eclipse.widgets.SortableTreeViewer)1