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


Java IResourceVisitor類代碼示例

本文整理匯總了Java中org.eclipse.core.resources.IResourceVisitor的典型用法代碼示例。如果您正苦於以下問題:Java IResourceVisitor類的具體用法?Java IResourceVisitor怎麽用?Java IResourceVisitor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: collectIndexableFiles

import org.eclipse.core.resources.IResourceVisitor; //導入依賴的package包/類
/**
 * Scans workspace for files that may end up in XtextIndex when given location is processed by the builder. This is
 * naive filtering based on {@link IndexableFilesDiscoveryUtil#INDEXABLE_FILTERS file extensions}. Symlinks are not
 * followed.
 *
 * @param workspace
 *            to scan
 * @return collection of indexable locations
 * @throws CoreException
 *             if scanning of the workspace is not possible.
 */
public static Collection<String> collectIndexableFiles(IWorkspace workspace) throws CoreException {
	Set<String> result = new HashSet<>();
	workspace.getRoot().accept(new IResourceVisitor() {

		@Override
		public boolean visit(IResource resource) throws CoreException {
			if (resource.getType() == IResource.FILE) {
				IFile file = (IFile) resource;
				if (INDEXABLE_FILTERS.contains(file.getFileExtension().toLowerCase())) {
					result.add(file.getFullPath().toString());
				}
			}
			return true;
		}
	});
	return result;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:29,代碼來源:IndexableFilesDiscoveryUtil.java

示例2: validateAll

import org.eclipse.core.resources.IResourceVisitor; //導入依賴的package包/類
protected void validateAll ( final IProject project, final ComposedAdapterFactory adapterFactory, final Set<String> extensions, final IProgressMonitor monitor )
{
    logger.debug ( "Validating all resources of {}", project );

    try
    {
        project.accept ( new IResourceVisitor () {

            @Override
            public boolean visit ( final IResource resource ) throws CoreException
            {
                return handleResource ( null, resource, adapterFactory, extensions, monitor );
            }
        } );
    }
    catch ( final CoreException e )
    {
        StatusManager.getManager ().handle ( e.getStatus () );
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:21,代碼來源:ProjectBuilder.java

示例3: configureTeamPrivateResource

import org.eclipse.core.resources.IResourceVisitor; //導入依賴的package包/類
private void configureTeamPrivateResource(IProject project)
{
	try {
		project.accept(
				new IResourceVisitor() {
					public boolean visit(IResource resource) throws CoreException {
						if ((resource.getType() == IResource.FOLDER)
								&& (resource.getName().equals(SVNProviderPlugin.getPlugin().getAdminDirectoryName()))
								&& (!resource.isTeamPrivateMember()))
						{
							resource.setTeamPrivateMember(true);
							return false;
						}
						else
						{
							return true;
						}
					}
				}, IResource.DEPTH_INFINITE, IContainer.INCLUDE_PHANTOMS | IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS);
	} catch (CoreException e) {
		SVNProviderPlugin.log(SVNException.wrapException(e));
	}
}
 
開發者ID:subclipse,項目名稱:subclipse,代碼行數:24,代碼來源:SVNTeamProvider.java

示例4: findAllWebInfFolders

import org.eclipse.core.resources.IResourceVisitor; //導入依賴的package包/類
/**
 * Returns a list of WEB-INF folders in {@code container}.
 */
@VisibleForTesting
static List<IFolder> findAllWebInfFolders(IContainer container) {
  final List<IFolder> webInfFolders = new ArrayList<>();

  try {
    IResourceVisitor webInfCollector = new IResourceVisitor() {
      @Override
      public boolean visit(IResource resource) throws CoreException {
        if (resource.getType() == IResource.FOLDER && "WEB-INF".equals(resource.getName())) {
          webInfFolders.add((IFolder) resource);
          return false;  // No need to visit sub-directories.
        }
        return true;
      }
    };
    container.accept(webInfCollector);
  } catch (CoreException ex) {
    // Our attempt to find folders failed, but don't error out.
  }
  return webInfFolders;
}
 
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-eclipse,代碼行數:25,代碼來源:FacetUtil.java

示例5: catalogExists

import org.eclipse.core.resources.IResourceVisitor; //導入依賴的package包/類
/**
 * Checks if a given catalog name already exists in the project.
 * 
 * @param packageFragment
 *          the package in which the file is looked for
 * @return true, if catalog exists
 */
private boolean catalogExists(final IResource packageFragment) {
  final Set<IResource> foundResources = Sets.newHashSet();
  final String catalogName = getCatalogName() + '.' + CheckConstants.FILE_EXTENSION;
  IResourceVisitor catalogNameVisitor = new IResourceVisitor() {
    public boolean visit(final IResource res) throws CoreException {
      String resourceName = res.getName();
      if (catalogName.equalsIgnoreCase(resourceName)) {
        foundResources.add(res);
      }
      return foundResources.isEmpty();
    }
  };
  try {
    packageFragment.accept(catalogNameVisitor);
    return !foundResources.isEmpty();
  } catch (CoreException e) {
    // packageFragment does not yet exist. Therefore, the catalog name is unique.
    return false;
  }
}
 
開發者ID:dsldevkit,項目名稱:dsl-devkit,代碼行數:28,代碼來源:NewCheckCatalogWizardPage.java

示例6: getAllEntries

import org.eclipse.core.resources.IResourceVisitor; //導入依賴的package包/類
/**
 * @since 2.4
 */
public Map<URI, IStorage> getAllEntries(IContainer container) {
	final Map<URI,IStorage> result = newLinkedHashMap();
	try {
		container.accept(new IResourceVisitor() {
			public boolean visit(IResource resource) throws CoreException {
				if (resource instanceof IFile) {
					final IFile storage = (IFile) resource;
					URI uri = getUri(storage);
					if (uri != null)
						result.put(uri, storage);
				}
				if (resource instanceof IFolder) {
					return isHandled((IFolder)resource);
				}
				return true;
			}
		});
	} catch (CoreException e) {
		log.error(e.getMessage(), e);
	}
	return result;
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:26,代碼來源:Storage2UriMapperImpl.java

示例7: filterForContent

import org.eclipse.core.resources.IResourceVisitor; //導入依賴的package包/類
public Object[] filterForContent(Object[] inputElements) throws CoreException {
	final Set<Object> result = new LinkedHashSet<Object>();
	for (final Object obj : inputElements) {
		((IResource) obj).accept(new IResourceVisitor() {
			public boolean visit(IResource resource) throws CoreException {
				// no file extension check
				if (resource instanceof IFile && hasFileExtension((IFile) resource)) {
					return false;
				}
				// check if file extension is proper
				else if (resource instanceof IFile && resource.getFileExtension().equals(fileExtension)) {
					result.add(obj);
					return true;
				} else if (resource instanceof IFolder && containsFile((IFolder) resource)) {
					result.add(obj);
					return true;
				}
				return false;
			}
		});
	}
	return result.toArray(new IResource[0]);
}
 
開發者ID:Yakindu,項目名稱:statecharts,代碼行數:24,代碼來源:WorkspaceTreeContentProvider.java

示例8: getProjectStatechartInput

import org.eclipse.core.resources.IResourceVisitor; //導入依賴的package包/類
protected Set<IFile> getProjectStatechartInput(Diagram diagram) {
	final IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
	final IProject project = file.getProject();
	final Set<IFile> result = new HashSet<IFile>();
	try {
		project.accept(new IResourceVisitor() {
			public boolean visit(IResource resource) throws CoreException {
				// TODO check for package explorer filters here
				if (resource.isHidden()) {
					return false;
				}
				if (resource instanceof IFile) {
					if (file.getFileExtension().equals(resource.getFileExtension()))
						result.add((IFile) resource);
				}
				return true;
			}
		});
	} catch (CoreException e) {
		e.printStackTrace();
	}
	return result;
}
 
開發者ID:Yakindu,項目名稱:statecharts,代碼行數:24,代碼來源:DiagramPartitioningBreadcrumbViewer.java

示例9: moveOrCopyDeep

import org.eclipse.core.resources.IResourceVisitor; //導入依賴的package包/類
/**
 * Helper method that generate a move or copy delta for a sub-tree of resources being moved or
 * copied.
 */
private void moveOrCopyDeep(IResource resource, IPath destination, final boolean move) {
  final IPath sourcePrefix = resource.getFullPath();
  final IPath destinationPrefix = destination;
  try {
    // build delta for the entire sub-tree if available
    if (resource.isAccessible()) {
      resource.accept(
          new IResourceVisitor() {
            public boolean visit(IResource child) {
              return moveOrCopy(child, sourcePrefix, destinationPrefix, move);
            }
          });
    } else {
      // just build a delta for the single resource
      moveOrCopy(resource, sourcePrefix, destination, move);
    }
  } catch (CoreException e) {
    fail(e);
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:25,代碼來源:ResourceChangeDescriptionFactory.java

示例10: checkDirtyResources

import org.eclipse.core.resources.IResourceVisitor; //導入依賴的package包/類
private void checkDirtyResources(final RefactoringStatus result) throws CoreException {
  for (int i = 0; i < fResources.length; i++) {
    IResource resource = fResources[i];
    if (resource instanceof IProject && !((IProject) resource).isOpen()) continue;
    resource.accept(
        new IResourceVisitor() {
          public boolean visit(IResource visitedResource) throws CoreException {
            if (visitedResource instanceof IFile) {
              checkDirtyFile(result, (IFile) visitedResource);
            }
            return true;
          }
        },
        IResource.DEPTH_INFINITE,
        false);
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:18,代碼來源:DeleteResourcesProcessor.java

示例11: findHostPages

import org.eclipse.core.resources.IResourceVisitor; //導入依賴的package包/類
private static Set<IFile> findHostPages(IFile moduleFile) {
  List<IFolder> publicFolders = getModulePublicFolders(moduleFile);
  if (publicFolders.isEmpty()) {
    return Collections.emptySet();
  }

  final Set<IFile> hostPages = new HashSet<IFile>();
  try {
    for (IFolder publicFolder : publicFolders) {
      publicFolder.accept(new IResourceVisitor() {
        public boolean visit(IResource resource) throws CoreException {
          // Look for any HTML files
          if (resource.getType() == IResource.FILE
              && "html".equalsIgnoreCase(resource.getFileExtension())) {
            hostPages.add((IFile) resource);
          }
          return true;
        }
      });
    }
  } catch (CoreException e) {
    CorePluginLog.logError(e);
  }

  return hostPages;
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:27,代碼來源:LegacyGWTLaunchShortcutStrategy.java

示例12: findChildModules

import org.eclipse.core.resources.IResourceVisitor; //導入依賴的package包/類
/**
 * Finds all GWT modules located directly in a particular container.
 *
 * @param container container to search within
 * @return the list of modules found
 */
public static IModule[] findChildModules(IContainer container) {
  final List<IModule> modules = new ArrayList<IModule>();

  IResourceVisitor moduleVisitor = new IResourceVisitor() {
    @Override
    public boolean visit(IResource resource) throws CoreException {
      if (resource.getType() == IResource.FILE) {
        IModule module = create((IFile) resource);
        if (module != null) {
          modules.add(module);
        }
      }
      return true;
    }
  };

  try {
    container.accept(moduleVisitor, IResource.DEPTH_ONE, false);
  } catch (CoreException e) {
    GWTPluginLog.logError(e);
  }

  return modules.toArray(new IModule[modules.size()]);
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:31,代碼來源:ModuleUtils.java

示例13: clean

import org.eclipse.core.resources.IResourceVisitor; //導入依賴的package包/類
@Override
protected void clean(IProgressMonitor monitor) throws CoreException {

	IProject project = getProject();
	project.accept(new IResourceVisitor() {

		@Override
		public boolean visit(IResource res) throws CoreException {
			if (res instanceof IFile) {
				IFile png = (IFile) res;
				if ("png".equalsIgnoreCase(png.getFileExtension())) {
					IFile uxf = UmletPluginUtils.getUxfDiagramForImgFile(png);
					if (uxf.exists()) {
						// clean only pngs with corresponding umlet diagrams
						png.delete(true, null);
					}
				}
			}
			return true;
		}
	});
}
 
開發者ID:umlet,項目名稱:umlet,代碼行數:23,代碼來源:UmletBuilder.java

示例14: readFiles

import org.eclipse.core.resources.IResourceVisitor; //導入依賴的package包/類
private static <RES> List<RES> readFiles(ResourceMapping resourceMapping,
    final FileFilter<RES> fileFilter) {
  final List<RES> fileList = new ArrayList<RES>(1);
  IResourceVisitor visitor = new IResourceVisitor() {
    public boolean visit(IResource resource) throws CoreException {
      if (resource instanceof IFile == false) {
        return true;
      } else {
        IFile file = (IFile) resource;
        RES res = fileFilter.accept(file);
        if (res != null) {
          fileList.add(res);
        }
        return false;
      }
    }
  };
  try {
    resourceMapping.accept(null, visitor, null);
  } catch (CoreException e) {
    throw new RuntimeException(e);
  }
  return fileList;
}
 
開發者ID:jbosstools,項目名稱:chromedevtools,代碼行數:25,代碼來源:FileBasedAction.java

示例15: delete

import org.eclipse.core.resources.IResourceVisitor; //導入依賴的package包/類
private void delete() throws CoreException {
	IResourceVisitor visitor = new IResourceVisitor() {
		public boolean visit(IResource resource) throws CoreException {
			if (resource.getName().startsWith(".")) {
				return false;
			}
			// there is a possibility for bugs if variables file is deleted too
			// then sync breaks ... so this is intensionally
			// disabled to simulate deletion of variables files
			//                if (resource.getName().startsWith(PREFIX_EXCL_FROM_SYNC)) {
			//                    return false;
			//                }
			if (resource.getType() == IResource.FOLDER) {
				resource.delete(true, monitor);
				return false;
			}
			return true;
		}
	};
	srcProj.accept(visitor);
}
 
開發者ID:iloveeclipse,項目名稱:filesync4eclipse,代碼行數:22,代碼來源:TestBuilder.java


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