• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IClassFileEditorInput类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createJavaProjectThroughActiveEditor

import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入依赖的package包/类
private IJavaProject createJavaProjectThroughActiveEditor() {
	
	IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	 	    if(page.getActiveEditor().getEditorInput() instanceof IFileEditorInput)
	 	    {	
	 		IFileEditorInput input = (IFileEditorInput) page.getActiveEditor().getEditorInput();
	 		IFile file = input.getFile();
	 		IProject activeProject = file.getProject();
	 		IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(activeProject.getName());
	 		return JavaCore.create(project);
	 	    }
	 	    else if(page.getActiveEditor().getEditorInput() instanceof IClassFileEditorInput)
	 	    {
	  IClassFileEditorInput classFileEditorInput=(InternalClassFileEditorInput)page.getActiveEditor().getEditorInput() ;
	  IClassFile classFile=classFileEditorInput.getClassFile();
	  return classFile.getJavaProject();
	 	    }
	 	    return null;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:20,代码来源:ValidatorUtility.java


示例2: setActiveEditor

import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入依赖的package包/类
@Override
public void setActiveEditor(IAction action, IEditorPart part) {
  if (part != null && part.getEditorInput() instanceof IClassFileEditorInput) {
    Set<IPackageFragmentRoot> queue = new LinkedHashSet<>();
    try {
      IClassFileEditorInput input = (IClassFileEditorInput) part.getEditorInput();
      IJavaElement element = input.getClassFile();
      while (element.getParent() != null) {
        element = element.getParent();
        if (element instanceof IPackageFragmentRoot) {
          IPackageFragmentRoot fragment = (IPackageFragmentRoot) element;
          if (canProcess(fragment)) {
            queue.add(fragment);
          }
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    findSources(queue);
  }
}
 
开发者ID:fbricon,项目名称:pde.source.lookup,代码行数:23,代码来源:DownloadSourcesActionDelegate.java


示例3: getProject

import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入依赖的package包/类
private IJavaProject getProject() {
	ITextEditor editor= getEditor();
	if (editor == null)
		return null;

	IJavaElement element= null;
	IEditorInput input= editor.getEditorInput();
	IDocumentProvider provider= editor.getDocumentProvider();
	if (provider instanceof ICompilationUnitDocumentProvider) {
		ICompilationUnitDocumentProvider cudp= (ICompilationUnitDocumentProvider) provider;
		element= cudp.getWorkingCopy(input);
	} else if (input instanceof IClassFileEditorInput) {
		IClassFileEditorInput cfei= (IClassFileEditorInput) input;
		element= cfei.getClassFile();
	}

	if (element == null)
		return null;

	return element.getJavaProject();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:JavaSourceViewerConfiguration.java


示例4: computeContainedMatches

import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入依赖的package包/类
public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
	//TODO same code in JavaSearchResult
	IEditorInput editorInput= editor.getEditorInput();
	if (editorInput instanceof IFileEditorInput)  {
		IFileEditorInput fileEditorInput= (IFileEditorInput) editorInput;
		return computeContainedMatches(result, fileEditorInput.getFile());

	} else if (editorInput instanceof IClassFileEditorInput) {
		IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) editorInput;
		IClassFile classFile= classFileEditorInput.getClassFile();

		Object[] elements= getElements();
		if (elements.length == 0)
			return NO_MATCHES;
		//all matches from same file:
		JavaElementLine jel= (JavaElementLine) elements[0];
		if (jel.getJavaElement().equals(classFile))
			return collectMatches(elements);
	}
	return NO_MATCHES;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:OccurrencesSearchResult.java


示例5: isShownInEditor

import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入依赖的package包/类
public boolean isShownInEditor(Match match, IEditorPart editor) {
	Object element= match.getElement();
	IJavaElement je= ((JavaElementLine) element).getJavaElement();
	IEditorInput editorInput= editor.getEditorInput();
	if (editorInput instanceof IFileEditorInput) {
		try {
			return ((IFileEditorInput)editorInput).getFile().equals(je.getCorrespondingResource());
		} catch (JavaModelException e) {
			return false;
		}
	} else if (editorInput instanceof IClassFileEditorInput) {
		return ((IClassFileEditorInput)editorInput).getClassFile().equals(je);
	}

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


示例6: getCurrentClassFile

import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入依赖的package包/类
public static IClassFile getCurrentClassFile(IWorkbenchWindow window) {
	IClassFile file = null;
	IEditorPart editor = window.getActivePage().getActiveEditor();
	if (editor != null) {
		IEditorInput input = editor.getEditorInput();
		if (input instanceof IClassFileEditorInput) {
			file = ((IClassFileEditorInput) input).getClassFile();
		}
	}
	return file;
}
 
开发者ID:aroog,项目名称:code,代码行数:12,代码来源:WorkspaceUtilities.java


示例7: computeContainedMatches

import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入依赖的package包/类
public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
	//TODO: copied from JavaSearchResult:
	IEditorInput editorInput= editor.getEditorInput();
	if (editorInput instanceof IFileEditorInput)  {
		IFileEditorInput fileEditorInput= (IFileEditorInput) editorInput;
		return computeContainedMatches(result, fileEditorInput.getFile());
	} else if (editorInput instanceof IClassFileEditorInput) {
		IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) editorInput;
		Set<Match> matches= new HashSet<Match>();
		collectMatches(matches, classFileEditorInput.getClassFile());
		return matches.toArray(new Match[matches.size()]);
	}
	return NO_MATCHES;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:NLSSearchResult.java


示例8: isShownInEditor

import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入依赖的package包/类
public boolean isShownInEditor(Match match, IEditorPart editor) {
	IEditorInput editorInput= editor.getEditorInput();
	if (match.getElement() instanceof FileEntry) {
		IFile file= ((FileEntry) match.getElement()).getPropertiesFile();
		if (editorInput instanceof IFileEditorInput) {
			return ((IFileEditorInput) editorInput).getFile().equals(file);
		}
	} else if (match.getElement() instanceof IJavaElement || match.getElement() instanceof CompilationUnitEntry) {
		IJavaElement je= null;
		if (match.getElement() instanceof IJavaElement) {
			je= (IJavaElement) match.getElement();
		} else {
			je= ((CompilationUnitEntry)match.getElement()).getCompilationUnit();
		}
		if (editorInput instanceof IFileEditorInput) {
			try {
				ICompilationUnit cu= (ICompilationUnit) je.getAncestor(IJavaElement.COMPILATION_UNIT);
				if (cu == null)
					return false;
				else
					return ((IFileEditorInput) editorInput).getFile().equals(cu.getCorrespondingResource());
			} catch (JavaModelException e) {
				return false;
			}
		} else if (editorInput instanceof IClassFileEditorInput) {
			return ((IClassFileEditorInput) editorInput).getClassFile().equals(je.getAncestor(IJavaElement.CLASS_FILE));
		}
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:31,代码来源:NLSSearchResult.java


示例9: getInput

import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入依赖的package包/类
private static IJavaElement getInput(JavaEditor editor) {
	if (editor == null)
		return null;
	IEditorInput input= editor.getEditorInput();
	if (input instanceof IClassFileEditorInput)
		return ((IClassFileEditorInput)input).getClassFile();
	IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
	return manager.getWorkingCopy(input);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:TextSelectionConverter.java


示例10: getJavaElement

import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入依赖的package包/类
private IJavaElement getJavaElement(Object element) {
	if (element instanceof IJavaElement)
		return (IJavaElement)element;
	if (element instanceof IClassFileEditorInput)
		return ((IClassFileEditorInput)element).getClassFile().getPrimaryElement();

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


示例11: computeScore

import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入依赖的package包/类
public int computeScore(String id, Object element) {
	if (!JavaSearchPage.EXTENSION_POINT_ID.equals(id))
		// Can't decide
		return ISearchPageScoreComputer.UNKNOWN;

	if (element instanceof IJavaElement || element instanceof IClassFileEditorInput || element instanceof LogicalPackage
			|| (element instanceof IEditorInput && JavaUI.getEditorInputJavaElement((IEditorInput)element) != null))
		return 90;

	return ISearchPageScoreComputer.LOWEST;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:JavaSearchPageScoreComputer.java


示例12: getTypes

import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入依赖的package包/类
private IType[] getTypes() throws JavaModelException {
	IEditorInput input= fEditor.getEditorInput();
	if (input instanceof IClassFileEditorInput) {
		return new IType[] { ((IClassFileEditorInput)input).getClassFile().getType() };
	} else {
		return JavaPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(input).getAllTypes();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:GoToNextPreviousMemberAction.java


示例13: getSourceReference

import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入依赖的package包/类
private ISourceReference getSourceReference() {
	IEditorInput input= fEditor.getEditorInput();
	if (input instanceof IClassFileEditorInput) {
		return ((IClassFileEditorInput)input).getClassFile();
	} else {
		return JavaPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(input);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:GoToNextPreviousMemberAction.java


示例14: getCodeAssist

import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入依赖的package包/类
protected ICodeAssist getCodeAssist() {
	if (fEditor != null) {
		IEditorInput input= fEditor.getEditorInput();
		if (input instanceof IClassFileEditorInput) {
			IClassFileEditorInput cfeInput= (IClassFileEditorInput) input;
			return cfeInput.getClassFile();
		}

		WorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
		return manager.getWorkingCopy(input, false);
	}

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


示例15: updateSelectionInActiveEditor

import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入依赖的package包/类
private void updateSelectionInActiveEditor(DeclarationReference reference, int offset, int length)
{
    IWorkbenchPage activePage = window.getActivePage();
    
    if (activePage != null)
    {
        IEditorPart activeEditor = activePage.getActiveEditor();
        
        if (activeEditor != null)
        {
            IEditorInput input = activeEditor.getEditorInput();
            
            if (input instanceof IClassFileEditorInput)
            {
                IClassFile classFile = ((IClassFileEditorInput) input).getClassFile();
                
                if (ObjectUtils.equals(classFile.getType(), EclipseUtils.findParentType(reference.getElement())))
                {
                    new SetEditorCaretPositionOffsetLength(offset, length).editorOpened(activeEditor);
                }
            }
            else if (input instanceof IFileEditorInput)
            {
                IFile file = ((IFileEditorInput) input).getFile();
                
                if (ObjectUtils.equals(file, reference.getElement().getResource()))
                {
                    new SetEditorCaretPositionOffsetLength(offset, length).editorOpened(activeEditor);
                }
            }
        }
    }
}
 
开发者ID:anjlab,项目名称:eclipse-tapestry5-plugin,代码行数:34,代码来源:TreeObjectSelectionListener.java


示例16: setSelectionFromEditor

import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入依赖的package包/类
private void setSelectionFromEditor(IWorkbenchPart part, ISelection selection) {
	if (part instanceof IEditorPart) {
		IJavaElement element= null;
		if (selection instanceof IStructuredSelection) {
			Object obj= getSingleElementFromSelection(selection);
			if (obj instanceof IJavaElement)
				element= (IJavaElement)obj;
		}
		IEditorInput ei;
		if (part instanceof AbstractMultiEditor)
			ei= ((AbstractMultiEditor)part).getActiveEditor().getEditorInput();
		else
			ei= ((IEditorPart)part).getEditorInput();
		if (selection instanceof ITextSelection) {
			int offset= ((ITextSelection)selection).getOffset();
			element= getElementAt(ei, offset);
		}
		if (element != null) {
			adjustInputAndSetSelection(element);
			return;
		}
		if (ei instanceof IFileEditorInput) {
			IFile file= ((IFileEditorInput)ei).getFile();
			IJavaElement je= (IJavaElement)file.getAdapter(IJavaElement.class);
			IContainer container= null;
			if (je == null) {
				container= ((IFileEditorInput)ei).getFile().getParent();
				if (container != null)
					je= (IJavaElement)container.getAdapter(IJavaElement.class);
			}
			if (je == null && container == null) {
				setSelection(null, false);
				return;
			}
			adjustInputAndSetSelection(je);
		} else if (ei instanceof IClassFileEditorInput) {
			IClassFile cf= ((IClassFileEditorInput)ei).getClassFile();
			adjustInputAndSetSelection(cf);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:42,代码来源:JavaBrowsingPart.java


示例17: getTapestryFileFromPage

import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入依赖的package包/类
public static TapestryFile getTapestryFileFromPage(IWorkbenchPage page)
{
    if (page == null)
    {
        return null;
    }
    
    IEditorPart activeEditor = page.getActiveEditor();
    
    if (activeEditor == null)
    {
        return null;
    }
    
    IEditorInput editorInput = activeEditor.getEditorInput();
    
    if (editorInput instanceof IFileEditorInput)
    {
        IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
        
        return Activator.getDefault()
                .getTapestryContextFactory()
                .createTapestryContext(fileEditorInput.getFile())
                .getInitialFile();
    }
    
    if (editorInput instanceof IStorageEditorInput)
    {
        try
        {
            IStorage storage = ((IStorageEditorInput) editorInput).getStorage();
            
            if (storage instanceof IJarEntryResource)
            {
                return Activator.getDefault()
                        .getTapestryContextFactory()
                        .createTapestryContext((IJarEntryResource) storage)
                        .getInitialFile();
            }
        }
        catch (CoreException e)
        {
            //  Ignore
            Activator.getDefault().logError("Error getting file from JAR", e);
        }
    }
    
    if (editorInput instanceof IClassFileEditorInput)
    {
        IClassFile classFile = ((IClassFileEditorInput) editorInput).getClassFile();
        
        if (classFile != null)
        {
            return Activator.getDefault()
                    .getTapestryContextFactory()
                    .createTapestryContext(classFile)
                    .getInitialFile();
        }
    }
    
    return null;
}
 
开发者ID:anjlab,项目名称:eclipse-tapestry5-plugin,代码行数:63,代码来源:TapestryUtils.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Setter类代码示例发布时间:2022-05-22
下一篇:
Java UnknownRowLockException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap