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;
}
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);
}
}
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();
}
});
}
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;
}
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);
}
Aggregations