Search in sources :

Example 16 with ObjectSelectionDialog

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

the class EmbeddedDashboard method addDashboard.

/**
 * Add dashboard to list
 */
protected void addDashboard() {
    ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createDashboardSelectionFilter());
    if (dlg.open() == Window.OK) {
        dashboardObjects.addAll(Arrays.asList(dlg.getSelectedObjects(Dashboard.class)));
        viewer.setInput(dashboardObjects.toArray());
    }
}
Also used : ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog)

Example 17 with ObjectSelectionDialog

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

the class MapLinkGeneral method addObject.

/**
 * Add object to status source list
 */
private void addObject() {
    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) {
            for (AbstractObject obj : objects) {
                object.addStatusObject(obj.getObjectId());
                // $NON-NLS-1$ //$NON-NLS-2$
                list.add((obj != null) ? obj.getObjectName() : ("<" + Long.toString(obj.getObjectId()) + ">"));
            }
        }
    }
}
Also used : ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) AbstractObject(org.netxms.client.objects.AbstractObject)

Example 18 with ObjectSelectionDialog

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

the class ShowIPRouteTo method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
@Override
public void run(IAction action) {
    if (node == null)
        return;
    ObjectSelectionDialog dlg = new ObjectSelectionDialog(window.getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
    if (dlg.open() != Window.OK)
        return;
    AbstractObject[] selection = dlg.getSelectedObjects(Node.class);
    if (selection.length == 0) {
        MessageDialogHelper.openError(window.getShell(), Messages.get().ShowIPRoute_Error, Messages.get().ShowIPRoute_InvalidTarget);
        return;
    }
    try {
        // $NON-NLS-1$
        window.getActivePage().showView(IPRouteMap.ID, Long.toString(node.getObjectId()) + "&" + Long.toString(selection[0].getObjectId()), IWorkbenchPage.VIEW_ACTIVATE);
    } catch (PartInitException e) {
        MessageDialogHelper.openError(window.getShell(), Messages.get().ShowIPRoute_Error, String.format(Messages.get().ShowIPRoute_ErrorOpenView, e.getLocalizedMessage()));
    }
}
Also used : ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) AbstractObject(org.netxms.client.objects.AbstractObject) PartInitException(org.eclipse.ui.PartInitException)

Example 19 with ObjectSelectionDialog

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

the class ObjectBrowser method moveObject.

/**
 * Move selected objects to another container
 */
private void moveObject(SubtreeType subtree) {
    if (!isValidSelectionForMove(subtree))
        return;
    List<Object> currentObject = new ArrayList<Object>();
    List<Object> parentObject = new ArrayList<Object>();
    TreeItem[] selection = objectTree.getTreeControl().getSelection();
    for (int i = 0; i < selection.length; i++) {
        currentObject.add(selection[i].getData());
        parentObject.add(selection[i].getParentItem().getData());
    }
    Set<Integer> filter;
    switch(subtree) {
        case INFRASTRUCTURE:
            filter = ObjectSelectionDialog.createContainerSelectionFilter();
            break;
        case TEMPLATES:
            filter = ObjectSelectionDialog.createTemplateGroupSelectionFilter();
            break;
        case BUSINESS_SERVICES:
            filter = ObjectSelectionDialog.createBusinessServiceSelectionFilter();
            break;
        case DASHBOARDS:
            filter = ObjectSelectionDialog.createDashboardGroupSelectionFilter();
            break;
        case MAPS:
            filter = ObjectSelectionDialog.createNetworkMapGroupsSelectionFilter();
            break;
        case POLICIES:
            filter = ObjectSelectionDialog.createPolicyGroupSelectionFilter();
            break;
        default:
            filter = null;
            break;
    }
    ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, filter, currentObject);
    dlg.enableMultiSelection(false);
    if (dlg.open() == Window.OK) {
        final AbstractObject target = dlg.getSelectedObjects().get(0);
        for (int i = 0; i < selection.length; i++) {
            performObjectMove(target, parentObject.get(i), currentObject.get(i), true);
        }
    }
}
Also used : ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) TreeItem(org.eclipse.swt.widgets.TreeItem) AbstractObject(org.netxms.client.objects.AbstractObject) ArrayList(java.util.ArrayList) AbstractObject(org.netxms.client.objects.AbstractObject)

Example 20 with ObjectSelectionDialog

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

the class TunnelManager method bindTunnel.

/**
 * Bind tunnel to node
 */
private void bindTunnel() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() != 1)
        return;
    final AgentTunnel tunnel = (AgentTunnel) selection.getFirstElement();
    if (tunnel.isBound())
        return;
    ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
    if (dlg.open() != Window.OK)
        return;
    final long nodeId = dlg.getSelectedObjects().get(0).getObjectId();
    final NXCSession session = ConsoleSharedData.getSession();
    new ConsoleJob("Bind tunnels", this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.bindAgentTunnel(tunnel.getId(), nodeId);
            final List<AgentTunnel> tunnels = session.getAgentTunnels();
            runInUIThread(new Runnable() {

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

        @Override
        protected String getErrorMessage() {
            return "Cannot bind tunnel";
        }
    }.start();
}
Also used : AgentTunnel(org.netxms.client.AgentTunnel) ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) 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