Search in sources :

Example 61 with Spinner

use of org.eclipse.swt.widgets.Spinner in project polymap4-core by Polymap4.

the class ConstantNumberEditor method createContents.

@Override
public Composite createContents(Composite parent) {
    Composite contents = super.createContents(parent);
    Spinner s = new Spinner(contents, SWT.BORDER);
    NumberRange nd = (NumberRange) prop.info().getAnnotation(NumberRange.class);
    if (nd != null) {
        int digits = nd.digits();
        double currentValue = (double) prop.get().constantNumber.get();
        double factorX = Math.pow(10, digits);
        s.setDigits(digits);
        s.setMinimum((int) (nd.from() * factorX));
        s.setMaximum((int) (nd.to() * factorX));
        s.setIncrement((int) (nd.increment() * factorX));
        s.setPageIncrement((int) (nd.increment() * factorX * 10));
        s.setSelection((int) (currentValue * factorX));
    }
    s.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            int selection = s.getSelection();
            int digits = s.getDigits();
            prop.get().constantNumber.set(selection / Math.pow(10, digits));
        }
    });
    return contents;
}
Also used : NumberRange(org.polymap.core.style.model.feature.NumberRange) Composite(org.eclipse.swt.widgets.Composite) Spinner(org.eclipse.swt.widgets.Spinner) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 62 with Spinner

use of org.eclipse.swt.widgets.Spinner in project netxms by netxms.

the class SeparatorProperties method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    config = (SeparatorConfig) getElement().getAdapter(SeparatorConfig.class);
    Composite dialogArea = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    dialogArea.setLayout(layout);
    Composite fgArea = new Composite(dialogArea, SWT.NONE);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    fgArea.setLayoutData(gd);
    RowLayout areaLayout = new RowLayout();
    areaLayout.type = SWT.HORIZONTAL;
    areaLayout.marginBottom = 0;
    areaLayout.marginTop = 0;
    areaLayout.marginLeft = 0;
    areaLayout.marginRight = 0;
    fgArea.setLayout(areaLayout);
    new Label(fgArea, SWT.NONE).setText(Messages.get().LabelProperties_TextColor);
    foreground = new ColorSelector(fgArea);
    foreground.setColorValue(ColorConverter.rgbFromInt(config.getForegroundColorAsInt()));
    Composite bgArea = new Composite(dialogArea, SWT.NONE);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    bgArea.setLayoutData(gd);
    areaLayout = new RowLayout();
    areaLayout.type = SWT.HORIZONTAL;
    areaLayout.marginBottom = 0;
    areaLayout.marginTop = 0;
    areaLayout.marginLeft = 0;
    areaLayout.marginRight = 0;
    bgArea.setLayout(areaLayout);
    new Label(bgArea, SWT.NONE).setText(Messages.get().LabelProperties_BgColor);
    background = new ColorSelector(bgArea);
    background.setColorValue(ColorConverter.rgbFromInt(config.getBackgroundColorAsInt()));
    Composite lineWidthGroup = new Composite(dialogArea, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.horizontalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.marginTop = WidgetHelper.OUTER_SPACING;
    lineWidthGroup.setLayout(layout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    lineWidthGroup.setLayoutData(gd);
    Label label = new Label(lineWidthGroup, SWT.NONE);
    label.setText(Messages.get().SeparatorProperties_LineWidth);
    gd = new GridData();
    gd.horizontalAlignment = SWT.LEFT;
    gd.horizontalSpan = 2;
    label.setLayoutData(gd);
    lineWidthScale = new Scale(lineWidthGroup, SWT.HORIZONTAL);
    lineWidthScale.setMinimum(0);
    lineWidthScale.setMaximum(15);
    lineWidthScale.setSelection(config.getLineWidth());
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    lineWidthScale.setLayoutData(gd);
    lineWidthScale.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            lineWidthSpinner.setSelection(lineWidthScale.getSelection());
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    lineWidthSpinner = new Spinner(lineWidthGroup, SWT.BORDER);
    lineWidthSpinner.setMinimum(1);
    lineWidthSpinner.setMaximum(600);
    lineWidthSpinner.setSelection(config.getLineWidth());
    lineWidthSpinner.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            lineWidthScale.setSelection(lineWidthSpinner.getSelection());
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    marginLeft = WidgetHelper.createLabeledSpinner(dialogArea, SWT.BORDER, Messages.get().SeparatorProperties_LeftMargin, 0, 255, WidgetHelper.DEFAULT_LAYOUT_DATA);
    marginLeft.setSelection(config.getLeftMargin());
    marginRight = WidgetHelper.createLabeledSpinner(dialogArea, SWT.BORDER, Messages.get().SeparatorProperties_RightMargin, 0, 255, WidgetHelper.DEFAULT_LAYOUT_DATA);
    marginRight.setSelection(config.getRightMargin());
    marginTop = WidgetHelper.createLabeledSpinner(dialogArea, SWT.BORDER, Messages.get().SeparatorProperties_TopMargin, 0, 255, WidgetHelper.DEFAULT_LAYOUT_DATA);
    marginTop.setSelection(config.getTopMargin());
    marginBottom = WidgetHelper.createLabeledSpinner(dialogArea, SWT.BORDER, Messages.get().SeparatorProperties_BottomMargin, 0, 255, WidgetHelper.DEFAULT_LAYOUT_DATA);
    marginBottom.setSelection(config.getBottomMargin());
    return dialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Spinner(org.eclipse.swt.widgets.Spinner) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Scale(org.eclipse.swt.widgets.Scale) ColorSelector(org.eclipse.jface.preference.ColorSelector) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 63 with Spinner

use of org.eclipse.swt.widgets.Spinner in project netxms by netxms.

the class WidgetHelper method createLabeledSpinner.

/**
 * Create pair of label and spinner, with label above
 *
 * @param parent Parent composite
 * @param flags Flags for Text creation
 * @param labelText Label's text
 * @param minVal minimal spinner value
 * @param maxVal maximum spinner value
 * @param layoutData Layout data for label/input pair. If null, default GridData will be assigned.
 * @return Created Spinner object
 */
public static Spinner createLabeledSpinner(final Composite parent, int flags, final String labelText, int minVal, int maxVal, Object layoutData) {
    Composite group = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = INNER_SPACING;
    layout.horizontalSpacing = 0;
    layout.marginTop = 0;
    layout.marginBottom = 0;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    group.setLayout(layout);
    if (layoutData != DEFAULT_LAYOUT_DATA) {
        group.setLayoutData(layoutData);
    } else {
        GridData gridData = new GridData();
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        group.setLayoutData(gridData);
    }
    Label label = new Label(group, SWT.NONE);
    label.setText(labelText);
    Spinner spinner = new Spinner(group, flags);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    spinner.setLayoutData(gridData);
    spinner.setMinimum(minVal);
    spinner.setMaximum(maxVal);
    return spinner;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Spinner(org.eclipse.swt.widgets.Spinner) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label)

Example 64 with Spinner

use of org.eclipse.swt.widgets.Spinner in project netxms by netxms.

the class General 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.getObjectAsItem();
    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().General_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().General_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().General_Parameter);
    parameter.getTextControl().setTextLimit(255);
    parameter.setText(dci.getName());
    selectButton = new Button(groupData, SWT.PUSH);
    selectButton.setText(Messages.get().General_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().General_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.add(Messages.get().General_SourceDeviceDriver);
    origin.select(dci.getOrigin());
    origin.addSelectionListener(new SelectionListener() {

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            onOriginChange();
        }
    });
    fd = new FormData();
    fd.left = new FormAttachment(50, WidgetHelper.OUTER_SPACING / 2);
    fd.top = new FormAttachment(parameter, WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
    fd.right = new FormAttachment(100, 0);
    dataType = WidgetHelper.createLabeledCombo(groupData, SWT.READ_ONLY, Messages.get().General_DataType, fd);
    dataType.add(DataCollectionDisplayInfo.getDataTypeName(DataType.INT32));
    dataType.add(DataCollectionDisplayInfo.getDataTypeName(DataType.UINT32));
    dataType.add(DataCollectionDisplayInfo.getDataTypeName(DataType.COUNTER32));
    dataType.add(DataCollectionDisplayInfo.getDataTypeName(DataType.INT64));
    dataType.add(DataCollectionDisplayInfo.getDataTypeName(DataType.UINT64));
    dataType.add(DataCollectionDisplayInfo.getDataTypeName(DataType.COUNTER64));
    dataType.add(DataCollectionDisplayInfo.getDataTypeName(DataType.FLOAT));
    dataType.add(DataCollectionDisplayInfo.getDataTypeName(DataType.STRING));
    dataType.select(getDataTypePosition(dci.getDataType()));
    checkInterpretRawSnmpValue = new Button(groupData, SWT.CHECK);
    checkInterpretRawSnmpValue.setText(Messages.get().General_InterpretRawValue);
    checkInterpretRawSnmpValue.setSelection(dci.isSnmpRawValueInOctetString());
    checkInterpretRawSnmpValue.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            snmpRawType.setEnabled(checkInterpretRawSnmpValue.getSelection());
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(origin.getParent(), WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
    checkInterpretRawSnmpValue.setLayoutData(fd);
    checkInterpretRawSnmpValue.setEnabled(dci.getOrigin() == DataCollectionItem.SNMP);
    snmpRawType = new Combo(groupData, SWT.BORDER | SWT.READ_ONLY);
    for (int i = 0; i < snmpRawTypes.length; i++) snmpRawType.add(snmpRawTypes[i]);
    snmpRawType.select(dci.getSnmpRawValueType());
    snmpRawType.setEnabled((dci.getOrigin() == DataCollectionItem.SNMP) && dci.isSnmpRawValueInOctetString());
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(checkInterpretRawSnmpValue, WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
    fd.right = new FormAttachment(checkInterpretRawSnmpValue, 0, SWT.RIGHT);
    snmpRawType.setLayoutData(fd);
    checkUseCustomSnmpPort = new Button(groupData, SWT.CHECK);
    checkUseCustomSnmpPort.setText(Messages.get().General_UseCustomPort);
    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(checkInterpretRawSnmpValue, WidgetHelper.OUTER_SPACING, SWT.RIGHT);
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(dataType.getParent(), WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
    checkUseCustomSnmpPort.setLayoutData(fd);
    checkUseCustomSnmpPort.setEnabled(dci.getOrigin() == DataCollectionItem.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(checkInterpretRawSnmpValue, WidgetHelper.OUTER_SPACING, SWT.RIGHT);
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(checkUseCustomSnmpPort, WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
    customSnmpPort.setLayoutData(fd);
    sampleCount = new LabeledSpinner(groupData, SWT.NONE);
    sampleCount.setLabel(Messages.get().General_SampleCountForAvg);
    sampleCount.setRange(0, 65535);
    sampleCount.setSelection(dci.getSampleCount());
    sampleCount.setEnabled(dci.getOrigin() == DataCollectionItem.WINPERF);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(snmpRawType, WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
    fd.right = new FormAttachment(100, 0);
    sampleCount.setLayoutData(fd);
    sourceNode = new ObjectSelector(groupData, SWT.NONE, true);
    sourceNode.setLabel(Messages.get().General_ProxyNode);
    sourceNode.setObjectClass(Node.class);
    sourceNode.setObjectId(dci.getSourceNode());
    sourceNode.setEnabled(dci.getOrigin() != DataCollectionItem.PUSH);
    fd = new FormData();
    fd.top = new FormAttachment(sampleCount, WidgetHelper.OUTER_SPACING, SWT.BOTTOM);
    fd.right = new FormAttachment(100, 0);
    agentCacheMode = WidgetHelper.createLabeledCombo(groupData, SWT.READ_ONLY, Messages.get().General_AgentCacheMode, fd);
    agentCacheMode.add(Messages.get().General_Default);
    agentCacheMode.add(Messages.get().General_On);
    agentCacheMode.add(Messages.get().General_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(sampleCount, 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().General_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().General_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() != DataCollectionItem.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);
    /**
     * status *
     */
    Group groupStatus = new Group(dialogArea, SWT.NONE);
    groupStatus.setText(Messages.get().General_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().General_Active);
    statusActive.setSelection(dci.getStatus() == DataCollectionItem.ACTIVE);
    statusDisabled = new Button(groupStatus, SWT.RADIO);
    statusDisabled.setText(Messages.get().General_Disabled);
    statusDisabled.setSelection(dci.getStatus() == DataCollectionItem.DISABLED);
    statusUnsupported = new Button(groupStatus, SWT.RADIO);
    statusUnsupported.setText(Messages.get().General_NotSupported);
    statusUnsupported.setSelection(dci.getStatus() == DataCollectionItem.NOT_SUPPORTED);
    /**
     * storage *
     */
    Group groupStorage = new Group(dialogArea, SWT.NONE);
    groupStorage.setText(Messages.get().General_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().General_RetentionMode, gd);
    retentionMode.add(Messages.get().General_UseDefaultRetention);
    retentionMode.add(Messages.get().General_UseCustomRetention);
    retentionMode.add(Messages.get().General_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().General_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);
    int mode = 0;
    if ((dci.getFlags() & DataCollectionObject.DCF_NO_STORAGE) != 0)
        mode = 2;
    else if (dci.getRetentionTime() > 0)
        mode = 1;
    retentionMode.select(mode);
    retentionTime.setEnabled(mode == 1);
    onOriginChange();
    return dialogArea;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) Spinner(org.eclipse.swt.widgets.Spinner) LabeledSpinner(org.netxms.ui.eclipse.widgets.LabeledSpinner) Text(org.eclipse.swt.widgets.Text) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) Combo(org.eclipse.swt.widgets.Combo) FillLayout(org.eclipse.swt.layout.FillLayout) LabeledSpinner(org.netxms.ui.eclipse.widgets.LabeledSpinner) GridLayout(org.eclipse.swt.layout.GridLayout) ObjectSelector(org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 65 with Spinner

use of org.eclipse.swt.widgets.Spinner in project netxms by netxms.

the class EmbeddedDashboard method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    config = (EmbeddedDashboardConfig) getElement().getAdapter(EmbeddedDashboardConfig.class);
    Composite dialogArea = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    dialogArea.setLayout(layout);
    Label label = new Label(dialogArea, SWT.NONE);
    label.setText(Messages.get().EmbeddedDashboard_Dashboards);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.LEFT;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    label.setLayoutData(gd);
    viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new WorkbenchLabelProvider());
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.heightHint = 0;
    viewer.getTable().setLayoutData(gd);
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    dashboardObjects = session.findMultipleObjects(config.getDashboardObjects(), Dashboard.class, false);
    viewer.setInput(dashboardObjects.toArray());
    /* buttons on left side */
    Composite leftButtons = new Composite(dialogArea, SWT.NONE);
    RowLayout buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginWidth = 0;
    buttonLayout.marginLeft = 0;
    leftButtons.setLayout(buttonLayout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.LEFT;
    leftButtons.setLayoutData(gd);
    upButton = new Button(leftButtons, SWT.PUSH);
    upButton.setText(Messages.get().EmbeddedDashboard_Up);
    RowData rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    upButton.setLayoutData(rd);
    upButton.addSelectionListener(new SelectionListener() {

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveUp();
        }
    });
    upButton.setEnabled(false);
    downButton = new Button(leftButtons, SWT.PUSH);
    downButton.setText(Messages.get().EmbeddedDashboard_Down);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    downButton.setLayoutData(rd);
    downButton.addSelectionListener(new SelectionListener() {

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveDown();
        }
    });
    downButton.setEnabled(false);
    /* buttons on right side */
    Composite rightButtons = new Composite(dialogArea, SWT.NONE);
    buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginWidth = 0;
    buttonLayout.marginRight = 0;
    rightButtons.setLayout(buttonLayout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.RIGHT;
    rightButtons.setLayoutData(gd);
    addButton = new Button(rightButtons, SWT.PUSH);
    addButton.setText(Messages.get().EmbeddedDashboard_Add);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    addButton.setLayoutData(rd);
    addButton.addSelectionListener(new SelectionListener() {

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            addDashboard();
        }
    });
    deleteButton = new Button(rightButtons, SWT.PUSH);
    deleteButton.setText(Messages.get().EmbeddedDashboard_Delete);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    deleteButton.setLayoutData(rd);
    deleteButton.addSelectionListener(new SelectionListener() {

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            deleteDashboards();
        }
    });
    deleteButton.setEnabled(false);
    Composite refreshIntervalGroup = new Composite(dialogArea, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.horizontalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.marginTop = WidgetHelper.OUTER_SPACING;
    refreshIntervalGroup.setLayout(layout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    refreshIntervalGroup.setLayoutData(gd);
    label = new Label(refreshIntervalGroup, SWT.NONE);
    label.setText(Messages.get().EmbeddedDashboard_DisplayTime);
    gd = new GridData();
    gd.horizontalAlignment = SWT.LEFT;
    gd.horizontalSpan = 2;
    label.setLayoutData(gd);
    refreshIntervalScale = new Scale(refreshIntervalGroup, SWT.HORIZONTAL);
    refreshIntervalScale.setMinimum(1);
    refreshIntervalScale.setMaximum(600);
    refreshIntervalScale.setSelection(config.getDisplayInterval());
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    refreshIntervalScale.setLayoutData(gd);
    refreshIntervalScale.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            refreshIntervalSpinner.setSelection(refreshIntervalScale.getSelection());
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    refreshIntervalSpinner = new Spinner(refreshIntervalGroup, SWT.BORDER);
    refreshIntervalSpinner.setMinimum(1);
    refreshIntervalSpinner.setMaximum(600);
    refreshIntervalSpinner.setSelection(config.getDisplayInterval());
    refreshIntervalSpinner.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            refreshIntervalScale.setSelection(refreshIntervalSpinner.getSelection());
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            deleteButton.setEnabled(selection.size() > 0);
            upButton.setEnabled(selection.size() == 1);
            downButton.setEnabled(selection.size() == 1);
        }
    });
    return dialogArea;
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) NXCSession(org.netxms.client.NXCSession) Composite(org.eclipse.swt.widgets.Composite) Spinner(org.eclipse.swt.widgets.Spinner) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) Dashboard(org.netxms.client.objects.Dashboard) Scale(org.eclipse.swt.widgets.Scale) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

Spinner (org.eclipse.swt.widgets.Spinner)159 Composite (org.eclipse.swt.widgets.Composite)108 GridData (org.eclipse.swt.layout.GridData)105 GridLayout (org.eclipse.swt.layout.GridLayout)103 Label (org.eclipse.swt.widgets.Label)102 Button (org.eclipse.swt.widgets.Button)86 SelectionEvent (org.eclipse.swt.events.SelectionEvent)59 Group (org.eclipse.swt.widgets.Group)58 Text (org.eclipse.swt.widgets.Text)43 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)40 ModifyListener (org.eclipse.swt.events.ModifyListener)33 SelectionListener (org.eclipse.swt.events.SelectionListener)31 ModifyEvent (org.eclipse.swt.events.ModifyEvent)30 Combo (org.eclipse.swt.widgets.Combo)27 SWT (org.eclipse.swt.SWT)18 Point (org.eclipse.swt.graphics.Point)12 FormLayout (org.eclipse.swt.layout.FormLayout)11 RowLayout (org.eclipse.swt.layout.RowLayout)11 LabeledText (org.netxms.ui.eclipse.widgets.LabeledText)11 FormAttachment (org.eclipse.swt.layout.FormAttachment)9