Search in sources :

Example 56 with Spinner

use of org.eclipse.swt.widgets.Spinner in project jbosstools-openshift by jbosstools.

the class ServicePortDialog method doCreateControls.

@Override
protected void doCreateControls(final Composite parent, final DataBindingContext dbc) {
    GridLayoutFactory.fillDefaults().margins(1, 1).applyTo(parent);
    final Composite dialogArea = new Composite(parent, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(dialogArea);
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(dialogArea);
    // service port
    final Label servicePortLabel = new Label(dialogArea, SWT.NONE);
    servicePortLabel.setText("Service port:");
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(servicePortLabel);
    final Spinner servicePortSpinner = new Spinner(dialogArea, SWT.BORDER);
    servicePortSpinner.setMinimum(1);
    servicePortSpinner.setMaximum(65535);
    servicePortSpinner.setToolTipText("The port exposed by the service that will route to the pod.");
    servicePortSpinner.addModifyListener(e -> {
        Spinner source = (Spinner) e.getSource();
        if (!String.valueOf(source.getSelection()).equals(source.getText())) {
            source.setSelection(source.getSelection());
        }
    });
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(servicePortSpinner);
    final Binding servicePortBinding = ValueBindingBuilder.bind(WidgetProperties.selection().observe(servicePortSpinner)).validatingAfterConvert(new ServicePortValidator(model.getPort(), this.ports)).to(BeanProperties.value(PROPERTY_SERVICE_PORT).observe(model)).in(dbc);
    ControlDecorationSupport.create(servicePortBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
    // Pod port
    final Label podPortLabel = new Label(dialogArea, SWT.NONE);
    podPortLabel.setText("Pod port:");
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(podPortLabel);
    final Text podPortText = new Text(dialogArea, SWT.BORDER);
    podPortText.setToolTipText("The port exposed by the pod which will accept traffic.\nIt must be an integer or the name of a port in the backend Pods.");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(podPortText);
    final Binding podPortBinding = ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(podPortText)).validatingAfterConvert(new PodPortValidator(this.model.getTargetPort(), this.ports)).to(BeanProperties.value(PROPERTY_POD_PORT).observe(model)).in(dbc);
    ControlDecorationSupport.create(podPortBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
    final Button routePortButton = new Button(dialogArea, SWT.CHECK);
    routePortButton.setText("Used by route");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(routePortButton);
    ValueBindingBuilder.bind(WidgetProperties.selection().observe(routePortButton)).to(BeanProperties.value(ServicePortAdapter.ROUTE_PORT).observe(model)).in(dbc);
}
Also used : Binding(org.eclipse.core.databinding.Binding) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) Spinner(org.eclipse.swt.widgets.Spinner) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text)

Example 57 with Spinner

use of org.eclipse.swt.widgets.Spinner in project mdw-designer by CenturyLinkCloud.

the class PropertyEditor method createSpinner.

private Spinner createSpinner(Composite parent) {
    createLabel(parent);
    int lStyle = SWT.BORDER | this.style;
    if (isReadOnly())
        lStyle = lStyle | SWT.READ_ONLY;
    final Spinner spinner = new Spinner(parent, lStyle);
    GridData gd = new GridData(SWT.LEFT);
    gd.widthHint = getWidth();
    gd.heightHint = getHeight();
    gd.horizontalSpan = COLUMNS - 1;
    gd.horizontalIndent = indent;
    spinner.setLayoutData(gd);
    if (getValue() != null)
        spinner.setSelection(Integer.parseInt(getValue()));
    spinner.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            int oldValue = value == null || value.length() == 0 ? 0 : Integer.parseInt(value);
            int newValue = spinner.getSelection();
            value = String.valueOf(newValue);
            boolean changed = oldValue != newValue;
            if (changed)
                fireValueChanged(value);
        }
    });
    return spinner;
}
Also used : Spinner(org.eclipse.swt.widgets.Spinner) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Point(org.eclipse.swt.graphics.Point)

Example 58 with Spinner

use of org.eclipse.swt.widgets.Spinner in project mdw-designer by CenturyLinkCloud.

the class ServerPropertyPage method createLogWatcherControls.

private void createLogWatcherControls(Composite parent) {
    addHeading(parent, "Log Watcher");
    Composite composite = createComposite(parent, 2);
    // host
    new Label(composite, SWT.NONE).setText("Log Watch Host:");
    logWatcherHostTextField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    GridData gd = new GridData(GridData.BEGINNING);
    gd.widthHint = 225;
    gd.verticalIndent = 5;
    logWatcherHostTextField.setLayoutData(gd);
    logWatcherHostTextField.setText("localhost");
    // wired to local host
    logWatcherHostTextField.setEditable(false);
    // port
    new Label(composite, SWT.NONE).setText("Log Watch Port:");
    logWatcherPortTextField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    gd = new GridData(GridData.BEGINNING);
    gd.widthHint = 100;
    gd.verticalIndent = 5;
    logWatcherPortTextField.setLayoutData(gd);
    logWatcherPortTextField.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String port = logWatcherPortTextField.getText().trim();
            workingCopy.setLogWatcherPort(Integer.parseInt(port));
        }
    });
    logWatcherPortTextField.setText(String.valueOf(workingCopy.getLogWatcherPort()));
    // timeout
    new Label(composite, SWT.NONE).setText("Timeout (secs):");
    logWatcherTimeoutSpinner = new Spinner(composite, SWT.BORDER);
    logWatcherTimeoutSpinner.setMinimum(10);
    logWatcherTimeoutSpinner.setMaximum(300);
    logWatcherTimeoutSpinner.setIncrement(10);
    logWatcherTimeoutSpinner.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            int timeout = logWatcherTimeoutSpinner.getSelection();
            workingCopy.setLogWatcherTimeout(timeout);
        }
    });
    logWatcherTimeoutSpinner.setSelection(workingCopy.getLogWatcherTimeout());
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Spinner(org.eclipse.swt.widgets.Spinner) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text)

Example 59 with Spinner

use of org.eclipse.swt.widgets.Spinner in project mdw-designer by CenturyLinkCloud.

the class ServerPropertyPage method createStubServerControls.

private void createStubServerControls(Composite parent) {
    addHeading(parent, "Stub Server");
    Composite composite = createComposite(parent, 2);
    // stub host
    new Label(composite, SWT.NONE).setText("Stub Server Host:");
    stubServerHostTextField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    GridData gd = new GridData(GridData.BEGINNING);
    gd.widthHint = 225;
    gd.verticalIndent = 5;
    stubServerHostTextField.setLayoutData(gd);
    stubServerHostTextField.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String host = stubServerHostTextField.getText().trim();
            workingCopy.setStubServerHost(host);
        }
    });
    stubServerHostTextField.setText("localhost");
    // wired to local host
    stubServerHostTextField.setEditable(false);
    // stub port
    new Label(composite, SWT.NONE).setText("Stub Server Port:");
    stubServerPortTextField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    gd = new GridData(GridData.BEGINNING);
    gd.widthHint = 100;
    gd.verticalIndent = 5;
    stubServerPortTextField.setLayoutData(gd);
    stubServerPortTextField.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String port = stubServerPortTextField.getText().trim();
            workingCopy.setStubServerPort(Integer.parseInt(port));
        }
    });
    stubServerPortTextField.setText(String.valueOf(workingCopy.getStubServerPort()));
    // timeout
    new Label(composite, SWT.NONE).setText("Timeout (secs):");
    stubServerTimeoutSpinner = new Spinner(composite, SWT.BORDER);
    stubServerTimeoutSpinner.setMinimum(10);
    stubServerTimeoutSpinner.setMaximum(300);
    stubServerTimeoutSpinner.setIncrement(10);
    stubServerTimeoutSpinner.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            int timeout = stubServerTimeoutSpinner.getSelection();
            workingCopy.setStubServerTimeout(timeout);
        }
    });
    stubServerTimeoutSpinner.setSelection(workingCopy.getStubServerTimeout());
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Spinner(org.eclipse.swt.widgets.Spinner) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text)

Example 60 with Spinner

use of org.eclipse.swt.widgets.Spinner in project mdw-designer by CenturyLinkCloud.

the class PreferencePage method createSpinner.

protected Spinner createSpinner(Composite group, int min, int max) {
    Spinner spinner = new Spinner(group, SWT.BORDER);
    spinner.setMinimum(min);
    spinner.setMaximum(max);
    spinner.setIncrement(1);
    return spinner;
}
Also used : Spinner(org.eclipse.swt.widgets.Spinner)

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