Search in sources :

Example 1 with IContentProposalProvider

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

the class ExpressionCellEditor method createExpressionProposalProvider.

private ExpressionProposalProvider createExpressionProposalProvider() {
    IContentProposalProvider[] contentProposalProviders = new IContentProposalProvider[0];
    contentProposalProviders = new IContentProposalProvider[] { new TalendProposalProvider(mapperManager.getMapperComponent().getProcess()) };
    ExpressionProposalProvider provider = new ExpressionProposalProvider(mapperManager, contentProposalProviders);
    provider.init(source);
    return provider;
}
Also used : IContentProposalProvider(org.eclipse.jface.fieldassist.IContentProposalProvider) TalendProposalProvider(org.talend.core.ui.proposal.TalendProposalProvider) ExpressionProposalProvider(org.talend.designer.xmlmap.parts.directedit.proposal.ExpressionProposalProvider)

Example 2 with IContentProposalProvider

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

the class ExpressionProposalProvider method getProposals.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.fieldassist.IContentProposalProvider#getProposals(java.lang.String, int)
     */
public IContentProposal[] getProposals(String contents, int position) {
    List<IContentProposal> proposals = new ArrayList<IContentProposal>();
    TableEntryLocation sourceEntryLocation = new TableEntryLocation();
    for (IDataMapTable table : this.tables) {
        List<IColumnEntry> dataMapTableEntries = table.getColumnEntries();
        for (IColumnEntry entrySource : dataMapTableEntries) {
            sourceEntryLocation.tableName = entrySource.getParentName();
            sourceEntryLocation.columnName = entrySource.getName();
            if (mapperManager.getUiManager().checkSourceLocationIsValid(entrySource, currentModifiedEntry)) {
                proposals.add(new EntryContentProposal(entrySource, this.currentLanguage));
            }
        }
        // for the globalMap
        if (table instanceof InputTable) {
            InputTable inputTable = (InputTable) table;
            List<GlobalMapEntry> globalMapEntries = inputTable.getGlobalMapEntries();
            for (GlobalMapEntry entry : globalMapEntries) {
                proposals.add(new EntryContentProposal(entry, this.currentLanguage));
            }
        }
    }
    for (IContentProposalProvider contentProposalProvider : otherContentProposalProviders) {
        proposals.addAll(Arrays.asList(contentProposalProvider.getProposals(contents, position)));
    }
    IContentProposal[] res = new IContentProposal[proposals.size()];
    res = proposals.toArray(res);
    return res;
}
Also used : IContentProposalProvider(org.eclipse.jface.fieldassist.IContentProposalProvider) ArrayList(java.util.ArrayList) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) IContentProposal(org.eclipse.jface.fieldassist.IContentProposal) InputTable(org.talend.designer.mapper.model.table.InputTable) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Example 3 with IContentProposalProvider

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

the class SqlEditDialog 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();
        IContentProposalProvider contentProposalProvider = new SQLEditorProposalProvider(repositoryNode, language);
        SQLEditorProposalAdapter contentProposalAdapter = new SQLEditorProposalAdapter(colorText, controlContentAdapter, contentProposalProvider, keyStroke, new char[] { ' ', '.' });
        contentProposalAdapter.setPropagateKeys(true);
        contentProposalAdapter.setFilterStyle(ContentProposalAdapter.FILTER_CUMULATIVE);
        contentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
        contentProposalAdapter.setLabelProvider(new SQLEditorLabelProvider());
        contentProposalAdapter.setAutoActivationDelay(10);
        contentProposalAdapter.setPopupSize(new Point(300, 200));
    } catch (Exception e) {
        //$NON-NLS-1$
        SqlBuilderPlugin.log(Messages.getString("SQLBuilderEditorComposite.logMessage"), e);
    }
}
Also used : IContentProposalProvider(org.eclipse.jface.fieldassist.IContentProposalProvider) SQLEditorLabelProvider(org.talend.sqlbuilder.ui.proposal.SQLEditorLabelProvider) SQLEditorProposalAdapter(org.talend.sqlbuilder.ui.proposal.SQLEditorProposalAdapter) IControlContentAdapter(org.eclipse.jface.fieldassist.IControlContentAdapter) KeyStroke(org.eclipse.jface.bindings.keys.KeyStroke) StyledTextContentAdapter(org.talend.commons.ui.swt.proposal.StyledTextContentAdapter) Point(org.eclipse.swt.graphics.Point) SQLEditorProposalProvider(org.talend.sqlbuilder.ui.proposal.SQLEditorProposalProvider)

Example 4 with IContentProposalProvider

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

the class ExpressionProposalProvider method getProposals.

@Override
public IContentProposal[] getProposals(String contents, int position) {
    List<IContentProposal> proposals = new ArrayList<IContentProposal>();
    proposals.addAll(proposalsInside);
    for (IContentProposalProvider contentProposalProvider : otherContentProposalProviders) {
        proposals.addAll(Arrays.asList(contentProposalProvider.getProposals(contents, position)));
    }
    IContentProposal[] res = new IContentProposal[proposals.size()];
    res = proposals.toArray(res);
    return res;
}
Also used : IContentProposalProvider(org.eclipse.jface.fieldassist.IContentProposalProvider) IContentProposal(org.eclipse.jface.fieldassist.IContentProposal) ArrayList(java.util.ArrayList)

Example 5 with IContentProposalProvider

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

the class DataMapTableView method initExpressionProposals.

/**
     * 
     * Init proposals of Text control, and StyledText in tab "Expression editor".
     * 
     * @param textControl
     * @param zones
     * @param tableViewerCreator
     * @param currentModifiedEntry
     */
protected void initExpressionProposals(final TextCellEditorWithProposal textCellEditor, Zone[] zones, final TableViewerCreator tableViewerCreator, ITableEntry currentModifiedEntry) {
    if (this.expressionProposalProvider == null) {
        IContentProposalProvider[] contentProposalProviders = new IContentProposalProvider[0];
        if (!MapperMain.isStandAloneMode()) {
            contentProposalProviders = new IContentProposalProvider[] { // new ProcessProposalProvider(mapperManager.getComponent().getProcess())
            new KeyWordProposalProvider("tsql", //$NON-NLS-1$ //$NON-NLS-2$
            "KEYWORD1") };
        }
        this.expressionProposalProvider = new ExpressionProposalProvider(mapperManager, contentProposalProviders);
    }
    this.expressionProposalProvider.init(abstractDataMapTable, zones, currentModifiedEntry);
    textCellEditor.setContentProposalProvider(this.expressionProposalProvider);
    StyledTextHandler styledTextHandler = mapperManager.getUiManager().getTabFolderEditors().getStyledTextHandler();
    styledTextHandler.getStyledText().setEnabled(true);
    ContentProposalAdapterExtended expressionProposalStyledText = styledTextHandler.getContentProposalAdapter();
    expressionProposalStyledText.setContentProposalProvider(this.expressionProposalProvider);
// System.out.println("init expression proposal:"+this.expressionProposal);
}
Also used : IContentProposalProvider(org.eclipse.jface.fieldassist.IContentProposalProvider) ContentProposalAdapterExtended(org.talend.commons.ui.swt.proposal.ContentProposalAdapterExtended) StyledTextHandler(org.talend.designer.dbmap.ui.tabs.StyledTextHandler) KeyWordProposalProvider(org.talend.designer.dbmap.ui.proposal.expression.KeyWordProposalProvider) ExpressionProposalProvider(org.talend.designer.dbmap.ui.proposal.expression.ExpressionProposalProvider)

Aggregations

IContentProposalProvider (org.eclipse.jface.fieldassist.IContentProposalProvider)11 ArrayList (java.util.ArrayList)5 IContentProposal (org.eclipse.jface.fieldassist.IContentProposal)5 KeyStroke (org.eclipse.jface.bindings.keys.KeyStroke)4 Pattern (java.util.regex.Pattern)2 IControlContentAdapter (org.eclipse.jface.fieldassist.IControlContentAdapter)2 TextContentAdapter (org.eclipse.jface.fieldassist.TextContentAdapter)2 Point (org.eclipse.swt.graphics.Point)2 StyledTextContentAdapter (org.talend.commons.ui.swt.proposal.StyledTextContentAdapter)2 TalendProposalProvider (org.talend.core.ui.proposal.TalendProposalProvider)2 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)2 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)2 ExpressionProposalProvider (org.talend.designer.xmlmap.parts.directedit.proposal.ExpressionProposalProvider)2 SQLEditorLabelProvider (org.talend.sqlbuilder.ui.proposal.SQLEditorLabelProvider)2 SQLEditorProposalAdapter (org.talend.sqlbuilder.ui.proposal.SQLEditorProposalAdapter)2 SQLEditorProposalProvider (org.talend.sqlbuilder.ui.proposal.SQLEditorProposalProvider)2 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)1 ContentProposalAdapter (org.eclipse.jface.fieldassist.ContentProposalAdapter)1 SWT (org.eclipse.swt.SWT)1 ContentProposalAdapterExtended (org.talend.commons.ui.swt.proposal.ContentProposalAdapterExtended)1