Search in sources :

Example 11 with Cluster

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

the class RemoveClusterNode method selectionChanged.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
	 */
public void selectionChanged(IAction action, ISelection selection) {
    if (selection instanceof IStructuredSelection) {
        Object obj = ((IStructuredSelection) selection).getFirstElement();
        if (obj instanceof Cluster) {
            action.setEnabled(true);
            clusterId = ((AbstractObject) obj).getObjectId();
        } else {
            action.setEnabled(false);
            clusterId = 0;
        }
    } else {
        action.setEnabled(false);
        clusterId = 0;
    }
}
Also used : Cluster(org.netxms.client.objects.Cluster) AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 12 with Cluster

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

the class HistoricalDataView method init.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite)
	 */
@Override
public void init(IViewSite site) throws PartInitException {
    super.init(site);
    session = (NXCSession) ConsoleSharedData.getSession();
    // Secondary ID must by in form nodeId&dciId
    // $NON-NLS-1$
    String[] parts = site.getSecondaryId().split("&");
    if (parts.length != 2)
        // $NON-NLS-1$
        throw new PartInitException("Internal error");
    nodeId = Long.parseLong(parts[0]);
    AbstractObject object = session.findObjectById(nodeId);
    if ((object == null) || (!(object instanceof AbstractNode) && !(object instanceof MobileDevice) && !(object instanceof Cluster) && !(object instanceof Sensor)))
        throw new PartInitException(Messages.get().HistoricalDataView_InvalidObjectID);
    nodeName = object.getObjectName();
    if (parts[1].contains("@")) {
        subparts = parts[1].split("@");
        try {
            dciId = Long.parseLong(subparts[0]);
            // $NON-NLS-1$
            tableName = URLDecoder.decode(subparts[1], "UTF-8");
            // $NON-NLS-1$
            instance = URLDecoder.decode(subparts[2], "UTF-8");
            // $NON-NLS-1$
            column = URLDecoder.decode(subparts[3], "UTF-8");
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    } else {
        dciId = Long.parseLong(parts[1]);
    }
    // $NON-NLS-1$ //$NON-NLS-2$
    setPartName(nodeName + ": [" + (tableName == null ? Long.toString(dciId) : tableName) + "]");
}
Also used : MobileDevice(org.netxms.client.objects.MobileDevice) AbstractNode(org.netxms.client.objects.AbstractNode) AbstractObject(org.netxms.client.objects.AbstractObject) Cluster(org.netxms.client.objects.Cluster) UnsupportedEncodingException(java.io.UnsupportedEncodingException) PartInitException(org.eclipse.ui.PartInitException) Sensor(org.netxms.client.objects.Sensor)

Example 13 with Cluster

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

the class ObjectStatusMap method buildSection.

/**
 * Build section of the form corresponding to one container
 */
private void buildSection(long rootId, String namePrefix) {
    AbstractObject root = session.findObjectById(rootId);
    if ((root == null) || !((root instanceof Container) || (root instanceof ServiceRoot) || (root instanceof Cluster)))
        return;
    List<AbstractObject> objects = new ArrayList<AbstractObject>(Arrays.asList(root.getChildsAsArray()));
    Collections.sort(objects, new Comparator<AbstractObject>() {

        @Override
        public int compare(AbstractObject o1, AbstractObject o2) {
            return o1.getObjectName().compareToIgnoreCase(o2.getObjectName());
        }
    });
    Composite section = null;
    Composite clientArea = null;
    // Add nodes and clusters
    for (AbstractObject o : objects) {
        if (!((o instanceof AbstractNode) || (o instanceof Cluster)))
            continue;
        if (!isAcceptedByFilter(o))
            continue;
        if (section == null) {
            section = new Composite(dataArea, SWT.NONE);
            section.setBackground(getBackground());
            GridData gd = new GridData();
            gd.grabExcessHorizontalSpace = true;
            gd.horizontalAlignment = SWT.FILL;
            section.setLayoutData(gd);
            GridLayout layout = new GridLayout();
            layout.marginHeight = 0;
            layout.marginWidth = 0;
            section.setLayout(layout);
            final Label title = new Label(section, SWT.NONE);
            title.setBackground(getBackground());
            title.setFont(titleFont);
            title.setText(namePrefix + root.getObjectName());
            clientArea = new Composite(section, SWT.NONE);
            clientArea.setBackground(getBackground());
            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(section);
        }
        addObjectElement(clientArea, o);
    }
    // Add subcontainers
    for (AbstractObject o : objects) {
        if (!(o instanceof Container) && !(o instanceof ServiceRoot) && !(o instanceof Cluster))
            continue;
        // $NON-NLS-1$
        buildSection(o.getObjectId(), namePrefix + root.getObjectName() + " / ");
    }
}
Also used : Composite(org.eclipse.swt.widgets.Composite) AbstractNode(org.netxms.client.objects.AbstractNode) ArrayList(java.util.ArrayList) Label(org.eclipse.swt.widgets.Label) Cluster(org.netxms.client.objects.Cluster) ServiceRoot(org.netxms.client.objects.ServiceRoot) Container(org.netxms.client.objects.Container) GridLayout(org.eclipse.swt.layout.GridLayout) AbstractObject(org.netxms.client.objects.AbstractObject) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData)

Example 14 with Cluster

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

the class TableLastValuesView method init.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite)
	 */
@Override
public void init(IViewSite site) throws PartInitException {
    super.init(site);
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    // Secondary ID must by in form nodeId&dciId
    // $NON-NLS-1$
    String[] parts = site.getSecondaryId().split("&");
    if (parts.length != 2)
        // $NON-NLS-1$
        throw new PartInitException("Internal error");
    objectId = Long.parseLong(parts[0]);
    AbstractObject object = session.findObjectById(objectId);
    if ((object == null) || (!(object instanceof AbstractNode) && !(object instanceof Cluster) && !(object instanceof MobileDevice) && !(object instanceof Sensor)))
        throw new PartInitException(Messages.get().TableLastValuesView_InvalidObjectID);
    dciId = Long.parseLong(parts[1]);
    // $NON-NLS-1$ //$NON-NLS-2$
    setPartName(object.getObjectName() + ": [" + Long.toString(dciId) + "]");
}
Also used : NXCSession(org.netxms.client.NXCSession) MobileDevice(org.netxms.client.objects.MobileDevice) AbstractNode(org.netxms.client.objects.AbstractNode) AbstractObject(org.netxms.client.objects.AbstractObject) Cluster(org.netxms.client.objects.Cluster) PartInitException(org.eclipse.ui.PartInitException) Sensor(org.netxms.client.objects.Sensor)

Example 15 with Cluster

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

the class NXCSession method createObjectFromMessage.

/**
 * Create object from message
 *
 * @param msg Source NXCP message
 * @return NetXMS object
 */
private AbstractObject createObjectFromMessage(NXCPMessage msg) {
    final int objectClass = msg.getFieldAsInt32(NXCPCodes.VID_OBJECT_CLASS);
    AbstractObject object = createCustomObjectFromMessage(objectClass, msg);
    if (object != null)
        return object;
    switch(objectClass) {
        case AbstractObject.OBJECT_ACCESSPOINT:
            object = new AccessPoint(msg, this);
            break;
        case AbstractObject.OBJECT_AGENTPOLICY:
            object = new AgentPolicy(msg, this);
            break;
        case AbstractObject.OBJECT_AGENTPOLICY_CONFIG:
            object = new AgentPolicyConfig(msg, this);
            break;
        case AbstractObject.OBJECT_AGENTPOLICY_LOGPARSER:
            object = new AgentPolicyLogParser(msg, this);
            break;
        case AbstractObject.OBJECT_BUSINESSSERVICE:
            object = new BusinessService(msg, this);
            break;
        case AbstractObject.OBJECT_BUSINESSSERVICEROOT:
            object = new BusinessServiceRoot(msg, this);
            break;
        case AbstractObject.OBJECT_CHASSIS:
            object = new Chassis(msg, this);
            break;
        case AbstractObject.OBJECT_CLUSTER:
            object = new Cluster(msg, this);
            break;
        case AbstractObject.OBJECT_CONDITION:
            object = new Condition(msg, this);
            break;
        case AbstractObject.OBJECT_CONTAINER:
            object = new Container(msg, this);
            break;
        case AbstractObject.OBJECT_DASHBOARDGROUP:
            object = new DashboardGroup(msg, this);
            break;
        case AbstractObject.OBJECT_DASHBOARD:
            object = new Dashboard(msg, this);
            break;
        case AbstractObject.OBJECT_DASHBOARDROOT:
            object = new DashboardRoot(msg, this);
            break;
        case AbstractObject.OBJECT_INTERFACE:
            object = new Interface(msg, this);
            break;
        case AbstractObject.OBJECT_MOBILEDEVICE:
            object = new MobileDevice(msg, this);
            break;
        case AbstractObject.OBJECT_NETWORK:
            object = new EntireNetwork(msg, this);
            break;
        case AbstractObject.OBJECT_NETWORKMAP:
            object = new NetworkMap(msg, this);
            break;
        case AbstractObject.OBJECT_NETWORKMAPGROUP:
            object = new NetworkMapGroup(msg, this);
            break;
        case AbstractObject.OBJECT_NETWORKMAPROOT:
            object = new NetworkMapRoot(msg, this);
            break;
        case AbstractObject.OBJECT_NETWORKSERVICE:
            object = new NetworkService(msg, this);
            break;
        case AbstractObject.OBJECT_NODE:
            object = new Node(msg, this);
            break;
        case AbstractObject.OBJECT_NODELINK:
            object = new NodeLink(msg, this);
            break;
        case AbstractObject.OBJECT_POLICYGROUP:
            object = new PolicyGroup(msg, this);
            break;
        case AbstractObject.OBJECT_POLICYROOT:
            object = new PolicyRoot(msg, this);
            break;
        case AbstractObject.OBJECT_RACK:
            object = new Rack(msg, this);
            break;
        case AbstractObject.OBJECT_SENSOR:
            object = new Sensor(msg, this);
            break;
        case AbstractObject.OBJECT_SERVICEROOT:
            object = new ServiceRoot(msg, this);
            break;
        case AbstractObject.OBJECT_SLMCHECK:
            object = new ServiceCheck(msg, this);
            break;
        case AbstractObject.OBJECT_SUBNET:
            object = new Subnet(msg, this);
            break;
        case AbstractObject.OBJECT_TEMPLATE:
            object = new Template(msg, this);
            break;
        case AbstractObject.OBJECT_TEMPLATEGROUP:
            object = new TemplateGroup(msg, this);
            break;
        case AbstractObject.OBJECT_TEMPLATEROOT:
            object = new TemplateRoot(msg, this);
            break;
        case AbstractObject.OBJECT_VPNCONNECTOR:
            object = new VPNConnector(msg, this);
            break;
        case AbstractObject.OBJECT_ZONE:
            object = new Zone(msg, this);
            break;
        default:
            object = new GenericObject(msg, this);
            break;
    }
    return object;
}
Also used : Chassis(org.netxms.client.objects.Chassis) DashboardGroup(org.netxms.client.objects.DashboardGroup) ServiceCheck(org.netxms.client.objects.ServiceCheck) TemplateRoot(org.netxms.client.objects.TemplateRoot) DashboardRoot(org.netxms.client.objects.DashboardRoot) AbstractNode(org.netxms.client.objects.AbstractNode) Node(org.netxms.client.objects.Node) NetworkMapGroup(org.netxms.client.objects.NetworkMapGroup) Dashboard(org.netxms.client.objects.Dashboard) AgentPolicyConfig(org.netxms.client.objects.AgentPolicyConfig) Template(org.netxms.client.objects.Template) Rack(org.netxms.client.objects.Rack) BusinessServiceRoot(org.netxms.client.objects.BusinessServiceRoot) Container(org.netxms.client.objects.Container) MobileDevice(org.netxms.client.objects.MobileDevice) TemplateGroup(org.netxms.client.objects.TemplateGroup) PolicyRoot(org.netxms.client.objects.PolicyRoot) Condition(org.netxms.client.objects.Condition) PolicyGroup(org.netxms.client.objects.PolicyGroup) Zone(org.netxms.client.objects.Zone) AccessPoint(org.netxms.client.objects.AccessPoint) VPNConnector(org.netxms.client.objects.VPNConnector) Cluster(org.netxms.client.objects.Cluster) NetworkMapRoot(org.netxms.client.objects.NetworkMapRoot) EntireNetwork(org.netxms.client.objects.EntireNetwork) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint) ServiceRoot(org.netxms.client.objects.ServiceRoot) BusinessServiceRoot(org.netxms.client.objects.BusinessServiceRoot) BusinessService(org.netxms.client.objects.BusinessService) AgentPolicy(org.netxms.client.objects.AgentPolicy) AbstractObject(org.netxms.client.objects.AbstractObject) GenericObject(org.netxms.client.objects.GenericObject) AgentPolicyLogParser(org.netxms.client.objects.AgentPolicyLogParser) NetworkService(org.netxms.client.objects.NetworkService) NodeLink(org.netxms.client.objects.NodeLink) Subnet(org.netxms.client.objects.Subnet) Interface(org.netxms.client.objects.Interface) NetworkMap(org.netxms.client.objects.NetworkMap) Sensor(org.netxms.client.objects.Sensor)

Aggregations

Cluster (org.netxms.client.objects.Cluster)22 AbstractObject (org.netxms.client.objects.AbstractObject)21 Container (org.netxms.client.objects.Container)11 AbstractNode (org.netxms.client.objects.AbstractNode)10 ServiceRoot (org.netxms.client.objects.ServiceRoot)7 Condition (org.netxms.client.objects.Condition)6 MobileDevice (org.netxms.client.objects.MobileDevice)6 Node (org.netxms.client.objects.Node)6 Sensor (org.netxms.client.objects.Sensor)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 Composite (org.eclipse.swt.widgets.Composite)5 NXCSession (org.netxms.client.NXCSession)5 Subnet (org.netxms.client.objects.Subnet)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 GridData (org.eclipse.swt.layout.GridData)4 Template (org.netxms.client.objects.Template)4 ArrayList (java.util.ArrayList)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 RowLayout (org.eclipse.swt.layout.RowLayout)3 PartInitException (org.eclipse.ui.PartInitException)3