use of org.talend.core.repository.ui.editor.RepositoryEditorInput in project tdi-studio-se by Talend.
the class SQLTemplateRepoViewLinker method isRelation.
/*
* (non-Javadoc)
*
* @see org.talend.core.repository.link.AbstractRepositoryEditorInputLinker#isRelation(org.eclipse.ui.IEditorInput,
* java.lang.String)
*/
@Override
public boolean isRelation(IEditorInput editorInput, String repoNodeId) {
if (editorInput instanceof RepositoryEditorInput) {
RepositoryEditorInput repoEditorInput = (RepositoryEditorInput) editorInput;
Item item = repoEditorInput.getItem();
if (item instanceof SQLPatternItem) {
// must be SQL template item
return super.isRelation(editorInput, repoNodeId);
}
}
return false;
}
use of org.talend.core.repository.ui.editor.RepositoryEditorInput 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.repository.ui.editor.RepositoryEditorInput 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.core.repository.ui.editor.RepositoryEditorInput in project tesb-studio-se by Talend.
the class LocalWSDLEditor method init.
@Override
public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException {
super.init(site, editorInput);
if (editorInput instanceof RepositoryEditorInput) {
RepositoryEditorInput serviceEditorInput = (RepositoryEditorInput) editorInput;
serviceItem = (ServiceItem) serviceEditorInput.getItem();
repositoryNode = serviceEditorInput.getRepositoryNode();
}
}
use of org.talend.core.repository.ui.editor.RepositoryEditorInput in project tesb-studio-se by Talend.
the class LocalWSDLEditor method dispose.
@Override
public void dispose() {
// unlock item if necessary
IEditorInput currentEditorInput = getEditorInput();
if (currentEditorInput instanceof RepositoryEditorInput) {
RepositoryEditorInput serviceEditorInput = (RepositoryEditorInput) currentEditorInput;
Item currentItem = serviceEditorInput.getItem();
if (currentItem != null) {
// unlock item if no other editors open it.
boolean openItemInOtherEditor = false;
IEditorReference[] editorRefs = getEditorSite().getPage().getEditorReferences();
for (IEditorReference editorRef : editorRefs) {
if (editorRef.getEditor(false) == this) {
continue;
}
try {
IEditorInput editorInput = editorRef.getEditorInput();
if (editorInput instanceof RepositoryEditorInput) {
Item item = ((RepositoryEditorInput) editorInput).getItem();
if (item == currentItem) {
// open this item & not this one.
openItemInOtherEditor = true;
}
}
} catch (PartInitException e) {
// ignore and compare others
ExceptionHandler.process(e);
}
}
if (!openItemInOtherEditor) {
try {
DesignerPlugin.getDefault().getProxyRepositoryFactory().unlock(currentItem);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
}
super.dispose();
}
Aggregations