use of org.eclipse.jface.fieldassist.ContentProposalAdapter 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.fieldassist.ContentProposalAdapter in project dbeaver by serge-rider.
the class UIUtils method installContentProposal.
public static void installContentProposal(Control control, IControlContentAdapter contentAdapter, IContentProposalProvider provider, boolean autoActivation) {
try {
KeyStroke keyStroke = autoActivation ? null : KeyStroke.getInstance("Ctrl+Space");
final ContentProposalAdapter proposalAdapter = new ContentProposalAdapter(control, contentAdapter, provider, keyStroke, autoActivation ? ".abcdefghijklmnopqrstuvwxyz_$(".toCharArray() : ".(".toCharArray());
proposalAdapter.setPopupSize(new Point(300, 200));
} catch (ParseException e) {
log.error("Error installing filters content assistant");
}
}
use of org.eclipse.jface.fieldassist.ContentProposalAdapter in project mechanoid by robotoworks.
the class PackageBrowserField method attachProposalProvider.
private void attachProposalProvider() {
try {
mProposalProvider = new PackageProposalProvider();
mPackageProposalAdapter = new ContentProposalAdapter(getTextField(), new TextContentAdapter(), mProposalProvider, KeyStroke.getInstance("Ctrl+Space"), new char[] { '.' });
mPackageProposalAdapter.setLabelProvider(new LabelProvider() {
@Override
public Image getImage(Object element) {
return mPackageImage;
}
@Override
public String getText(Object element) {
PackageProposal p = (PackageProposal) element;
return p.getContent();
}
});
mPackageProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
} catch (ParseException e) {
e.printStackTrace();
}
}
use of org.eclipse.jface.fieldassist.ContentProposalAdapter in project tdi-studio-se by Talend.
the class BatchExpressionComposite method createEditorProposal.
/**
* Creates proposal for editor.
*/
private void createEditorProposal() {
try {
// create KeyStroke use Ctrl+Space as default
KeyStroke keyStroke = HotKeyUtil.getHotKey(HotKeyUtil.contentAssist);
IControlContentAdapter controlContentAdapter = new StyledTextContentAdapter();
// TDI-25309 :expression builder UDF autocompletion need add the inputTable node
if (GlobalServiceRegister.getDefault().isServiceRegistered(IPigMapService.class)) {
final IPigMapService service = (IPigMapService) GlobalServiceRegister.getDefault().getService(IPigMapService.class);
ContentProposalAdapterExtended proposalAdaptor = ProposalUtils.getCommonProposal(textControl, service.createExpressionProposalProvider(dataBean));
new ContentProposalAdapter(textControl, controlContentAdapter, service.createExpressionProposalProvider(dataBean), keyStroke, new char[] { ' ', '.' });
}
} catch (Exception e) {
//
}
}
use of org.eclipse.jface.fieldassist.ContentProposalAdapter in project tdi-studio-se by Talend.
the class TalendEditorComponentCreationAssist method createAssistText.
private void createAssistText(org.eclipse.swt.graphics.Point cursorRelativePosition) {
// disable key event filter on Display
if (bindingService != null) {
bindingService.setKeyFilterEnabled(false);
}
highlightOveredConnection(cursorRelativePosition);
// create assist input text
assistText = new Text((Composite) graphicControl, SWT.BORDER);
assistText.setLocation(cursorRelativePosition.x, cursorRelativePosition.y - assistText.getLineHeight());
assistText.setSize(200, assistText.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
assistText.setFocus();
/*
* create the proposal by using available components list
*/
// TODO the trigger way may need improved, currently, any visible character will trigger it
// TalendEditorComponentProposalProvider proposalProvider = new
// TalendEditorComponentProposalProvider(components);
TalendEditorComponentProposalProvider proposalProvider = new TalendEditorComponentProposalProvider(this, proposalList);
contentProposalAdapter = new ContentProposalAdapter(assistText, new TextContentAdapter(), proposalProvider, null, null);
contentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
contentProposalAdapter.setLabelProvider(new TalendEditorComponentLabelProvider());
}
Aggregations