Search in sources :

Example 1 with Threshold

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

the class Thresholds method addThreshold.

/**
 * Add new threshold
 */
private void addThreshold() {
    Threshold threshold = new Threshold();
    EditThresholdDialog dlg = new EditThresholdDialog(getShell(), threshold);
    if (dlg.open() == Window.OK) {
        thresholds.add(threshold);
        thresholdList.setInput(thresholds.toArray());
        thresholdList.setSelection(new StructuredSelection(threshold));
    }
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) EditThresholdDialog(org.netxms.ui.eclipse.datacollection.dialogs.EditThresholdDialog) Threshold(org.netxms.client.datacollection.Threshold)

Example 2 with Threshold

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

the class Thresholds method moveUp.

/**
 * Move currently selected threshold up
 */
private void moveUp() {
    final IStructuredSelection selection = (IStructuredSelection) thresholdList.getSelection();
    if (selection.size() == 1) {
        final Threshold threshold = (Threshold) selection.getFirstElement();
        int index = thresholds.indexOf(threshold);
        if (index > 0) {
            Collections.swap(thresholds, index - 1, index);
            thresholdList.setInput(thresholds.toArray());
            thresholdList.setSelection(new StructuredSelection(threshold));
        }
    }
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Threshold(org.netxms.client.datacollection.Threshold)

Example 3 with Threshold

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

the class DataComparisonView method updateChart.

/**
 * Get DCI data from server
 */
private void updateChart() {
    if (updateInProgress)
        return;
    updateInProgress = true;
    ConsoleJob job = new ConsoleJob(Messages.get().DataComparisonView_JobName, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {

        @Override
        protected String getErrorMessage() {
            return Messages.get().DataComparisonView_JobError;
        }

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final double[] values = new double[items.size()];
            for (int i = 0; i < items.size(); i++) {
                GraphItem item = items.get(i);
                DciData data = (item.getType() == DataCollectionObject.DCO_TYPE_ITEM) ? session.getCollectedData(item.getNodeId(), item.getDciId(), null, null, 1, false) : session.getCollectedTableData(item.getNodeId(), item.getDciId(), item.getInstance(), item.getDataColumn(), null, null, 1);
                DciDataRow value = data.getLastValue();
                values[i] = (value != null) ? value.getValueAsDouble() : 0.0;
            }
            final Threshold[][] thresholds = new Threshold[items.size()][];
            if (chartType == DataComparisonChart.GAUGE_CHART) {
                for (int i = 0; i < items.size(); i++) {
                    GraphItem item = items.get(i);
                    thresholds[i] = session.getThresholds(item.getNodeId(), item.getDciId());
                }
            }
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    if (chartType == DataComparisonChart.GAUGE_CHART)
                        for (int i = 0; i < thresholds.length; i++) chart.updateParameterThresholds(i, thresholds[i]);
                    setChartData(values);
                    chart.clearErrors();
                    updateInProgress = false;
                }
            });
        }

        @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 : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DciDataRow(org.netxms.client.datacollection.DciDataRow) GraphItem(org.netxms.client.datacollection.GraphItem) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) DciData(org.netxms.client.datacollection.DciData) PartInitException(org.eclipse.ui.PartInitException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Threshold(org.netxms.client.datacollection.Threshold)

Example 4 with Threshold

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

the class HistoricalGraphView method getDataFromServer.

/**
 * Get DCI data from server
 */
private void getDataFromServer() {
    final ChartDciConfig[] dciList = settings.getDciList();
    // Request data from server
    ConsoleJob job = new ConsoleJob(Messages.get().HistoricalGraphView_JobName, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {

        private ChartDciConfig currentItem;

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            monitor.beginTask(getName(), dciList.length);
            final DciData[] data = new DciData[dciList.length];
            final Threshold[][] thresholds = new Threshold[dciList.length][];
            for (int i = 0; i < dciList.length; i++) {
                currentItem = dciList[i];
                if (currentItem.type == ChartDciConfig.ITEM) {
                    data[i] = session.getCollectedData(currentItem.nodeId, currentItem.dciId, settings.getTimeFrom(), settings.getTimeTo(), 0, false);
                    thresholds[i] = session.getThresholds(currentItem.nodeId, currentItem.dciId);
                } else {
                    data[i] = session.getCollectedTableData(currentItem.nodeId, currentItem.dciId, currentItem.instance, currentItem.column, settings.getTimeFrom(), settings.getTimeTo(), 0);
                    thresholds[i] = null;
                }
                monitor.worked(1);
            }
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    if (!((Widget) chart).isDisposed()) {
                        chart.setTimeRange(settings.getTimeFrom(), settings.getTimeTo());
                        setChartData(data);
                        chart.clearErrors();
                    }
                    updateInProgress = false;
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().HistoricalGraphView_JobError, session.getObjectName(currentItem.nodeId), currentItem.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) PartInitException(org.eclipse.ui.PartInitException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NXCException(org.netxms.client.NXCException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) Threshold(org.netxms.client.datacollection.Threshold)

Example 5 with Threshold

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

the class LastValuesAdapter method getView.

/*
	 * (non-Javadoc)
	 * 
	 * @see android.widget.Adapter#getView(int, android.view.View,
	 * android.view.ViewGroup)
	 */
@SuppressLint("RtlHardcoded")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    TextView threshold, date, name, value;
    CheckableLinearLayout view;
    LinearLayout texts, info, info2, icons;
    ImageView severity, state;
    Resources r = context.getResources();
    if (// new view, create fields
    convertView == null) {
        severity = new ImageView(context);
        severity.setPadding(5, 5, 5, 2);
        state = new ImageView(context);
        state.setPadding(5, 5, 5, 2);
        icons = new LinearLayout(context);
        icons.setOrientation(LinearLayout.VERTICAL);
        icons.addView(severity);
        icons.addView(state);
        threshold = new TextView(context);
        threshold.setPadding(5, 2, 5, 2);
        threshold.setTextColor(r.getColor(R.color.text_color));
        date = new TextView(context);
        date.setPadding(5, 2, 5, 2);
        date.setTextColor(r.getColor(R.color.text_color));
        date.setGravity(Gravity.RIGHT);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        lp.gravity = Gravity.RIGHT;
        date.setLayoutParams(lp);
        info = new LinearLayout(context);
        info.setOrientation(LinearLayout.HORIZONTAL);
        info.addView(threshold);
        info.addView(date);
        name = new TextView(context);
        name.setPadding(5, 2, 5, 2);
        name.setTextColor(r.getColor(R.color.text_color));
        name.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1));
        value = new TextView(context);
        value.setPadding(5, 2, 5, 2);
        value.setTextColor(r.getColor(R.color.text_color));
        value.setGravity(Gravity.RIGHT);
        lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 2);
        lp.gravity = Gravity.RIGHT;
        value.setLayoutParams(lp);
        info2 = new LinearLayout(context);
        info2.setOrientation(LinearLayout.HORIZONTAL);
        info2.addView(name);
        info2.addView(value);
        texts = new LinearLayout(context);
        texts.setOrientation(LinearLayout.VERTICAL);
        texts.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        texts.addView(info);
        texts.addView(info2);
        view = new CheckableLinearLayout(context);
        view.addView(icons);
        view.addView(texts);
    } else {
        // get reference to existing alarm
        view = (CheckableLinearLayout) convertView;
        icons = (LinearLayout) view.getChildAt(1);
        severity = (ImageView) icons.getChildAt(0);
        state = (ImageView) icons.getChildAt(1);
        texts = (LinearLayout) view.getChildAt(2);
        info = (LinearLayout) texts.getChildAt(0);
        threshold = (TextView) info.getChildAt(0);
        date = (TextView) info.getChildAt(1);
        info2 = (LinearLayout) texts.getChildAt(1);
        name = (TextView) info2.getChildAt(0);
        value = (TextView) info2.getChildAt(1);
    }
    // get node current name/value pair
    DciValue item = currentValues.get(position);
    if (item == null) {
        name.setText(r.getString(R.string.node_unknown));
        value.setText(r.getString(R.string.last_values_na));
    } else {
        Threshold t = item.getActiveThreshold();
        severity.setImageResource(getThresholdIcon(t));
        threshold.setText(getThresholdText(t));
        state.setImageResource(LastValuesAdapter.stateImageId[item.getStatus()]);
        date.setText(DateFormat.getDateTimeInstance().format(item.getTimestamp()));
        name.setText(item.getDescription());
        value.setText((item.getDcObjectType() == DataCollectionObject.DCO_TYPE_TABLE) ? r.getString(R.string.table_value_placeholder) : getFormattedValue(item));
    }
    return view;
}
Also used : CheckableLinearLayout(org.netxms.ui.android.main.views.CheckableLinearLayout) DciValue(org.netxms.client.datacollection.DciValue) TextView(android.widget.TextView) ImageView(android.widget.ImageView) Resources(android.content.res.Resources) LinearLayout(android.widget.LinearLayout) CheckableLinearLayout(org.netxms.ui.android.main.views.CheckableLinearLayout) Threshold(org.netxms.client.datacollection.Threshold) SuppressLint(android.annotation.SuppressLint)

Aggregations

Threshold (org.netxms.client.datacollection.Threshold)14 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 PartInitException (org.eclipse.ui.PartInitException)2 NXCPMessage (org.netxms.base.NXCPMessage)2 DataCollectionItem (org.netxms.client.datacollection.DataCollectionItem)2 DciData (org.netxms.client.datacollection.DciData)2 EventTemplate (org.netxms.client.events.EventTemplate)2 AccessPoint (org.netxms.client.objects.AccessPoint)2 ConnectionPoint (org.netxms.client.topology.ConnectionPoint)2 EditThresholdDialog (org.netxms.ui.eclipse.datacollection.dialogs.EditThresholdDialog)2 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)2 SuppressLint (android.annotation.SuppressLint)1 Resources (android.content.res.Resources)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 ArrayList (java.util.ArrayList)1