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


Java IResource.exists方法代码示例

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


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

示例1: resfreshFileInContainer

import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
 * @param folder
 * @param filetorefresh
 * @return
 * @throws CoreException
 * @throws InterruptedException
 */
public static IResource resfreshFileInContainer(IContainer folder, String filetorefresh)
		throws CoreException, InterruptedException {
	final IResource buildfile = find(folder, filetorefresh);
	Job job = new WorkspaceJob("Refresh folders") {
		public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
			if (buildfile != null && buildfile.exists()) {
				try {
					buildfile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
				} catch (CoreException e) {
					ResourceManager.logException(e);
				}
			}
			return Status.OK_STATUS;
		}
	};
	job.setUser(true);
	job.schedule();

	return buildfile;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:28,代码来源:ResourceManager.java

示例2: getGradleProperties

import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
private Properties getGradleProperties() {
    Properties gradleProperties = new Properties();
    IResource resource = project.findMember("gradle.properties");
    if (resource != null && resource.exists()) {
        IFile gradlePropertiesFile = (IFile) resource;
        if (gradlePropertiesFile.exists()) {
            try (FileReader gradlePropertiesReader = new FileReader(new File(gradlePropertiesFile.getLocationURI()))) {
                gradleProperties.load(gradlePropertiesReader);
                return gradleProperties;
            } catch (IOException e) {
                e.printStackTrace();
            } 
        }
    } 
    System.out.println("gradle resource not found");
    return null;
}
 
开发者ID:gluonhq,项目名称:ide-plugins,代码行数:18,代码来源:ExecuteUploadFunction.java

示例3: doFinish

import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
private void doFinish(IPath containerPath, String[] path, IProgressMonitor monitor) throws CoreException {
	monitor.beginTask("Creating package " + String.join(".", path), path.length);
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

	IResource resource = root.findMember(containerPath);
	if (!resource.exists() || !(resource instanceof IContainer)) {
		throwCoreException("Container \"" + containerPath + "\" does not exist.");
	}

	IContainer container = (IContainer) resource;
	for(int i = 0; i < path.length; i++) {
		Path p = new Path(path[i]);
		final IFolder folder = container.getFolder(p);
		if(!folder.exists())
			folder.create(true, false, monitor);
		container = container.getFolder(p);
		monitor.worked(1);
	}
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:20,代码来源:NewPackageWizard.java

示例4: getGradleBuildFile

import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
public static IFile getGradleBuildFile(IContainer project) {
    IResource resource = project.findMember("build.gradle");
        if (resource != null && resource.exists()) {
            return (IFile) resource;
        }
        return null;
}
 
开发者ID:gluonhq,项目名称:ide-plugins,代码行数:8,代码来源:ProjectUtils.java

示例5: getGradleSettingsFile

import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
public static IFile getGradleSettingsFile(IContainer project) {
       IResource resource = project.findMember("settings.gradle");
           if (resource != null && resource.exists()) {
               return (IFile) resource;
           }
           return null;
}
 
开发者ID:gluonhq,项目名称:ide-plugins,代码行数:8,代码来源:ProjectUtils.java

示例6: cleanProblems

import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
private void cleanProblems(IResource resource, int depth) throws CoreException
{
	if( resource.exists() )
	{
		resource.deleteMarkers(JPFClasspathPlugin.MARKER_ID, true, depth);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:8,代码来源:JPFManifestBuilder.java

示例7: createRule

import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
 * Returns the scheduling rule to use when creating the resource at the
 * given container path. The rule should be the creation rule for the
 * top-most non-existing parent.
 * 
 * @param resource
 *            The resource being created
 * @return The scheduling rule for creating the given resource
 * @since 3.1
 * @deprecated As of 3.3, scheduling rules are provided by the undoable
 *             operation that this page creates and executes.
 */
protected ISchedulingRule createRule(IResource resource) {
	IResource parent = resource.getParent();
	while (parent != null) {
		if (parent.exists()) {
			return resource.getWorkspace().getRuleFactory()
					.createRule(resource);
		}
		resource = parent;
		parent = parent.getParent();
	}
	return resource.getWorkspace().getRoot();
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:25,代码来源:WizardNewFileCreationPage.java

示例8: isValid

import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
@Override
public boolean isValid(ILaunchConfiguration config) {
	setErrorMessage(null);
	setMessage(null);
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	String modelName = _modelLocationText.getText().trim();
	if (modelName.length() > 0) {
		
		IResource modelIResource = workspace.getRoot().findMember(modelName);
		if (modelIResource == null || !modelIResource.exists()) {
			setErrorMessage(NLS.bind(LauncherMessages.SequentialMainTab_model_doesnt_exist, new String[] {modelName})); 
			return false;
		}
		if (modelName.equals("/")) {
			setErrorMessage(LauncherMessages.SequentialMainTab_Model_not_specified); 
			return false;
		}
		if (! (modelIResource instanceof IFile)) {
			setErrorMessage(NLS.bind(LauncherMessages.SequentialMainTab_invalid_model_file, new String[] {modelName})); 
			return false;
		}
	}
	if (modelName.length() == 0) {
		setErrorMessage(LauncherMessages.SequentialMainTab_Model_not_specified); 
		return false;
	}
	
	String languageName = _languageCombo.getText().trim();
	if (languageName.length() == 0) {
		setErrorMessage(LauncherMessages.SequentialMainTab_Language_not_specified); 
		return false;
	}
	else if(MelangeHelper.getEntryPoints(languageName).isEmpty()){
		setErrorMessage(LauncherMessages.SequentialMainTab_Language_main_methods_dont_exist); 
		return false;
	}
	
	String mainMethod = _entryPointMethodText.getText().trim();
	if (mainMethod.length() == 0) {
		setErrorMessage(LauncherMessages.SequentialMainTab_Language_main_method_not_selected); 
		return false;
	}
	
	String rootElement = _entryPointModelElementText.getText().trim();
	if (rootElement.length() == 0) {
		setErrorMessage(LauncherMessages.SequentialMainTab_Language_root_element_not_selected); 
		return false;
	}
	
	String[] params =MelangeHelper.getParametersType(mainMethod);
	String firstParam = MelangeHelper.lastSegment(params[0]);
	String rootEClass = getModel().getEObject(rootElement).eClass().getName();
	if( !(params.length == 1 && firstParam.equals(rootEClass)) ){
		setErrorMessage(LauncherMessages.SequentialMainTab_Language_incompatible_root_and_main); 
		return false;
	}
	
	return true;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:60,代码来源:LaunchConfigurationMainTab.java

示例9: execute

import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
	boolean autoBuilding = ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding();
	IWorkbenchWindow aww = HandlerUtil.getActiveWorkbenchWindow(event);
	ISelection sel = HandlerUtil.getCurrentSelection(event);
	if (sel.isEmpty())
		return null;
	if (sel instanceof IStructuredSelection) {

		IStructuredSelection selection = (IStructuredSelection) sel;
		if (selection != null) {
			Object obj = selection.getFirstElement();
			if (obj != null) {
				try {
					IResource selectedResource = null;
					if (obj instanceof IJavaProject) {
						IJavaProject jp = (IJavaProject) obj;
						selectedResource = jp.getProject();
					}
					if (obj instanceof IPackageFragmentRoot) {
						IPackageFragmentRoot pfr = (IPackageFragmentRoot) obj;
						selectedResource = pfr.getCorrespondingResource();
					}
					if (obj instanceof IPackageFragment) {
						IPackageFragment pf = (IPackageFragment) obj;
						selectedResource = pf.getCorrespondingResource();
					}
					if (selectedResource != null && !selectedResource.exists())
						return null;
					// This is where the synchronization is done ...
					ResourceManager.setAutoBuilding(false);
					GraphWalkerContextManager.synchronizeBuildPolicies(selectedResource, aww);
				} catch (Exception e) {
					ResourceManager.logException(e);
				} finally {
					ResourceManager.setAutoBuilding(autoBuilding);
				}
			}
		}
	}
	return null;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:42,代码来源:SynchronizeBuildPoliciesHandler.java

示例10: test

import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
@Override
public boolean test() throws Exception {
	IResource resource = ResourceManager.getResource(path.toString());
	return resource!=null && resource.exists();
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:6,代码来源:ResourceExists.java


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