Search in sources :

Example 16 with GraphSettings

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

the class PredefinedGraphTree method notificationHandler.

/* (non-Javadoc)
    * @see org.netxms.api.client.SessionListener#notificationHandler(org.netxms.api.client.SessionNotification)
    */
@Override
public void notificationHandler(final SessionNotification n) {
    switch(n.getCode()) {
        case SessionNotification.PREDEFINED_GRAPHS_DELETED:
            viewer.getControl().getDisplay().asyncExec(new Runnable() {

                @SuppressWarnings("unchecked")
                @Override
                public void run() {
                    List<GraphSettings> list = (List<GraphSettings>) viewer.getInput();
                    for (int i = 0; i < list.size(); i++) if (list.get(i).getId() == n.getSubCode()) {
                        Object o = list.get(i);
                        list.remove(o);
                        viewer.refresh();
                        break;
                    }
                }
            });
            break;
        case SessionNotification.PREDEFINED_GRAPHS_CHANGED:
            if (((GraphSettings) n.getObject()).isTemplate())
                return;
            viewer.getControl().getDisplay().asyncExec(new Runnable() {

                @SuppressWarnings("unchecked")
                @Override
                public void run() {
                    final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
                    final List<GraphSettings> list = (List<GraphSettings>) viewer.getInput();
                    boolean objectUpdated = false;
                    for (int i = 0; i < list.size(); i++) {
                        if (list.get(i).getId() == n.getSubCode()) {
                            list.set(i, (GraphSettings) n.getObject());
                            objectUpdated = true;
                            break;
                        }
                    }
                    if (!objectUpdated) {
                        list.add((GraphSettings) n.getObject());
                        viewer.setInput(list);
                    }
                    viewer.refresh();
                    if ((selection.size() == 1) && (selection.getFirstElement() instanceof GraphSettings)) {
                        GraphSettings element = (GraphSettings) selection.getFirstElement();
                        if (element.getId() == n.getSubCode())
                            viewer.setSelection(new StructuredSelection((GraphSettings) n.getObject()), true);
                    }
                }
            });
            break;
    }
}
Also used : GraphSettings(org.netxms.client.datacollection.GraphSettings) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 17 with GraphSettings

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

the class TemplateGraphView method notificationHandler.

/* (non-Javadoc)
    * @see org.netxms.api.client.SessionListener#notificationHandler(org.netxms.api.client.SessionNotification)
    */
@Override
public void notificationHandler(final SessionNotification n) {
    switch(n.getCode()) {
        case SessionNotification.PREDEFINED_GRAPHS_DELETED:
            viewer.getControl().getDisplay().asyncExec(new Runnable() {

                @Override
                public void run() {
                    for (int i = 0; i < graphList.size(); i++) if (graphList.get(i).getId() == n.getSubCode()) {
                        Object o = graphList.get(i);
                        graphList.remove(o);
                        viewer.setInput(graphList);
                        break;
                    }
                }
            });
            break;
        case SessionNotification.PREDEFINED_GRAPHS_CHANGED:
            viewer.getControl().getDisplay().asyncExec(new Runnable() {

                @Override
                public void run() {
                    if (!(n.getObject() instanceof GraphSettings)) {
                        return;
                    }
                    final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
                    boolean objectUpdated = false;
                    for (int i = 0; i < graphList.size(); i++) {
                        if (graphList.get(i).getId() == n.getSubCode()) {
                            graphList.set(i, (GraphSettings) n.getObject());
                            objectUpdated = true;
                            break;
                        }
                    }
                    if (!objectUpdated) {
                        if (((GraphSettings) n.getObject()).isTemplate())
                            graphList.add((GraphSettings) n.getObject());
                    }
                    viewer.setInput(graphList);
                    if (selection.size() == 1) {
                        if (selection.getFirstElement() instanceof GraphSettings) {
                            GraphSettings element = (GraphSettings) selection.getFirstElement();
                            if (element.getId() == n.getSubCode())
                                viewer.setSelection(new StructuredSelection((GraphSettings) n.getObject()), true);
                        }
                    }
                }
            });
            break;
    }
}
Also used : GraphSettings(org.netxms.client.datacollection.GraphSettings) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 18 with GraphSettings

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

the class General method applyChanges.

/**
 * Apply changes
 *
 * @param isApply true if update operation caused by "Apply" button
 */
protected void applyChanges(final boolean isApply) {
    config.setTitle(title.getText());
    config.setShowGrid(checkShowGrid.getSelection());
    config.setShowLegend(checkShowLegend.getSelection());
    config.setAutoScale(yAxisRange.isAuto());
    config.setShowHostNames(checkShowHostNames.getSelection());
    config.setAutoRefresh(checkAutoRefresh.getSelection());
    config.setLogScale(checkLogScale.getSelection());
    config.setRefreshRate(refreshIntervalSpinner.getSelection());
    config.setStacked(checkStacked.getSelection());
    config.setExtendedLegend(checkExtendedLegend.getSelection());
    config.setArea(checkAreaChart.getSelection());
    config.setLegendPosition((int) Math.pow(2, legendLocation.getSelectionIndex()));
    config.setTranslucent(checkTranslucent.getSelection());
    config.setLineWidth(lineWidth.getSelection());
    config.setTimeFrameType(timeSelector.getTimeFrameType());
    config.setTimeUnits(timeSelector.getTimeUnitValue());
    config.setTimeRange(timeSelector.getTimeRangeValue());
    config.setTimeFrom(timeSelector.getTimeFrom());
    config.setTimeTo(timeSelector.getTimeTo());
    config.setUseMultipliers(checkUseMultipliers.getSelection());
    config.setMinYScaleValue(yAxisRange.getMinY());
    config.setMaxYScaleValue(yAxisRange.getMaxY());
    config.setModifyYBase(yAxisRange.modifyYBase());
    if ((config instanceof GraphSettings) && isApply) {
        setValid(false);
        final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
        new ConsoleJob(Messages.get().General_JobName, null, Activator.PLUGIN_ID, null) {

            @Override
            protected void runInternal(IProgressMonitor monitor) throws Exception {
                session.saveGraph((GraphSettings) config, true);
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        General.this.setValid(true);
                    }
                });
            }

            @Override
            protected String getErrorMessage() {
                return Messages.get().General_JobError;
            }
        }.start();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) GraphSettings(org.netxms.client.datacollection.GraphSettings) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Aggregations

GraphSettings (org.netxms.client.datacollection.GraphSettings)18 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)8 NXCSession (org.netxms.client.NXCSession)5 PartInitException (org.eclipse.ui.PartInitException)4 ChartDciConfig (org.netxms.client.datacollection.ChartDciConfig)4 ArrayList (java.util.ArrayList)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 NXCException (org.netxms.client.NXCException)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 Action (org.eclipse.jface.action.Action)2 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)2 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 PropertyDialog (org.eclipse.ui.internal.dialogs.PropertyDialog)2