Search in sources :

Example 1 with SubnetComparator

use of org.netxms.ui.eclipse.objectmanager.propertypages.helpers.SubnetComparator in project netxms by netxms.

the class VPNSubnets method createNetworkList.

/**
 * Creates network list
 *
 * @param dialogArea
 * @param viewList viewer to be created and added to view
 * @param data elements that should be added as a content of this viewer
 */
private void createNetworkList(Composite dialogArea, String title, TableViewer viewList, final List<InetAddressEx> data) {
    Group clientArea = new Group(dialogArea, SWT.NONE);
    clientArea.setText(title);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    GridData gd = new GridData();
    clientArea.setLayout(layout);
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    clientArea.setLayoutData(gd);
    viewList = new TableViewer(clientArea, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.verticalSpan = 2;
    gd.heightHint = 100;
    viewList.getTable().setLayoutData(gd);
    viewList.getTable().setSortDirection(SWT.UP);
    viewList.setContentProvider(new ArrayContentProvider());
    viewList.setComparator(new SubnetComparator());
    viewList.setInput(data.toArray());
    final TableViewer list = viewList;
    final ImageHyperlink linkAdd = new ImageHyperlink(clientArea, SWT.NONE);
    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) {
            addTargetAddressListElement(list, data);
        }
    });
    final ImageHyperlink linkRemove = new ImageHyperlink(clientArea, SWT.NONE);
    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) {
            removeTargetAddressListElements(list, data);
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) SubnetComparator(org.netxms.ui.eclipse.objectmanager.propertypages.helpers.SubnetComparator) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Aggregations

ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Group (org.eclipse.swt.widgets.Group)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 SubnetComparator (org.netxms.ui.eclipse.objectmanager.propertypages.helpers.SubnetComparator)1