Search in sources :

Example 1 with ChartDciConfig

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

the class DataSources method drawColorCell.

/**
 * @param event
 */
private void drawColorCell(Event event) {
    TableItem item = (TableItem) event.item;
    ChartDciConfig dci = (ChartDciConfig) item.getData();
    if (dci.color.equalsIgnoreCase(ChartDciConfig.UNSET_COLOR))
        return;
    int width = viewer.getTable().getColumn(COLUMN_COLOR).getWidth();
    Color color = ColorConverter.colorFromInt(dci.getColorAsInt(), colorCache);
    event.gc.setForeground(colorCache.create(0, 0, 0));
    event.gc.setBackground(color);
    event.gc.setLineWidth(1);
    event.gc.fillRectangle(event.x + 3, event.y + 2, width - 7, event.height - 5);
    event.gc.drawRectangle(event.x + 3, event.y + 2, width - 7, event.height - 5);
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) ChartDciConfig(org.netxms.client.datacollection.ChartDciConfig) Color(org.eclipse.swt.graphics.Color)

Example 2 with ChartDciConfig

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

the class TemplateDataSources method drawColorCell.

/**
 * @param event
 */
private void drawColorCell(Event event) {
    TableItem item = (TableItem) event.item;
    ChartDciConfig dci = (ChartDciConfig) item.getData();
    if (dci.color.equalsIgnoreCase(ChartDciConfig.UNSET_COLOR))
        return;
    int width = viewer.getTable().getColumn(COLUMN_COLOR).getWidth();
    Color color = ColorConverter.colorFromInt(dci.getColorAsInt(), colorCache);
    event.gc.setForeground(colorCache.create(0, 0, 0));
    event.gc.setBackground(color);
    event.gc.setLineWidth(1);
    event.gc.fillRectangle(event.x + 3, event.y + 2, width - 7, event.height - 5);
    event.gc.drawRectangle(event.x + 3, event.y + 2, width - 7, event.height - 5);
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) ChartDciConfig(org.netxms.client.datacollection.ChartDciConfig) Color(org.eclipse.swt.graphics.Color)

Example 3 with ChartDciConfig

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

the class AbstractChartConfig method remapDataCollectionItems.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.dashboard.widgets.internal.DashboardElementConfig#remapDataCollectionItems(java.util.Map)
	 */
@Override
public void remapDataCollectionItems(Map<Long, DciIdMatchingData> remapData) {
    super.remapDataCollectionItems(remapData);
    for (ChartDciConfig dci : dciList) {
        DciIdMatchingData md = remapData.get(dci.dciId);
        if (md != null) {
            dci.dciId = md.dstDciId;
            dci.nodeId = md.dstNodeId;
        }
    }
}
Also used : ChartDciConfig(org.netxms.client.datacollection.ChartDciConfig) DciIdMatchingData(org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData)

Example 4 with ChartDciConfig

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

the class LineChartElement method refreshData.

/**
 * Refresh graph's data
 */
private void refreshData() {
    if (updateInProgress)
        return;
    updateInProgress = true;
    ConsoleJob job = new ConsoleJob(Messages.get().LineChartElement_JobTitle, viewPart, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {

        private ChartDciConfig currentDci;

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final Date from = new Date(System.currentTimeMillis() - config.getTimeRangeMillis());
            final Date to = new Date(System.currentTimeMillis());
            final ChartDciConfig[] dciList = config.getDciList();
            final DciData[] data = new DciData[dciList.length];
            for (int i = 0; i < dciList.length; i++) {
                currentDci = dciList[i];
                if (currentDci.type == ChartDciConfig.ITEM)
                    data[i] = session.getCollectedData(currentDci.nodeId, currentDci.dciId, from, to, 0, false);
                else
                    data[i] = session.getCollectedTableData(currentDci.nodeId, currentDci.dciId, currentDci.instance, currentDci.column, from, to, 0);
            }
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    if (!((Widget) chart).isDisposed()) {
                        dataCache.clear();
                        chart.setTimeRange(from, to);
                        for (int i = 0; i < data.length; i++) {
                            chart.updateParameter(i, data[i], false);
                            dataCache.add(new DataCacheElement(dciList[i], data[i]));
                        }
                        chart.refresh();
                        chart.clearErrors();
                    }
                    updateInProgress = false;
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().LineChartElement_JobError, session.getObjectName(currentDci.nodeId), currentDci.name);
        }

        @Override
        protected void jobFailureHandler() {
            updateInProgress = false;
            super.jobFailureHandler();
        }

        @Override
        protected IStatus createFailureStatus(final Exception e) {
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    // $NON-NLS-1$ //$NON-NLS-2$
                    chart.addError(getErrorMessage() + " (" + e.getLocalizedMessage() + ")");
                }
            });
            return Status.OK_STATUS;
        }
    };
    job.setUser(false);
    job.start();
}
Also used : ChartDciConfig(org.netxms.client.datacollection.ChartDciConfig) Widget(org.eclipse.swt.widgets.Widget) DciData(org.netxms.client.datacollection.DciData) Date(java.util.Date) Point(org.eclipse.swt.graphics.Point) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 5 with ChartDciConfig

use of org.netxms.client.datacollection.ChartDciConfig 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);
            select.add(dci);
            labelProvider.addCacheEntry(dci.nodeId, dci.dciId, dci.name);
            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)

Aggregations

ChartDciConfig (org.netxms.client.datacollection.ChartDciConfig)21 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 ArrayList (java.util.ArrayList)7 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)4 GraphSettings (org.netxms.client.datacollection.GraphSettings)4 DataSourceEditDlg (org.netxms.ui.eclipse.datacollection.dialogs.DataSourceEditDlg)4 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)4 Date (java.util.Date)3 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)3 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)3 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)3 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 SelectionListener (org.eclipse.swt.events.SelectionListener)3 Color (org.eclipse.swt.graphics.Color)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 RowData (org.eclipse.swt.layout.RowData)3