Search in sources :

Example 1 with StringComparator

use of org.netxms.ui.eclipse.tools.StringComparator in project netxms by netxms.

the class CustomSchedule method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    Composite dialogArea = (Composite) super.createContents(parent);
    dci = editor.getObject();
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    final String[] columnNames = { Messages.get().CustomSchedule_Schedule };
    final int[] columnWidths = { 300 };
    viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setComparator(new StringComparator());
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection != null) {
                editButton.setEnabled(selection.size() == 1);
                deleteButton.setEnabled(selection.size() > 0);
            }
        }
    });
    schedules = new HashSet<String>();
    schedules.addAll(dci.getSchedules());
    viewer.setInput(schedules.toArray());
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.heightHint = 0;
    viewer.getControl().setLayoutData(gridData);
    Composite buttons = new Composite(dialogArea, SWT.NONE);
    RowLayout buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.marginBottom = 0;
    buttonLayout.marginTop = 0;
    buttonLayout.marginLeft = 0;
    buttonLayout.marginRight = 0;
    buttonLayout.spacing = WidgetHelper.OUTER_SPACING;
    buttonLayout.fill = true;
    buttonLayout.pack = false;
    buttons.setLayout(buttonLayout);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.RIGHT;
    buttons.setLayoutData(gridData);
    addButton = new Button(buttons, SWT.PUSH);
    addButton.setText(Messages.get().CustomSchedule_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) {
            addSchedule();
        }
    });
    editButton = new Button(buttons, SWT.PUSH);
    editButton.setText(Messages.get().CustomSchedule_Edit);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    editButton.setLayoutData(rd);
    editButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            editSchedule();
        }
    });
    deleteButton = new Button(buttons, SWT.PUSH);
    deleteButton.setText(Messages.get().CustomSchedule_Delete);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    deleteButton.setLayoutData(rd);
    deleteButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            deleteSchedules();
        }
    });
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            editButton.notifyListeners(SWT.Selection, new Event());
        }
    });
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StringComparator(org.netxms.ui.eclipse.tools.StringComparator) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 2 with StringComparator

use of org.netxms.ui.eclipse.tools.StringComparator in project netxms by netxms.

the class WinPerfCounterSelectionDialog 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.numColumns = 2;
    layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
    layout.verticalSpacing = WidgetHelper.INNER_SPACING;
    dialogArea.setLayout(layout);
    new Label(dialogArea, SWT.NONE).setText(Messages.get().WinPerfCounterSelectionDialog_ObjectsAndCounters);
    new Label(dialogArea, SWT.NONE).setText(Messages.get().WinPerfCounterSelectionDialog_Instances);
    objectTree = new TreeViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.heightHint = 400;
    gd.widthHint = 350;
    objectTree.getControl().setLayoutData(gd);
    objectTree.setContentProvider(new WinPerfObjectTreeContentProvider());
    objectTree.setLabelProvider(new WinPerfObjectTreeLabelProvider());
    objectTree.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            String s1 = (e1 instanceof WinPerfCounter) ? ((WinPerfCounter) e1).getName() : ((WinPerfObject) e1).getName();
            String s2 = (e2 instanceof WinPerfCounter) ? ((WinPerfCounter) e2).getName() : ((WinPerfObject) e2).getName();
            return s1.compareToIgnoreCase(s2);
        }
    });
    objectTree.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            onObjectSelection();
        }
    });
    instanceList = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.widthHint = 350;
    instanceList.getControl().setLayoutData(gd);
    instanceList.setContentProvider(new ArrayContentProvider());
    instanceList.setLabelProvider(new LabelProvider());
    instanceList.setComparator(new StringComparator());
    fillData();
    return dialogArea;
}
Also used : WinPerfObjectTreeLabelProvider(org.netxms.ui.eclipse.datacollection.dialogs.helpers.WinPerfObjectTreeLabelProvider) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) WinPerfObject(org.netxms.client.datacollection.WinPerfObject) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) StringComparator(org.netxms.ui.eclipse.tools.StringComparator) GridLayout(org.eclipse.swt.layout.GridLayout) WinPerfCounter(org.netxms.client.datacollection.WinPerfCounter) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) WinPerfObject(org.netxms.client.datacollection.WinPerfObject) TableViewer(org.eclipse.jface.viewers.TableViewer) WinPerfObjectTreeLabelProvider(org.netxms.ui.eclipse.datacollection.dialogs.helpers.WinPerfObjectTreeLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) WinPerfObjectTreeContentProvider(org.netxms.ui.eclipse.datacollection.dialogs.helpers.WinPerfObjectTreeContentProvider)

Example 3 with StringComparator

use of org.netxms.ui.eclipse.tools.StringComparator in project netxms by netxms.

the class SnmpCredentials method createSnmpCommunitySection.

/**
 * Create "SNMP Communities" section
 */
private void createSnmpCommunitySection() {
    Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TITLE_BAR);
    section.setText(Messages.get().SnmpConfigurator_SectionCommunities);
    section.setDescription(Messages.get().SnmpConfigurator_SectionCommunitiesDescr);
    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);
    snmpCommunityList = new TableViewer(clientArea, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    toolkit.adapt(snmpCommunityList.getTable());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.verticalSpan = 2;
    gd.heightHint = 150;
    snmpCommunityList.getTable().setLayoutData(gd);
    snmpCommunityList.getTable().setSortDirection(SWT.UP);
    snmpCommunityList.setContentProvider(new ArrayContentProvider());
    snmpCommunityList.setComparator(new StringComparator());
    final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);
    linkAdd.setText(Messages.get().SnmpConfigurator_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) {
            addCommunity();
        }
    });
    final ImageHyperlink linkRemove = toolkit.createImageHyperlink(clientArea, SWT.NONE);
    linkRemove.setText(Messages.get().SnmpConfigurator_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) {
            removeCommunity();
        }
    });
}
Also used : TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) GridLayout(org.eclipse.swt.layout.GridLayout) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Section(org.eclipse.ui.forms.widgets.Section) TableViewer(org.eclipse.jface.viewers.TableViewer) StringComparator(org.netxms.ui.eclipse.tools.StringComparator) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 4 with StringComparator

use of org.netxms.ui.eclipse.tools.StringComparator in project netxms by netxms.

the class SnmpCredentials method createSnmpPortList.

/**
 * Create "Port List" section
 */
private void createSnmpPortList() {
    Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TITLE_BAR);
    section.setText("SNMP Ports");
    section.setDescription("SNMP ports used in the network");
    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);
    snmpPortList = new TableViewer(clientArea, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    toolkit.adapt(snmpPortList.getTable());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.verticalSpan = 2;
    gd.heightHint = 150;
    snmpPortList.getTable().setLayoutData(gd);
    snmpPortList.setContentProvider(new ArrayContentProvider());
    snmpPortList.setComparator(new StringComparator());
    final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);
    linkAdd.setText(Messages.get().SnmpConfigurator_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) {
            addSnmpPort();
        }
    });
    final ImageHyperlink linkRemove = toolkit.createImageHyperlink(clientArea, SWT.NONE);
    linkRemove.setText(Messages.get().SnmpConfigurator_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) {
            removeSnmpPort();
        }
    });
}
Also used : TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) GridLayout(org.eclipse.swt.layout.GridLayout) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Section(org.eclipse.ui.forms.widgets.Section) TableViewer(org.eclipse.jface.viewers.TableViewer) StringComparator(org.netxms.ui.eclipse.tools.StringComparator) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Aggregations

ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)4 GridData (org.eclipse.swt.layout.GridData)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 Composite (org.eclipse.swt.widgets.Composite)4 StringComparator (org.netxms.ui.eclipse.tools.StringComparator)4 TableViewer (org.eclipse.jface.viewers.TableViewer)3 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 HyperlinkAdapter (org.eclipse.ui.forms.events.HyperlinkAdapter)2 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)2 ImageHyperlink (org.eclipse.ui.forms.widgets.ImageHyperlink)2 Section (org.eclipse.ui.forms.widgets.Section)2 TableWrapData (org.eclipse.ui.forms.widgets.TableWrapData)2 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1