Search in sources :

Example 6 with IRepositoryView

use of org.talend.repository.ui.views.IRepositoryView in project tdi-studio-se by Talend.

the class StandAloneTalendJavaEditor method setName.

private void setName() {
    IRepositoryView repoView = RepositoryManagerHelper.findRepositoryView();
    if (repoView != null) {
        RepositoryNode repositoryNode = rEditorInput.getRepositoryNode();
        if (repositoryNode != null) {
            setTitleImage(getTitleImage());
            setPartName(getTitleText(repositoryNode.getObject()));
        }
    }
}
Also used : IRepositoryView(org.talend.repository.ui.views.IRepositoryView) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 7 with IRepositoryView

use of org.talend.repository.ui.views.IRepositoryView in project tdi-studio-se by Talend.

the class DynamicComposite method getConnectionItems.

/**
     * DOC qzhang Comment method "getConnectionItems".
     * 
     * @return
     * @throws PersistenceException
     */
private List<ConnectionItem> getConnectionItems() throws PersistenceException {
    List<ConnectionItem> list = new ArrayList<ConnectionItem>();
    IRepositoryView repositoryView = RepositoryManagerHelper.findRepositoryView();
    if (repositoryView != null) {
        TreeViewer viewer = (TreeViewer) repositoryView.getViewer();
        IContentProvider contentProvider = viewer.getContentProvider();
        if (contentProvider instanceof RepositoryContentProvider) {
            RepositoryContentProvider provider = (RepositoryContentProvider) contentProvider;
            RepositoryNode metadataConNode = provider.getRootRepositoryNode(ERepositoryObjectType.METADATA);
            for (IRepositoryNode connectionItem : metadataConNode.getChildren()) {
                if (viewer.isExpandable(connectionItem)) {
                    provider.getChildren(connectionItem);
                }
                for (IRepositoryNode node : connectionItem.getChildren()) {
                    addConnectionItem(viewer, provider, list, (RepositoryNode) node);
                }
            }
        }
    }
    return list;
}
Also used : IContentProvider(org.eclipse.jface.viewers.IContentProvider) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryContentProvider(org.talend.repository.viewer.ui.provider.RepositoryContentProvider) ConnectionItem(org.talend.core.model.properties.ConnectionItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) IRepositoryView(org.talend.repository.ui.views.IRepositoryView) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 8 with IRepositoryView

use of org.talend.repository.ui.views.IRepositoryView in project tdi-studio-se by Talend.

the class CreateDiagramAction method setRepositoryNode.

private void setRepositoryNode(Properties params) {
    IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (null == workbenchWindow) {
        return;
    }
    IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
    if (null == workbenchPage) {
        return;
    }
    IPerspectiveDescriptor currentPerspective = workbenchPage.getPerspective();
    if (!IBrandingConfiguration.PERSPECTIVE_DI_ID.equals(currentPerspective.getId())) {
        // show di perspective
        try {
            workbenchWindow.getWorkbench().showPerspective(IBrandingConfiguration.PERSPECTIVE_DI_ID, workbenchWindow);
            workbenchPage = workbenchWindow.getActivePage();
        } catch (WorkbenchException e) {
            ExceptionHandler.process(e);
            return;
        }
    }
    // bug 16594
    IRepositoryView view = RepositoryManagerHelper.getRepositoryView();
    if (view != null) {
        Object type = params.get("type");
        if (ERepositoryObjectType.BUSINESS_PROCESS != null && ERepositoryObjectType.BUSINESS_PROCESS.name().equals(type)) {
            RepositoryNode processNode = ((ProjectRepositoryNode) view.getRoot()).getRootRepositoryNode(ERepositoryObjectType.BUSINESS_PROCESS);
            final StructuredViewer viewer = view.getViewer();
            if (viewer instanceof TreeViewer) {
                ((TreeViewer) viewer).expandToLevel(processNode, 1);
            }
            this.repositoryNode = processNode;
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) WorkbenchException(org.eclipse.ui.WorkbenchException) IRepositoryView(org.talend.repository.ui.views.IRepositoryView) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 9 with IRepositoryView

use of org.talend.repository.ui.views.IRepositoryView 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 10 with IRepositoryView

use of org.talend.repository.ui.views.IRepositoryView in project tdi-studio-se by Talend.

the class OpenDiagramAction method getSelectedObject.

private ISelection getSelectedObject() {
    if (params == null) {
        return getSelection();
    } else {
        IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (null == workbenchWindow) {
            return null;
        }
        IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
        if (null == workbenchPage) {
            return null;
        }
        IPerspectiveDescriptor currentPerspective = workbenchPage.getPerspective();
        if (!IBrandingConfiguration.PERSPECTIVE_DI_ID.equals(currentPerspective.getId())) {
            // show di perspective
            try {
                workbenchWindow.getWorkbench().showPerspective(IBrandingConfiguration.PERSPECTIVE_DI_ID, workbenchWindow);
                workbenchPage = workbenchWindow.getActivePage();
            } catch (WorkbenchException e) {
                ExceptionHandler.process(e);
                return null;
            }
        }
        RepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(params.getProperty("nodeId"), false);
        IRepositoryView viewPart = getViewPart();
        if (repositoryNode != null && viewPart != null) {
            RepositoryNodeUtilities.expandParentNode(viewPart, repositoryNode);
            return new StructuredSelection(repositoryNode);
        }
        return null;
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) WorkbenchException(org.eclipse.ui.WorkbenchException) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryView(org.talend.repository.ui.views.IRepositoryView)

Aggregations

IRepositoryView (org.talend.repository.ui.views.IRepositoryView)20 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)11 RepositoryNode (org.talend.repository.model.RepositoryNode)9 TreeViewer (org.eclipse.jface.viewers.TreeViewer)7 IRepositoryNode (org.talend.repository.model.IRepositoryNode)7 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)6 IPerspectiveDescriptor (org.eclipse.ui.IPerspectiveDescriptor)5 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)5 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)5 ISelection (org.eclipse.jface.viewers.ISelection)4 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)4 Shell (org.eclipse.swt.widgets.Shell)4 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)4 WorkbenchException (org.eclipse.ui.WorkbenchException)4 WizardDialog (org.eclipse.jface.wizard.WizardDialog)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 ArrayList (java.util.ArrayList)2 ConnectionItem (org.talend.core.model.properties.ConnectionItem)2 RoutineItem (org.talend.core.model.properties.RoutineItem)2 File (java.io.File)1