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);
}
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;
}
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());
}
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());
}
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;
}
Aggregations