Search in sources :

Example 1 with ContentProposalAdapterExtended

use of org.talend.commons.ui.swt.proposal.ContentProposalAdapterExtended 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)

Example 2 with ContentProposalAdapterExtended

use of org.talend.commons.ui.swt.proposal.ContentProposalAdapterExtended in project tdi-studio-se by Talend.

the class AbstractHL7MetadataTableEditorView method configurePatternColumn.

/**
     * DOC amaumont Comment method "configurePatternColumn".
     * 
     * @param tableViewerCreator
     */
protected void configurePatternColumn(TableViewerCreator<B> tableViewerCreator) {
    if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA && showPatternColumn) {
        final TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
        //$NON-NLS-1$
        String patternTitle = Messages.getString("MetadataTableEditorView.PatternTitle");
        column.setTitle(patternTitle);
        column.setToolTipHeader(patternTitle);
        column.setId(ID_COLUMN_PATTERN);
        column.setBeanPropertyAccessors(getPatternAccessor());
        column.setModifiable(!isReadOnly());
        column.setWeight(16);
        final ColumnCellModifier columnCellModifier = new ColumnCellModifier(column) {

            public boolean canModify(Object bean) {
                boolean typeIsDate = currentBeanHasJavaDateType(bean) && !isReadOnly();
                return typeIsDate;
            }
        };
        column.setColorProvider(new IColumnColorProvider() {

            public Color getBackgroundColor(Object bean) {
                if (!columnCellModifier.canModify(bean)) {
                    return READONLY_CELL_BG_COLOR;
                }
                return null;
            }

            public Color getForegroundColor(Object bean) {
                return null;
            }
        });
        column.setLabelProvider(new IColumnLabelProvider() {

            /*
                 * (non-Javadoc)
                 * 
                 * @see org.talend.commons.ui.swt.tableviewer.behavior.IColumnLabelProvider#getLabel(java.lang.Object)
                 */
            public String getLabel(Object bean) {
                if (!currentBeanHasJavaDateType(bean)) {
                    //$NON-NLS-1$
                    return "";
                }
                return null;
            }
        });
        column.setColumnCellModifier(columnCellModifier);
        JavaSimpleDateFormatProposalProvider proposalProvider = new JavaSimpleDateFormatProposalProvider();
        TextCellEditorWithProposal patternCellEditor = new TextCellEditorWithProposal(tableViewerCreator.getTable(), column);
        ContentProposalAdapterExtended contentProposalAdapter = patternCellEditor.getContentProposalAdapter();
        contentProposalAdapter.setFilterStyle(ContentProposalAdapterExtended.FILTER_NONE);
        contentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapterExtended.PROPOSAL_INSERT);
        patternCellEditor.setContentProposalProvider(proposalProvider);
        column.setCellEditor(patternCellEditor, CellEditorValueAdapterFactory.getNullToEmptyStringTextAdapater());
    }
}
Also used : IColumnLabelProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnLabelProvider) ContentProposalAdapterExtended(org.talend.commons.ui.swt.proposal.ContentProposalAdapterExtended) TextCellEditorWithProposal(org.talend.commons.ui.swt.proposal.TextCellEditorWithProposal) Color(org.eclipse.swt.graphics.Color) JavaSimpleDateFormatProposalProvider(org.talend.core.ui.proposal.JavaSimpleDateFormatProposalProvider) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) IColumnColorProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnColorProvider) ColumnCellModifier(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ColumnCellModifier)

Example 3 with ContentProposalAdapterExtended

use of org.talend.commons.ui.swt.proposal.ContentProposalAdapterExtended in project tdi-studio-se by Talend.

the class PigExpressionComposite 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 4 with ContentProposalAdapterExtended

use of org.talend.commons.ui.swt.proposal.ContentProposalAdapterExtended in project tdi-studio-se by Talend.

the class XmlTreeSchemaTableView method createColumns.

@Override
protected void createColumns(final TableViewerCreator<TreeNode> tableViewerCreator, Table table) {
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
    column.setTitle("XPath");
    column.setId(ID_COLUMN_XPATH);
    column.setWeight(20);
    column.setModifiable(true);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<TreeNode, Object>() {

        @Override
        public Object get(TreeNode bean) {
            return bean.getXpath();
        }

        @Override
        public void set(TreeNode bean, Object value) {
            if (isValidName) {
                bean.setName((String) value);
                // String xPath = bean.getXPath();
                // xPath = xPath.substring(0, xPath.lastIndexOf(XmlMapUtil.XPATH_SEPARATOR) + 1);
                // NodeType nodeType = bean.getTreeNode().getNodeType();
                // String typedValue = null;
                // if (NodeType.ATTRIBUT.equals(nodeType)) {
                // typedValue = xPath + XmlMapUtil.XPATH_ATTRIBUTE + bean.getName();
                // } else if (NodeType.NAME_SPACE.equals(nodeType)) {
                // typedValue = xPath + XmlMapUtil.XPATH_NAMESPACE + bean.getName();
                // } else {
                // typedValue = xPath + bean.getName();
                // }
                // bean.setXPath(typedValue);
                XmlMapData mapperData = XmlMapUtil.getXmlMapData(bean);
                XmlMapExpressionManager expressionManager = new XmlMapExpressionManager();
                XmlMapUtil.updateXPathAndExpression(mapperData, expressionManager, bean, bean.getName(), XmlMapUtil.getXPathLength(bean.getXpath()), true);
                if (!bean.getChildren().isEmpty()) {
                    refresh();
                }
            }
        }
    });
    final TextCellEditor cellEditor = new TextCellEditor(tableViewerCreator.getTable());
    cellEditor.addListener(new DialogErrorForCellEditorListener(cellEditor, column) {

        @Override
        public void newValidValueTyped(int itemIndex, Object previousValue, Object newValue, CELL_EDITOR_STATE state) {
        }

        @Override
        public String validateValue(String newValue, int beanPosition) {
            return validateXPath(newValue, beanPosition);
        }
    });
    column.setCellEditor(cellEditor);
    column.setColumnCellModifier(new ColumnCellModifier(column) {

        @Override
        public Object getValue(Object bean) {
            TreeNode entry = (TreeNode) bean;
            return entry.getName();
        }

        @Override
        public boolean modify(Object bean, Object value) {
            return false;
        }
    });
    column = new TableViewerCreatorColumn(tableViewerCreator);
    column.setTitle("Key");
    column.setToolTipHeader("Key");
    column.setId(ID_COLUMN_KEY);
    //$NON-NLS-1$
    column.setDisplayedValue("");
    column.setWeight(10);
    column.setModifiable(true);
    CheckboxTableEditorContent checkbox = new CheckboxTableEditorContent();
    column.setTableEditorContent(checkbox);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<TreeNode, Boolean>() {

        @Override
        public Boolean get(TreeNode bean) {
            return bean.isKey();
        }

        @Override
        public void set(TreeNode bean, Boolean value) {
            bean.setKey(value);
        }
    });
    column = new TableViewerCreatorColumn(tableViewerCreator);
    column.setTitle("Type");
    column.setToolTipHeader("Type");
    column.setId(ID_COLUMN_TYPE);
    column.setBeanPropertyAccessors(getTalendTypeAccessor());
    column.setModifiable(true);
    column.setWeight(20);
    TreeSchemaJavaTypeComboValueAdapter comboValueAdapter = new TreeSchemaJavaTypeComboValueAdapter<TreeNode>(JavaTypesManager.getDefaultJavaType(), getNullableAccessor());
    ComboBoxCellEditor typeComboEditor = new ComboBoxCellEditor(tableViewerCreator.getTable(), comboValueAdapter.getTalendTypesLabels(), SWT.READ_ONLY);
    CCombo typeCombo = (CCombo) typeComboEditor.getControl();
    typeCombo.setEditable(false);
    column.setCellEditor(typeComboEditor, comboValueAdapter);
    column = new TableViewerCreatorColumn(tableViewerCreator);
    column.setTitle("Nullable");
    column.setToolTipHeader("Nullable");
    column.setId(ID_COLUMN_NULLABLE);
    column.setBeanPropertyAccessors(getNullableAccessor());
    column.setWeight(20);
    //$NON-NLS-1$
    column.setDisplayedValue("");
    column.setModifiable(true);
    column.setTableColumnSelectionListener(new CheckColumnSelectionListener(column, tableViewerCreator));
    column.setImageHeader(ImageProvider.getImage(EImage.CHECKED_ICON));
    CheckboxTableEditorContent nullableCheckbox = new CheckboxTableEditorContent();
    column.setTableEditorContent(nullableCheckbox);
    column = new TableViewerCreatorColumn(tableViewerCreator);
    column.setTitle("Pattern");
    column.setId(ID_COLUMN_PATTERN);
    column.setWeight(20);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<TreeNode, String>() {

        @Override
        public String get(TreeNode bean) {
            return bean.getPattern();
        }

        @Override
        public void set(TreeNode bean, String value) {
            bean.setPattern(value);
        }
    });
    final ColumnCellModifier columnCellModifier = new ColumnCellModifier(column) {

        @Override
        public boolean canModify(Object bean) {
            boolean typeIsDate = currentBeanHasJavaDateType(bean) && !isReadOnly();
            return typeIsDate;
        }
    };
    column.setColorProvider(new IColumnColorProvider() {

        @Override
        public Color getBackgroundColor(Object bean) {
            if (!columnCellModifier.canModify(bean)) {
                return READONLY_CELL_BG_COLOR;
            }
            return null;
        }

        @Override
        public Color getForegroundColor(Object bean) {
            return null;
        }
    });
    column.setLabelProvider(new IColumnLabelProvider() {

        /*
             * (non-Javadoc)
             * 
             * @see org.talend.commons.ui.swt.tableviewer.behavior.IColumnLabelProvider#getLabel(java.lang.Object)
             */
        @Override
        public String getLabel(Object bean) {
            if (!currentBeanHasJavaDateType(bean)) {
                //$NON-NLS-1$
                return "";
            }
            return null;
        }
    });
    column.setColumnCellModifier(columnCellModifier);
    JavaSimpleDateFormatProposalProvider proposalProvider = new JavaSimpleDateFormatProposalProvider();
    TextCellEditorWithProposal patternCellEditor = new TextCellEditorWithProposal(tableViewerCreator.getTable(), column);
    ContentProposalAdapterExtended contentProposalAdapter = patternCellEditor.getContentProposalAdapter();
    contentProposalAdapter.setFilterStyle(ContentProposalAdapterExtended.FILTER_NONE);
    contentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapterExtended.PROPOSAL_INSERT);
    patternCellEditor.setContentProposalProvider(proposalProvider);
    column.setCellEditor(patternCellEditor, CellEditorValueAdapterFactory.getNullToEmptyStringTextAdapater());
    tableViewerCreator.setCellModifier(new XmlCellModifier(tableViewerCreator));
}
Also used : DialogErrorForCellEditorListener(org.talend.commons.ui.swt.tableviewer.celleditor.DialogErrorForCellEditorListener) CheckColumnSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.CheckColumnSelectionListener) JavaSimpleDateFormatProposalProvider(org.talend.core.ui.proposal.JavaSimpleDateFormatProposalProvider) ColumnCellModifier(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ColumnCellModifier) ContentProposalAdapterExtended(org.talend.commons.ui.swt.proposal.ContentProposalAdapterExtended) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) XmlMapExpressionManager(org.talend.designer.xmlmap.ui.expressionutil.XmlMapExpressionManager) IColumnColorProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnColorProvider) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData) IColumnLabelProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnLabelProvider) CELL_EDITOR_STATE(org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE) TextCellEditorWithProposal(org.talend.commons.ui.swt.proposal.TextCellEditorWithProposal) Color(org.eclipse.swt.graphics.Color) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) CCombo(org.eclipse.swt.custom.CCombo) CheckboxTableEditorContent(org.talend.commons.ui.swt.tableviewer.tableeditor.CheckboxTableEditorContent) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)

Example 5 with ContentProposalAdapterExtended

use of org.talend.commons.ui.swt.proposal.ContentProposalAdapterExtended 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)

Aggregations

ContentProposalAdapterExtended (org.talend.commons.ui.swt.proposal.ContentProposalAdapterExtended)5 KeyStroke (org.eclipse.jface.bindings.keys.KeyStroke)2 ContentProposalAdapter (org.eclipse.jface.fieldassist.ContentProposalAdapter)2 IControlContentAdapter (org.eclipse.jface.fieldassist.IControlContentAdapter)2 Color (org.eclipse.swt.graphics.Color)2 ColumnCellModifier (org.talend.commons.ui.runtime.swt.tableviewer.behavior.ColumnCellModifier)2 IColumnColorProvider (org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnColorProvider)2 IColumnLabelProvider (org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnLabelProvider)2 StyledTextContentAdapter (org.talend.commons.ui.swt.proposal.StyledTextContentAdapter)2 TextCellEditorWithProposal (org.talend.commons.ui.swt.proposal.TextCellEditorWithProposal)2 TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)2 IPigMapService (org.talend.core.service.IPigMapService)2 JavaSimpleDateFormatProposalProvider (org.talend.core.ui.proposal.JavaSimpleDateFormatProposalProvider)2 IContentProposalProvider (org.eclipse.jface.fieldassist.IContentProposalProvider)1 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)1 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)1 CCombo (org.eclipse.swt.custom.CCombo)1 CheckColumnSelectionListener (org.talend.commons.ui.runtime.swt.tableviewer.behavior.CheckColumnSelectionListener)1 CELL_EDITOR_STATE (org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE)1 DialogErrorForCellEditorListener (org.talend.commons.ui.swt.tableviewer.celleditor.DialogErrorForCellEditorListener)1