Search in sources :

Example 11 with IContentProposal

use of org.eclipse.jface.fieldassist.IContentProposal in project bndtools by bndtools.

the class CachingContentProposalProvider method getProposals.

@Override
public final IContentProposal[] getProposals(String contents, int position) {
    Collection<? extends IContentProposal> currentProposals;
    if (initialProposals == null || initialContent == null || contents.length() < initialContent.length()) {
        currentProposals = doGenerateProposals(contents, position);
        initialContent = contents;
        initialProposals = currentProposals;
    } else {
        List<IContentProposal> temp = new ArrayList<IContentProposal>(initialProposals.size());
        for (IContentProposal proposal : initialProposals) {
            if (match(contents, position, proposal)) {
                temp.add(proposal);
            }
        }
        currentProposals = temp;
    }
    return currentProposals.toArray(new IContentProposal[0]);
}
Also used : IContentProposal(org.eclipse.jface.fieldassist.IContentProposal) ArrayList(java.util.ArrayList)

Example 12 with IContentProposal

use of org.eclipse.jface.fieldassist.IContentProposal in project tdi-studio-se by Talend.

the class TalendEditorComponentCreationAssist method acceptProposal.

/**
     * create component at current position, according to select proposal label DOC talend2 Comment method
     * "createComponent".
     * 
     * @param componentName
     * @param location
     */
protected void acceptProposal() {
    String componentName = assistText.getText().trim();
    Iterator<IContentProposal> iter = proposalList.iterator();
    IComponent component = null;
    while (iter.hasNext()) {
        IContentProposal proposal = iter.next();
        if (proposal instanceof ComponentContentProposal && componentName.equals(proposal.getLabel())) {
            component = ((ComponentContentProposal) proposal).getComponent();
            break;
        }
    }
    acceptProposal(component);
}
Also used : IContentProposal(org.eclipse.jface.fieldassist.IContentProposal) IComponent(org.talend.core.model.components.IComponent)

Example 13 with IContentProposal

use of org.eclipse.jface.fieldassist.IContentProposal in project yamcs-studio by yamcs.

the class ContentProposalAdapter method proposalAccepted.

/**
 * A content proposal has been accepted. Update the control contents
 * accordingly and notify any listeners.
 *
 * @param proposal the accepted proposal
 */
public void proposalAccepted(final Proposal proposal, final boolean addToHistory) {
    hasSelectedTopProposal = false;
    setControlContent(proposal, true);
    // Add entry to history
    if (addToHistory && !(proposal.isFunction() || proposal.isPartial()))
        history.addEntry(proposal.getValue());
    // Update helper
    helper.clearData();
    helper.updateData(proposal.getTooltips());
    // TODO: remove useless stuff
    // In all cases, notify listeners of an accepted proposal.
    IContentProposal contentProposal = new IContentProposal() {

        @Override
        public String getLabel() {
            return proposal.getValue();
        }

        @Override
        public String getDescription() {
            return null;
        }

        @Override
        public int getCursorPosition() {
            return proposal.getValue().length();
        }

        @Override
        public String getContent() {
            return proposal.getValue();
        }
    };
    notifyProposalAccepted(contentProposal);
}
Also used : IContentProposal(org.eclipse.jface.fieldassist.IContentProposal)

Aggregations

IContentProposal (org.eclipse.jface.fieldassist.IContentProposal)13 ArrayList (java.util.ArrayList)8 IContentProposalProvider (org.eclipse.jface.fieldassist.IContentProposalProvider)3 ContentProposalAdapter (org.eclipse.jface.fieldassist.ContentProposalAdapter)2 IContentProposalListener (org.eclipse.jface.fieldassist.IContentProposalListener)2 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)2 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)2 Function (org.talend.designer.rowgenerator.data.Function)2 JsonTreeNode (org.talend.repository.ui.wizards.metadata.connection.files.json.JsonTreeNode)2 JavaContentProposal (bndtools.utils.JavaContentProposal)1 JavaContentProposalLabelProvider (bndtools.utils.JavaContentProposalLabelProvider)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 IType (org.eclipse.jdt.core.IType)1 JavaModelException (org.eclipse.jdt.core.JavaModelException)1 KeyStroke (org.eclipse.jface.bindings.keys.KeyStroke)1