Search in sources :

Example 81 with LabeledText

use of org.netxms.ui.eclipse.widgets.LabeledText in project netxms by netxms.

the class LoginSettingsDialog method createDialogArea.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 */
protected Control createDialogArea(Composite parent) {
    final Composite dialogArea = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout();
    layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
    dialogArea.setLayout(layout);
    serverAddress = new LabeledText(dialogArea, SWT.NONE);
    serverAddress.setLabel(Messages.get().LoginSettingsDialog_ServerAddress);
    // $NON-NLS-1$ //$NON-NLS-2$
    serverAddress.setText(properties.getProperty("server", "127.0.0.1"));
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.widthHint = 300;
    serverAddress.setLayoutData(gd);
    return dialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) GridData(org.eclipse.swt.layout.GridData)

Example 82 with LabeledText

use of org.netxms.ui.eclipse.widgets.LabeledText in project netxms by netxms.

the class SendSMSDialog method createDialogArea.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite dialogArea = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout();
    layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    dialogArea.setLayout(layout);
    numberField = new LabeledText(dialogArea, SWT.NONE);
    numberField.setLabel(Messages.get().SendSMSDialog_PhoneNumber);
    numberField.setText(phoneNumber);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.widthHint = 300;
    numberField.setLayoutData(gd);
    messageField = new LabeledText(dialogArea, SWT.NONE);
    messageField.setLabel(Messages.get().SendSMSDialog_Message);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    messageField.setLayoutData(gd);
    if ((phoneNumber != null) && !phoneNumber.isEmpty())
        messageField.getTextControl().setFocus();
    return dialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) GridData(org.eclipse.swt.layout.GridData)

Example 83 with LabeledText

use of org.netxms.ui.eclipse.widgets.LabeledText 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 84 with LabeledText

use of org.netxms.ui.eclipse.widgets.LabeledText in project netxms by netxms.

the class InstanceDiscovery 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);
    editor = (DataCollectionObjectEditor) getElement().getAdapter(DataCollectionObjectEditor.class);
    dco = editor.getObject();
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    discoveryMethod = WidgetHelper.createLabeledCombo(dialogArea, SWT.BORDER | SWT.READ_ONLY, Messages.get().InstanceDiscovery_Method, WidgetHelper.DEFAULT_LAYOUT_DATA);
    discoveryMethod.add(Messages.get().InstanceDiscovery_None);
    discoveryMethod.add(Messages.get().InstanceDiscovery_AgentList);
    discoveryMethod.add(Messages.get().InstanceDiscovery_AgentTable);
    discoveryMethod.add(Messages.get().InstanceDiscovery_SnmpWalkValues);
    discoveryMethod.add(Messages.get().InstanceDiscovery_SnmpWalkOids);
    discoveryMethod.add(Messages.get().InstanceDiscovery_Script);
    discoveryMethod.select(dco.getInstanceDiscoveryMethod());
    discoveryMethod.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            int method = discoveryMethod.getSelectionIndex();
            discoveryData.setLabel(getDataLabel(method));
            discoveryData.setEnabled(method != DataCollectionObject.IDM_NONE);
            filterScript.setEnabled(method != DataCollectionObject.IDM_NONE);
            instanceRetentionMode.setEnabled(method != DataCollectionObject.IDM_NONE);
            instanceRetentionTime.setEnabled(method != DataCollectionObject.IDM_NONE && instanceRetentionMode.getSelectionIndex() > 0);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    discoveryData = new LabeledText(dialogArea, SWT.NONE);
    discoveryData.setLabel(getDataLabel(dco.getInstanceDiscoveryMethod()));
    discoveryData.setText(dco.getInstanceDiscoveryData());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    discoveryData.setLayoutData(gd);
    discoveryData.setEnabled(dco.getInstanceDiscoveryMethod() != DataCollectionObject.IDM_NONE);
    groupRetention = new Group(dialogArea, SWT.NONE);
    groupRetention.setText("Instance retention");
    gd = new GridData();
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.horizontalSpan = 2;
    groupRetention.setLayoutData(gd);
    GridLayout retentionLayout = new GridLayout();
    retentionLayout.numColumns = 2;
    retentionLayout.horizontalSpacing = WidgetHelper.OUTER_SPACING;
    groupRetention.setLayout(retentionLayout);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    instanceRetentionMode = WidgetHelper.createLabeledCombo(groupRetention, SWT.READ_ONLY, "Instance retention mode", gd);
    instanceRetentionMode.add("Server default");
    instanceRetentionMode.add("Custom");
    instanceRetentionMode.select(dco.getInstanceRetentionTime() == -1 ? 0 : 1);
    instanceRetentionMode.setEnabled(dco.getInstanceDiscoveryMethod() != DataCollectionObject.IDM_NONE);
    instanceRetentionMode.addSelectionListener(new SelectionListener() {

        /* (non-Javadoc)
          * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
          */
        @Override
        public void widgetSelected(SelectionEvent e) {
            instanceRetentionTime.setEnabled(instanceRetentionMode.getSelectionIndex() == 1);
        }

        /* (non-Javadoc)
          * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
          */
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    instanceRetentionTime = WidgetHelper.createLabeledSpinner(groupRetention, SWT.BORDER, "Instance retention time (days)", 0, 100, new GridData());
    instanceRetentionTime.setSelection(dco.getInstanceRetentionTime());
    instanceRetentionTime.setEnabled(instanceRetentionMode.getSelectionIndex() > 0);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.widthHint = 0;
    gd.heightHint = 0;
    final WidgetFactory factory = new WidgetFactory() {

        @Override
        public Control createControl(Composite parent, int style) {
            return new ScriptEditor(parent, style, SWT.H_SCROLL | SWT.V_SCROLL, false, "Variables:\r\n\t$1\tInstance to test\r\n\r\nReturn value:\r\n\ttrue/false to accept or reject instance without additional changes or\r\n\tarray of two or three elements to modify instance:\r\n\t\t1st element - true/false to indicate acceptance;\r\n\t\t2nd element - new instance name;\r\n\t\t3rd element - new instance display name.");
        }
    };
    filterScript = (ScriptEditor) WidgetHelper.createLabeledControl(dialogArea, SWT.BORDER, factory, Messages.get().InstanceDiscovery_FilterScript, gd);
    filterScript.addFunctions(Arrays.asList(DCI_FUNCTIONS));
    filterScript.addVariables(Arrays.asList(DCI_VARIABLES));
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    filterScript.setLayoutData(gd);
    filterScript.setText(dco.getInstanceDiscoveryFilter());
    filterScript.setEnabled(dco.getInstanceDiscoveryMethod() != DataCollectionObject.IDM_NONE);
    return dialogArea;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) WidgetFactory(org.netxms.ui.eclipse.tools.WidgetFactory) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) SelectionListener(org.eclipse.swt.events.SelectionListener) ScriptEditor(org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor)

Example 85 with LabeledText

use of org.netxms.ui.eclipse.widgets.LabeledText in project netxms by netxms.

the class CreateInterfaceDciDialog method createDialogArea.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite dialogArea = (Composite) super.createDialogArea(parent);
    final IDialogSettings settings = Activator.getDefault().getDialogSettings();
    final boolean[] enabled = new boolean[DEFAULT_ENABLED.length];
    for (int i = 0; i < enabled.length; i++) {
        // $NON-NLS-1$
        String v = settings.get("CreateInterfaceDciDialog.enabled_" + i);
        if (v != null) {
            enabled[i] = Boolean.parseBoolean(v);
        } else {
            enabled[i] = DEFAULT_ENABLED[i];
        }
    }
    GridLayout layout = new GridLayout();
    dialogArea.setLayout(layout);
    Group dataGroup = new Group(dialogArea, SWT.NONE);
    dataGroup.setText(Messages.get().CreateInterfaceDciDialog_Data);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    dataGroup.setLayoutData(gd);
    layout = new GridLayout();
    dataGroup.setLayout(layout);
    for (int i = 0; i < names.length; i++) {
        if (i > 0) {
            Label sep = new Label(dataGroup, SWT.SEPARATOR | SWT.HORIZONTAL);
            gd = new GridData();
            gd.horizontalAlignment = SWT.FILL;
            gd.grabExcessHorizontalSpace = true;
            sep.setLayoutData(gd);
        }
        forms[i] = new InterfaceDciForm(dataGroup, names[i], (object != null) ? descriptions[i].replaceAll("@@ifName@@", object.getObjectName()) : descriptions[i], // $NON-NLS-1$
        enabled[i]);
        gd = new GridData();
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessHorizontalSpace = true;
        forms[i].setLayoutData(gd);
    }
    Group optionsGroup = new Group(dialogArea, SWT.NONE);
    optionsGroup.setText(Messages.get().CreateInterfaceDciDialog_Options);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    optionsGroup.setLayoutData(gd);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.makeColumnsEqualWidth = true;
    optionsGroup.setLayout(layout);
    textInterval = new LabeledText(optionsGroup, SWT.NONE);
    textInterval.setLabel(Messages.get().CreateInterfaceDciDialog_PollingInterval);
    textInterval.getTextControl().setTextLimit(5);
    // $NON-NLS-1$
    String v = settings.get("CreateInterfaceDciDialog.pollingInterval");
    // $NON-NLS-1$
    textInterval.setText((v != null) ? v : "60");
    textRetention = new LabeledText(optionsGroup, SWT.NONE);
    textRetention.setLabel(Messages.get().CreateInterfaceDciDialog_RetentionTime);
    textRetention.getTextControl().setTextLimit(5);
    // $NON-NLS-1$
    v = settings.get("CreateInterfaceDciDialog.retentionTime");
    // $NON-NLS-1$
    textRetention.setText((v != null) ? v : "30");
    return dialogArea;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label)

Aggregations

Composite (org.eclipse.swt.widgets.Composite)104 LabeledText (org.netxms.ui.eclipse.widgets.LabeledText)104 GridLayout (org.eclipse.swt.layout.GridLayout)103 GridData (org.eclipse.swt.layout.GridData)102 Button (org.eclipse.swt.widgets.Button)50 SelectionEvent (org.eclipse.swt.events.SelectionEvent)37 SelectionListener (org.eclipse.swt.events.SelectionListener)31 Group (org.eclipse.swt.widgets.Group)24 ObjectSelector (org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector)22 Label (org.eclipse.swt.widgets.Label)18 RowLayout (org.eclipse.swt.layout.RowLayout)11 Spinner (org.eclipse.swt.widgets.Spinner)11 ModifyEvent (org.eclipse.swt.events.ModifyEvent)9 ModifyListener (org.eclipse.swt.events.ModifyListener)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8 LabeledSpinner (org.netxms.ui.eclipse.widgets.LabeledSpinner)8 ColorSelector (org.eclipse.jface.preference.ColorSelector)6 DisposeEvent (org.eclipse.swt.events.DisposeEvent)6 DisposeListener (org.eclipse.swt.events.DisposeListener)6 WidgetFactory (org.netxms.ui.eclipse.tools.WidgetFactory)6