本文整理汇总了Java中org.eclipse.emf.common.util.URI.isFile方法的典型用法代码示例。如果您正苦于以下问题:Java URI.isFile方法的具体用法?Java URI.isFile怎么用?Java URI.isFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.common.util.URI
的用法示例。
在下文中一共展示了URI.isFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getN4JSProject
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public N4JSEclipseProject getN4JSProject(URI location) {
checkArgument(
location.isPlatformResource() || location.isFile(),
"Expected either platform:/resource or file:/ URI. Was: " + location);
if (location.isPlatformResource() && location.segmentCount() != DIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT) {
checkArgument(
DIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT == location.segmentCount(),
"Expected 2 segment counts for platform resource URI. Was " + location.segmentCount());
}
final String projectName = location.lastSegment();
final IProject project;
if (location.isFile()) {
project = externalLibraryWorkspace.getProject(projectName);
checkNotNull(project, "Project does not exist in external workspace. URI: " + location);
} else {
project = workspace.getProject(projectName);
}
return doGetN4JSProject(project, location);
}
示例2: findSelection
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public IStructuredSelection findSelection(final IEditorInput input) {
final IStructuredSelection selection = super.findSelection(input);
if (null == selection || selection.isEmpty() && input instanceof XtextReadonlyEditorInput) {
try {
final IStorage storage = ((XtextReadonlyEditorInput) input).getStorage();
if (storage instanceof URIBasedStorage) {
final URI uri = ((URIBasedStorage) storage).getURI();
if (uri.isFile()) {
final File file = new File(uri.toFileString());
if (file.exists() && file.isFile()) {
final Node node = getResourceNode(file);
if (null != node) {
return new StructuredSelection(node);
}
}
}
}
} catch (final CoreException e) {
LOGGER.error("Error while extracting storage from read-only Xtext editor input.", e);
return EMPTY;
}
}
return selection;
}
示例3: tryFindProjectRecursivelyByManifest
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
private URI tryFindProjectRecursivelyByManifest(URI location, Optional<URI> stopUri) {
URI nestedLocation = location;
int segmentCount = 0;
if (nestedLocation.isFile()) { // Here, unlike java.io.File, #isFile can mean directory as well.
File directory = new File(nestedLocation.toFileString());
while (directory != null) {
if (stopUri.isPresent() && stopUri.get().equals(nestedLocation)) {
break;
}
if (directory.isDirectory()) {
if (new File(directory, IN4JSProject.N4MF_MANIFEST).exists()) {
URI projectLocation = URI.createFileURI(directory.getAbsolutePath());
registerProject(projectLocation);
return projectLocation;
}
}
nestedLocation = nestedLocation.trimSegments(segmentCount++);
directory = directory.getParentFile();
}
}
return null;
}
示例4: load
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public Optional<Pair<ExternalProject, ProjectDescription>> load(final URI rootLocation) throws Exception {
if (null != rootLocation && rootLocation.isFile()) {
final File projectRoot = new File(rootLocation.toFileString());
if (projectRoot.exists() && projectRoot.isDirectory()) {
final URI manifestLocation = rootLocation.appendSegment(IN4JSProject.N4MF_MANIFEST);
final ProjectDescription projectDescription = packageManager.loadManifest(manifestLocation);
if (null != projectDescription) {
final ExternalProject project = new ExternalProject(projectRoot, NATURE_ID, BUILDER_ID);
return Optional.of(Tuples.create(project, projectDescription));
}
}
}
return Optional.absent();
}
示例5: findProjectWith
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public URI findProjectWith(URI nestedLocation) {
final String path = nestedLocation.toFileString();
if (null == path) {
return null;
}
final File nestedResource = new File(path);
if (!nestedResource.exists()) {
return null;
}
final Path nestedResourcePath = nestedResource.toPath();
final Iterable<URI> registeredProjectUris = projectCache.asMap().keySet();
for (final URI projectUri : registeredProjectUris) {
if (projectUri.isFile()) {
final File projectRoot = new File(projectUri.toFileString());
final Path projectRootPath = projectRoot.toPath();
if (nestedResourcePath.startsWith(projectRootPath)) {
return projectUri;
}
}
}
return null;
}
示例6: isExternalLocation
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
* Check if the {@link URI URI} argument represents an external library location or not.
*
* @param uri
* to check whether external location or not.
* @return {@code true} if the argument points to an external library location, otherwise {@code false}.
*/
public boolean isExternalLocation(final URI uri) {
if (null != uri && uri.isFile()) {
final IN4JSProject project = core.findProject(uri).orNull();
return null != project && project.exists() && project.isExternal();
}
return false;
}