Java Code Examples for org.eclipse.ui.IWorkbenchPage#activate()

The following examples show how to use org.eclipse.ui.IWorkbenchPage#activate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LamiReportViewFactory.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Create all the views from a given report
 *
 * @param report
 *            The report to open
 * @throws PartInitException
 *             If there was a problem initializing a view
 */
public static synchronized void createNewView(LamiAnalysisReport report)
        throws PartInitException {
    currentReport = report;

    final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

    /*
     * Doing this in two operations here, instead of using
     * IWorkbenchPage.VIEW_ACTIVATE, works around a bug where the contextual
     * menu would get "stuck" until the Project view is defocused and
     * refocused.
     */
    page.showView(LamiReportView.VIEW_ID, String.valueOf(secondaryViewId), IWorkbenchPage.VIEW_VISIBLE);
    page.activate(page.findView(LamiReportView.VIEW_ID));

    secondaryViewId++;

    currentReport = null;
}
 
Example 2
Source File: BrowserEditorInstance.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void openURL(URL url) throws PartInitException {
	WebBrowserEditorInput editorInput = new WebBrowserEditorInput(url, style);
	editorInput.setName(name);
	editorInput.setToolTipText(tooltip);
	WebBrowserEditor editor = (WebBrowserEditor) part;
	IWorkbenchWindow workbenchWindow = WebBrowserUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow();
	IWorkbenchPage workbenchPage = null;
	if (workbenchWindow != null) {
		workbenchPage = workbenchWindow.getActivePage();
	}
	if (workbenchPage == null) {
		throw new PartInitException("Cannot get Workbench page"); //$NON-NLS-1$
	}
	if (editor != null) {
		editor.init(editor.getEditorSite(), editorInput);
		workbenchPage.activate(editor);
	} else {
		editor = (WebBrowserEditor) workbenchPage.openEditor(editorInput, WebBrowserEditor.EDITOR_ID);
		hookPart(workbenchPage, editor);
	}
}
 
Example 3
Source File: ReadCamelProcess.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
@Override
protected void doRun() {
    final IRepositoryNode node = (IRepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
    CamelProcessItem processItem = (CamelProcessItem) node.getObject().getProperty().getItem();

    IWorkbenchPage page = getActivePage();

    try {
        CamelProcessEditorInput fileEditorInput = new CamelProcessEditorInput(processItem, true, null, true);
        checkUnLoadedNodeForProcess(fileEditorInput);
        IEditorPart editorPart = page.findEditor(fileEditorInput);

        if (editorPart == null) {
            fileEditorInput.setRepositoryNode(node);
            page.openEditor(fileEditorInput, CamelMultiPageTalendEditor.ID, true);
        } else {
            page.activate(editorPart);
        }
    } catch (PartInitException | PersistenceException e) {
        MessageBoxExceptionHandler.process(e);
    }
}
 
Example 4
Source File: DynamicDatasetPluginTest.java    From dawnsci with Eclipse Public License 1.0 5 votes vote down vote up
private IWorkbenchPart openView() throws PartInitException {
	final IWorkbenchPage     page = TestUtils.getPage();		
	IViewPart part = page.showView("org.dawnsci.processing.ui.view.vanillaPlottingSystemView", null, IWorkbenchPage.VIEW_ACTIVATE);		
		page.activate(part);
		page.setPartState(page.getActivePartReference(), IWorkbenchPage.STATE_MAXIMIZED);
		return part;
}
 
Example 5
Source File: AddArticleToOrderHandler.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
	IWorkbenchPage activePage =
		HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
	// activate after BestellView usage, needed for selection provider
	IWorkbenchPart activePart = activePage.getActivePart();
	
	List<IArticle> articlesToOrder = getArticlesToOrder(
		HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection());
	if (articlesToOrder.isEmpty()) {
		log.debug("Skip handler execution as no articles are selected to add to an order!");
		return null;
	}
	
	// load BestellView and pass articles to order
	try {
		BestellView bestellView = (BestellView) activePage.showView(BestellView.ID);
		if (bestellView != null) {
			bestellView.addItemsToOrder(articlesToOrder);
		} else {
			log.error("Cant't load BestellView to add articles to order");
		}
		activePage.activate(activePart);
	} catch (PartInitException e) {
		log.error("Cant't load BestellView to add articles to order", e);
	}
	return null;
	
}
 
Example 6
Source File: BatchValidationHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void showReport(final BatchValidationOperation validateOperation) {
    if (statusContainsError(validateOperation.getResult())) {
        final String errorMessage = Messages.validationErrorFoundMessage + " "
                + currentDiagramStore.getDisplayName();
        final int result = new ValidationDialog(Display.getDefault().getActiveShell(), Messages.validationFailedTitle, errorMessage,
                ValidationDialog.OK_SEEDETAILS).open();

        if (result == ValidationDialog.SEE_DETAILS) {
            IWorkbenchPart openedEditor = currentDiagramStore.getOpenedEditor();
            if (openedEditor == null) {
                openedEditor = currentDiagramStore.open();
            }
            final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
            activePage.activate(openedEditor);

            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    try {
                        activePage.showView("org.bonitasoft.studio.validation.view");
                    } catch (final PartInitException e) {
                        BonitaStudioLog.error(e);
                    }
                }
            });
        }
    }

}
 
Example 7
Source File: RunProcessesValidationOperation.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static void showValidationPart() {
    final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    final IEditorPart part = activePage.getActiveEditor();
    if (part != null && part instanceof DiagramEditor) {
        final MainProcess proc = ModelHelper
                .getMainProcess(((DiagramEditor) part).getDiagramEditPart().resolveSemanticElement());
        final String partName = proc.getName() + " (" + proc.getVersion() + ")";
        for (final IEditorReference ref : activePage.getEditorReferences()) {
            if (partName.equals(ref.getPartName())) {
                activePage.activate(ref.getPart(true));
                break;
            }
        }

    }
    Display.getDefault().asyncExec(new Runnable() {

        @Override
        public void run() {
            try {
                activePage.showView("org.bonitasoft.studio.validation.view");
            } catch (final PartInitException e) {
                BonitaStudioLog.error(e);
            }
        }
    });
}
 
Example 8
Source File: GetStartedAction.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void run() {
	// Close the Eclipse welcome page
	IIntroManager manager = PlatformUI.getWorkbench().getIntroManager();
	IIntroPart introPart = manager.getIntro();
	if (introPart != null) {
		manager.closeIntro(introPart);
	}
	
	// Open the J2EE perspective
	try {
		IWorkbench workbench = PlatformUI.getWorkbench();
		workbench.showPerspective("org.eclipse.jst.j2ee.J2EEPerspective", workbench.getActiveWorkbenchWindow());
	} catch (Exception e) {
		Logger.logError("An error occurred trying to open the J2EE perspective", e);
	}

	// Open the Codewind welcome page
	IEditorPart part = OpenWelcomePageAction.openWelcomePage();

	// Open the Codewind Explorer view
	ViewHelper.openCodewindExplorerViewNoExec();

	// Make the welcome page the focus
	if (part != null) {
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		if (window != null) {
			IWorkbenchPage page = window.getActivePage();
			if (page != null) {
				page.activate(part);
			}
		}
	}
}
 
Example 9
Source File: NextEditorHandler.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private static void switchEditor(IWorkbenchPage activePage, boolean next)
{
	IEditorPart activeEditor = activePage.getActiveEditor();
	if (activeEditor != null)
	{
		IEditorReference[] editorReferences = activePage.getEditorReferences();
		if (editorReferences != null && editorReferences.length >= 2)
		{
			List<IEditorPart> editorsList = new LinkedList<IEditorPart>();
			for (IEditorReference editorReference : editorReferences)
			{
				IWorkbenchPart editorPart = editorReference.getPart(true);
				if (editorPart instanceof IEditorPart)
				{
					editorsList.add((IEditorPart) editorPart);
				}
			}
			int activeEditorIndex = editorsList.indexOf(activeEditor);
			int toEditorIndex = ((activeEditorIndex == -1) ? 0 : (activeEditorIndex + (next ? 1 : -1)));
			if (toEditorIndex < 0)
			{
				toEditorIndex = editorsList.size() - 1;
			}
			else if (toEditorIndex >= editorsList.size())
			{
				toEditorIndex = 0;
			}
			activePage.activate(editorsList.get(toEditorIndex));
		}
	}
}
 
Example 10
Source File: PerspectiveHelper.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
private static void applyActiveEditor(final IWorkbenchPage page) {
	if ( activeEditor == null ) { return; }
	final IEditorPart part = page.findEditor(activeEditor);
	if ( part != null ) {
		page.activate(part);
		// DEBUG.OUT("Applying memorized editor to " + page.getPerspective().getId() + " = " + activeEditor.getName());
		// page.bringToTop(part);
	}

}
 
Example 11
Source File: TmfViewFactory.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Create a new view. <br>
 * If a view with the corresponding id already exists and no suffix were
 * added the existing view will be given focus.
 *
 * @param viewId
 *            The id of the view to be created. <br>
 *            Format: primary_id[:secondary_id[&uuid]|:uuid]
 * @param generateSuffix
 *            Add or replace a generated suffix id (UUID). This allows
 *            multiple views with the same id to be displayed.
 * @return The view instance, or null if an error occurred.
 */
@NonNullByDefault
public static @Nullable IViewPart newView(String viewId, boolean generateSuffix) {
    IViewPart viewPart = null;
    String primaryId = null;
    String secondaryId = null;

    /* Parse the view id */
    int index = viewId.indexOf(TmfView.VIEW_ID_SEPARATOR);
    if (index != -1) {
        primaryId = viewId.substring(0, index);
        secondaryId = getBaseSecId(viewId.substring(index + 1));
    } else {
        primaryId = viewId;
    }

    if (generateSuffix) {
        if (secondaryId == null) {
            secondaryId = UUID.randomUUID().toString();
        } else {
            secondaryId += INTERNAL_SECONDARY_ID_SEPARATOR + UUID.randomUUID().toString();
        }
    }

    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
    IWorkbenchPage page = workbenchWindow.getActivePage();
    try {
        viewPart = page.showView(primaryId, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
        page.activate(viewPart);
    } catch (PartInitException e) {
        /* Simply return null on error */
    }

    return viewPart;
}
 
Example 12
Source File: TestResultsView.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the instance of this view in the active workbench page. Will open the view if not open already. Returns
 * <code>null</code> on error (e.g. not invoked from UI thread).
 *
 * @param activate
 *            if true, the view will be brought to the front.
 */
public static TestResultsView getInstance(boolean activate) {
	try {
		final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		final TestResultsView view = (TestResultsView) page.showView(ID);
		if (activate)
			page.activate(view);
		return view;
	} catch (Exception e) {
		return null;
	}
}
 
Example 13
Source File: MultiFilesOper.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
	 * 根据指定要合并打开的文件,获取其配置文件
	 * @param selectIFiles
	 * @param isActive	如果找到了符合的合并打开临时文件,是否激活当前nattable编辑器
	 * @return ;
	 */
	public IFile getMultiFilesTempIFile(boolean isActive){
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		IEditorReference[] editorRes = page.getEditorReferences();
		
		for (int i = 0; i < editorRes.length; i++) {
			if (editorRes[i].getId().equals(XLIFF_EDITOR_ID)) {
				try {
					IXliffEditor xlfEditor = (IXliffEditor) editorRes[i].getEditor(true);
					IFile multiTempFile = ((FileEditorInput) editorRes[i].getEditorInput()).getFile();
					List<File> openedFileList = xlfEditor.getMultiFileList();
					
					boolean isExist = false;
					if (selectIFiles.size() == openedFileList.size()) {
						isExist = true;
						for (IFile iFile : selectIFiles) {
							if (openedFileList.indexOf(iFile.getFullPath().toFile()) == -1) {
								continue;
							}
						}
					}
					
//					Map<String, Object> resultMap = handler.openFile(multiTempFile.getLocation().toOSString());
//					if (resultMap == null
//							|| Constant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) resultMap.get(Constant.RETURNVALUE_RESULT)) {
//						continue;
//					}
//					List<String> mergerFileList = handler.getMultiFiles(multiTempFile);
//					if (mergerFileList.size() == selectIFiles.size()) {
//						for (IFile iFile : selectIFiles) {
//							if (mergerFileList.indexOf(iFile.getLocation().toOSString()) < 0) {
//								continue;
//							}
//						}
//					}
					if (isActive) {
						page.activate(editorRes[i].getEditor(true));
					}
					if (isExist) {
						return multiTempFile;
					}
				} catch (PartInitException e) {
					e.printStackTrace();
				}
			}
		}
		return null;
	}
 
Example 14
Source File: MultiFilesOper.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
	 * 根据指定要合并打开的文件,获取其配置文件
	 * @param selectIFiles
	 * @param isActive	如果找到了符合的合并打开临时文件,是否激活当前nattable编辑器
	 * @return ;
	 */
	public IFile getMultiFilesTempIFile(boolean isActive){
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		IEditorReference[] editorRes = page.getEditorReferences();
		
		for (int i = 0; i < editorRes.length; i++) {
			if (editorRes[i].getId().equals(XLIFF_EDITOR_ID)) {
				try {
					IXliffEditor xlfEditor = (IXliffEditor) editorRes[i].getEditor(true);
					IFile multiTempFile = ((FileEditorInput) editorRes[i].getEditorInput()).getFile();
					List<File> openedFileList = xlfEditor.getMultiFileList();
					
					boolean isExist = false;
					if (selectIFiles.size() == openedFileList.size()) {
						isExist = true;
						for (IFile iFile : selectIFiles) {
							if (openedFileList.indexOf(iFile.getFullPath().toFile()) == -1) {
								continue;
							}
						}
					}
					
//					Map<String, Object> resultMap = handler.openFile(multiTempFile.getLocation().toOSString());
//					if (resultMap == null
//							|| Constant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) resultMap.get(Constant.RETURNVALUE_RESULT)) {
//						continue;
//					}
//					List<String> mergerFileList = handler.getMultiFiles(multiTempFile);
//					if (mergerFileList.size() == selectIFiles.size()) {
//						for (IFile iFile : selectIFiles) {
//							if (mergerFileList.indexOf(iFile.getLocation().toOSString()) < 0) {
//								continue;
//							}
//						}
//					}
					if (isActive) {
						page.activate(editorRes[i].getEditor(true));
					}
					if (isExist) {
						return multiTempFile;
					}
				} catch (PartInitException e) {
					e.printStackTrace();
				}
			}
		}
		return null;
	}
 
Example 15
Source File: SwitchToBufferHandler.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
private void activatePart(IWorkbenchPart part) {
	IWorkbenchPage page = getWorkbenchPage();
	page.bringToTop(part);
	page.activate(part);
	forceActivate();
}
 
Example 16
Source File: MarkGlobalHandler.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Get the next position off the global mark ring and move to that file and location
 *
 * @param editor
 * @param document
 * @param currentSelection
 * @param norotate - if true, pop else rotate and pop
 * @return NO_OFFSET
 * @throws BadLocationException
 */
protected int doTransform(ITextEditor editor, IDocument document, ITextSelection currentSelection, boolean norotate, boolean isTags)
throws BadLocationException {
	// get editor and offset
	IBufferLocation location = (isTags ? MarkUtils.popTagMark() : MarkUtils.popGlobalMark(norotate));
	if (location != null) {
		if (currentSelection != null &&
				location.getEditor() == editor && location.getOffset() == currentSelection.getOffset()) {
			// if we're already at the global mark location, move to next location
			// recurse with no selection to avoid infinite loop if only one global location
			return doTransform(editor,document,null,norotate, isTags);
		}
		ITextEditor jumpTo = location.getEditor();
		int offset = location.getOffset();
		IWorkbenchPage page = getWorkbenchPage();
		IEditorPart part = jumpTo;
		if (part != null) {
			// move to the correct page
			IEditorPart apart = part;
			IEditorSite esite = part.getEditorSite();
			if (esite instanceof MultiPageEditorSite) {
				apart = ((MultiPageEditorSite)esite).getMultiPageEditor();
				// handle multi page by activating the correct part within the parent
				if (apart instanceof MultiPageEditorPart) {
					((MultiPageEditorPart)apart).setActiveEditor(part);
				}
			}
			// check to make sure the editor is still valid
			if (page.findEditor(apart.getEditorInput()) != null)  {
				// then activate
				page.activate(apart);
				page.bringToTop(apart);
				if (part instanceof ITextEditor) {
					selectAndReveal((ITextEditor) part,offset,offset);
					EmacsPlusUtils.clearMessage(part);
				}
			} else {
				EmacsPlusUtils.showMessage(editor, String.format(BAD_MARK, apart.getTitle()), true);
			}
		}
	} else {
		beep();
	}
	return NO_OFFSET;
}
 
Example 17
Source File: RegisterJumpToHandler.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @see com.mulgasoft.emacsplus.minibuffer.IMinibufferExecutable#executeResult(org.eclipse.ui.texteditor.ITextEditor, java.lang.Object)
 */
public boolean doExecuteResult(ITextEditor editor, Object minibufferResult) {

	if (minibufferResult != null) {
		String key = (String)minibufferResult;
		IRegisterLocation location = TecoRegister.getInstance().getLocation(key);
		if (location != null) {
			IWorkbenchPage page = getWorkbenchPage();
			IEditorPart part = location.getEditor(); 
			int offset = location.getOffset();
			if (part != null) {
				// move to the correct page
				IEditorPart apart = part;
				IEditorSite esite = part.getEditorSite();
				if (esite instanceof MultiPageEditorSite) {
					apart = ((MultiPageEditorSite)esite).getMultiPageEditor();
					// handle multi page by activating the correct part within the parent
					if (apart instanceof MultiPageEditorPart) {
						((MultiPageEditorPart)apart).setActiveEditor(part);
					}
				}
				// now activate
				page.activate(apart);
				page.bringToTop(apart);
			} else {
				// restore the resource from the file system
				if (location.getPath() != null) {
					try {
						// loads and activates
						part = IDE.openEditor(page, location.getPath(), true);
						if (part instanceof IEditorPart) {
							if (part instanceof MultiPageEditorPart) {
								IEditorPart[] parts = ((MultiPageEditorPart)part).findEditors(part.getEditorInput());
								//  TODO this will only work on the first load of a multi page
								// There is no supported way to determine the correct sub part in this case
								// Investigate org.eclipse.ui.PageSwitcher (used in org.eclipse.ui.part.MultiPageEditorPart)
								// as a means for locating the correct sub page at this level
								for (int i = 0; i < parts.length; i++) {
									if (parts[i] instanceof ITextEditor) {
										((MultiPageEditorPart)part).setActiveEditor(parts[i]);
										part = parts[i];
										break;
									}
								}
							}
							location.setEditor((ITextEditor)part);
						}
					} catch (PartInitException e) {
						showResultMessage(editor, String.format(BAD_LOCATION,key + ' ' + e.getLocalizedMessage()), true);				
					}
				} else {
					showResultMessage(editor, String.format(NO_LOCATION,key), true);				
				}
			}
			if (part instanceof ITextEditor) {
				((ITextEditor) part).selectAndReveal(offset, 0);
				showResultMessage(editor, String.format(LOCATED, key), false);
			} else {
			
			}
		} else {
			showResultMessage(editor, NO_REGISTER, true);
		}
	}
	return true;
}
 
Example 18
Source File: EditorOpener.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
private IEditorPart showWithReuse(IFile file, IWorkbenchPage page, String editorId, boolean activate)
        throws PartInitException {
    IEditorInput input = new FileEditorInput(file);
    IEditorPart editor = page.findEditor(input);
    if (editor != null) {
        page.bringToTop(editor);
        if (activate) {
            page.activate(editor);
        }
        return editor;
    }
    IEditorReference reusedEditorRef = fReusedEditor;
    if (reusedEditorRef != null) {
        boolean isOpen = reusedEditorRef.getEditor(false) != null;
        boolean canBeReused = isOpen && !reusedEditorRef.isDirty() && !reusedEditorRef.isPinned();
        if (canBeReused) {
            boolean showsSameInputType = reusedEditorRef.getId().equals(editorId);
            if (!showsSameInputType) {
                page.closeEditors(new IEditorReference[] { reusedEditorRef }, false);
                fReusedEditor = null;
            } else {
                editor = reusedEditorRef.getEditor(true);
                if (editor instanceof IReusableEditor) {
                    ((IReusableEditor) editor).setInput(input);
                    page.bringToTop(editor);
                    if (activate) {
                        page.activate(editor);
                    }
                    return editor;
                }
            }
        }
    }
    editor = page.openEditor(input, editorId, activate);
    if (editor instanceof IReusableEditor) {
        IEditorReference reference = (IEditorReference) page.getReference(editor);
        fReusedEditor = reference;
    } else {
        fReusedEditor = null;
    }
    return editor;
}
 
Example 19
Source File: EditorOpener.java    From typescript.java with MIT License 4 votes vote down vote up
private IEditorPart showWithReuse(IFile file, IWorkbenchPage page, String editorId, boolean activate) throws PartInitException {
	IEditorInput input= new FileEditorInput(file);
	IEditorPart editor= page.findEditor(input);
	if (editor != null) {
		page.bringToTop(editor);
		if (activate) {
			page.activate(editor);
		}
		return editor;
	}
	IEditorReference reusedEditorRef= fReusedEditor;
	if (reusedEditorRef !=  null) {
		boolean isOpen= reusedEditorRef.getEditor(false) != null;
		boolean canBeReused= isOpen && !reusedEditorRef.isDirty() && !reusedEditorRef.isPinned();
		if (canBeReused) {
			boolean showsSameInputType= reusedEditorRef.getId().equals(editorId);
			if (!showsSameInputType) {
				page.closeEditors(new IEditorReference[] { reusedEditorRef }, false);
				fReusedEditor= null;
			} else {
				editor= reusedEditorRef.getEditor(true);
				if (editor instanceof IReusableEditor) {
					((IReusableEditor) editor).setInput(input);
					page.bringToTop(editor);
					if (activate) {
						page.activate(editor);
					}
					return editor;
				}
			}
		}
	}
	editor= page.openEditor(input, editorId, activate);
	if (editor instanceof IReusableEditor) {
		IEditorReference reference= (IEditorReference) page.getReference(editor);
		fReusedEditor= reference;
	} else {
		fReusedEditor= null;
	}
	return editor;
}
 
Example 20
Source File: Utilities.java    From jbt with Apache License 2.0 2 votes vote down vote up
/**
 * Activates an editor.
 * 
 * @param editor
 *            the editor to activate.
 */
public static void activateEditor(EditorPart editor) {
	IWorkbenchPage page = editor.getSite().getPage();
	page.activate(editor);
}