本文整理汇总了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;
}
示例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 () );
}
}
示例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));
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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]);
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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()]);
}
示例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;
}
});
}
示例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;
}
示例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);
}