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


Java EditorUtility类代码示例

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


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

示例1: getMethodDeclaration

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入依赖的package包/类
public static MethodDeclaration getMethodDeclaration(String methodName) {
	IJavaElement javaElem = EditorUtility.getActiveEditorJavaInput();
	if (javaElem.getElementType() == IJavaElement.COMPILATION_UNIT) {
		ICompilationUnit iCompUnit = (ICompilationUnit) javaElem;
		ASTNode astNode = Crystal.getInstance()
				.getASTNodeFromCompilationUnit(iCompUnit);
		if (astNode != null
				&& astNode.getNodeType() == ASTNode.COMPILATION_UNIT) {
			CompilationUnit compUnit = (CompilationUnit) astNode;
			for (Object declaration : compUnit.types()) {
				if (declaration instanceof TypeDeclaration) {
					for (MethodDeclaration method : ((TypeDeclaration) declaration)
							.getMethods()) {
						if (methodName.contentEquals(method.getName()
								.getFullyQualifiedName())) {
							return method;
						}
					}
				}
			}
		}
	}
	return null;
}
 
开发者ID:aroog,项目名称:code,代码行数:25,代码来源:ASTUtils.java

示例2: getTypeOfOpenJavaEditor

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入依赖的package包/类
public static IType getTypeOfOpenJavaEditor() {
	IJavaElement activeEditorJavaInput = EditorUtility.getActiveEditorJavaInput();
	if (activeEditorJavaInput != null) {
		if (activeEditorJavaInput.getElementType() == IJavaElement.COMPILATION_UNIT) {
			try {
				ICompilationUnit iCompilationUnit = (ICompilationUnit) activeEditorJavaInput;
				String elementName = iCompilationUnit.getElementName();
				elementName = elementName.substring(0,
						elementName.lastIndexOf('.'));
				IType[] types = iCompilationUnit.getTypes();
				for (IType type : types) {
					String fullyQualifiedName = type
							.getFullyQualifiedName();
					if (fullyQualifiedName.contains(elementName)) {
						return type;
					}
				}
			} catch (JavaModelException e1) {
				e1.printStackTrace();
			}
		}
	} else {
		System.err.println("Java Editor is not open");
	}
	return null;
}
 
开发者ID:aroog,项目名称:code,代码行数:27,代码来源:ASTUtils.java

示例3: 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

示例4: 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

示例5: run

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入依赖的package包/类
@Override
public void run(IMarker marker) {
  try {
    IEditorPart part = EditorUtility.isOpenInEditor(cu);
    if (part == null) {
      part = JavaUI.openInEditor(cu, true, false);
      if (part instanceof ITextEditor) {
        ((ITextEditor) part).selectAndReveal(offset, length);
      }
    }
    if (part != null) {
      IEditorInput input = part.getEditorInput();
      IDocument doc = JavaPlugin.getDefault().getCompilationUnitDocumentProvider().getDocument(
          input);
      proposal.apply(doc);
    }
  } catch (CoreException e) {
    CorePluginLog.logError(e);
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:21,代码来源:QuickFixCompletionProposalWrapper.java

示例6: run

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入依赖的package包/类
@Override
public void run(IStructuredSelection selection) {
	IMember[] members= getSelectedMembers(selection);
	if (members == null || members.length == 0) {
		return;
	}

	try {
		ICompilationUnit cu= members[0].getCompilationUnit();
		if (!ActionUtil.isEditable(getShell(), cu)) {
			return;
		}

		// open the editor, forces the creation of a working copy
		IEditorPart editor= JavaUI.openInEditor(cu);

		if (ElementValidator.check(members, getShell(), getDialogTitle(), false))
			run(members);
		JavaModelUtil.reconcile(cu);
		EditorUtility.revealInEditor(editor, members[0]);

	} catch (CoreException e) {
		ExceptionHandler.handle(e, getShell(), getDialogTitle(), ActionMessages.AddJavaDocStubsAction_error_actionFailed);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:AddJavaDocStubAction.java

示例7: init

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入依赖的package包/类
public void init(IWorkbench workbench, IStructuredSelection structuredSelection) {
	IWorkbenchWindow window= workbench.getActiveWorkbenchWindow();
	List<?> selected= Collections.EMPTY_LIST;
	if (window != null) {
		ISelection selection= window.getSelectionService().getSelection();
		if (selection instanceof IStructuredSelection) {
			selected= ((IStructuredSelection) selection).toList();
		} else {
			IJavaElement element= EditorUtility.getActiveEditorJavaInput();
			if (element != null) {
				selected= Arrays.asList(element);
			}
		}
	}
	fStore= new JavadocOptionsManager(fXmlJavadocFile, getDialogSettings(), selected);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:JavadocWizard.java

示例8: 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

示例9: revealElementInEditor

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入依赖的package包/类
private void revealElementInEditor(Object elem, StructuredViewer originViewer) {
	// only allow revealing when the type hierarchy is the active page
	// no revealing after selection events due to model changes

	if (getSite().getPage().getActivePart() != this) {
		return;
	}

	if (fSelectionProviderMediator.getViewerInFocus() != originViewer) {
		return;
	}

	IEditorPart editorPart= EditorUtility.isOpenInEditor(elem);
	if (editorPart != null && (elem instanceof IJavaElement)) {
		getSite().getPage().removePartListener(fPartListener);
		getSite().getPage().bringToTop(editorPart);
		EditorUtility.revealInEditor(editorPart, (IJavaElement) elem);
		getSite().getPage().addPartListener(fPartListener);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:TypeHierarchyViewPart.java

示例10: computeStateMask

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入依赖的package包/类
/**
 * Computes the state mask for the given modifier string.
 *
 * @param modifiers	the string with the modifiers, separated by '+', '-', ';', ',' or '.'
 * @return the state mask or -1 if the input is invalid
 */
public static int computeStateMask(String modifiers) {
	if (modifiers == null)
		return -1;

	if (modifiers.length() == 0)
		return SWT.NONE;

	int stateMask= 0;
	StringTokenizer modifierTokenizer= new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
	while (modifierTokenizer.hasMoreTokens()) {
		int modifier= EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
		if (modifier == 0 || (stateMask & modifier) == modifier)
			return -1;
		stateMask= stateMask | modifier;
	}
	return stateMask;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:JavaEditorTextHoverDescriptor.java

示例11: run

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入依赖的package包/类
public void run(IMarker marker) {
	try {
		IEditorPart part= EditorUtility.isOpenInEditor(fCompilationUnit);
		if (part == null) {
			part= JavaUI.openInEditor(fCompilationUnit, true, false);
			if (part instanceof ITextEditor) {
				((ITextEditor) part).selectAndReveal(fOffset, fLength);
			}
		}
		if (part != null) {
			IEditorInput input= part.getEditorInput();
			IDocument doc= JavaPlugin.getDefault().getCompilationUnitDocumentProvider().getDocument(input);
			fProposal.apply(doc);
		}
	} catch (CoreException e) {
		JavaPlugin.log(e);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:CorrectionMarkerResolutionGenerator.java

示例12: getProjectPath

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入依赖的package包/类
private String getProjectPath(IStructuredSelection selection) {
	Object selectedElement= null;
	if (selection == null || selection.isEmpty()) {
		selectedElement= EditorUtility.getActiveEditorJavaInput();
	} else if (selection.size() == 1) {
		selectedElement= selection.getFirstElement();
	}

	if (selectedElement instanceof IResource) {
		IProject proj= ((IResource)selectedElement).getProject();
		if (proj != null) {
			return proj.getFullPath().makeRelative().toString();
		}
	} else if (selectedElement instanceof IJavaElement) {
		IJavaProject jproject= ((IJavaElement)selectedElement).getJavaProject();
		if (jproject != null) {
			return jproject.getProject().getFullPath().makeRelative().toString();
		}
	}

	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:NewSourceFolderWizardPage.java

示例13: execute

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    Shell shell = HandlerUtil.getActiveShell(event);
    ISelection sel = HandlerUtil.getActiveMenuSelection(event);
    ICompilationUnit cu = null;
    if (sel instanceof IStructuredSelection) {
        IStructuredSelection selection = (IStructuredSelection) sel;
        Object el = selection.getFirstElement();
        if (el instanceof ICompilationUnit)
            cu = (ICompilationUnit) el;
    } else if (HandlerUtil.getActivePartId(event).equals("org.eclipse.jdt.ui.CompilationUnitEditor")) {
        IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
        cu = (ICompilationUnit) EditorUtility.getEditorInputJavaElement(editor, false);
    }
    if (cu != null) {
        doRename(shell, cu);
    } else {
        MessageDialog.openInformation(shell, "Info", "Please select a Java source file");
    }
    return null;
}
 
开发者ID:Flamefire,项目名称:ImportSmaliVarNames,代码行数:22,代码来源:RenameVariablesHandler.java

示例14: 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

示例15: 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


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