本文整理汇总了Java中org.eclipse.jdt.internal.ui.javaeditor.EditorUtility类的典型用法代码示例。如果您正苦于以下问题:Java EditorUtility类的具体用法?Java EditorUtility怎么用?Java EditorUtility使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EditorUtility类属于org.eclipse.jdt.internal.ui.javaeditor包,在下文中一共展示了EditorUtility类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: gotoBookmark
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入依赖的package包/类
@Override
public boolean gotoBookmark(IWorkbenchWindow window, Bookmark bookmark, IBookmarkLocation bookmarkLocation) {
if (!(bookmarkLocation instanceof JavaMarkerBookmarkLocation)) {
return false;
}
JavaMarkerBookmarkLocation javaMarkerBookmarkLocation = (JavaMarkerBookmarkLocation) bookmarkLocation;
IJavaElement javaElement = JavaCore.create(javaMarkerBookmarkLocation.getHandle());
if (javaElement == null) {
return false;
}
IEditorInput editorInput = EditorUtility.getEditorInput(javaElement);
if (editorInput == null) {
return false;
}
String editorId = getEditorId(editorInput);
if (editorId == null) {
return false;
}
try {
IEditorPart editorPart = IDE.openEditor(window.getActivePage(), editorInput, editorId);
if (editorPart == null) {
return false;
}
IDE.gotoMarker(editorPart, javaMarkerBookmarkLocation.getMarker());
return true;
} catch (PartInitException e) {
return false;
}
}
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:30,代码来源:GotoJavaBookmarkMarker.java
示例17: getASTNode
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入依赖的package包/类
public static ASTNode getASTNode(int offset, int length, IEditorPart part) {
IJavaElement activeEditorJavaInput = null;
if (part != null) {
IEditorInput editorInput = part.getEditorInput();
if (editorInput != null) {
activeEditorJavaInput = JavaUI
.getEditorInputJavaElement(editorInput);
}
} else {
activeEditorJavaInput = EditorUtility.getActiveEditorJavaInput();
part = getActivePart();
}
if (activeEditorJavaInput != null
&& activeEditorJavaInput.getElementType() == IJavaElement.COMPILATION_UNIT) {
ICompilationUnit compilationUnit = (ICompilationUnit) activeEditorJavaInput;
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(compilationUnit);
parser.setResolveBindings(true);
ASTNode root = parser.createAST(null);
ASTNode node = NodeFinder.perform(root, offset, length);
return node;
}
return null;
}
开发者ID:aroog,项目名称:code,代码行数:29,代码来源:ASTUtils.java
示例18: getOpenJavaEditors
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入依赖的package包/类
public static IEditorReference[] getOpenJavaEditors(IProject project) {
List<IEditorReference> projectOpenJavaEditors = new ArrayList<IEditorReference>();
try {
IWorkbenchPage page = JavaPlugin.getActivePage();
if (page != null) {
// Iterate through all the open editors
IEditorReference[] openEditors = page.getEditorReferences();
for (IEditorReference openEditor : openEditors) {
IEditorPart editor = openEditor.getEditor(false);
// Only look for Java Editor and subclasses
if (editor instanceof CompilationUnitEditor) {
IEditorInput input = openEditor.getEditorInput();
IJavaProject inputProject = EditorUtility.getJavaProject(input);
// See if the editor is editing a file in this project
if (inputProject != null && inputProject.getProject().equals(project)) {
projectOpenJavaEditors.add(openEditor);
}
}
}
}
} catch (PartInitException e) {
GWTPluginLog.logError(e);
}
return projectOpenJavaEditors.toArray(new IEditorReference[0]);
}
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:29,代码来源:GWTProjectPropertyPage.java
示例19: doSetInput
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入依赖的package包/类
@Override
protected void doSetInput(IEditorInput input) throws CoreException {
IJavaProject javaProject = EditorUtility.getJavaProject(input);
if (javaProject != null && GWTNature.isGWTProject(javaProject.getProject())) {
// Use GWT partitioning if the compilation unit is in a GWT project
inputPartitioning = GWTPartitions.GWT_PARTITIONING;
} else {
// Otherwise, use Java partitioning to emulate the Java editor
inputPartitioning = IJavaPartitions.JAVA_PARTITIONING;
}
super.doSetInput(input);
}
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:15,代码来源:GWTJavaEditor.java
示例20: 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
注:本文中的org.eclipse.jdt.internal.ui.javaeditor.EditorUtility类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论