Search in sources :

Example 6 with ObjectSelectionDialog

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

the class PredefinedMap method addObjectToMap.

/**
 * Add object to map
 */
private void addObjectToMap() {
    ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, null);
    if (dlg.open() != Window.OK)
        return;
    addObjectsFromList(dlg.getSelectedObjects(), null);
}
Also used : ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog)

Example 7 with ObjectSelectionDialog

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

the class ObjectSelector method selectionButtonHandler.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.widgets.AbstractSelector#selectionButtonHandler()
	 */
@Override
protected void selectionButtonHandler() {
    ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, classFilter);
    dlg.enableMultiSelection(false);
    if (dlg.open() == Window.OK) {
        AbstractObject[] objects = dlg.getSelectedObjects(objectClass);
        if (objects.length > 0) {
            objectId = objects[0].getObjectId();
            setText(objects[0].getObjectName());
        } else {
            objectId = 0;
            setText(emptySelectionName);
        }
        fireModifyListeners();
    }
}
Also used : ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) AbstractObject(org.netxms.client.objects.AbstractObject)

Example 8 with ObjectSelectionDialog

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

the class ApplyPolicy method run.

@Override
public void run(IAction action) {
    final ObjectSelectionDialog dlg = new ObjectSelectionDialog(shell, null, ObjectSelectionDialog.createPolicySelectionFilter());
    dlg.showFilterToolTip(false);
    if (dlg.open() == Window.OK) {
        final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
        new ConsoleJob("Deploy agent policy", null, Activator.PLUGIN_ID, null) {

            @Override
            protected void runInternal(IProgressMonitor monitor) throws Exception {
                for (int i = 0; i < selectedObjects.size(); i++) {
                    for (int n = 0; n < dlg.getSelectedObjects().size(); n++) {
                        session.deployAgentPolicy(dlg.getSelectedObjects().get(n).getObjectId(), selectedObjects.get(i).getObjectId());
                    }
                }
            }

            @Override
            protected String getErrorMessage() {
                return "Cannot deploy agent policy";
            }
        }.start();
    }
}
Also used : ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 9 with ObjectSelectionDialog

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

the class BindObjectTo method run.

/**
 * @see IActionDelegate#run(IAction)
 */
public void run(IAction action) {
    final ObjectSelectionDialog dlg = new ObjectSelectionDialog(shell, null, ObjectSelectionDialog.createContainerSelectionFilter());
    dlg.showFilterToolTip(false);
    if (dlg.open() == Window.OK) {
        final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
        final Long[] childIdList = objects.toArray(new Long[objects.size()]);
        new ConsoleJob(Messages.get().BindObject_JobTitle, viewPart, Activator.PLUGIN_ID, null) {

            @Override
            protected String getErrorMessage() {
                return Messages.get().BindObject_JobError;
            }

            @Override
            protected void runInternal(IProgressMonitor monitor) throws Exception {
                List<AbstractObject> objects = dlg.getSelectedObjects();
                for (AbstractObject parent : objects) {
                    for (Long childId : childIdList) {
                        session.bindObject(parent.getObjectId(), childId);
                    }
                }
            }
        }.start();
    }
}
Also used : ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) AbstractObject(org.netxms.client.objects.AbstractObject) List(java.util.List) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 10 with ObjectSelectionDialog

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

the class WorldMap method placeObject.

/**
 * Place object on map at mouse position
 */
private void placeObject() {
    final ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(true));
    if (dlg.open() == Window.OK) {
        final NXCObjectModificationData md = new NXCObjectModificationData(dlg.getSelectedObjects().get(0).getObjectId());
        md.setGeolocation(map.getLocationAtPoint(map.getCurrentPoint()));
        final NXCSession session = ConsoleSharedData.getSession();
        new ConsoleJob(Messages.get().WorldMap_JobTitle, this, Activator.PLUGIN_ID, null) {

            @Override
            protected void runInternal(IProgressMonitor monitor) throws Exception {
                session.modifyObject(md);
            }

            @Override
            protected String getErrorMessage() {
                return Messages.get().WorldMap_JobError;
            }
        }.start();
    }
}
Also used : ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

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