本文整理汇总了Java中org.eclipse.core.resources.IContainer.exists方法的典型用法代码示例。如果您正苦于以下问题:Java IContainer.exists方法的具体用法?Java IContainer.exists怎么用?Java IContainer.exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.resources.IContainer
的用法示例。
在下文中一共展示了IContainer.exists方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cleanOutput
import org.eclipse.core.resources.IContainer; //导入方法依赖的package包/类
private void cleanOutput(IProject aProject, OutputConfiguration config, IProgressMonitor monitor)
throws CoreException {
IContainer container = getContainer(aProject, config.getOutputDirectory());
if (!container.exists()) {
return;
}
if (config.isCanClearOutputDirectory()) {
for (IResource resource : container.members()) {
resource.delete(IResource.KEEP_HISTORY, monitor);
}
} else if (config.isCleanUpDerivedResources()) {
List<IFile> resources = derivedResourceMarkers.findDerivedResources(container, null);
for (IFile iFile : resources) {
iFile.delete(IResource.KEEP_HISTORY, monitor);
}
}
}
示例2: getGraphModels
import org.eclipse.core.resources.IContainer; //导入方法依赖的package包/类
/**
* Retrieve the graph models contained in the container
*
* @param container
* @param models
* @throws CoreException
*/
public static void getGraphModels(IContainer container, List<IFile> models) throws CoreException {
if (!container.exists())
return;
IResource[] members = container.members();
for (IResource member : members) {
if (member instanceof IContainer)
getGraphModels((IContainer) member, models);
else if (member instanceof IFile) {
IFile file = (IFile) member;
if (PreferenceManager.isGraphModelFile(file))
models.add(file);
if (PreferenceManager.isGW3ModelFile(file))
models.add(file);
if (PreferenceManager.isJSONModelFile(file))
models.add(file);
}
}
}
示例3: mkdirs
import org.eclipse.core.resources.IContainer; //导入方法依赖的package包/类
private static void mkdirs(IFolder destPath) {
IContainer parent = destPath.getParent();
if (! parent.exists()) {
if (parent instanceof IFolder) {
mkdirs((IFolder) parent);
}
else if (parent instanceof IProject) {
mkdirs( ((IProject)parent).getFolder(".") );
}
}
try {
destPath.create(/*force*/true, /*local*/true, Constants.NULL_PROGRESS_MONITOR);
} catch (CoreException e) {
e.printStackTrace();
}
}
示例4: updateProposalContext
import org.eclipse.core.resources.IContainer; //导入方法依赖的package包/类
/**
* This method should be invoked whenever source folder or project value change, to update the proposal contexts for
* the field source folder and module specifier
*/
private void updateProposalContext() {
IPath projectPath = model.getProject();
IPath sourceFolderPath = model.getSourceFolder();
// Early exit for empty project value
if (projectPath.isEmpty()) {
sourceFolderContentProposalAdapter.setContentProposalProvider(null);
moduleSpecifierContentProposalAdapter.setContentProposalProvider(null);
return;
}
IProject project = ResourcesPlugin.getWorkspace().getRoot()
.getProject(projectPath.toString());
if (null == project || !project.exists()) {
// Disable source folder and module specifier proposals
sourceFolderContentProposalAdapter.setContentProposalProvider(null);
moduleSpecifierContentProposalAdapter.setContentProposalProvider(null);
} else {
// Try to retrieve the source folder and if not specified set it to null
IContainer sourceFolder = sourceFolderPath.segmentCount() != 0 ? project.getFolder(sourceFolderPath) : null;
// If the project exists, enable source folder proposals
sourceFolderContentProposalAdapter
.setContentProposalProvider(sourceFolderContentProviderFactory.createProviderForProject(project));
if (null != sourceFolder && sourceFolder.exists()) {
// If source folder exists as well enable module specifier proposal
moduleSpecifierContentProposalAdapter.setContentProposalProvider(
moduleSpecifierContentProviderFactory.createProviderForPath(sourceFolder.getFullPath()));
} else {
// Otherwise disable module specifier proposals
moduleSpecifierContentProposalAdapter.setContentProposalProvider(null);
}
}
}
示例5: 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();
}
示例6: getProposals
import org.eclipse.core.resources.IContainer; //导入方法依赖的package包/类
@Override
public IContentProposal[] getProposals(String contents, int position) {
IContainer proposalRootFolder;
if (null == rootFolder) {
return EMPTY_PROPOSAL;
}
if (rootFolder.isEmpty()) {
proposalRootFolder = ResourcesPlugin.getWorkspace().getRoot();
} else if (rootFolder.segmentCount() == 1) {
proposalRootFolder = ResourcesPlugin.getWorkspace().getRoot().getProject(rootFolder.segment(0));
} else {
proposalRootFolder = findContainerForPath(rootFolder);
}
if (null == proposalRootFolder || !proposalRootFolder.exists()) {
return EMPTY_PROPOSAL;
}
// The field content as path
IPath contentsPath = new Path(contents);
// The directory to look for prefix matches
IPath workingDirectoryPath;
// If the contents path has a trailing separator...
if (contentsPath.hasTrailingSeparator()) {
// Use the full content as working directory path
workingDirectoryPath = contentsPath;
} else {
// Otherwise only use complete segments as working directory
workingDirectoryPath = contentsPath.removeLastSegments(1);
}
IContainer workingDirectory;
if (workingDirectoryPath.segmentCount() > 0) {
workingDirectory = proposalRootFolder.getFolder(workingDirectoryPath);
} else {
workingDirectory = proposalRootFolder;
}
// Return an empty proposal list for non-existing working directories
if (null == workingDirectory || !workingDirectory.exists()) {
return EMPTY_PROPOSAL;
}
try {
return Arrays.asList(workingDirectory.members()).stream()
// Only work with files and folders
.filter(r -> (r instanceof IFile || r instanceof IFolder))
// Filter by prefix matching
.filter(resource -> {
IPath rootRelativePath = resource.getFullPath().makeRelativeTo(rootFolder);
return rootRelativePath.toString().startsWith(contentsPath.toString());
})
// Transform to a ModuleSpecifierProposal
.map(resource -> {
// Create proposal path
IPath proposalPath = resource.getFullPath()
.makeRelativeTo(proposalRootFolder.getFullPath());
// Set the proposal type
ModuleSpecifierProposal.ModuleProposalType type = resource instanceof IFile
? ModuleSpecifierProposal.ModuleProposalType.MODULE
: ModuleSpecifierProposal.ModuleProposalType.FOLDER;
// Create a new module specifier proposal
return ModuleSpecifierProposal.createFromPath(proposalPath, type);
})
.toArray(IContentProposal[]::new);
} catch (CoreException e) {
return EMPTY_PROPOSAL;
}
}