本文整理匯總了Java中org.eclipse.core.resources.IContainer.accept方法的典型用法代碼示例。如果您正苦於以下問題:Java IContainer.accept方法的具體用法?Java IContainer.accept怎麽用?Java IContainer.accept使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IContainer
的用法示例。
在下文中一共展示了IContainer.accept方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import org.eclipse.core.resources.IContainer; //導入方法依賴的package包/類
@Override
public IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
startTime = System.currentTimeMillis();
AbstractTextSearchResult textResult = (AbstractTextSearchResult) getSearchResult();
textResult.removeAll();
try {
IContainer dir = configFile.getParent();
dir.accept(new AbstractSectionPatternVisitor(section) {
@Override
protected void collect(IResourceProxy proxy) {
Match match = new FileMatch((IFile) proxy.requestResource());
result.addMatch(match);
}
}, IResource.NONE);
return Status.OK_STATUS;
} catch (Exception ex) {
return new Status(IStatus.ERROR, EditorConfigPlugin.PLUGIN_ID, ex.getMessage(), ex);
}
}
示例2: getFolderIterator
import org.eclipse.core.resources.IContainer; //導入方法依賴的package包/類
@Override
public UnmodifiableIterator<URI> getFolderIterator(URI folderLocation) {
final IContainer container;
if (DIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT == folderLocation.segmentCount()) {
container = workspace.getProject(folderLocation.lastSegment());
} else {
container = workspace.getFolder(new Path(folderLocation.toPlatformString(true)));
}
if (container != null && container.exists()) {
final List<URI> result = Lists.newLinkedList();
try {
container.accept(new IResourceVisitor() {
@Override
public boolean visit(IResource resource) throws CoreException {
if (resource.getType() == IResource.FILE) {
result.add(URI.createPlatformResourceURI(resource.getFullPath().toString(), true));
}
return true;
}
});
return Iterators.unmodifiableIterator(result.iterator());
} catch (CoreException e) {
return Iterators.unmodifiableIterator(result.iterator());
}
}
return Iterators.emptyIterator();
}
示例3: getFolderIterator
import org.eclipse.core.resources.IContainer; //導入方法依賴的package包/類
@Override
public Iterator<URI> getFolderIterator(URI folderLocation) {
ensureInitialized();
final URI findProjectWith = findProjectWith(folderLocation);
if (null != findProjectWith) {
final String projectName = findProjectWith.lastSegment();
final ExternalProject project = getProjectMapping().get(projectName);
if (null != project) {
String projectPath = new File(project.getLocationURI()).getAbsolutePath();
String folderPath = folderLocation.toFileString();
final IContainer container = projectPath.equals(folderPath) ? project
: project.getFolder(folderPath.substring(projectPath.length() + 1));
final Collection<URI> result = Lists.newLinkedList();
try {
container.accept(resource -> {
if (resource instanceof IFile) {
final String path = new File(resource.getLocationURI()).getAbsolutePath();
result.add(URI.createFileURI(path));
}
return true;
});
return unmodifiableIterator(result.iterator());
} catch (CoreException e) {
return unmodifiableIterator(result.iterator());
}
}
}
return emptyIterator();
}
示例4: countFiles
import org.eclipse.core.resources.IContainer; //導入方法依賴的package包/類
public static int countFiles(IContainer container) throws CoreException {
int[] count = new int[1];
container.accept(p -> {
if (p.getType() == IResource.FILE) {
++count[0];
}
return true;
}, 0);
return count[0];
}