Search in sources :

Example 11 with IRepositoryView

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

the class CreateProcess method selectRootObject.

protected final void selectRootObject(Properties params) {
    IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (null == workbenchWindow) {
        return;
    }
    IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
    if (null == workbenchPage) {
        return;
    }
    IPerspectiveDescriptor currentPerspective = workbenchPage.getPerspective();
    if (!getPerspectiveId().equals(currentPerspective.getId())) {
        // show di perspective
        try {
            workbenchWindow.getWorkbench().showPerspective(getPerspectiveId(), workbenchWindow);
            workbenchPage = workbenchWindow.getActivePage();
        } catch (WorkbenchException e) {
            ExceptionHandler.process(e);
            return;
        }
    }
    IRepositoryView view = RepositoryManagerHelper.getRepositoryView();
    if (view != null) {
        Object type = params.get("type");
        if (getProcessType().name().equals(type)) {
            IRepositoryNode processNode = ((ProjectRepositoryNode) view.getRoot()).getRootRepositoryNode(getProcessType());
            if (processNode != null) {
                setWorkbenchPart(view);
                final StructuredViewer viewer = view.getViewer();
                if (viewer instanceof TreeViewer) {
                    ((TreeViewer) viewer).expandToLevel(processNode, 1);
                }
                viewer.setSelection(new StructuredSelection(processNode));
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IRepositoryNode(org.talend.repository.model.IRepositoryNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) 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)

Example 12 with IRepositoryView

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

the class EditProcess method getSelectedObject.

private IRepositoryNode getSelectedObject() {
    if (params == null) {
        ISelection selection = getSelection();
        if (selection != null) {
            return (IRepositoryNode) ((IStructuredSelection) selection).getFirstElement();
        }
    } 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 (!getPerspectiveId().equals(currentPerspective.getId())) {
            // show di perspective
            try {
                workbenchWindow.getWorkbench().showPerspective(getPerspectiveId(), workbenchWindow);
                workbenchPage = workbenchWindow.getActivePage();
            } catch (WorkbenchException e) {
                ExceptionHandler.process(e);
                return null;
            }
        }
        IRepositoryNode repositoryNode = RepositorySeekerManager.getInstance().searchRepoViewNode(params.getProperty("nodeId"), false);
        IRepositoryView viewPart = getViewPart();
        if (repositoryNode != null && viewPart != null) {
            RepositoryNodeUtilities.expandParentNode(viewPart, repositoryNode);
            return repositoryNode;
        }
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) WorkbenchException(org.eclipse.ui.WorkbenchException) IRepositoryView(org.talend.repository.ui.views.IRepositoryView)

Example 13 with IRepositoryView

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

the class ImportDemoItemAction method doRun.

@Override
protected void doRun() {
    if (ProxyRepositoryFactory.getInstance().isUserReadOnlyOnCurrentProject()) {
        return;
    }
    // qli modified to fix the bug "6999".
    IRepositoryView repositoryView = RepositoryManagerHelper.findRepositoryView();
    if (repositoryView != null && repositoryView.getViewer() instanceof TreeViewer) {
        ((TreeViewer) repositoryView.getViewer()).getTree().setFocus();
    }
    ISelection selection = this.getSelection();
    RepositoryNode rNode = null;
    if (toolbarAction) {
        if (repositoryView != null) {
            selection = repositoryView.getViewer().getSelection();
        }
    } else if ((selection instanceof IStructuredSelection) && (((IStructuredSelection) selection).getFirstElement() instanceof RepositoryNode)) {
        Object o = ((IStructuredSelection) selection).getFirstElement();
        if (o instanceof RepositoryNode) {
            rNode = (RepositoryNode) o;
        }
    }
    final List<DemoProjectBean> demoProjectList = ImportProjectsUtilities.getAllDemoProjects();
    ImportDemoProjectItemsWizard wizard = new ImportDemoProjectItemsWizard(demoProjectList);
    wizard.setWindowTitle(IMPORT_DEMO);
    wizard.init(PlatformUI.getWorkbench(), (IStructuredSelection) selection);
    Shell activeShell = Display.getCurrent().getActiveShell();
    WizardDialog dialog = new WizardDialog(activeShell, wizard);
    dialog.open();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) DemoProjectBean(org.talend.repository.ui.actions.importproject.DemoProjectBean) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IRepositoryView(org.talend.repository.ui.views.IRepositoryView) RepositoryNode(org.talend.repository.model.RepositoryNode) ImportDemoProjectItemsWizard(org.talend.repository.ui.actions.importproject.ImportDemoProjectItemsWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 14 with IRepositoryView

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

the class OpenJobSelectionDialog method buttonPressed.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
     */
@Override
protected void buttonPressed(int buttonId) {
    if (SELECTINREPOSITORY == buttonId) {
        IStructuredSelection selection = (IStructuredSelection) getRepositoryTreeViewer().getSelection();
        // RepositoryNode node = (RepositoryNode) selection.getFirstElement();
        //
        // RepositoryView.show().expand(node);
        final IRepositoryView repositoryView = RepositoryManagerHelper.findRepositoryView();
        if (repositoryView != null) {
            repositoryView.getViewer().setSelection(selection, true);
        }
    } else {
        super.buttonPressed(buttonId);
    }
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IRepositoryView(org.talend.repository.ui.views.IRepositoryView)

Example 15 with IRepositoryView

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

the class EditQueriesAction method doRun.

@Override
protected void doRun() {
    IStructuredSelection selection = (IStructuredSelection) getSelection();
    if (repositoryNode == null && selection != null) {
        repositoryNode = (RepositoryNode) selection.getFirstElement();
    }
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    IRepositoryViewObject nodeObject = repositoryNode.getObject();
    boolean locked = false;
    if (!factory.getRepositoryContext().isEditableAsReadOnly()) {
        if (nodeObject.getRepositoryStatus() == ERepositoryStatus.LOCK_BY_OTHER) {
            locked = true;
        }
    }
    // Avoid to delete node which is locked.
    if (locked || RepositoryManager.isOpenedItemInEditor(nodeObject)) {
        final String title = "Impossible to edit queries";
        String nodeName = nodeObject.getRepositoryObjectType().getLabel();
        final String message = "item is already locked by another user.";
        Display.getDefault().syncExec(new Runnable() {

            @Override
            public void run() {
                MessageDialog dialog = new MessageDialog(new Shell(), title, null, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0);
                dialog.open();
            }
        });
        return;
    }
    DatabaseConnectionItem dbConnectionItem = null;
    boolean readOnly = false;
    ConnectionParameters connParameters = new ConnectionParameters();
    if (repositoryNode.getObjectType() == ERepositoryObjectType.METADATA_CONNECTIONS) {
        dbConnectionItem = (DatabaseConnectionItem) repositoryNode.getObject().getProperty().getItem();
        connParameters.setRepositoryName(repositoryNode.getObject().getLabel());
        connParameters.setRepositoryId(repositoryNode.getObject().getId());
        //$NON-NLS-1$
        connParameters.setQuery("");
    } else if (repositoryNode.getObjectType() == ERepositoryObjectType.METADATA_CON_QUERY) {
        QueryRepositoryObject queryRepositoryObject = (QueryRepositoryObject) repositoryNode.getObject();
        readOnly = SubItemHelper.isDeleted(queryRepositoryObject.getAbstractMetadataObject());
        dbConnectionItem = (DatabaseConnectionItem) queryRepositoryObject.getProperty().getItem();
        connParameters.setRepositoryName(dbConnectionItem.getProperty().getLabel());
        connParameters.setRepositoryId(dbConnectionItem.getProperty().getId());
        connParameters.setQueryObject(queryRepositoryObject.getQuery());
        connParameters.setQuery(queryRepositoryObject.getQuery().getValue());
        // first open Sql Builder,set true
        connParameters.setFirstOpenSqlBuilder(true);
    } else if (repositoryNode.getObjectType() == ERepositoryObjectType.METADATA_CON_TABLE) {
        dbConnectionItem = (DatabaseConnectionItem) repositoryNode.getObject().getProperty().getItem();
        connParameters.setRepositoryName(dbConnectionItem.getProperty().getLabel());
        connParameters.setRepositoryId(dbConnectionItem.getProperty().getId());
        connParameters.setMetadataTable((MetadataTableRepositoryObject) repositoryNode.getObject());
        //$NON-NLS-1$
        connParameters.setQuery("");
    }
    IRepositoryView viewPart = getViewPart();
    Display display = null;
    if (viewPart != null) {
        display = viewPart.getViewer().getControl().getDisplay();
    } else {
        display = Display.getCurrent();
        if (display == null) {
            display = Display.getDefault();
        }
    }
    Shell parentShell = new Shell(display);
    TextUtil.setDialogTitle(TextUtil.SQL_BUILDER_TITLE_REP);
    Connection connection = dbConnectionItem.getConnection();
    String selectedContext = null;
    if (connection.isContextMode()) {
        ContextItem contextItem = ContextUtils.getContextItemById2(connection.getContextId());
        if (contextItem != null && connection.isContextMode()) {
            ContextSetsSelectionDialog setsDialog = new ContextSetsSelectionDialog(null, contextItem, false);
            setsDialog.open();
            selectedContext = setsDialog.getSelectedContext();
        }
    }
    SQLBuilderDialog dial = new SQLBuilderDialog(parentShell, repositoryNode, selectedContext);
    dial.setReadOnly(readOnly);
    if (connection instanceof DatabaseConnection) {
        IMetadataConnection imetadataConnection = ConvertionHelper.convert(connection, true);
        connParameters.setSchema(imetadataConnection.getSchema() == null ? "" : imetadataConnection.getSchema());
        UIUtils.checkConnection(parentShell, imetadataConnection);
    }
    connParameters.setNodeReadOnly(readOnly);
    connParameters.setFromRepository(true);
    dial.setConnParameters(connParameters);
    dial.open();
    IRepositoryView view = getViewPart();
    if (view != null) {
        view.refreshView();
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) ConnectionParameters(org.talend.core.sqlbuilder.util.ConnectionParameters) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IRepositoryView(org.talend.repository.ui.views.IRepositoryView) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) Shell(org.eclipse.swt.widgets.Shell) QueryRepositoryObject(org.talend.core.repository.model.repositoryObject.QueryRepositoryObject) ContextSetsSelectionDialog(org.talend.metadata.managment.ui.wizard.metadata.ContextSetsSelectionDialog) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) SQLBuilderDialog(org.talend.sqlbuilder.ui.SQLBuilderDialog) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) Display(org.eclipse.swt.widgets.Display)

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