Search in sources :

Example 11 with Container

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

the class UploadFileToAgent method selectionChanged.

/**
 * @see IActionDelegate#selectionChanged(IAction, ISelection)
 */
@SuppressWarnings("rawtypes")
public void selectionChanged(IAction action, ISelection selection) {
    nodes.clear();
    if (!(selection instanceof IStructuredSelection)) {
        action.setEnabled(false);
        return;
    }
    Iterator it = ((IStructuredSelection) selection).iterator();
    while (it.hasNext()) {
        Object object = it.next();
        if (object instanceof Node) {
            nodes.add(((Node) object).getObjectId());
        } else if ((object instanceof Container) || (object instanceof ServiceRoot) || (object instanceof Subnet) || (object instanceof EntireNetwork)) {
            Set<AbstractObject> set = ((AbstractObject) object).getAllChilds(AbstractObject.OBJECT_NODE);
            for (AbstractObject o : set) nodes.add(o.getObjectId());
        }
    }
    action.setEnabled(nodes.size() > 0);
}
Also used : Container(org.netxms.client.objects.Container) HashSet(java.util.HashSet) Set(java.util.Set) Node(org.netxms.client.objects.Node) AbstractObject(org.netxms.client.objects.AbstractObject) Iterator(java.util.Iterator) AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Subnet(org.netxms.client.objects.Subnet) EntireNetwork(org.netxms.client.objects.EntireNetwork) ServiceRoot(org.netxms.client.objects.ServiceRoot)

Example 12 with Container

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

the class ServiceComponents 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 13 with Container

use of org.netxms.client.objects.Container 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 14 with Container

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

the class BindObject method selectionChanged.

/**
 * @see IActionDelegate#selectionChanged(IAction, ISelection)
 */
public void selectionChanged(IAction action, ISelection selection) {
    if ((selection instanceof IStructuredSelection) && (((IStructuredSelection) selection).size() == 1)) {
        Object obj = ((IStructuredSelection) selection).getFirstElement();
        if ((obj instanceof ServiceRoot) || (obj instanceof Container)) {
            action.setEnabled(true);
            parentId = ((AbstractObject) obj).getObjectId();
        } else {
            action.setEnabled(false);
            parentId = 0;
        }
    } else {
        action.setEnabled(false);
        parentId = 0;
    }
}
Also used : Container(org.netxms.client.objects.Container) AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ServiceRoot(org.netxms.client.objects.ServiceRoot)

Example 15 with Container

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

the class ObjectStatusMap method buildFlatView.

/**
 * Build flat view - all nodes in one group
 */
private void buildFlatView() {
    AbstractObject root = session.findObjectById(rootObjectId);
    if ((root == null) || !((root instanceof Container) || (root instanceof ServiceRoot) || (root instanceof Cluster)))
        return;
    List<AbstractObject> objects = new ArrayList<AbstractObject>(root.getAllChilds(new int[] { AbstractObject.OBJECT_NODE, AbstractObject.OBJECT_CLUSTER, AbstractObject.OBJECT_MOBILEDEVICE }));
    filterObjects(objects);
    Collections.sort(objects, new Comparator<AbstractObject>() {

        @Override
        public int compare(AbstractObject o1, AbstractObject o2) {
            return o1.getObjectName().compareToIgnoreCase(o2.getObjectName());
        }
    });
    final Composite clientArea = new Composite(dataArea, SWT.NONE);
    clientArea.setBackground(getBackground());
    GridData gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    clientArea.setLayoutData(gd);
    RowLayout clayout = new RowLayout();
    clayout.marginBottom = 0;
    clayout.marginTop = 0;
    clayout.marginLeft = 0;
    clayout.marginRight = 0;
    clayout.type = SWT.HORIZONTAL;
    clayout.wrap = true;
    clayout.pack = false;
    clientArea.setLayout(clayout);
    sections.add(clientArea);
    for (AbstractObject o : objects) {
        if (!isLeafObject(o))
            continue;
        addObjectElement(clientArea, o);
    }
}
Also used : Container(org.netxms.client.objects.Container) Composite(org.eclipse.swt.widgets.Composite) AbstractObject(org.netxms.client.objects.AbstractObject) RowLayout(org.eclipse.swt.layout.RowLayout) ArrayList(java.util.ArrayList) GridData(org.eclipse.swt.layout.GridData) Cluster(org.netxms.client.objects.Cluster) ServiceRoot(org.netxms.client.objects.ServiceRoot)

Aggregations

AbstractObject (org.netxms.client.objects.AbstractObject)15 Container (org.netxms.client.objects.Container)15 Cluster (org.netxms.client.objects.Cluster)11 ServiceRoot (org.netxms.client.objects.ServiceRoot)10 Node (org.netxms.client.objects.Node)7 Condition (org.netxms.client.objects.Condition)6 Subnet (org.netxms.client.objects.Subnet)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 ArrayList (java.util.ArrayList)4 EntireNetwork (org.netxms.client.objects.EntireNetwork)4 NetworkMapLink (org.netxms.client.maps.NetworkMapLink)3 NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)3 AbstractNode (org.netxms.client.objects.AbstractNode)3 MobileDevice (org.netxms.client.objects.MobileDevice)3 HashSet (java.util.HashSet)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 RowLayout (org.eclipse.swt.layout.RowLayout)2 Composite (org.eclipse.swt.widgets.Composite)2