use of org.eclipse.jface.databinding.viewers.ObservableListContentProvider in project linuxtools by eclipse.
the class ImageRunSelectionPage 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) {
// Image selection name
final Label imageSelectionLabel = new Label(container, SWT.NONE);
imageSelectionLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ImageRunSelectionPage.imageName"));
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).applyTo(searchImageButton);
searchImageButton.addSelectionListener(onSearchImage());
// link to pull image
final Label fillerLabel = new Label(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).span(1, 1).applyTo(fillerLabel);
pullImageLink = new Link(container, SWT.NONE);
pullImageLink.setText(// $NON-NLS-1$
WizardMessages.getString("ImageRunSelectionPage.pullImage"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(COLUMNS - 1, 1).applyTo(pullImageLink);
pullImageLink.addSelectionListener(onPullImage());
dbc.bindValue(WidgetProperties.enabled().observe(pullImageLink), BeanProperties.value(ImageRunSelectionModel.class, ImageRunSelectionModel.SELECTED_IMAGE_NEEDS_PULLING).observe(model));
// bind combo with model (for values and selection)
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 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();
}
}
use of org.eclipse.jface.databinding.viewers.ObservableListContentProvider in project linuxtools by eclipse.
the class ConfigureLabelsPage method createLabelVariablesTable.
private TableViewer createLabelVariablesTable(Composite container) {
final Table table = new Table(container, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
final TableViewer tableViewer = new TableViewer(table);
table.setHeaderVisible(true);
table.setLinesVisible(true);
addTableViewerColumn(tableViewer, WizardMessages.getString(// $NON-NLS-1$
"ImageRunResourceVolVarPage.nameColumn"), 200);
addTableViewerColumn(tableViewer, WizardMessages.getString(// $NON-NLS-1$
"ImageRunResourceVolVarPage.valueColumn"), 200);
tableViewer.setContentProvider(new ObservableListContentProvider());
return tableViewer;
}
use of org.eclipse.jface.databinding.viewers.ObservableListContentProvider in project eclipse-pmd by acanda.
the class RuleSetConfigurationTable method initDataBindings.
private void initDataBindings() {
final DataBindingContext bindingContext = new DataBindingContext();
//
final ObservableListContentProvider listContentProvider = new ObservableListContentProvider();
tableViewer.setContentProvider(listContentProvider);
//
final IObservableList ruleSetsObserveList = BeansObservables.observeList(Realm.getDefault(), model, "ruleSets");
tableViewer.setInput(ruleSetsObserveList);
//
final IObservableValue tableObserveEnabledObserveWidget = SWTObservables.observeEnabled(table);
final IObservableValue modelPMDEnabledObserveValue = BeansObservables.observeValue(model, "PMDEnabled");
bindingContext.bindValue(tableObserveEnabledObserveWidget, modelPMDEnabledObserveValue, null, null);
//
final IObservableList tableViewerObserveMultiSelection = ViewersObservables.observeMultiSelection(tableViewer);
final IObservableList selectedRuleSetsObserveList = BeansObservables.observeList(Realm.getDefault(), model, "selectedRuleSets");
bindingContext.bindList(tableViewerObserveMultiSelection, selectedRuleSetsObserveList, null, null);
//
final IObservableSet tableViewerObserveCheckedElements = ViewersObservables.observeCheckedElements(tableViewer, RuleSetViewModel.class);
final IObservableSet activeConfigurationsObserveSet = BeansObservables.observeSet(Realm.getDefault(), model, "activeRuleSets");
bindingContext.bindSet(tableViewerObserveCheckedElements, activeConfigurationsObserveSet, null, null);
}
use of org.eclipse.jface.databinding.viewers.ObservableListContentProvider in project linuxtools by eclipse.
the class RunImageLabelsTab method createLabelVariablesTable.
private TableViewer createLabelVariablesTable(Composite container) {
final Table table = new Table(container, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
final TableViewer tableViewer = new TableViewer(table);
table.setHeaderVisible(true);
table.setLinesVisible(true);
addTableViewerColumn(tableViewer, WizardMessages.getString(// $NON-NLS-1$
"ImageRunResourceVolVarPage.nameColumn"), 200);
addTableViewerColumn(tableViewer, WizardMessages.getString(// $NON-NLS-1$
"ImageRunResourceVolVarPage.valueColumn"), 200);
tableViewer.setContentProvider(new ObservableListContentProvider());
return tableViewer;
}
Aggregations