Search in sources :

Example 16 with DciValue

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

the class AbstractNetworkMapView method openLinkDci.

/**
 * Handler for opening network map dci on double click
 */
private void openLinkDci() {
    final NetworkMapLink link = (NetworkMapLink) currentSelection.getFirstElement();
    if (!link.hasDciData())
        return;
    new ConsoleJob("Open link dci job", this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {

        /* (non-Javadoc)
          * @see org.netxms.ui.eclipse.jobs.ConsoleJob#runInternal(org.eclipse.core.runtime.IProgressMonitor)
          */
        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            DciValue[] values = session.getLastValues(link.getDciAsList());
            final StringBuilder sb = new StringBuilder();
            for (DciValue v : values) {
                sb.append("&");
                sb.append(Integer.toString(v instanceof SimpleDciValue ? ChartDciConfig.ITEM : ChartDciConfig.TABLE));
                sb.append("@");
                sb.append(Long.toString(v.getNodeId()));
                sb.append("@");
                sb.append(Long.toString(v.getId()));
                sb.append("@");
                sb.append(URLEncoder.encode(v.getDescription(), "UTF-8"));
                sb.append("@");
                sb.append(URLEncoder.encode(v.getName(), "UTF-8"));
            }
            runInUIThread(new Runnable() {

                /* (non-Javadoc)
                * @see java.lang.Runnable#run()
                */
                @Override
                public void run() {
                    try {
                        getSite().getPage().showView(HistoricalGraphView.ID, sb.toString(), IWorkbenchPage.VIEW_ACTIVATE);
                    } catch (PartInitException e) {
                        MessageDialogHelper.openError(getSite().getShell(), "Error", String.format("Error opening view: %s", e.getLocalizedMessage()));
                    }
                }
            });
        }

        /* (non-Javadoc)
          * @see org.netxms.ui.eclipse.jobs.ConsoleJob#getErrorMessage()
          */
        @Override
        protected String getErrorMessage() {
            return "Cannot open dci link historical graph view";
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DciValue(org.netxms.client.datacollection.DciValue) SimpleDciValue(org.netxms.client.datacollection.SimpleDciValue) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) SimpleDciValue(org.netxms.client.datacollection.SimpleDciValue) PartInitException(org.eclipse.ui.PartInitException) NetworkMapLink(org.netxms.client.maps.NetworkMapLink) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException)

Example 17 with DciValue

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

the class LinkDciValueProvider method getDciDataAsString.

/**
 * @param DCIList
 * @return
 */
public String getDciDataAsString(List<SingleDciConfig> DCIList) {
    // $NON-NLS-1$
    String result = "";
    for (int i = 0; i < DCIList.size(); ) {
        DciValue v = getDciLastValue(DCIList.get(i).dciId);
        if (v != null) {
            String formatString = DCIList.get(i).getFormatString();
            // $NON-NLS-1$
            result += v.format(formatString.isEmpty() ? "%s" : formatString);
        }
        if (++i != DCIList.size())
            // $NON-NLS-1$
            result += "\n";
    }
    return result;
}
Also used : DciValue(org.netxms.client.datacollection.DciValue)

Example 18 with DciValue

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

the class LinkDciValueProvider method getDciDataAsString.

/**
 * @param link
 * @return
 */
public String getDciDataAsString(NetworkMapLink link) {
    if (!link.hasDciData())
        // $NON-NLS-1$
        return "";
    // $NON-NLS-1$
    String result = "";
    SingleDciConfig[] dciList = link.getDciList();
    for (int i = 0; i < dciList.length; ) {
        DciValue v = getDciLastValue(dciList[i].dciId);
        if (v != null) {
            String formatString = dciList[i].getFormatString();
            // $NON-NLS-1$
            result += v.format(formatString.isEmpty() ? "%s" : formatString);
        }
        if (++i != dciList.length)
            // $NON-NLS-1$
            result += "\n";
    }
    return result;
}
Also used : DciValue(org.netxms.client.datacollection.DciValue) SingleDciConfig(org.netxms.client.maps.configs.SingleDciConfig)

Example 19 with DciValue

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

the class DCIContainerDataSources method addItem.

/**
 * Add new item
 */
private void addItem() {
    SelectDciDialog dlg = new SelectDciDialog(getShell(), 0);
    if (dlg.open() == Window.OK) {
        List<DciValue> selection = dlg.getSelection();
        List<SingleDciConfig> select = new ArrayList<SingleDciConfig>();
        for (DciValue item : selection) {
            SingleDciConfig dci = new SingleDciConfig(item);
            select.add(dci);
            labelProvider.addCacheEntry(dci.getNodeId(), dci.dciId, dci.name);
            dciList.add(dci);
        }
        viewer.setInput(dciList.toArray());
        viewer.setSelection(new StructuredSelection(select));
    }
}
Also used : DciValue(org.netxms.client.datacollection.DciValue) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectDciDialog(org.netxms.ui.eclipse.datacollection.dialogs.SelectDciDialog) SingleDciConfig(org.netxms.client.maps.configs.SingleDciConfig)

Example 20 with DciValue

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

the class DCIImageFigure method paintFigure.

/* (non-Javadoc)
	 * @see org.eclipse.draw2d.Figure#paintFigure(org.eclipse.draw2d.Graphics)
	 */
@Override
protected void paintFigure(Graphics gc) {
    DciValue latDCIValue = dciValueProvider.getLastDciData(dciImageConfiguration.getDci());
    try {
        UUID guid = dciImageConfiguration.getCorrectImage(latDCIValue);
        Image image = ImageProvider.getInstance().getImage(guid);
        Rectangle rect = new Rectangle(getBounds());
        gc.drawImage(image, rect.x, rect.y);
    } catch (IllegalArgumentException e) {
    }
}
Also used : DciValue(org.netxms.client.datacollection.DciValue) Rectangle(org.eclipse.draw2d.geometry.Rectangle) UUID(java.util.UUID) Image(org.eclipse.swt.graphics.Image) NetworkMapDCIImage(org.netxms.client.maps.elements.NetworkMapDCIImage)

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