Search in sources :

Example 16 with RowData

use of org.eclipse.swt.layout.RowData in project netxms by netxms.

the class MapSeedNodes method createContents.

/* (non-Javadoc)
    * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
    */
@Override
protected Control createContents(Composite parent) {
    Composite dialogArea = new Composite(parent, SWT.NONE);
    object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
    if (object == null || !(object instanceof NetworkMap))
        return dialogArea;
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    viewer = new TableViewer(dialogArea, SWT.BORDER);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LabelProvider() {

        /* (non-Javadoc)
          * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
          */
        @Override
        public String getText(Object element) {
            return ((AbstractObject) element).getObjectName();
        }
    });
    NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    seedNodes = new HashSet<AbstractObject>(session.findMultipleObjects(((NetworkMap) object).getSeedObjectIds(), false));
    viewer.setInput(seedNodes);
    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.pack = false;
    buttonLayout.marginWidth = 0;
    buttonLayout.marginRight = 0;
    buttons.setLayout(buttonLayout);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.RIGHT;
    buttons.setLayoutData(gridData);
    addButton = new Button(buttons, SWT.PUSH);
    addButton.setText("Add...");
    RowData rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    addButton.setLayoutData(rd);
    addButton.addSelectionListener(new SelectionListener() {

        /* (non-Javadoc)
          * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
          */
        @Override
        public void widgetSelected(SelectionEvent e) {
            final ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
            dlg.enableMultiSelection(true);
            if (dlg.open() == Window.OK) {
                List<AbstractObject> selected = dlg.getSelectedObjects();
                if (selected.size() > 0) {
                    seedNodes.addAll(selected);
                    viewer.setInput(seedNodes);
                    isModified = true;
                }
            }
        }

        /* (non-Javadoc)
          * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
          */
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    deleteButton = new Button(buttons, SWT.PUSH);
    deleteButton.setText("Delete");
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    deleteButton.setLayoutData(rd);
    deleteButton.addSelectionListener(new SelectionListener() {

        /* (non-Javadoc)
          * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
          */
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            if (selection.size() > 0) {
                seedNodes.removeAll(selection.toList());
                viewer.setInput(seedNodes);
                isModified = true;
            }
        }

        /* (non-Javadoc)
          * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
          */
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    return dialogArea;
}
Also used : NXCSession(org.netxms.client.NXCSession) Composite(org.eclipse.swt.widgets.Composite) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) AbstractObject(org.netxms.client.objects.AbstractObject) RowLayout(org.eclipse.swt.layout.RowLayout) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AbstractObject(org.netxms.client.objects.AbstractObject) ArrayList(java.util.ArrayList) List(java.util.List) TableViewer(org.eclipse.jface.viewers.TableViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider) NetworkMap(org.netxms.client.objects.NetworkMap) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 17 with RowData

use of org.eclipse.swt.layout.RowData in project netxms by netxms.

the class TrustedNodes method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    Composite dialogArea = new Composite(parent, SWT.NONE);
    object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    final String[] columnNames = { Messages.get().TrustedNodes_Node };
    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.setLabelProvider(new WorkbenchLabelProvider());
    viewer.setComparator(new ObjectLabelComparator((ILabelProvider) viewer.getLabelProvider()));
    AbstractObject[] nodes = object.getTrustedNodes();
    for (int i = 0; i < nodes.length; i++) {
        if (nodes[i] != null)
            trustedNodes.put(nodes[i].getObjectId(), nodes[i]);
    }
    viewer.setInput(trustedNodes.values().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.pack = false;
    buttonLayout.marginWidth = 0;
    buttons.setLayout(buttonLayout);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.RIGHT;
    buttons.setLayoutData(gridData);
    addButton = new Button(buttons, SWT.PUSH);
    addButton.setText(Messages.get().TrustedNodes_Add);
    addButton.addSelectionListener(new SelectionListener() {

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(true));
            if (dlg.open() == Window.OK) {
                AbstractObject[] nodes = dlg.getSelectedObjects(AbstractNode.class);
                for (int i = 0; i < nodes.length; i++) trustedNodes.put(nodes[i].getObjectId(), nodes[i]);
                viewer.setInput(trustedNodes.values().toArray());
                isModified = true;
            }
        }
    });
    RowData rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    addButton.setLayoutData(rd);
    deleteButton = new Button(buttons, SWT.PUSH);
    deleteButton.setText(Messages.get().TrustedNodes_Delete);
    deleteButton.addSelectionListener(new SelectionListener() {

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

        @SuppressWarnings("unchecked")
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            Iterator<AbstractObject> it = selection.iterator();
            if (it.hasNext()) {
                while (it.hasNext()) {
                    AbstractObject object = it.next();
                    trustedNodes.remove(object.getObjectId());
                }
                viewer.setInput(trustedNodes.values().toArray());
                isModified = true;
            }
        }
    });
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    deleteButton.setLayoutData(rd);
    return dialogArea;
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) AbstractNode(org.netxms.client.objects.AbstractNode) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) Composite(org.eclipse.swt.widgets.Composite) ObjectLabelComparator(org.netxms.ui.eclipse.tools.ObjectLabelComparator) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) AbstractObject(org.netxms.client.objects.AbstractObject) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 18 with RowData

use of org.eclipse.swt.layout.RowData in project netxms by netxms.

the class Dashboards method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    Composite dialogArea = new Composite(parent, SWT.NONE);
    object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    final String[] columnNames = { Messages.get().Dashboards_Dashboard };
    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.setLabelProvider(new WorkbenchLabelProvider());
    viewer.setComparator(new ObjectLabelComparator((ILabelProvider) viewer.getLabelProvider()));
    for (AbstractObject d : object.getDashboards(false)) dashboards.put(d.getObjectId(), d);
    viewer.setInput(dashboards.values().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.pack = false;
    buttonLayout.marginWidth = 0;
    buttons.setLayout(buttonLayout);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.RIGHT;
    buttons.setLayoutData(gridData);
    addButton = new Button(buttons, SWT.PUSH);
    addButton.setText(Messages.get().TrustedNodes_Add);
    addButton.addSelectionListener(new SelectionListener() {

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createDashboardSelectionFilter());
            dlg.showFilterToolTip(false);
            if (dlg.open() == Window.OK) {
                AbstractObject[] d = dlg.getSelectedObjects(Dashboard.class);
                for (int i = 0; i < d.length; i++) dashboards.put(d[i].getObjectId(), d[i]);
                viewer.setInput(dashboards.values().toArray());
                isModified = true;
            }
        }
    });
    RowData rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    addButton.setLayoutData(rd);
    deleteButton = new Button(buttons, SWT.PUSH);
    deleteButton.setText(Messages.get().TrustedNodes_Delete);
    deleteButton.addSelectionListener(new SelectionListener() {

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

        @SuppressWarnings("unchecked")
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            Iterator<AbstractObject> it = selection.iterator();
            if (it.hasNext()) {
                while (it.hasNext()) {
                    AbstractObject object = it.next();
                    dashboards.remove(object.getObjectId());
                }
                viewer.setInput(dashboards.values().toArray());
                isModified = true;
            }
        }
    });
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    deleteButton.setLayoutData(rd);
    return dialogArea;
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) Composite(org.eclipse.swt.widgets.Composite) ObjectLabelComparator(org.netxms.ui.eclipse.tools.ObjectLabelComparator) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) Dashboard(org.netxms.client.objects.Dashboard) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) AbstractObject(org.netxms.client.objects.AbstractObject) RowLayout(org.eclipse.swt.layout.RowLayout) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 19 with RowData

use of org.eclipse.swt.layout.RowData in project netxms by netxms.

the class DataSources method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    config = (ChartConfig) getElement().getAdapter(ChartConfig.class);
    if (config instanceof GraphSettings)
        graphIsTemplate = ((GraphSettings) config).isTemplate();
    Composite dialogArea = new Composite(parent, SWT.NONE);
    dciList = new ArrayList<ChartDciConfig>();
    for (ChartDciConfig dci : config.getDciList()) dciList.add(new ChartDciConfig(dci));
    labelProvider = new DciListLabelProvider(dciList);
    labelProvider.resolveDciNames(dciList);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.numColumns = 2;
    dialogArea.setLayout(layout);
    final String[] columnNames = { Messages.get().DataSources_ColPosition, Messages.get().DataSources_ColNode, Messages.get().DataSources_ColParameter, Messages.get().DataSources_ColLabel, Messages.get().DataSources_ColColor };
    final int[] columnWidths = { 40, 130, 200, 150, 50 };
    viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(labelProvider);
    viewer.disableSorting();
    viewer.setInput(dciList.toArray());
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.heightHint = 0;
    gridData.horizontalSpan = 2;
    viewer.getControl().setLayoutData(gridData);
    /* buttons on left side */
    Composite leftButtons = new Composite(dialogArea, SWT.NONE);
    RowLayout buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginWidth = 0;
    buttonLayout.marginLeft = 0;
    leftButtons.setLayout(buttonLayout);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.LEFT;
    leftButtons.setLayoutData(gridData);
    upButton = new Button(leftButtons, SWT.PUSH);
    upButton.setText(Messages.get().DataSources_Up);
    RowData rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    upButton.setLayoutData(rd);
    upButton.addSelectionListener(new SelectionListener() {

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveUp();
        }
    });
    upButton.setEnabled(false);
    downButton = new Button(leftButtons, SWT.PUSH);
    downButton.setText(Messages.get().DataSources_Down);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    downButton.setLayoutData(rd);
    downButton.addSelectionListener(new SelectionListener() {

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveDown();
        }
    });
    downButton.setEnabled(false);
    /* buttons on right side */
    Composite rightButtons = new Composite(dialogArea, SWT.NONE);
    buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginWidth = 0;
    buttonLayout.marginRight = 0;
    rightButtons.setLayout(buttonLayout);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.RIGHT;
    rightButtons.setLayoutData(gridData);
    addButton = new Button(rightButtons, SWT.PUSH);
    addButton.setText(Messages.get().DataSources_Add);
    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) {
            addItem();
        }
    });
    editButton = new Button(rightButtons, SWT.PUSH);
    editButton.setText(Messages.get().DataSources_Modify);
    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) {
            editItem();
        }
    });
    editButton.setEnabled(false);
    deleteButton = new Button(rightButtons, SWT.PUSH);
    deleteButton.setText(Messages.get().DataSources_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) {
            deleteItems();
        }
    });
    deleteButton.setEnabled(false);
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            editButton.notifyListeners(SWT.Selection, new Event());
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            editButton.setEnabled(selection.size() == 1);
            deleteButton.setEnabled(selection.size() > 0);
            upButton.setEnabled(selection.size() == 1);
            downButton.setEnabled(selection.size() == 1);
        }
    });
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ChartDciConfig(org.netxms.client.datacollection.ChartDciConfig) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) GraphSettings(org.netxms.client.datacollection.GraphSettings) 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) DciListLabelProvider(org.netxms.ui.eclipse.perfview.propertypages.helpers.DciListLabelProvider) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 20 with RowData

use of org.eclipse.swt.layout.RowData in project netxms by netxms.

the class AccessControl method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    objectTool = (ObjectToolDetails) getElement().getAdapter(ObjectToolDetails.class);
    // Build internal copy of access list
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    for (Long uid : objectTool.getAccessList()) {
        AbstractUserObject o = session.findUserDBObjectById(uid);
        if (o != null)
            acl.add(o);
    }
    Composite dialogArea = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.INNER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    Label label = new Label(dialogArea, SWT.NONE);
    label.setText(Messages.get().AccessControl_Label);
    viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new WorkbenchLabelProvider());
    viewer.setComparator(new ObjectLabelComparator((ILabelProvider) viewer.getLabelProvider()));
    viewer.getTable().setSortDirection(SWT.UP);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.heightHint = 300;
    viewer.getTable().setLayoutData(gd);
    viewer.setInput(acl.toArray());
    Composite buttons = new Composite(dialogArea, SWT.NONE);
    RowLayout buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginWidth = 0;
    buttons.setLayout(buttonLayout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.RIGHT;
    gd.verticalIndent = WidgetHelper.OUTER_SPACING - WidgetHelper.INNER_SPACING;
    buttons.setLayoutData(gd);
    buttonAdd = new Button(buttons, SWT.PUSH);
    buttonAdd.setText(Messages.get().AccessControl_Add);
    buttonAdd.addSelectionListener(new SelectionListener() {

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

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

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            removeUsers();
        }
    });
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    buttonRemove.setLayoutData(rd);
    return dialogArea;
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) NXCSession(org.netxms.client.NXCSession) Composite(org.eclipse.swt.widgets.Composite) ObjectLabelComparator(org.netxms.ui.eclipse.tools.ObjectLabelComparator) AbstractUserObject(org.netxms.client.users.AbstractUserObject) Label(org.eclipse.swt.widgets.Label) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

RowData (org.eclipse.swt.layout.RowData)55 RowLayout (org.eclipse.swt.layout.RowLayout)52 Composite (org.eclipse.swt.widgets.Composite)48 Button (org.eclipse.swt.widgets.Button)45 GridData (org.eclipse.swt.layout.GridData)44 SelectionEvent (org.eclipse.swt.events.SelectionEvent)43 GridLayout (org.eclipse.swt.layout.GridLayout)40 SelectionListener (org.eclipse.swt.events.SelectionListener)33 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)26 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)26 Label (org.eclipse.swt.widgets.Label)26 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)25 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)25 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)21 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)21 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)20 Event (org.eclipse.swt.widgets.Event)15 TableViewer (org.eclipse.jface.viewers.TableViewer)12 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 Text (org.eclipse.swt.widgets.Text)11