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


Java IPackageFragmentRoot.getJavaProject方法代码示例

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


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

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

示例2: getSimpleTextForJavaElement

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入方法依赖的package包/类
private String getSimpleTextForJavaElement(Object element) {
  if (element instanceof IPackageFragmentRoot) {
    final IPackageFragmentRoot root = (IPackageFragmentRoot) element;
    // tweak label if the package fragment root is the project itself:
    if (root.getElementName().length() == 0) {
      element = root.getJavaProject();
    }
    // shorten JAR references
    try {
      if (root.getKind() == IPackageFragmentRoot.K_BINARY) {
        return root.getPath().lastSegment();
      }
    } catch (JavaModelException e) {
      EclEmmaUIPlugin.log(e);
    }
  }
  return workbenchLabelProvider.getText(element);
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:19,代码来源:CellTextConverter.java

示例3: packageChanged

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入方法依赖的package包/类
protected IStatus packageChanged() {
	StatusInfo status = new StatusInfo();
	IPackageFragmentRoot root = getPackageFragmentRoot();
	IJavaProject project = root != null ? root.getJavaProject() : null;

	String packName = getPackageText().getText();
	if (packName.length() > 0) {
		IStatus val = validatePackageName(packName, project);
		if (val.getSeverity() == IStatus.ERROR) {
			status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidPackageName, val.getMessage()));
			return status;
		} else if (val.getSeverity() == IStatus.WARNING) {
			status.setWarning(Messages.format(NewWizardMessages.NewTypeWizardPage_warning_DiscouragedPackageName, val.getMessage()));
			// continue
		}
	} else {
		status.setWarning(NewWizardMessages.NewTypeWizardPage_warning_DefaultPackageDiscouraged);
	}

	if (project != null) {
		if (project.exists() && packName.length() > 0) {
			try {
				IPath rootPath = root.getPath();
				IPath outputPath = project.getOutputLocation();
				if (rootPath.isPrefixOf(outputPath) && !rootPath.equals(outputPath)) {
					// if the bin folder is inside of our root, don't allow
					// to name a package
					// like the bin folder
					IPath packagePath = rootPath.append(packName.replace('.', '/'));
					if (outputPath.isPrefixOf(packagePath)) {
						status.setError(NewWizardMessages.NewTypeWizardPage_error_ClashOutputLocation);
						return status;
					}
				}
			} catch (JavaModelException e) {
				JavaPlugin.log(e);
				// let pass
			}
		}

		fCurrPackage = root.getPackageFragment(packName);
		IResource resource = fCurrPackage.getResource();
		if (resource != null) {
			if (resource.isVirtual()) {
				status.setError(NewWizardMessages.NewTypeWizardPage_error_PackageIsVirtual);
				return status;
			}
			if (!ResourcesPlugin.getWorkspace().validateFiltered(resource).isOK()) {
				status.setError(NewWizardMessages.NewTypeWizardPage_error_PackageNameFiltered);
				return status;
			}
		}
	} else {
		status.setError("");
	}
	return status;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:58,代码来源:ExportToJavaBeanWizardPage.java

示例4: isOnClasspath

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入方法依赖的package包/类
/**
 * This methods checks whether the given package fragment root is still on the
 * classpath. This check is required as the user might change the classpath
 * and old coverage sessions afterwards (SF #1836551).
 *
 * @param root
 *          package fragment root
 * @return true, if the classpath entry still exists
 * @throws JavaModelException
 */
private boolean isOnClasspath(IPackageFragmentRoot root)
    throws JavaModelException {
  IPath path = root.getPath();
  IJavaProject project = root.getJavaProject();
  return project.findPackageFragmentRoot(path) != null;
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:17,代码来源:TypeTraverser.java


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