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


Java IPackageFragmentRoot.getChildren方法代码示例

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


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

示例1: getDefaultPackage

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入方法依赖的package包/类
public String getDefaultPackage() {
	WPILibJavaPlugin.logInfo("Project: "+project);
	String defaultPackage = null;
	if (project != null) {
		try {
			IPackageFragmentRoot root = JavaCore.create(project)
					.getPackageFragmentRoot(project.getFolder("src"));
			String backupPackage = "";
			for (IJavaElement child : root.getChildren()) {
				if (child.getElementType()==IJavaElement.PACKAGE_FRAGMENT
						&& child.getElementName().endsWith("."+ending)) {
					defaultPackage = child.getElementName();
				}
				backupPackage =  child.getElementName();
			}
			if (defaultPackage == null) defaultPackage = backupPackage;
		} catch (JavaModelException e) {
               WPILibJavaPlugin.logError("Error getting default package.", e);
		}
	}
	if (defaultPackage != null) return defaultPackage;
	else return "";
}
 
开发者ID:wpilibsuite,项目名称:EclipsePlugins,代码行数:24,代码来源:FileTemplateWizardMainPage.java

示例2: populatePackageNameFromSelectedJar

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入方法依赖的package包/类
/**
 * Populate packages for selected jar file
 * 
 */
public void populatePackageNameFromSelectedJar() {
	sourcePackageList.removeAll();
	IPackageFragmentRoot iPackageFragmentRoot = (IPackageFragmentRoot) comboJarList.getData(String
			.valueOf(comboJarList.getSelectionIndex()));
	if (iPackageFragmentRoot != null) {
		try {
			for (IJavaElement iJavaElement : iPackageFragmentRoot.getChildren()) {
					if (iJavaElement instanceof IPackageFragment) {
						IPackageFragment packageFragment = (IPackageFragment) iJavaElement;
						if (packageFragment.containsJavaResources()) {
							if(!isAlreadyPresentInTargetList(packageFragment.getElementName()))
							sourcePackageList.add(packageFragment.getElementName());
						}
					}
			}
		} catch (JavaModelException javaModelException) {
			LOGGER.warn("Error occurred while fetching packages from "
					+ iPackageFragmentRoot.getElementName());
		}
	}
	if(comboJarList.getSelectionIndex() ==0){
		deleteButton.setEnabled(false);
	}else{
		deleteButton.setEnabled(true);
	}
	enableOrDisableAddLabelsOnComboSelection();
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:32,代码来源:CategoriesDialogSourceComposite.java

示例3: choosePackage

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入方法依赖的package包/类
protected IPackageFragment choosePackage() {
	IPackageFragmentRoot froot = getPackageFragmentRoot();
	IJavaElement[] packages = null;
	try {
		if (froot != null && froot.exists()) {
			packages = froot.getChildren();
		}
	} catch (JavaModelException e) {
		JavaPlugin.log(e);
	}
	if (packages == null) {
		packages = new IJavaElement[0];
	}

	ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new JavaElementLabelProvider(
			JavaElementLabelProvider.SHOW_DEFAULT));
	dialog.setIgnoreCase(false);
	dialog.setTitle(NewWizardMessages.NewTypeWizardPage_ChoosePackageDialog_title);
	dialog.setMessage(NewWizardMessages.NewTypeWizardPage_ChoosePackageDialog_description);
	dialog.setEmptyListMessage(NewWizardMessages.NewTypeWizardPage_ChoosePackageDialog_empty);
	dialog.setElements(packages);
	dialog.setHelpAvailable(false);
	if (dialog.open() == Window.OK) {
		return (IPackageFragment) dialog.getFirstResult();
	}
	return null;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:28,代码来源:ExportToJavaBeanWizardPage.java

示例4: collectCompilationUnits

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入方法依赖的package包/类
private void collectCompilationUnits(IPackageFragmentRoot root, Collection<IJavaElement> result, String prefix) throws JavaModelException {
	if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
		IJavaElement[] children = root.getChildren();
		for (int i = 0; i < children.length; i++) {
			IPackageFragment pack = (IPackageFragment) children[i];
			if (StringUtils.isBlank(prefix) || pack.getElementName().indexOf(prefix) >= 0) {
				collectCompilationUnits(pack, result);
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:12,代码来源:OrganizeImportsCommand.java

示例5: isJavaFilePresent

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入方法依赖的package包/类
/**
 * Checks that the Java file for the given class name exists in the project.
 *
 * @param project
 *          the project, must not be {@code null}
 * @param className
 *          the class name, must not be {@code null}
 * @return whether the corresponding java file exists in the project
 */
public boolean isJavaFilePresent(final IProject project, final String className) {
  int packageSplitIndex = className.lastIndexOf('.');
  if (packageSplitIndex == -1) {
    throw new IllegalArgumentException(String.format("%s is a simple class name or not a class name at all.", className));
  }
  int fileNameEndIndex = className.indexOf('$');
  if (fileNameEndIndex == -1) {
    fileNameEndIndex = className.length();
  }
  String packageName = className.substring(0, packageSplitIndex);
  String fileName = className.substring(packageSplitIndex + 1, fileNameEndIndex) + ".java";
  try {
    if (project.hasNature(JavaCore.NATURE_ID)) {
      for (IPackageFragmentRoot root : JavaCore.create(project).getAllPackageFragmentRoots()) {
        if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
          for (IJavaElement element : root.getChildren()) {
            if (element instanceof IPackageFragment && packageName.equals(element.getElementName())
                && ((IPackageFragment) element).getCompilationUnit(fileName).exists()) {
              return true;
            }
          }
        }
      }
    }
  } catch (CoreException e) {
    LOGGER.error(String.format("Failed to read project %s.", project.getName()), e);
  }
  return false;
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:39,代码来源:CheckProjectHelper.java


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