use of org.talend.designer.codegen.ICodeGeneratorService in project tdi-studio-se by Talend.
the class DownloadComponenentsAction method updateUI.
/**
* Update ui after job finished.
*
* @param action
* @param event
*/
private void updateUI(final IJobChangeEvent event) {
// activate aection again after job finished
if (fExtensionDownloaded > 0) {
// refresh palette
ExchangeUtils.reloadComponents();
// update needed modules.
CorePlugin.getDefault().getLibrariesService().resetModulesNeeded();
// see feature 0005050: confirmation popup once the component is installed
confirmInstallation();
// Start Code Generation Init
ICodeGeneratorService codeGenService = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
Job job = codeGenService.refreshTemplates();
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
ComponentPaletteUtilities.setSkipUpdatePalette(false);
}
});
RefreshComponenentsAction action = new RefreshComponenentsAction();
action.run(new String[] { RefreshComponenentsAction.REFRESH_INSTALLED }, ContentConstants.UL_DOWNLOADED_EXTENSIONS);
}
}
use of org.talend.designer.codegen.ICodeGeneratorService 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.designer.codegen.ICodeGeneratorService in project tesb-studio-se by Talend.
the class AbstractBeanAction method openBeanEditor.
public IEditorPart openBeanEditor(BeanItem beanItem, boolean readOnly) throws SystemException, PartInitException {
if (beanItem == 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 = service.createRoutineSynchronizer();
// 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(beanItem)) {
page.bringToTop(editor);
found = true;
talendEditor = editor;
break;
}
}
}
if (!found) {
routineSynchronizer.syncRoutine(beanItem, true);
IFile file = routineSynchronizer.getFile(beanItem);
if (file == null) {
return null;
}
RepositoryEditorInput input = new BeanEditorInput(file, beanItem);
input.setReadOnly(readOnly);
//$NON-NLS-1$
talendEditor = page.openEditor(input, talendEditorID);
}
return talendEditor;
}
use of org.talend.designer.codegen.ICodeGeneratorService 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;
}
use of org.talend.designer.codegen.ICodeGeneratorService in project tdi-studio-se by Talend.
the class ProblemsView method restoreProblem.
/**
*
* ggu Comment method "restoreProblem".
*
* when restore the item, check the problem.
*/
private void restoreProblem(RoutineItem item) {
ICodeGeneratorService service = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
ITalendSynchronizer routineSynchronizer = null;
switch(LanguageManager.getCurrentLanguage()) {
case JAVA:
routineSynchronizer = service.createJavaRoutineSynchronizer();
break;
case PERL:
routineSynchronizer = service.createPerlRoutineSynchronizer();
break;
default:
}
if (routineSynchronizer != null) {
try {
routineSynchronizer.syncRoutine(item, true);
IFile file = routineSynchronizer.getFile(item);
if (file == null) {
return;
}
file.refreshLocal(IResource.DEPTH_ONE, null);
Problems.addRoutineFile(file, item.getProperty());
} catch (SystemException e) {
ExceptionHandler.process(e);
} catch (CoreException e) {
ExceptionHandler.process(e);
}
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
Problems.refreshProblemTreeView();
}
});
}
}
Aggregations