当前位置: 首页>>代码示例>>Java>>正文


Java EditorUtility.openInEditor方法代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor方法的典型用法代码示例。如果您正苦于以下问题:Java EditorUtility.openInEditor方法的具体用法?Java EditorUtility.openInEditor怎么用?Java EditorUtility.openInEditor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.internal.ui.javaeditor.EditorUtility的用法示例。


在下文中一共展示了EditorUtility.openInEditor方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: selectInEditor

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
public static void selectInEditor(ASTNode node) {
	if(TraceToCodeUIAction.highlightCode){
		IJavaElement javaElement = getIJavaElement(node);
		if (javaElement != null) {
			try {

				EditorUtility.openInEditor(javaElement);
				IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
				if (part instanceof ITextEditor) {
					((ITextEditor) part).selectAndReveal(node.getStartPosition(), node.getLength());
				}
			} catch (PartInitException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}
 
开发者ID:aroog,项目名称:code,代码行数:19,代码来源:TraceUtility.java

示例2: highlightInEditor

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
public static void highlightInEditor(ASTNode enclosingDeclaration , ASTNode expressionNode){
	if(TraceToCodeUIAction.highlightCode){
		IJavaElement javaElement = getIJavaElement(enclosingDeclaration);
		if (javaElement != null) {
			try {

				EditorUtility.openInEditor(javaElement);
				IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
				if (part instanceof ITextEditor) {
					((ITextEditor) part).selectAndReveal(expressionNode.getStartPosition(), expressionNode.getLength());
				
				}
			} catch (PartInitException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}
 
开发者ID:aroog,项目名称:code,代码行数:20,代码来源:TraceUtility.java

示例3: open

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
private void open(KeyReference keyReference) {
	if (keyReference == null)
		return;

	try {
		IEditorPart part= keyReference.element != null ? EditorUtility.openInEditor(keyReference.element, true) : EditorUtility.openInEditor(keyReference.resource, true);
		if (part != null)
			EditorUtility.revealInEditor(part, keyReference.offset, keyReference.length);
	} catch (PartInitException x) {

		String message= null;

		IWorkbenchAdapter wbAdapter= (IWorkbenchAdapter)((IAdaptable)keyReference).getAdapter(IWorkbenchAdapter.class);
		if (wbAdapter != null)
			message= Messages.format(PropertiesFileEditorMessages.OpenAction_error_messageArgs,
					new String[] { wbAdapter.getLabel(keyReference), x.getLocalizedMessage() } );

		if (message == null)
			message= Messages.format(PropertiesFileEditorMessages.OpenAction_error_message, x.getLocalizedMessage());

		MessageDialog.openError(fShell,
			PropertiesFileEditorMessages.OpenAction_error_messageProblems,
			message);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:PropertyKeyHyperlink.java

示例4: open

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
private void open(KeyReference keyReference) {
	if (keyReference == null)
		return;

	try {
		IEditorPart part= EditorUtility.openInEditor(keyReference.storage, true);
		if (part != null)
			EditorUtility.revealInEditor(part, keyReference.offset, keyReference.length);
	} catch (PartInitException x) {

		String message= null;

		IWorkbenchAdapter wbAdapter= (IWorkbenchAdapter)((IAdaptable)keyReference).getAdapter(IWorkbenchAdapter.class);
		if (wbAdapter != null)
			message= Messages.format(PropertiesFileEditorMessages.OpenAction_error_messageArgs,
					new String[] { wbAdapter.getLabel(keyReference), x.getLocalizedMessage() } );

		if (message == null)
			message= Messages.format(PropertiesFileEditorMessages.OpenAction_error_message, x.getLocalizedMessage());

		MessageDialog.openError(fShell,
			PropertiesFileEditorMessages.OpenAction_error_messageProblems,
			message);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:26,代码来源:PropertyKeyHyperlink.java

示例5: openInEditor

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
private static void openInEditor(Object inputElement, final EditorCallback editorCallback)
{
    try
    {
        IEditorPart editorPart = EditorUtility.openInEditor(inputElement);
        
        if (editorCallback != null)
        {
            editorCallback.editorOpened(editorPart);
        }
    }
    catch (PartInitException e)
    {
        Activator.getDefault().logError("Unable to open editor", e);
    }
}
 
开发者ID:anjlab,项目名称:eclipse-tapestry5-plugin,代码行数:17,代码来源:EclipseUtils.java

示例6: run

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
@Override
public void run() {
	IPath path = new Path(exampleReportPath.concat(exampleReportName));
	IFile sampleFile =  ResourcesPlugin.getWorkspace().getRoot().getFile(path);
	if (sampleFile.exists()){
		try {
			EditorUtility.openInEditor(sampleFile, true);
		} catch (PartInitException e) {
			e.printStackTrace();
		}
	}  else {
		String message =  Messages.OpenReportHandler_warningmessage_text1.concat(exampleReportName).concat(Messages.OpenReportHandler_warningmessage_text2);
		MessageDialog.openWarning(PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages.OpenReportHandler_warningmessage_title,message);
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:16,代码来源:OpenReportHandler.java

示例7: showWithoutReuse

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
private IEditorPart showWithoutReuse(Object element) throws PartInitException {
	try {
		return EditorUtility.openInEditor(element, false);
	} catch (PartInitException e) {
		if (e.getStatus().getCode() != IJavaStatusConstants.EDITOR_NO_EDITOR_INPUT) {
			throw e;
		}
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:JavaSearchEditorOpener.java

示例8: openDeclaration

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
public static IEditorPart openDeclaration(IJavaElement element) throws PartInitException, JavaModelException {
	if (!(element instanceof IPackageFragment)) {
		return JavaUI.openInEditor(element);
	}
	
	IPackageFragment packageFragment= (IPackageFragment) element;
	ITypeRoot typeRoot;
	IPackageFragmentRoot root= (IPackageFragmentRoot) packageFragment.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
	if (root.getKind() == IPackageFragmentRoot.K_BINARY) {
		typeRoot= packageFragment.getClassFile(JavaModelUtil.PACKAGE_INFO_CLASS);
	} else {
		typeRoot= packageFragment.getCompilationUnit(JavaModelUtil.PACKAGE_INFO_JAVA);
	}

	// open the package-info file in editor if one exists
	if (typeRoot.exists())
		return JavaUI.openInEditor(typeRoot);

	// open the package.html file in editor if one exists
	Object[] nonJavaResources= packageFragment.getNonJavaResources();
	for (Object nonJavaResource : nonJavaResources) {
		if (nonJavaResource instanceof IFile) {
			IFile file= (IFile) nonJavaResource;
			if (file.exists() && JavaModelUtil.PACKAGE_HTML.equals(file.getName())) {
				return EditorUtility.openInEditor(file, true);
			}
		}
	}

	// select the package in the Package Explorer if there is no associated package Javadoc file
	PackageExplorerPart view= (PackageExplorerPart) JavaPlugin.getActivePage().showView(JavaUI.ID_PACKAGES);
	view.tryToReveal(packageFragment);
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:35,代码来源:JavadocHover.java

示例9: gotoSelectedElement

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
private void gotoSelectedElement() {
	Object selectedElement= getSelectedElement();
	if (selectedElement != null) {
		try {
			dispose();
			IEditorPart part= EditorUtility.openInEditor(selectedElement, true);
			if (part != null && selectedElement instanceof IJavaElement)
				EditorUtility.revealInEditor(part, (IJavaElement) selectedElement);
		} catch (CoreException ex) {
			JavaPlugin.log(ex);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:AbstractInformationControl.java

示例10: openInEditor

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
/**
 * Opens an editor on the given Java element in the active page. Valid elements are all Java elements that are {@link ISourceReference}.
	 * For elements inside a compilation unit or class file, the parent is opened in the editor is opened.
	 * If there already is an open Java editor for the given element, it is returned.
 *
 * @param element the input element; either a compilation unit
 *   (<code>ICompilationUnit</code>) or a class file (<code>IClassFile</code>) or source references inside.
 * @param activate if set, the editor will be activated.
 * @param reveal if set, the element will be revealed.
 * @return returns the editor part of the opened editor or <code>null</code> if the element is not a {@link ISourceReference} or the
 * file was opened in an external editor.
 * @exception PartInitException if the editor could not be initialized or no workbench page is active
 * @exception JavaModelException if this element does not exist or if an exception occurs while accessing its underlying resource
 * @since 3.3
 */
public static IEditorPart openInEditor(IJavaElement element, boolean activate, boolean reveal) throws JavaModelException, PartInitException {
	if (!(element instanceof ISourceReference)) {
		return null;
	}
	IEditorPart part= EditorUtility.openInEditor(element, activate);
	if (reveal && part != null) {
		EditorUtility.revealInEditor(part, element);
	}
	return part;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:JavaUI.java


注:本文中的org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。