use of org.eclipse.jface.databinding.swt.ISWTObservableValue in project linuxtools by eclipse.
the class ContainerDataVolumeDialog method createDialogArea.
@Override
protected Control createDialogArea(final Composite parent) {
final Composite container = new Composite(parent, SWT.NONE);
final int COLUMNS = 3;
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(1, 1).grab(true, true).applyTo(container);
GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(COLUMNS).applyTo(container);
// Container path
final Label containerPathLabel = new Label(container, SWT.NONE);
containerPathLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.containerPathLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(containerPathLabel);
final Text containerPathText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(containerPathText);
final IObservableValue containerPathObservable = BeanProperties.value(DataVolumeModel.class, DataVolumeModel.CONTAINER_PATH).observe(model);
dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(containerPathText), containerPathObservable);
// mount type
final Label explanationLabel = new Label(container, SWT.NONE);
explanationLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.explanationLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).grab(true, false).applyTo(explanationLabel);
final int INDENT = 20;
// No mount
final Button noMountButton = new Button(container, SWT.RADIO);
noMountButton.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.noMountButton"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(INDENT, 0).span(COLUMNS, 1).grab(true, false).applyTo(noMountButton);
bindButton(noMountButton, MountType.NONE);
// File System mount
final Button fileSystemMountButton = new Button(container, SWT.RADIO);
fileSystemMountButton.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.fileSystemMountButton"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(INDENT, 0).span(COLUMNS, 1).grab(true, false).applyTo(fileSystemMountButton);
final Label hostPathLabel = new Label(container, SWT.NONE);
hostPathLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.hostPathLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(2 * INDENT, SWT.DEFAULT).grab(false, false).applyTo(hostPathLabel);
final Text hostPathText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(hostPathText);
final IObservableValue hostPathObservable = BeanProperties.value(DataVolumeModel.class, DataVolumeModel.HOST_PATH_MOUNT).observe(model);
dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(hostPathText), hostPathObservable);
// browse for directory
final Button hostPathDirectoryButton = new Button(container, SWT.NONE);
hostPathDirectoryButton.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.directoryButton"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(hostPathDirectoryButton);
hostPathDirectoryButton.addSelectionListener(onHostDirectoryPath());
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(new Label(container, SWT.NONE));
// optional read-only access
final Button readOnlyButton = new Button(container, SWT.CHECK);
readOnlyButton.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.readOnlyButton"));
readOnlyButton.setToolTipText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.readOnlyButtonTooltip"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS - 2, 1).grab(true, false).applyTo(readOnlyButton);
final ISWTObservableValue readOnlyButtonObservable = WidgetProperties.selection().observe(readOnlyButton);
dbc.bindValue(readOnlyButtonObservable, BeanProperties.value(DataVolumeModel.class, DataVolumeModel.READ_ONLY_VOLUME).observe(model));
// browse for file
final Button hostPathFileButton = new Button(container, SWT.NONE);
hostPathFileButton.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.fileButton"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(hostPathFileButton);
hostPathFileButton.addSelectionListener(onHostFilePath());
bindButton(fileSystemMountButton, MountType.HOST_FILE_SYSTEM, hostPathText, hostPathDirectoryButton, hostPathFileButton, readOnlyButton);
// Container mount
final Button containerMountButton = new Button(container, SWT.RADIO);
containerMountButton.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.containerMountButton"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(INDENT, 0).span(COLUMNS, 1).grab(true, false).applyTo(containerMountButton);
final Label containerSelectionLabel = new Label(container, SWT.NONE);
containerSelectionLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerDataVolumeDialog.containerSelectionLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(2 * INDENT, SWT.DEFAULT).applyTo(containerSelectionLabel);
final Combo containerSelectionCombo = new Combo(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(1, 1).applyTo(containerSelectionCombo);
new ControlDecoration(containerSelectionCombo, SWT.TOP | SWT.LEFT);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(new Label(container, SWT.NONE));
bindButton(containerMountButton, MountType.CONTAINER, containerSelectionCombo);
final ComboViewer containerSelectionComboViewer = new ComboViewer(containerSelectionCombo);
containerSelectionComboViewer.setContentProvider(new ArrayContentProvider());
containerSelectionComboViewer.setInput(this.containerNames);
final IObservableValue selectedContainerObservable = BeanProperties.value(DataVolumeModel.class, DataVolumeModel.CONTAINER_MOUNT).observe(model);
dbc.bindValue(WidgetProperties.selection().observe(containerSelectionCombo), selectedContainerObservable);
new ContentProposalAdapter(containerSelectionCombo, new ComboContentAdapter() {
@Override
public void insertControlContents(Control control, String text, int cursorPosition) {
final Combo combo = (Combo) control;
final Point selection = combo.getSelection();
combo.setText(text);
selection.x = text.length();
selection.y = selection.x;
combo.setSelection(selection);
}
}, getContainerNameContentProposalProvider(containerSelectionCombo), null, null);
// error message
final Composite errorContainer = new Composite(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(COLUMNS, 1).grab(true, true).applyTo(errorContainer);
GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(2).applyTo(errorContainer);
final Label errorMessageIcon = new Label(errorContainer, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).hint(20, SWT.DEFAULT).applyTo(errorMessageIcon);
final Label errorMessageLabel = new Label(errorContainer, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(errorMessageLabel);
setupValidationSupport(errorMessageIcon, errorMessageLabel);
return container;
}
use of org.eclipse.jface.databinding.swt.ISWTObservableValue in project linuxtools by eclipse.
the class ContainerEnvironmentVariableDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
final int COLUMNS = 2;
final Composite container = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(COLUMNS, 1).grab(true, true).applyTo(container);
GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(10, 10).applyTo(container);
final Label explanationLabel = new Label(container, SWT.NONE);
explanationLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerEnvironmentVariableDialog.explanationLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).grab(false, false).applyTo(explanationLabel);
final Label variableNameLabel = new Label(container, SWT.NONE);
variableNameLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerEnvironmentVariableDialog.nameLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(variableNameLabel);
final Text variableNameText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(variableNameText);
final Label variableValueLabel = new Label(container, SWT.NONE);
variableValueLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerEnvironmentVariableDialog.valueLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(variableValueLabel);
final Text variableValueText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(variableValueText);
// error message
final Label errorMessageLabel = new Label(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).grab(true, false).applyTo(errorMessageLabel);
// listening to changes
final ISWTObservableValue variableNameObservable = WidgetProperties.text(SWT.Modify).observe(variableNameText);
dbc.bindValue(variableNameObservable, BeanProperties.value(EnvironmentVariableModel.class, EnvironmentVariableModel.NAME).observe(model));
final ISWTObservableValue variableValueObservable = WidgetProperties.text(SWT.Modify).observe(variableValueText);
dbc.bindValue(variableValueObservable, BeanProperties.value(EnvironmentVariableModel.class, EnvironmentVariableModel.VALUE).observe(model));
variableNameObservable.addValueChangeListener(onEnvironmentVariableSettingsChanged());
variableValueObservable.addValueChangeListener(onEnvironmentVariableSettingsChanged());
return container;
}
use of org.eclipse.jface.databinding.swt.ISWTObservableValue in project linuxtools by eclipse.
the class ContainerPortDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
final int COLUMNS = 2;
final Composite container = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(COLUMNS, 1).grab(true, true).applyTo(container);
GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(10, 10).applyTo(container);
final Label explanationLabel = new Label(container, SWT.NONE);
explanationLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerPortDialog.explanationLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).grab(false, false).applyTo(explanationLabel);
final Label containerLabel = new Label(container, SWT.NONE);
containerLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ContainerPortDialog.containerLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(containerLabel);
final Text containerPortText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(containerPortText);
final Label hostAddressLabel = new Label(container, SWT.NONE);
hostAddressLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerPortDialog.hostAddressLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(hostAddressLabel);
final Text hostAddressText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(hostAddressText);
final Label hostPortLabel = new Label(container, SWT.NONE);
hostPortLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ContainerPortDialog.hostPortLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(hostPortLabel);
final Text hostPortText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(hostPortText);
// error message
final Label errorMessageLabel = new Label(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).grab(true, false).applyTo(errorMessageLabel);
// listening to changes
final ISWTObservableValue containerPortObservable = WidgetProperties.text(SWT.Modify).observe(containerPortText);
dbc.bindValue(containerPortObservable, BeanProperties.value(ContainerPortDialogModel.class, ContainerPortDialogModel.CONTAINER_PORT).observe(model));
final ISWTObservableValue hostAddressObservable = WidgetProperties.text(SWT.Modify).observe(hostAddressText);
dbc.bindValue(hostAddressObservable, BeanProperties.value(ContainerPortDialogModel.class, ContainerPortDialogModel.HOST_ADDRESS).observe(model));
final ISWTObservableValue hostPortObservable = WidgetProperties.text(SWT.Modify).observe(hostPortText);
dbc.bindValue(hostPortObservable, BeanProperties.value(ContainerPortDialogModel.class, ContainerPortDialogModel.HOST_PORT).observe(model));
containerPortObservable.addValueChangeListener(onContainerPortSettingsChanged());
hostPortObservable.addValueChangeListener(onContainerPortSettingsChanged());
hostAddressObservable.addValueChangeListener(onContainerPortSettingsChanged());
return container;
}
use of org.eclipse.jface.databinding.swt.ISWTObservableValue in project linuxtools by eclipse.
the class DockerComposeUpDialog method createDialogArea.
@SuppressWarnings("unchecked")
@Override
protected Control createDialogArea(final Composite parent) {
final int COLUMNS = 2;
final Composite container = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(COLUMNS, 1).grab(true, false).applyTo(container);
GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(10, 10).applyTo(container);
final Label explanationLabel = new Label(container, SWT.NONE);
explanationLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"DockerComposeUpDialog.explanationLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).grab(false, false).applyTo(explanationLabel);
final Label containerLabel = new Label(container, SWT.NONE);
containerLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"DockerComposeUpDialog.connectionLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(containerLabel);
final Combo containerSelectionCombo = new Combo(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(containerSelectionCombo);
final ComboViewer connectionSelectionComboViewer = new ComboViewer(containerSelectionCombo);
connectionSelectionComboViewer.setContentProvider(new ArrayContentProvider());
final List<String> connectionNames = model.getConnectionNames();
connectionSelectionComboViewer.setInput(connectionNames);
new ContentProposalAdapter(containerSelectionCombo, new ComboContentAdapter() {
@Override
public void insertControlContents(Control control, String text, int cursorPosition) {
final Combo combo = (Combo) control;
final Point selection = combo.getSelection();
combo.setText(text);
selection.x = text.length();
selection.y = selection.x;
combo.setSelection(selection);
}
}, getConnectionNameContentProposalProvider(containerSelectionCombo), null, null);
final ISWTObservableValue connnectionNameObservable = WidgetProperties.selection().observe(connectionSelectionComboViewer.getCombo());
// pre-select with first connection
if (!connectionNames.isEmpty()) {
model.setConnectionName(connectionNames.get(0));
}
// error message
final Composite errorContainer = new Composite(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(COLUMNS, 1).grab(true, true).applyTo(errorContainer);
GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(2).applyTo(errorContainer);
final Label errorMessageIcon = new Label(errorContainer, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).hint(20, SWT.DEFAULT).applyTo(errorMessageIcon);
final Label errorMessageLabel = new Label(errorContainer, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(errorMessageLabel);
dbc.bindValue(connnectionNameObservable, BeanProperties.value(DockerComposeUpModel.class, DockerComposeUpModel.CONNECTION_NAME).observe(model));
// must be called after bindings were set
setupValidationSupport(errorMessageIcon, errorMessageLabel);
return container;
}
use of org.eclipse.jface.databinding.swt.ISWTObservableValue in project linuxtools by eclipse.
the class ImageSearchPage method createControl.
@Override
public void createControl(final Composite parent) {
final int COLUMNS = 3;
final Composite container = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(1, 1).grab(true, false).applyTo(container);
GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(6, 6).spacing(10, 2).applyTo(container);
// search text
final Label searchImageLabel = new Label(container, SWT.NONE);
searchImageLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ImageSearchPage.imageLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(searchImageLabel);
final Text searchImageText = new Text(container, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(searchImageText);
searchImageText.addKeyListener(onKeyPressed());
searchImageText.addTraverseListener(onSearchImageTextTraverse());
final Button searchImageButton = new Button(container, SWT.NONE);
searchImageButton.setText(// $NON-NLS-1$
WizardMessages.getString("ImageSearchPage.search"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(searchImageButton);
searchImageButton.addSelectionListener(onSearchImageButtonSelected());
// result table
final Label searchResultLabel = new Label(container, SWT.NONE);
searchResultLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ImageSearchPage.searchResultLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(COLUMNS, 1).applyTo(searchResultLabel);
final Table table = new Table(container, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
final TableViewer searchResultTableViewer = new TableViewer(table);
table.setHeaderVisible(true);
table.setLinesVisible(true);
addTableViewerColum(searchResultTableViewer, // $NON-NLS-1$
WizardMessages.getString("ImageSearchPage.nameColumn"), SWT.NONE, SWT.RIGHT, 290, new ImageNameColumnLabelProvider());
addTableViewerColum(searchResultTableViewer, // $NON-NLS-1$
WizardMessages.getString("ImageSearchPage.starsColumn"), SWT.NONE, SWT.RIGHT, 70, new ImageStarsColumnLabelProvider());
addTableViewerColum(searchResultTableViewer, // $NON-NLS-1$
WizardMessages.getString("ImageSearchPage.officialColumn"), SWT.NONE, SWT.CENTER, 70, new ImageOfficialColumnLabelProvider());
addTableViewerColum(searchResultTableViewer, // $NON-NLS-1$
WizardMessages.getString("ImageSearchPage.automatedColumn"), SWT.NONE, SWT.CENTER, 70, new ImageAutomatedColumnLabelProvider());
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(COLUMNS, 1).hint(200, 100).applyTo(table);
// description text area
final Group selectedImageDescriptionGroup = new Group(container, SWT.NONE);
// $NON-NLS-1$
selectedImageDescriptionGroup.setText(WizardMessages.getString("ImageSearchPage.descriptionGroup"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, true).span(COLUMNS, 1).applyTo(selectedImageDescriptionGroup);
GridLayoutFactory.fillDefaults().margins(6, 6).spacing(10, 2).applyTo(selectedImageDescriptionGroup);
final Label selectedImageDescription = new Label(selectedImageDescriptionGroup, SWT.WRAP);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, true).hint(200, 100).applyTo(selectedImageDescription);
// bind the search term
final IObservableValue observableTermModel = BeanProperties.value(ImageSearchModel.class, ImageSearchModel.TERM).observe(model);
final ISWTObservableValue imageSearchTextObservable = WidgetProperties.text(SWT.Modify).observe(searchImageText);
ctx.bindValue(imageSearchTextObservable, observableTermModel, new UpdateValueStrategy().setBeforeSetValidator(new SearchTermValidator(searchImageButton)), null);
// observe the viewer content
searchResultTableViewer.setContentProvider(new ObservableListContentProvider());
// observe the viewer content
final IObservableList observableSearchResultModel = BeanProperties.list(ImageSearchModel.class, ImageSearchModel.IMAGE_SEARCH_RESULT).observe(model);
searchResultTableViewer.setInput(observableSearchResultModel);
// observe the viewer selection
ctx.bindValue(ViewerProperties.singleSelection().observe(searchResultTableViewer), BeanProperties.value(ImageSearchModel.SELECTED_IMAGE).observe(model));
// observe the viewer selection to update the description label
final IObservableValue observableSelectedImageDescription = PojoProperties.value("description", // $NON-NLS-1$
String.class).observeDetail(ViewerProperties.singleSelection().observe(searchResultTableViewer));
ctx.bindValue(WidgetProperties.text().observe(selectedImageDescription), observableSelectedImageDescription);
searchImageText.setFocus();
// attach the Databinding context status to this wizard page.
WizardPageSupport.create(this, this.ctx);
setControl(container);
// trigger a search if an image name was provided
if (model.getTerm() != null && !model.getTerm().isEmpty()) {
searchImages();
}
}
Aggregations