use of org.eclipse.jface.viewers.ComboViewer in project eclipse.platform.text by eclipse.
the class LinkedModeConfigurationBlock method createControl.
/**
* Creates page for hover preferences.
*
* @param parent the parent composite
* @return the control for the preference page
*/
@Override
public Control createControl(Composite parent) {
OverlayPreferenceStore store = getPreferenceStore();
store.load();
store.start();
initializeDialogUnits(parent);
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
composite.setLayout(layout);
Label label = new Label(composite, SWT.LEFT);
label.setText(TextEditorMessages.LinkedModeConfigurationBlock_annotationPresentationOptions);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
label.setLayoutData(gd);
Composite editorComposite = new Composite(composite, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
editorComposite.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
editorComposite.setLayoutData(gd);
fAnnotationTypeViewer = new TableViewer(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
fAnnotationTypeViewer.setLabelProvider(new ItemLabelProvider());
fAnnotationTypeViewer.setContentProvider(new ItemContentProvider());
gd = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
gd.heightHint = convertHeightInCharsToPixels(5);
fAnnotationTypeViewer.getControl().setLayoutData(gd);
Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
optionsComposite.setLayout(layout);
optionsComposite.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
// we only allow to set either "show in text" or "highlight in text", but not both
fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
fShowInTextCheckBox.setText(TextEditorMessages.LinkedModeConfigurationBlock_labels_showIn);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.BEGINNING;
fShowInTextCheckBox.setLayoutData(gd);
fDecorationViewer = new ComboViewer(optionsComposite, SWT.READ_ONLY);
fDecorationViewer.setContentProvider(new ArrayContentProvider());
fDecorationViewer.setLabelProvider(new ArrayLabelProvider());
fDecorationViewer.setComparator(new ViewerComparator(Collator.getInstance()));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.BEGINNING;
fDecorationViewer.getControl().setLayoutData(gd);
fDecorationViewer.setInput(new Object[] { HIGHLIGHT, SQUIGGLES, BOX, DASHED_BOX, UNDERLINE, IBEAM });
label = new Label(optionsComposite, SWT.LEFT);
label.setText(TextEditorMessages.LinkedModeConfigurationBlock_color);
gd = new GridData();
gd.horizontalAlignment = GridData.BEGINNING;
label.setLayoutData(gd);
fAnnotationForegroundColorEditor = new ColorSelector(optionsComposite);
Button foregroundColorButton = fAnnotationForegroundColorEditor.getButton();
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.BEGINNING;
foregroundColorButton.setLayoutData(gd);
createDependency(fShowInTextCheckBox, new Control[] { label, foregroundColorButton });
fAnnotationTypeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
handleAnnotationListSelection();
}
});
fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
@Override
public void widgetSelected(SelectionEvent e) {
ListItem item = getSelectedItem();
final boolean value = fShowInTextCheckBox.getSelection();
if (value) {
// enable whatever is in the combo
String[] decoration = (String[]) ((IStructuredSelection) fDecorationViewer.getSelection()).getFirstElement();
if (HIGHLIGHT.equals(decoration))
getPreferenceStore().setValue(item.highlightKey, true);
else
getPreferenceStore().setValue(item.textKey, true);
} else {
// disable both
getPreferenceStore().setValue(item.textKey, false);
getPreferenceStore().setValue(item.highlightKey, false);
}
getPreferenceStore().setValue(item.textKey, value);
updateDecorationViewer(item, false);
}
});
foregroundColorButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
@Override
public void widgetSelected(SelectionEvent e) {
ListItem item = getSelectedItem();
PreferenceConverter.setValue(getPreferenceStore(), item.colorKey, fAnnotationForegroundColorEditor.getColorValue());
}
});
fDecorationViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
String[] decoration = (String[]) ((IStructuredSelection) fDecorationViewer.getSelection()).getFirstElement();
ListItem item = getSelectedItem();
if (fShowInTextCheckBox.getSelection()) {
if (HIGHLIGHT.equals(decoration)) {
getPreferenceStore().setValue(item.highlightKey, true);
getPreferenceStore().setValue(item.textKey, false);
getPreferenceStore().setValue(item.textStyleKey, AnnotationPreference.STYLE_NONE);
} else {
getPreferenceStore().setValue(item.highlightKey, false);
getPreferenceStore().setValue(item.textKey, true);
getPreferenceStore().setValue(item.textStyleKey, decoration[1]);
}
}
}
});
return composite;
}
use of org.eclipse.jface.viewers.ComboViewer in project linuxtools by eclipse.
the class BuildDockerImageLaunchConfigurationMainTab method createControl.
@Override
public void createControl(final Composite parent) {
final Composite container = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(container);
GridLayoutFactory.fillDefaults().margins(6, 6).applyTo(container);
setControl(container);
// connection selection
final Group connectionGroup = new Group(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(connectionGroup);
GridLayoutFactory.fillDefaults().numColumns(2).margins(6, 6).applyTo(connectionGroup);
connectionGroup.setText(LaunchMessages.getString(CONNECTION_LABEL));
connectionGroup.setToolTipText(LaunchMessages.getString(CONNECTION_TOOLTIP));
final Combo connectionSelectionCombo = new Combo(connectionGroup, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(connectionSelectionCombo);
this.connectionSelectionComboViewer = new ComboViewer(connectionSelectionCombo);
this.connectionSelectionComboViewer.setContentProvider(new ArrayContentProvider());
this.connectionSelectionComboViewer.setInput(DockerConnectionManager.getInstance().getConnectionNames());
connectionSelectionCombo.addSelectionListener(new LaunchConfigurationChangeListener());
// build context path
createBuildContextPathGroup(container);
// repository name
createRepoNameGroup(container);
// dockerfile path
// createDockerfilePathGroup(container);
// build options
createBuildOptionsGroup(container);
}
use of org.eclipse.jface.viewers.ComboViewer in project linuxtools by eclipse.
the class DockerComposeUpLaunchConfigurationMainTab method createControl.
@Override
public void createControl(final Composite parent) {
final Composite container = new Composite(parent, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(container);
GridLayoutFactory.fillDefaults().margins(6, 6).applyTo(container);
setControl(container);
// connection selection
final Group connectionGroup = new Group(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(connectionGroup);
GridLayoutFactory.fillDefaults().numColumns(2).margins(6, 6).applyTo(connectionGroup);
connectionGroup.setText(LaunchMessages.getString(// $NON-NLS-1$
"DockerComposeUpLaunchConfigurationMainTab.connection.group.label"));
connectionGroup.setToolTipText(LaunchMessages.getString(// $NON-NLS-1$
"DockerComposeUpLaunchConfigurationMainTab.connection.group.tooltip"));
final Combo connectionSelectionCombo = new Combo(connectionGroup, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(connectionSelectionCombo);
this.connectionSelectionComboViewer = new ComboViewer(connectionSelectionCombo);
this.connectionSelectionComboViewer.setContentProvider(new ArrayContentProvider());
this.connectionSelectionComboViewer.setInput(DockerConnectionManager.getInstance().getConnectionNames());
connectionSelectionCombo.addSelectionListener(new LaunchConfigurationChangeListener());
// docker compose config file
createDockerComposeWorkingDirLocationGroup(container);
}
use of org.eclipse.jface.viewers.ComboViewer 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.viewers.ComboViewer in project linuxtools by eclipse.
the class JavaImageTab method createControl.
@Override
public void createControl(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);
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);
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;
if (conn == null || conn.getImages() == null) {
return new Object[0];
} else {
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();
selectedConnection = conn;
imageCmb.setInput(conn);
updateLaunchConfigurationDialog();
}
});
imageCmb.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = event.getStructuredSelection();
IDockerImage img = (IDockerImage) sel.getFirstElement();
selectedImage = img;
updateLaunchConfigurationDialog();
}
});
Group dirGroup = new Group(composite, SWT.NONE);
dirGroup.setText(Messages.JavaImageTab_additional_dirs);
dirGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
dirGroup.setLayout(new GridLayout(2, false));
directoryList = new List(dirGroup, SWT.SINGLE | SWT.V_SCROLL);
directoryList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
directoryList.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
removeButton.setEnabled(true);
}
});
addButton = createPushButton(dirGroup, Messages.JavaImageTab_button_add, null);
addButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
addButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(getShell());
String directory = dialog.open();
if (directory != null && !listContains(directoryList, directory)) {
directoryList.add(directory);
updateLaunchConfigurationDialog();
}
}
});
removeButton = createPushButton(dirGroup, Messages.JavaImageTab_button_remove, null);
removeButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, true));
removeButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int i = directoryList.getSelectionIndex();
if (i >= 0) {
directoryList.remove(i);
updateLaunchConfigurationDialog();
}
if (directoryList.getItemCount() == 0) {
removeButton.setEnabled(false);
}
}
});
removeButton.setEnabled(false);
setControl(composite);
}
Aggregations