Search in sources :

Example 21 with Node

use of org.netxms.client.objects.Node in project netxms by netxms.

the class ServiceComponentsElement method addServiceComponents.

/**
 * Add parent services for given object
 *
 * @param object
 */
private void addServiceComponents(AbstractObject object, long parentElementId) {
    Iterator<Long> it = object.getChildren();
    while (it.hasNext()) {
        long objectId = it.next();
        AbstractObject child = session.findObjectById(objectId);
        if ((child != null) && ((child instanceof Container) || (child instanceof Cluster) || (child instanceof Node) || (child instanceof Condition))) {
            long elementId = mapPage.createElementId();
            mapPage.addElement(new NetworkMapObject(elementId, objectId));
            mapPage.addLink(new NetworkMapLink(NetworkMapLink.NORMAL, parentElementId, elementId));
            addServiceComponents(child, elementId);
        }
    }
}
Also used : Condition(org.netxms.client.objects.Condition) Container(org.netxms.client.objects.Container) AbstractObject(org.netxms.client.objects.AbstractObject) Node(org.netxms.client.objects.Node) Cluster(org.netxms.client.objects.Cluster) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 22 with Node

use of org.netxms.client.objects.Node in project netxms by netxms.

the class SoftwareInventory method setRootObjectId.

/**
 * @param rootObjectId the rootObjectId to set
 */
public void setRootObjectId(long rootObjectId) {
    this.rootObjectId = rootObjectId;
    AbstractObject object = ((NXCSession) ConsoleSharedData.getSession()).findObjectById(rootObjectId);
    if (object instanceof Node) {
        if (!(viewer instanceof SortableTableViewer)) {
            viewer.getControl().dispose();
            createTableViewer();
        }
    } else {
        if (!(viewer instanceof SortableTreeViewer)) {
            viewer.getControl().dispose();
            createTreeViewer();
        }
    }
}
Also used : SortableTreeViewer(org.netxms.ui.eclipse.widgets.SortableTreeViewer) NXCSession(org.netxms.client.NXCSession) AbstractObject(org.netxms.client.objects.AbstractObject) AbstractNode(org.netxms.client.objects.AbstractNode) SoftwareInventoryNode(org.netxms.ui.eclipse.objectview.widgets.helpers.SoftwareInventoryNode) Node(org.netxms.client.objects.Node) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer)

Example 23 with Node

use of org.netxms.client.objects.Node in project netxms by netxms.

the class UninstallPolicy method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
@Override
public void run(IAction action) {
    // Read custom root objects
    long[] rootObjects = null;
    // $NON-NLS-1$
    Object value = ConsoleSharedData.getProperty("PolicyManager.rootObjects");
    if ((value != null) && (value instanceof long[])) {
        rootObjects = (long[]) value;
    }
    final ObjectSelectionDialog dlg = new ObjectSelectionDialog(shell, rootObjects, ObjectSelectionDialog.createNodeSelectionFilter(false));
    if (dlg.open() == Window.OK) {
        final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
        for (final AgentPolicy policy : currentSelection) {
            new ConsoleJob(String.format(Messages.get().UninstallPolicy_JobName, policy.getObjectName()), null, Activator.PLUGIN_ID, null) {

                @Override
                protected void runInternal(IProgressMonitor monitor) throws Exception {
                    AbstractObject[] nodeList = dlg.getSelectedObjects(Node.class);
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < nodeList.length; i++) {
                        try {
                            session.uninstallAgentPolicy(policy.getObjectId(), nodeList[i].getObjectId());
                        } catch (NXCException e) {
                            if (e.getErrorCode() == CommonRCC.INCOMPATIBLE_OPERATION || e.getErrorCode() == CommonRCC.INTERNAL_ERROR || e.getErrorCode() == CommonRCC.ACCESS_DENIED || e.getErrorCode() == CommonRCC.INVALID_OBJECT_ID) {
                                if (sb.length() == 0)
                                    sb.append("Could not apply policy to the node(s):\n");
                                sb.append(nodeList[i].getObjectName());
                                sb.append(" - ");
                                sb.append(e.getLocalizedMessage());
                                sb.append("\n");
                            } else {
                                throw (e);
                            }
                        }
                    }
                    if (sb.length() != 0) {
                        final String error = sb.toString();
                        runInUIThread(new Runnable() {

                            @Override
                            public void run() {
                                MessageDialog.openError(shell, "Error", error);
                            }
                        });
                    }
                }

                @Override
                protected String getErrorMessage() {
                    return String.format(Messages.get().UninstallPolicy_JobError, policy.getObjectName());
                }
            }.start();
        }
    }
}
Also used : NXCSession(org.netxms.client.NXCSession) Node(org.netxms.client.objects.Node) NXCException(org.netxms.client.NXCException) NXCException(org.netxms.client.NXCException) ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AgentPolicy(org.netxms.client.objects.AgentPolicy) AbstractObject(org.netxms.client.objects.AbstractObject) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Aggregations

Node (org.netxms.client.objects.Node)23 AbstractObject (org.netxms.client.objects.AbstractObject)19 Container (org.netxms.client.objects.Container)7 NXCSession (org.netxms.client.NXCSession)6 Cluster (org.netxms.client.objects.Cluster)6 Condition (org.netxms.client.objects.Condition)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 Interface (org.netxms.client.objects.Interface)5 NetworkMapLink (org.netxms.client.maps.NetworkMapLink)4 AccessPoint (org.netxms.client.objects.AccessPoint)4 ServiceRoot (org.netxms.client.objects.ServiceRoot)4 Subnet (org.netxms.client.objects.Subnet)4 ArrayList (java.util.ArrayList)3 NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)3 AgentPolicy (org.netxms.client.objects.AgentPolicy)3 EntireNetwork (org.netxms.client.objects.EntireNetwork)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Shell (org.eclipse.swt.widgets.Shell)2 IViewPart (org.eclipse.ui.IViewPart)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2