Search in sources :

Example 1 with ObjectStatus

use of org.netxms.client.constants.ObjectStatus in project netxms by netxms.

the class MapLabelProvider method selfStyleConnection.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.gef4.zest.core.viewers.ISelfStyleProvider#selfStyleConnection(java
	 * .lang.Object, org.eclipse.gef4.zest.core.widgets.GraphConnection)
	 */
@Override
public void selfStyleConnection(Object element, GraphConnection connection) {
    connection.setVisible(connectionsVisible);
    NetworkMapLink link = (NetworkMapLink) connection.getData();
    if (link.getType() == NetworkMapLink.VPN) {
        connection.setLineStyle(Graphics.LINE_DOT);
    }
    if (link.hasConnectorName1() && connectionLabelsVisible) {
        ConnectionEndpointLocator sourceEndpointLocator = new ConnectionEndpointLocator(connection.getConnectionFigure(), false);
        sourceEndpointLocator.setVDistance(0);
        final Label label = new ConnectorLabel(link.getConnectorName1());
        label.setFont(fontLabel);
        connection.getConnectionFigure().add(label, sourceEndpointLocator);
    }
    if (link.hasConnectorName2() && connectionLabelsVisible) {
        ConnectionEndpointLocator targetEndpointLocator = new ConnectionEndpointLocator(connection.getConnectionFigure(), true);
        targetEndpointLocator.setVDistance(0);
        final Label label = new ConnectorLabel(link.getConnectorName2());
        label.setFont(fontLabel);
        connection.getConnectionFigure().add(label, targetEndpointLocator);
    }
    if (showLinkDirection)
        ((PolylineConnection) connection.getConnectionFigure()).setSourceDecoration(new PolylineDecoration());
    IFigure owner = ((PolylineConnection) connection.getConnectionFigure()).getTargetAnchor().getOwner();
    ((PolylineConnection) connection.getConnectionFigure()).setTargetAnchor(new MultiConnectionAnchor(owner, link));
    owner = ((PolylineConnection) connection.getConnectionFigure()).getSourceAnchor().getOwner();
    ((PolylineConnection) connection.getConnectionFigure()).setSourceAnchor(new MultiConnectionAnchor(owner, link));
    boolean hasDciData = link.hasDciData();
    boolean hasName = link.hasName();
    if (link.getStatusObject() != null && link.getStatusObject().size() != 0) {
        ObjectStatus status = ObjectStatus.UNKNOWN;
        for (Long id : link.getStatusObject()) {
            AbstractObject object = session.findObjectById(id);
            if (object != null) {
                ObjectStatus s = object.getStatus();
                if ((s.compareTo(ObjectStatus.UNKNOWN) < 0) && ((status.compareTo(s) < 0) || (status == ObjectStatus.UNKNOWN))) {
                    status = s;
                    if (status == ObjectStatus.CRITICAL)
                        break;
                }
            }
        }
        connection.setLineColor(StatusDisplayInfo.getStatusColor(status));
    } else if (link.getColor() >= 0) {
        connection.setLineColor(colors.create(ColorConverter.rgbFromInt(link.getColor())));
    } else if (link.getType() == NetworkMapLink.AGENT_TUNEL) {
        connection.setLineColor(COLOR_AGENT_TUNNEL);
    } else if (link.getType() == NetworkMapLink.AGENT_PROXY) {
        connection.setLineColor(COLOR_AGENT_PROXY);
    } else if (link.getType() == NetworkMapLink.ICMP_PROXY) {
        connection.setLineColor(COLOR_ICMP_PROXY);
    } else if (link.getType() == NetworkMapLink.SNMP_PROXY) {
        connection.setLineColor(COLOR_SNMP_PROXY);
    } else if (link.getType() == NetworkMapLink.SSH_PROXY) {
        connection.setLineColor(COLOR_SSH_PROXY);
    } else if (link.getType() == NetworkMapLink.ZONE_PROXY) {
        connection.setLineColor(COLOR_ZONE_PROXY);
    } else if (defaultLinkColor != null) {
        connection.setLineColor(defaultLinkColor);
    }
    if ((hasName || hasDciData) && connectionLabelsVisible) {
        MultiLabelConnectionLocator nameLocator = new MultiLabelConnectionLocator(connection.getConnectionFigure(), link);
        // $NON-NLS-1$
        String labelString = "";
        if (hasName)
            labelString += link.getName();
        if (hasName && hasDciData)
            // $NON-NLS-1$
            labelString += "\n";
        if (hasDciData) {
            labelString += dciValueProvider.getDciDataAsString(link);
        }
        final Label label;
        if (link.getType() == NetworkMapLink.AGENT_TUNEL || link.getType() == NetworkMapLink.AGENT_PROXY || link.getType() == NetworkMapLink.ICMP_PROXY || link.getType() == NetworkMapLink.SNMP_PROXY || link.getType() == NetworkMapLink.SSH_PROXY || link.getType() == NetworkMapLink.ZONE_PROXY)
            label = new ConnectorLabel(labelString, connection.getLineColor());
        else
            label = new ConnectorLabel(labelString);
        label.setFont(fontLabel);
        connection.getConnectionFigure().add(label, nameLocator);
    }
    switch(link.getRouting()) {
        case NetworkMapLink.ROUTING_DIRECT:
            connection.setRouter(ConnectionRouter.NULL);
            break;
        case NetworkMapLink.ROUTING_MANHATTAN:
            connection.setRouter(manhattanRouter);
            break;
        case NetworkMapLink.ROUTING_BENDPOINTS:
            connection.setRouter(bendpointRouter);
            // $NON-NLS-1$
            connection.setData("ROUTER", bendpointRouter);
            Object bp = getConnectionPoints(link);
            bendpointRouter.setConstraint(connection.getConnectionFigure(), bp);
            connection.getConnectionFigure().setRoutingConstraint(bp);
            break;
        default:
            connection.setRouter(null);
            break;
    }
    connection.setLineWidth(2);
}
Also used : Label(org.eclipse.draw2d.Label) PolylineDecoration(org.eclipse.draw2d.PolylineDecoration) PolylineConnection(org.eclipse.draw2d.PolylineConnection) ObjectStatus(org.netxms.client.constants.ObjectStatus) AbstractObject(org.netxms.client.objects.AbstractObject) ConnectionEndpointLocator(org.eclipse.draw2d.ConnectionEndpointLocator) AbstractObject(org.netxms.client.objects.AbstractObject) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) UnknownObject(org.netxms.client.objects.UnknownObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with ObjectStatus

use of org.netxms.client.constants.ObjectStatus in project netxms by netxms.

the class SlotView method drawPort.

/**
 * Draw single port
 *
 * @param p port information
 * @param x X coordinate of top left corner
 * @param y Y coordinate of top left corner
 */
private void drawPort(PortInfo p, Point point, GC gc) {
    final String label = Integer.toString(p.getPort());
    Rectangle rect = new Rectangle(point.x, point.y, PORT_WIDTH, PORT_HEIGHT);
    finder.addPortLocation(rect, p);
    if (p.isHighlighted()) {
        gc.setBackground(colors.create(HIGHLIGHT_COLOR));
        gc.fillRectangle(rect);
    } else if (portStatusVisible) {
        ObjectStatus status = ObjectStatus.UNKNOWN;
        switch(p.getAdminState()) {
            case Interface.ADMIN_STATE_DOWN:
                status = ObjectStatus.DISABLED;
                break;
            case Interface.ADMIN_STATE_TESTING:
                status = ObjectStatus.TESTING;
                break;
            case Interface.ADMIN_STATE_UP:
                switch(p.getOperState()) {
                    case Interface.OPER_STATE_DOWN:
                        status = ObjectStatus.CRITICAL;
                        break;
                    case Interface.OPER_STATE_TESTING:
                        status = ObjectStatus.TESTING;
                        break;
                    case Interface.OPER_STATE_UP:
                        status = ObjectStatus.NORMAL;
                        break;
                }
                break;
        }
        gc.setBackground(StatusDisplayInfo.getStatusColor(status));
        gc.fillRectangle(rect);
    } else {
        gc.setBackground(colors.create(BACKGROUND_COLOR));
        gc.fillRectangle(rect);
    }
    gc.drawRectangle(rect);
    if (selection == p) {
        // gc.setLineStyle(SWT.LINE_DOT);
        gc.drawRectangle(rect.x + 2, rect.y + 2, rect.width - 4, rect.height - 4);
    // gc.setLineStyle(SWT.LINE_SOLID);
    }
    Point ext = gc.textExtent(label);
    gc.drawText(label, point.x + (PORT_WIDTH - ext.x) / 2, point.y + (PORT_HEIGHT - ext.y) / 2);
}
Also used : ObjectStatus(org.netxms.client.constants.ObjectStatus) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point)

Example 3 with ObjectStatus

use of org.netxms.client.constants.ObjectStatus in project netxms by netxms.

the class ObjectListAdapter method getView.

/*
	 * (non-Javadoc)
	 * 
	 * @see android.widget.Adapter#getView(int, android.view.View,
	 * android.view.ViewGroup)
	 */
@SuppressWarnings("deprecation")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    TextView objectName;
    TextView objectStatusText;
    LinearLayout view, texts;
    ImageView objectIcon;
    Resources r = context.getResources();
    if (convertView == null) {
        // new object, create fields
        objectName = new TextView(context);
        objectName.setPadding(5, 2, 5, 2);
        objectName.setTextColor(r.getColor(R.color.text_color));
        objectName.setTextSize(TypedValue.COMPLEX_UNIT_PX, objectName.getTextSize() * 1.1f);
        objectStatusText = new TextView(context);
        objectStatusText.setPadding(5, 2, 5, 2);
        objectStatusText.setTextColor(r.getColor(R.color.text_color));
        objectIcon = new ImageView(context);
        objectIcon.setPadding(5, 5, 5, 2);
        texts = new LinearLayout(context);
        texts.setOrientation(LinearLayout.VERTICAL);
        texts.addView(objectName);
        texts.addView(objectStatusText);
        view = new LinearLayout(context);
        view.addView(objectIcon);
        view.addView(texts);
    } else {
        // get reference to existing object
        view = (LinearLayout) convertView;
        objectIcon = (ImageView) view.getChildAt(0);
        texts = (LinearLayout) view.getChildAt(1);
        objectName = (TextView) texts.getChildAt(0);
        objectStatusText = (TextView) texts.getChildAt(1);
    }
    // set fields in view
    ObjectStatus objectStatus;
    int objectIconId = R.drawable.object_unknown;
    AbstractObject object = objectList.get(position);
    if (object == null) {
        objectName.setText(r.getString(R.string.node_unknown));
        objectStatusText.setText(r.getString(R.string.status_unknown));
        objectStatus = ObjectStatus.UNKNOWN;
    } else {
        objectName.setText(object.getObjectName());
        objectStatusText.setText(statusTextId[object.getStatus().getValue()]);
        objectStatus = object.getStatus();
        switch(object.getObjectClass()) {
            case AbstractObject.OBJECT_CONTAINER:
                objectIconId = R.drawable.object_container;
                break;
            case AbstractObject.OBJECT_NODE:
                objectIconId = R.drawable.object_node;
                break;
            case AbstractObject.OBJECT_CLUSTER:
                objectIconId = R.drawable.object_cluster;
                break;
            case AbstractObject.OBJECT_DASHBOARD:
                objectIconId = R.drawable.dashboard;
                break;
            case AbstractObject.OBJECT_MOBILEDEVICE:
                objectIconId = R.drawable.object_mobiledevice;
                break;
            case AbstractObject.OBJECT_SUBNET:
                objectIconId = R.drawable.object_subnet;
                break;
            case AbstractObject.OBJECT_ZONE:
                objectIconId = R.drawable.object_zone;
                break;
        }
    }
    Drawable[] layers = new Drawable[2];
    layers[0] = parent.getResources().getDrawable(objectIconId);
    layers[1] = parent.getResources().getDrawable(ObjectListAdapter.statusImageId[objectStatus.getValue()]);
    LayerDrawable drawable = new LayerDrawable(layers);
    drawable.setLayerInset(1, layers[0].getIntrinsicWidth() - layers[1].getIntrinsicWidth(), layers[0].getIntrinsicHeight() - layers[1].getIntrinsicHeight(), 0, 0);
    objectIcon.setImageDrawable(drawable);
    return view;
}
Also used : ObjectStatus(org.netxms.client.constants.ObjectStatus) AbstractObject(org.netxms.client.objects.AbstractObject) LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView) ImageView(android.widget.ImageView) Resources(android.content.res.Resources) LinearLayout(android.widget.LinearLayout)

Example 4 with ObjectStatus

use of org.netxms.client.constants.ObjectStatus in project netxms by netxms.

the class NXCSession method modifyObject.

/**
 * Modify object (generic interface, in most cases wrapper functions should
 * be used instead).
 *
 * @param data     Object modification data
 * @param userData user-defined data for custom object modification
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void modifyObject(final NXCObjectModificationData data, final Object userData) throws IOException, NXCException {
    NXCPMessage msg = newMessage(NXCPCodes.CMD_MODIFY_OBJECT);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) data.getObjectId());
    // Object name
    if (data.isFieldSet(NXCObjectModificationData.NAME)) {
        msg.setField(NXCPCodes.VID_OBJECT_NAME, data.getName());
    }
    // Primary IP
    if (data.isFieldSet(NXCObjectModificationData.PRIMARY_IP)) {
        msg.setField(NXCPCodes.VID_IP_ADDRESS, data.getPrimaryIpAddress());
    }
    // Access control list
    if (data.isFieldSet(NXCObjectModificationData.ACL)) {
        final AccessListElement[] acl = data.getACL();
        msg.setFieldInt32(NXCPCodes.VID_ACL_SIZE, acl.length);
        msg.setFieldInt16(NXCPCodes.VID_INHERIT_RIGHTS, data.isInheritAccessRights() ? 1 : 0);
        long id1 = NXCPCodes.VID_ACL_USER_BASE;
        long id2 = NXCPCodes.VID_ACL_RIGHTS_BASE;
        for (int i = 0; i < acl.length; i++) {
            msg.setFieldInt32(id1++, (int) acl[i].getUserId());
            msg.setFieldInt32(id2++, acl[i].getAccessRights());
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.CUSTOM_ATTRIBUTES)) {
        Map<String, String> attrList = data.getCustomAttributes();
        Iterator<String> it = attrList.keySet().iterator();
        long id = NXCPCodes.VID_CUSTOM_ATTRIBUTES_BASE;
        int count = 0;
        while (it.hasNext()) {
            String key = it.next();
            String value = attrList.get(key);
            msg.setField(id++, key);
            msg.setField(id++, value);
            count++;
        }
        msg.setFieldInt32(NXCPCodes.VID_NUM_CUSTOM_ATTRIBUTES, count);
    }
    if (data.isFieldSet(NXCObjectModificationData.AUTOBIND_FILTER)) {
        msg.setField(NXCPCodes.VID_AUTOBIND_FILTER, data.getAutoBindFilter());
    }
    if (data.isFieldSet(NXCObjectModificationData.FILTER)) {
        msg.setField(NXCPCodes.VID_FILTER, data.getFilter());
    }
    if (data.isFieldSet(NXCObjectModificationData.DESCRIPTION)) {
        msg.setField(NXCPCodes.VID_DESCRIPTION, data.getDescription());
    }
    if (data.isFieldSet(NXCObjectModificationData.VERSION)) {
        msg.setFieldInt32(NXCPCodes.VID_VERSION, data.getVersion());
    }
    // Configuration file
    if (data.isFieldSet(NXCObjectModificationData.POLICY_CONFIG)) {
        msg.setField(NXCPCodes.VID_CONFIG_FILE_DATA, data.getConfigFileContent());
    }
    if (data.isFieldSet(NXCObjectModificationData.AGENT_PORT)) {
        msg.setFieldInt16(NXCPCodes.VID_AGENT_PORT, data.getAgentPort());
    }
    if (data.isFieldSet(NXCObjectModificationData.AGENT_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_AGENT_PROXY, (int) data.getAgentProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.AGENT_AUTH)) {
        msg.setFieldInt16(NXCPCodes.VID_AUTH_METHOD, data.getAgentAuthMethod());
        msg.setField(NXCPCodes.VID_SHARED_SECRET, data.getAgentSecret());
    }
    if (data.isFieldSet(NXCObjectModificationData.TRUSTED_NODES)) {
        final long[] nodes = data.getTrustedNodes();
        msg.setFieldInt32(NXCPCodes.VID_NUM_TRUSTED_NODES, nodes.length);
        msg.setField(NXCPCodes.VID_TRUSTED_NODES, nodes);
    }
    if (data.isFieldSet(NXCObjectModificationData.SNMP_VERSION)) {
        msg.setFieldInt16(NXCPCodes.VID_SNMP_VERSION, data.getSnmpVersion());
    }
    if (data.isFieldSet(NXCObjectModificationData.SNMP_AUTH)) {
        msg.setField(NXCPCodes.VID_SNMP_AUTH_OBJECT, data.getSnmpAuthName());
        msg.setField(NXCPCodes.VID_SNMP_AUTH_PASSWORD, data.getSnmpAuthPassword());
        msg.setField(NXCPCodes.VID_SNMP_PRIV_PASSWORD, data.getSnmpPrivPassword());
        int methods = data.getSnmpAuthMethod() | (data.getSnmpPrivMethod() << 8);
        msg.setFieldInt16(NXCPCodes.VID_SNMP_USM_METHODS, methods);
    }
    if (data.isFieldSet(NXCObjectModificationData.SNMP_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_SNMP_PROXY, (int) data.getSnmpProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.SNMP_PORT)) {
        msg.setFieldInt16(NXCPCodes.VID_SNMP_PORT, data.getSnmpPort());
    }
    if (data.isFieldSet(NXCObjectModificationData.ICMP_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_ICMP_PROXY, (int) data.getIcmpProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.GEOLOCATION)) {
        final GeoLocation gl = data.getGeolocation();
        msg.setFieldInt16(NXCPCodes.VID_GEOLOCATION_TYPE, gl.getType());
        msg.setField(NXCPCodes.VID_LATITUDE, gl.getLatitude());
        msg.setField(NXCPCodes.VID_LONGITUDE, gl.getLongitude());
        msg.setFieldInt16(NXCPCodes.VID_ACCURACY, gl.getAccuracy());
        if (gl.getTimestamp() != null) {
            msg.setFieldInt64(NXCPCodes.VID_GEOLOCATION_TIMESTAMP, gl.getTimestamp().getTime() / 1000);
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.MAP_LAYOUT)) {
        msg.setFieldInt16(NXCPCodes.VID_LAYOUT, data.getMapLayout().getValue());
    }
    if (data.isFieldSet(NXCObjectModificationData.MAP_BACKGROUND)) {
        msg.setField(NXCPCodes.VID_BACKGROUND, data.getMapBackground());
        msg.setField(NXCPCodes.VID_BACKGROUND_LATITUDE, data.getMapBackgroundLocation().getLatitude());
        msg.setField(NXCPCodes.VID_BACKGROUND_LONGITUDE, data.getMapBackgroundLocation().getLongitude());
        msg.setFieldInt16(NXCPCodes.VID_BACKGROUND_ZOOM, data.getMapBackgroundZoom());
        msg.setFieldInt32(NXCPCodes.VID_BACKGROUND_COLOR, data.getMapBackgroundColor());
    }
    if (data.isFieldSet(NXCObjectModificationData.IMAGE)) {
        msg.setField(NXCPCodes.VID_IMAGE, data.getImage());
    }
    if (data.isFieldSet(NXCObjectModificationData.MAP_CONTENT)) {
        msg.setFieldInt32(NXCPCodes.VID_NUM_ELEMENTS, data.getMapElements().size());
        long varId = NXCPCodes.VID_ELEMENT_LIST_BASE;
        for (NetworkMapElement e : data.getMapElements()) {
            e.fillMessage(msg, varId);
            varId += 100;
        }
        msg.setFieldInt32(NXCPCodes.VID_NUM_LINKS, data.getMapLinks().size());
        varId = NXCPCodes.VID_LINK_LIST_BASE;
        for (NetworkMapLink l : data.getMapLinks()) {
            l.fillMessage(msg, varId);
            varId += 20;
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.COLUMN_COUNT)) {
        msg.setFieldInt16(NXCPCodes.VID_NUM_COLUMNS, data.getColumnCount());
    }
    if (data.isFieldSet(NXCObjectModificationData.DASHBOARD_ELEMENTS)) {
        msg.setFieldInt32(NXCPCodes.VID_NUM_ELEMENTS, data.getDashboardElements().size());
        long varId = NXCPCodes.VID_ELEMENT_LIST_BASE;
        for (DashboardElement e : data.getDashboardElements()) {
            e.fillMessage(msg, varId);
            varId += 10;
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.URL_LIST)) {
        msg.setFieldInt32(NXCPCodes.VID_NUM_URLS, data.getUrls().size());
        long fieldId = NXCPCodes.VID_URL_LIST_BASE;
        for (ObjectUrl u : data.getUrls()) {
            u.fillMessage(msg, fieldId);
            fieldId += 10;
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.SCRIPT)) {
        msg.setField(NXCPCodes.VID_SCRIPT, data.getScript());
    }
    if (data.isFieldSet(NXCObjectModificationData.ACTIVATION_EVENT)) {
        msg.setFieldInt32(NXCPCodes.VID_ACTIVATION_EVENT, data.getActivationEvent());
    }
    if (data.isFieldSet(NXCObjectModificationData.DEACTIVATION_EVENT)) {
        msg.setFieldInt32(NXCPCodes.VID_DEACTIVATION_EVENT, data.getDeactivationEvent());
    }
    if (data.isFieldSet(NXCObjectModificationData.SOURCE_OBJECT)) {
        msg.setFieldInt32(NXCPCodes.VID_SOURCE_OBJECT, (int) data.getSourceObject());
    }
    if (data.isFieldSet(NXCObjectModificationData.ACTIVE_STATUS)) {
        msg.setFieldInt16(NXCPCodes.VID_ACTIVE_STATUS, data.getActiveStatus());
    }
    if (data.isFieldSet(NXCObjectModificationData.INACTIVE_STATUS)) {
        msg.setFieldInt16(NXCPCodes.VID_INACTIVE_STATUS, data.getInactiveStatus());
    }
    if (data.isFieldSet(NXCObjectModificationData.DCI_LIST)) {
        List<ConditionDciInfo> dciList = data.getDciList();
        msg.setFieldInt32(NXCPCodes.VID_NUM_ITEMS, dciList.size());
        long varId = NXCPCodes.VID_DCI_LIST_BASE;
        for (ConditionDciInfo dci : dciList) {
            msg.setFieldInt32(varId++, (int) dci.getDciId());
            msg.setFieldInt32(varId++, (int) dci.getNodeId());
            msg.setFieldInt16(varId++, dci.getFunction());
            msg.setFieldInt16(varId++, dci.getPolls());
            varId += 6;
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.DRILL_DOWN_OBJECT_ID)) {
        msg.setFieldInt32(NXCPCodes.VID_DRILL_DOWN_OBJECT_ID, (int) data.getDrillDownObjectId());
    }
    if (data.isFieldSet(NXCObjectModificationData.SERVICE_TYPE)) {
        msg.setFieldInt16(NXCPCodes.VID_SERVICE_TYPE, data.getServiceType());
    }
    if (data.isFieldSet(NXCObjectModificationData.IP_ADDRESS)) {
        msg.setField(NXCPCodes.VID_IP_ADDRESS, data.getIpAddress());
    }
    if (data.isFieldSet(NXCObjectModificationData.IP_PROTOCOL)) {
        msg.setFieldInt16(NXCPCodes.VID_IP_PROTO, data.getIpProtocol());
    }
    if (data.isFieldSet(NXCObjectModificationData.IP_PORT)) {
        msg.setFieldInt16(NXCPCodes.VID_IP_PORT, data.getIpPort());
    }
    if (data.isFieldSet(NXCObjectModificationData.POLLER_NODE)) {
        msg.setFieldInt32(NXCPCodes.VID_POLLER_NODE_ID, (int) data.getPollerNode());
    }
    if (data.isFieldSet(NXCObjectModificationData.REQUIRED_POLLS)) {
        msg.setFieldInt16(NXCPCodes.VID_REQUIRED_POLLS, data.getRequiredPolls());
    }
    if (data.isFieldSet(NXCObjectModificationData.REQUEST)) {
        msg.setField(NXCPCodes.VID_SERVICE_REQUEST, data.getRequest());
    }
    if (data.isFieldSet(NXCObjectModificationData.RESPONSE)) {
        msg.setField(NXCPCodes.VID_SERVICE_RESPONSE, data.getResponse());
    }
    if (data.isFieldSet(NXCObjectModificationData.OBJECT_FLAGS)) {
        msg.setFieldInt32(NXCPCodes.VID_FLAGS, data.getObjectFlags());
        msg.setFieldInt32(NXCPCodes.VID_FLAGS_MASK, data.getObjectFlagsMask());
    }
    if (data.isFieldSet(NXCObjectModificationData.IFXTABLE_POLICY)) {
        msg.setFieldInt16(NXCPCodes.VID_USE_IFXTABLE, data.getIfXTablePolicy());
    }
    if (data.isFieldSet(NXCObjectModificationData.REPORT_DEFINITION)) {
        msg.setField(NXCPCodes.VID_REPORT_DEFINITION, data.getReportDefinition());
    }
    if (data.isFieldSet(NXCObjectModificationData.CLUSTER_RESOURCES)) {
        msg.setFieldInt32(NXCPCodes.VID_NUM_RESOURCES, data.getResourceList().size());
        long varId = NXCPCodes.VID_RESOURCE_LIST_BASE;
        for (ClusterResource r : data.getResourceList()) {
            msg.setFieldInt32(varId++, (int) r.getId());
            msg.setField(varId++, r.getName());
            msg.setField(varId++, r.getVirtualAddress());
            varId += 7;
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.CLUSTER_NETWORKS)) {
        int count = data.getNetworkList().size();
        msg.setFieldInt32(NXCPCodes.VID_NUM_SYNC_SUBNETS, count);
        long varId = NXCPCodes.VID_SYNC_SUBNETS_BASE;
        for (InetAddressEx n : data.getNetworkList()) {
            msg.setField(varId++, n);
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.PRIMARY_NAME)) {
        msg.setField(NXCPCodes.VID_PRIMARY_NAME, data.getPrimaryName());
    }
    if (data.isFieldSet(NXCObjectModificationData.STATUS_CALCULATION)) {
        msg.setFieldInt16(NXCPCodes.VID_STATUS_CALCULATION_ALG, data.getStatusCalculationMethod());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_PROPAGATION_ALG, data.getStatusPropagationMethod());
        msg.setFieldInt16(NXCPCodes.VID_FIXED_STATUS, data.getFixedPropagatedStatus().getValue());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_SHIFT, data.getStatusShift());
        ObjectStatus[] transformation = data.getStatusTransformation();
        msg.setFieldInt16(NXCPCodes.VID_STATUS_TRANSLATION_1, transformation[0].getValue());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_TRANSLATION_2, transformation[1].getValue());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_TRANSLATION_3, transformation[2].getValue());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_TRANSLATION_4, transformation[3].getValue());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_SINGLE_THRESHOLD, data.getStatusSingleThreshold());
        int[] thresholds = data.getStatusThresholds();
        msg.setFieldInt16(NXCPCodes.VID_STATUS_THRESHOLD_1, thresholds[0]);
        msg.setFieldInt16(NXCPCodes.VID_STATUS_THRESHOLD_2, thresholds[1]);
        msg.setFieldInt16(NXCPCodes.VID_STATUS_THRESHOLD_3, thresholds[2]);
        msg.setFieldInt16(NXCPCodes.VID_STATUS_THRESHOLD_4, thresholds[3]);
    }
    if (data.isFieldSet(NXCObjectModificationData.EXPECTED_STATE)) {
        msg.setFieldInt16(NXCPCodes.VID_EXPECTED_STATE, data.getExpectedState());
    }
    if (data.isFieldSet(NXCObjectModificationData.LINK_COLOR)) {
        msg.setFieldInt32(NXCPCodes.VID_LINK_COLOR, data.getLinkColor());
    }
    if (data.isFieldSet(NXCObjectModificationData.CONNECTION_ROUTING)) {
        msg.setFieldInt16(NXCPCodes.VID_LINK_ROUTING, data.getConnectionRouting());
    }
    if (data.isFieldSet(NXCObjectModificationData.DISCOVERY_RADIUS)) {
        msg.setFieldInt32(NXCPCodes.VID_DISCOVERY_RADIUS, data.getDiscoveryRadius());
    }
    if (data.isFieldSet(NXCObjectModificationData.HEIGHT)) {
        msg.setFieldInt16(NXCPCodes.VID_HEIGHT, data.getHeight());
    }
    if (data.isFieldSet(NXCObjectModificationData.RACK_NUMB_SCHEME)) {
        msg.setField(NXCPCodes.VID_TOP_BOTTOM, data.isRackNumberingTopBottom());
    }
    if (data.isFieldSet(NXCObjectModificationData.PEER_GATEWAY)) {
        msg.setFieldInt32(NXCPCodes.VID_PEER_GATEWAY, (int) data.getPeerGatewayId());
    }
    if (data.isFieldSet(NXCObjectModificationData.VPN_NETWORKS)) {
        long fieldId = NXCPCodes.VID_VPN_NETWORK_BASE;
        msg.setFieldInt32(NXCPCodes.VID_NUM_LOCAL_NETS, data.getLocalNetworks().size());
        for (InetAddressEx a : data.getLocalNetworks()) {
            msg.setField(fieldId++, a);
        }
        msg.setFieldInt32(NXCPCodes.VID_NUM_REMOTE_NETS, data.getRemoteNetworks().size());
        for (InetAddressEx a : data.getRemoteNetworks()) {
            msg.setField(fieldId++, a);
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.POSTAL_ADDRESS)) {
        data.getPostalAddress().fillMessage(msg);
    }
    if (data.isFieldSet(NXCObjectModificationData.AGENT_CACHE_MODE)) {
        msg.setFieldInt16(NXCPCodes.VID_AGENT_CACHE_MODE, data.getAgentCacheMode().getValue());
    }
    if (data.isFieldSet(NXCObjectModificationData.AGENT_COMPRESSION_MODE)) {
        msg.setFieldInt16(NXCPCodes.VID_AGENT_COMPRESSION_MODE, data.getAgentCompressionMode().getValue());
    }
    if (data.isFieldSet(NXCObjectModificationData.MAPOBJ_DISP_MODE)) {
        msg.setFieldInt16(NXCPCodes.VID_DISPLAY_MODE, data.getMapObjectDisplayMode().getValue());
    }
    if (data.isFieldSet(NXCObjectModificationData.RACK_PLACEMENT)) {
        msg.setFieldInt32(NXCPCodes.VID_RACK_ID, (int) data.getRackId());
        msg.setField(NXCPCodes.VID_RACK_IMAGE_FRONT, data.getFrontRackImage());
        msg.setField(NXCPCodes.VID_RACK_IMAGE_REAR, data.getRearRackImage());
        msg.setFieldInt16(NXCPCodes.VID_RACK_POSITION, data.getRackPosition());
        msg.setFieldInt16(NXCPCodes.VID_RACK_HEIGHT, data.getRackHeight());
        msg.setFieldInt16(NXCPCodes.VID_RACK_ORIENTATION, data.getRackOrientation().getValue());
    }
    if (data.isFieldSet(NXCObjectModificationData.DASHBOARD_LIST)) {
        msg.setField(NXCPCodes.VID_DASHBOARDS, data.getDashboards());
    }
    if (data.isFieldSet(NXCObjectModificationData.CHASSIS_ID)) {
        msg.setFieldInt32(NXCPCodes.VID_CHASSIS_ID, (int) data.getChassisId());
    }
    if (data.isFieldSet(NXCObjectModificationData.CONTROLLER_ID)) {
        msg.setFieldInt32(NXCPCodes.VID_CONTROLLER_ID, (int) data.getControllerId());
    }
    if (data.isFieldSet(NXCObjectModificationData.SSH_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_SSH_PROXY, (int) data.getSshProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.SSH_LOGIN)) {
        msg.setField(NXCPCodes.VID_SSH_LOGIN, data.getSshLogin());
    }
    if (data.isFieldSet(NXCObjectModificationData.SSH_PASSWORD)) {
        msg.setField(NXCPCodes.VID_SSH_PASSWORD, data.getSshPassword());
    }
    if (data.isFieldSet(NXCObjectModificationData.ZONE_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_ZONE_PROXY, (int) data.getZoneProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.SEED_OBJECTS)) {
        msg.setField(NXCPCodes.VID_SEED_OBJECTS, data.getSeedObjectIds());
    }
    if (data.isFieldSet(NXCObjectModificationData.MAC_ADDRESS)) {
        msg.setField(NXCPCodes.VID_MAC_ADDR, data.getMacAddress());
    }
    if (data.isFieldSet(NXCObjectModificationData.DEVICE_CLASS)) {
        msg.setFieldInt32(NXCPCodes.VID_DEVICE_CLASS, data.getDeviceClass());
    }
    if (data.isFieldSet(NXCObjectModificationData.VENDOR)) {
        msg.setField(NXCPCodes.VID_VENDOR, data.getVendor());
    }
    if (data.isFieldSet(NXCObjectModificationData.SERIAL_NUMBER)) {
        msg.setField(NXCPCodes.VID_SERIAL_NUMBER, data.getSerialNumber());
    }
    if (data.isFieldSet(NXCObjectModificationData.DEVICE_ADDRESS)) {
        msg.setField(NXCPCodes.VID_DEVICE_ADDRESS, data.getDeviceAddress());
    }
    if (data.isFieldSet(NXCObjectModificationData.META_TYPE)) {
        msg.setField(NXCPCodes.VID_META_TYPE, data.getMetaType());
    }
    if (data.isFieldSet(NXCObjectModificationData.SENSOR_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_SENSOR_PROXY, (int) data.getSensorProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.XML_CONFIG)) {
        msg.setField(NXCPCodes.VID_XML_CONFIG, data.getXmlConfig());
    }
    if (data.isFieldSet(NXCObjectModificationData.SNMP_PORT_LIST)) {
        msg.setFieldInt32(NXCPCodes.VID_ZONE_SNMP_PORT_COUNT, data.getSnmpPorts().size());
        for (int i = 0; i < data.getSnmpPorts().size(); i++) {
            msg.setField(NXCPCodes.VID_ZONE_SNMP_PORT_LIST_BASE + i, data.getSnmpPorts().get(i));
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.PASSIVE_ELEMENTS)) {
        msg.setField(NXCPCodes.VID_PASSIVE_ELEMENTS, data.getPassiveElements());
    }
    if (data.isFieldSet(NXCObjectModificationData.RESPONSIBLE_USERS)) {
        Long[] users = data.getResponsibleUsers().toArray(new Long[data.getResponsibleUsers().size()]);
        msg.setField(NXCPCodes.VID_RESPONSIBLE_USERS, users);
    }
    modifyCustomObject(data, userData, msg);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ConditionDciInfo(org.netxms.client.datacollection.ConditionDciInfo) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint) DashboardElement(org.netxms.client.dashboards.DashboardElement) ClusterResource(org.netxms.client.objects.ClusterResource) ObjectStatus(org.netxms.client.constants.ObjectStatus) InetAddressEx(org.netxms.base.InetAddressEx) NetworkMapElement(org.netxms.client.maps.elements.NetworkMapElement) AtomicLong(java.util.concurrent.atomic.AtomicLong) GeoLocation(org.netxms.base.GeoLocation) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 5 with ObjectStatus

use of org.netxms.client.constants.ObjectStatus in project netxms by netxms.

the class ObjectStatusIndicator method drawObject.

/**
 * @param object
 * @param y
 */
private void drawObject(GC gc, AbstractObject object, int y, int width, int height) {
    final ObjectStatus status = object.getStatus();
    if ((status == ObjectStatus.NORMAL) && hideNormal)
        return;
    if ((status == ObjectStatus.UNMANAGED) && hideUnmanaged)
        return;
    if ((status == ObjectStatus.UNKNOWN) && hideUnknown)
        return;
    if ((status == ObjectStatus.DISABLED) && hideDisabled)
        return;
    if (showIcons) {
        gc.drawImage(StatusDisplayInfo.getStatusImage(status), (width - 16) / 2, y + (height - 16) / 2);
    } else {
        gc.setBackground(StatusDisplayInfo.getStatusColor(status));
        gc.setForeground(StatusDisplayInfo.getStatusColor(status));
        int size = Math.min(width - 8, height - 8);
        gc.setAlpha(127);
        gc.fillOval((width - size) / 2, y + (height - size) / 2, size, size);
        gc.setAlpha(255);
        gc.drawOval((width - size) / 2, y + (height - size) / 2, size, size);
    }
}
Also used : ObjectStatus(org.netxms.client.constants.ObjectStatus) Point(org.eclipse.swt.graphics.Point)

Aggregations

ObjectStatus (org.netxms.client.constants.ObjectStatus)7 AbstractObject (org.netxms.client.objects.AbstractObject)3 Point (org.eclipse.swt.graphics.Point)2 NetworkMapLink (org.netxms.client.maps.NetworkMapLink)2 Resources (android.content.res.Resources)1 Drawable (android.graphics.drawable.Drawable)1 LayerDrawable (android.graphics.drawable.LayerDrawable)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ConnectionEndpointLocator (org.eclipse.draw2d.ConnectionEndpointLocator)1 IFigure (org.eclipse.draw2d.IFigure)1 Label (org.eclipse.draw2d.Label)1 PolylineConnection (org.eclipse.draw2d.PolylineConnection)1 PolylineDecoration (org.eclipse.draw2d.PolylineDecoration)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 GeoLocation (org.netxms.base.GeoLocation)1 InetAddressEx (org.netxms.base.InetAddressEx)1