Search in sources :

Example 1 with DataCollectionTable

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

the class DataCollectionEditor method createTable.

/**
 * Create new data collection table
 */
private void createTable() {
    DataCollectionTable dci = new DataCollectionTable(dciConfig, 0);
    if ((object instanceof AbstractNode) && !((AbstractNode) object).hasAgent()) {
        if (((AbstractNode) object).hasSnmpAgent()) {
            dci.setOrigin(DataCollectionObject.SNMP);
        } else {
            dci.setOrigin(DataCollectionObject.INTERNAL);
        }
    }
    viewer.add(dci);
    viewer.setSelection(new StructuredSelection(dci), true);
    actionEdit.run();
}
Also used : AbstractNode(org.netxms.client.objects.AbstractNode) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) DataCollectionTable(org.netxms.client.datacollection.DataCollectionTable)

Example 2 with DataCollectionTable

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

the class DciLabelProvider method getColumnText.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
	 */
@Override
public String getColumnText(Object element, int columnIndex) {
    DataCollectionObject dci = (DataCollectionObject) element;
    switch(columnIndex) {
        case DataCollectionEditor.COLUMN_ID:
            return Long.toString(dci.getId());
        case DataCollectionEditor.COLUMN_ORIGIN:
            return originTexts.get(dci.getOrigin());
        case DataCollectionEditor.COLUMN_DESCRIPTION:
            return dci.getDescription();
        case DataCollectionEditor.COLUMN_PARAMETER:
            return dci.getName();
        case DataCollectionEditor.COLUMN_DATATYPE:
            if (dci instanceof DataCollectionItem)
                return DataCollectionDisplayInfo.getDataTypeName(((DataCollectionItem) dci).getDataType());
            return Messages.get().DciLabelProvider_Table;
        case DataCollectionEditor.COLUMN_INTERVAL:
            if (dci.isUseAdvancedSchedule())
                return Messages.get().DciLabelProvider_CustomSchedule;
            if (dci.getPollingInterval() <= 0)
                return Messages.get().DciLabelProvider_Default;
            return Integer.toString(dci.getPollingInterval());
        case DataCollectionEditor.COLUMN_RETENTION:
            if ((dci.getFlags() & DataCollectionItem.DCF_NO_STORAGE) != 0)
                return Messages.get().DciLabelProvider_None;
            int days = dci.getRetentionTime();
            if (days <= 0)
                return Messages.get().DciLabelProvider_Default;
            return Integer.toString(days) + ((days == 1) ? Messages.get().DciLabelProvider_Day : Messages.get().DciLabelProvider_Days);
        case DataCollectionEditor.COLUMN_STATUS:
            return statusTexts.get(dci.getStatus());
        case DataCollectionEditor.COLUMN_THRESHOLD:
            StringBuilder thresholds = new StringBuilder();
            if ((dci instanceof DataCollectionItem)) {
                ArrayList<Threshold> list = ((DataCollectionItem) dci).getThresholds();
                for (int i = 0; i < list.size(); i++) {
                    Threshold tr = list.get(i);
                    int f = tr.getFunction();
                    StringBuilder text = new StringBuilder(ThresholdLabelProvider.FUNCTIONS[f]);
                    text.append(tr.getSampleCount());
                    // $NON-NLS-1$
                    text.append(") ");
                    if (f != Threshold.F_SCRIPT) {
                        text.append(ThresholdLabelProvider.OPERATIONS[tr.getOperation()]);
                        text.append(' ');
                        text.append(tr.getValue());
                    }
                    thresholds.append(text);
                    if (i < list.size() - 1)
                        // $NON-NLS-1$
                        thresholds.append(", ");
                }
            }
            if ((dci instanceof DataCollectionTable)) {
                List<TableThreshold> list = ((DataCollectionTable) dci).getThresholds();
                for (int i = 0; i < list.size(); i++) {
                    thresholds.append(list.get(i).getConditionAsText());
                    if (i + 1 != list.size())
                        // $NON-NLS-1$
                        thresholds.append(", ");
                }
            }
            return thresholds.toString();
        case DataCollectionEditor.COLUMN_TEMPLATE:
            if (dci.getTemplateId() == 0)
                return null;
            AbstractObject object = session.findObjectById(dci.getTemplateId());
            if (object == null)
                return Messages.get().DciLabelProvider_Unknown;
            if (!(object instanceof Template))
                return object.getObjectName();
            Set<AbstractObject> parents = object.getAllParents(null);
            StringBuilder sb = new StringBuilder();
            for (AbstractObject parent : parents) {
                sb.append(parent.getObjectName());
                // $NON-NLS-1$
                sb.append("/");
            }
            sb.append(object.getObjectName());
            return sb.toString();
    }
    return null;
}
Also used : DataCollectionObject(org.netxms.client.datacollection.DataCollectionObject) AbstractObject(org.netxms.client.objects.AbstractObject) DataCollectionItem(org.netxms.client.datacollection.DataCollectionItem) TableThreshold(org.netxms.client.datacollection.TableThreshold) DataCollectionTable(org.netxms.client.datacollection.DataCollectionTable) Threshold(org.netxms.client.datacollection.Threshold) TableThreshold(org.netxms.client.datacollection.TableThreshold) Template(org.netxms.client.objects.Template)

Aggregations

DataCollectionTable (org.netxms.client.datacollection.DataCollectionTable)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 DataCollectionItem (org.netxms.client.datacollection.DataCollectionItem)1 DataCollectionObject (org.netxms.client.datacollection.DataCollectionObject)1 TableThreshold (org.netxms.client.datacollection.TableThreshold)1 Threshold (org.netxms.client.datacollection.Threshold)1 AbstractNode (org.netxms.client.objects.AbstractNode)1 AbstractObject (org.netxms.client.objects.AbstractObject)1 Template (org.netxms.client.objects.Template)1