use of org.eclipse.emf.ecore.EPackage in project xtext-eclipse by eclipse.
the class BuilderTestLanguageSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == BuilderTestLanguagePackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case BuilderTestLanguagePackage.ELEMENT:
sequence_Element(context, (Element) semanticObject);
return;
case BuilderTestLanguagePackage.IMPORT:
sequence_Import(context, (Import) semanticObject);
return;
case BuilderTestLanguagePackage.NAMESPACE:
sequence_Namespace(context, (Namespace) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.eclipse.emf.ecore.EPackage in project xtext-eclipse by eclipse.
the class StatemachineSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == StatemachinePackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case StatemachinePackage.COMMAND:
sequence_Command(context, (Command) semanticObject);
return;
case StatemachinePackage.EVENT:
sequence_Event(context, (Event) semanticObject);
return;
case StatemachinePackage.STATE:
sequence_State(context, (State) semanticObject);
return;
case StatemachinePackage.STATEMACHINE:
sequence_Statemachine(context, (Statemachine) semanticObject);
return;
case StatemachinePackage.TRANSITION:
sequence_Transition(context, (Transition) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.eclipse.emf.ecore.EPackage 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.EPackage in project benchmarx by eMoflon.
the class MediniQVTFamiliesToPersonsConfig 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, target and configuration 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();
}
}
// in case, no configuration is set, switch to default
checkConfiguration();
// 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(RESULTPATH + "/source.xmi"));
config = resourceSet.createResource(URI.createURI(RESULTPATH + "/config.xmi"));
target = resourceSet.createResource(URI.createURI(RESULTPATH + "/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(config);
thirdSetOfModels.add(target);
URI directory = URI.createFileURI(basePath + "traces");
this.preExecution(modelResources, directory);
// Call setConfigurator, which will initialize the configurator with default decisions
setConfigurator(new Configurator<Decisions>());
source.getContents().add(FamiliesFactory.eINSTANCE.createFamilyRegister());
config.getContents().add(ConfigFactory.eINSTANCE.createConfiguration());
launchFWD();
}
use of org.eclipse.emf.ecore.EPackage in project benchmarx by eMoflon.
the class ChangeRecorder method WriteFullElement.
private void WriteFullElement(EObject element, String type) {
buffer.append("\t\t<");
buffer.append(type);
buffer.append(" xsi:type=\"");
EClass eClass = element.eClass();
EPackage ePackage = (EPackage) eClass.eContainer();
buffer.append(ePackage.getNsPrefix());
buffer.append(":");
buffer.append(eClass.getName());
buffer.append("\" xmlns:");
buffer.append(ePackage.getNsPrefix());
buffer.append("=\"");
buffer.append(ePackage.getNsURI());
buffer.append("\"");
for (EAttribute att : eClass.getEAllAttributes()) {
if (element.eIsSet(att)) {
Object value = element.eGet(att);
WriteAttribute(att.getName(), toCompatibleString(value));
}
}
buffer.append(" />\n");
this.RegisterNewElement(element, this.changeCounter, type);
}
Aggregations