use of org.eclipse.jface.databinding.viewers.ObservableListContentProvider in project linuxtools by eclipse.
the class RunImageMainTab method createImageSettingsSection.
/**
* Creates the {@link Composite} container that will display widgets to
* select an {@link IDockerImage}, name it and specify the command to run.
*
* @param container
* the parent {@link Composite}
*/
private void createImageSettingsSection(final Composite container) {
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).span(3, 1).applyTo(new Label(container, SWT.NONE));
final Label connectionSelectionLabel = new Label(container, SWT.NONE);
connectionSelectionLabel.setText(// $NON-NLS-1$
WizardMessages.getString("Connection.label"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(connectionSelectionLabel);
final Combo connectionSelectionCombo = new Combo(container, SWT.BORDER);
connectionSelectionCombo.setToolTipText(// $NON-NLS-1$
LaunchMessages.getString("RunMainTabSelectConnection.tooltip"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(1, 1).applyTo(connectionSelectionCombo);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).span(1, 1).applyTo(new Label(container, SWT.NONE));
new ControlDecoration(connectionSelectionCombo, SWT.TOP | SWT.LEFT);
final ComboViewer connectionSelectionComboViewer = new ComboViewer(connectionSelectionCombo);
connectionSelectionComboViewer.setContentProvider(new ArrayContentProvider());
connectionSelectionComboViewer.setInput(DockerConnectionManager.getInstance().getConnectionNames().toArray());
dbc.bindValue(WidgetProperties.selection().observe(connectionSelectionCombo), BeanProperties.value(ImageRunSelectionModel.class, ImageRunSelectionModel.SELECTED_CONNECTION_NAME).observe(model));
// Image selection name
final Label imageSelectionLabel = new Label(container, SWT.NONE);
// $NON-NLS-1$
imageSelectionLabel.setText(WizardMessages.getString("Image.label"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(imageSelectionLabel);
final Combo imageSelectionCombo = new Combo(container, SWT.BORDER);
final ComboViewer imageSelectionComboViewer = new ComboViewer(imageSelectionCombo);
imageSelectionCombo.setToolTipText(WizardMessages.getString(// $NON-NLS-1$
"ImageRunSelectionPage.selectTooltip"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(1, 1).applyTo(imageSelectionCombo);
new ControlDecoration(imageSelectionCombo, SWT.TOP | SWT.LEFT);
new ContentProposalAdapter(imageSelectionCombo, 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);
}
}, getImageNameContentProposalProvider(imageSelectionCombo), null, null);
// image search
final Button searchImageButton = new Button(container, SWT.NONE);
searchImageButton.setText(// $NON-NLS-1$
WizardMessages.getString("ImageRunSelectionPage.search"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).span(1, 1).hint(LaunchConfigurationUtils.getButtonWidthHint(searchImageButton), SWT.DEFAULT).applyTo(searchImageButton);
searchImageButton.addSelectionListener(onSearchImage());
imageSelectionComboViewer.setContentProvider(new ObservableListContentProvider());
dbc.bindList(WidgetProperties.items().observe(imageSelectionCombo), BeanProperties.list(ImageRunSelectionModel.class, ImageRunSelectionModel.IMAGE_NAMES).observe(model));
dbc.bindValue(WidgetProperties.selection().observe(imageSelectionCombo), BeanProperties.value(ImageRunSelectionModel.class, ImageRunSelectionModel.SELECTED_IMAGE_NAME).observe(model));
// Container name (optional)
final Label containerNameLabel = new Label(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(imageSelectionLabel);
containerNameLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ImageRunSelectionPage.containerName"));
final Text containerNameText = new Text(container, SWT.BORDER);
containerNameText.setToolTipText(WizardMessages.getString(// $NON-NLS-1$
"ImageRunSelectionPage.containerTooltip"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(1, 1).applyTo(containerNameText);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).span(1, 1).applyTo(new Label(container, SWT.NONE));
dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(containerNameText), BeanProperties.value(ImageRunSelectionModel.class, ImageRunSelectionModel.CONTAINER_NAME).observe(model));
// EntryPoint (optional)
final Label entrypointLabel = new Label(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(imageSelectionLabel);
entrypointLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ImageRunSelectionPage.entrypoint"));
// TODO: include SWT.SEARCH | SWT.ICON_SEARCH to support value reset
final Text entrypointText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(1, 1).applyTo(entrypointText);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).span(1, 1).applyTo(new Label(container, SWT.NONE));
dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(entrypointText), BeanProperties.value(ImageRunSelectionModel.class, ImageRunSelectionModel.ENTRYPOINT).observe(model));
// Command (optional)
final Label commandLabel = new Label(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(imageSelectionLabel);
commandLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ImageRunSelectionPage.command"));
final Text commandText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(1, 1).applyTo(commandText);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).span(1, 1).applyTo(new Label(container, SWT.NONE));
dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(commandText), BeanProperties.value(ImageRunSelectionModel.class, ImageRunSelectionModel.COMMAND).observe(model));
}
use of org.eclipse.jface.databinding.viewers.ObservableListContentProvider in project linuxtools by eclipse.
the class ImageRunSelectionPage method createPortSettingsTable.
private CheckboxTableViewer createPortSettingsTable(final Composite container) {
final Table table = new Table(container, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWT.CHECK);
final CheckboxTableViewer tableViewer = new CheckboxTableViewer(table);
table.setHeaderVisible(true);
table.setLinesVisible(true);
createTableViewerColum(tableViewer, WizardMessages.getString(// $NON-NLS-1$
"ImageRunSelectionPage.containerPortColumn"), 100);
createTableViewerColum(tableViewer, // $NON-NLS-1$
WizardMessages.getString("ImageRunSelectionPage.typeColumn"), 50);
createTableViewerColum(tableViewer, WizardMessages.getString(// $NON-NLS-1$
"ImageRunSelectionPage.hostAddressColumn"), 100);
createTableViewerColum(tableViewer, WizardMessages.getString(// $NON-NLS-1$
"ImageRunSelectionPage.hostPortColumn"), 100);
tableViewer.setContentProvider(new ObservableListContentProvider());
return tableViewer;
}
use of org.eclipse.jface.databinding.viewers.ObservableListContentProvider in project linuxtools by eclipse.
the class ImageTagSelectionPage method createControl.
@SuppressWarnings("unchecked")
@Override
public void createControl(final Composite parent) {
final int COLUMNS = 1;
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);
// tags/layers table
final Table table = new Table(container, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(COLUMNS, 1).hint(200, 200).applyTo(table);
final TableViewer tableViewer = new TableViewer(table);
table.setHeaderVisible(true);
table.setLinesVisible(true);
addTableViewerColum(tableViewer, // $NON-NLS-1$
WizardMessages.getString("ImageTagSelectionPage.column.tag"), SWT.NONE, SWT.LEFT, 200, new RepositoryTagColumnLabelProvider());
addTableViewerColum(tableViewer, // $NON-NLS-1$
WizardMessages.getString("ImageTagSelectionPage.column.layer"), SWT.NONE, SWT.LEFT, 200, new RepositoryLayerColumnLabelProvider());
addTableViewerColum(tableViewer, WizardMessages.getString(// $NON-NLS-1$
"ImageTagSelectionPage.column.localcopy"), SWT.NONE, SWT.LEFT, 75, new ImagePulledColumnLabelProvider());
tableViewer.setContentProvider(new ObservableListContentProvider());
// observe the viewer content
final IObservableList<?> observableSearchResultModel = BeanProperties.list(ImageSearchModel.class, ImageSearchModel.IMAGE_TAG_SEARCH_RESULT).observe(model);
tableViewer.setInput(observableSearchResultModel);
// observe the viewer selection
ctx.bindValue(ViewerProperties.singleSelection().observe(tableViewer), BeanProperties.value(ImageSearchModel.SELECTED_IMAGE_TAG).observe(model));
setControl(container);
}
use of org.eclipse.jface.databinding.viewers.ObservableListContentProvider in project eclipse-pmd by acanda.
the class AddRuleSetConfigurationWizardPage method initDataBindings.
private DataBindingContext initDataBindings() {
final DataBindingContext bindingContext = new DataBindingContext();
//
final IObservableValue locationObserveText = SWTObservables.observeDelayedValue(200, SWTObservables.observeText(location, SWT.Modify));
final IObservableValue locationObserveValue = BeansObservables.observeValue(controller.getModel(), "location");
bindingContext.bindValue(locationObserveText, locationObserveValue, null, null);
//
final ObservableListContentProvider rulesContentProvider = new ObservableListContentProvider();
final IObservableMap rulesObserveMap = PojoObservables.observeMap(rulesContentProvider.getKnownElements(), Rule.class, "name");
tableViewer.setLabelProvider(new ObservableMapLabelProvider(rulesObserveMap));
tableViewer.setContentProvider(rulesContentProvider);
//
final IObservableList rulesObserveList = BeansObservables.observeList(Realm.getDefault(), controller.getModel(), "rules");
tableViewer.setInput(rulesObserveList);
//
final IObservableValue nameObserveTextObserveWidget = SWTObservables.observeDelayedValue(100, SWTObservables.observeText(name, SWT.Modify));
final IObservableValue controllergetModelNameObserveValue = BeansObservables.observeValue(controller.getModel(), "name");
bindingContext.bindValue(nameObserveTextObserveWidget, controllergetModelNameObserveValue, null, null);
//
final IObservableValue observeVisibleBrowseObserveWidget = WidgetProperties.visible().observe(browse);
final IObservableValue browseEnabledControllergetModelObserveValue = BeanProperties.value("browseEnabled").observe(controller.getModel());
bindingContext.bindValue(observeVisibleBrowseObserveWidget, browseEnabledControllergetModelObserveValue, null, null);
//
return bindingContext;
}
Aggregations