Example usage for org.eclipse.jface.fieldassist ContentProposalAdapter PROPOSAL_INSERT

List of usage examples for org.eclipse.jface.fieldassist ContentProposalAdapter PROPOSAL_INSERT

Introduction

In this page you can find the example usage for org.eclipse.jface.fieldassist ContentProposalAdapter PROPOSAL_INSERT.

Prototype

int PROPOSAL_INSERT

To view the source code for org.eclipse.jface.fieldassist ContentProposalAdapter PROPOSAL_INSERT.

Click Source Link

Document

Indicates that a chosen proposal should be inserted into the field.

Usage

From source file:com.android.control.MtesterAutoCompleteField.java

License:Apache License

public MtesterAutoCompleteField(final Control control, final IControlContentAdapter controlContentAdapter,
        final String[] literals, final String[] labels, final Shell shell) {
    this.shell = shell;
    contentProposalProvider = new ContentProposalProvider(literals, labels);
    contentProposalProvider.setFiltering(false);
    contentProposalAdapter = new ContentProposalAdapter(control, new StyledTextContentAdapter(),
            contentProposalProvider, null, null);
    contentProposalAdapter.setPropagateKeys(false);
    contentProposalAdapter.setFilterStyle(ContentProposalAdapter.FILTER_CUMULATIVE);
    contentProposalAdapter.setAutoActivationCharacters(new char[] { '.' });
    contentProposalAdapter.setPopupSize(getPoint((StyledText) control));
    contentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_INSERT);
    contentProposalAdapter.setLabelProvider(new LabelProvider() {
        @Override//  w ww . j  av  a 2 s .  com
        public String getText(Object element) {
            IContentProposal proposal = (IContentProposal) element;
            return proposal.getLabel();
        }

        @Override
        public Image getImage(Object element) {
            Image iconCapture = new Image(shell.getDisplay(),
                    ClassLoader.getSystemResourceAsStream("icons/function.png"));
            return iconCapture;
        }
    });
}

From source file:de.sebastianbenz.task.ui.contentassist.TextProposalProvider.java

License:Open Source License

public void configure(final Text text) {
    try {//from   w  w  w . j  ava 2  s. co  m
        KeyStroke ks = KeyStroke.getInstance(KEY_PRESS);
        ContentProposalAdapter adapter = new ContentProposalAdapter(text, new TextContentAdapter(), this, ks,
                null);
        adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_INSERT);
    } catch (ParseException e) {
        throw new RuntimeException(e);
    }
}

From source file:fr.imag.adele.cadse.cadseg.pages.actions.GlobalPathIC.java

License:Apache License

public int getProposalAcceptanceStyle() {
    return ContentProposalAdapter.PROPOSAL_INSERT;
}

From source file:fr.imag.adele.cadse.si.workspace.uiplatform.swt.ui.DBrowserUI.java

License:Apache License

public void proposalAccepted(IContentProposal proposal) {
    IFieldContenProposalProvider proposer = getContentAssistant();

    if (proposer != null) {
        if (((Proposal) proposal).getValue() == null) {
            return;
        }/*from  ww w  .j  a  v  a2  s . c  om*/
        if (proposer.getProposalAcceptanceStyle() == ContentProposalAdapter.PROPOSAL_INSERT) {
            return;
        }

        Object newValue = proposer.getValueFromProposal((Proposal) proposal);
        // setVisualValue(newValue);
        if (newValue != null) {
            _value = newValue;
            _swtuiplatform.broadcastValueChanged(_page, _field, newValue);

        } else {
            _swtuiplatform.broadcastValueDeleted(_page, _field, _value);
            _value = null;
        }

    }

}

From source file:fr.imag.adele.cadse.si.workspace.uiplatform.swt.ui.DTextUI.java

License:Apache License

public void proposalAccepted(IContentProposal proposal) {
    IFieldContenProposalProvider proposer = getContentAssistant();

    if (proposer != null) {
        if (((Proposal) proposal).getValue() == null) {
            return;
        }//ww  w. j  a  v a 2 s  . co m
        if (proposer.getProposalAcceptanceStyle() == ContentProposalAdapter.PROPOSAL_INSERT) {
            return;
        }

        Object newValue = proposer.getValueFromProposal((Proposal) proposal);
        // setVisualValue(newValue);
        if (newValue != null) {
            _currentValue = newValue.toString();
            _swtuiplatform.broadcastValueChanged(_page, _field, newValue);

        } else {
            _swtuiplatform.broadcastValueDeleted(_page, _field, _currentValue);
            _currentValue = null;
        }

    }

}

From source file:org.bonitasoft.studio.expression.editor.viewer.ExpressionViewer.java

License:Open Source License

@Override
public void setSelection(ISelection selection, boolean reveal) {

    if (selection instanceof IStructuredSelection) {
        Object sel = ((IStructuredSelection) selection).getFirstElement();
        if (sel instanceof Expression) {
            selectedExpression = (Expression) sel;
            bindExpression();//www  . j  a  v a  2s . c  o m
            if (editingDomain == null) {
                editingDomain = TransactionUtil.getEditingDomain(selectedExpression);
            }
            final StructuredSelection selection2 = new StructuredSelection(selectedExpression);
            fireSelectionChanged(new SelectionChangedEvent(this, selection2));
            for (IExpressionToolbarContribution contribution : toolbarContributions) {
                contribution.setExpression(selectedExpression);
            }
            if (ExpressionConstants.CONDITION_TYPE.equals(selectedExpression.getType())) {
                autoCompletion.getContentProposalAdapter().setEnabled(false);
                autoCompletion.getContentProposalAdapter()
                        .setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_INSERT);
            } else {
                autoCompletion.getContentProposalAdapter().setEnabled(true);
                autoCompletion.getContentProposalAdapter()
                        .setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
            }
            validate();
            refresh();
        } else {
            selectedExpression = null;
        }
    }
    editing = false;

}

From source file:org.bonitasoft.studio.expression.editor.viewer.ExpressionViewer.java

License:Open Source License

public void manageNatureProviderAndAutocompletionProposal(Object input) {
    if (expressionNatureProvider != null) {
        if (context == null) {
            expressionNatureProvider.setContext((EObject) input);
        } else {/*from  www .  j av a2  s.  c om*/
            expressionNatureProvider.setContext(context);
        }
    }
    if (selectedExpression != null && ExpressionConstants.CONDITION_TYPE.equals(selectedExpression.getType())) {
        setProposalsFiltering(false);
        autoCompletion.getContentProposalAdapter()
                .setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_INSERT);
    } else {
        autoCompletion.getContentProposalAdapter()
                .setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
    }
    autoCompletion.setContext(expressionNatureProvider.getContext());
    final Set<Expression> filteredExpressions = getFilteredExpressions();
    autoCompletion.setProposals(filteredExpressions.toArray(new Expression[filteredExpressions.size()]));

    final ArrayList<String> filteredExpressionType = getFilteredExpressionType();
    autoCompletion.setFilteredExpressionType(filteredExpressionType);
    if ((filteredExpressionType.contains(ExpressionConstants.VARIABLE_TYPE)
            && filteredExpressionType.contains(ExpressionConstants.PARAMETER_TYPE)
            && filteredExpressions.isEmpty())) {
        contentAssistText.setProposalEnabled(false);
    } else {
        contentAssistText.setProposalEnabled(true);
    }
}

From source file:org.eclipse.birt.chart.ui.swt.fieldassist.FieldAssistHelper.java

License:Open Source License

private int getContentAssistAcceptance() {
    IPreferenceStore store = getPreferenceStore();
    String acceptanceStyle = store.getString(PreferenceConstants.PREF_CONTENTASSISTRESULT);
    if (acceptanceStyle.equals(PreferenceConstants.PREF_CONTENTASSISTRESULT_INSERT))
        return ContentProposalAdapter.PROPOSAL_INSERT;
    if (acceptanceStyle.equals(PreferenceConstants.PREF_CONTENTASSISTRESULT_REPLACE))
        return ContentProposalAdapter.PROPOSAL_REPLACE;
    return ContentProposalAdapter.PROPOSAL_IGNORE;
}

From source file:org.eclipse.conesc.plugin.utils.HelperAssistant.java

License:Open Source License

public static void applyAssistentTo(Control control, Node diagram) {

    try {/*from ww  w.  j av  a 2  s .c om*/
        ContentProposalAdapter adapter = new ContentProposalAdapter(control, new TextContentAdapter(),
                new SimpleContentProposalProvider(getAllProposals(diagram)),
                KeyStroke.getInstance("Ctrl+Space"), new char[] { '(', '|', '&', '>' });
        adapter.setFilterStyle(ContentProposalAdapter.FILTER_CHARACTER);
        adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_INSERT);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:org.eclipse.jubula.client.ui.rcp.controllers.propertydescriptors.ParamComboPropertyDescriptor.java

License:Open Source License

/**
 * {@inheritDoc}/*from  w ww .  ja  v  a 2 s .co  m*/
 */
public CellEditor createPropertyEditor(Composite parent) {
    AbstractParamValueController contr = (AbstractParamValueController) getId();
    return new ContentAssistCellEditor(parent,
            new ParamProposalProvider(m_proposals, contr.getParamNode(), contr.getParamDesc()),
            new CheckedParamText.StringTextValidator(contr.getParamNode(), contr.getParamDesc(),
                    getDataValidator()),
            ContentProposalAdapter.PROPOSAL_INSERT);
}