當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。