Search in sources :

Example 1 with ViewRefreshController

use of org.netxms.ui.eclipse.tools.ViewRefreshController in project netxms by netxms.

the class StatusIndicatorElement method startRefreshTimer.

/**
 * Start element refresh timer
 */
protected void startRefreshTimer() {
    refreshController = new ViewRefreshController(viewPart, 1, new Runnable() {

        @Override
        public void run() {
            if (StatusIndicatorElement.this.isDisposed())
                return;
            refreshData();
        }
    });
    refreshData();
}
Also used : ViewRefreshController(org.netxms.ui.eclipse.tools.ViewRefreshController)

Example 2 with ViewRefreshController

use of org.netxms.ui.eclipse.tools.ViewRefreshController in project netxms by netxms.

the class ComparisonChartElement method startRefreshTimer.

/**
 * Start refresh timer
 */
protected void startRefreshTimer() {
    refreshController = new ViewRefreshController(viewPart, refreshInterval, new Runnable() {

        @Override
        public void run() {
            if (ComparisonChartElement.this.isDisposed())
                return;
            refreshData(getDciList());
        }
    });
    refreshData(getDciList());
}
Also used : ViewRefreshController(org.netxms.ui.eclipse.tools.ViewRefreshController)

Example 3 with ViewRefreshController

use of org.netxms.ui.eclipse.tools.ViewRefreshController in project netxms by netxms.

the class DataComparisonView method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    switch(chartType) {
        case DataComparisonChart.BAR_CHART:
            chart = ChartFactory.createBarChart(parent, SWT.NONE);
            break;
        case DataComparisonChart.TUBE_CHART:
            chart = ChartFactory.createTubeChart(parent, SWT.NONE);
            break;
        case DataComparisonChart.PIE_CHART:
            chart = ChartFactory.createPieChart(parent, SWT.NONE);
            break;
    }
    chart.setLegendPosition(legendPosition);
    chart.setLegendVisible(showLegend);
    chart.set3DModeEnabled(showIn3D);
    chart.setTransposed(transposed);
    chart.setTranslucent(translucent);
    for (GraphItem item : items) chart.addParameter(item, 0);
    chart.initializationComplete();
    createActions();
    contributeToActionBars();
    createPopupMenu();
    updateChart();
    refreshController = new ViewRefreshController(this, autoRefreshEnabled ? autoRefreshInterval : -1, new Runnable() {

        @Override
        public void run() {
            if (((Widget) chart).isDisposed())
                return;
            updateChart();
        }
    });
}
Also used : Widget(org.eclipse.swt.widgets.Widget) GraphItem(org.netxms.client.datacollection.GraphItem) ViewRefreshController(org.netxms.ui.eclipse.tools.ViewRefreshController)

Example 4 with ViewRefreshController

use of org.netxms.ui.eclipse.tools.ViewRefreshController in project netxms by netxms.

the class HistoricalGraphView method init.

/*
    * (non-Javadoc)
    * 
    * @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite)
    */
@Override
public void init(IViewSite site) throws PartInitException {
    super.init(site);
    refreshController = new ViewRefreshController(this, -1, new Runnable() {

        @Override
        public void run() {
            if (((Widget) chart).isDisposed())
                return;
            updateChart();
        }
    });
    session = (NXCSession) ConsoleSharedData.getSession();
    settings.setTimeFrom(new Date(System.currentTimeMillis() - settings.getTimeRangeMillis()));
    settings.setTimeTo(new Date(System.currentTimeMillis()));
    // Extract DCI ids from view id
    // (first field will be unique view id, so we skip it)
    String id = site.getSecondaryId();
    // $NON-NLS-1$
    String[] fields = id.split("&");
    if (!fields[0].equals(PREDEFINED_GRAPH_SUBID)) {
        List<ChartDciConfig> items = new ArrayList<ChartDciConfig>();
        for (int i = 1; i < fields.length; i++) {
            // $NON-NLS-1$
            String[] subfields = fields[i].split("\\@");
            if (subfields.length == 0)
                continue;
            if (Integer.parseInt(subfields[0]) == ChartDciConfig.ITEM) {
                try {
                    ChartDciConfig dci = new ChartDciConfig();
                    dci.type = Integer.parseInt(subfields[0]);
                    dci.nodeId = Long.parseLong(subfields[1], 10);
                    dci.dciId = Long.parseLong(subfields[2], 10);
                    // $NON-NLS-1$
                    dci.name = URLDecoder.decode(subfields[3], "UTF-8");
                    // $NON-NLS-1$
                    dci.dciDescription = URLDecoder.decode(subfields[3], "UTF-8");
                    // $NON-NLS-1$
                    dci.dciName = URLDecoder.decode(subfields[4], "UTF-8");
                    // Extra fields
                    if (subfields.length >= 6)
                        dci.invertValues = (Integer.parseInt(subfields[5]) & GraphItemStyle.INVERTED) > 0 ? true : false;
                    if (subfields.length >= 7)
                        dci.area = Integer.parseInt(subfields[6]) == GraphItemStyle.AREA ? true : false;
                    if (subfields.length >= 8)
                        dci.color = "0x" + Integer.toHexString(Integer.parseInt(subfields[7]));
                    items.add(dci);
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
            } else if (Integer.parseInt(subfields[0]) == ChartDciConfig.TABLE) {
                try {
                    ChartDciConfig dci = new ChartDciConfig();
                    dci.type = Integer.parseInt(subfields[0]);
                    dci.nodeId = Long.parseLong(subfields[1], 10);
                    dci.dciId = Long.parseLong(subfields[2], 10);
                    // $NON-NLS-1$
                    dci.name = URLDecoder.decode(subfields[3], "UTF-8");
                    // $NON-NLS-1$
                    dci.dciName = URLDecoder.decode(subfields[3], "UTF-8");
                    // $NON-NLS-1$
                    dci.instance = URLDecoder.decode(subfields[4], "UTF-8");
                    // $NON-NLS-1$
                    dci.column = URLDecoder.decode(subfields[5], "UTF-8");
                    items.add(dci);
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
            }
        }
        // Set view title to "host name: dci description" if we have only one DCI
        if (items.size() == 1) {
            ChartDciConfig item = items.get(0);
            AbstractObject object = session.findObjectById(item.nodeId);
            if (object != null) {
                // $NON-NLS-1$
                setPartName(object.getObjectName() + ": " + item.name);
            }
        } else if (items.size() > 1) {
            long nodeId = items.get(0).nodeId;
            for (ChartDciConfig item : items) if (item.nodeId != nodeId) {
                nodeId = -1;
                break;
            }
            if (nodeId != -1) {
                // All DCIs from same node, set title to "host name"
                AbstractObject object = session.findObjectById(nodeId);
                if (object != null) {
                    setPartName(String.format(Messages.get().HistoricalGraphView_PartName, object.getObjectName()));
                }
            }
        }
        settings.setTitle(getPartName());
        settings.setDciList(items.toArray(new ChartDciConfig[items.size()]));
    }
}
Also used : ChartDciConfig(org.netxms.client.datacollection.ChartDciConfig) Widget(org.eclipse.swt.widgets.Widget) ArrayList(java.util.ArrayList) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Date(java.util.Date) AbstractObject(org.netxms.client.objects.AbstractObject) ViewRefreshController(org.netxms.ui.eclipse.tools.ViewRefreshController)

Example 5 with ViewRefreshController

use of org.netxms.ui.eclipse.tools.ViewRefreshController in project netxms by netxms.

the class TableComparisonChartElement method startRefreshTimer.

/**
 * Start refresh timer
 */
protected void startRefreshTimer() {
    if ((config == null) || (config.getDataColumn() == null))
        // Invalid configuration
        return;
    refreshController = new ViewRefreshController(viewPart, config.getRefreshRate(), new Runnable() {

        @Override
        public void run() {
            if (TableComparisonChartElement.this.isDisposed())
                return;
            refreshData();
        }
    });
    refreshData();
}
Also used : ViewRefreshController(org.netxms.ui.eclipse.tools.ViewRefreshController)

Aggregations

ViewRefreshController (org.netxms.ui.eclipse.tools.ViewRefreshController)5 Widget (org.eclipse.swt.widgets.Widget)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ChartDciConfig (org.netxms.client.datacollection.ChartDciConfig)1 GraphItem (org.netxms.client.datacollection.GraphItem)1 AbstractObject (org.netxms.client.objects.AbstractObject)1