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