本文整理汇总了Java中org.eclipse.jdt.internal.core.JarPackageFragmentRoot类的典型用法代码示例。如果您正苦于以下问题:Java JarPackageFragmentRoot类的具体用法?Java JarPackageFragmentRoot怎么用?Java JarPackageFragmentRoot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JarPackageFragmentRoot类属于org.eclipse.jdt.internal.core包,在下文中一共展示了JarPackageFragmentRoot类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProjectCompilationUnits
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot; //导入依赖的package包/类
/**
* Returns all compilation units of a given project.
* @param javaProject Project to collect units
* @return List of org.eclipse.jdt.core.ICompilationUnit
*/
protected List getProjectCompilationUnits(IJavaProject javaProject) throws CoreException {
IPackageFragmentRoot[] fragmentRoots = javaProject.getPackageFragmentRoots();
int length = fragmentRoots.length;
List allUnits = new ArrayList();
for (int i = 0; i < length; i++) {
if (fragmentRoots[i] instanceof JarPackageFragmentRoot)
continue;
IJavaElement[] packages = fragmentRoots[i].getChildren();
for (int k = 0; k < packages.length; k++) {
IPackageFragment pack = (IPackageFragment) packages[k];
ICompilationUnit[] units = pack.getCompilationUnits();
for (int u = 0; u < units.length; u++) {
allUnits.add(units[u]);
}
}
}
return allUnits;
}
示例2: select
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot; //导入依赖的package包/类
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IJavaModel) {
return true;
} else if (element instanceof JarPackageFragmentRoot) {
return false;
} else if (element instanceof IJavaProject) {
return true;
} else if (element instanceof PackageFragmentRoot) {
return true;
} else if (element instanceof PackageFragment) {
PackageFragment packageFragment = (PackageFragment) element;
if (packageFragment.isDefaultPackage()) {
return false;
}
return true;
} else if (element instanceof ICompilationUnit) {
return true;
}
return false;
}
示例3: getPackages
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot; //导入依赖的package包/类
public static List<Object> getPackages(final IPackage paccage) {
final ILibrary library = paccage.getLibrary();
final List<Object> eclipseTypes = new ArrayList<>();
if (library instanceof IProject) {
final List<IJavaProject> eclipseProjects = getProjects((IProject) library);
try {
for (final IJavaProject javaProject : eclipseProjects) {
final IPackageFragmentRoot[] allPackageFragmentRoots = javaProject.getAllPackageFragmentRoots();
for (final IPackageFragmentRoot packageFragmentRoot : allPackageFragmentRoots) {
if (packageFragmentRoot instanceof JarPackageFragmentRoot) {
continue;
}
if (packageFragmentRoot instanceof ExternalPackageFragmentRoot) {
continue;
}
final IPackageFragment packageFragment = packageFragmentRoot.getPackageFragment(paccage.getName());
if (packageFragment.exists()) {
eclipseTypes.add(packageFragment);
}
}
}
} catch (final JavaModelException e) {
// nothing to do
}
}
return eclipseTypes;
}
示例4: getProjectDependecyJars
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot; //导入依赖的package包/类
public List<Jar> getProjectDependecyJars(IJavaProject project) throws JavaModelException {
List<Jar> jars = new ArrayList<>();
for (IPackageFragmentRoot fragmentRoot : project.getAllPackageFragmentRoots()) {
if (fragmentRoot instanceof JarPackageFragmentRoot) {
Jar jar = DtoFactory.getInstance().createDto(Jar.class);
jar.setId(fragmentRoot.hashCode());
jar.setName(fragmentRoot.getElementName());
jars.add(jar);
}
}
return jars;
}
示例5: getJarFile
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot; //导入依赖的package包/类
static private File getJarFile(IAdaptable adaptable) {
JarPackageFragmentRoot jpfr = (JarPackageFragmentRoot) adaptable;
File file = (File)jpfr.getPath().makeAbsolute().toFile();
if (!((File)file).exists()) {
File projectFile = new File(jpfr.getJavaProject().getProject().getLocation().toOSString());
file = new File(projectFile.getParent() + file.toString());
}
return file;
}
示例6: selectionChanged
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot; //导入依赖的package包/类
/**
* @see IActionDelegate#selectionChanged(IAction, ISelection)
* @param action
* action
* @param selection
* selection
*/
public void selectionChanged(IAction action, ISelection selection)
{
try {
IAdaptable adaptable = null;
this.selected = "unknown";
if (selection instanceof IStructuredSelection) {
adaptable = (IAdaptable) ((IStructuredSelection) selection).getFirstElement();
if (adaptable == null) {
return;
}
this.selectedClass = adaptable.getClass();
if (adaptable instanceof IResource) {
this.selected = (IResource) adaptable;
} else if (adaptable instanceof PackageFragment
&& ((PackageFragment) adaptable).getPackageFragmentRoot() instanceof JarPackageFragmentRoot) {
this.selected = getJarFile(((PackageFragment) adaptable)
.getPackageFragmentRoot());
} else if (adaptable instanceof JarPackageFragmentRoot) {
this.selected = getJarFile(adaptable);
} else {
this.selected = (IResource) adaptable.getAdapter(IResource.class);
}
}
} catch (Throwable e) {
EasyExploreActivator.log(e);
}
}
示例7: getJarFile
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot; //导入依赖的package包/类
/**
*
* 方法说明:继承方法
*
* @param adaptable
* adaptable
* @return file
*/
protected File getJarFile(IAdaptable adaptable)
{
JarPackageFragmentRoot jpfr = (JarPackageFragmentRoot) adaptable;
File selected = (File) jpfr.getPath().makeAbsolute().toFile();
if (!((File) selected).exists()) {
File projectFile = new File(jpfr.getJavaProject().getProject().getLocation()
.toOSString());
selected = new File(projectFile.getParent() + selected.toString());
}
return selected;
}
示例8: getResource
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot; //导入依赖的package包/类
static public Resource getResource(Object myObj) {
Object object = null;
// handle IEditorPart
if (myObj instanceof IEditorPart) {
IEditorPart editorPart = (IEditorPart)myObj;
IEditorInput input = editorPart.getEditorInput();
if (input instanceof IFileEditorInput) {
object = ((IFileEditorInput)input).getFile();
} else {
Object adapter = input.getAdapter(IFile.class);
if(adapter instanceof IFile){
object = (IFile) adapter;
} else {
adapter = editorPart.getAdapter(IFile.class);
if(adapter instanceof IFile){
object = (IFile) adapter;
} else {
object = input;
}
}
}
} else {
object = myObj;
}
// the most input types first
if (object instanceof Resource) {
return new Resource((Resource)object);
}
if (object instanceof IFile) {
return new Resource(((IFile) object));
}
if (object instanceof File) {
return new Resource((File) object);
}
// still adaptable
if (object instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable) object;
// IFile
IFile iFile = (IFile) adaptable.getAdapter(IFile.class);
if (iFile != null) {
return new Resource(iFile);
}
// IResource
IResource ires = (IResource) adaptable.getAdapter(IResource.class);
if (ires != null) {
IPath path = ires.getLocation();
if (path != null) {
return new Resource(ires);
}
}
// FileStoreEditorInput
if (adaptable instanceof FileStoreEditorInput) {
URI fileuri = ((FileStoreEditorInput) adaptable).getURI();
return new Resource(new File(fileuri.getPath()));
}
// optional org.eclipse.jdt.core
Bundle bundle = Platform.getBundle("org.eclipse.jdt.core");
if (bundle != null) {
if ( (adaptable instanceof PackageFragment) &&
( ((PackageFragment) adaptable).getPackageFragmentRoot() instanceof JarPackageFragmentRoot) ) {
return new Resource(getJarFile(((PackageFragment) adaptable)
.getPackageFragmentRoot()));
} else if (adaptable instanceof JarPackageFragmentRoot) {
return new Resource(getJarFile(adaptable));
}
}
// File
File file = (File) adaptable.getAdapter(File.class);
if (file != null) {
return new Resource(file);
}
}
return null;
}
示例9: getProjectOrJar
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot; //导入依赖的package包/类
public static IJavaElement getProjectOrJar(IJavaElement element) {
while (!(element instanceof IJavaProject) && !(element instanceof JarPackageFragmentRoot)) {
element = element.getParent();
}
return element;
}
示例10: getSourceClasses
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot; //导入依赖的package包/类
@Override
public Class<?>[] getSourceClasses() {
return new Class<?>[] { IJavaElement.class, JarPackageFragmentRoot.class };
}