Search in sources :

Example 6 with IPerspectiveDescriptor

use of org.eclipse.ui.IPerspectiveDescriptor 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 7 with IPerspectiveDescriptor

use of org.eclipse.ui.IPerspectiveDescriptor in project tesb-studio-se by Talend.

the class OpenWSDLEditorAction method run.

public void run(IIntroSite site, Properties params) {
    PlatformUI.getWorkbench().getIntroManager().closeIntro(PlatformUI.getWorkbench().getIntroManager().getIntro());
    IPerspectiveDescriptor currentPerspective = site.getPage().getPerspective();
    if (!PERSPECTIVE_ID.equals(currentPerspective.getId())) {
        // show required perspective
        IWorkbenchWindow workbenchWindow = site.getWorkbenchWindow();
        try {
            workbenchWindow.getWorkbench().showPerspective(PERSPECTIVE_ID, workbenchWindow);
        } catch (WorkbenchException e) {
            ExceptionHandler.process(e);
            return;
        }
    }
    // find repository node
    repositoryNode = (RepositoryNode) RepositorySeekerManager.getInstance().searchRepoViewNode(params.getProperty("nodeId"), false);
    if (null != repositoryNode) {
        // expand/select node item
        RepositoryManagerHelper.getRepositoryView().getViewer().setSelection(new StructuredSelection(repositoryNode));
        init(repositoryNode);
        doRun();
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) WorkbenchException(org.eclipse.ui.WorkbenchException)

Example 8 with IPerspectiveDescriptor

use of org.eclipse.ui.IPerspectiveDescriptor in project tesb-studio-se by Talend.

the class CreateESBAction method selectRootObject.

private 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 (!IBrandingConfiguration.PERSPECTIVE_DI_ID.equals(currentPerspective.getId())) {
        // show Integration perspective
        try {
            workbenchWindow.getWorkbench().showPerspective(IBrandingConfiguration.PERSPECTIVE_DI_ID, workbenchWindow);
            workbenchPage = workbenchWindow.getActivePage();
        } catch (WorkbenchException e) {
            ExceptionHandler.process(e);
            return;
        }
    }
    IRepositoryView view = RepositoryManagerHelper.getRepositoryView();
    if (view != null) {
        Object type = params.get("type");
        if (ESBRepositoryNodeType.SERVICES.name().equals(type)) {
            RepositoryNode servicesNode = ((ProjectRepositoryNode) view.getRoot()).getRootRepositoryNode(ESBRepositoryNodeType.SERVICES);
            if (servicesNode != null) {
                setWorkbenchPart(view);
                final StructuredViewer viewer = view.getViewer();
                if (viewer instanceof TreeViewer) {
                    ((TreeViewer) viewer).expandToLevel(servicesNode, 1);
                }
                viewer.setSelection(new StructuredSelection(servicesNode));
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) 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) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 9 with IPerspectiveDescriptor

use of org.eclipse.ui.IPerspectiveDescriptor in project tdi-studio-se by Talend.

the class BootTalendAction method run.

public void run(IAction action) {
    IWorkbench workbench = PlatformUI.getWorkbench();
    if (store.getInt(LOGIN_COUNTER) > 1) {
        boolean openConfirm = MessageDialog.openConfirm(Display.getDefault().getActiveShell(), "Confirm", "Are you want to switch to another project");
        if (!openConfirm) {
            return;
        }
    // workbench.restart();
    }
    int counter = store.getInt(LOGIN_COUNTER);
    store.setValue(LOGIN_COUNTER, ++counter);
    IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
    if (activeWorkbenchWindow == null) {
        return;
    }
    IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
    if (activePage == null) {
        return;
    }
    IPerspectiveDescriptor pDescriptor = activePage.getPerspective();
    if (!pDescriptor.getId().equals(TALEND_PERSPECTIVE_ID)) {
        pDescriptor = getPerspective(TALEND_PERSPECTIVE_ID);
        activePage.setPerspective(pDescriptor);
    }
    SwitchProjectAction switchAction = new SwitchProjectAction();
    switchAction.run();
    return;
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor)

Example 10 with IPerspectiveDescriptor

use of org.eclipse.ui.IPerspectiveDescriptor in project bndtools by bndtools.

the class ImportBndWorkspaceWizard method performFinish.

@Override
public boolean performFinish() {
    final ImportSettings importSettings = new ImportSettings(mainPage.getSelectedFolder(), mainPage.isDeleteSettings(), mainPage.isInferExecutionEnvironment());
    // create the new project operation
    final WorkspaceModifyOperation op = new WorkspaceModifyOperation() {

        @Override
        protected void execute(IProgressMonitor monitor) throws CoreException {
            try {
                importProjects(importSettings, monitor);
            } catch (Exception e) {
                throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, "Error during import of Bnd workspace!", e));
            }
        }
    };
    Job importJob = new Job("Import Bnd Workspace") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                op.run(monitor);
            } catch (InvocationTargetException e) {
                Throwable t = e.getCause();
                if (t instanceof CoreException && ((CoreException) t).getStatus().getException() != null) {
                    // unwrap the cause of the CoreException
                    t = ((CoreException) t).getStatus().getException();
                }
                return new Status(Status.ERROR, Plugin.PLUGIN_ID, "Could not finish import job for Bnd Workspace!", t);
            } catch (InterruptedException e) {
                return Status.CANCEL_STATUS;
            }
            return Status.OK_STATUS;
        }
    };
    importJob.schedule();
    try {
        // Prompt to switch to the BndTools perspective
        IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
        IPerspectiveDescriptor currentPerspective = window.getActivePage().getPerspective();
        if (!"bndtools.perspective".equals(currentPerspective.getId())) {
            if (MessageDialog.openQuestion(getShell(), "Bndtools Perspective", "Switch to the Bndtools perspective?")) {
                this.workbench.showPerspective("bndtools.perspective", window);
            }
        }
    } catch (WorkbenchException e) {
        error("Unable to switch to BndTools perspective", e);
    }
    return true;
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) WorkbenchException(org.eclipse.ui.WorkbenchException) WorkbenchException(org.eclipse.ui.WorkbenchException) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) JavaModelException(org.eclipse.jdt.core.JavaModelException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) Job(org.eclipse.core.runtime.jobs.Job)

Aggregations

IPerspectiveDescriptor (org.eclipse.ui.IPerspectiveDescriptor)10 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)10 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)7 WorkbenchException (org.eclipse.ui.WorkbenchException)7 IRepositoryView (org.talend.repository.ui.views.IRepositoryView)5 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 CoreException (org.eclipse.core.runtime.CoreException)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)3 TreeViewer (org.eclipse.jface.viewers.TreeViewer)3 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 IRepositoryNode (org.talend.repository.model.IRepositoryNode)2 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1