Search in sources :

Example 1 with ObjectSelectionDialog

use of org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog in project netxms by netxms.

the class IdMatchingDialog method mapNode.

/**
 * Map node
 *
 * @param data
 */
private void mapNode(ObjectIdMatchingData data) {
    Set<Integer> classFilter;
    switch(data.objectClass) {
        case AbstractObject.OBJECT_NODE:
        case AbstractObject.OBJECT_CLUSTER:
            classFilter = ObjectSelectionDialog.createNodeSelectionFilter(false);
            showFilterToolTip = true;
            break;
        case AbstractObject.OBJECT_CONTAINER:
            classFilter = ObjectSelectionDialog.createContainerSelectionFilter();
            showFilterToolTip = false;
            break;
        case AbstractObject.OBJECT_ZONE:
            classFilter = ObjectSelectionDialog.createZoneSelectionFilter();
            showFilterToolTip = true;
            break;
        case AbstractObject.OBJECT_DASHBOARD:
            classFilter = new HashSet<Integer>(2);
            classFilter.add(AbstractObject.OBJECT_DASHBOARD);
            classFilter.add(AbstractObject.OBJECT_DASHBOARDROOT);
            break;
        default:
            classFilter = null;
            break;
    }
    ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, classFilter);
    dlg.showFilterToolTip(showFilterToolTip);
    if (dlg.open() == Window.OK) {
        AbstractObject object = dlg.getSelectedObjects().get(0);
        if (ImportDashboard.isCompatibleClasses(object.getObjectClass(), data.objectClass)) {
            data.dstId = object.getObjectId();
            data.dstName = object.getObjectName();
            updateDciMapping(data);
            viewer.update(data, null);
        } else {
            MessageDialogHelper.openWarning(getShell(), Messages.get().IdMatchingDialog_Warning, Messages.get().IdMatchingDialog_ClassMismatch);
        }
    }
}
Also used : ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) AbstractObject(org.netxms.client.objects.AbstractObject)

Example 2 with ObjectSelectionDialog

use of org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog in project netxms by netxms.

the class TableColumns method queryColumns.

/**
 * Query columns from agent
 */
private void queryColumns() {
    if (!MessageDialogHelper.openQuestion(getShell(), "Warning", "Current column definition will be replaced by definition provided by agent. Continue?"))
        return;
    AbstractObject object = ConsoleSharedData.getSession().findObjectById(dci.getNodeId());
    if ((editor.getSourceNode() == 0) && ((object instanceof Template) || (object instanceof Cluster))) {
        ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
        if (dlg.open() != Window.OK)
            return;
        object = dlg.getSelectedObjects().get(0);
    }
    updateColumnsFromAgent(dci.getName(), true, object);
}
Also used : ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) AbstractObject(org.netxms.client.objects.AbstractObject) Cluster(org.netxms.client.objects.Cluster) Template(org.netxms.client.objects.Template)

Example 3 with ObjectSelectionDialog

use of org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog in project netxms by netxms.

the class DataCollectionEditor method copyItems.

/**
 * Copy items to another node
 */
private void copyItems(final boolean doMove) {
    final ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createNodeAndTemplateSelectionFilter(true));
    if (dlg.open() != Window.OK)
        return;
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    Iterator<?> it = selection.iterator();
    final long[] dciList = new long[selection.size()];
    for (int i = 0; (i < dciList.length) && it.hasNext(); i++) dciList[i] = ((DataCollectionObject) it.next()).getId();
    new ConsoleJob(Messages.get().DataCollectionEditor_CopyJob_Title + object.getObjectName(), this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            for (AbstractObject o : dlg.getSelectedObjects(AbstractNode.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            for (AbstractObject o : dlg.getSelectedObjects(Template.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            for (AbstractObject o : dlg.getSelectedObjects(Cluster.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            for (AbstractObject o : dlg.getSelectedObjects(MobileDevice.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            for (AbstractObject o : dlg.getSelectedObjects(Sensor.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            if (doMove) {
                for (long id : dciList) dciConfig.deleteObject(id);
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        viewer.setInput(dciConfig.getItems());
                    }
                });
            }
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().DataCollectionEditor_CopyJob_Error + object.getObjectName();
        }
    }.start();
}
Also used : AbstractNode(org.netxms.client.objects.AbstractNode) DataCollectionObject(org.netxms.client.datacollection.DataCollectionObject) Cluster(org.netxms.client.objects.Cluster) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException) NXCException(org.netxms.client.NXCException) Template(org.netxms.client.objects.Template) ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MobileDevice(org.netxms.client.objects.MobileDevice) AbstractObject(org.netxms.client.objects.AbstractObject) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) Sensor(org.netxms.client.objects.Sensor)

Example 4 with ObjectSelectionDialog

use of org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog in project netxms by netxms.

the class PackageManager method deployPackage.

/**
 * Deploy package on managed nodes
 */
private void deployPackage() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() != 1)
        return;
    final PackageInfo pkg = (PackageInfo) selection.getFirstElement();
    ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
    dlg.enableMultiSelection(true);
    if (dlg.open() != Window.OK)
        return;
    final Set<Long> objects = new HashSet<Long>();
    for (AbstractObject o : dlg.getSelectedObjects()) {
        objects.add(o.getObjectId());
    }
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    ConsoleJob job = new ConsoleJob(Messages.get().PackageManager_DeployAgentPackage, null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.deployPackage(pkg.getId(), objects.toArray(new Long[objects.size()]), new PackageDeploymentListener() {

                private PackageDeploymentMonitor monitor = null;

                @Override
                public void statusUpdate(long nodeId, int status, String message) {
                    if (monitor != null)
                        monitor.viewStatusUpdate(nodeId, status, message);
                }

                @Override
                public void deploymentStarted() {
                    final Object sync = new Object();
                    synchronized (sync) {
                        runInUIThread(new Runnable() {

                            @Override
                            public void run() {
                                try {
                                    monitor = (PackageDeploymentMonitor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(PackageDeploymentMonitor.ID, toString(), IWorkbenchPage.VIEW_ACTIVATE);
                                    monitor.setPackageId(pkg.getId());
                                } catch (PartInitException e) {
                                    MessageDialogHelper.openError(getSite().getShell(), Messages.get().PackageManager_Error, Messages.get().PackageManager_ErrorOpenView + e.getLocalizedMessage());
                                }
                                synchronized (sync) {
                                    sync.notify();
                                }
                            }
                        });
                        try {
                            sync.wait();
                        } catch (InterruptedException e) {
                        }
                    }
                }

                @Override
                public void deploymentComplete() {
                    runInUIThread(new Runnable() {

                        @Override
                        public void run() {
                            MessageDialogHelper.openInformation(getSite().getShell(), Messages.get().PackageManager_Information, Messages.get().PackageManager_PkgDepCompleted);
                        }
                    });
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().PackageManager_DepStartError;
        }
    };
    job.setUser(false);
    job.start();
}
Also used : NXCSession(org.netxms.client.NXCSession) PackageInfo(org.netxms.client.packages.PackageInfo) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PackageDeploymentListener(org.netxms.client.packages.PackageDeploymentListener) ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AbstractObject(org.netxms.client.objects.AbstractObject) AbstractObject(org.netxms.client.objects.AbstractObject) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) PartInitException(org.eclipse.ui.PartInitException) HashSet(java.util.HashSet)

Example 5 with ObjectSelectionDialog

use of org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog in project netxms by netxms.

the class ObjectConditionEditor method selectObject.

/**
 * Select object
 */
private void selectObject() {
    ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, null);
    dlg.enableMultiSelection(false);
    if (dlg.open() == Window.OK) {
        AbstractObject[] objects = dlg.getSelectedObjects(AbstractObject.class);
        if (objects.length > 0) {
            objectId = objects[0].getObjectId();
            objectName.setText(objects[0].getObjectName());
            objectName.setImage(labelProvider.getImage(objects[0]));
        } else {
            objectId = 0;
            objectName.setText(EMPTY_SELECTION_TEXT);
            objectName.setImage(null);
        }
    }
}
Also used : ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) AbstractObject(org.netxms.client.objects.AbstractObject)

Aggregations

ObjectSelectionDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog)29 AbstractObject (org.netxms.client.objects.AbstractObject)22 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)13 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)13 NXCSession (org.netxms.client.NXCSession)11 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 List (java.util.List)6 PartInitException (org.eclipse.ui.PartInitException)5 Template (org.netxms.client.objects.Template)5 ArrayList (java.util.ArrayList)3 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 SelectionListener (org.eclipse.swt.events.SelectionListener)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 RowData (org.eclipse.swt.layout.RowData)3 RowLayout (org.eclipse.swt.layout.RowLayout)3 Button (org.eclipse.swt.widgets.Button)3 Composite (org.eclipse.swt.widgets.Composite)3 NXCException (org.netxms.client.NXCException)3