Search in sources :

Example 6 with ContentProposalAdapter

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));
}
Also used : ComboContentAdapter(org.eclipse.jface.fieldassist.ComboContentAdapter) ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) ContentProposalAdapter(org.eclipse.jface.fieldassist.ContentProposalAdapter) Control(org.eclipse.swt.widgets.Control) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Button(org.eclipse.swt.widgets.Button) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) Link(org.eclipse.swt.widgets.Link)

Example 7 with ContentProposalAdapter

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");
    }
}
Also used : KeyStroke(org.eclipse.jface.bindings.keys.KeyStroke) ParseException(org.eclipse.jface.bindings.keys.ParseException) ContentProposalAdapter(org.eclipse.jface.fieldassist.ContentProposalAdapter)

Example 8 with ContentProposalAdapter

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();
    }
}
Also used : ParseException(org.eclipse.jface.bindings.keys.ParseException) TextContentAdapter(org.eclipse.jface.fieldassist.TextContentAdapter) Image(org.eclipse.swt.graphics.Image) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) ContentProposalAdapter(org.eclipse.jface.fieldassist.ContentProposalAdapter)

Example 9 with ContentProposalAdapter

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) {
    //
    }
}
Also used : ContentProposalAdapterExtended(org.talend.commons.ui.swt.proposal.ContentProposalAdapterExtended) IControlContentAdapter(org.eclipse.jface.fieldassist.IControlContentAdapter) KeyStroke(org.eclipse.jface.bindings.keys.KeyStroke) StyledTextContentAdapter(org.talend.commons.ui.swt.proposal.StyledTextContentAdapter) IPigMapService(org.talend.core.service.IPigMapService) ContentProposalAdapter(org.eclipse.jface.fieldassist.ContentProposalAdapter)

Example 10 with ContentProposalAdapter

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());
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Text(org.eclipse.swt.widgets.Text) TextContentAdapter(org.eclipse.jface.fieldassist.TextContentAdapter) ContentProposalAdapter(org.eclipse.jface.fieldassist.ContentProposalAdapter)

Aggregations

ContentProposalAdapter (org.eclipse.jface.fieldassist.ContentProposalAdapter)15 Combo (org.eclipse.swt.widgets.Combo)8 Composite (org.eclipse.swt.widgets.Composite)8 ComboContentAdapter (org.eclipse.jface.fieldassist.ComboContentAdapter)7 Point (org.eclipse.swt.graphics.Point)7 Control (org.eclipse.swt.widgets.Control)7 Label (org.eclipse.swt.widgets.Label)7 Text (org.eclipse.swt.widgets.Text)7 ComboViewer (org.eclipse.jface.viewers.ComboViewer)6 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)5 KeyStroke (org.eclipse.jface.bindings.keys.KeyStroke)4 ISWTObservableValue (org.eclipse.jface.databinding.swt.ISWTObservableValue)4 ControlDecoration (org.eclipse.jface.fieldassist.ControlDecoration)4 TextContentAdapter (org.eclipse.jface.fieldassist.TextContentAdapter)4 ParseException (org.eclipse.jface.bindings.keys.ParseException)3 Button (org.eclipse.swt.widgets.Button)3 ObservableListContentProvider (org.eclipse.jface.databinding.viewers.ObservableListContentProvider)2 IContentProposal (org.eclipse.jface.fieldassist.IContentProposal)2 IContentProposalListener (org.eclipse.jface.fieldassist.IContentProposalListener)2 IControlContentAdapter (org.eclipse.jface.fieldassist.IControlContentAdapter)2