Search in sources :

Example 36 with AbstractNode

use of org.netxms.client.objects.AbstractNode in project netxms by netxms.

the class OpenAgentConfig method selectionChanged.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
	 */
@Override
public void selectionChanged(IAction action, ISelection selection) {
    if ((selection instanceof IStructuredSelection) && (((IStructuredSelection) selection).size() == 1)) {
        Object obj = ((IStructuredSelection) selection).getFirstElement();
        if ((obj instanceof AbstractNode) && ((AbstractNode) obj).hasAgent()) {
            action.setEnabled(true);
            nodeId = ((AbstractObject) obj).getObjectId();
        } else {
            action.setEnabled(false);
            nodeId = 0;
        }
    } else {
        action.setEnabled(false);
        nodeId = 0;
    }
}
Also used : AbstractNode(org.netxms.client.objects.AbstractNode) AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 37 with AbstractNode

use of org.netxms.client.objects.AbstractNode 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 38 with AbstractNode

use of org.netxms.client.objects.AbstractNode in project netxms by netxms.

the class ClusterOptions method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    Composite dialogArea = (Composite) super.createContents(parent);
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    owner = session.findObjectById(editor.getObject().getNodeId());
    if (owner instanceof Cluster) {
        cluster = (Cluster) owner;
    } else if (owner instanceof AbstractNode) {
        for (AbstractObject o : owner.getParentsAsArray()) {
            if (o instanceof Cluster) {
                cluster = (Cluster) o;
                break;
            }
        }
    }
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
    layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    clusterResource = WidgetHelper.createLabeledCombo(dialogArea, SWT.BORDER | SWT.READ_ONLY, Messages.get().General_ClRes, WidgetHelper.DEFAULT_LAYOUT_DATA);
    if (cluster != null) {
        clusterResourceMap = new HashMap<Integer, Long>();
        clusterResourceMap.put(0, 0L);
        clusterResource.add(Messages.get().General_None);
        if (editor.getObject().getResourceId() == 0)
            clusterResource.select(0);
        int index = 1;
        for (ClusterResource r : cluster.getResources()) {
            clusterResource.add(r.getName());
            clusterResourceMap.put(index, r.getId());
            if (editor.getObject().getResourceId() == r.getId())
                clusterResource.select(index);
            index++;
        }
    } else {
        clusterResource.add(Messages.get().General_None);
        clusterResource.select(0);
        clusterResource.setEnabled(false);
    }
    Group aggregationGroup = new Group(dialogArea, SWT.NONE);
    aggregationGroup.setText(Messages.get().ClusterOptions_DataAggregation);
    aggregationGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
    layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
    aggregationGroup.setLayout(layout);
    checkAggregate = new Button(aggregationGroup, SWT.CHECK);
    checkAggregate.setText(Messages.get().ClusterOptions_AggregateFromNodes);
    checkAggregate.setSelection(editor.getObject().isAggregateOnCluster());
    checkAggregateWithErrors = new Button(aggregationGroup, SWT.CHECK);
    checkAggregateWithErrors.setText("Use last known value for aggregation in case of data collection error");
    checkAggregateWithErrors.setSelection(editor.getObject().isAggregateWithErrors());
    checkRunScript = new Button(aggregationGroup, SWT.CHECK);
    checkRunScript.setText(Messages.get().ClusterOptions_RunScriptOnAggregatedData);
    checkRunScript.setSelection(editor.getObject().isTransformAggregated());
    if (editor.getObject() instanceof DataCollectionItem) {
        checkAggregate.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                aggregationFunction.setEnabled(checkAggregate.getSelection());
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
                widgetSelected(e);
            }
        });
        aggregationFunction = WidgetHelper.createLabeledCombo(aggregationGroup, SWT.BORDER | SWT.READ_ONLY, Messages.get().ClusterOptions_AggrFunction, WidgetHelper.DEFAULT_LAYOUT_DATA);
        aggregationFunction.add(Messages.get().ClusterOptions_Total);
        aggregationFunction.add(Messages.get().ClusterOptions_Average);
        aggregationFunction.add(Messages.get().ClusterOptions_Min);
        aggregationFunction.add(Messages.get().ClusterOptions_Max);
        aggregationFunction.select(editor.getObjectAsItem().getAggregationFunction());
        aggregationFunction.setEnabled(editor.getObjectAsItem().isAggregateOnCluster());
    }
    return dialogArea;
}
Also used : Group(org.eclipse.swt.widgets.Group) NXCSession(org.netxms.client.NXCSession) Composite(org.eclipse.swt.widgets.Composite) AbstractNode(org.netxms.client.objects.AbstractNode) Cluster(org.netxms.client.objects.Cluster) ClusterResource(org.netxms.client.objects.ClusterResource) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) AbstractObject(org.netxms.client.objects.AbstractObject) GridData(org.eclipse.swt.layout.GridData) DataCollectionItem(org.netxms.client.datacollection.DataCollectionItem) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 39 with AbstractNode

use of org.netxms.client.objects.AbstractNode in project netxms by netxms.

the class GeneralTable method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    Composite dialogArea = (Composite) super.createContents(parent);
    dci = editor.getObjectAsTable();
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    owner = session.findObjectById(dci.getNodeId());
    if (owner instanceof Cluster) {
        cluster = (Cluster) owner;
    } else if (owner instanceof AbstractNode) {
        for (AbstractObject o : owner.getParentsAsArray()) {
            if (o instanceof Cluster) {
                cluster = (Cluster) o;
                break;
            }
        }
    }
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.numColumns = 2;
    dialogArea.setLayout(layout);
    /**
     * description area *
     */
    Group groupDescription = new Group(dialogArea, SWT.NONE);
    groupDescription.setText(Messages.get().GeneralTable_Description);
    FillLayout descriptionLayout = new FillLayout();
    descriptionLayout.marginWidth = WidgetHelper.OUTER_SPACING;
    descriptionLayout.marginHeight = WidgetHelper.OUTER_SPACING;
    groupDescription.setLayout(descriptionLayout);
    description = new Text(groupDescription, SWT.BORDER);
    description.setTextLimit(255);
    description.setText(dci.getDescription());
    GridData gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.horizontalSpan = 2;
    groupDescription.setLayoutData(gd);
    /**
     * data area *
     */
    Group groupData = new Group(dialogArea, SWT.NONE);
    groupData.setText(Messages.get().GeneralTable_Data);
    FormLayout dataLayout = new FormLayout();
    dataLayout.marginHeight = WidgetHelper.OUTER_SPACING;
    dataLayout.marginWidth = WidgetHelper.OUTER_SPACING;
    groupData.setLayout(dataLayout);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.horizontalSpan = 2;
    groupData.setLayoutData(gd);
    parameter = new LabeledText(groupData, SWT.NONE);
    parameter.setLabel(Messages.get().GeneralTable_Parameter);
    parameter.getTextControl().setTextLimit(255);
    parameter.setText(dci.getName());
    selectButton = new Button(groupData, SWT.PUSH);
    selectButton.setText(Messages.get().GeneralTable_Select);
    selectButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            selectParameter();
        }
    });
    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(0, 0);
    fd.right = new FormAttachment(selectButton, -WidgetHelper.INNER_SPACING, SWT.LEFT);
    parameter.setLayoutData(fd);
    fd = new FormData();
    fd.right = new FormAttachment(100, 0);
    fd.bottom = new FormAttachment(parameter, 0, SWT.BOTTOM);
    fd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    selectButton.setLayoutData(fd);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(parameter, WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
    fd.right = new FormAttachment(50, -WidgetHelper.OUTER_SPACING / 2);
    origin = WidgetHelper.createLabeledCombo(groupData, SWT.READ_ONLY, Messages.get().GeneralTable_Origin, fd);
    origin.add(Messages.get().General_SourceInternal);
    origin.add(Messages.get().General_SourceAgent);
    origin.add(Messages.get().General_SourceSNMP);
    origin.add(Messages.get().General_SourceCPSNMP);
    origin.add(Messages.get().General_SourcePush);
    origin.add(Messages.get().General_WinPerf);
    origin.add(Messages.get().General_SMCLP);
    origin.add(Messages.get().General_Script);
    origin.add(Messages.get().General_SourceSSH);
    origin.add(Messages.get().General_SourceMQTT);
    origin.select(dci.getOrigin());
    origin.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            onOriginChange();
        }
    });
    checkUseCustomSnmpPort = new Button(groupData, SWT.CHECK);
    checkUseCustomSnmpPort.setText(Messages.get().GeneralTable_UseCustomSNMPPort);
    checkUseCustomSnmpPort.setSelection(dci.getSnmpPort() != 0);
    checkUseCustomSnmpPort.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            customSnmpPort.setEnabled(checkUseCustomSnmpPort.getSelection());
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    fd = new FormData();
    fd.left = new FormAttachment(origin.getParent(), WidgetHelper.OUTER_SPACING, SWT.RIGHT);
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(parameter, WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
    checkUseCustomSnmpPort.setLayoutData(fd);
    checkUseCustomSnmpPort.setEnabled(dci.getOrigin() == DataCollectionObject.SNMP);
    customSnmpPort = new Spinner(groupData, SWT.BORDER);
    customSnmpPort.setMinimum(1);
    customSnmpPort.setMaximum(65535);
    if ((dci.getOrigin() == DataCollectionItem.SNMP) && (dci.getSnmpPort() != 0)) {
        customSnmpPort.setEnabled(true);
        customSnmpPort.setSelection(dci.getSnmpPort());
    } else {
        customSnmpPort.setEnabled(false);
    }
    fd = new FormData();
    fd.left = new FormAttachment(origin.getParent(), WidgetHelper.OUTER_SPACING, SWT.RIGHT);
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(checkUseCustomSnmpPort, WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
    customSnmpPort.setLayoutData(fd);
    sourceNode = new ObjectSelector(groupData, SWT.NONE, true);
    sourceNode.setLabel(Messages.get().GeneralTable_ProxyNode);
    sourceNode.setObjectClass(Node.class);
    sourceNode.setObjectId(dci.getSourceNode());
    sourceNode.setEnabled(dci.getOrigin() != DataCollectionObject.PUSH);
    sourceNode.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            editor.setSourceNode(sourceNode.getObjectId());
        }
    });
    fd = new FormData();
    fd.top = new FormAttachment(origin.getParent(), WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
    fd.right = new FormAttachment(100, 0);
    agentCacheMode = WidgetHelper.createLabeledCombo(groupData, SWT.READ_ONLY, Messages.get().GeneralTable_AgentCacheMode, fd);
    agentCacheMode.add(Messages.get().GeneralTable_Default);
    agentCacheMode.add(Messages.get().GeneralTable_On);
    agentCacheMode.add(Messages.get().GeneralTable_Off);
    agentCacheMode.select(dci.getCacheMode().getValue());
    agentCacheMode.setEnabled((dci.getOrigin() == DataCollectionItem.AGENT) || (dci.getOrigin() == DataCollectionItem.SNMP));
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(origin.getParent(), WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
    fd.right = new FormAttachment(agentCacheMode.getParent(), -WidgetHelper.OUTER_SPACING, SWT.LEFT);
    sourceNode.setLayoutData(fd);
    /**
     * polling area *
     */
    Group groupPolling = new Group(dialogArea, SWT.NONE);
    groupPolling.setText(Messages.get().GeneralTable_Polling);
    FormLayout pollingLayout = new FormLayout();
    pollingLayout.marginHeight = WidgetHelper.OUTER_SPACING;
    pollingLayout.marginWidth = WidgetHelper.OUTER_SPACING;
    groupPolling.setLayout(pollingLayout);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    groupPolling.setLayoutData(gd);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(50, -WidgetHelper.OUTER_SPACING / 2);
    fd.top = new FormAttachment(0, 0);
    schedulingMode = WidgetHelper.createLabeledCombo(groupPolling, SWT.READ_ONLY, Messages.get().GeneralTable_PollingMode, fd);
    schedulingMode.add(Messages.get().General_FixedIntervalsDefault);
    schedulingMode.add(Messages.get().General_FixedIntervalsCustom);
    schedulingMode.add(Messages.get().General_CustomSchedule);
    schedulingMode.select(dci.isUseAdvancedSchedule() ? 2 : ((dci.getPollingInterval() > 0) ? 1 : 0));
    schedulingMode.setEnabled(dci.getOrigin() != DataCollectionObject.PUSH);
    schedulingMode.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            pollingInterval.setEnabled(schedulingMode.getSelectionIndex() == 1);
        }
    });
    pollingInterval = new LabeledSpinner(groupPolling, SWT.NONE);
    pollingInterval.setLabel(Messages.get().General_PollingInterval);
    pollingInterval.setRange(1, 99999);
    pollingInterval.setSelection((dci.getPollingInterval() > 0) ? dci.getPollingInterval() : ConsoleSharedData.getSession().getDefaultDciPollingInterval());
    pollingInterval.setEnabled(!dci.isUseAdvancedSchedule() && (dci.getPollingInterval() > 0) && (dci.getOrigin() != DataCollectionItem.PUSH));
    fd = new FormData();
    fd.left = new FormAttachment(50, WidgetHelper.OUTER_SPACING / 2);
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(0, 0);
    pollingInterval.setLayoutData(fd);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(schedulingMode.getParent(), WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
    clusterResource = WidgetHelper.createLabeledCombo(groupPolling, SWT.READ_ONLY, Messages.get().GeneralTable_ClRes, fd);
    if (cluster != null) {
        clusterResourceMap = new HashMap<Integer, Long>();
        clusterResourceMap.put(0, 0L);
        clusterResource.add(Messages.get().GeneralTable_None);
        if (dci.getResourceId() == 0)
            clusterResource.select(0);
        int index = 1;
        for (ClusterResource r : cluster.getResources()) {
            clusterResource.add(r.getName());
            clusterResourceMap.put(index, r.getId());
            if (dci.getResourceId() == r.getId())
                clusterResource.select(index);
            index++;
        }
    } else {
        clusterResource.add(Messages.get().GeneralTable_None);
        clusterResource.select(0);
        clusterResource.setEnabled(false);
    }
    /**
     * status *
     */
    Group groupStatus = new Group(dialogArea, SWT.NONE);
    groupStatus.setText(Messages.get().GeneralTable_Status);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    groupStatus.setLayoutData(gd);
    RowLayout statusLayout = new RowLayout();
    statusLayout.type = SWT.VERTICAL;
    groupStatus.setLayout(statusLayout);
    statusActive = new Button(groupStatus, SWT.RADIO);
    statusActive.setText(Messages.get().GeneralTable_Active);
    statusActive.setSelection(dci.getStatus() == DataCollectionObject.ACTIVE);
    statusDisabled = new Button(groupStatus, SWT.RADIO);
    statusDisabled.setText(Messages.get().GeneralTable_Disabled);
    statusDisabled.setSelection(dci.getStatus() == DataCollectionObject.DISABLED);
    statusUnsupported = new Button(groupStatus, SWT.RADIO);
    statusUnsupported.setText(Messages.get().GeneralTable_NotSupported);
    statusUnsupported.setSelection(dci.getStatus() == DataCollectionObject.NOT_SUPPORTED);
    /**
     * storage *
     */
    Group groupStorage = new Group(dialogArea, SWT.NONE);
    groupStorage.setText(Messages.get().GeneralTable_Storage);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.horizontalSpan = 2;
    groupStorage.setLayoutData(gd);
    GridLayout storageLayout = new GridLayout();
    storageLayout.numColumns = 2;
    storageLayout.horizontalSpacing = WidgetHelper.OUTER_SPACING;
    groupStorage.setLayout(storageLayout);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    retentionMode = WidgetHelper.createLabeledCombo(groupStorage, SWT.READ_ONLY, Messages.get().GeneralTable_RetentionMode, gd);
    retentionMode.add(Messages.get().GeneralTable_UseDefaultRetention);
    retentionMode.add(Messages.get().GeneralTable_UseCustomRetention);
    retentionMode.add(Messages.get().GeneralTable_NoStorage);
    retentionMode.select(((dci.getFlags() & DataCollectionObject.DCF_NO_STORAGE) != 0) ? 2 : ((dci.getRetentionTime() > 0) ? 1 : 0));
    retentionMode.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            int mode = retentionMode.getSelectionIndex();
            retentionTime.setEnabled(mode == 1);
        }
    });
    retentionTime = new LabeledSpinner(groupStorage, SWT.NONE);
    retentionTime.setLabel(Messages.get().GeneralTable_RetentionTime);
    retentionTime.setRange(1, 99999);
    retentionTime.setSelection((dci.getRetentionTime() > 0) ? dci.getRetentionTime() : ConsoleSharedData.getSession().getDefaultDciRetentionTime());
    retentionTime.setEnabled(((dci.getFlags() & DataCollectionObject.DCF_NO_STORAGE) == 0) && (dci.getRetentionTime() > 0));
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    retentionTime.setLayoutData(gd);
    return dialogArea;
}
Also used : Group(org.eclipse.swt.widgets.Group) NXCSession(org.netxms.client.NXCSession) ModifyListener(org.eclipse.swt.events.ModifyListener) AbstractNode(org.netxms.client.objects.AbstractNode) Spinner(org.eclipse.swt.widgets.Spinner) LabeledSpinner(org.netxms.ui.eclipse.widgets.LabeledSpinner) LabeledSpinner(org.netxms.ui.eclipse.widgets.LabeledSpinner) ClusterResource(org.netxms.client.objects.ClusterResource) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) Cluster(org.netxms.client.objects.Cluster) Text(org.eclipse.swt.widgets.Text) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) FillLayout(org.eclipse.swt.layout.FillLayout) ObjectSelector(org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector) AbstractObject(org.netxms.client.objects.AbstractObject) GridData(org.eclipse.swt.layout.GridData) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 40 with AbstractNode

use of org.netxms.client.objects.AbstractNode in project netxms by netxms.

the class ObjectPolling method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    Composite dialogArea = new Composite(parent, SWT.NONE);
    object = (PollingTarget) getElement().getAdapter(PollingTarget.class);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    GridData gd = new GridData();
    /* poller node */
    if (object.containPollerNode()) {
        Group servicePollGroup = new Group(dialogArea, SWT.NONE);
        servicePollGroup.setText(Messages.get().NodePolling_GroupNetSrv);
        layout = new GridLayout();
        layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
        layout.numColumns = 2;
        servicePollGroup.setLayout(layout);
        gd = new GridData();
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessHorizontalSpace = true;
        servicePollGroup.setLayoutData(gd);
        pollerNode = new ObjectSelector(servicePollGroup, SWT.NONE, true);
        pollerNode.setLabel(Messages.get().NodePolling_PollerNode);
        pollerNode.setObjectClass(AbstractNode.class);
        pollerNode.setEmptySelectionName(Messages.get().NodePolling_EmptySelectionServer);
        pollerNode.setObjectId(object.getPollerNodeId());
        gd = new GridData();
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessHorizontalSpace = true;
        pollerNode.setLayoutData(gd);
        Label label = new Label(servicePollGroup, SWT.WRAP);
        label.setText(Messages.get().NodePolling_PollerNodeDescription);
        gd = new GridData();
        gd.widthHint = 250;
        label.setLayoutData(gd);
    }
    /* poll count */
    if (object instanceof AbstractNode) {
        pollCount = new LabeledSpinner(dialogArea, SWT.NONE);
        pollCount.setLabel("Required poll count for status change");
        pollCount.setSelection(((AbstractNode) object).getRequredPollCount());
    }
    /* options */
    Group optionsGroup = new Group(dialogArea, SWT.NONE);
    optionsGroup.setText(Messages.get().NodePolling_GroupOptions);
    layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
    optionsGroup.setLayout(layout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    optionsGroup.setLayoutData(gd);
    if (object.containAgent())
        addFlag(optionsGroup, AbstractNode.NF_DISABLE_NXCP, Messages.get().NodePolling_OptDisableAgent);
    if (object.containInterfaces()) {
        addFlag(optionsGroup, AbstractNode.NF_DISABLE_SNMP, Messages.get().NodePolling_OptDisableSNMP);
        addFlag(optionsGroup, AbstractNode.NF_DISABLE_ICMP, Messages.get().NodePolling_OptDisableICMP);
    }
    addFlag(optionsGroup, AbstractNode.DCF_DISABLE_STATUS_POLL, Messages.get().NodePolling_OptDisableStatusPoll);
    addFlag(optionsGroup, AbstractNode.DCF_DISABLE_CONF_POLL, Messages.get().NodePolling_OptDisableConfigPoll);
    if (object.containInterfaces()) {
        addFlag(optionsGroup, AbstractNode.NF_DISABLE_ROUTE_POLL, Messages.get().NodePolling_OptDisableRTPoll);
        addFlag(optionsGroup, AbstractNode.NF_DISABLE_TOPOLOGY_POLL, Messages.get().NodePolling_OptDisableTopoPoll);
        addFlag(optionsGroup, AbstractNode.NF_DISABLE_DISCOVERY_POLL, Messages.get().NodePolling_OptDisableDiscoveryPoll);
    }
    addFlag(optionsGroup, AbstractNode.DCF_DISABLE_DATA_COLLECT, Messages.get().NodePolling_OptDisableDataCollection);
    /* use ifXTable */
    if (object.containInterfaces()) {
        Group ifXTableGroup = new Group(dialogArea, SWT.NONE);
        ifXTableGroup.setText(Messages.get().NodePolling_GroupIfXTable);
        layout = new GridLayout();
        layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
        layout.numColumns = 3;
        layout.makeColumnsEqualWidth = true;
        ifXTableGroup.setLayout(layout);
        gd = new GridData();
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessHorizontalSpace = true;
        ifXTableGroup.setLayoutData(gd);
        radioIfXTableDefault = new Button(ifXTableGroup, SWT.RADIO);
        radioIfXTableDefault.setText(Messages.get().NodePolling_Default);
        radioIfXTableDefault.setSelection(object.getIfXTablePolicy() == AbstractNode.IFXTABLE_DEFAULT);
        radioIfXTableEnable = new Button(ifXTableGroup, SWT.RADIO);
        radioIfXTableEnable.setText(Messages.get().NodePolling_Enable);
        radioIfXTableEnable.setSelection(object.getIfXTablePolicy() == AbstractNode.IFXTABLE_ENABLED);
        radioIfXTableDisable = new Button(ifXTableGroup, SWT.RADIO);
        radioIfXTableDisable.setText(Messages.get().NodePolling_Disable);
        radioIfXTableDisable.setSelection(object.getIfXTablePolicy() == AbstractNode.IFXTABLE_DISABLED);
    }
    /* agent cache */
    if (object.containAgent()) {
        Group agentCacheGroup = new Group(dialogArea, SWT.NONE);
        agentCacheGroup.setText(Messages.get().NodePolling_AgentCacheMode);
        layout = new GridLayout();
        layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
        layout.numColumns = 3;
        layout.makeColumnsEqualWidth = true;
        agentCacheGroup.setLayout(layout);
        gd = new GridData();
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessHorizontalSpace = true;
        agentCacheGroup.setLayoutData(gd);
        radioAgentCacheDefault = new Button(agentCacheGroup, SWT.RADIO);
        radioAgentCacheDefault.setText(Messages.get().NodePolling_Default);
        radioAgentCacheDefault.setSelection(object.getAgentCacheMode() == AgentCacheMode.DEFAULT);
        radioAgentCacheOn = new Button(agentCacheGroup, SWT.RADIO);
        radioAgentCacheOn.setText(Messages.get().NodePolling_On);
        radioAgentCacheOn.setSelection(object.getAgentCacheMode() == AgentCacheMode.ON);
        radioAgentCacheOff = new Button(agentCacheGroup, SWT.RADIO);
        radioAgentCacheOff.setText(Messages.get().NodePolling_Off);
        radioAgentCacheOff.setSelection(object.getAgentCacheMode() == AgentCacheMode.OFF);
    }
    return dialogArea;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) ObjectSelector(org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector) Composite(org.eclipse.swt.widgets.Composite) AbstractNode(org.netxms.client.objects.AbstractNode) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) LabeledSpinner(org.netxms.ui.eclipse.widgets.LabeledSpinner)

Aggregations

AbstractNode (org.netxms.client.objects.AbstractNode)47 AbstractObject (org.netxms.client.objects.AbstractObject)27 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)14 NXCSession (org.netxms.client.NXCSession)13 ArrayList (java.util.ArrayList)12 Cluster (org.netxms.client.objects.Cluster)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 Composite (org.eclipse.swt.widgets.Composite)6 PartInitException (org.eclipse.ui.PartInitException)6 MobileDevice (org.netxms.client.objects.MobileDevice)6 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)6 NXCException (org.netxms.client.NXCException)5 Interface (org.netxms.client.objects.Interface)5 Sensor (org.netxms.client.objects.Sensor)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 DataCollectionItem (org.netxms.client.datacollection.DataCollectionItem)4 Subnet (org.netxms.client.objects.Subnet)4 ISelection (org.eclipse.jface.viewers.ISelection)3