use of org.eclipse.jface.fieldassist.ControlDecoration in project bndtools by bndtools.
the class TemplateParamsWizardPage method createFieldControl.
private Control createFieldControl(Composite parent, final AttributeDefinition ad) {
switch(ad.getType()) {
case AttributeDefinition.STRING:
case AttributeDefinition.INTEGER:
final Text text = new Text(parent, SWT.BORDER);
if (ad.getName() != null)
text.setMessage(ad.getName());
if (ad.getDescription() != null) {
ControlDecoration decor = new ControlDecoration(text, SWT.LEFT, parent);
decor.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
decor.setShowHover(true);
decor.setDescriptionText(ad.getDescription());
decor.setMarginWidth(5);
}
String[] defaultValue = ad.getDefaultValue();
if (defaultValue != null && defaultValue.length == 1) {
text.setText(defaultValue[0]);
values.put(ad.getID(), defaultValue[0]);
}
text.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent ev) {
values.put(ad.getID(), text.getText());
updateValidation();
}
});
return text;
default:
Label label = new Label(parent, SWT.NONE);
label.setText("<Unknown Attribute Type>");
label.setFont(JFaceResources.getFontRegistry().getItalic(JFaceResources.DEFAULT_FONT));
label.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR));
return label;
}
}
use of org.eclipse.jface.fieldassist.ControlDecoration in project bndtools by bndtools.
the class IndexerWizardPage method createControl.
@Override
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NULL);
setControl(composite);
// Create controls
new Label(composite, SWT.NONE).setText(Messages.IndexerWizardPage_baseDir);
txtBaseDir = new Text(composite, SWT.BORDER);
newSpacer(composite);
Composite cmpButtonBar = new Composite(composite, SWT.NONE);
Button btnBrowseWorkspace = new Button(cmpButtonBar, SWT.PUSH);
btnBrowseWorkspace.setText(Messages.IndexerWizardPage_browse);
Button btnBrowseExternal = new Button(cmpButtonBar, SWT.PUSH);
btnBrowseExternal.setText(Messages.IndexerWizardPage_browseExternal);
new Label(composite, SWT.NONE).setText(Messages.IndexerWizardPage_resourcePattern);
txtResourcePattern = new Text(composite, SWT.BORDER);
ControlDecoration decorResourcePattern = new ControlDecoration(txtResourcePattern, SWT.LEFT | SWT.TOP, composite);
decorResourcePattern.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
decorResourcePattern.setMarginWidth(3);
decorResourcePattern.setDescriptionText(Messages.IndexerWizardPage_resourcePatternHelp);
decorResourcePattern.setShowHover(true);
decorResourcePattern.setShowOnlyOnFocus(false);
Label lblInputs = new Label(composite, SWT.NONE);
lblInputs.setText(Messages.IndexerWizardPage_inputs);
Table tblInputs = new Table(composite, SWT.MULTI | SWT.BORDER);
vwrInputs = new TableViewer(tblInputs);
vwrInputs.setContentProvider(ArrayContentProvider.getInstance());
vwrInputs.setLabelProvider(new StyledCellLabelProvider() {
@Override
public void update(ViewerCell cell) {
Object elem = cell.getElement();
if (elem instanceof Path) {
cell.setText(elem.toString());
cell.setImage(imgFile);
} else if (elem instanceof IStatus) {
IStatus status = (IStatus) elem;
cell.setText(status.getMessage());
if (status.getSeverity() == IStatus.ERROR)
cell.setImage(imgError);
else if (status.getSeverity() == IStatus.WARNING)
cell.setImage(imgWarning);
}
}
});
newSpacer(composite);
lblInputCount = new Label(composite, SWT.NONE);
Label lblOutputs = new Label(composite, SWT.NONE);
lblOutputs.setText(Messages.IndexerWizardPage_output);
Group grpOutput = new Group(composite, SWT.NONE);
new Label(grpOutput, SWT.NONE).setText(Messages.IndexerWizardPage_prefix);
txtOutputPrefix = new Text(grpOutput, SWT.BORDER);
newSpacer(grpOutput);
btnOutputPretty = new Button(grpOutput, SWT.RADIO);
btnOutputPretty.setText(Messages.IndexerWizardPage_prettyPrint);
newSpacer(grpOutput);
btnOutputCompressed = new Button(grpOutput, SWT.RADIO);
btnOutputCompressed.setText(Messages.IndexerWizardPage_compressed);
newSpacer(grpOutput);
lblOutputName = new Label(grpOutput, SWT.NONE);
// LAYOUT
GridLayout gl;
GridData gd;
gl = new GridLayout(2, false);
gl.horizontalSpacing = 10;
composite.setLayout(gl);
txtBaseDir.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
cmpButtonBar.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false));
gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
cmpButtonBar.setLayout(gl);
btnBrowseWorkspace.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
btnBrowseExternal.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
txtResourcePattern.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
lblInputs.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
gd.heightHint = 120;
gd.widthHint = 100;
tblInputs.setLayoutData(gd);
lblInputCount.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
lblOutputs.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
grpOutput.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
grpOutput.setLayout(new GridLayout(2, false));
txtOutputPrefix.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
btnOutputCompressed.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
btnOutputPretty.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
lblOutputName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
// LOAD DATA
if (baseDir != null)
txtBaseDir.setText(baseDir.getAbsolutePath());
if (resourcePattern != null)
txtResourcePattern.setText(resourcePattern);
//$NON-NLS-1$
txtOutputPrefix.setText("index");
btnOutputCompressed.setSelection(outputStyle == IndexFormatStyle.COMPRESSED);
btnOutputPretty.setSelection(outputStyle == IndexFormatStyle.PRETTY_UNCOMPRESSED);
updateOutputFileName();
updateInputs();
// LISTENERS
txtBaseDir.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent me) {
String baseDirStr = txtBaseDir.getText();
baseDir = baseDirStr.isEmpty() ? null : new File(baseDirStr);
validate();
updateInputs();
}
});
txtResourcePattern.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent me) {
resourcePattern = txtResourcePattern.getText();
updateInputs();
}
});
btnBrowseWorkspace.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
ContainerSelectionDialog containerDlg = new ContainerSelectionDialog(getShell(), root, false, Messages.IndexerWizardPage_selectBaseDir);
containerDlg.showClosedProjects(false);
if (containerDlg.open() == Window.OK) {
Object[] selection = containerDlg.getResult();
if (selection != null && selection.length > 0) {
IPath workspacePath = (IPath) selection[0];
IResource resource = root.findMember(workspacePath);
if (resource == null)
MessageDialog.openError(getShell(), "Error", "Could not find resource for path " + workspacePath);
else
txtBaseDir.setText(resource.getLocation().toString());
}
}
}
});
btnBrowseExternal.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dirDialog = new DirectoryDialog(getShell());
dirDialog.setMessage(Messages.IndexerWizardPage_selectBaseDir);
String selectedPath = dirDialog.open();
if (selectedPath != null)
txtBaseDir.setText(selectedPath);
}
});
txtOutputPrefix.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent me) {
updateOutputFileName();
validate();
}
});
Listener outputRadioListener = new Listener() {
@Override
public void handleEvent(Event ev) {
outputStyle = btnOutputCompressed.getSelection() ? IndexFormatStyle.COMPRESSED : IndexFormatStyle.PRETTY_UNCOMPRESSED;
updateOutputFileName();
validate();
}
};
btnOutputCompressed.addListener(SWT.Selection, outputRadioListener);
btnOutputPretty.addListener(SWT.Selection, outputRadioListener);
validate();
}
use of org.eclipse.jface.fieldassist.ControlDecoration in project eclipse.platform.text by eclipse.
the class AbstractControlContentAssistSubjectAdapter method setContentAssistCueProvider.
/**
* Sets the visual feedback provider for content assist.
* The given {@link ILabelProvider} methods are called with
* {@link #getControl()} as argument.
*
* <ul>
* <li><code>getImage(Object)</code> provides the visual cue image.
* The image can maximally be 5 pixels wide and 8 pixels high.
* If <code>getImage(Object)</code> returns <code>null</code>, a default image is used.
* </li>
* <li><code>getText(Object)</code> provides the hover info text.
* It is shown when hovering over the cue image or the adapted {@link Control}.
* No info text is shown if <code>getText(Object)</code> returns <code>null</code>.
* </li>
* </ul>
* <p>
* The given {@link ILabelProvider} becomes owned by the {@link AbstractControlContentAssistSubjectAdapter},
* i.e. it gets disposed when the adapted {@link Control} is disposed
* or when another {@link ILabelProvider} is set.
* </p>
*
* @param labelProvider a {@link ILabelProvider}, or <code>null</code>
* if no visual feedback should be shown
*/
public void setContentAssistCueProvider(final ILabelProvider labelProvider) {
if (fCueLabelProvider != null) {
fCueLabelProvider.dispose();
}
fCueLabelProvider = labelProvider;
if (labelProvider == null) {
if (fControlDecoration != null) {
fControlDecoration.dispose();
fControlDecoration = null;
}
} else {
if (fControlDecoration == null) {
fControlDecoration = new ControlDecoration(getControl(), (SWT.TOP | SWT.LEFT));
getControl().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (fCueLabelProvider != null) {
fCueLabelProvider.dispose();
fCueLabelProvider = null;
}
if (fControlDecoration != null) {
fControlDecoration.dispose();
fControlDecoration = null;
}
if (fCachedDefaultCueImage != null) {
fCachedDefaultCueImage.dispose();
fCachedDefaultCueImage = null;
}
}
});
fControlDecoration.setShowHover(true);
fControlDecoration.setShowOnlyOnFocus(true);
}
ILabelProviderListener listener = new ILabelProviderListener() {
@Override
public void labelProviderChanged(LabelProviderChangedEvent event) {
fControlDecoration.setDescriptionText(labelProvider.getText(getControl()));
Image image = labelProvider.getImage(getControl());
if (image == null)
image = getDefaultCueImage();
fControlDecoration.setImage(image);
}
};
labelProvider.addListener(listener);
// initialize control decoration:
listener.labelProviderChanged(new LabelProviderChangedEvent(labelProvider));
}
}
use of org.eclipse.jface.fieldassist.ControlDecoration 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));
}
Aggregations