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


Java IPackageFragmentRoot类代码示例

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


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

示例1: ResourceContext

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入依赖的package包/类
/**
 * @param containerFullPath
 * @param packageFragmentRoot
 * @param targetPkg
 * @param selectedFilename
 * @param selectedFile
 * @param openEditor
 * @param ce
 * @throws CoreException
 */
public ResourceContext(
		IPath containerFullPath, 
		IPackageFragmentRoot packageFragmentRoot,
		IPackageFragment targetPkg,
		String selectedFilename, 
		String extendedClassname,
		IFile selectedFile,
		GENERATION_MODE mode,
		ClassExtension ce) throws CoreException {
	this.selectedFile=selectedFile;
	this.packageFragmentRoot = packageFragmentRoot;
	this.targetPkg  = targetPkg;
	this.interfaceName = selectedFile.getName().split("\\.")[0] + ".java";
	this.selectedFilename = selectedFilename;
	this.containerFullPath = containerFullPath;
	this.mode=mode;
	this.classExtension=ce;
	this.generateOnlyInterface = false;
	this.openEditor = false;
	this.erase = true;
	this.extendedClassname=extendedClassname; 
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:33,代码来源:ResourceContext.java

示例2: getIFileFromQualifiedName

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入依赖的package包/类
/**
 * @param project
 * @param qualifiedName
 * @return
 * @throws CoreException
 */
public static IFile getIFileFromQualifiedName(String projectname, String qualifiedName) throws CoreException {
	IProject project = getProject(projectname);
	IJavaProject jproject = JavaCore.create(project);
	IPackageFragment[] pkgs = jproject.getPackageFragments();
	String spath = qualifiedName.replace(".", "/");
	for (int i = 0; i < pkgs.length; i++) {
		if (pkgs[i].getKind() != IPackageFragmentRoot.K_SOURCE)
			continue;
		IPath path = pkgs[i].getPath().append(spath);
		IFile iFile = (IFile) ResourceManager.getResource(path.toString() + ".java");
		if (iFile != null && iFile.exists())
			return iFile;
	}
	return null;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:22,代码来源:ResourceManager.java

示例3: getSelectedPathInProject

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入依赖的package包/类
/**
 * Lets get the path of hat have been selected in the UI - the complete path
 * a path is something like "src/main/resources"
 * 
 * @param receiver
 * @return
 */
public static String getSelectedPathInProject(Object receiver) {
	if (!ResourceManager.isPackageFragmentRoot(receiver)) {
		return null;
	}
	IPackageFragmentRoot pkg = (IPackageFragmentRoot) receiver;

	IJavaProject javaProject = pkg.getJavaProject();
	if (javaProject == null)
		return null;

	IProject project = javaProject.getProject();

	if (!GW4ENature.hasGW4ENature(project))
		return null;

	String projectName = pkg.getJavaProject().getElementName();
	int pos = projectName.length();
	String input = pkg.getPath().toString().substring(pos + 2);
	return input;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:28,代码来源:ResourceManager.java

示例4: test

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入依赖的package包/类
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
	if ("isAuthorizedFolderForGraphDefinition".equals(property)) {
		// Only PackageFragmentRoot is allowed to enable the menu
		// Represents a set of package fragments, and maps the fragments to
		// an underlying resource which is either
		// a folder, JAR, or ZIP file. (Child of IJavaProject)
		// See JDT Plug-in Developer Guide > Programmer's Guide > JDT Core
		// for more information on Java Model
		if (!ResourceManager.isPackageFragmentRoot(receiver)) {
			return false;
		}
		// Lets get the path of hat have been selected in the UI - the
		// complete path
		// a path is something like "src/main/resources"
		String input = ResourceManager.getSelectedPathInProject(receiver);
		// Now we have it, check whether it is listed in the Preference
		boolean authorized = PreferenceManager.isAuthorizedFolderForGraphDefinition(((IPackageFragmentRoot)receiver).getJavaProject().getProject().getName(),input);
		// Sounds like we have an answer now !
		return authorized;
	}
	// Boo !
	return false;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:25,代码来源:AuthorizedFolderForGraphDefinition.java

示例5: assertHasSourceFolders

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入依赖的package包/类
public void assertHasSourceFolders(String[] folders) throws JavaModelException {
	IProject project = getRoot().getProject(this.projectName);
	IJavaProject jproject = JavaCore.create(project);
	IPackageFragmentRoot[] pkgs = jproject.getPackageFragmentRoots();

	for (int i = 0; i < folders.length; i++) {
		String folder = folders[i];
		boolean found = false;
		for (int j = 0; j < pkgs.length; j++) {
			IPackageFragmentRoot pkg = pkgs[j];
			IPath path = new Path("/").append(this.projectName).append(folder);
			if (pkg.getPath().toString().equalsIgnoreCase(path.toString())) {
				found = true;
			}
			;
		}
		assertTrue("Expected folder: " + folder, found);
	}
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:20,代码来源:GW4EProject.java

示例6: get

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入依赖的package包/类
public static TestResourceGeneration get (IFile file) throws CoreException, FileNotFoundException {
	String targetFolder = GraphWalkerContextManager.getTargetFolderForTestImplementation(file);
	IPath pkgFragmentRootPath = file.getProject().getFullPath().append(new Path(targetFolder));
	IPackageFragmentRoot implementationFragmentRoot = JDTManager.getPackageFragmentRoot(file.getProject(), pkgFragmentRootPath);
	String classname = file.getName().split("\\.")[0];
	classname = classname + PreferenceManager.suffixForTestImplementation(implementationFragmentRoot.getJavaProject().getProject().getName()) + ".java";

	ClassExtension ce = PreferenceManager.getDefaultClassExtension(file);
	IPath p = ResourceManager.getPathWithinPackageFragment(file).removeLastSegments(1);
	p = implementationFragmentRoot.getPath().append(p);
	
	ResourceContext context = new ResourceContext(p, classname, file, true, false, false, ce);
	
	TestResourceGeneration trg = new TestResourceGeneration(context);
	return trg;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:17,代码来源:GenerationFactory.java

示例7: createClassRepo

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入依赖的package包/类
public void createClassRepo(String jarFileName, String Package) {
	ClassRepo.INSTANCE.flusRepo();
	try {
		IPackageFragmentRoot iPackageFragmentRoot = getIPackageFragment(jarFileName);
		if (iPackageFragmentRoot != null) {
			IPackageFragment fragment = iPackageFragmentRoot.getPackageFragment(Package);
			if (fragment != null) {
				for (IClassFile element : fragment.getClassFiles()) {
					ClassRepo.INSTANCE.addClass(element,"","",false);
				}
			} else {
				new CustomMessageBox(SWT.ERROR, Package + " Package not found in jar "
						+ iPackageFragmentRoot.getElementName(), "ERROR").open();
			}
		}
	} catch (JavaModelException e) {
		LOGGER.error("Error occurred while loading class from jar {}", jarFileName, e);
	}
	loadClassesFromSettingsFolder();
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:21,代码来源:BuildExpressionEditorDataSturcture.java

示例8: getSourceFolders

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入依赖的package包/类
/**
 * Returns the list of source folders of the given project as a list of
 * absolute workspace paths.
 * 
 * @param project
 *            a project
 * @return a list of absolute workspace paths
 */
public static List<IFolder> getSourceFolders(IProject project) {
	List<IFolder> srcFolders = new ArrayList<IFolder>();

	try {
		IJavaProject javaProject = JavaCore.create(project);
		if (!javaProject.exists()) {
			return srcFolders;
		}

		// iterate over package roots
		for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) {
			IResource resource = root.getCorrespondingResource();
			if (resource != null && resource.getType() == IResource.FOLDER) {
				srcFolders.add((IFolder) resource);
			}
		}
	} catch (CoreException e) {
		Logger.debug("Get source folder exception: %s", e);
	}

	return srcFolders;
}
 
开发者ID:turnus,项目名称:turnus,代码行数:31,代码来源:EcoreUtils.java

示例9: attachSource

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入依赖的package包/类
public static void attachSource(final IPackageFragmentRoot fragment, final IPath newSourcePath,
    IProgressMonitor monitor) {
  try {
    if (fragment == null || fragment.getKind() != IPackageFragmentRoot.K_BINARY) {
      return;
    }
    if (!Objects.equals(fragment.getSourceAttachmentPath(), newSourcePath)) {
      // would be so cool if it refreshed the UI automatically
      fragment.attachSource(newSourcePath, null, monitor);
      // close the root so that source attachment cache is flushed. Else UI
      // won't update
      fragment.close();
      // we have to manually fire a delta to notify the UI about the source
      // attachment.
      JavaModelManager manager = JavaModelManager.getJavaModelManager();
      JavaElementDelta attachedSourceDelta = new JavaElementDelta(fragment.getJavaModel());
      attachedSourceDelta.sourceAttached(fragment);
      manager.getDeltaProcessor().fire(attachedSourceDelta, ElementChangedEvent.POST_CHANGE);
    }
  } catch (CoreException e) {
    // ignore
  }
}
 
开发者ID:fbricon,项目名称:pde.source.lookup,代码行数:24,代码来源:ClasspathUtils.java

示例10: getPluginContainerEntries

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入依赖的package包/类
public static IPackageFragmentRoot[] getPluginContainerEntries(IProject project) {
  if (!ProjectUtils.isPluginProject(project)) {
    return new IPackageFragmentRoot[0];
  }
  IJavaProject javaProject = JavaCore.create(project);

  IClasspathEntry pluginContainer = null;
  try {
    pluginContainer = Stream.of(javaProject.getRawClasspath()).filter(cpe -> isPluginContainer(cpe)).findFirst()
        .orElse(null);
  } catch (JavaModelException e) {
    e.printStackTrace();
  }
  if (pluginContainer == null) {
    return new IPackageFragmentRoot[0];
  }
  IPackageFragmentRoot[] pfr = javaProject.findPackageFragmentRoots(pluginContainer);
  return pfr;
}
 
开发者ID:fbricon,项目名称:pde.source.lookup,代码行数:20,代码来源:ClasspathUtils.java

示例11: run

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入依赖的package包/类
@Override
protected IStatus run(IProgressMonitor monitor) {
  if (monitor == null) {
    monitor = new NullProgressMonitor();
  }
  Collection<IPackageFragmentRoot> currentQueue;
  synchronized (this.queue) {
    currentQueue = new LinkedHashSet<>(this.queue);
    this.queue.clear();
  }

  for (IPackageFragmentRoot fragment : currentQueue) {
    if (monitor.isCanceled()) {
      break;
    }
    findAndAttachSources(fragment, monitor);
  }
  // schedule remaining requests that were added during this run
  synchronized (this.queue) {
    if (!queue.isEmpty() && !monitor.isCanceled()) {
      schedule();
    }
  }
  return Status.OK_STATUS;
}
 
开发者ID:fbricon,项目名称:pde.source.lookup,代码行数:26,代码来源:AbstractSourceDownloadJob.java

示例12: getSelectedClasspathEntries

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入依赖的package包/类
private Collection<IPackageFragmentRoot> getSelectedClasspathEntries(ISelection selection) {
  if (!(selection instanceof ITreeSelection)) {
    return Collections.emptyList();
  }
  ITreeSelection structuredSelection = (ITreeSelection) selection;
  Set<IPackageFragmentRoot> fragments = new LinkedHashSet<>(structuredSelection.size());
  for (Object o : structuredSelection.toList()) {
    if (o instanceof IPackageFragmentRoot) {
      IPackageFragmentRoot pfr = (IPackageFragmentRoot) o;
      if (ClasspathUtils.isBinaryFragment(pfr) && belongsToPluginContainer(structuredSelection, pfr)) {
        fragments.add(pfr);
      }
    } else if (isPluginContainer(o)) {
      IAdaptable adaptable = (IAdaptable) o;
      IWorkbenchAdapter wa = adaptable.getAdapter(IWorkbenchAdapter.class);
      if (wa != null) {
        Object[] children = wa.getChildren(o);
        if (children instanceof IAdaptable[]) {
          IAdaptable[] adaptables = (IAdaptable[]) children;
          fragments.addAll(filterPackageFragmentRoots(adaptables));
        }
      }
    }
  }
  return fragments;
}
 
开发者ID:fbricon,项目名称:pde.source.lookup,代码行数:27,代码来源:DownloadSourcesHandler.java

示例13: run

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入依赖的package包/类
@Override
public void run(IAction action) {
  if (selection == null || selection.isEmpty()) {
    return;
  }
  Set<IPackageFragmentRoot> queue = new LinkedHashSet<>();
  for(Iterator<?> it = selection.iterator(); it.hasNext();) {
    Object element = it.next();
    if(element instanceof IPackageFragmentRoot) {
      IPackageFragmentRoot fragment = (IPackageFragmentRoot) element;
      try {
        if (canProcess(fragment)) {
          queue.add(fragment);
        }
      } catch (CoreException e) {
        e.printStackTrace();
      }
    }
  }
  findSources(queue);
}
 
开发者ID:fbricon,项目名称:pde.source.lookup,代码行数:22,代码来源:DownloadSourcesActionDelegate.java

示例14: setActiveEditor

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入依赖的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

示例15: createCompilationUnit

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入依赖的package包/类
public ICompilationUnit createCompilationUnit(
    IPackageFragmentRoot fragmentRoot, String testsrc, String path)
    throws CoreException, IOException {
  IPath typepath = new Path(path);
  String pkgname = typepath.removeLastSegments(1).toString()
      .replace('/', '.');
  IPackageFragment fragment = createPackage(fragmentRoot, pkgname);
  StringBuilder sb = new StringBuilder();
  InputStream source = openTestResource(new Path(testsrc).append(typepath));
  Reader r = new InputStreamReader(source);
  int c;
  while ((c = r.read()) != -1)
    sb.append((char) c);
  r.close();
  return createCompilationUnit(fragment, typepath.lastSegment(),
      sb.toString());
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:18,代码来源:JavaProjectKit.java


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