Search in sources :

Example 1 with DciList

use of org.netxms.ui.eclipse.datacollection.widgets.DciList in project netxms by netxms.

the class SelectDciDialog method createDialogArea.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createDialogArea(Composite parent) {
    IDialogSettings settings = Activator.getDefault().getDialogSettings();
    Composite dialogArea = (Composite) super.createDialogArea(parent);
    dialogArea.setLayout(new FillLayout());
    if (fixedNode == 0) {
        splitter = new SashForm(dialogArea, SWT.HORIZONTAL);
        objectTree = new ObjectTree(splitter, SWT.BORDER, ObjectTree.NONE, null, ObjectSelectionDialog.createNodeSelectionFilter(true), true, false);
        // $NON-NLS-1$
        String text = settings.get("SelectDciDialog.Filter");
        if (text != null)
            objectTree.setFilter(text);
    }
    dciList = new DciList(null, (fixedNode == 0) ? splitter : dialogArea, SWT.BORDER, null, "SelectDciDialog.dciList", dcObjectType, allowSingleSelection ? SWT.NONE : SWT.MULTI, // $NON-NLS-1$
    allowNoValueObjects);
    dciList.setDcObjectType(dcObjectType);
    dciList.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            okPressed();
        }
    });
    if (fixedNode == 0) {
        try {
            int[] weights = new int[2];
            // $NON-NLS-1$
            weights[0] = settings.getInt("SelectDciDialog.weight1");
            // $NON-NLS-1$
            weights[1] = settings.getInt("SelectDciDialog.weight2");
            splitter.setWeights(weights);
        } catch (NumberFormatException e) {
            splitter.setWeights(new int[] { 30, 70 });
        }
        objectTree.getTreeViewer().addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                AbstractObject object = objectTree.getFirstSelectedObject2();
                if ((object != null) && ((object instanceof AbstractNode) || (object instanceof MobileDevice) || (object instanceof Cluster) || (allowTemplateItems && (object instanceof Template) || (object instanceof Sensor)))) {
                    dciList.setNode(object);
                } else {
                    dciList.setNode(null);
                }
            }
        });
        objectTree.setFocus();
    } else {
        dciList.setNode(((NXCSession) ConsoleSharedData.getSession()).findObjectById(fixedNode));
    }
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) AbstractNode(org.netxms.client.objects.AbstractNode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Cluster(org.netxms.client.objects.Cluster) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FillLayout(org.eclipse.swt.layout.FillLayout) DciList(org.netxms.ui.eclipse.datacollection.widgets.DciList) Template(org.netxms.client.objects.Template) SashForm(org.eclipse.swt.custom.SashForm) MobileDevice(org.netxms.client.objects.MobileDevice) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) ObjectTree(org.netxms.ui.eclipse.objectbrowser.widgets.ObjectTree) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) AbstractObject(org.netxms.client.objects.AbstractObject) Sensor(org.netxms.client.objects.Sensor)

Example 2 with DciList

use of org.netxms.ui.eclipse.datacollection.widgets.DciList in project netxms by netxms.

the class SelectNodeDciDialog 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);
    dialogArea.setLayout(new FillLayout());
    // $NON-NLS-1$
    dciList = new DciList(null, dialogArea, SWT.BORDER, null, "SelectNodeDciDialog.dciList", dcObjectType, SWT.SINGLE, false);
    dciList.setDcObjectType(dcObjectType);
    dciList.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            okPressed();
        }
    });
    dciList.setNode(((NXCSession) ConsoleSharedData.getSession()).findObjectById(nodeId));
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FillLayout(org.eclipse.swt.layout.FillLayout) DciList(org.netxms.ui.eclipse.datacollection.widgets.DciList)

Aggregations

DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)2 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 DciList (org.netxms.ui.eclipse.datacollection.widgets.DciList)2 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 SashForm (org.eclipse.swt.custom.SashForm)1 AbstractNode (org.netxms.client.objects.AbstractNode)1 AbstractObject (org.netxms.client.objects.AbstractObject)1 Cluster (org.netxms.client.objects.Cluster)1 MobileDevice (org.netxms.client.objects.MobileDevice)1 Sensor (org.netxms.client.objects.Sensor)1 Template (org.netxms.client.objects.Template)1 ObjectTree (org.netxms.ui.eclipse.objectbrowser.widgets.ObjectTree)1