Search in sources :

Example 1 with SortableTreeViewer

use of org.netxms.ui.eclipse.widgets.SortableTreeViewer in project netxms by netxms.

the class IdMatchingDialog method createDialogArea.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite dialogArea = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout();
    layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    dialogArea.setLayout(layout);
    Label label = new Label(dialogArea, SWT.WRAP);
    label.setText(Messages.get().IdMatchingDialog_HelpText);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.widthHint = 0;
    label.setLayoutData(gd);
    final String[] names = { Messages.get().IdMatchingDialog_ColumnOriginalID, Messages.get().IdMatchingDialog_ColumnName, Messages.get().IdMatchingDialog_ColumnMatchID, Messages.get().IdMatchingDialog_ColumnMatchName };
    final int[] widths = { 100, 300, 80, 300 };
    viewer = new SortableTreeViewer(dialogArea, names, widths, 0, SWT.UP, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
    viewer.getTree().setLinesVisible(true);
    viewer.getTree().setHeaderVisible(true);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.heightHint = 400;
    viewer.getControl().setLayoutData(gd);
    viewer.setContentProvider(new IdMatchingContentProvider());
    viewer.setLabelProvider(new IdMatchingLabelProvider());
    viewer.setInput(new Object[] { objects, dcis });
    viewer.expandAll();
    createActions();
    createPopupMenu();
    return dialogArea;
}
Also used : SortableTreeViewer(org.netxms.ui.eclipse.widgets.SortableTreeViewer) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) IdMatchingContentProvider(org.netxms.ui.eclipse.dashboard.dialogs.helpers.IdMatchingContentProvider) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) IdMatchingLabelProvider(org.netxms.ui.eclipse.dashboard.dialogs.helpers.IdMatchingLabelProvider)

Example 2 with SortableTreeViewer

use of org.netxms.ui.eclipse.widgets.SortableTreeViewer in project netxms by netxms.

the class RepositoryManager method createPartControl.

/* (non-Javadoc)
    * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
    */
@Override
public void createPartControl(Composite parent) {
    content = new Composite(parent, SWT.NONE);
    content.setLayout(new FormLayout());
    // Create filter area
    filterText = new FilterText(content, SWT.NONE);
    filterText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            onFilterModify();
        }
    });
    filterText.setCloseAction(new Action() {

        @Override
        public void run() {
            enableFilter(false);
        }
    });
    final String[] columnNames = { "Name", "Version", "GUID" };
    final int[] columnWidths = { 300, 120, 150 };
    viewer = new SortableTreeViewer(content, columnNames, columnWidths, 0, SWT.UP, SortableTableViewer.DEFAULT_STYLE);
    WidgetHelper.restoreTreeViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
    viewer.setContentProvider(new RepositoryContentProvider(this));
    viewer.setLabelProvider(new RepositoryLabelProvider());
    // viewer.setComparator(new AgentFileComparator());
    filter = new RepositoryFilter();
    viewer.addFilter(filter);
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection != null) {
                actionDelete.setEnabled(selection.size() > 0);
            }
        }
    });
    viewer.getTree().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            WidgetHelper.saveTreeViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
        }
    });
    // Setup layout
    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(filterText);
    fd.right = new FormAttachment(100, 0);
    fd.bottom = new FormAttachment(100, 0);
    viewer.getTree().setLayoutData(fd);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    filterText.setLayoutData(fd);
    createActions();
    contributeToActionBars();
    createPopupMenu();
    activateContext();
    filterText.setCloseAction(actionShowFilter);
    // Set initial focus to filter input line
    if (filterEnabled)
        filterText.setFocus();
    else
        // Will hide filter area correctly
        enableFilter(false);
    refreshRepositoryList();
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) SortableTreeViewer(org.netxms.ui.eclipse.widgets.SortableTreeViewer) DisposeListener(org.eclipse.swt.events.DisposeListener) Action(org.eclipse.jface.action.Action) RefreshAction(org.netxms.ui.eclipse.actions.RefreshAction) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryLabelProvider(org.netxms.ui.eclipse.market.views.helpers.RepositoryLabelProvider) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) RepositoryContentProvider(org.netxms.ui.eclipse.market.views.helpers.RepositoryContentProvider) RepositoryFilter(org.netxms.ui.eclipse.market.views.helpers.RepositoryFilter) FilterText(org.netxms.ui.eclipse.widgets.FilterText) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 3 with SortableTreeViewer

use of org.netxms.ui.eclipse.widgets.SortableTreeViewer in project netxms by netxms.

the class AgentFileManager method createPartControl.

/*
    * (non-Javadoc)
    * 
    * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
    */
@Override
public void createPartControl(Composite parent) {
    content = new Composite(parent, SWT.NONE);
    content.setLayout(new FormLayout());
    // Create filter area
    filterText = new FilterText(content, SWT.NONE);
    filterText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            onFilterModify();
        }
    });
    // $NON-NLS-1$
    String os = ((Node) session.findObjectById(objectId)).getSystemDescription();
    if (// if OS is windows don't show group and access rights columns //$NON-NLS-1$
    os.contains("Windows")) {
        final String[] columnNames = { Messages.get().AgentFileManager_ColName, Messages.get().AgentFileManager_ColType, Messages.get().AgentFileManager_ColSize, Messages.get().AgentFileManager_ColDate, Messages.get().AgentFileManager_ColOwner };
        final int[] columnWidths = { 300, 120, 150, 150, 150 };
        viewer = new SortableTreeViewer(content, columnNames, columnWidths, 0, SWT.UP, SortableTableViewer.DEFAULT_STYLE);
    } else {
        final String[] columnNames = { Messages.get().AgentFileManager_ColName, Messages.get().AgentFileManager_ColType, Messages.get().AgentFileManager_ColSize, Messages.get().AgentFileManager_ColDate, Messages.get().AgentFileManager_ColOwner, Messages.get().AgentFileManager_ColGroup, Messages.get().AgentFileManager_ColAccessRights };
        final int[] columnWidths = { 300, 120, 150, 150, 150, 150, 200 };
        viewer = new SortableTreeViewer(content, columnNames, columnWidths, 0, SWT.UP, SortableTableViewer.DEFAULT_STYLE);
    }
    WidgetHelper.restoreTreeViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
    viewer.setContentProvider(new ViewAgentFilesProvider());
    viewer.setLabelProvider(new AgentFileLabelProvider());
    viewer.setComparator(new AgentFileComparator());
    filter = new AgentFileFilter();
    viewer.addFilter(filter);
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection != null) {
                actionDelete.setEnabled(selection.size() > 0);
                actionCalculateFolderSize.setEnabled(selection.size() > 0);
            }
        }
    });
    viewer.getTree().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            WidgetHelper.saveTreeViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
        }
    });
    enableDragSupport();
    enableDropSupport();
    enableInPlaceRename();
    // Setup layout
    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(filterText);
    fd.right = new FormAttachment(100, 0);
    fd.bottom = new FormAttachment(100, 0);
    viewer.getTree().setLayoutData(fd);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    filterText.setLayoutData(fd);
    createActions();
    contributeToActionBars();
    createPopupMenu();
    activateContext();
    filterText.setCloseAction(actionShowFilter);
    // Set initial focus to filter input line
    if (initShowFilter)
        filterText.setFocus();
    else
        // Will hide filter area correctly
        enableFilter(false);
    refreshFileList();
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) SortableTreeViewer(org.netxms.ui.eclipse.widgets.SortableTreeViewer) DisposeListener(org.eclipse.swt.events.DisposeListener) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ViewAgentFilesProvider(org.netxms.ui.eclipse.filemanager.views.helpers.ViewAgentFilesProvider) Node(org.netxms.client.objects.Node) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AgentFileComparator(org.netxms.ui.eclipse.filemanager.views.helpers.AgentFileComparator) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) FilterText(org.netxms.ui.eclipse.widgets.FilterText) AgentFileFilter(org.netxms.ui.eclipse.filemanager.views.helpers.AgentFileFilter) AgentFileLabelProvider(org.netxms.ui.eclipse.filemanager.views.helpers.AgentFileLabelProvider) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 4 with SortableTreeViewer

use of org.netxms.ui.eclipse.widgets.SortableTreeViewer 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)

Example 5 with SortableTreeViewer

use of org.netxms.ui.eclipse.widgets.SortableTreeViewer in project netxms by netxms.

the class SummaryTableItemComparator method compare.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
	 */
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
    // $NON-NLS-1$
    final int column = (Integer) ((SortableTreeViewer) viewer).getTree().getSortColumn().getData("ID");
    final DataType format = (column < formats.length) ? formats[column] : DataType.STRING;
    final String value1 = getCellValue((TableRow) e1, column);
    final String value2 = getCellValue((TableRow) e2, column);
    int result;
    switch(format) {
        case INT32:
            result = safeParseInt(value1) - safeParseInt(value2);
            break;
        case UINT32:
        case COUNTER32:
        case INT64:
        case UINT64:
        case COUNTER64:
            result = Long.signum(safeParseLong(value1) - safeParseLong(value2));
            break;
        case FLOAT:
            result = (int) Math.signum(safeParseDouble(value1) - safeParseDouble(value2));
            break;
        default:
            result = value1.compareToIgnoreCase(value2);
            break;
    }
    return (((SortableTreeViewer) viewer).getTree().getSortDirection() == SWT.UP) ? result : -result;
}
Also used : SortableTreeViewer(org.netxms.ui.eclipse.widgets.SortableTreeViewer) DataType(org.netxms.client.constants.DataType)

Aggregations

SortableTreeViewer (org.netxms.ui.eclipse.widgets.SortableTreeViewer)8 DisposeEvent (org.eclipse.swt.events.DisposeEvent)4 DisposeListener (org.eclipse.swt.events.DisposeListener)4 Composite (org.eclipse.swt.widgets.Composite)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 FormAttachment (org.eclipse.swt.layout.FormAttachment)2 FormData (org.eclipse.swt.layout.FormData)2 FormLayout (org.eclipse.swt.layout.FormLayout)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Node (org.netxms.client.objects.Node)2 FilterText (org.netxms.ui.eclipse.widgets.FilterText)2 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)2 Action (org.eclipse.jface.action.Action)1 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1