Search in sources :

Example 16 with ECodeLanguage

use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.

the class TabFolderEditors method createStyledText.

private StyledText createStyledText(CTabItem item) {
    StyledText styledText = null;
    RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
    ECodeLanguage language = repositoryContext.getProject().getLanguage();
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    styledText = new UnnotifiableColorStyledText(tabFolderEditors, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, preferenceStore, language.getName());
    styledText.setEnabled(false);
    item.setControl(styledText);
    return styledText;
}
Also used : RepositoryContext(org.talend.core.context.RepositoryContext) StyledText(org.eclipse.swt.custom.StyledText) UnnotifiableColorStyledText(org.talend.commons.ui.swt.colorstyledtext.UnnotifiableColorStyledText) UnnotifiableColorStyledText(org.talend.commons.ui.swt.colorstyledtext.UnnotifiableColorStyledText) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 17 with ECodeLanguage

use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.

the class OpenExistVersionProcessWizard method openAnotherVersion.

protected void openAnotherVersion(final RepositoryNode node, final boolean readonly) {
    try {
        if (node.getObject() != null) {
            final Item item = node.getObject().getProperty().getItem();
            final IWorkbenchPage page = getActivePage();
            final RepositoryEditorInput fileEditorInput = getEditorInput(item, readonly, page);
            if (fileEditorInput != null) {
                IEditorPart editorPart = page.findEditor(fileEditorInput);
                if (editorPart == null) {
                    fileEditorInput.setRepositoryNode(node);
                    if (item instanceof ProcessItem) {
                        page.openEditor(fileEditorInput, MultiPageTalendEditor.ID, readonly);
                    } else if (item instanceof BusinessProcessItem) {
                        CorePlugin.getDefault().getDiagramModelService().openBusinessDiagramEditor(page, fileEditorInput);
                    } else {
                        ECodeLanguage lang = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
                        //$NON-NLS-1$ //$NON-NLS-2$
                        String talendEditorID = "org.talend.designer.core.ui.editor.StandAloneTalend" + lang.getCaseName() + "Editor";
                        page.openEditor(fileEditorInput, talendEditorID);
                    }
                } else {
                    page.activate(editorPart);
                }
            } else {
                // TDI-19014:open another version of jobScript
                if (item instanceof JobScriptItem) {
                    IProject fsProject = ResourceUtils.getProject(ProjectManager.getInstance().getCurrentProject());
                    openXtextEditor(node, fsProject, readonly);
                }
            }
        }
    } catch (PartInitException e) {
        MessageBoxExceptionHandler.process(e);
    } catch (SystemException e) {
        MessageBoxExceptionHandler.process(e);
    }
}
Also used : RepositoryContext(org.talend.core.context.RepositoryContext) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) JobScriptItem(org.talend.core.model.properties.JobScriptItem) IEditorPart(org.eclipse.ui.IEditorPart) IProject(org.eclipse.core.resources.IProject) Item(org.talend.core.model.properties.Item) JobScriptItem(org.talend.core.model.properties.JobScriptItem) RoutineItem(org.talend.core.model.properties.RoutineItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) SystemException(org.talend.commons.exception.SystemException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 18 with ECodeLanguage

use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.

the class ContextParameterPage method addListeners.

private void addListeners() {
    nameText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (nameText.getText().length() == 0) {
                nameStatus = new Status(IStatus.ERROR, DesignerPlugin.ID, IStatus.OK, Messages.getString("ContextParameterPage.nameEmpty"), //$NON-NLS-1$
                null);
            } else if (existingParameterNames.contains(nameText.getText())) {
                nameStatus = new Status(IStatus.ERROR, DesignerPlugin.ID, IStatus.OK, Messages.getString("ContextParameterPage.nameExists"), //$NON-NLS-1$
                null);
            } else if (!contextManager.checkValidParameterName(null, nameText.getText())) {
                //$NON-NLS-1$
                nameStatus = new Status(IStatus.ERROR, DesignerPlugin.ID, IStatus.OK, "Parameter name is not valid.", null);
            } else {
                nameStatus = createOkStatus();
            }
            parameter.setName(StringUtils.trimToEmpty(nameText.getText()));
            updatePageStatus();
        }
    });
    commentText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (commentText.getText().length() == 0) {
                commentStatus = new Status(IStatus.WARNING, DesignerPlugin.ID, IStatus.OK, Messages.getString(//$NON-NLS-1$
                "ContextParameterPage.commentEmpty"), null);
            } else {
                commentStatus = createOkStatus();
            }
            parameter.setComment(StringUtils.trimToEmpty(commentText.getText()));
            updatePageStatus();
        }
    });
    final ECodeLanguage curLanguage = LanguageManager.getCurrentLanguage();
    typeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            String type;
            if (event.getSelection().isEmpty()) {
                typeStatus = new Status(IStatus.ERROR, DesignerPlugin.ID, IStatus.OK, Messages.getString("ContextParameterPage.typeEmpty"), //$NON-NLS-1$
                null);
                type = null;
            } else {
                typeStatus = createOkStatus();
                type = (String) ((IStructuredSelection) event.getSelection()).getFirstElement();
            }
            if (curLanguage == ECodeLanguage.JAVA) {
                type = getJavaDisplayedType(type);
            }
            final String value = parameter.getValue();
            // value will be empty
            parameter.setType(type);
            // revert the value
            parameter.setValue(value);
            updatePageStatus();
        }
    });
    PromptListener promptListener = new PromptListener();
    promptText.addModifyListener(promptListener);
    promptBtn.addSelectionListener(promptListener);
    defaultText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (defaultText.getText().length() == 0) {
                defaultStatus = new Status(IStatus.WARNING, DesignerPlugin.ID, IStatus.OK, Messages.getString("ContextParameterPage.defaultValueEmpty"), //$NON-NLS-1$
                null);
            } else {
                defaultStatus = createOkStatus();
            }
            parameter.setValue(StringUtils.trimToEmpty(defaultText.getText()));
            updatePageStatus();
        }
    });
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 19 with ECodeLanguage

use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.

the class SqlMemoController method createCommand.

// built-in open query
private Command createCommand() {
    initConnectionParameters();
    IElementParameter basePropertyParameter = null;
    for (IElementParameter param : elem.getElementParameters()) {
        if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
            if (param.getRepositoryValue().startsWith("DATABASE")) {
                basePropertyParameter = param;
                break;
            }
        }
    }
    String repositoryType = null;
    if (basePropertyParameter != null) {
        repositoryType = (String) basePropertyParameter.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).getValue();
    } else {
        repositoryType = (String) elem.getPropertyValue(EParameterName.PROPERTY_TYPE.getName());
    }
    String propertyName = (String) openSQLEditorButton.getData(PARAMETER_NAME);
    String query = (String) elem.getPropertyValue(propertyName);
    ECodeLanguage lang = LanguageManager.getCurrentLanguage();
    if ((!TalendTextUtils.isCommonString(query) || QueryUtil.checkIfHasSpecialEscapeValue(query) || QueryUtil.checkIfIsNoQuotesAtAll(query)) && (lang == ECodeLanguage.JAVA)) {
        // if
        // the input query is in context mode in java
        // String pid = SqlBuilderPlugin.PLUGIN_ID;
        // String mainMsg = Messages.getString("SqlMemoController.QueryError.mainMsg");
        // String infoMsg = Messages.getString("SqlMemoController.QueryError.infoMsg",
        // TalendTextUtils.getQuoteChar());
        // new ErrorDialogWidthDetailArea(composite.getShell(), pid, mainMsg, infoMsg);
        // return null;
        // pass the value to Initializing the contextmode button
        connParameters.setIfContextButtonCheckedFromBuiltIn(true);
    // String contextSql = openSQLBuilder(repositoryType, propertyName, query);
    // if (contextSql != null) {
    // queryText.setText(contextSql);
    // return new PropertyChangeCommand(elem, propertyName, contextSql);
    // }
    // return null;
    } else {
        // if the input query isn't contextmode or it's a standard query in perl
        query = this.removeStrInQuery(query);
    }
    initConnectionParametersWithContext(elem, part == null ? new EmptyContextManager().getDefaultContext() : part.getProcess().getContextManager().getDefaultContext());
    String sql = openSQLBuilder(repositoryType, propertyName, query);
    if (sql != null) {
        queryText.setText(sql);
        return new PropertyChangeCommand(elem, propertyName, sql);
    }
    return null;
}
Also used : PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) IElementParameter(org.talend.core.model.process.IElementParameter) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 20 with ECodeLanguage

use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.

the class VarsDataMapTableView method initColumnsOfTableColumns.

@Override
public void initColumnsOfTableColumns(final TableViewerCreator tableViewerCreatorForColumns) {
    ECodeLanguage codeLanguage = LanguageProvider.getCurrentLanguage().getCodeLanguage();
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("VarsDataMapTableView.columnTitle.expression"));
    column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
    expressionCellEditor = createExpressionCellEditor(tableViewerCreatorForColumns, column, new Zone[] { Zone.INPUTS, Zone.VARS }, false);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<VarTableEntry, String>() {

        public String get(VarTableEntry bean) {
            return bean.getExpression();
        }

        public void set(VarTableEntry bean, String value) {
            bean.setExpression(value);
            mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
        }
    });
    column.setModifiable(!mapperManager.componentIsReadOnly());
    //$NON-NLS-1$
    column.setDefaultInternalValue("");
    if (codeLanguage == ECodeLanguage.JAVA) {
        column.setWeight(40);
    } else {
        column.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
    }
    if (codeLanguage == ECodeLanguage.JAVA) {
        String[] arrayTalendTypes = new String[0];
        try {
            arrayTalendTypes = MetadataTalendType.getTalendTypesLabels();
            arrayTalendTypes = this.talendTypeFilter.filter(arrayTalendTypes);
        } catch (NoClassDefFoundError e) {
            // shouln't be happend
            // e.printStackTrace();
            ExceptionHandler.process(e);
        } catch (ExceptionInInitializerError e) {
            // shouln't be happend
            // e.printStackTrace();
            ExceptionHandler.process(e);
        }
        IBeanPropertyAccessors<VarTableEntry, Boolean> nullableAccessors = new IBeanPropertyAccessors<VarTableEntry, Boolean>() {

            public Boolean get(VarTableEntry bean) {
                return bean.isNullable() ? Boolean.TRUE : Boolean.FALSE;
            }

            public void set(VarTableEntry bean, Boolean value) {
                bean.setNullable(value.booleanValue());
            }
        };
        CellEditorValueAdapter comboValueAdapter = new JavaTypeComboValueAdapter(JavaTypesManager.getDefaultJavaType(), nullableAccessors, this.talendTypeFilter);
        column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
        //$NON-NLS-1$
        column.setTitle(Messages.getString("VarsDataMapTableView.columnTitle.type"));
        column.setBeanPropertyAccessors(new IBeanPropertyAccessors<VarTableEntry, String>() {

            public String get(VarTableEntry bean) {
                return bean.getType();
            }

            public void set(VarTableEntry bean, String value) {
                bean.setType(value);
                mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
            }
        });
        column.setModifiable(!mapperManager.componentIsReadOnly());
        column.setWeight(18);
        column.setCellEditor(new ComboBoxCellEditor(tableViewerCreatorForColumns.getTable(), arrayTalendTypes), comboValueAdapter);
        column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
        //$NON-NLS-1$
        column.setTitle("Nullable");
        column.setBeanPropertyAccessors(new IBeanPropertyAccessors<VarTableEntry, Boolean>() {

            public Boolean get(VarTableEntry bean) {
                return bean.isNullable();
            }

            public void set(VarTableEntry bean, Boolean value) {
                bean.setNullable(value);
                mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
            }
        });
        column.setModifiable(!mapperManager.componentIsReadOnly());
        column.setWidth(WindowSystem.isWIN32() ? 12 : 20);
        //$NON-NLS-1$
        column.setDisplayedValue("");
        column.setResizable(false);
        CheckboxTableEditorContent checkboxTableEditorContent = new CheckboxTableEditorContent();
        //$NON-NLS-1$
        String nullable = Messages.getString("VarsDataMapTableView.nullable");
        checkboxTableEditorContent.setToolTipText(nullable);
        column.setTableEditorContent(checkboxTableEditorContent);
        column.setToolTipHeader(nullable);
    }
    column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("VarsDataMapTableView.columnTitle.variable"));
    column.setId(DataMapTableView.ID_NAME_COLUMN);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<VarTableEntry, String>() {

        public String get(VarTableEntry bean) {
            return bean.getName();
        }

        public void set(VarTableEntry bean, String value) {
            bean.setName(value);
        }
    });
    column.setModifiable(!mapperManager.componentIsReadOnly());
    if (codeLanguage == ECodeLanguage.JAVA) {
        column.setWeight(25);
    } else {
        column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
    }
    final TextCellEditor cellEditor = new TextCellEditor(tableViewerCreatorForColumns.getTable());
    cellEditor.addListener(new DialogErrorForCellEditorListener(cellEditor, column) {

        @Override
        public void newValidValueTyped(int itemIndex, Object previousValue, Object newValue, CELL_EDITOR_STATE state) {
            if (state == CELL_EDITOR_STATE.APPLYING) {
                ModifiedObjectInfo modifiedObjectInfo = tableViewerCreatorForColumns.getModifiedObjectInfo();
                String originalValue = (String) modifiedObjectInfo.getOriginalPropertyBeanValue();
                Object currentModifiedBean = modifiedObjectInfo.getCurrentModifiedBean();
                mapperManager.getUiManager().processColumnNameChanged(originalValue.toString(), newValue.toString(), VarsDataMapTableView.this, (ITableEntry) currentModifiedBean);
            }
        }

        @Override
        public String validateValue(String newValue, int beanPosition) {
            return ((VarsTable) getDataMapTable()).validateColumnName(newValue, beanPosition);
        }
    });
    column.setCellEditor(cellEditor);
}
Also used : CELL_EDITOR_STATE(org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE) Zone(org.talend.designer.mapper.ui.visualmap.zone.Zone) DialogErrorForCellEditorListener(org.talend.commons.ui.swt.tableviewer.celleditor.DialogErrorForCellEditorListener) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) CellEditorValueAdapter(org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) CheckboxTableEditorContent(org.talend.commons.ui.swt.tableviewer.tableeditor.CheckboxTableEditorContent) JavaTypeComboValueAdapter(org.talend.core.ui.metadata.celleditor.JavaTypeComboValueAdapter) IBeanPropertyAccessors(org.talend.commons.utils.data.bean.IBeanPropertyAccessors) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ExtendedTextCellEditor(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor) ModifiedObjectInfo(org.talend.commons.ui.runtime.swt.tableviewer.data.ModifiedObjectInfo) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Aggregations

ECodeLanguage (org.talend.core.language.ECodeLanguage)29 RepositoryContext (org.talend.core.context.RepositoryContext)5 HashMap (java.util.HashMap)4 StyledText (org.eclipse.swt.custom.StyledText)4 IEditorPart (org.eclipse.ui.IEditorPart)4 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)4 IElementParameter (org.talend.core.model.process.IElementParameter)4 RepositoryEditorInput (org.talend.core.repository.ui.editor.RepositoryEditorInput)4 IFile (org.eclipse.core.resources.IFile)3 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)3 IEditorReference (org.eclipse.ui.IEditorReference)3 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)3 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)3 ICodeGeneratorService (org.talend.designer.codegen.ICodeGeneratorService)3 HashSet (java.util.HashSet)2 Map (java.util.Map)2 EList (org.eclipse.emf.common.util.EList)2 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)2 UnnotifiableColorStyledText (org.talend.commons.ui.swt.colorstyledtext.UnnotifiableColorStyledText)2 Item (org.talend.core.model.properties.Item)2