Search in sources :

Example 6 with DataCollectionTarget

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

the class ObjectPopupDialog method createDialogArea.

/* (non-Javadoc)
    * @see org.eclipse.jface.dialogs.PopupDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
    */
@Override
protected Control createDialogArea(Composite parent) {
    Composite dialogArea = (Composite) super.createDialogArea(parent);
    statusLabel = new CLabel(dialogArea, SWT.NONE);
    statusLabel.setText(StatusDisplayInfo.getStatusText(object.getStatus()).toUpperCase());
    statusLabel.setForeground(StatusDisplayInfo.getStatusColor(object.getStatus()));
    statusLabel.setFont(boldFont);
    StringBuilder sb = new StringBuilder();
    if (object instanceof AbstractNode) {
        appendText(sb, ((AbstractNode) object).getPrimaryIP().getHostAddress());
        appendText(sb, ((AbstractNode) object).getPlatformName());
        String sd = ((AbstractNode) object).getSystemDescription();
        if (sd.length() > 127)
            // $NON-NLS-1$
            sd = sd.substring(0, 127) + "...";
        appendText(sb, sd);
        appendText(sb, ((AbstractNode) object).getSnmpSysName());
        appendText(sb, ((AbstractNode) object).getSnmpSysContact());
    }
    if (sb.length() > 0) {
        createSeparator(dialogArea);
        if (sb.charAt(sb.length() - 1) == '\n')
            sb.deleteCharAt(sb.length() - 1);
        CLabel infoText = new CLabel(dialogArea, SWT.MULTI);
        infoText.setText(sb.toString());
    }
    if (object instanceof DataCollectionTarget) {
        List<DciValue> values = ((DataCollectionTarget) object).getTooltipDciData();
        if (!values.isEmpty()) {
            createSeparator(dialogArea);
            Composite group = new Composite(dialogArea, SWT.NONE);
            GridLayout layout = new GridLayout();
            layout.marginHeight = 0;
            layout.marginWidth = 0;
            layout.numColumns = 2;
            group.setLayout(layout);
            StringBuilder leftColumn = new StringBuilder();
            StringBuilder rightColumn = new StringBuilder();
            for (DciValue v : values) {
                if (leftColumn.length() > 0) {
                    leftColumn.append('\n');
                    rightColumn.append('\n');
                }
                leftColumn.append(v.getDescription());
                rightColumn.append(v.getValue());
            }
            new CLabel(group, SWT.MULTI).setText(leftColumn.toString());
            new CLabel(group, SWT.MULTI).setText(rightColumn.toString());
        }
    }
    if (!object.getComments().isEmpty()) {
        createSeparator(dialogArea);
        new CLabel(dialogArea, SWT.MULTI).setText(object.getComments());
    }
    return dialogArea;
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) AbstractNode(org.netxms.client.objects.AbstractNode) DataCollectionTarget(org.netxms.client.objects.DataCollectionTarget) DciValue(org.netxms.client.datacollection.DciValue)

Aggregations

DataCollectionTarget (org.netxms.client.objects.DataCollectionTarget)6 AbstractObject (org.netxms.client.objects.AbstractObject)4 DciValue (org.netxms.client.datacollection.DciValue)3 Date (java.util.Date)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1 CLabel (org.eclipse.swt.custom.CLabel)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 NXCException (org.netxms.client.NXCException)1 NXCSession (org.netxms.client.NXCSession)1 DciData (org.netxms.client.datacollection.DciData)1 ThresholdViolationSummary (org.netxms.client.datacollection.ThresholdViolationSummary)1 AbstractNode (org.netxms.client.objects.AbstractNode)1 Template (org.netxms.client.objects.Template)1 OverviewDciLabelProvider (org.netxms.ui.eclipse.objectview.objecttabs.helpers.OverviewDciLabelProvider)1 ResponseContainer (org.netxms.websvc.json.ResponseContainer)1