本文整理汇总了Java中org.eclipse.emf.common.util.URI.toPlatformString方法的典型用法代码示例。如果您正苦于以下问题:Java URI.toPlatformString方法的具体用法?Java URI.toPlatformString怎么用?Java URI.toPlatformString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.common.util.URI
的用法示例。
在下文中一共展示了URI.toPlatformString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadManifest
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
ProjectDescription loadManifest(URI manifest) {
try {
ProjectDescription result = null;
ResourceSet resourceSet = resourceSetProvider.get(null /* we don't care about the project right now */);
String platformPath = manifest.toPlatformString(true);
if (manifest.isArchive() || platformPath != null) {
if (manifest.isArchive() || workspace.getFile(new Path(platformPath)).exists()) {
Resource resource = resourceSet.getResource(manifest, true);
if (resource != null) {
List<EObject> contents = resource.getContents();
if (contents.isEmpty() || !(contents.get(0) instanceof ProjectDescription)) {
return null;
}
result = (ProjectDescription) contents.get(0);
contents.clear();
}
}
}
return result;
} catch (WrappedException e) {
throw new IllegalStateException("Unexpected manifest URI: " + manifest, e);
}
}
示例2: showInstruction
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
* Show the given {@link EObject instruction}.
*
* @param editorPart
* the opened {@link DialectEditor}
* @param instruction
* the {@link EObject instruction} to show
*/
public static void showInstruction(DialectEditor editorPart, EObject instruction) {
final URI resourceURI = instruction.eResource().getURI();
if (resourceURI.isPlatformResource()) {
final String resourcePath = resourceURI.toPlatformString(true);
final IResource resource = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(
resourcePath));
try {
final IMarker marker = resource.createMarker(EValidator.MARKER);
marker.setAttribute(EValidator.URI_ATTRIBUTE, EcoreUtil.getURI(instruction).toString());
final TraceabilityMarkerNavigationProvider navigationProvider = new TraceabilityMarkerNavigationProvider(
(DialectEditor)editorPart);
navigationProvider.gotoMarker(marker);
marker.delete();
} catch (CoreException e) {
DebugSiriusIdeUiPlugin.INSTANCE.log(e);
}
}
}
示例3: getIFile
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
* Getting an IFile from an EMF Resource
*
* @param eObject
* @return
*/
public static IFile getIFile(Resource res) {
URI uri = res.getURI();
String filePath = uri.toPlatformString(true);
IFile ifile = ResourcesPlugin.getWorkspace().getRoot()
.getFile(new Path(filePath));
return ifile;
}
示例4: assertResourceDescriptions
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
* Checks if expected list of stringified file locations matches
*
* @param expected
* collection of entries
* @param actual
* collection of entries
*/
public void assertResourceDescriptions(Collection<String> expected, Iterable<IResourceDescription> actual) {
Set<String> extraDescriptions = new HashSet<>();
Set<String> missingDescriptions = new HashSet<>(expected);
for (IResourceDescription iResourceDescription : actual) {
URI uri = iResourceDescription.getURI();
String stringUri = uri.isPlatform() ? uri.toPlatformString(false) : uri.toFileString();
if (!missingDescriptions.contains(stringUri)) {
extraDescriptions.add(stringUri);
} else {
missingDescriptions.remove(stringUri);
}
}
if (missingDescriptions.isEmpty() && extraDescriptions.isEmpty()) {
return;
}
StringBuilder msg = new StringBuilder("unexpected actual resources" + "\n");
if (!extraDescriptions.isEmpty()) {
msg.append("actual contains " + extraDescriptions.size() + " extra resources" + "\n");
}
if (!missingDescriptions.isEmpty()) {
msg.append("actual is missing " + missingDescriptions.size() + " expected resources" + "\n");
}
for (String extra : extraDescriptions) {
msg.append("[extra] " + extra + "\n");
}
for (String missing : missingDescriptions) {
msg.append("[missing] " + missing + "\n");
}
fail(msg.toString());
}
示例5: findArtifactInFolder
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public URI findArtifactInFolder(URI folderLocation, String folderRelativePath) {
final String folderLocationString = folderLocation.toPlatformString(true);
if (null != folderLocationString) {
final IFolder folder = workspace.getFolder(new Path(folderLocationString));
final String subPathStr = folderRelativePath.replace(File.separator, "/");
final IPath subPath = new Path(subPathStr);
final IFile file = folder != null ? folder.getFile(subPath) : null;
if (file != null && file.exists()) {
return folderLocation.appendSegments(subPathStr.split("/"));
}
}
return null;
}
示例6: initializeFrom
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
* From the configuration to the UI widgets.
*
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
*/
@Override
public void initializeFrom(ILaunchConfiguration configuration) {
try {
final String uriStr = configuration.getAttribute(getResourceRunConfigKey(), "");
final URI uri = uriStr.trim().length() > 0 ? URI.createURI(uriStr) : null;
final String wsRelativePath = uri != null ? uri.toPlatformString(true) : null;
txtResource.setText(wsRelativePath != null ? wsRelativePath : "");
final String implId = configuration.getAttribute(RunConfiguration.IMPLEMENTATION_ID, "");
txtImplementationId.setText(implId);
} catch (CoreException e) {
setErrorMessage(e.getMessage());
}
}
示例7: getEditorInput
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public IEditorInput getEditorInput(Object element) {
if (element instanceof EObject) {
EObject eObject = (EObject) element;
EObject target = eObject;
Resource res = eObject.eResource();
if(res != null && res.getResourceSet() != null) {
MelangeResourceImpl mr = null;
for(Resource candidate : res.getResourceSet().getResources()) {
if(candidate instanceof MelangeResourceImpl) {
mr = (MelangeResourceImpl) candidate;
break;
}
}
if(mr != null) {
String uriFragment = res.getURIFragment(eObject);
target = mr.getWrappedResource().getEObject(uriFragment);
}
}
Resource r = eObject.eResource();
if (r instanceof XtextResource) {
URI uri = target.eResource().getURI();
if(uri.toPlatformString(true) != null){
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uri.toPlatformString(true)));
IFileEditorInput input = new FileEditorInput(file);
return input;
}
}
else {
//Default
return getPresentation().getEditorInput(eObject);
}
}
return null;
}
示例8: DSLBreakpoint
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param identifier
* the debug model identifier
* @param instruction
* the {@link EObject} representing the instruction
* @param persistent
* should be persisted
* @throws CoreException
* if marker can't be installed
*/
public DSLBreakpoint(String identifier, EObject instruction, boolean persistent) throws CoreException {
super();
this.identifier = identifier;
this.instructionUri = EcoreUtil.getURI(instruction);
final URI resourceURI = ((EObject)instruction).eResource().getURI();
final String pathString = resourceURI.toPlatformString(true);
final IFile resource = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(pathString));
if (resource != null) {
IWorkspaceRunnable runnable = new CreateMarker(resource, instruction, persistent);
run(getMarkerRule(resource), runnable);
}
}
示例9: getFirstEcore
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
public static IFile getFirstEcore(Language lang){
final String ecoreURI = getFirstEcorePath(lang);
if(ecoreURI != null){
final URI uri = org.eclipse.emf.common.util.URI.createURI(ecoreURI);
final String filePath = uri.toPlatformString(true);
final IPath path = new Path(filePath);
return ResourcesPlugin.getWorkspace().getRoot().getFile(path);
}
return null;
}
示例10: toIResource
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
* Returns the equivalent {@linkplain org.eclipse.core.resources.IResource
* Eclipse IResource} for an {@linkplain org.eclipse.emf.common.util.URI Ecore
* URI}, if available.
*
* <p>
* {@code uri} can be represented as IResource if {@code uri} is an
* {@linkplain URI#isPlatformResource() platform resource} (i.e. {@code uri}
* starts with {@code platform:/resource/}). Otherwise, this method returns
* {@code null}.
* </p>
*
* <p>
* This method ignores any {@linkplain URI#fragment() fragment} or
* {@linkplain URI#query() query} of {@code uri}.
* </p>
*
* <p>
* If the resulting IResource exists, this method returns the existing kind of
* IResource ({@linkplain org.eclipse.core.resources.IWorkspaceRoot
* IWorkspaceRoot}, {@linkplain org.eclipse.core.resources.IProject IProject},
* {@linkplain org.eclipse.core.resources.IFolder IFolder}, or
* {@linkplain org.eclipse.core.resources.IFile IFile}).
* </p>
*
* <p>
* If the resulting IResource does not exist, this method returns an IFile
* pointing to the place equivalent to {@code uri}.
* </p>
*
* <p>
* This method handles excess slashes (behind the platform resource identifiers)
* gracefully (i.e. ignores the slashes).<br/>
* Example: An URI of
* {@code platform:/resource/////MyProject///folder///deep/myFile.ext//} leads
* to an IFile for path {@code /MyProject/folder/deep/myFile.ext}.
* </p>
*
* <p>
* <b>Note:</b> This method treats {@code uri} as case-sensitive (on <i>all</i>
* platforms, including Windows). Therefore, if the workspace contained a file
* at {@code /MyProject/myFolder/myFile.ext} and we passed the URI
* {@code platform:/resource/MyProject/myFolder/mYfILE.ext} to this method, the
* result is an IFile for path {@code /MyProject/myFolder/mYfILE.ext}.
* {@link IResource#exists() result.exists()} will return {@code false}.
* </p>
*
* @param uri
* The Ecore URI to return as Eclipse IResource.
* @return {@code uri} as Eclipse IResource, if available; {@code null}
* otherwise.
*
* @throws IllegalArgumentException
* If {@code uri} is seriously ill-formatted.
*
* @since 0.1
*/
public static @Nullable IResource toIResource(final @NonNull URI uri) {
if (uri.isPlatformResource()) {
String platformString = uri.toPlatformString(true);
IPath path = Path.fromOSString(platformString);
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
if (workspaceRoot.exists(path)) {
return workspaceRoot.findMember(path);
} else {
return workspaceRoot.getFile(path);
}
}
return null;
}