Search in sources :

Example 6 with ProjectManager

use of org.talend.repository.ProjectManager in project tdi-studio-se by Talend.

the class ValidationRuleTypeProcessor method selectRepositoryNode.

@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
    if (node.getContentType() == ERepositoryObjectType.REFERENCED_PROJECTS) {
        return true;
    }
    ProjectManager pManager = ProjectManager.getInstance();
    if (!pManager.isInCurrentMainProject(node)) {
        if (node.getType() == ENodeType.STABLE_SYSTEM_FOLDER) {
            return false;
        }
        if (node.getType() == ENodeType.SYSTEM_FOLDER) {
            return true;
        }
    }
    if (node.getType() == ENodeType.SYSTEM_FOLDER) {
        return true;
    }
    if (node.getObject() == null || node.getObject().getProperty().getItem() == null) {
        return false;
    }
    if (node.getObject() instanceof MetadataTable) {
        return false;
    }
    Item item = node.getObject().getProperty().getItem();
    if (item instanceof FolderItem) {
        return true;
    }
    if (node.getObjectType() == getType()) {
        return true;
    }
    return false;
}
Also used : FolderItem(org.talend.core.model.properties.FolderItem) Item(org.talend.core.model.properties.Item) FolderItem(org.talend.core.model.properties.FolderItem) MetadataTable(org.talend.core.model.metadata.MetadataTable) ProjectManager(org.talend.repository.ProjectManager)

Example 7 with ProjectManager

use of org.talend.repository.ProjectManager 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 8 with ProjectManager

use of org.talend.repository.ProjectManager in project tdi-studio-se by Talend.

the class ExportItemWizardPage method performFinish.

public boolean performFinish() {
    if (!checkExportFile()) {
        return false;
    }
    ProjectManager pManager = ProjectManager.getInstance();
    Project project = pManager.getCurrentProject().getEmfProject();
    //$NON-NLS-1$
    String projectPath = lastPath + "\\" + project.getTechnicalLabel();
    if ((itemFromDirectoryRadio.getSelection() && new File(projectPath).exists()) || (itemFromArchiveRadio.getSelection() && new File(archivePathField.getText()).exists())) {
        File oldFile = new File(projectPath).exists() ? new File(projectPath) : new File(archivePathField.getText());
        if (MessageDialogWithToggle.openConfirm(null, Messages.getString("ExportItemWizardPage.waring"), Messages.getString("ExportItemWizardPage.fileAlreadyExist"))) {
            //$NON-NLS-1$ //$NON-NLS-2$
            deleteFile(oldFile);
        } else {
            return false;
        }
    }
    Collection<Item> selectedItems = getSelectedItems();
    if (exportDependencies.getSelection() && !implicitDependences.isEmpty()) {
        for (IRepositoryViewObject object : implicitDependences) {
            selectedItems.add(object.getProperty().getItem());
        }
    }
    List<String> folders = new ArrayList<String>();
    for (Object obj : filteredCheckboxTree.getViewer().getCheckedElements()) {
        if (obj instanceof RepositoryNode) {
            RepositoryNode repositoryNode = (RepositoryNode) obj;
            if (repositoryNode.getType() == ENodeType.SIMPLE_FOLDER && repositoryNode.getObject() instanceof Folder) {
                Folder folder = (Folder) repositoryNode.getObject();
                ERepositoryObjectType contentType = repositoryNode.getContentType();
                IProjectRepositoryNode root = repositoryNode.getRoot();
                if (root != null && root.getProject() != null) {
                    IPath path = new Path(root.getProject().getTechnicalLabel());
                    path = path.append(contentType.getFolder());
                    String folderPath = folder.getPath();
                    if (folderPath != null && !"".equals(folderPath)) {
                        path = path.append(folderPath);
                    }
                    path = path.append(folder.getLabel());
                    folders.add(path.toPortableString() + "/");
                }
            }
        }
    }
    try {
        ExportItemUtil exportItemUtil = new ExportItemUtil();
        if (itemFromArchiveRadio.getSelection()) {
            if (lastPath != null && !lastPath.endsWith(FileConstants.TAR_FILE_SUFFIX) && !lastPath.endsWith(FileConstants.TAR_GZ_FILE_SUFFIX) && !lastPath.endsWith(FileConstants.ZIP_FILE_SUFFIX)) {
                // set zip as default
                lastPath = lastPath + FileConstants.ZIP_FILE_SUFFIX;
            }
        }
        // MOD sgandon 31/03/2010 bug 12229: moved getAllVersion into ExportItemUtil.exportitems() method.
        exportItemUtil.exportItems(new File(lastPath), selectedItems, folders, true, new NullProgressMonitor());
    } catch (Exception e) {
        MessageBoxExceptionHandler.process(e);
    }
    return true;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Folder(org.talend.core.model.repository.Folder) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProjectManager(org.talend.repository.ProjectManager) Project(org.talend.core.model.properties.Project) Item(org.talend.core.model.properties.Item) TreeItem(org.eclipse.swt.widgets.TreeItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) ExportItemUtil(org.talend.repository.local.ExportItemUtil) File(java.io.File) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode)

Example 9 with ProjectManager

use of org.talend.repository.ProjectManager in project tdi-studio-se by Talend.

the class DBTreeProvider method getMetadataConnection.

/**
     * @return MetadataConnection
     */
@SuppressWarnings("unchecked")
private Container getMetadataConnection() {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    ProjectManager pManager = ProjectManager.getInstance();
    Container container = null;
    try {
        container = factory.getMetadata(pManager.getCurrentProject(), ERepositoryObjectType.METADATA_CONNECTIONS);
        pManager.retrieveReferencedProjects();
        for (Project p : pManager.getAllReferencedProjects()) {
            RootContainer rContainer = factory.getMetadata(p, ERepositoryObjectType.METADATA_CONNECTIONS);
            if (container == null) {
                container = rContainer;
            } else if (rContainer != null) {
                Iterator iterator = rContainer.absoluteKeySet().iterator();
                while (iterator.hasNext()) {
                    Object id = iterator.next();
                    container.addMember(id, rContainer.getAbsoluteMember(id));
                }
            }
        }
    } catch (PersistenceException e) {
        //$NON-NLS-1$
        SqlBuilderPlugin.log(Messages.getString("DBTreeProvider.logMessage"), e);
    } catch (BusinessException e) {
        //$NON-NLS-1$
        SqlBuilderPlugin.log(Messages.getString("DBTreeProvider.logMessage"), e);
    }
    return container;
}
Also used : Project(org.talend.core.model.general.Project) Container(org.talend.commons.utils.data.container.Container) RootContainer(org.talend.commons.utils.data.container.RootContainer) BusinessException(org.talend.commons.exception.BusinessException) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) Iterator(java.util.Iterator) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) RootContainer(org.talend.commons.utils.data.container.RootContainer) ProjectManager(org.talend.repository.ProjectManager)

Aggregations

ProjectManager (org.talend.repository.ProjectManager)9 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 ArrayList (java.util.ArrayList)2 IPath (org.eclipse.core.runtime.IPath)2 Path (org.eclipse.core.runtime.Path)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 Project (org.talend.core.model.general.Project)2 Item (org.talend.core.model.properties.Item)2 Project (org.talend.core.model.properties.Project)2 Property (org.talend.core.model.properties.Property)2 RepositoryObject (org.talend.core.model.repository.RepositoryObject)2 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)2 RepositoryNode (org.talend.repository.model.RepositoryNode)2 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1