Search in sources :

Example 16 with WorkbenchException

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

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

use of org.eclipse.ui.WorkbenchException in project eclipse.platform.text by eclipse.

the class SearchViewManager method activateSearchView.

public ISearchResultViewPart activateSearchView(boolean avoidPinnedViews, boolean openInNew) {
    IWorkbenchPage activePage = SearchPlugin.getActivePage();
    String defaultPerspectiveId = NewSearchUI.getDefaultPerspectiveId();
    if (defaultPerspectiveId != null) {
        IWorkbenchWindow window = activePage.getWorkbenchWindow();
        if (window != null && window.getShell() != null && !window.getShell().isDisposed()) {
            try {
                activePage = PlatformUI.getWorkbench().showPerspective(defaultPerspectiveId, window);
            } catch (WorkbenchException ex) {
            // show view in current perspective
            }
        }
    }
    if (activePage != null) {
        try {
            ISearchResultViewPart viewPart = null;
            if (!openInNew) {
                viewPart = findLRUSearchResultView(activePage, avoidPinnedViews);
            }
            String secondaryId = null;
            if (viewPart == null) {
                if (activePage.findViewReference(NewSearchUI.SEARCH_VIEW_ID) != null)
                    // avoid a secondary ID because of bug 125315
                    secondaryId = String.valueOf(++fViewCount);
            } else if (!SearchPreferencePage.isViewBroughtToFront())
                return viewPart;
            else
                secondaryId = viewPart.getViewSite().getSecondaryId();
            return (ISearchResultViewPart) activePage.showView(NewSearchUI.SEARCH_VIEW_ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
        } catch (PartInitException ex) {
            ExceptionHandler.handle(ex, SearchMessages.Search_Error_openResultView_title, SearchMessages.Search_Error_openResultView_message);
        }
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ISearchResultViewPart(org.eclipse.search.ui.ISearchResultViewPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) WorkbenchException(org.eclipse.ui.WorkbenchException)

Example 19 with WorkbenchException

use of org.eclipse.ui.WorkbenchException in project linuxtools by eclipse.

the class CloseWelcomePageRule method before.

@Override
protected void before() {
    Display.getDefault().syncExec(() -> {
        final IWorkbench workbench = PlatformUI.getWorkbench();
        if (workbench.getIntroManager().getIntro() != null) {
            workbench.getIntroManager().closeIntro(workbench.getIntroManager().getIntro());
        }
        try {
            workbench.showPerspective(defaultPerspectiveId, workbench.getActiveWorkbenchWindow());
        } catch (WorkbenchException e) {
            e.printStackTrace();
        }
    });
    // $NON-NLS-1$
    final String PREF_ENABLE_LAUNCHBAR = "enableLaunchBar";
    // $NON-NLS-1$
    final String PREF_ENABLE_TARGETSELECTOR = "enableTargetSelector";
    // $NON-NLS-1$
    final String PREF_ENABLE_BUILDBUTTON = "enableBuildButton";
    Display.getDefault().asyncExec(() -> {
        final IPreferenceStore store = org.eclipse.launchbar.ui.controls.internal.Activator.getDefault().getPreferenceStore();
        store.setValue(PREF_ENABLE_LAUNCHBAR, false);
        store.setValue(PREF_ENABLE_TARGETSELECTOR, false);
        store.setValue(PREF_ENABLE_BUILDBUTTON, false);
    });
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) WorkbenchException(org.eclipse.ui.WorkbenchException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 20 with WorkbenchException

use of org.eclipse.ui.WorkbenchException in project linuxtools by eclipse.

the class ImportDataSetHandler method execute.

/**
 * Import a data set from the specified path.
 * @param path The path of the data set to import.
 */
public void execute(String path) {
    IFilteredDataSet dataset = null;
    File file = new File(path);
    try (InputStreamReader fr = new InputStreamReader(new FileInputStream(file), Charset.defaultCharset());
        BufferedReader br = new BufferedReader(fr)) {
        String id = br.readLine();
        // $NON-NLS-1$
        String[] titles = br.readLine().split(", ");
        if (id == null && titles == null) {
            throw new IOException();
        } else if (id.equals(RowDataSet.ID)) {
            dataset = new FilteredRowDataSet(titles);
        } else if (id.equals(TableDataSet.ID)) {
            dataset = new FilteredTableDataSet(titles);
        } else {
            throw new IOException();
        }
        dataset.readFromFile(file);
        String title = path.substring(path.lastIndexOf('/') + 1);
        IWorkbenchPage p = PlatformUI.getWorkbench().showPerspective(IDEPerspective.ID, PlatformUI.getWorkbench().getActiveWorkbenchWindow());
        GraphSelectorEditor ivp = (GraphSelectorEditor) p.openEditor(new GraphSelectorEditorInput(title), GraphSelectorEditor.ID);
        ivp.createScriptSets(path, Arrays.asList(title), Arrays.asList(dataset));
    } catch (FileNotFoundException fnfe) {
        ExceptionErrorDialog.openError(Messages.ImportDataSetAction_FileNotFound, fnfe);
    } catch (IOException ioe) {
        ExceptionErrorDialog.openError(Messages.ImportDataSetAction_FileInvalid, ioe);
    } catch (WorkbenchException we) {
        ExceptionErrorDialog.openError(Messages.RunScriptChartHandler_couldNotSwitchToGraphicPerspective, we);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) GraphSelectorEditor(org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditor) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) WorkbenchException(org.eclipse.ui.WorkbenchException) IFilteredDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IFilteredDataSet) FileInputStream(java.io.FileInputStream) FilteredRowDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.FilteredRowDataSet) GraphSelectorEditorInput(org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditorInput) BufferedReader(java.io.BufferedReader) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) FilteredTableDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.table.FilteredTableDataSet) File(java.io.File)

Aggregations

WorkbenchException (org.eclipse.ui.WorkbenchException)37 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)16 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)15 IPerspectiveDescriptor (org.eclipse.ui.IPerspectiveDescriptor)11 IMemento (org.eclipse.ui.IMemento)7 IOException (java.io.IOException)6 IWorkbench (org.eclipse.ui.IWorkbench)5 IRepositoryView (org.talend.repository.ui.views.IRepositoryView)5 StringReader (java.io.StringReader)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)4 CoreException (org.eclipse.core.runtime.CoreException)3 IStatus (org.eclipse.core.runtime.IStatus)3 Status (org.eclipse.core.runtime.Status)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 ProcessExplorerView (com.centurylink.mdw.plugin.designer.views.ProcessExplorerView)2 BufferedReader (java.io.BufferedReader)2