Search in sources :

Example 16 with RepositoryEditorInput

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;
}
Also used : Item(org.talend.core.model.properties.Item) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IRepositoryEditorInput(org.talend.core.model.repository.IRepositoryEditorInput) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem)

Example 17 with RepositoryEditorInput

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;
}
Also used : ITalendSynchronizer(org.talend.designer.codegen.ITalendSynchronizer) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IFile(org.eclipse.core.resources.IFile) IEditorPart(org.eclipse.ui.IEditorPart) ICodeGeneratorService(org.talend.designer.codegen.ICodeGeneratorService) ProjectManager(org.talend.repository.ProjectManager) IEditorReference(org.eclipse.ui.IEditorReference) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 18 with RepositoryEditorInput

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;
}
Also used : ITalendSynchronizer(org.talend.designer.codegen.ITalendSynchronizer) IEditorReference(org.eclipse.ui.IEditorReference) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IFile(org.eclipse.core.resources.IFile) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) ICodeGeneratorService(org.talend.designer.codegen.ICodeGeneratorService) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 19 with RepositoryEditorInput

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();
    }
}
Also used : RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput)

Example 20 with RepositoryEditorInput

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();
}
Also used : Item(org.talend.core.model.properties.Item) ServiceItem(org.talend.repository.services.model.services.ServiceItem) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IEditorReference(org.eclipse.ui.IEditorReference) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) LoginException(org.talend.commons.exception.LoginException) PersistenceException(org.talend.commons.exception.PersistenceException)

Aggregations

RepositoryEditorInput (org.talend.core.repository.ui.editor.RepositoryEditorInput)21 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)9 IFile (org.eclipse.core.resources.IFile)7 IEditorPart (org.eclipse.ui.IEditorPart)7 Item (org.talend.core.model.properties.Item)7 SQLPatternItem (org.talend.core.model.properties.SQLPatternItem)7 IEditorInput (org.eclipse.ui.IEditorInput)6 IEditorReference (org.eclipse.ui.IEditorReference)6 PartInitException (org.eclipse.ui.PartInitException)5 ICodeGeneratorService (org.talend.designer.codegen.ICodeGeneratorService)5 ECodeLanguage (org.talend.core.language.ECodeLanguage)4 CoreException (org.eclipse.core.runtime.CoreException)3 PersistenceException (org.talend.commons.exception.PersistenceException)3 BusinessProcessItem (org.talend.core.model.properties.BusinessProcessItem)3 ProcessItem (org.talend.core.model.properties.ProcessItem)3 ISQLPatternSynchronizer (org.talend.designer.codegen.ISQLPatternSynchronizer)3 ITalendSynchronizer (org.talend.designer.codegen.ITalendSynchronizer)3 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)3 IProject (org.eclipse.core.resources.IProject)2 WizardDialog (org.eclipse.jface.wizard.WizardDialog)2