當前位置: 首頁>>代碼示例>>Java>>正文


Java IJavaProject.close方法代碼示例

本文整理匯總了Java中org.eclipse.jdt.core.IJavaProject.close方法的典型用法代碼示例。如果您正苦於以下問題:Java IJavaProject.close方法的具體用法?Java IJavaProject.close怎麽用?Java IJavaProject.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jdt.core.IJavaProject的用法示例。


在下文中一共展示了IJavaProject.close方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getIPackageFragment

import org.eclipse.jdt.core.IJavaProject; //導入方法依賴的package包/類
/**
 * Returns packages of given jar file
 * 
 * @param jarFileName
 * @return IPackageFragmentRoot
 * 			packages of given jar file
 */
public IPackageFragmentRoot getIPackageFragment(String jarFileName) {
	IProject iProject = getCurrentProject();
	IJavaProject javaProject = JavaCore.create(iProject);
	try {
		if(StringUtils.equals(jarFileName, hydrograph.ui.common.util.Constants.ProjectSupport_SRC)){
			return getSrcPackageFragment(javaProject);
		}
		
		IPackageFragmentRoot[] fragmentRoot = javaProject.getAllPackageFragmentRoots();
		for (IPackageFragmentRoot iPackageFragmentRoot : fragmentRoot) {
			if (StringUtils.contains(iPackageFragmentRoot.getElementName(), jarFileName))
				return iPackageFragmentRoot;
		}
	} catch (JavaModelException javaModelException) {
		LOGGER.error("Error occurred while loading engines-transform jar", javaModelException);
	}
	finally{
		if(javaProject!=null){
			try {
				javaProject.close();
			} catch (JavaModelException modelException) {
				LOGGER.warn("JavaModelException occurred while closing java-project"+modelException);
			}
		}
	}
	if(StringUtils.equals(jarFileName, ConfigFileReader.INSTANCE.getConfigurationValueFromCommon(Constants.KEY_TRANSFORMATION_JAR)))
		new CustomMessageBox(SWT.ERROR, "Error occurred while loading " + jarFileName + " file", "ERROR").open();
	return null;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:37,代碼來源:BuildExpressionEditorDataSturcture.java

示例2: loadComboJarListFromBuildPath

import org.eclipse.jdt.core.IJavaProject; //導入方法依賴的package包/類
@SuppressWarnings("restriction")
private void loadComboJarListFromBuildPath(Combo comboJarList, String newJarName) {
	comboJarList.removeAll();
	IProject iProject = BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject();
	IJavaProject iJavaProject=null;
	try {
		iJavaProject = JavaCore.create(iProject);
		PackageFragmentRoot srcfragmentRoot= BuildExpressionEditorDataSturcture.INSTANCE.getSrcPackageFragment(iJavaProject);
		comboJarList.add(hydrograph.ui.common.util.Constants.ProjectSupport_SRC);
		comboJarList.setData(String.valueOf(comboJarList.getItemCount() - 1), srcfragmentRoot);
		
		for (IPackageFragmentRoot iPackageFragmentRoot : iJavaProject.getAllPackageFragmentRoots()) {
			if (isJarPresentInLibFolder(iPackageFragmentRoot.getPath())
					&& iPackageFragmentRoot.getKind() != IPackageFragmentRoot.K_SOURCE) {
				comboJarList.add(iPackageFragmentRoot.getElementName());
				comboJarList.setData(String.valueOf(comboJarList.getItemCount() - 1), iPackageFragmentRoot);
			}
		}
		selectAndLoadJarData(newJarName);
	} catch (JavaModelException javaModelException) {
		LOGGER.error("Error occurred while loading engines-transform jar", javaModelException);
	}
	finally{
		if(iJavaProject!=null){
			try {
				iJavaProject.close();
			} catch (JavaModelException e) {
				LOGGER.warn("JavaModelException occurred while closing java-project"+e);
			}
		}
	}

}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:34,代碼來源:CategoriesDialogSourceComposite.java

示例3: getFiles

import org.eclipse.jdt.core.IJavaProject; //導入方法依賴的package包/類
private static Set<ICompilationUnit> getFiles(String projname) throws CoreException {
	IWorkspaceRoot ws = ResourcesPlugin.getWorkspace().getRoot();
	IProject proj = ws.getProject(projname);
	IJavaProject javaProject = JavaCore.create(proj);
	Set<ICompilationUnit> files = new HashSet<ICompilationUnit>();
	javaProject.open(new NullProgressMonitor());
	for( IPackageFragment packFrag : javaProject.getPackageFragments()) {
		for (ICompilationUnit icu : packFrag.getCompilationUnits()) {
			files.add(icu);
		}
	}
	javaProject.close();
	return files;
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:15,代碼來源:LSDiffRunner.java

示例4: SourceViewer

import org.eclipse.jdt.core.IJavaProject; //導入方法依賴的package包/類
public SourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
		boolean showAnnotationsOverview, int styles, IAnnotationAccess annotationAccess, ISharedTextColors sharedColors,
		IDocument document) 
{
	super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, SWT.BOLD);
	int id = currentId++;
	filename = VIEWER_CLASS_NAME + id++ + ".java";
	this.sharedColors=sharedColors;
	this.annotationAccess=annotationAccess;
	this.fOverviewRuler=overviewRuler;
	oldAnnotations= new HashMap<ProjectionAnnotation, Position>();

	IJavaProject javaProject = JavaCore.create(BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject());
	try 
	{
		IPackageFragmentRoot[] ipackageFragmentRootList=javaProject.getPackageFragmentRoots();
		IPackageFragmentRoot ipackageFragmentRoot=null;
		for(IPackageFragmentRoot tempIpackageFragmentRoot:ipackageFragmentRootList)
		{
			if(tempIpackageFragmentRoot.getKind()==IPackageFragmentRoot.K_SOURCE 
					&& StringUtils.equals(PathConstant.TEMP_BUILD_PATH_SETTINGS_FOLDER,tempIpackageFragmentRoot.getPath().removeFirstSegments(1).toString()))
			{
				ipackageFragmentRoot=tempIpackageFragmentRoot;
				break;
			}   
		} 

		IPackageFragment compilationUnitPackage=   ipackageFragmentRoot.createPackageFragment(HYDROGRAPH_COMPILATIONUNIT_PACKAGE, true, new NullProgressMonitor());
		compilatioUnit=   compilationUnitPackage.createCompilationUnit(filename,document.get(),true, new NullProgressMonitor());
	} 
	catch (Exception exception) {
		LOGGER.warn("Exception occurred while initializing source viewer", exception);
	} finally {
		if (javaProject != null) {
			try {
				javaProject.close();
			} catch (JavaModelException javaModelException) {
				LOGGER.warn("Exception occurred while closing java-project", javaModelException);
			}
		}
	}
	initializeViewer(document);
	updateContents();
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:45,代碼來源:SourceViewer.java

示例5: getBuildPathForMethodInvocation

import org.eclipse.jdt.core.IJavaProject; //導入方法依賴的package包/類
public static Object[] getBuildPathForMethodInvocation() throws JavaModelException, MalformedURLException {
	String transfromJarPath = null;
	Object[] returnObj=new Object[3];
	IJavaProject iJavaProject = JavaCore.create(BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject());
	List<URL> urlList = new ArrayList<>();
	Properties properties = ConfigFileReader.INSTANCE.getCommonConfigurations();
	for (IPackageFragmentRoot iPackageFragmentRoot : iJavaProject.getAllPackageFragmentRoots()) {
		if (!iPackageFragmentRoot.isExternal()
				|| StringUtils.contains(iPackageFragmentRoot.getElementName(), properties.getProperty(Constants.KEY_TRANSFORMATION_JAR))
				|| StringUtils.contains(iPackageFragmentRoot.getElementName(), Constants.ANTLR_JAR_FILE_NAME)
				|| StringUtils.contains(iPackageFragmentRoot.getElementName(), Constants.BEAN_SHELLJAR_FILE_NAME)
				|| StringUtils.contains(iPackageFragmentRoot.getElementName(), Constants.SL4JLOG)
				|| StringUtils.contains(iPackageFragmentRoot.getElementName(), properties.getProperty(Constants.KEY_EXPRESSION_JAR))) {
			URL url = null;
			if (!iPackageFragmentRoot.isExternal()) {
				url = BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject()
						.getFile(iPackageFragmentRoot.getPath().removeFirstSegments(1)).getLocation().toFile()
						.toURI().toURL();
				urlList.add(url);
			} else {
				url = iPackageFragmentRoot.getPath().toFile().toURI().toURL();
				urlList.add(url);
			}

			if (!iPackageFragmentRoot.isExternal()
					|| StringUtils.contains(iPackageFragmentRoot.getElementName(), properties.getProperty(Constants.KEY_TRANSFORMATION_JAR))) {
				if (transfromJarPath == null) {
					if (OSValidator.isMac() || OSValidator.isUnix())
						transfromJarPath = url.getPath() + Constants.COLON;
					else
						transfromJarPath = url.getPath() + Constants.SEMICOLON;
				} else {
					if (OSValidator.isMac() || OSValidator.isUnix())
						transfromJarPath = transfromJarPath + url.getPath() + Constants.COLON;
					else
						transfromJarPath = transfromJarPath + url.getPath() + Constants.SEMICOLON;
				}
			}
		}
	}
	
	returnObj[0]=urlList;
	returnObj[1]=transfromJarPath;
	returnObj[2]=getPropertyFilePath(iJavaProject);
	iJavaProject.close();
	return returnObj;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:48,代碼來源:ValidateExpressionToolButton.java


注:本文中的org.eclipse.jdt.core.IJavaProject.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。