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));
}
}
}
}
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;
}
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;
}
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);
});
}
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);
}
}
Aggregations