Added a model mutation scheme.

This commit is contained in:
Anish Bhobe 2024-07-31 17:20:03 +02:00
parent ac72ac79d4
commit 53ca7ea590
50 changed files with 5580 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.class

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>fr.tpt.mem4csd.loss.modelMutation.edit</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@ -0,0 +1,18 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: fr.tpt.mem4csd.loss.modelMutation.edit;singleton:=true
Automatic-Module-Name: fr.tpt.mem4csd.loss.modelMutation.edit
Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: mutator.provider.MutatorEditPlugin$Implementation
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-17
Export-Package: mutator.provider
Require-Bundle: org.eclipse.core.runtime,
fr.tpt.mem4csd.loss.modelMutation;visibility:=reexport,
org.eclipse.emf.edit;visibility:=reexport,
de.mdelab.workflow;visibility:=reexport,
de.mdelab.workflow.edit;visibility:=reexport
Bundle-ActivationPolicy: lazy

View File

@ -0,0 +1,10 @@
#
bin.includes = .,\
icons/,\
META-INF/,\
plugin.xml,\
plugin.properties
jars.compile.order = .
source.. = src/
output.. = bin/

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

View File

@ -0,0 +1,24 @@
#
pluginName = fr.tpt.mem4csd.loss.modelMutation Edit Support
providerName = www.example.org
_UI_CreateChild_text = {0}
_UI_CreateChild_text2 = {1} {0}
_UI_CreateChild_text3 = {1}
_UI_CreateChild_tooltip = Create New {0} Under {1} Feature
_UI_CreateChild_description = Create a new child of type {0} for the {1} feature of the selected {2}.
_UI_CreateSibling_description = Create a new sibling of type {0} for the selected {2}, under the {1} feature of their parent.
_UI_PropertyDescriptor_description = The {0} of the {1}
_UI_RandomMutateModel_type = Random Mutate Model
_UI_Unknown_type = Object
_UI_Unknown_datatype= Value
_UI_RandomMutateModel_srcModelSlot_feature = Src Model Slot
_UI_RandomMutateModel_dstModelSlot_feature = Dst Model Slot
_UI_Unknown_feature = Unspecified
_UI_RandomMutateModel_modelSlot_feature = Model Slot

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<!--
-->
<plugin>
<extension point="org.eclipse.emf.edit.itemProviderAdapterFactories">
<!-- @generated Mutator -->
<factory
uri="http://mem4csd.telecom-paris.fr/loss/mutator"
class="mutator.provider.MutatorItemProviderAdapterFactory"
supportedTypes=
"org.eclipse.emf.edit.provider.IEditingDomainItemProvider
org.eclipse.emf.edit.provider.IStructuredItemContentProvider
org.eclipse.emf.edit.provider.ITreeItemContentProvider
org.eclipse.emf.edit.provider.IItemLabelProvider
org.eclipse.emf.edit.provider.IItemPropertySource"/>
</extension>
<extension point="org.eclipse.emf.edit.childCreationExtenders">
<!-- @generated Mutator -->
<extender
uri="http://mdelab/workflow/1.0"
class="mutator.provider.MutatorItemProviderAdapterFactory$WorkflowChildCreationExtender"/>
<extender
uri="http://mdelab/workflow/components/1.0"
class="mutator.provider.MutatorItemProviderAdapterFactory$ComponentsChildCreationExtender"/>
</extension>
</plugin>

View File

@ -0,0 +1,92 @@
/**
*/
package mutator.provider;
import de.mdelab.workflow.provider.WorkflowEditPlugin;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.util.ResourceLocator;
/**
* This is the central singleton for the Mutator edit plugin.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public final class MutatorEditPlugin extends EMFPlugin {
/**
* Keep track of the singleton.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static final MutatorEditPlugin INSTANCE = new MutatorEditPlugin();
/**
* Keep track of the singleton.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private static Implementation plugin;
/**
* Create the instance.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MutatorEditPlugin() {
super
(new ResourceLocator [] {
WorkflowEditPlugin.INSTANCE,
});
}
/**
* Returns the singleton instance of the Eclipse plugin.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the singleton instance.
* @generated
*/
@Override
public ResourceLocator getPluginResourceLocator() {
return plugin;
}
/**
* Returns the singleton instance of the Eclipse plugin.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the singleton instance.
* @generated
*/
public static Implementation getPlugin() {
return plugin;
}
/**
* The actual implementation of the Eclipse <b>Plugin</b>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static class Implementation extends EclipsePlugin {
/**
* Creates an instance.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Implementation() {
super();
// Remember the static instance.
//
plugin = this;
}
}
}

View File

@ -0,0 +1,454 @@
/**
*/
package mutator.provider;
import de.mdelab.workflow.Workflow;
import de.mdelab.workflow.WorkflowPackage;
import de.mdelab.workflow.components.ComponentsPackage;
import de.mdelab.workflow.components.LogicBlock;
import de.mdelab.workflow.components.ModelContainer;
import de.mdelab.workflow.components.util.ComponentsSwitch;
import de.mdelab.workflow.util.WorkflowSwitch;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import mutator.MutatorFactory;
import mutator.MutatorPackage;
import mutator.util.MutatorAdapterFactory;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.command.CommandParameter;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ChildCreationExtenderManager;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IChildCreationExtender;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
/**
* This is the factory that is used to provide the interfaces needed to support Viewers.
* The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
* The adapters also support Eclipse property sheets.
* Note that most of the adapters are shared among multiple instances.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public class MutatorItemProviderAdapterFactory extends MutatorAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable, IChildCreationExtender {
/**
* This keeps track of the root adapter factory that delegates to this adapter factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ComposedAdapterFactory parentAdapterFactory;
/**
* This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IChangeNotifier changeNotifier = new ChangeNotifier();
/**
* This helps manage the child creation extenders.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ChildCreationExtenderManager childCreationExtenderManager = new ChildCreationExtenderManager(MutatorEditPlugin.INSTANCE, MutatorPackage.eNS_URI);
/**
* This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected Collection<Object> supportedTypes = new ArrayList<Object>();
/**
* This constructs an instance.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MutatorItemProviderAdapterFactory() {
supportedTypes.add(IEditingDomainItemProvider.class);
supportedTypes.add(IStructuredItemContentProvider.class);
supportedTypes.add(ITreeItemContentProvider.class);
supportedTypes.add(IItemLabelProvider.class);
supportedTypes.add(IItemPropertySource.class);
}
/**
* This keeps track of the one adapter used for all {@link mutator.RandomMutateModel} instances.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected RandomMutateModelItemProvider randomMutateModelItemProvider;
/**
* This creates an adapter for a {@link mutator.RandomMutateModel}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Adapter createRandomMutateModelAdapter() {
if (randomMutateModelItemProvider == null) {
randomMutateModelItemProvider = new RandomMutateModelItemProvider(this);
}
return randomMutateModelItemProvider;
}
/**
* This returns the root adapter factory that contains this factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public ComposeableAdapterFactory getRootAdapterFactory() {
return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
}
/**
* This sets the composed adapter factory that contains this factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
this.parentAdapterFactory = parentAdapterFactory;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean isFactoryForType(Object type) {
return supportedTypes.contains(type) || super.isFactoryForType(type);
}
/**
* This implementation substitutes the factory itself as the key for the adapter.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Adapter adapt(Notifier notifier, Object type) {
return super.adapt(notifier, this);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object adapt(Object object, Object type) {
if (isFactoryForType(type)) {
Object adapter = super.adapt(object, type);
if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) {
return adapter;
}
}
return null;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public List<IChildCreationExtender> getChildCreationExtenders() {
return childCreationExtenderManager.getChildCreationExtenders();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Collection<?> getNewChildDescriptors(Object object, EditingDomain editingDomain) {
return childCreationExtenderManager.getNewChildDescriptors(object, editingDomain);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ResourceLocator getResourceLocator() {
return childCreationExtenderManager;
}
/**
* This adds a listener.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void addListener(INotifyChangedListener notifyChangedListener) {
changeNotifier.addListener(notifyChangedListener);
}
/**
* This removes a listener.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void removeListener(INotifyChangedListener notifyChangedListener) {
changeNotifier.removeListener(notifyChangedListener);
}
/**
* This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void fireNotifyChanged(Notification notification) {
changeNotifier.fireNotifyChanged(notification);
if (parentAdapterFactory != null) {
parentAdapterFactory.fireNotifyChanged(notification);
}
}
/**
* This disposes all of the item providers created by this factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void dispose() {
if (randomMutateModelItemProvider != null) randomMutateModelItemProvider.dispose();
}
/**
* A child creation extender for the {@link WorkflowPackage}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static class WorkflowChildCreationExtender implements IChildCreationExtender {
/**
* The switch for creating child descriptors specific to each extended class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected static class CreationSwitch extends WorkflowSwitch<Object> {
/**
* The child descriptors being populated.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected List<Object> newChildDescriptors;
/**
* The domain in which to create the children.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EditingDomain editingDomain;
/**
* Creates the a switch for populating child descriptors in the given domain.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
CreationSwitch(List<Object> newChildDescriptors, EditingDomain editingDomain) {
this.newChildDescriptors = newChildDescriptors;
this.editingDomain = editingDomain;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object caseWorkflow(Workflow object) {
newChildDescriptors.add
(createChildParameter
(WorkflowPackage.Literals.WORKFLOW__COMPONENTS,
MutatorFactory.eINSTANCE.createRandomMutateModel()));
return null;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected CommandParameter createChildParameter(Object feature, Object child) {
return new CommandParameter(null, feature, child);
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Collection<Object> getNewChildDescriptors(Object object, EditingDomain editingDomain) {
ArrayList<Object> result = new ArrayList<Object>();
new CreationSwitch(result, editingDomain).doSwitch((EObject)object);
return result;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ResourceLocator getResourceLocator() {
return MutatorEditPlugin.INSTANCE;
}
}
/**
* A child creation extender for the {@link ComponentsPackage}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static class ComponentsChildCreationExtender implements IChildCreationExtender {
/**
* The switch for creating child descriptors specific to each extended class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected static class CreationSwitch extends ComponentsSwitch<Object> {
/**
* The child descriptors being populated.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected List<Object> newChildDescriptors;
/**
* The domain in which to create the children.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EditingDomain editingDomain;
/**
* Creates the a switch for populating child descriptors in the given domain.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
CreationSwitch(List<Object> newChildDescriptors, EditingDomain editingDomain) {
this.newChildDescriptors = newChildDescriptors;
this.editingDomain = editingDomain;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object caseModelContainer(ModelContainer object) {
newChildDescriptors.add
(createChildParameter
(ComponentsPackage.Literals.MODEL_CONTAINER__MODELS,
MutatorFactory.eINSTANCE.createRandomMutateModel()));
return null;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object caseLogicBlock(LogicBlock object) {
newChildDescriptors.add
(createChildParameter
(ComponentsPackage.Literals.LOGIC_BLOCK__COMPONENTS,
MutatorFactory.eINSTANCE.createRandomMutateModel()));
return null;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected CommandParameter createChildParameter(Object feature, Object child) {
return new CommandParameter(null, feature, child);
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Collection<Object> getNewChildDescriptors(Object object, EditingDomain editingDomain) {
ArrayList<Object> result = new ArrayList<Object>();
new CreationSwitch(result, editingDomain).doSwitch((EObject)object);
return result;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ResourceLocator getResourceLocator() {
return MutatorEditPlugin.INSTANCE;
}
}
}

View File

@ -0,0 +1,150 @@
/**
*/
package mutator.provider;
import de.mdelab.workflow.components.provider.WorkflowComponentItemProvider;
import java.util.Collection;
import java.util.List;
import mutator.MutatorPackage;
import mutator.RandomMutateModel;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IChildCreationExtender;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ViewerNotification;
/**
* This is the item provider adapter for a {@link mutator.RandomMutateModel} object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public class RandomMutateModelItemProvider extends WorkflowComponentItemProvider {
/**
* This constructs an instance from a factory and a notifier.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public RandomMutateModelItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}
/**
* This returns the property descriptors for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
addModelSlotPropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
/**
* This adds a property descriptor for the Model Slot feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addModelSlotPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_RandomMutateModel_modelSlot_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_RandomMutateModel_modelSlot_feature", "_UI_RandomMutateModel_type"),
MutatorPackage.Literals.RANDOM_MUTATE_MODEL__MODEL_SLOT,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This returns RandomMutateModel.gif.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object getImage(Object object) {
return overlayImage(object, getResourceLocator().getImage("full/obj16/RandomMutateModel"));
}
/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@Override
public String getText(Object object) {
RandomMutateModel model = (RandomMutateModel)object;
String label = model.getName();
return (label == null || label.length() == 0 ?
getString("_UI_RandomMutateModel_type") :
getString("_UI_RandomMutateModel_type") + " " + label)
+ " | mutatate " + model.getModelSlot();
}
/**
* This handles model notifications by calling {@link #updateChildren} to update any cached
* children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void notifyChanged(Notification notification) {
updateChildren(notification);
switch (notification.getFeatureID(RandomMutateModel.class)) {
case MutatorPackage.RANDOM_MUTATE_MODEL__MODEL_SLOT:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
}
super.notifyChanged(notification);
}
/**
* This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
* that can be created under this object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
}
/**
* Return the resource locator for this item provider's resources.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public ResourceLocator getResourceLocator() {
return ((IChildCreationExtender)adapterFactory).getResourceLocator();
}
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>fr.tpt.mem4csd.loss.modelMutation.editor</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@ -0,0 +1,20 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: fr.tpt.mem4csd.loss.modelMutation.editor;singleton:=true
Automatic-Module-Name: fr.tpt.mem4csd.loss.modelMutation.editor
Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: mutator.presentation.MutatorEditorPlugin$Implementation
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-17
Export-Package: mutator.presentation
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources;visibility:=reexport,
fr.tpt.mem4csd.loss.modelMutation.edit;visibility:=reexport,
org.eclipse.emf.ecore.xmi;visibility:=reexport,
org.eclipse.emf.edit.ui;visibility:=reexport,
org.eclipse.ui.ide;visibility:=reexport,
de.mdelab.workflow.edit;visibility:=reexport
Bundle-ActivationPolicy: lazy

View File

@ -0,0 +1,10 @@
#
bin.includes = .,\
icons/,\
META-INF/,\
plugin.xml,\
plugin.properties
jars.compile.order = .
source.. = src/
output.. = bin

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -0,0 +1,53 @@
#
pluginName = fr.tpt.mem4csd.loss.modelMutation Editor
providerName = www.example.org
_UI_MutatorEditor_menu = &Mutator Editor
_UI_CreateChild_menu_item = &New Child
_UI_CreateSibling_menu_item = N&ew Sibling
_UI_ShowPropertiesView_menu_item = Show &Properties View
_UI_RefreshViewer_menu_item = &Refresh
_UI_SelectionPage_label = Selection
_UI_ParentPage_label = Parent
_UI_ListPage_label = List
_UI_TreePage_label = Tree
_UI_TablePage_label = Table
_UI_TreeWithColumnsPage_label = Tree with Columns
_UI_ObjectColumn_label = Object
_UI_SelfColumn_label = Self
_UI_NoObjectSelected = Selected Nothing
_UI_SingleObjectSelected = Selected Object: {0}
_UI_MultiObjectSelected = Selected {0} Objects
_UI_OpenEditorError_label = Open Editor
_UI_Wizard_category = Example EMF Model Creation Wizards
_UI_CreateModelError_message = Problems encountered in file "{0}"
_UI_MutatorModelWizard_label = Mutator Model
_UI_MutatorModelWizard_description = Create a new Mutator model
_UI_MutatorEditor_label = Mutator Model Editor
_UI_MutatorEditorFilenameDefaultBase = My
_UI_MutatorEditorFilenameExtensions = mutator
_UI_Wizard_label = New
_WARN_FilenameExtension = The file name must end in ''.{0}''
_WARN_FilenameExtensions = The file name must have one of the following extensions: {0}
_UI_ModelObject = &Model Object
_UI_XMLEncoding = &XML Encoding
_UI_XMLEncodingChoices = UTF-8 ASCII UTF-16 UTF-16BE UTF-16LE ISO-8859-1
_UI_Wizard_initial_object_description = Select a model object to create
_UI_FileConflict_label = File Conflict
_WARN_FileConflict = There are unsaved changes that conflict with changes made outside the editor. Do you wish to discard this editor's changes?

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<!--
-->
<plugin>
<extension point="org.eclipse.ui.newWizards">
<!-- @generated Mutator -->
<category
id="org.eclipse.emf.ecore.Wizard.category.ID"
name="%_UI_Wizard_category"/>
<wizard
id="mutator.presentation.MutatorModelWizardID"
name="%_UI_MutatorModelWizard_label"
class="mutator.presentation.MutatorModelWizard"
category="org.eclipse.emf.ecore.Wizard.category.ID"
icon="icons/full/obj16/MutatorModelFile.gif">
<description>%_UI_MutatorModelWizard_description</description>
<selection class="org.eclipse.core.resources.IResource"/>
</wizard>
</extension>
<extension point="org.eclipse.ui.editors">
<!-- @generated Mutator -->
<editor
id="mutator.presentation.MutatorEditorID"
name="%_UI_MutatorEditor_label"
icon="icons/full/obj16/MutatorModelFile.gif"
extensions="mutator"
class="mutator.presentation.MutatorEditor"
contributorClass="mutator.presentation.MutatorActionBarContributor">
</editor>
</extension>
</plugin>

View File

@ -0,0 +1,426 @@
/**
*/
package mutator.presentation;
import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.emf.common.ui.viewer.IViewerProvider;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.emf.edit.ui.action.ControlAction;
import org.eclipse.emf.edit.ui.action.CreateChildAction;
import org.eclipse.emf.edit.ui.action.CreateSiblingAction;
import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
import org.eclipse.emf.edit.ui.action.LoadResourceAction;
import org.eclipse.emf.edit.ui.action.ValidateAction;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IContributionManager;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.SubContributionItem;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PartInitException;
/**
* This is the action bar contributor for the Mutator model editor.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public class MutatorActionBarContributor
extends EditingDomainActionBarContributor
implements ISelectionChangedListener {
/**
* This keeps track of the active editor.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IEditorPart activeEditorPart;
/**
* This keeps track of the current selection provider.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ISelectionProvider selectionProvider;
/**
* This action opens the Properties view.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IAction showPropertiesViewAction =
new Action(MutatorEditorPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) {
@Override
public void run() {
try {
getPage().showView("org.eclipse.ui.views.PropertySheet");
}
catch (PartInitException exception) {
MutatorEditorPlugin.INSTANCE.log(exception);
}
}
};
/**
* This action refreshes the viewer of the current editor if the editor
* implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IAction refreshViewerAction =
new Action(MutatorEditorPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) {
@Override
public boolean isEnabled() {
return activeEditorPart instanceof IViewerProvider;
}
@Override
public void run() {
if (activeEditorPart instanceof IViewerProvider) {
Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer();
if (viewer != null) {
viewer.refresh();
}
}
}
};
/**
* This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each descriptor
* generated for the current selection by the item provider.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected Collection<IAction> createChildActions;
/**
* This is the menu manager into which menu contribution items should be added for CreateChild actions.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IMenuManager createChildMenuManager;
/**
* This will contain one {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} corresponding to each descriptor
* generated for the current selection by the item provider.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected Collection<IAction> createSiblingActions;
/**
* This is the menu manager into which menu contribution items should be added for CreateSibling actions.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IMenuManager createSiblingMenuManager;
/**
* This creates an instance of the contributor.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MutatorActionBarContributor() {
super(ADDITIONS_LAST_STYLE);
loadResourceAction = new LoadResourceAction();
validateAction = new ValidateAction();
controlAction = new ControlAction();
}
/**
* This adds Separators for editor additions to the tool bar.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void contributeToToolBar(IToolBarManager toolBarManager) {
super.contributeToToolBar(toolBarManager);
toolBarManager.add(new Separator("mutator-settings"));
toolBarManager.add(new Separator("mutator-additions"));
}
/**
* This adds to the menu bar a menu and some separators for editor additions,
* as well as the sub-menus for object creation items.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void contributeToMenu(IMenuManager menuManager) {
super.contributeToMenu(menuManager);
IMenuManager submenuManager = new MenuManager(MutatorEditorPlugin.INSTANCE.getString("_UI_MutatorEditor_menu"), "mutatorMenuID");
menuManager.insertAfter("additions", submenuManager);
submenuManager.add(new Separator("settings"));
submenuManager.add(new Separator("actions"));
submenuManager.add(new Separator("additions"));
submenuManager.add(new Separator("additions-end"));
// Prepare for CreateChild item addition or removal.
//
createChildMenuManager = new MenuManager(MutatorEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item"));
submenuManager.insertBefore("additions", createChildMenuManager);
// Prepare for CreateSibling item addition or removal.
//
createSiblingMenuManager = new MenuManager(MutatorEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item"));
submenuManager.insertBefore("additions", createSiblingMenuManager);
// Force an update because Eclipse hides empty menus now.
//
submenuManager.addMenuListener
(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager menuManager) {
menuManager.updateAll(true);
}
});
addGlobalActions(submenuManager);
}
/**
* When the active editor changes, this remembers the change and registers with it as a selection provider.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setActiveEditor(IEditorPart part) {
super.setActiveEditor(part);
activeEditorPart = part;
// Switch to the new selection provider.
//
if (selectionProvider != null) {
selectionProvider.removeSelectionChangedListener(this);
}
if (part == null) {
selectionProvider = null;
}
else {
selectionProvider = part.getSite().getSelectionProvider();
selectionProvider.addSelectionChangedListener(this);
// Fake a selection changed event to update the menus.
//
if (selectionProvider.getSelection() != null) {
selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
}
}
}
/**
* This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener},
* handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings
* that can be added to the selected object and updating the menus accordingly.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void selectionChanged(SelectionChangedEvent event) {
// Remove any menu items for old selection.
//
if (createChildMenuManager != null) {
depopulateManager(createChildMenuManager, createChildActions);
}
if (createSiblingMenuManager != null) {
depopulateManager(createSiblingMenuManager, createSiblingActions);
}
// Query the new selection for appropriate new child/sibling descriptors
//
Collection<?> newChildDescriptors = null;
Collection<?> newSiblingDescriptors = null;
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) {
Object object = ((IStructuredSelection)selection).getFirstElement();
EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain();
newChildDescriptors = domain.getNewChildDescriptors(object, null);
newSiblingDescriptors = domain.getNewChildDescriptors(null, object);
}
// Generate actions for selection; populate and redraw the menus.
//
createChildActions = generateCreateChildActions(newChildDescriptors, selection);
createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection);
if (createChildMenuManager != null) {
populateManager(createChildMenuManager, createChildActions, null);
createChildMenuManager.update(true);
}
if (createSiblingMenuManager != null) {
populateManager(createSiblingMenuManager, createSiblingActions, null);
createSiblingMenuManager.update(true);
}
}
/**
* This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>,
* and returns the collection of these actions.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected Collection<IAction> generateCreateChildActions(Collection<?> descriptors, ISelection selection) {
Collection<IAction> actions = new ArrayList<IAction>();
if (descriptors != null) {
for (Object descriptor : descriptors) {
actions.add(new CreateChildAction(activeEditorPart, selection, descriptor));
}
}
return actions;
}
/**
* This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in <code>descriptors</code>,
* and returns the collection of these actions.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected Collection<IAction> generateCreateSiblingActions(Collection<?> descriptors, ISelection selection) {
Collection<IAction> actions = new ArrayList<IAction>();
if (descriptors != null) {
for (Object descriptor : descriptors) {
actions.add(new CreateSiblingAction(activeEditorPart, selection, descriptor));
}
}
return actions;
}
/**
* This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s
* based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection,
* by inserting them before the specified contribution item <code>contributionID</code>.
* If <code>contributionID</code> is <code>null</code>, they are simply added.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions, String contributionID) {
if (actions != null) {
for (IAction action : actions) {
if (contributionID != null) {
manager.insertBefore(contributionID, action);
}
else {
manager.add(action);
}
}
}
}
/**
* This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
* based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) {
if (actions != null) {
IContributionItem[] items = manager.getItems();
for (int i = 0; i < items.length; i++) {
// Look into SubContributionItems
//
IContributionItem contributionItem = items[i];
while (contributionItem instanceof SubContributionItem) {
contributionItem = ((SubContributionItem)contributionItem).getInnerItem();
}
// Delete the ActionContributionItems with matching action.
//
if (contributionItem instanceof ActionContributionItem) {
IAction action = ((ActionContributionItem)contributionItem).getAction();
if (actions.contains(action)) {
manager.remove(contributionItem);
}
}
}
}
}
/**
* This populates the pop-up menu before it appears.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void menuAboutToShow(IMenuManager menuManager) {
super.menuAboutToShow(menuManager);
MenuManager submenuManager = null;
submenuManager = new MenuManager(MutatorEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item"));
populateManager(submenuManager, createChildActions, null);
menuManager.insertBefore("edit", submenuManager);
submenuManager = new MenuManager(MutatorEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item"));
populateManager(submenuManager, createSiblingActions, null);
menuManager.insertBefore("edit", submenuManager);
}
/**
* This inserts global actions before the "additions-end" separator.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected void addGlobalActions(IMenuManager menuManager) {
menuManager.insertAfter("additions-end", new Separator("ui-actions"));
menuManager.insertAfter("ui-actions", showPropertiesViewAction);
refreshViewerAction.setEnabled(refreshViewerAction.isEnabled());
menuManager.insertAfter("ui-actions", refreshViewerAction);
super.addGlobalActions(menuManager);
}
/**
* This ensures that a delete action will clean up all references to deleted objects.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected boolean removeAllReferencesOnDelete() {
return true;
}
}

View File

@ -0,0 +1,94 @@
/**
*/
package mutator.presentation;
import de.mdelab.workflow.provider.WorkflowEditPlugin;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.ui.EclipseUIPlugin;
import org.eclipse.emf.common.util.ResourceLocator;
/**
* This is the central singleton for the Mutator editor plugin.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public final class MutatorEditorPlugin extends EMFPlugin {
/**
* Keep track of the singleton.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static final MutatorEditorPlugin INSTANCE = new MutatorEditorPlugin();
/**
* Keep track of the singleton.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private static Implementation plugin;
/**
* Create the instance.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MutatorEditorPlugin() {
super
(new ResourceLocator [] {
WorkflowEditPlugin.INSTANCE,
});
}
/**
* Returns the singleton instance of the Eclipse plugin.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the singleton instance.
* @generated
*/
@Override
public ResourceLocator getPluginResourceLocator() {
return plugin;
}
/**
* Returns the singleton instance of the Eclipse plugin.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the singleton instance.
* @generated
*/
public static Implementation getPlugin() {
return plugin;
}
/**
* The actual implementation of the Eclipse <b>Plugin</b>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static class Implementation extends EclipseUIPlugin {
/**
* Creates an instance.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Implementation() {
super();
// Remember the static instance.
//
plugin = this;
}
}
}

View File

@ -0,0 +1,631 @@
/**
*/
package mutator.presentation;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.StringTokenizer;
import org.eclipse.emf.common.CommonPlugin;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.part.ISetSelectionTarget;
import mutator.MutatorFactory;
import mutator.MutatorPackage;
import mutator.provider.MutatorEditPlugin;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
/**
* This is a simple wizard for creating a new model file.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public class MutatorModelWizard extends Wizard implements INewWizard {
/**
* The supported extensions for created files.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static final List<String> FILE_EXTENSIONS =
Collections.unmodifiableList(Arrays.asList(MutatorEditorPlugin.INSTANCE.getString("_UI_MutatorEditorFilenameExtensions").split("\\s*,\\s*")));
/**
* A formatted list of supported file extensions, suitable for display.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static final String FORMATTED_FILE_EXTENSIONS =
MutatorEditorPlugin.INSTANCE.getString("_UI_MutatorEditorFilenameExtensions").replaceAll("\\s*,\\s*", ", ");
/**
* This caches an instance of the model package.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected MutatorPackage mutatorPackage = MutatorPackage.eINSTANCE;
/**
* This caches an instance of the model factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected MutatorFactory mutatorFactory = mutatorPackage.getMutatorFactory();
/**
* This is the file creation page.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected MutatorModelWizardNewFileCreationPage newFileCreationPage;
/**
* This is the initial object creation page.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected MutatorModelWizardInitialObjectCreationPage initialObjectCreationPage;
/**
* Remember the selection during initialization for populating the default container.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IStructuredSelection selection;
/**
* Remember the workbench during initialization.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IWorkbench workbench;
/**
* Caches the names of the types that can be created as the root object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected List<String> initialObjectNames;
/**
* This just records the information.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
this.workbench = workbench;
this.selection = selection;
setWindowTitle(MutatorEditorPlugin.INSTANCE.getString("_UI_Wizard_label"));
setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(MutatorEditorPlugin.INSTANCE.getImage("full/wizban/NewMutator")));
}
/**
* Returns the names of the types that can be created as the root object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected Collection<String> getInitialObjectNames() {
if (initialObjectNames == null) {
initialObjectNames = new ArrayList<String>();
for (EClassifier eClassifier : mutatorPackage.getEClassifiers()) {
if (eClassifier instanceof EClass) {
EClass eClass = (EClass)eClassifier;
if (!eClass.isAbstract()) {
initialObjectNames.add(eClass.getName());
}
}
}
Collections.sort(initialObjectNames, CommonPlugin.INSTANCE.getComparator());
}
return initialObjectNames;
}
/**
* Create a new model.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EObject createInitialModel() {
EClass eClass = (EClass)mutatorPackage.getEClassifier(initialObjectCreationPage.getInitialObjectName());
EObject rootObject = mutatorFactory.create(eClass);
return rootObject;
}
/**
* Do the work after everything is specified.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean performFinish() {
try {
// Remember the file.
//
final IFile modelFile = getModelFile();
// Do the work within an operation.
//
WorkspaceModifyOperation operation =
new WorkspaceModifyOperation() {
@Override
protected void execute(IProgressMonitor progressMonitor) {
try {
// Create a resource set
//
ResourceSet resourceSet = new ResourceSetImpl();
// Get the URI of the model file.
//
URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);
// Create a resource for this file.
//
Resource resource = resourceSet.createResource(fileURI);
// Add the initial model object to the contents.
//
EObject rootObject = createInitialModel();
if (rootObject != null) {
resource.getContents().add(rootObject);
}
// Save the contents of the resource to the file system.
//
Map<Object, Object> options = new HashMap<Object, Object>();
options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding());
resource.save(options);
}
catch (Exception exception) {
MutatorEditorPlugin.INSTANCE.log(exception);
}
finally {
progressMonitor.done();
}
}
};
getContainer().run(false, false, operation);
// Select the new file resource in the current view.
//
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
final IWorkbenchPart activePart = page.getActivePart();
if (activePart instanceof ISetSelectionTarget) {
final ISelection targetSelection = new StructuredSelection(modelFile);
getShell().getDisplay().asyncExec
(new Runnable() {
@Override
public void run() {
((ISetSelectionTarget)activePart).selectReveal(targetSelection);
}
});
}
// Open an editor on the new file.
//
try {
page.openEditor
(new FileEditorInput(modelFile),
workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId());
}
catch (PartInitException exception) {
MessageDialog.openError(workbenchWindow.getShell(), MutatorEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage());
return false;
}
return true;
}
catch (Exception exception) {
MutatorEditorPlugin.INSTANCE.log(exception);
return false;
}
}
/**
* This is the one page of the wizard.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public class MutatorModelWizardNewFileCreationPage extends WizardNewFileCreationPage {
/**
* Pass in the selection.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MutatorModelWizardNewFileCreationPage(String pageId, IStructuredSelection selection) {
super(pageId, selection);
}
/**
* The framework calls this to see if the file is correct.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected boolean validatePage() {
if (super.validatePage()) {
String extension = new Path(getFileName()).getFileExtension();
if (extension == null || !FILE_EXTENSIONS.contains(extension)) {
String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension";
setErrorMessage(MutatorEditorPlugin.INSTANCE.getString(key, new Object [] { FORMATTED_FILE_EXTENSIONS }));
return false;
}
return true;
}
return false;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public IFile getModelFile() {
return ResourcesPlugin.getWorkspace().getRoot().getFile(getContainerFullPath().append(getFileName()));
}
}
/**
* This is the page where the type of object to create is selected.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public class MutatorModelWizardInitialObjectCreationPage extends WizardPage {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected Combo initialObjectField;
/**
* @generated
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
protected List<String> encodings;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected Combo encodingField;
/**
* Pass in the selection.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MutatorModelWizardInitialObjectCreationPage(String pageId) {
super(pageId);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE); {
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.verticalSpacing = 12;
composite.setLayout(layout);
GridData data = new GridData();
data.verticalAlignment = GridData.FILL;
data.grabExcessVerticalSpace = true;
data.horizontalAlignment = GridData.FILL;
composite.setLayoutData(data);
}
Label containerLabel = new Label(composite, SWT.LEFT);
{
containerLabel.setText(MutatorEditorPlugin.INSTANCE.getString("_UI_ModelObject"));
GridData data = new GridData();
data.horizontalAlignment = GridData.FILL;
containerLabel.setLayoutData(data);
}
initialObjectField = new Combo(composite, SWT.BORDER);
{
GridData data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.grabExcessHorizontalSpace = true;
initialObjectField.setLayoutData(data);
}
for (String objectName : getInitialObjectNames()) {
initialObjectField.add(getLabel(objectName));
}
if (initialObjectField.getItemCount() == 1) {
initialObjectField.select(0);
}
initialObjectField.addModifyListener(validator);
Label encodingLabel = new Label(composite, SWT.LEFT);
{
encodingLabel.setText(MutatorEditorPlugin.INSTANCE.getString("_UI_XMLEncoding"));
GridData data = new GridData();
data.horizontalAlignment = GridData.FILL;
encodingLabel.setLayoutData(data);
}
encodingField = new Combo(composite, SWT.BORDER);
{
GridData data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.grabExcessHorizontalSpace = true;
encodingField.setLayoutData(data);
}
for (String encoding : getEncodings()) {
encodingField.add(encoding);
}
encodingField.select(0);
encodingField.addModifyListener(validator);
setPageComplete(validatePage());
setControl(composite);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ModifyListener validator =
new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
setPageComplete(validatePage());
}
};
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected boolean validatePage() {
return getInitialObjectName() != null && getEncodings().contains(encodingField.getText());
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setVisible(boolean visible) {
super.setVisible(visible);
if (visible) {
if (initialObjectField.getItemCount() == 1) {
initialObjectField.clearSelection();
encodingField.setFocus();
}
else {
encodingField.clearSelection();
initialObjectField.setFocus();
}
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getInitialObjectName() {
String label = initialObjectField.getText();
for (String name : getInitialObjectNames()) {
if (getLabel(name).equals(label)) {
return name;
}
}
return null;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getEncoding() {
return encodingField.getText();
}
/**
* Returns the label for the specified type name.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected String getLabel(String typeName) {
try {
return MutatorEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type");
}
catch(MissingResourceException mre) {
MutatorEditorPlugin.INSTANCE.log(mre);
}
return typeName;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected Collection<String> getEncodings() {
if (encodings == null) {
encodings = new ArrayList<String>();
for (StringTokenizer stringTokenizer = new StringTokenizer(MutatorEditorPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens(); ) {
encodings.add(stringTokenizer.nextToken());
}
}
return encodings;
}
}
/**
* The framework calls this to create the contents of the wizard.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void addPages() {
// Create a page, set the title, and the initial model file name.
//
newFileCreationPage = new MutatorModelWizardNewFileCreationPage("Whatever", selection);
newFileCreationPage.setTitle(MutatorEditorPlugin.INSTANCE.getString("_UI_MutatorModelWizard_label"));
newFileCreationPage.setDescription(MutatorEditorPlugin.INSTANCE.getString("_UI_MutatorModelWizard_description"));
newFileCreationPage.setFileName(MutatorEditorPlugin.INSTANCE.getString("_UI_MutatorEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0));
addPage(newFileCreationPage);
// Try and get the resource selection to determine a current directory for the file dialog.
//
if (selection != null && !selection.isEmpty()) {
// Get the resource...
//
Object selectedElement = selection.iterator().next();
if (selectedElement instanceof IResource) {
// Get the resource parent, if its a file.
//
IResource selectedResource = (IResource)selectedElement;
if (selectedResource.getType() == IResource.FILE) {
selectedResource = selectedResource.getParent();
}
// This gives us a directory...
//
if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
// Set this for the container.
//
newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());
// Make up a unique new name here.
//
String defaultModelBaseFilename = MutatorEditorPlugin.INSTANCE.getString("_UI_MutatorEditorFilenameDefaultBase");
String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0);
String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension;
for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension;
}
newFileCreationPage.setFileName(modelFilename);
}
}
}
initialObjectCreationPage = new MutatorModelWizardInitialObjectCreationPage("Whatever2");
initialObjectCreationPage.setTitle(MutatorEditorPlugin.INSTANCE.getString("_UI_MutatorModelWizard_label"));
initialObjectCreationPage.setDescription(MutatorEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description"));
addPage(initialObjectCreationPage);
}
/**
* Get the file from the page.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public IFile getModelFile() {
return newFileCreationPage.getModelFile();
}
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>fr.tpt.mem4csd.loss.modelMutation</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@ -0,0 +1,17 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: fr.tpt.mem4csd.loss.modelMutation;singleton:=true
Automatic-Module-Name: fr.tpt.mem4csd.loss.modelMutation
Bundle-Version: 0.1.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-17
Export-Package: mutator,
mutator.impl,
mutator.util
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.ecore;visibility:=reexport,
de.mdelab.workflow;visibility:=reexport
Bundle-ActivationPolicy: lazy

View File

@ -0,0 +1,10 @@
#
bin.includes = .,\
model/,\
META-INF/,\
plugin.xml,\
plugin.properties
jars.compile.order = .
source.. = src/
output.. = bin/

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="mutator" nsURI="http://mem4csd.telecom-paris.fr/loss/mutator"
nsPrefix="mutator">
<eClassifiers xsi:type="ecore:EClass" name="RandomMutateModel" eSuperTypes="platform:/plugin/de.mdelab.workflow/model/components.ecore#//WorkflowComponent">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="modelSlot" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/fr.tpt.mem4csd.loss.modelMutation/src-gen" editDirectory="/fr.tpt.mem4csd.loss.modelMutation.edit/src-gen"
editorDirectory="/fr.tpt.mem4csd.loss.modelMutation.editor/src-gen" modelPluginID="fr.tpt.mem4csd.loss.modelMutation"
modelName="Mutator" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container"
importerID="org.eclipse.emf.importer.ecore" complianceLevel="17.0" copyrightFields="false"
usedGenPackages="../../de.mdelab.workflow/model/workflow.genmodel#//workflow ../../de.mdelab.workflow/model/workflow.genmodel#//helpers ../../de.mdelab.workflow/model/workflow.genmodel#//components"
operationReflection="true" importOrganizing="true">
<foreignModel>Mutator.ecore</foreignModel>
<genPackages prefix="Mutator" disposableProviderFactory="true" extensibleProviderFactory="true"
childCreationExtenders="true" ecorePackage="Mutator.ecore#/">
<genClasses ecoreClass="Mutator.ecore#//RandomMutateModel">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute Mutator.ecore#//RandomMutateModel/modelSlot"/>
</genClasses>
</genPackages>
</genmodel:GenModel>

View File

@ -0,0 +1,4 @@
#
pluginName = fr.tpt.mem4csd.loss.modelMutation
providerName = www.example.org

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<!--
-->
<plugin>
<extension point="org.eclipse.emf.ecore.generated_package">
<!-- @generated Mutator -->
<package
uri="http://mem4csd.telecom-paris.fr/loss/mutator"
class="mutator.MutatorPackage"
genModel="model/Mutator.genmodel"/>
</extension>
</plugin>

View File

@ -0,0 +1,42 @@
/**
*/
package mutator;
import org.eclipse.emf.ecore.EFactory;
/**
* <!-- begin-user-doc -->
* The <b>Factory</b> for the model.
* It provides a create method for each non-abstract class of the model.
* <!-- end-user-doc -->
* @see mutator.MutatorPackage
* @generated
*/
public interface MutatorFactory extends EFactory {
/**
* The singleton instance of the factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
MutatorFactory eINSTANCE = mutator.impl.MutatorFactoryImpl.init();
/**
* Returns a new object of class '<em>Random Mutate Model</em>'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return a new object of class '<em>Random Mutate Model</em>'.
* @generated
*/
RandomMutateModel createRandomMutateModel();
/**
* Returns the package supported by this factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the package supported by this factory.
* @generated
*/
MutatorPackage getMutatorPackage();
} //MutatorFactory

View File

@ -0,0 +1,227 @@
/**
*/
package mutator;
import de.mdelab.workflow.components.ComponentsPackage;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EPackage;
/**
* <!-- begin-user-doc -->
* The <b>Package</b> for the model.
* It contains accessors for the meta objects to represent
* <ul>
* <li>each class,</li>
* <li>each feature of each class,</li>
* <li>each operation of each class,</li>
* <li>each enum,</li>
* <li>and each data type</li>
* </ul>
* <!-- end-user-doc -->
* @see mutator.MutatorFactory
* @model kind="package"
* @generated
*/
public interface MutatorPackage extends EPackage {
/**
* The package name.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
String eNAME = "mutator";
/**
* The package namespace URI.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
String eNS_URI = "http://mem4csd.telecom-paris.fr/loss/mutator";
/**
* The package namespace name.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
String eNS_PREFIX = "mutator";
/**
* The singleton instance of the package.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
MutatorPackage eINSTANCE = mutator.impl.MutatorPackageImpl.init();
/**
* The meta object id for the '{@link mutator.impl.RandomMutateModelImpl <em>Random Mutate Model</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see mutator.impl.RandomMutateModelImpl
* @see mutator.impl.MutatorPackageImpl#getRandomMutateModel()
* @generated
*/
int RANDOM_MUTATE_MODEL = 0;
/**
* The feature id for the '<em><b>Name</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
int RANDOM_MUTATE_MODEL__NAME = ComponentsPackage.WORKFLOW_COMPONENT__NAME;
/**
* The feature id for the '<em><b>Description</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
int RANDOM_MUTATE_MODEL__DESCRIPTION = ComponentsPackage.WORKFLOW_COMPONENT__DESCRIPTION;
/**
* The feature id for the '<em><b>Enabled</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
int RANDOM_MUTATE_MODEL__ENABLED = ComponentsPackage.WORKFLOW_COMPONENT__ENABLED;
/**
* The feature id for the '<em><b>Model Slot</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
int RANDOM_MUTATE_MODEL__MODEL_SLOT = ComponentsPackage.WORKFLOW_COMPONENT_FEATURE_COUNT + 0;
/**
* The number of structural features of the '<em>Random Mutate Model</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
int RANDOM_MUTATE_MODEL_FEATURE_COUNT = ComponentsPackage.WORKFLOW_COMPONENT_FEATURE_COUNT + 1;
/**
* The operation id for the '<em>Check Configuration</em>' operation.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
int RANDOM_MUTATE_MODEL___CHECK_CONFIGURATION__WORKFLOWEXECUTIONCONTEXT = ComponentsPackage.WORKFLOW_COMPONENT___CHECK_CONFIGURATION__WORKFLOWEXECUTIONCONTEXT;
/**
* The operation id for the '<em>Execute</em>' operation.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @deprecated See {@link de.mdelab.workflow.components.WorkflowComponent#execute(de.mdelab.workflow.WorkflowExecutionContext) model documentation} for details.
* @generated
* @ordered
*/
@Deprecated
int RANDOM_MUTATE_MODEL___EXECUTE__WORKFLOWEXECUTIONCONTEXT = ComponentsPackage.WORKFLOW_COMPONENT___EXECUTE__WORKFLOWEXECUTIONCONTEXT;
/**
* The operation id for the '<em>Execute</em>' operation.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
int RANDOM_MUTATE_MODEL___EXECUTE__WORKFLOWEXECUTIONCONTEXT_IPROGRESSMONITOR = ComponentsPackage.WORKFLOW_COMPONENT___EXECUTE__WORKFLOWEXECUTIONCONTEXT_IPROGRESSMONITOR;
/**
* The operation id for the '<em>Check Canceled</em>' operation.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
int RANDOM_MUTATE_MODEL___CHECK_CANCELED__IPROGRESSMONITOR = ComponentsPackage.WORKFLOW_COMPONENT___CHECK_CANCELED__IPROGRESSMONITOR;
/**
* The number of operations of the '<em>Random Mutate Model</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
int RANDOM_MUTATE_MODEL_OPERATION_COUNT = ComponentsPackage.WORKFLOW_COMPONENT_OPERATION_COUNT + 0;
/**
* Returns the meta object for class '{@link mutator.RandomMutateModel <em>Random Mutate Model</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the meta object for class '<em>Random Mutate Model</em>'.
* @see mutator.RandomMutateModel
* @generated
*/
EClass getRandomMutateModel();
/**
* Returns the meta object for the attribute '{@link mutator.RandomMutateModel#getModelSlot <em>Model Slot</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the meta object for the attribute '<em>Model Slot</em>'.
* @see mutator.RandomMutateModel#getModelSlot()
* @see #getRandomMutateModel()
* @generated
*/
EAttribute getRandomMutateModel_ModelSlot();
/**
* Returns the factory that creates the instances of the model.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the factory that creates the instances of the model.
* @generated
*/
MutatorFactory getMutatorFactory();
/**
* <!-- begin-user-doc -->
* Defines literals for the meta objects that represent
* <ul>
* <li>each class,</li>
* <li>each feature of each class,</li>
* <li>each operation of each class,</li>
* <li>each enum,</li>
* <li>and each data type</li>
* </ul>
* <!-- end-user-doc -->
* @generated
*/
interface Literals {
/**
* The meta object literal for the '{@link mutator.impl.RandomMutateModelImpl <em>Random Mutate Model</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see mutator.impl.RandomMutateModelImpl
* @see mutator.impl.MutatorPackageImpl#getRandomMutateModel()
* @generated
*/
EClass RANDOM_MUTATE_MODEL = eINSTANCE.getRandomMutateModel();
/**
* The meta object literal for the '<em><b>Model Slot</b></em>' attribute feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
EAttribute RANDOM_MUTATE_MODEL__MODEL_SLOT = eINSTANCE.getRandomMutateModel_ModelSlot();
}
} //MutatorPackage

View File

@ -0,0 +1,46 @@
/**
*/
package mutator;
import de.mdelab.workflow.components.WorkflowComponent;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Random Mutate Model</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* </p>
* <ul>
* <li>{@link mutator.RandomMutateModel#getModelSlot <em>Model Slot</em>}</li>
* </ul>
*
* @see mutator.MutatorPackage#getRandomMutateModel()
* @model
* @generated
*/
public interface RandomMutateModel extends WorkflowComponent {
/**
* Returns the value of the '<em><b>Model Slot</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Model Slot</em>' attribute.
* @see #setModelSlot(String)
* @see mutator.MutatorPackage#getRandomMutateModel_ModelSlot()
* @model required="true"
* @generated
*/
String getModelSlot();
/**
* Sets the value of the '{@link mutator.RandomMutateModel#getModelSlot <em>Model Slot</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Model Slot</em>' attribute.
* @see #getModelSlot()
* @generated
*/
void setModelSlot(String value);
} // RandomMutateModel

View File

@ -0,0 +1,97 @@
/**
*/
package mutator.impl;
import mutator.*;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.impl.EFactoryImpl;
import org.eclipse.emf.ecore.plugin.EcorePlugin;
/**
* <!-- begin-user-doc -->
* An implementation of the model <b>Factory</b>.
* <!-- end-user-doc -->
* @generated
*/
public class MutatorFactoryImpl extends EFactoryImpl implements MutatorFactory {
/**
* Creates the default factory implementation.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static MutatorFactory init() {
try {
MutatorFactory theMutatorFactory = (MutatorFactory)EPackage.Registry.INSTANCE.getEFactory(MutatorPackage.eNS_URI);
if (theMutatorFactory != null) {
return theMutatorFactory;
}
}
catch (Exception exception) {
EcorePlugin.INSTANCE.log(exception);
}
return new MutatorFactoryImpl();
}
/**
* Creates an instance of the factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MutatorFactoryImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EObject create(EClass eClass) {
switch (eClass.getClassifierID()) {
case MutatorPackage.RANDOM_MUTATE_MODEL: return createRandomMutateModel();
default:
throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public RandomMutateModel createRandomMutateModel() {
RandomMutateModelImpl randomMutateModel = new RandomMutateModelImpl();
return randomMutateModel;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public MutatorPackage getMutatorPackage() {
return (MutatorPackage)getEPackage();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @deprecated
* @generated
*/
@Deprecated
public static MutatorPackage getPackage() {
return MutatorPackage.eINSTANCE;
}
} //MutatorFactoryImpl

View File

@ -0,0 +1,194 @@
/**
*/
package mutator.impl;
import de.mdelab.workflow.WorkflowPackage;
import de.mdelab.workflow.components.ComponentsPackage;
import de.mdelab.workflow.helpers.HelpersPackage;
import mutator.MutatorFactory;
import mutator.MutatorPackage;
import mutator.RandomMutateModel;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.impl.EPackageImpl;
/**
* <!-- begin-user-doc -->
* An implementation of the model <b>Package</b>.
* <!-- end-user-doc -->
* @generated
*/
public class MutatorPackageImpl extends EPackageImpl implements MutatorPackage {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private EClass randomMutateModelEClass = null;
/**
* Creates an instance of the model <b>Package</b>, registered with
* {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
* package URI value.
* <p>Note: the correct way to create the package is via the static
* factory method {@link #init init()}, which also performs
* initialization of the package, or returns the registered package,
* if one already exists.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see org.eclipse.emf.ecore.EPackage.Registry
* @see mutator.MutatorPackage#eNS_URI
* @see #init()
* @generated
*/
private MutatorPackageImpl() {
super(eNS_URI, MutatorFactory.eINSTANCE);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private static boolean isInited = false;
/**
* Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
*
* <p>This method is used to initialize {@link MutatorPackage#eINSTANCE} when that field is accessed.
* Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #eNS_URI
* @see #createPackageContents()
* @see #initializePackageContents()
* @generated
*/
public static MutatorPackage init() {
if (isInited) return (MutatorPackage)EPackage.Registry.INSTANCE.getEPackage(MutatorPackage.eNS_URI);
// Obtain or create and register package
Object registeredMutatorPackage = EPackage.Registry.INSTANCE.get(eNS_URI);
MutatorPackageImpl theMutatorPackage = registeredMutatorPackage instanceof MutatorPackageImpl ? (MutatorPackageImpl)registeredMutatorPackage : new MutatorPackageImpl();
isInited = true;
// Initialize simple dependencies
WorkflowPackage.eINSTANCE.eClass();
HelpersPackage.eINSTANCE.eClass();
ComponentsPackage.eINSTANCE.eClass();
// Create package meta-data objects
theMutatorPackage.createPackageContents();
// Initialize created meta-data
theMutatorPackage.initializePackageContents();
// Mark meta-data to indicate it can't be changed
theMutatorPackage.freeze();
// Update the registry and return the package
EPackage.Registry.INSTANCE.put(MutatorPackage.eNS_URI, theMutatorPackage);
return theMutatorPackage;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EClass getRandomMutateModel() {
return randomMutateModelEClass;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EAttribute getRandomMutateModel_ModelSlot() {
return (EAttribute)randomMutateModelEClass.getEStructuralFeatures().get(0);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public MutatorFactory getMutatorFactory() {
return (MutatorFactory)getEFactoryInstance();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private boolean isCreated = false;
/**
* Creates the meta-model objects for the package. This method is
* guarded to have no affect on any invocation but its first.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void createPackageContents() {
if (isCreated) return;
isCreated = true;
// Create classes and their features
randomMutateModelEClass = createEClass(RANDOM_MUTATE_MODEL);
createEAttribute(randomMutateModelEClass, RANDOM_MUTATE_MODEL__MODEL_SLOT);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private boolean isInitialized = false;
/**
* Complete the initialization of the package and its meta-model. This
* method is guarded to have no affect on any invocation but its first.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void initializePackageContents() {
if (isInitialized) return;
isInitialized = true;
// Initialize package
setName(eNAME);
setNsPrefix(eNS_PREFIX);
setNsURI(eNS_URI);
// Obtain other dependent packages
ComponentsPackage theComponentsPackage = (ComponentsPackage)EPackage.Registry.INSTANCE.getEPackage(ComponentsPackage.eNS_URI);
// Create type parameters
// Set bounds for type parameters
// Add supertypes to classes
randomMutateModelEClass.getESuperTypes().add(theComponentsPackage.getWorkflowComponent());
// Initialize classes, features, and operations; add parameters
initEClass(randomMutateModelEClass, RandomMutateModel.class, "RandomMutateModel", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getRandomMutateModel_ModelSlot(), ecorePackage.getEString(), "modelSlot", null, 1, 1, RandomMutateModel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// Create resource
createResource(eNS_URI);
}
} //MutatorPackageImpl

View File

@ -0,0 +1,194 @@
/**
*/
package mutator.impl;
import de.mdelab.workflow.WorkflowExecutionContext;
import de.mdelab.workflow.components.impl.WorkflowComponentImpl;
import de.mdelab.workflow.impl.WorkflowExecutionException;
import fr.tpt.mem4csd.loss.modelMutationUtils.SiteOfLossGenerator;
import mutator.MutatorPackage;
import mutator.RandomMutateModel;
import java.io.IOException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.EMap;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.resource.Resource;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Random Mutate Model</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link mutator.impl.RandomMutateModelImpl#getModelSlot <em>Model Slot</em>}</li>
* </ul>
*
* @generated
*/
public class RandomMutateModelImpl extends WorkflowComponentImpl implements RandomMutateModel {
/**
* The default value of the '{@link #getModelSlot() <em>Model Slot</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getModelSlot()
* @generated
* @ordered
*/
protected static final String MODEL_SLOT_EDEFAULT = null;
/**
* The cached value of the '{@link #getModelSlot() <em>Model Slot</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getModelSlot()
* @generated
* @ordered
*/
protected String modelSlot = MODEL_SLOT_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected RandomMutateModelImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return MutatorPackage.Literals.RANDOM_MUTATE_MODEL;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String getModelSlot() {
return modelSlot;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setModelSlot(String newModelSlot) {
String oldModelSlot = modelSlot;
modelSlot = newModelSlot;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MutatorPackage.RANDOM_MUTATE_MODEL__MODEL_SLOT, oldModelSlot, modelSlot));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case MutatorPackage.RANDOM_MUTATE_MODEL__MODEL_SLOT:
return getModelSlot();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case MutatorPackage.RANDOM_MUTATE_MODEL__MODEL_SLOT:
setModelSlot((String)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case MutatorPackage.RANDOM_MUTATE_MODEL__MODEL_SLOT:
setModelSlot(MODEL_SLOT_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case MutatorPackage.RANDOM_MUTATE_MODEL__MODEL_SLOT:
return MODEL_SLOT_EDEFAULT == null ? modelSlot != null : !MODEL_SLOT_EDEFAULT.equals(modelSlot);
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuilder result = new StringBuilder(super.toString());
result.append(" (modelSlot: ");
result.append(modelSlot);
result.append(')');
return result.toString();
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void execute(final WorkflowExecutionContext context, final IProgressMonitor monitor)
throws WorkflowExecutionException, IOException {
final SubMonitor subMonitor = SubMonitor.convert(monitor, 2);
context.getLogger().addInfo("Modifying a slot.", this);
subMonitor.setTaskName("RandomMutation");
Resource model = getModelResource(context, modelSlot, "temp", true);
EList<EObject> contents = model.getContents();
SiteOfLossGenerator gen = new SiteOfLossGenerator(3);
gen.generateSiteOfLoss(contents);
subMonitor.done();
context.getLogger().addInfo("Done.", this);
}
} //RandomMutateModelImpl

View File

@ -0,0 +1,160 @@
/**
*/
package mutator.util;
import de.mdelab.workflow.NamedComponent;
import de.mdelab.workflow.components.WorkflowComponent;
import mutator.*;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
import org.eclipse.emf.ecore.EObject;
/**
* <!-- begin-user-doc -->
* The <b>Adapter Factory</b> for the model.
* It provides an adapter <code>createXXX</code> method for each class of the model.
* <!-- end-user-doc -->
* @see mutator.MutatorPackage
* @generated
*/
public class MutatorAdapterFactory extends AdapterFactoryImpl {
/**
* The cached model package.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected static MutatorPackage modelPackage;
/**
* Creates an instance of the adapter factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MutatorAdapterFactory() {
if (modelPackage == null) {
modelPackage = MutatorPackage.eINSTANCE;
}
}
/**
* Returns whether this factory is applicable for the type of the object.
* <!-- begin-user-doc -->
* This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model.
* <!-- end-user-doc -->
* @return whether this factory is applicable for the type of the object.
* @generated
*/
@Override
public boolean isFactoryForType(Object object) {
if (object == modelPackage) {
return true;
}
if (object instanceof EObject) {
return ((EObject)object).eClass().getEPackage() == modelPackage;
}
return false;
}
/**
* The switch that delegates to the <code>createXXX</code> methods.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected MutatorSwitch<Adapter> modelSwitch =
new MutatorSwitch<Adapter>() {
@Override
public Adapter caseRandomMutateModel(RandomMutateModel object) {
return createRandomMutateModelAdapter();
}
@Override
public Adapter caseNamedComponent(NamedComponent object) {
return createNamedComponentAdapter();
}
@Override
public Adapter caseWorkflowComponent(WorkflowComponent object) {
return createWorkflowComponentAdapter();
}
@Override
public Adapter defaultCase(EObject object) {
return createEObjectAdapter();
}
};
/**
* Creates an adapter for the <code>target</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param target the object to adapt.
* @return the adapter for the <code>target</code>.
* @generated
*/
@Override
public Adapter createAdapter(Notifier target) {
return modelSwitch.doSwitch((EObject)target);
}
/**
* Creates a new adapter for an object of class '{@link mutator.RandomMutateModel <em>Random Mutate Model</em>}'.
* <!-- begin-user-doc -->
* This default implementation returns null so that we can easily ignore cases;
* it's useful to ignore a case when inheritance will catch all the cases anyway.
* <!-- end-user-doc -->
* @return the new adapter.
* @see mutator.RandomMutateModel
* @generated
*/
public Adapter createRandomMutateModelAdapter() {
return null;
}
/**
* Creates a new adapter for an object of class '{@link de.mdelab.workflow.NamedComponent <em>Named Component</em>}'.
* <!-- begin-user-doc -->
* This default implementation returns null so that we can easily ignore cases;
* it's useful to ignore a case when inheritance will catch all the cases anyway.
* <!-- end-user-doc -->
* @return the new adapter.
* @see de.mdelab.workflow.NamedComponent
* @generated
*/
public Adapter createNamedComponentAdapter() {
return null;
}
/**
* Creates a new adapter for an object of class '{@link de.mdelab.workflow.components.WorkflowComponent <em>Workflow Component</em>}'.
* <!-- begin-user-doc -->
* This default implementation returns null so that we can easily ignore cases;
* it's useful to ignore a case when inheritance will catch all the cases anyway.
* <!-- end-user-doc -->
* @return the new adapter.
* @see de.mdelab.workflow.components.WorkflowComponent
* @generated
*/
public Adapter createWorkflowComponentAdapter() {
return null;
}
/**
* Creates a new adapter for the default case.
* <!-- begin-user-doc -->
* This default implementation returns null.
* <!-- end-user-doc -->
* @return the new adapter.
* @generated
*/
public Adapter createEObjectAdapter() {
return null;
}
} //MutatorAdapterFactory

View File

@ -0,0 +1,146 @@
/**
*/
package mutator.util;
import de.mdelab.workflow.NamedComponent;
import de.mdelab.workflow.components.WorkflowComponent;
import mutator.*;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.util.Switch;
/**
* <!-- begin-user-doc -->
* The <b>Switch</b> for the model's inheritance hierarchy.
* It supports the call {@link #doSwitch(EObject) doSwitch(object)}
* to invoke the <code>caseXXX</code> method for each class of the model,
* starting with the actual class of the object
* and proceeding up the inheritance hierarchy
* until a non-null result is returned,
* which is the result of the switch.
* <!-- end-user-doc -->
* @see mutator.MutatorPackage
* @generated
*/
public class MutatorSwitch<T> extends Switch<T> {
/**
* The cached model package
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected static MutatorPackage modelPackage;
/**
* Creates an instance of the switch.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MutatorSwitch() {
if (modelPackage == null) {
modelPackage = MutatorPackage.eINSTANCE;
}
}
/**
* Checks whether this is a switch for the given package.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param ePackage the package in question.
* @return whether this is a switch for the given package.
* @generated
*/
@Override
protected boolean isSwitchFor(EPackage ePackage) {
return ePackage == modelPackage;
}
/**
* Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the first non-null result returned by a <code>caseXXX</code> call.
* @generated
*/
@Override
protected T doSwitch(int classifierID, EObject theEObject) {
switch (classifierID) {
case MutatorPackage.RANDOM_MUTATE_MODEL: {
RandomMutateModel randomMutateModel = (RandomMutateModel)theEObject;
T result = caseRandomMutateModel(randomMutateModel);
if (result == null) result = caseWorkflowComponent(randomMutateModel);
if (result == null) result = caseNamedComponent(randomMutateModel);
if (result == null) result = defaultCase(theEObject);
return result;
}
default: return defaultCase(theEObject);
}
}
/**
* Returns the result of interpreting the object as an instance of '<em>Random Mutate Model</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Random Mutate Model</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseRandomMutateModel(RandomMutateModel object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Named Component</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Named Component</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseNamedComponent(NamedComponent object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Workflow Component</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Workflow Component</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseWorkflowComponent(WorkflowComponent object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch, but this is the last case anyway.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>EObject</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject)
* @generated
*/
@Override
public T defaultCase(EObject object) {
return null;
}
} //MutatorSwitch

View File

@ -0,0 +1,115 @@
package fr.tpt.mem4csd.loss.modelMutationUtils;
import java.util.Collection;
import java.util.List;
import javax.management.RuntimeErrorException;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.*;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
public class BaseMutations {
public BaseMutations() {
}
protected EObject doCreate(Resource res, EClass clazz) {
EObject obj = EcoreUtil.create(clazz);
res.getContents().add(obj);
return obj;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
protected EObject addComplex(EObject container, EReference reference, EClass clazz, String name) {
EObject obj = EcoreUtil.create(clazz);
obj.eSet(clazz.getEStructuralFeature("name"), name);
if (reference.isMany()) {
((EList) container.eGet(reference)).add(obj);
if (!reference.isContainment()) {
// ECore will add containment if contained.
// Otherwise the object needs to be manually added to the resource.
container.eResource().getContents().add(obj);
}
} else {
container.eSet(reference, obj);
if (!reference.isContainment()) {
// ECore will add containment if contained.
// Otherwise the object needs to be manually added to the resource.
container.eResource().getContents().add(obj);
}
assert container.eIsSet(reference);
}
return obj;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
protected EObject addPrimitive(EObject container, EAttribute attribute, EDataType dataType) {
EObject data = (EObject)dataType.getDefaultValue();
if (attribute.isMany()) {
((EList) container.eGet(attribute)).add(data);
} else {
container.eSet(attribute, data);
}
return data;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void doAdd(EObject container, EStructuralFeature reference, Collection<? extends Object> elements) {
((EList) container.eGet(reference)).addAll(elements);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void doAdd(EObject container, EStructuralFeature reference, Object what, int index) {
((EList) container.eGet(reference)).add(index, what);
}
protected void doSet(EObject container, EStructuralFeature feature, Object value) {
if (value == null) {
container.eUnset(feature);
} else {
container.eSet(feature, value);
}
}
protected void doRemove(EObject object) {
EcoreUtil.remove(object);
}
protected void doRemove(EObject container, EStructuralFeature reference) {
List<?> list = (List<?>) container.eGet(reference);
list.clear();
}
protected void doRemove(EObject container, EStructuralFeature feature, Object element) {
((EList<?>) container.eGet(feature)).remove(element);
}
protected void doRemove(EObject container, EStructuralFeature feature, int index) {
((EList<?>) container.eGet(feature)).remove(index);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void doMoveTo(EObject what, EObject newContainer, EReference reference, int index) {
if (reference.isMany()) {
((EList) newContainer.eGet(reference)).add(index, what);
} else {
newContainer.eSet(reference, what);
}
}
protected void doMoveTo(EObject what, Resource newContainer, int index) {
newContainer.getContents().add(index, what);
}
protected void doChangeIndex(EObject container, EStructuralFeature feature, int oldIndex, int newIndex) {
EList<?> featureValue = (EList<?>) container.eGet(feature);
featureValue.move(newIndex, oldIndex);
}
}

View File

@ -0,0 +1,96 @@
package fr.tpt.mem4csd.loss.modelMutationUtils;
import java.util.Collection;
import java.util.List;
import java.util.Queue;
import java.util.Set;
import java.util.LinkedList;
import java.util.HashSet;
import java.util.ArrayList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.common.util.EList;
public class LimitedAdditionExtractor implements MutationExtractor {
@Override
public List<Mutation> extract(Collection<EObject> rootObjects) {
List<Mutation> mutations = new ArrayList<>();
Queue<EObject> toVisit = new LinkedList<EObject>();
Set<EObject> visited = new HashSet<>();
toVisit.addAll(rootObjects);
while (!toVisit.isEmpty()) {
EObject element = toVisit.poll();
if (element == null || visited.contains(element)) {
continue;
}
visited.add(element);
EClass eclass = element.eClass();
List<EStructuralFeature> features = eclass.getEStructuralFeatures();
for (EStructuralFeature feature : features) {
int lowerBound = feature.getLowerBound();
int upperBound = feature.getUpperBound();
boolean isContainmentRef = feature instanceof EReference;
// Check how many elements exist already.
int existingElements = 0;
Object objExistingFeatures = element.eGet(feature);
if (feature.isMany()) {
// EList
existingElements = ((EList<?>)objExistingFeatures).size();
if (isContainmentRef) {
@SuppressWarnings("unchecked")
EList<ENamedElement> contents = (EList<ENamedElement>)objExistingFeatures;
toVisit.addAll(contents);
}
} else {
// EObject
existingElements = ((objExistingFeatures == null) ? 0 : 1);
if (isContainmentRef) {
toVisit.add((ENamedElement)objExistingFeatures);
}
}
// Primitive Validation. Existing Model must be valid.
assert (existingElements >= lowerBound);
if (upperBound < 0) {
upperBound = maxCardinality;
}
assert (existingElements <= upperBound);
int countToCreate = Integer.min(upperBound, maxCardinality) - existingElements;
for (int i = 0; i < countToCreate; i++) {
mutations.add(new Mutation(Mutation.Type.eCreate, element, feature));
}
}
}
return mutations;
}
public int getMaxCardinality() {
return maxCardinality;
}
public LimitedAdditionExtractor(int maxCardinality) {
super();
this.maxCardinality = maxCardinality;
}
private int maxCardinality;
}

View File

@ -0,0 +1,77 @@
package fr.tpt.mem4csd.loss.modelMutationUtils;
import java.util.Objects;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
public class Mutation {
public enum Type {
eCreate,
eUpdate,
eDestroy
}
public Mutation(Type mutationType, EObject targetElement, EStructuralFeature targetLink) {
super();
this.mutationType = mutationType;
this.targetElement = targetElement;
this.targetLink = targetLink;
}
@Override
public int hashCode() {
return Objects.hash(mutationType, targetElement, targetLink);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Mutation other = (Mutation) obj;
return mutationType == other.mutationType && Objects.equals(targetElement, other.targetElement)
&& Objects.equals(targetLink, other.targetLink);
}
@Override
public String toString() {
String name = "<noname>";
if (targetElement instanceof ENamedElement) {
name = ((ENamedElement)targetElement).getName();
}
else
{
EClass clzz = targetElement.eClass();
if (clzz != null) {
EList<EStructuralFeature> features = clzz.getEAllStructuralFeatures();
for (EStructuralFeature feature : features) {
if (feature.getName().equals("name")) {
name = (String)targetElement.eGet(feature);
}
}
}
}
return "Mutation [" + mutationType + " " + targetLink.getName() + " on " + name + "]";
}
private Type mutationType;
private EObject targetElement;
private EStructuralFeature targetLink;
public Type getMutationType() {
return mutationType;
}
public EObject getTargetElement() {
return targetElement;
}
public EStructuralFeature getTargetLink() {
return targetLink;
}
}

View File

@ -0,0 +1,10 @@
package fr.tpt.mem4csd.loss.modelMutationUtils;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
public interface MutationExtractor {
List<Mutation> extract(Collection<EObject> rootObjects);
}

View File

@ -0,0 +1,80 @@
package fr.tpt.mem4csd.loss.modelMutationUtils;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
public class SiteOfLossGenerator {
public void generateSiteOfLoss(Collection<EObject> root) {
List<Mutation> mutations = extractor.extract(root);
for (Mutation mutation : mutations) {
applyMutation(mutation);
}
}
private EClass findConcreteClass(EClass clazz) {
if (!clazz.isAbstract()) {
return clazz;
}
TreeIterator<EObject> treeIter = clazz.getEPackage().eAllContents();
while (treeIter.hasNext()) {
EObject element = treeIter.next();
if (element instanceof EClass) {
EClass currentClass = (EClass) element;
if (!currentClass.isAbstract() && !currentClass.getName().contains("Abstract") && currentClass.getEAllSuperTypes().contains(clazz)) {
return (EClass) element;
}
}
};
return null;
}
private int idCounter = 0;
private String generateName(EObject parent, EStructuralFeature feature) {
// The EObjects are definitely NamedElements, but can't be casted due to difference in Equinox modules.
String parentName = parent.eGet(parent.eClass().getEStructuralFeature("name")).toString();
return "GEN_" + parentName + "_" + feature.getName() + "_" + idCounter++;
}
private void applyMutation(Mutation mutation) {
if (mutation.getMutationType() == Mutation.Type.eCreate) {
EStructuralFeature feature = mutation.getTargetLink();
EObject element = mutation.getTargetElement();
if (feature instanceof EReference) {
EReference reference = (EReference)feature;
EClass featureType = findConcreteClass(reference.getEReferenceType());
if (featureType == null) {
return;
}
mutator.addComplex(element, reference, featureType, generateName(element, reference));
} else if (feature instanceof EAttribute) {
EAttribute attribute = (EAttribute)feature;
EDataType dataType = attribute.getEAttributeType();
mutator.addPrimitive(element, attribute, dataType);
}
}
}
public SiteOfLossGenerator(int maxCardinality) {
this.maxCardinality = maxCardinality;
extractor = new LimitedAdditionExtractor(maxCardinality);
mutator = new BaseMutations();
}
BaseMutations mutator;
MutationExtractor extractor;
int maxCardinality;
}