use of org.eclipse.emf.ecore.resource.Resource in project coffeescript-eclipse by adamschmideg.
the class Main method runGenerator.
protected void runGenerator(String string) {
// load the resource
ResourceSet set = resourceSetProvider.get();
Resource resource = set.getResource(URI.createURI(string), true);
// validate the resource
List<Issue> list = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl);
if (!list.isEmpty()) {
for (Issue issue : list) {
System.err.println(issue);
}
return;
}
// configure and start the generator
fileAccess.setOutputPath("src-gen/");
generator.doGenerate(resource, fileAccess);
System.out.println("Code generation finished.");
}
use of org.eclipse.emf.ecore.resource.Resource in project mechanoid by robotoworks.
the class NewMechanoidOpsFileWizard method createElementResource.
@Override
protected IResource createElementResource(IProgressMonitor monitor, IPath path) {
try {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask(Messages.NewMechanoidOpsFileWizard_Progress_Message, 1);
URI newEmfResourceURI = URI.createURI(//$NON-NLS-1$
"platform:/resource" + path.toPortableString());
Resource emfResource = mResourceSet.createResource(newEmfResourceURI);
Model model = OpServiceModelFactory.eINSTANCE.createModel();
model.setPackageName(mSelectedPackageName);
emfResource.getContents().add(model);
ServiceBlock service = (ServiceBlock) OpServiceModelFactory.eINSTANCE.createServiceBlock();
service.setName(mSelectedElementName);
model.setService(service);
emfResource.save(Collections.EMPTY_MAP);
IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(newEmfResourceURI.toPlatformString(true));
monitor.worked(1);
return resource;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of org.eclipse.emf.ecore.resource.Resource in project mechanoid by robotoworks.
the class NewMechanoidNetFileWizard method createElementResource.
@Override
protected IResource createElementResource(IProgressMonitor monitor, IPath path) {
try {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask(Messages.NewMechanoidNetFileWizard_Progress_Message, 1);
URI newEmfResourceURI = URI.createURI(//$NON-NLS-1$
"platform:/resource" + path.toPortableString());
Resource emfResource = mResourceSet.createResource(newEmfResourceURI);
Model model = NetModelFactory.eINSTANCE.createModel();
model.setPackageName(mSelectedPackageName);
emfResource.getContents().add(model);
Client client = (Client) NetModelFactory.eINSTANCE.createClient();
client.setName(mSelectedElementName);
if (!Strings.isNullOrEmpty(mSelectedBaseUrl)) {
client.setBaseUrl(mSelectedBaseUrl);
}
model.getDeclarations().add(client);
emfResource.save(Collections.EMPTY_MAP);
IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(newEmfResourceURI.toPlatformString(true));
monitor.worked(1);
return resource;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of org.eclipse.emf.ecore.resource.Resource in project tdi-studio-se by Talend.
the class ComponentsFactory method loadComponentResource.
/**
* DOC guanglong.du Comment method "loadComponentResource".
*
* @param eclipseProject
* @return
* @throws IOException
*/
private ComponentsCache loadComponentResource(String installLocation) throws IOException {
String filePath = ComponentsFactory.TALEND_COMPONENT_CACHE + LanguageManager.getCurrentLanguage().toString().toLowerCase() + ComponentsFactory.TALEND_FILE_NAME;
URI uri = URI.createFileURI(installLocation).appendSegment(filePath);
ComponentCacheResourceFactoryImpl compFact = new ComponentCacheResourceFactoryImpl();
Resource resource = compFact.createResource(uri);
Map optionMap = new HashMap();
optionMap.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
optionMap.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
optionMap.put(XMLResource.OPTION_USE_PARSER_POOL, new XMLParserPoolImpl());
optionMap.put(XMLResource.OPTION_USE_XML_NAME_TO_FEATURE_MAP, new HashMap());
optionMap.put(XMLResource.OPTION_USE_DEPRECATED_METHODS, Boolean.FALSE);
resource.load(optionMap);
ComponentsCache cache = (ComponentsCache) EcoreUtil.getObjectByType(resource.getContents(), ComponentCachePackage.eINSTANCE.getComponentsCache());
return cache;
}
use of org.eclipse.emf.ecore.resource.Resource in project tdi-studio-se by Talend.
the class DiagramResourceManager method createResource.
private Resource createResource(IFile file) {
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.getResource(URI.createPlatformResourceURI(file.getFullPath().toString()), true);
return resource;
}
Aggregations