Search in sources :

Example 1 with IProjectRepositoryNode

use of org.talend.repository.model.nodes.IProjectRepositoryNode in project tdi-studio-se by Talend.

the class BusinessAssignmentComposite method createSelectionListener.

private void createSelectionListener() {
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            BusinessAssignment businessAssignment = getBusinessAssignment(event.getSelection());
            if (businessAssignment != null) {
                final IRepositoryView repositoryView = getRepositoryView();
                if (repositoryView != null) {
                    IProjectRepositoryNode rootRepositoryNode = repositoryView.getRoot();
                    TalendItem item = businessAssignment.getTalendItem();
                    //
                    if (item instanceof Routine && rootRepositoryNode instanceof ProjectRepositoryNode) {
                        RepositoryNodeUtilities.expandParentNode(getRepositoryView(), ((ProjectRepositoryNode) rootRepositoryNode).getRootRepositoryNode(ERepositoryObjectType.CODE));
                    }
                    selectChild(item, (IRepositoryNode) rootRepositoryNode);
                }
            }
        }

        private void selectChild(TalendItem item, IRepositoryNode rootRepositoryNode) {
            try {
                RepositoryNode curNode = null;
                JobSettingsView viewer = (JobSettingsView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(JobSettingsView.ID);
                IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(item.getId());
                if (lastVersion != null) {
                    curNode = RepositoryNodeUtilities.getRepositoryNode(lastVersion);
                    select(viewer, curNode);
                } else if (item instanceof TableMetadata) {
                    MetadataTable table = MetadataToolHelper.getMetadataTableFromRepository(item.getId());
                    if (table != null) {
                        //$NON-NLS-1$
                        String id = item.getId().split(" - ")[0];
                        RepositoryNode node = RepositoryNodeUtilities.getMetadataTableFromConnection(item.getId());
                        IRepositoryView view = getRepositoryView();
                        if (view != null) {
                            RepositoryNodeUtilities.expandParentNode(view, node);
                            select(viewer, node);
                        }
                    }
                } else if (item instanceof Query) {
                    org.talend.core.model.metadata.builder.connection.Query query = MetadataToolHelper.getQueryFromRepository(item.getId());
                    if (query != null) {
                        //$NON-NLS-1$
                        String id = item.getId().split(" - ")[0];
                        IRepositoryView view = getRepositoryView();
                        RepositoryNode node = RepositoryNodeUtilities.getQueryFromConnection(item.getId());
                        RepositoryNodeUtilities.expandParentNode(view, node);
                        select(viewer, node);
                    }
                } else if (item instanceof SAPFunction) {
                    SAPFunctionUnit function = MetadataToolHelper.getSAPFunctionFromRepository(item.getId());
                    if (function != null) {
                        IRepositoryView view = getRepositoryView();
                        RepositoryNode node = RepositoryNodeUtilities.getSAPFunctionFromConnection(item.getId());
                        RepositoryNodeUtilities.expandParentNode(view, node);
                        select(viewer, node);
                    }
                } else {
                    for (IRepositoryNode node : rootRepositoryNode.getChildren()) {
                        RepositoryNode rNode = (RepositoryNode) node;
                        if (item instanceof SQLPattern && rNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.SQLPATTERNS) {
                            if (rNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
                                SQLPatternItem sqlItem = (SQLPatternItem) rNode.getObject().getProperty().getItem();
                                if (sqlItem.isSystem() && item.getLabel().equals(rNode.getObject().getLabel())) {
                                    select(viewer, rNode);
                                }
                            } else {
                                selectChild(item, rNode);
                            }
                        } else if (item instanceof Routine && rNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.ROUTINES) {
                            if (rNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
                                RoutineItem sqlItem = (RoutineItem) rNode.getObject().getProperty().getItem();
                                if (sqlItem.isBuiltIn() && item.getLabel().equals(rNode.getObject().getLabel())) {
                                    select(viewer, rNode);
                                }
                            } else {
                                selectChild(item, rNode);
                            }
                        }
                    }
                }
            } catch (PersistenceException e) {
                // TODO Auto-generated catch block
                // e.printStackTrace();
                ExceptionHandler.process(e);
            }
        }

        private void select(JobSettingsView viewer, RepositoryNode repositoryNode) {
            if (viewer == null) {
                return;
            }
            if (repositoryNode == null) {
                return;
            }
            CorePlugin.getDefault().getRepositoryService().removeRepositoryTreeViewListener(viewer);
            final IRepositoryView repositoryView = getRepositoryView();
            if (repositoryView != null) {
                repositoryView.getViewer().setSelection(new StructuredSelection(repositoryNode));
            }
            CorePlugin.getDefault().getRepositoryService().addRepositoryTreeViewListener(viewer);
        }
    });
}
Also used : JobSettingsView(org.talend.designer.core.ui.views.jobsettings.JobSettingsView) BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) Query(org.talend.designer.business.model.business.Query) SAPFunctionUnit(org.talend.core.model.metadata.builder.connection.SAPFunctionUnit) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) IRepositoryView(org.talend.repository.ui.views.IRepositoryView) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) TalendItem(org.talend.designer.business.model.business.TalendItem) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) TableMetadata(org.talend.designer.business.model.business.TableMetadata) SAPFunction(org.talend.designer.business.model.business.SAPFunction) SQLPattern(org.talend.designer.business.model.business.SQLPattern) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) RoutineItem(org.talend.core.model.properties.RoutineItem) Routine(org.talend.designer.business.model.business.Routine) 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) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 2 with IProjectRepositoryNode

use of org.talend.repository.model.nodes.IProjectRepositoryNode in project tdi-studio-se by Talend.

the class AbstractVersionManagementProjectSettingPage method processItems.

protected void processItems(List<ItemVersionObject> objects, RepositoryNode node) {
    if (node == null) {
        return;
    }
    // if the root node of type is not init, force init.
    IProjectRepositoryNode root = node.getRoot();
    if (root instanceof ProjectRepositoryNode) {
        ((ProjectRepositoryNode) root).initNode(node);
    }
    if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
        if (node.getObject() != null) {
            Property property = node.getObject().getProperty();
            Item item = property.getItem();
            if (item != null && filterRepositoryNode(node)) {
                // must be item
                ItemVersionObject object = createItemVersionObject(node, property);
                objects.add(object);
            }
        }
    } else {
        IContentProvider contentProvider = treeViewer.getContentProvider();
        if (contentProvider instanceof NavigatorContentServiceContentProvider) {
            NavigatorContentServiceContentProvider navigatorProvider = (NavigatorContentServiceContentProvider) contentProvider;
            Object[] children = navigatorProvider.getChildren(node);
            for (Object child : children) {
                if (child instanceof RepositoryNode) {
                    processItems(objects, (RepositoryNode) child);
                }
            }
        } else {
            for (IRepositoryNode child : node.getChildren()) {
                processItems(objects, (RepositoryNode) child);
            }
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) TableItem(org.eclipse.swt.widgets.TableItem) IContentProvider(org.eclipse.jface.viewers.IContentProvider) IRepositoryNode(org.talend.repository.model.IRepositoryNode) NavigatorContentServiceContentProvider(org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ItemVersionObject(org.talend.repository.model.ItemVersionObject) ItemVersionObject(org.talend.repository.model.ItemVersionObject) 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) Property(org.talend.core.model.properties.Property) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode)

Example 3 with IProjectRepositoryNode

use of org.talend.repository.model.nodes.IProjectRepositoryNode in project tdi-studio-se by Talend.

the class StatusManagerSettingPage method processItems.

private void processItems(List<RepositoryObject> objects, IRepositoryNode node) {
    if (node == null) {
        return;
    }
    // if the root node of type is not init, force init.
    IProjectRepositoryNode root = node.getRoot();
    if (root instanceof ProjectRepositoryNode) {
        ((ProjectRepositoryNode) root).initNode(node);
    }
    if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
        if (node.getObject() != null) {
            Property property = node.getObject().getProperty();
            Item item = property.getItem();
            if (item != null && filterRepositoryNode((RepositoryNode) node)) {
                // must be item
                RepositoryObject object = new RepositoryObject(node.getObject().getProperty());
                object.setRepositoryNode(node);
                // ItemVersionObject object = new ItemVersionObject(node, property.getVersion());
                objects.add(object);
            }
        }
    } else {
        IContentProvider contentProvider = treeViewer.getContentProvider();
        if (contentProvider instanceof NavigatorContentServiceContentProvider) {
            NavigatorContentServiceContentProvider navigatorProvider = (NavigatorContentServiceContentProvider) contentProvider;
            Object[] children = navigatorProvider.getChildren(node);
            for (Object child : children) {
                if (child instanceof RepositoryNode) {
                    processItems(objects, (RepositoryNode) child);
                }
            }
        } else {
            for (IRepositoryNode child : node.getChildren()) {
                processItems(objects, child);
            }
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) TableItem(org.eclipse.swt.widgets.TableItem) RepositoryObject(org.talend.core.model.repository.RepositoryObject) IContentProvider(org.eclipse.jface.viewers.IContentProvider) IRepositoryNode(org.talend.repository.model.IRepositoryNode) NavigatorContentServiceContentProvider(org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) RepositoryObject(org.talend.core.model.repository.RepositoryObject) 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) Property(org.talend.core.model.properties.Property) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode)

Example 4 with IProjectRepositoryNode

use of org.talend.repository.model.nodes.IProjectRepositoryNode 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 5 with IProjectRepositoryNode

use of org.talend.repository.model.nodes.IProjectRepositoryNode in project tdi-studio-se by Talend.

the class StatusManagerSettingPage method expandSomeNodes.

private void expandSomeNodes(IProjectRepositoryNode root) {
    if (root instanceof IProjectRepositoryNode) {
        final IProjectRepositoryNode rootNode = root;
        // metadata
        IRepositoryNode metadataConNode = rootNode.getRootRepositoryNode(ERepositoryObjectType.METADATA);
        if (metadataConNode != null) {
            treeViewer.expandToLevel(metadataConNode, 1);
        }
        // code
        IRepositoryNode codeNode = rootNode.getRootRepositoryNode(ERepositoryObjectType.CODE);
        if (codeNode != null) {
            treeViewer.expandToLevel(codeNode, 1);
        }
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode)

Aggregations

IRepositoryNode (org.talend.repository.model.IRepositoryNode)6 IProjectRepositoryNode (org.talend.repository.model.nodes.IProjectRepositoryNode)6 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)5 RepositoryNode (org.talend.repository.model.RepositoryNode)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 Item (org.talend.core.model.properties.Item)3 IContentProvider (org.eclipse.jface.viewers.IContentProvider)2 TableItem (org.eclipse.swt.widgets.TableItem)2 NavigatorContentServiceContentProvider (org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider)2 Property (org.talend.core.model.properties.Property)2 RepositoryObject (org.talend.core.model.repository.RepositoryObject)2 ItemVersionObject (org.talend.repository.model.ItemVersionObject)2 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 IPath (org.eclipse.core.runtime.IPath)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Path (org.eclipse.core.runtime.Path)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1