use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.
the class MultipleThreadDynamicComposite method operationInThread.
// refactore to be synchonized with the dispose() method because of TDI-24184
// the synchronized methodis a quick fix but not the ideal one because this method is accessing many attributes
// of the current class that may be modified by other thread (just like "elem" modified by the dispose() method.
protected synchronized void operationInThread() {
if (elem == null) {
return;
}
// hywang modified for
List<? extends IElementParameter> listParam = elem.getElementParametersWithChildrens();
Boolean updateNeeded = (Boolean) elem.getPropertyValue(updataComponentParamName);
if (updateNeeded != null) {
if (updateNeeded) {
if (elem != null) {
addComponents(forceRedraw);
elem.setPropertyValue(updataComponentParamName, new Boolean(false));
forceRedraw = false;
}
}
}
final ECodeLanguage language = ((RepositoryContext) org.talend.core.CorePlugin.getContext().getProperty(org.talend.core.context.Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
IRunProcessService service = DesignerPlugin.getDefault().getRunProcessService();
final ICodeProblemsChecker syntaxChecker = service.getSyntaxChecker(language);
List<Problem> javaProblem = null;
for (int i = 0; i < listParam.size(); i++) {
if (listParam.get(i).getCategory() == section) {
if (listParam.get(i).isShow(listParam)) {
final IElementParameter e = listParam.get(i);
e.isReadOnly();
e.isNoCheck();
if (language == ECodeLanguage.JAVA && javaProblem == null) {
if (!e.isReadOnly() && !e.isNoCheck()) {
javaProblem = syntaxChecker.checkProblems(null);
}
}
final List<Problem> nodePros = javaProblem;
if (generator != null) {
AbstractElementPropertySectionController controller = generator.getController(e.getFieldType(), MultipleThreadDynamicComposite.this);
if (controller != null) {
controller.updateCodeProblems(nodePros);
controller.refresh(e, checkErrorsWhenViewRefreshed);
}
}
}
}
}
if (propertyResized) {
try {
removeListener(SWT.Resize, resizeListener);
getParent().layout();
composite.pack();
propertyResized = false;
addListener(SWT.Resize, resizeListener);
} catch (Exception e) {
}
}
checkErrorsWhenViewRefreshed = false;
// long time = TimeMeasure.timeSinceBegin("DC:refresh:" + getCurrentComponent()); //$NON-NLS-1$
// TimeMeasure.end("DC:refresh:" + getCurrentComponent()); //$NON-NLS-1$
// if (DynamicTabbedPropertySection.DEBUG_TIME) {
// System.out.println("DC;total;" + getCurrentComponent() + ";" + time); //$NON-NLS-1$ //$NON-NLS-2$
// }
}
use of org.talend.core.language.ECodeLanguage in project tmdm-studio-se by Talend.
the class DeployOnMDMAction method init.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
* org.eclipse.jface.viewers.IStructuredSelection)
*/
public void init(TreeViewer viewer, IStructuredSelection selection) {
boolean canWork = true;
ECodeLanguage language = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
if (selection.isEmpty() || language == ECodeLanguage.PERL) {
// only Java project can see the action
setEnabled(false);
return;
}
if (MDMServerHelper.getServers().size() == 0) {
setEnabled(false);
return;
}
List<RepositoryNode> nodes = selection.toList();
for (RepositoryNode node : nodes) {
if (node.getType() == ENodeType.REPOSITORY_ELEMENT && node.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.PROCESS) {
continue;
}
canWork = false;
break;
}
setEnabled(canWork);
}
use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.
the class ChangeReturnTypeOfServerAliveResult 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();
EList connections = processType.getConnection();
for (Object n : node) {
NodeType type = (NodeType) n;
EList elementParameterList = type.getElementParameter();
for (Object elem : elementParameterList) {
ElementParameterType elemType = (ElementParameterType) elem;
if (language.equals(ECodeLanguage.JAVA)) {
if (elemType.getValue() != null && elemType.getValue().contains("tServerAlive")) {
//$NON-NLS-1$
Matcher match = PATTERN_GET.matcher(elemType.getValue());
String replace = getReplaceValue(match);
if (replace != null && replace.length() > 0) {
elemType.setValue(replace);
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("tServerAlive")) {
//$NON-NLS-1$
Matcher match = PATTERN_GET.matcher(elemVal.getValue());
String replace = getReplaceValue(match);
if (replace != null && replace.length() > 0) {
elemVal.setValue(replace);
modified = true;
}
}
}
}
}
}
// the links
for (Object n : connections) {
ConnectionType type = (ConnectionType) n;
EList elementParameterList = type.getElementParameter();
for (Object elem : elementParameterList) {
ElementParameterType elemType = (ElementParameterType) elem;
if (language.equals(ECodeLanguage.JAVA)) {
if (elemType.getValue() != null && elemType.getValue().contains("tServerAlive")) {
//$NON-NLS-1$
Matcher match = PATTERN_GET.matcher(elemType.getValue());
String replace = getReplaceValue(match);
if (replace != null && replace.length() > 0) {
elemType.setValue(replace);
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 AbstractRoutineAction method openRoutineEditor.
/**
* DOC smallet Comment method "openRoutineEditor".
*
* @param routineItem
* @throws SystemException
* @throws PartInitException
*/
protected IEditorPart openRoutineEditor(RoutineItem routineItem, boolean readOnly) throws SystemException, PartInitException {
if (routineItem == null) {
return null;
}
ICodeGeneratorService service = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
ECodeLanguage lang = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
ITalendSynchronizer routineSynchronizer;
switch(lang) {
case JAVA:
routineSynchronizer = service.createJavaRoutineSynchronizer();
break;
case PERL:
routineSynchronizer = service.createPerlRoutineSynchronizer();
break;
default:
//$NON-NLS-1$
throw new UnsupportedOperationException(Messages.getString("AbstractRoutineAction.unknowLanguage") + lang);
}
// check if the related editor is open.
IWorkbenchPage page = getActivePage();
IEditorReference[] editorParts = page.getEditorReferences();
//$NON-NLS-1$ //$NON-NLS-2$
String talendEditorID = "org.talend.designer.core.ui.editor.StandAloneTalend" + lang.getCaseName() + "Editor";
boolean found = false;
IEditorPart talendEditor = null;
for (IEditorReference reference : editorParts) {
IEditorPart editor = reference.getEditor(false);
if (talendEditorID.equals(editor.getSite().getId())) {
// TextEditor talendEditor = (TextEditor) editor;
RepositoryEditorInput editorInput = (RepositoryEditorInput) editor.getEditorInput();
if (editorInput.getItem().equals(routineItem)) {
page.bringToTop(editor);
found = true;
talendEditor = editor;
break;
}
}
}
if (!found) {
IFile file = null;
ProjectManager projectManager = ProjectManager.getInstance();
boolean flag = projectManager.isInCurrentMainProject(routineItem);
if (!flag) {
// is ref project
file = routineSynchronizer.getRoutinesFile(routineItem);
} else {
// need open from item file with multiple version
boolean needForceRefresh = false;
if (!ProxyRepositoryFactory.getInstance().isLocalConnectionProvider()) {
// in case only routine.item file modified, better refresh every time, especially for git mode
needForceRefresh = true;
}
routineSynchronizer.syncRoutine(routineItem, true, needForceRefresh);
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
String lastVersion = factory.getLastVersion(routineItem.getProperty().getId()).getVersion();
String curVersion = routineItem.getProperty().getVersion();
if (curVersion != null && curVersion.equals(lastVersion)) {
file = routineSynchronizer.getFile(routineItem);
} else {
file = routineSynchronizer.getRoutinesFile(routineItem);
}
}
if (file == null) {
return null;
}
RepositoryEditorInput input = new RoutineEditorInput(file, routineItem);
input.setReadOnly(readOnly);
talendEditor = page.openEditor(input, talendEditorID);
}
return talendEditor;
}
use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.
the class AbstractSqlpatternAction method openSQLPatternEditor.
/**
* DOC smallet Comment method "openRoutineEditor".
*
* @param item
* @throws SystemException
* @throws PartInitException
*/
public IEditorPart openSQLPatternEditor(SQLPatternItem item, boolean readOnly) throws SystemException, PartInitException {
if (item == null) {
return null;
}
ICodeGeneratorService service = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
ECodeLanguage lang = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
ISQLPatternSynchronizer routineSynchronizer = service.getSQLPatternSynchronizer();
// check if the related editor is open.
IWorkbenchPage page = getActivePage();
IEditorReference[] editorParts = page.getEditorReferences();
//$NON-NLS-1$ //$NON-NLS-2$
String talendEditorID = "org.talend.designer.core.ui.editor.StandAloneTalend" + lang.getCaseName() + "Editor";
boolean found = false;
IEditorPart talendEditor = null;
for (IEditorReference reference : editorParts) {
IEditorPart editor = reference.getEditor(false);
if (talendEditorID.equals(editor.getSite().getId())) {
// TextEditor talendEditor = (TextEditor) editor;
RepositoryEditorInput editorInput = (RepositoryEditorInput) editor.getEditorInput();
Item item2 = editorInput.getItem();
if (item2 != null && item2 instanceof SQLPatternItem && item2.getProperty().getId().equals(item.getProperty().getId())) {
if (item2.getProperty().getVersion().equals(item.getProperty().getVersion())) {
page.bringToTop(editor);
found = true;
talendEditor = editor;
break;
} else {
page.closeEditor(editor, false);
}
}
}
}
if (!found) {
routineSynchronizer.syncSQLPattern(item, true);
IFile file = routineSynchronizer.getSQLPatternFile(item);
if (file == null) {
return null;
}
RepositoryEditorInput input = new RepositoryEditorInput(file, item);
input.setReadOnly(readOnly);
//$NON-NLS-1$
talendEditor = page.openEditor(input, talendEditorID);
}
return talendEditor;
}
Aggregations