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;
if (MapperMain.isStandAloneMode()) {
styledText = new StyledText(tabFolderEditors, SWT.V_SCROLL | SWT.H_SCROLL);
} else {
RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
ECodeLanguage language = repositoryContext.getProject().getLanguage();
IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
// styledText = new ColorStyledText(tabFolderEditors, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL,
// colorManager, language.getName());
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 UIManager method parseFilterColumn.
public ParseExpressionResult parseFilterColumn(String expression, ITableEntry currentModifiedITableEntry, boolean linkMustHaveSelectedState, boolean checkInputKeyAutomatically, boolean inputExpressionAppliedOrCanceled) {
if (currentModifiedITableEntry instanceof InputColumnTableEntry) {
InputColumnTableEntry entry = (InputColumnTableEntry) currentModifiedITableEntry;
if (StringUtils.trimToNull(expression) == null) {
entry.setOperator(null);
}
}
DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentModifiedITableEntry);
boolean linkHasBeenAdded = false;
boolean linkHasBeenRemoved = false;
DataMapExpressionParser dataMapExpressionParser = new DataMapExpressionParser(LanguageProvider.getCurrentLanguage());
TableEntryLocation[] tableEntriesLocationsSources = dataMapExpressionParser.parseTableEntryLocations(expression);
Set<TableEntryLocation> alreadyProcessed = new HashSet<TableEntryLocation>();
Set<ITableEntry> sourcesForTarget = mapperManager.getSourcesForTarget(currentModifiedITableEntry);
Set<ITableEntry> sourcesForTargetToDelete = new HashSet<ITableEntry>(sourcesForTarget);
boolean isInputEntry = currentModifiedITableEntry instanceof InputColumnTableEntry;
ECodeLanguage codeLanguage = LanguageProvider.getCurrentLanguage().getCodeLanguage();
for (TableEntryLocation tableEntriesLocationsSource : tableEntriesLocationsSources) {
TableEntryLocation location = tableEntriesLocationsSource;
// tests to know if link must be removed if key is unchecked
boolean dontRemoveLink = (!isInputEntry || isInputEntry && (inputExpressionAppliedOrCanceled || !inputExpressionAppliedOrCanceled && !mapperManager.checkEntryHasInvalidUncheckedKey((InputColumnTableEntry) currentModifiedITableEntry)));
if (!alreadyProcessed.contains(location) && checkSourceLocationIsValid(location, currentModifiedITableEntry) && (mapperManager.isAdvancedMap() || !mapperManager.isAdvancedMap() && dontRemoveLink)) {
ITableEntry sourceTableEntry = mapperManager.retrieveTableEntry(location);
if (sourceTableEntry != null && sourcesForTarget.contains(sourceTableEntry)) {
Set<IMapperLink> targets = mapperManager.getGraphicalLinksFromTarget(currentModifiedITableEntry);
Set<IMapperLink> linksFromTarget = new HashSet<IMapperLink>(targets);
for (IMapperLink link : linksFromTarget) {
link.calculate();
}
}
}
}
mapperManager.orderLinks();
if (!mapperManager.isAdvancedMap()) {
if (dataMapTableView.getZone() == Zone.INPUTS) {
if (linkHasBeenAdded || linkHasBeenRemoved) {
checkTargetInputKey(currentModifiedITableEntry, checkInputKeyAutomatically, inputExpressionAppliedOrCanceled);
}
if (inputExpressionAppliedOrCanceled) {
openChangeKeysDialog((InputDataMapTableView) dataMapTableView);
}
}
}
return new ParseExpressionResult(linkHasBeenAdded, linkHasBeenRemoved);
}
use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.
the class UIManager method parseExpression.
/**
*
*
* @param expression
* @param currentModifiedITableEntry
* @param linkMustHaveSelectedState
* @param checkInputKeyAutomatically TODO
* @param inputExpressionAppliedOrCanceled TODO
* @param newSelectedDataMapTableView
* @return true if a link has been added or removed, false else
*/
public ParseExpressionResult parseExpression(String expression, ITableEntry currentModifiedITableEntry, boolean linkMustHaveSelectedState, boolean checkInputKeyAutomatically, boolean inputExpressionAppliedOrCanceled) {
if (currentModifiedITableEntry instanceof InputColumnTableEntry) {
InputColumnTableEntry entry = (InputColumnTableEntry) currentModifiedITableEntry;
if (StringUtils.trimToNull(expression) == null) {
entry.setOperator(null);
}
}
DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentModifiedITableEntry);
boolean linkHasBeenAdded = false;
boolean linkHasBeenRemoved = false;
DataMapExpressionParser dataMapExpressionParser = new DataMapExpressionParser(LanguageProvider.getCurrentLanguage());
TableEntryLocation[] tableEntriesLocationsSources = dataMapExpressionParser.parseTableEntryLocations(expression);
Set<TableEntryLocation> alreadyProcessed = new HashSet<TableEntryLocation>();
Set<ITableEntry> sourcesForTarget = mapperManager.getSourcesForTarget(currentModifiedITableEntry);
Set<ITableEntry> sourcesForTargetToDelete = new HashSet<ITableEntry>(sourcesForTarget);
boolean isInputEntry = currentModifiedITableEntry instanceof InputColumnTableEntry;
ECodeLanguage codeLanguage = LanguageProvider.getCurrentLanguage().getCodeLanguage();
for (TableEntryLocation tableEntriesLocationsSource : tableEntriesLocationsSources) {
TableEntryLocation location = tableEntriesLocationsSource;
// tests to know if link must be removed if key is unchecked
boolean dontRemoveLink = (!isInputEntry || isInputEntry && (inputExpressionAppliedOrCanceled || !inputExpressionAppliedOrCanceled && !mapperManager.checkEntryHasInvalidUncheckedKey((InputColumnTableEntry) currentModifiedITableEntry)));
if (!alreadyProcessed.contains(location) && checkSourceLocationIsValid(location, currentModifiedITableEntry) && (mapperManager.isAdvancedMap() || !mapperManager.isAdvancedMap() && dontRemoveLink)) {
ITableEntry sourceTableEntry = mapperManager.retrieveTableEntry(location);
sourcesForTargetToDelete.remove(sourceTableEntry);
if (sourceTableEntry != null && !sourcesForTarget.contains(sourceTableEntry)) {
DataMapTableView sourceDataMapTableView = mapperManager.retrieveDataMapTableView(sourceTableEntry);
IMapperLink link = new Link(new PointLinkDescriptor(sourceTableEntry, sourceDataMapTableView.getZone()), new PointLinkDescriptor(currentModifiedITableEntry, dataMapTableView.getZone()), mapperManager);
link.setState(linkMustHaveSelectedState ? LinkState.SELECTED : LinkState.UNSELECTED);
mapperManager.addLink(link);
linkHasBeenAdded = true;
}
alreadyProcessed.add(location);
}
}
Set<IMapperLink> targets = mapperManager.getGraphicalLinksFromTarget(currentModifiedITableEntry);
Set<IMapperLink> linksFromTarget = new HashSet<IMapperLink>(targets);
for (IMapperLink link : linksFromTarget) {
if (sourcesForTargetToDelete.contains(link.getPointLinkDescriptor1().getTableEntry())) {
mapperManager.removeLink(link, link.getPointLinkDescriptor2().getTableEntry());
linkHasBeenRemoved = true;
}
}
mapperManager.orderLinks();
if (!mapperManager.isAdvancedMap()) {
if (dataMapTableView.getZone() == Zone.INPUTS) {
if (linkHasBeenAdded || linkHasBeenRemoved) {
checkTargetInputKey(currentModifiedITableEntry, checkInputKeyAutomatically, inputExpressionAppliedOrCanceled);
}
if (inputExpressionAppliedOrCanceled) {
openChangeKeysDialog((InputDataMapTableView) dataMapTableView);
}
}
}
return new ParseExpressionResult(linkHasBeenAdded, linkHasBeenRemoved);
}
use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.
the class RenametForCurrentIterationMigrationTask method convertItem.
private boolean convertItem(Item item, ProcessType processType) throws PersistenceException {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
ECodeLanguage language = getProject().getLanguage();
EList node = processType.getNode();
for (Object n : node) {
NodeType type = (NodeType) n;
EList elementParameterList = type.getElementParameter();
for (Object elem : elementParameterList) {
ElementParameterType elemType = (ElementParameterType) elem;
if (!elemType.getField().equals("CHECK")) {
//$NON-NLS-1$
if (language.equals(ECodeLanguage.JAVA)) {
if (elemType.getValue() != null && elemType.getValue().contains(TFOR) && elemType.getValue().contains(CURRENT_ITER)) {
elemType.setValue(elemType.getValue().replaceAll(CURRENT_ITER, CURRENT_VALUE));
}
}
if (elemType.getValue() != null && elemType.getValue().contains(TFOR)) {
elemType.setValue(elemType.getValue().replaceAll(TFOR, TLOOP));
modified = true;
}
// for table
EList elemValue = elemType.getElementValue();
for (Object elemV : elemValue) {
ElementValueType elemVal = (ElementValueType) elemV;
if (language.equals(ECodeLanguage.JAVA)) {
if (elemVal.getValue() != null && elemVal.getValue().contains(TFOR) && elemVal.getValue().contains(CURRENT_ITER)) {
elemVal.setValue(elemVal.getValue().replaceAll(CURRENT_ITER, CURRENT_VALUE));
}
}
if (elemVal.getValue() != null && elemVal.getValue().contains(TFOR)) {
elemVal.setValue(elemVal.getValue().replaceAll(TFOR, TLOOP));
modified = true;
}
}
}
}
}
if (modified) {
factory.save(item, true);
}
return modified;
}
use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.
the class RenametFTPToFTPGetMigrationTaskForPerl method execute.
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
try {
ECodeLanguage projectLanguage = getProject().getLanguage();
if (projectLanguage.equals(ECodeLanguage.PERL)) {
//$NON-NLS-1$
IComponentConversion removePropertyComponentConversion = new RemovePropertyComponentConversion("TYPE");
//$NON-NLS-1$
RenameComponentConversion renameComponentConversion = new RenameComponentConversion("tFTPGet");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
IComponentFilter filter1 = new PropertyComponentFilter("tFTP", "ACTION", "get");
ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(renameComponentConversion, removePropertyComponentConversion));
//$NON-NLS-1$
renameComponentConversion.setNewName("tFTPPut");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
IComponentFilter filter2 = new PropertyComponentFilter("tFTP", "ACTION", "put");
ModifyComponentsAction.searchAndModify(item, processType, filter2, Arrays.<IComponentConversion>asList(renameComponentConversion, removePropertyComponentConversion));
//$NON-NLS-1$
renameComponentConversion.setNewName("tFTPDelete");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
IComponentFilter filter3 = new PropertyComponentFilter("tFTP", "ACTION", "delete");
ModifyComponentsAction.searchAndModify(item, processType, filter3, Arrays.<IComponentConversion>asList(renameComponentConversion, removePropertyComponentConversion));
//$NON-NLS-1$
renameComponentConversion.setNewName("tFTPRename");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
IComponentFilter filter4 = new PropertyComponentFilter("tFTP", "ACTION", "rename");
ModifyComponentsAction.searchAndModify(item, processType, filter4, Arrays.<IComponentConversion>asList(renameComponentConversion, removePropertyComponentConversion));
return ExecutionResult.SUCCESS_WITH_ALERT;
} else {
// do nothing
return ExecutionResult.NOTHING_TO_DO;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
Aggregations