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