use of org.eclipse.emf.ecore.resource.impl.ResourceSetImpl 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;
}
use of org.eclipse.emf.ecore.resource.impl.ResourceSetImpl in project tdi-studio-se by Talend.
the class BusinessInitDiagramFileAction method run.
/**
* @generated NOT
*/
public void run(IAction action) {
TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE.createEditingDomain();
ResourceSet resourceSet = new ResourceSetImpl();
EObject diagramRoot = null;
try {
Resource resource = resourceSet.getResource(URI.createPlatformResourceURI(mySelectedModelFile.getFullPath().toString()), true);
diagramRoot = (EObject) resource.getContents().get(0);
} catch (WrappedException ex) {
BusinessDiagramEditorPlugin.getInstance().logError(Messages.getString("BusinessInitDiagramFileAction.UnableToLoadResource") + mySelectedModelFile.getFullPath().toString(), //$NON-NLS-1$
ex);
}
if (diagramRoot == null) {
MessageDialog.openError(myPart.getSite().getShell(), Messages.getString("BusinessInitDiagramFileAction.Error"), //$NON-NLS-1$ //$NON-NLS-2$
Messages.getString("BusinessInitDiagramFileAction.LoadFaild"));
return;
}
Wizard wizard = new BusinessNewDiagramFileWizard(mySelectedModelFile, myPart.getSite().getPage(), mySelection, diagramRoot, editingDomain);
IDialogSettings pluginDialogSettings = BusinessDiagramEditorPlugin.getInstance().getDialogSettings();
//$NON-NLS-1$
IDialogSettings initDiagramFileSettings = pluginDialogSettings.getSection("InisDiagramFile");
if (initDiagramFileSettings == null) {
//$NON-NLS-1$
initDiagramFileSettings = pluginDialogSettings.addNewSection("InisDiagramFile");
}
wizard.setDialogSettings(initDiagramFileSettings);
wizard.setForcePreviousAndNextButtons(false);
wizard.setWindowTitle(//$NON-NLS-1$ //$NON-NLS-2$
Messages.getString("BusinessInitDiagramFileAction.IntialNew") + BusinessProcessEditPart.MODEL_ID + Messages.getString("BusinessInitDiagramFileAction.DiagramFile"));
WizardDialog dialog = new WizardDialog(myPart.getSite().getShell(), wizard);
dialog.create();
dialog.getShell().setSize(Math.max(500, dialog.getShell().getSize().x), 500);
dialog.open();
}
use of org.eclipse.emf.ecore.resource.impl.ResourceSetImpl in project benchmarx by eMoflon.
the class EMoflonFamiliesToPersons method saveModels.
public void saveModels(String name) {
ResourceSet set = new ResourceSetImpl();
set.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
URI srcURI = URI.createFileURI(RESULTPATH + "/" + name + "Family.xmi");
URI trgURI = URI.createFileURI(RESULTPATH + "/" + name + "Person.xmi");
Resource resSource = set.createResource(srcURI);
Resource resTarget = set.createResource(trgURI);
EObject colSource = EcoreUtil.copy(getSourceModel());
EObject colTarget = EcoreUtil.copy(getTargetModel());
resSource.getContents().add(colSource);
resTarget.getContents().add(colTarget);
try {
resSource.save(null);
resTarget.save(null);
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.eclipse.emf.ecore.resource.impl.ResourceSetImpl in project benchmarx by eMoflon.
the class MediniQVTFamiliesToPersons method initiateSynchronisationDialogue.
/**
* Initiates a synchronization between a source and a target model. The medini QVT engine is initialized,
* the required metamodels are registered and empty source and target models are created.
* Finally a FamilyRegister is added to the source model and an initial forward transformation is issued
* to create a corresponding PersonRegister.
*/
@Override
public void initiateSynchronisationDialogue() {
// delete content of traces folder
File tracesFolder = new File("./src/org/benchmarx/examples/familiestopersons/implementations/medini/base/traces");
final File[] files = tracesFolder.listFiles();
if (files != null) {
for (File f : files) {
if (f != null)
f.delete();
}
}
// Initialise resource set of models
this.resourceSet = new ResourceSetImpl();
this.resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
// Collect all necessary packages from the metamodel(s)
Collection<EPackage> metaPackages = new ArrayList<EPackage>();
this.collectMetaModels(metaPackages);
// Make these packages known to the QVT engine
init(metaPackages);
// Create resources for models
source = resourceSet.createResource(URI.createURI("source.xmi"));
target = resourceSet.createResource(URI.createURI("target.xmi"));
// Collect the models, which should participate in the transformation.
// You can provide a list of models for each direction.
// The models must be added in the same order as defined in your transformation!
Collection<Collection<Resource>> modelResources = new ArrayList<Collection<Resource>>();
Collection<Resource> firstSetOfModels = new ArrayList<Resource>();
Collection<Resource> secondSetOfModels = new ArrayList<Resource>();
Collection<Resource> thirdSetOfModels = new ArrayList<Resource>();
modelResources.add(firstSetOfModels);
modelResources.add(secondSetOfModels);
modelResources.add(thirdSetOfModels);
firstSetOfModels.add(source);
secondSetOfModels.add(target);
URI directory = URI.createFileURI(basePath + "traces");
this.preExecution(modelResources, directory);
source.getContents().add(FamiliesFactory.eINSTANCE.createFamilyRegister());
launchFWD();
}
use of org.eclipse.emf.ecore.resource.impl.ResourceSetImpl in project benchmarx by eMoflon.
the class MediniQVTFamiliesToPersons method saveModels.
/**
* Allows to save the current state of the source and target models
*
* @param name : Filename
*/
public void saveModels(String name) {
ResourceSet set = new ResourceSetImpl();
set.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
URI srcURI = URI.createFileURI(RESULTPATH + "/" + name + "Family.xmi");
URI trgURI = URI.createFileURI(RESULTPATH + "/" + name + "Person.xmi");
Resource resSource = set.createResource(srcURI);
Resource resTarget = set.createResource(trgURI);
EObject colSource = EcoreUtil.copy(getSourceModel());
EObject colTarget = EcoreUtil.copy(getTargetModel());
resSource.getContents().add(colSource);
resTarget.getContents().add(colTarget);
try {
resSource.save(null);
resTarget.save(null);
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations