Search in sources :

Example 21 with DciValue

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

the class ConditionData 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<ConditionDciInfo> select = new ArrayList<ConditionDciInfo>();
        for (DciValue item : selection) {
            ConditionDciInfo dci = new ConditionDciInfo(item.getNodeId(), item.getId(), item.getDcObjectType(), Threshold.F_LAST, 1);
            labelProvider.addCacheEntry(dci.getNodeId(), dci.getDciId(), item.getDescription());
            dciList.add(dci);
            select.add(dci);
            viewer.setInput(dciList.toArray());
            isModified = true;
            viewer.setSelection(new StructuredSelection(dci));
            editItem();
        }
        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) ConditionDciInfo(org.netxms.client.datacollection.ConditionDciInfo) SelectDciDialog(org.netxms.ui.eclipse.datacollection.dialogs.SelectDciDialog)

Example 22 with DciValue

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

the class DataSources 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<ChartDciConfig> select = new ArrayList<ChartDciConfig>();
        for (DciValue item : selection) {
            ChartDciConfig dci = new ChartDciConfig(item);
            labelProvider.addCacheEntry(dci.nodeId, dci.dciId, dci.name);
            select.add(dci);
            dciList.add(dci);
        }
        viewer.setInput(dciList.toArray());
        viewer.setSelection(new StructuredSelection(select));
    }
}
Also used : ChartDciConfig(org.netxms.client.datacollection.ChartDciConfig) 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)

Example 23 with DciValue

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

the class TemplateDataSources method importItem.

/**
 * Import new item
 */
private void importItem() {
    SelectDciDialog dlg = new SelectDciDialog(getShell(), 0);
    if (dlg.open() == Window.OK) {
        List<DciValue> selection = dlg.getSelection();
        List<ChartDciConfig> select = new ArrayList<ChartDciConfig>();
        for (DciValue item : selection) {
            ChartDciConfig dci = new ChartDciConfig(item);
            select.add(dci);
            dciList.add(dci);
        }
        viewer.setInput(dciList.toArray());
        viewer.setSelection(new StructuredSelection(select));
    }
}
Also used : ChartDciConfig(org.netxms.client.datacollection.ChartDciConfig) 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)

Example 24 with DciValue

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

the class ShowDataComparisonChart method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
@Override
public void run(IAction action) {
    if (currentSelection != null) {
        // $NON-NLS-1$
        String id = Long.toString(uniqueId++) + "&" + Integer.toString(getChartType());
        for (int i = 0; i < currentSelection.length; i++) {
            long dciId = 0, nodeId = 0;
            int source = 0;
            DataType dataType = DataType.INT32;
            String name = null, description = null;
            try {
                if (currentSelection[i] instanceof DciValue) {
                    dciId = ((DciValue) currentSelection[i]).getId();
                    nodeId = ((DciValue) currentSelection[i]).getNodeId();
                    source = ((DciValue) currentSelection[i]).getSource();
                    dataType = ((DciValue) currentSelection[i]).getDataType();
                    // $NON-NLS-1$
                    name = URLEncoder.encode(((DciValue) currentSelection[i]).getName(), "UTF-8");
                    // $NON-NLS-1$
                    description = URLEncoder.encode(((DciValue) currentSelection[i]).getDescription(), "UTF-8");
                } else if (currentSelection[i] instanceof DataCollectionItem) {
                    dciId = ((DataCollectionItem) currentSelection[i]).getId();
                    nodeId = ((DataCollectionItem) currentSelection[i]).getNodeId();
                    source = ((DataCollectionItem) currentSelection[i]).getOrigin();
                    dataType = ((DataCollectionItem) currentSelection[i]).getDataType();
                    // $NON-NLS-1$
                    name = URLEncoder.encode(((DataCollectionItem) currentSelection[i]).getName(), "UTF-8");
                    // $NON-NLS-1$
                    description = URLEncoder.encode(((DataCollectionItem) currentSelection[i]).getDescription(), "UTF-8");
                }
            } catch (UnsupportedEncodingException e) {
                description = Messages.get().ShowDataComparisonChart_DescriptionUnavailable;
            }
            id += // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
            "&" + Long.toString(nodeId) + "@" + Long.toString(dciId) + "@" + Integer.toString(source) + "@" + Integer.toString(dataType.getValue()) + "@" + name + "@" + // $NON-NLS-1$ //$NON-NLS-2$
            description;
        }
        try {
            window.getActivePage().showView(DataComparisonView.ID, id, IWorkbenchPage.VIEW_ACTIVATE);
        } catch (PartInitException e) {
            MessageDialogHelper.openError(window.getShell(), Messages.get().ShowDataComparisonChart_Error, String.format(Messages.get().ShowDataComparisonChart_ErrorOpeningView, e.getMessage()));
        } catch (IllegalArgumentException e) {
            MessageDialogHelper.openError(window.getShell(), Messages.get().ShowDataComparisonChart_14, String.format(Messages.get().ShowDataComparisonChart_15, e.getMessage()));
        }
    }
}
Also used : DciValue(org.netxms.client.datacollection.DciValue) DataCollectionItem(org.netxms.client.datacollection.DataCollectionItem) DataType(org.netxms.client.constants.DataType) UnsupportedEncodingException(java.io.UnsupportedEncodingException) PartInitException(org.eclipse.ui.PartInitException)

Example 25 with DciValue

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

the class LastValues method createClientArea.

/* (non-Javadoc)
    * @see org.netxms.ui.eclipse.objectview.objecttabs.elements.OverviewPageElement#createClientArea(org.eclipse.swt.widgets.Composite)
    */
@Override
protected Control createClientArea(Composite parent) {
    viewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.HIDE_SELECTION | SWT.H_SCROLL | SWT.MULTI);
    setupTable();
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new OverviewDciLabelProvider());
    viewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            return ((DciValue) e1).getDescription().compareToIgnoreCase(((DciValue) e2).getDescription());
        }
    });
    viewer.setInput(((DataCollectionTarget) getObject()).getOverviewDciData().toArray());
    viewer.getTable().getColumn(0).pack();
    viewer.getTable().getColumn(1).pack();
    createPopupMenu();
    refreshController.setInterval(30);
    refresh();
    return viewer.getTable();
}
Also used : OverviewDciLabelProvider(org.netxms.ui.eclipse.objectview.objecttabs.helpers.OverviewDciLabelProvider) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) DataCollectionTarget(org.netxms.client.objects.DataCollectionTarget) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) DciValue(org.netxms.client.datacollection.DciValue) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) AbstractObject(org.netxms.client.objects.AbstractObject) TableViewer(org.eclipse.jface.viewers.TableViewer)

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