use of org.eclipse.jface.viewers.ComboViewer in project linuxtools by eclipse.
the class ImageSelectionDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
Label connLbl = new Label(composite, SWT.NONE);
connLbl.setText(Messages.ImageSelectionDialog_connection_label);
ComboViewer connCmb = new ComboViewer(composite, SWT.READ_ONLY);
connCmb.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
connCmb.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
for (IDockerConnection conn : DockerConnectionManager.getInstance().getAllConnections()) {
try {
((DockerConnection) conn).open(false);
} catch (DockerException e) {
}
}
return DockerConnectionManager.getInstance().getAllConnections().stream().filter(c -> c.isOpen()).toArray(size -> new IDockerConnection[size]);
}
});
// $NON-NLS-1$
connCmb.setInput("place_holder");
Label imageLbl = new Label(composite, SWT.NONE);
imageLbl.setText(Messages.ImageSelectionDialog_image_label);
ComboViewer imageCmb = new ComboViewer(composite, SWT.READ_ONLY);
imageCmb.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
imageCmb.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
IDockerConnection conn = (IDockerConnection) inputElement;
return conn.getImages().stream().filter(// $NON-NLS-1$
i -> !i.repoTags().get(0).equals("<none>:<none>")).toArray(size -> new IDockerImage[size]);
}
});
imageCmb.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
IDockerImage img = (IDockerImage) element;
return img.repoTags().get(0);
}
});
imageCmb.setInput(null);
connCmb.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = event.getStructuredSelection();
IDockerConnection conn = (IDockerConnection) sel.getFirstElement();
connection = conn;
imageCmb.setInput(conn);
}
});
imageCmb.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = event.getStructuredSelection();
IDockerImage img = (IDockerImage) sel.getFirstElement();
image = img;
getOkButton().setEnabled(true);
}
});
return composite;
}
use of org.eclipse.jface.viewers.ComboViewer in project linuxtools by eclipse.
the class NewProjectCreationPage method createControl.
@Override
public void createControl(Composite parent) {
super.createControl(parent);
Composite control = (Composite) getControl();
Composite projectTypeGroup = new Composite(control, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
projectTypeGroup.setLayout(layout);
projectTypeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label typeLabel = new Label(projectTypeGroup, SWT.NONE);
// $NON-NLS-1$
typeLabel.setText(Messages.getString("SRPMImportPage.4"));
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.grabExcessHorizontalSpace = true;
typeCombo = new ComboViewer(projectTypeGroup, SWT.READ_ONLY);
typeCombo.getControl().setLayoutData(data);
typeCombo.setContentProvider(ArrayContentProvider.getInstance());
typeCombo.setInput(RPMProjectLayout.values());
typeCombo.getCombo().select(0);
// Working set controls
Control workingSetControl = wsGroup.createControl(control);
workingSetControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
use of org.eclipse.jface.viewers.ComboViewer in project linuxtools by eclipse.
the class RPMDetailsPanel method initialize.
private void initialize() {
Button defaultSettings = new Button(parent, SWT.CHECK);
// $NON-NLS-1$
defaultSettings.setText(Messages.getString("SRPMImportPage.0"));
defaultSettings.setSelection(true);
final Group specGrid = new Group(parent, SWT.NONE);
defaultSettings.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
if (defaultSettings.getSelection()) {
for (Control control : specGrid.getChildren()) {
specGrid.setEnabled(false);
control.setEnabled(false);
}
} else {
for (Control control : specGrid.getChildren()) {
specGrid.setEnabled(true);
control.setEnabled(true);
}
}
}));
GridLayout layout = new GridLayout();
layout.numColumns = 3;
specGrid.setLayout(layout);
// $NON-NLS-1$
specGrid.setText(Messages.getString("SRPMImportPage.1"));
specGrid.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
specGrid.setEnabled(false);
Label locationLabel = new Label(specGrid, SWT.NULL);
// $NON-NLS-1$
locationLabel.setText(Messages.getString("SRPMImportPage.2"));
locationLabel.setEnabled(false);
locationPath = new Text(specGrid, SWT.SINGLE | SWT.BORDER);
locationPath.setEnabled(false);
locationPath.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
Button containerBrowseButton = new Button(specGrid, SWT.PUSH);
// $NON-NLS-1$
containerBrowseButton.setText(Messages.getString("SRPMImportPage.3"));
containerBrowseButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
containerBrowseButton.setEnabled(false);
final Composite projectTypeGroup = new Composite(parent, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
projectTypeGroup.setLayout(layout);
projectTypeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label typeLabel = new Label(projectTypeGroup, SWT.NULL);
// $NON-NLS-1$
typeLabel.setText(Messages.getString("SRPMImportPage.4"));
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
typeCombo = new ComboViewer(projectTypeGroup, SWT.READ_ONLY);
typeCombo.getCombo().setLayoutData(gridData);
typeCombo.setContentProvider(ArrayContentProvider.getInstance());
typeCombo.setInput(RPMProjectLayout.values());
typeCombo.setSelection(new StructuredSelection(RPMProjectLayout.RPMBUILD));
}
use of org.eclipse.jface.viewers.ComboViewer 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.viewers.ComboViewer 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;
}
Aggregations