Search in sources :

Example 36 with DciValue

use of org.netxms.client.datacollection.DciValue in project netxms by netxms.

the class LastValues method refresh.

/**
 * Refresh view
 */
private void refresh() {
    final NXCSession session = ConsoleSharedData.getSession();
    final long nodeId = getObject().getObjectId();
    ConsoleJob job = new ConsoleJob(Messages.get().LastValues_JobName, getObjectTab().getViewPart(), Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            try {
                final DciValue[] list = session.getLastValues(nodeId, false, true, false);
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        if (viewer.getControl().isDisposed() || (getObject().getObjectId() != nodeId))
                            return;
                        viewer.setInput(list);
                        viewer.getTable().getColumn(0).pack();
                        viewer.getTable().getColumn(1).pack();
                    }
                });
            } catch (Exception e) {
                // $NON-NLS-1$
                Activator.log("Exception in last values overview element", e);
            }
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().LastValues_JobErrorMsg;
        }
    };
    job.setUser(false);
    job.setSystem(true);
    job.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) DciValue(org.netxms.client.datacollection.DciValue) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 37 with DciValue

use of org.netxms.client.datacollection.DciValue 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

DciValue (org.netxms.client.datacollection.DciValue)37 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 ArrayList (java.util.ArrayList)9 SelectDciDialog (org.netxms.ui.eclipse.datacollection.dialogs.SelectDciDialog)8 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)7 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)5 AbstractObject (org.netxms.client.objects.AbstractObject)4 Intent (android.content.Intent)3 NXCSession (org.netxms.client.NXCSession)3 ChartDciConfig (org.netxms.client.datacollection.ChartDciConfig)3 DataCollectionObject (org.netxms.client.datacollection.DataCollectionObject)3 SimpleDciValue (org.netxms.client.datacollection.SimpleDciValue)3 SingleDciConfig (org.netxms.client.maps.configs.SingleDciConfig)3 CoreException (org.eclipse.core.runtime.CoreException)2 PartInitException (org.eclipse.ui.PartInitException)2 NXCPMessage (org.netxms.base.NXCPMessage)2 DataCollectionTarget (org.netxms.client.objects.DataCollectionTarget)2 DciIdMatchingData (org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData)2 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)2