本文整理汇总了Java中org.eclipse.emf.common.util.URI.createFileURI方法的典型用法代码示例。如果您正苦于以下问题:Java URI.createFileURI方法的具体用法?Java URI.createFileURI怎么用?Java URI.createFileURI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.common.util.URI
的用法示例。
在下文中一共展示了URI.createFileURI方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findProjectsForSingleFiles
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
* Collects the projects containing the given single source files.
*
* @param sourceFiles
* the list of single source files
* @return list of N4JS project locations
* @throws N4JSCompileException
* if no project cannot be found for one of the given files
*/
private List<File> findProjectsForSingleFiles(List<File> sourceFiles)
throws N4JSCompileException {
Set<URI> result = Sets.newLinkedHashSet();
for (File sourceFile : sourceFiles) {
URI sourceFileURI = URI.createFileURI(sourceFile.toString());
URI projectURI = n4jsFileBasedWorkspace.findProjectWith(sourceFileURI);
if (projectURI == null) {
throw new N4JSCompileException("No project for file '" + sourceFile.toString() + "' found.");
}
result.add(projectURI);
}
// convert back to Files:
return result.stream().map(u -> new File(u.toFileString())).collect(Collectors.toList());
}
示例2: registerProjects
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
* Configure fbWorkspace with all projects found in Subfolders of projectLocations.
*
* @param projectLocations
* list of project roots
* @param n4jsFileBasedWorkspace
* instance of FileBasedWorkspace to configure (in N4JS injector)
* @throws N4JSCompileException
* in error Case.
*/
public static void registerProjects(List<File> projectLocations, FileBasedWorkspace n4jsFileBasedWorkspace)
throws N4JSCompileException {
// make absolute, since downstream URI conversion doesn't work if relative dir only.
List<File> absProjectRoots = HeadlessHelper.toAbsoluteFileList(projectLocations);
// Collect all Projects in first Level
ArrayList<File> pDir = HeadlessHelper.collectAllProjectPaths(absProjectRoots);
ArrayList<URI> projectURIs = new ArrayList<>(pDir.size());
for (File pdir : pDir) {
URI puri = URI.createFileURI(pdir.toString());
projectURIs.add(puri);
try {
n4jsFileBasedWorkspace.registerProject(puri);
} catch (N4JSBrokenProjectException e) {
throw new N4JSCompileException("Unable to register project '" + puri + "'", e);
}
}
}
示例3: getEcoreModel
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
protected ResourceSet getEcoreModel(File ecorefile) {
ResourceSetImpl rs = new ResourceSetImpl();
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
try {
URI fileUri = URI.createFileURI(ecorefile.getCanonicalPath());
Resource resource = rs.createResource(fileUri);
resource.load(null);
EcoreUtil.resolveAll(resource);
rs.getResources().add(resource);
EcoreUtil.resolveAll(rs);
} catch (IOException e) {
e.printStackTrace();
}
return rs;
}
示例4: loadGexpressionTestFile
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
public static void loadGexpressionTestFile() {
// Getting the serializer
GExpressionsStandaloneSetup setup = new GExpressionsStandaloneSetup();
Injector injector = setup.createInjectorAndDoEMFRegistration();
GexpressionsPackage.eINSTANCE.eClass();
Serializer serializer = injector.getInstance(Serializer.class);
// Load the model
URI modelURI = URI
.createFileURI("/home/flatombe/thesis/gemoc/git/gemoc-dev/org/eclipse/gemoc/GEL/org.eclipse.gemoc.gel.gexpressions.test/model/test.gexpressions");
XtextResourceSet resSet = injector.getInstance(XtextResourceSet.class);
resSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
Resource resource = resSet.getResource(modelURI, true);
GProgram program = (GProgram) resource.getContents().get(0);
List<GExpression> exps = program.getExpressions();
for (GExpression exp : exps) {
// Serializing
String s = serializer.serialize(exp);
System.out.println(s);
}
}
示例5: generateDesignProject
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
private IProject generateDesignProject(String occieLocation, String designName, String designProjectName,
final IProgressMonitor monitor) throws CoreException, IOException {
// Load the ecore file.
String ecoreLocation = occieLocation.replace(".occie", ".ecore");
URI ecoreURI = URI.createFileURI(ecoreLocation);
// Create a new resource set.
ResourceSet resourceSet = new ResourceSetImpl();
// Load the OCCI resource.
org.eclipse.emf.ecore.resource.Resource resource = resourceSet.getResource(ecoreURI, true);
// Return the first element.
EPackage ePackage = (EPackage) resource.getContents().get(0);
String extensionScheme = Occi2Ecore.convertEcoreNamespace2OcciScheme(ePackage.getNsURI());
// Register the ePackage to avoid an error when trying to open the generated
// .odesign file,
EPackage.Registry.INSTANCE.put(ePackage.getNsURI(), ePackage);
URI occieURI = URI.createFileURI(occieLocation);
/*
* Create design project
*/
IProject project = DesignerGeneratorUtils.genDesignProject(designProjectName, designName, extensionScheme,
new ProgressMonitorDialog(shell));
/*
* Create design model
*/
org.eclipse.cmf.occi.core.gen.design.main.Generate generator = new org.eclipse.cmf.occi.core.gen.design.main.Generate(
occieURI, project.getFolder("description").getLocation().toFile(), new ArrayList<String>());
generator.doGenerate(BasicMonitor.toMonitor(monitor));
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
return project;
}
示例6: internalGetUri
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
private URI internalGetUri(IStorage storage) {
if (storage instanceof IFile) {
if (storage instanceof ExternalFile) {
final File externalResource = ((ExternalFile) storage).getExternalResource();
if (externalResource.exists() && externalResource.isFile()) {
return URI.createFileURI(externalResource.getAbsolutePath());
}
} else {
return URI.createPlatformResourceURI(storage.getFullPath().toString(), true);
}
}
return null;
}
示例7: findArtifactInFolder
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public URI findArtifactInFolder(URI folderLocation, String folderRelativePath) {
ensureInitialized();
final IResource folder = getResource(folderLocation);
if (folder instanceof IFolder) {
final IFile file = ((IFolder) folder).getFile(folderRelativePath);
if (file instanceof IExternalResource) {
final File externalResource = ((IExternalResource) file).getExternalResource();
return URI.createFileURI(externalResource.getAbsolutePath());
}
}
return null;
}
示例8: generateDesignProject
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
private IProject generateDesignProject(String occieLocation, String designName, String designProjectName,
final IProgressMonitor monitor) throws CoreException, IOException {
// Load the ecore file.
String ecoreLocation = occieLocation.replace(".occie", ".ecore");
URI ecoreURI = URI.createFileURI(ecoreLocation);
// Create a new resource set.
ResourceSet resourceSet = new ResourceSetImpl();
// Load the OCCI resource.
org.eclipse.emf.ecore.resource.Resource resource = resourceSet.getResource(ecoreURI, true);
// Return the first element.
EPackage ePackage = (EPackage) resource.getContents().get(0);
String extensionScheme = Occi2Ecore.convertEcoreNamespace2OcciScheme(ePackage.getNsURI());
// Register the ePackage to avoid an error when trying to open the generated
// .odesign file,
EPackage.Registry.INSTANCE.put(ePackage.getNsURI(), ePackage);
URI occieURI = URI.createFileURI(occieLocation);
/*
* Create design project
*/
IProject project = DesignerGeneratorUtils.genDesignProject(designProjectName, designName, extensionScheme,
new ProgressMonitorDialog(shell));
/*
* Create design model
*/
org.eclipse.cmf.occi.core.gen.design.extended.main.Generate generator = new org.eclipse.cmf.occi.core.gen.design.extended.main.Generate(
occieURI, project.getFolder("description").getLocation().toFile(), new ArrayList<String>());
generator.doGenerate(BasicMonitor.toMonitor(monitor));
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
return project;
}
示例9: build
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
public void build() {
Map<String, String> env = System.getenv();
String changeSet = env.get("ChangeSet");
String changePath = env.get("ChangePath");
String runIndex = env.get("RunIndex");
int sequenceLength = Integer.parseInt(env.get("Sequences"));
long start = System.nanoTime();
this.rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
this.rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
EPackage.Registry.INSTANCE.put(CIM.CIMPackage.eINSTANCE.getNsURI(), CIM.CIMPackage.eINSTANCE);
EPackage.Registry.INSTANCE.put(substationStandard.SubstationStandardPackage.eINSTANCE.getNsURI(), substationStandard.SubstationStandardPackage.eINSTANCE);
EPackage.Registry.INSTANCE.put(COSEM.COSEMPackage.eINSTANCE.getNsURI(), COSEM.COSEMPackage.eINSTANCE);
EPackage.Registry.INSTANCE.put(outageDetectionJointarget.OutageDetectionJointargetPackage.eINSTANCE.getNsURI(), outageDetectionJointarget.OutageDetectionJointargetPackage.eINSTANCE);
EPackage.Registry.INSTANCE.put(outageDetectionMjtrace.OutageDetectionMjtracePackage.eINSTANCE.getNsURI(), outageDetectionMjtrace.OutageDetectionMjtracePackage.eINSTANCE);
EPackage.Registry.INSTANCE.put(outagePreventionJointarget.OutagePreventionJointargetPackage.eINSTANCE.getNsURI(), outagePreventionJointarget.OutagePreventionJointargetPackage.eINSTANCE);
EPackage.Registry.INSTANCE.put(outagePreventionMjtrace.OutagePreventionMjtracePackage.eINSTANCE.getNsURI(), outagePreventionMjtrace.OutagePreventionMjtracePackage.eINSTANCE);
URI txURI = URI.createFileURI(new File("transformations/" + this.transformation + ".qvto").getAbsolutePath());
TransformationExecutor executor = new TransformationExecutor(txURI);
ExecutionContextImpl context = new ExecutionContextImpl();
context.setConfigProperty("keepModeling", true);
OutputStreamWriter outStream = new OutputStreamWriter(System.err);
Log log = new WriterLog(outStream);
context.setLog(log);
long end = System.nanoTime();
System.out.println("ModelJoin;" + this.transformation + ";" + changeSet + ";" + runIndex + ";;Loading;Time;" + Long.toString(end-start));
this.runIteration(changePath + "/CIM_DCIM-out000.xmi",
changePath + "/COSEM-out000.xmi",
changePath + "/Substandard-out000.xmi",
0, changeSet, runIndex, "Initial", executor, context);
for (int i = 1; i <= sequenceLength; i++) {
this.runIteration(changePath + String.format("/CIM_DCIM-out%03d.xmi", i),
changePath + String.format("/COSEM-out%03d.xmi", i),
changePath + String.format("/Substandard-out%03d.xmi", i),
i, changeSet, runIndex, "Update", executor, context);
}
}
示例10: toURI
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
private static final URI toURI(File file) {
return URI.createFileURI(file.getAbsolutePath());
}
示例11: fullTest
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unused")
protected void fullTest(String projectId)
throws IOException, InterruptedException, InterruptedException {
String systemSeparator = System.getProperty("line.separator", "\n");
try {
for (String lsep : new String[] { "\n", "\r\n", "\r" }) {
System.setProperty("line.separator", lsep);
String expectationFileName = projectId + "/expected.adoc";
workspace = new FileBasedWorkspace(resourceSetProvider, classpathPackageManager);
URI uriProject = URI.createFileURI(new File(TESTRESOURCES + projectId).getAbsolutePath());
workspace.registerProject(uriProject);
N4JSModel model = new N4JSModel(workspace);
injector.injectMembers(model);
runtimeCore = new N4JSRuntimeCore(workspace, model);
IN4JSProject project = runtimeCore.findProject(uriProject).get();
assertNotNull("Project not found", project);
Collection<SpecFile> specChangeSet = jSDoc2SpecProcessor.convert(
new File(TESTRESOURCES),
Collections.singleton(project),
(p) -> resourceSetProvider.get(),
SubMonitorMsg.nullProgressMonitor());
String adocRootName = TESTRESOURCES + projectId + "/expectedADoc";
List<String> expectedFileNames = getExpectedFileNames(adocRootName, specChangeSet);
assertFalse(expectedFileNames.isEmpty());
File adocRoot = new File(adocRootName);
String completeActual = "";
String completeExpected = "";
for (SpecFile specFile : specChangeSet) {
String fileName = specFile.getFile().getName().toString();
if (!expectedFileNames.contains(fileName))
continue;
String fullExpectationFileName = adocRoot.toPath().resolve(fileName).toString();
String expectedADoc = Files.readFileIntoString(fullExpectationFileName);
String actualADoc = specFile.getNewContent();
if (UPDATE_EXPECTION && !actualADoc.equals(expectedADoc)) {
expectedADoc = actualADoc;
Files.writeStringIntoFile(fullExpectationFileName, expectedADoc);
System.out.println("Updated expectation " + fullExpectationFileName);
}
completeActual += "\n//////// " + fileName + " ////////\n";
completeActual += actualADoc;
completeExpected += "\n//////// " + fileName + " ////////\n";
completeExpected += expectedADoc;
}
assertEqualsIgnoreWS(completeExpected, completeActual);
}
} finally {
System.setProperty("line.separator", systemSeparator);
}
}
示例12: main
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
* This can be used to launch the generation from a standalone application.
*
* @param args
* Arguments of the generation.
* @generated
*/
public static void main(String[] args) {
try {
if (args.length < 2) {
System.out.println("Arguments not valid : {model, folder}.");
} else {
URI modelURI = URI.createFileURI(args[0]);
File folder = new File(args[1]);
List<String> arguments = new ArrayList<String>();
/*
* If you want to change the content of this method, do NOT forget to change the "@generated"
* tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
* of the Acceleo module with the main template that has caused the creation of this class will
* revert your modifications.
*/
/*
* Add in this list all the arguments used by the starting point of the generation
* If your main template is called on an element of your model and a String, you can
* add in "arguments" this "String" attribute.
*/
Generate generator = new Generate(modelURI, folder, arguments);
/*
* Add the properties from the launch arguments.
* If you want to programmatically add new properties, add them in "propertiesFiles"
* You can add the absolute path of a properties files, or even a project relative path.
* If you want to add another "protocol" for your properties files, please override
* "getPropertiesLoaderService(AcceleoService)" in order to return a new property loader.
* The behavior of the properties loader service is explained in the Acceleo documentation
* (Help -> Help Contents).
*/
for (int i = 2; i < args.length; i++) {
generator.addPropertiesFile(args[i]);
}
generator.doGenerate(new BasicMonitor());
}
} catch (IOException e) {
e.printStackTrace();
}
}
示例13: getUri
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
public static URI getUri() {
return URI.createFileURI(AlloyUtilities.getLocation());
}
示例14: main
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
* This can be used to launch the generation from a standalone application.
*
* @param args
* Arguments of the generation.
* @generated
*/
public static void main(String[] args) {
try {
if (args.length < 2) {
System.out.println("Arguments not valid : {model, folder}.");
} else {
URI modelURI = URI.createFileURI(args[0]);
File folder = new File(args[1]);
List<String> arguments = new ArrayList<String>();
/*
* If you want to change the content of this method, do NOT forget to change the "@generated"
* tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
* of the Acceleo module with the main template that has caused the creation of this class will
* revert your modifications.
*/
/*
* Add in this list all the arguments used by the starting point of the generation
* If your main template is called on an element of your model and a String, you can
* add in "arguments" this "String" attribute.
*/
Content generator = new Content(modelURI, folder, arguments);
/*
* Add the properties from the launch arguments.
* If you want to programmatically add new properties, add them in "propertiesFiles"
* You can add the absolute path of a properties files, or even a project relative path.
* If you want to add another "protocol" for your properties files, please override
* "getPropertiesLoaderService(AcceleoService)" in order to return a new property loader.
* The behavior of the properties loader service is explained in the Acceleo documentation
* (Help -> Help Contents).
*/
for (int i = 2; i < args.length; i++) {
generator.addPropertiesFile(args[i]);
}
generator.doGenerate(new BasicMonitor());
}
} catch (IOException e) {
e.printStackTrace();
}
}
示例15: main
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
* This can be used to launch the generation from a standalone application.
*
* @param args
* Arguments of the generation.
* @generated
*/
public static void main ( String[] args )
{
try {
if (args.length < 2) {
System.out.println("Arguments not valid : {model, folder}.");
} else {
URI modelURI = URI.createFileURI(args[0]);
File folder = new File(args[1]);
List<String> arguments = new ArrayList<String>();
/*
* If you want to change the content of this method, do NOT forget to change the "@generated"
* tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
* of the Acceleo module with the main template that has caused the creation of this class will
* revert your modifications.
*/
/*
* Add in this list all the arguments used by the starting point of the generation
* If your main template is called on an element of your model and a String, you can
* add in "arguments" this "String" attribute.
*/
GenerateCodec generator = new GenerateCodec(modelURI, folder, arguments);
/*
* Add the properties from the launch arguments.
* If you want to programmatically add new properties, add them in "propertiesFiles"
* You can add the absolute path of a properties files, or even a project relative path.
* If you want to add another "protocol" for your properties files, please override
* "getPropertiesLoaderService(AcceleoService)" in order to return a new property loader.
* The behavior of the properties loader service is explained in the Acceleo documentation
* (Help -> Help Contents).
*/
for (int i = 2; i < args.length; i++) {
generator.addPropertiesFile(args[i]);
}
generator.doGenerate(new BasicMonitor());
}
} catch (IOException e) {
e.printStackTrace();
}
}