Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider 7605db1c rédigé par hiba-coder's avatar hiba-coder
Parcourir les fichiers

add xKPI + fixe bugs for smallcasestudy/myrms

parent ee360bfe
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 550 ajouts et 0 suppression
Aucun aperçu pour ce type de fichier
Aucun aperçu pour ce type de fichier
Fichier ajouté
Fichier ajouté
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<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>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>engineConfiguration</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>
eclipse.preferences.version=1
encoding/<project>=UTF-8
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: customizedEngine
Bundle-SymbolicName: engineConfiguration;singleton:=true
Bundle-Version: 0.1.0.qualifier
Import-Package: languageGenFacilities,
org.eclipse.core.runtime,
org.eclipse.core.runtime.jobs
Require-Bundle: org.eclipse.emf.ecore,
org.eclipse.debug.core;bundle-version="3.21.0",
org.eclipse.ui,
engineCustomizing,
org.eclipse.gemoc.xdsmlframework.api;bundle-version="4.0.0"
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<!--<plugin>
<extension
point="org.eclipse.ui.commands">
<command
id="execution.command"
name="Execute model">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="util.ExecutionHandler"
commandId="execution.command">
</handler>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
id="execute.Menu"
label="Execute model">
<command
commandId="execution.command"
style="push">
</command>
</menu>
</menuContribution>
</extension>
</plugin>-->
<plugin>
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<command
commandId="execution.command"
label="Execute model"
style="push">
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
defaultHandler="util.ExecutionHandler"
id="execution.command"
name="Execute model">
</command>
</extension>
</plugin>
\ No newline at end of file
Fichier ajouté
package engine;
public class EngineConfiguration {
public EngineConfiguration(String dslPath, String modelPath) {
CustomizedJavaEngineLauncher launcher= new CustomizedJavaEngineLauncher();
launcher.setDSLPath(dslPath);
launcher.setModelPath(modelPath);
launcher.customExecuteModel();
}
}
package util;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import java.util.HashMap;
import java.util.Set;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;
import org.eclipse.gemoc.xdsmlframework.api.extensions.languages.LanguageDefinitionExtensionPoint;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class ExecutionDialog extends TitleAreaDialog{
private Group languageArea;
private Combo languageCombo;
;
private Group ModelArea;
private Text modelPathInput;
private String selectedDSLPath;
private String modelPath;
public ExecutionDialog(Shell parentShell) {
super(parentShell);
super.setTitle("Generate TraceQL code from DSL definition");
}
@Override
protected Control createDialogArea(Composite parent) {
Composite area = new Composite(parent, SWT.NULL);
FillLayout fillLayout = new FillLayout();
fillLayout.type = SWT.CENTER;
fillLayout.marginHeight = 10;
fillLayout.marginWidth = 10;
area.setLayout(fillLayout);
area.layout();
this.languageArea = createGroup(area, "Select a language");
createLanguageLayout (languageArea, null);
//this.ModelArea = createGroup(area, "Enter the model path");
//createTraceLayout(ModelArea,null);
return area;
}
protected Group createGroup(Composite parent, String text) {
Group group = new Group(parent, SWT.CENTER);
group.setText(text);
GridLayout locationLayout = new GridLayout();
locationLayout.numColumns = 3;
locationLayout.marginHeight = 10;
locationLayout.marginWidth = 10;
group.setLayout(locationLayout);
return group;
}
protected Composite createLanguageLayout(Composite parent, Font font) {
createTextLabelLayout(parent, "Languages");
languageCombo = new Combo(parent, SWT.NONE);
languageCombo.setLayoutData(createStandardLayout());
final HashMap<String, String> languagesPaths = getAllLanguages();
Set<String> languagesNames = (Set<String>) languagesPaths.keySet();
String[] empty = {};
languageCombo.setItems(languagesNames.toArray(empty));
languageCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectedDSLPath = languagesPaths.get(languageCombo.getText());
if (!selectedDSLPath.contains("platform:/plugin")) {
selectedDSLPath = "platform:/plugin" + languagesPaths.get(languageCombo.getText());
}
}
});
createTextLabelLayout(parent, "");
return parent;
}
protected void createTextLabelLayout(Composite parent, String labelString) {
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
parent.setLayoutData(gd);
Label inputLabel = new Label(parent, SWT.NONE);
inputLabel.setText(labelString);
}
protected GridData createStandardLayout() {
return new GridData(SWT.FILL, SWT.CENTER, true, false);
}
public HashMap<String, String> getAllLanguages() {
HashMap<String, String> languagesPaths = new HashMap<String, String>();
IConfigurationElement[] languages = Platform
.getExtensionRegistry().getConfigurationElementsFor(
LanguageDefinitionExtensionPoint.GEMOC_LANGUAGE_EXTENSION_POINT);
for (IConfigurationElement lang : languages) {
String xdsmlPath = lang.getAttribute("xdsmlFilePath");
String xdsmlName = lang.getAttribute("name");
if (xdsmlPath.endsWith(".dsl")) {
languagesPaths.put(xdsmlName, xdsmlPath);
}
}
return languagesPaths;
}
public HashMap<String, IPath> getAllTraceQLProjects() {
HashMap<String, IPath> projects = new HashMap<>();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject[] traceQLProjects = root.getProjects();
for (int i=0; i<traceQLProjects.length; i++) {
projects.put(traceQLProjects[i].getName(), traceQLProjects[i].getFullPath());
}
return projects;
}
public Composite createTraceLayout (Composite parent, Font font) {
modelPathInput = new Text(createElementLayout(parent,"Trace URI"), SWT.BORDER);
GridData textGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
modelPathInput.setLayoutData(textGridData);
return parent;
}
private void saveInputs() {
modelPath = modelPathInput.getText();
}
@Override
protected void okPressed() {
//saveInputs();
super.okPressed();
}
protected Composite createElementLayout(Composite parent, String title) {
Composite elementContainer = new Composite(parent, SWT.NULL);
GridData gridData= new GridData (SWT.FILL,SWT.FILL, true, true, 2, 1);
elementContainer.setLayoutData(gridData);
GridLayout layout = new GridLayout(100, false);
elementContainer.setLayout(layout);
Label label = new Label(elementContainer, SWT.NONE);
label.setText(title);
GridData labelGridData = new GridData(SWT.FILL,SWT.FILL, true, true, 2, 1);
label.setLayoutData(labelGridData);
return elementContainer;
}
public String getSelectedDSLFilePath() {
return this.selectedDSLPath;
}
public String getmodelPath() {
return modelPath;
}
}
package util;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.internal.resources.File;
import org.eclipse.core.internal.resources.Folder;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.handlers.HandlerUtil;
import engine.EngineConfiguration;
public class ExecutionHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
String modelPath = "";
Shell shell = new Shell(HandlerUtil.getActiveWorkbenchWindow(event).getShell());
ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
if (!selection.isEmpty()) {
if (selection instanceof TreeSelection) {
Object element = ((TreeSelection) selection).getFirstElement();
if (element instanceof File) {
modelPath = ((File)element).getRawLocation().toOSString();
}
}
}
try {
ExecutionDialog dialog = new ExecutionDialog(shell);
dialog.create();
if (dialog.open() == Window.OK) {
String dslPath = dialog.getSelectedDSLFilePath();
//modelPath = dialog.getmodelPath();
EngineConfiguration engineConfiguration = new EngineConfiguration(dslPath,modelPath);
}
}catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
Fichier ajouté
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<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>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>engineCustomizing</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>
eclipse.preferences.version=1
encoding/<project>=UTF-8
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: engineCustomizing
Bundle-SymbolicName: engineCustomizing; singleton:=true
Bundle-Version: 0.1.0.qualifier
Require-Bundle: org.eclipse.emf.ecore,
org.eclipse.emf.transaction,
org.eclipse.gemoc.execution.sequential.javaengine;bundle-version="4.0.0",
org.eclipse.gemoc.executionframework.engine;bundle-version="4.0.0",
org.eclipse.jdt.core;bundle-version="3.34.0",
fr.inria.diverse.k3.al.annotationprocessor.plugin;bundle-version="4.2.0",
fr.inria.diverse.melange.adapters;bundle-version="0.4.0",
org.eclipse.gemoc.commons.eclipse;bundle-version="3.6.1",
org.eclipse.gemoc.executionframework.extensions.sirius,
org.eclipse.debug.core,
org.eclipse.gemoc.executionframework.engine.ui;bundle-version="4.0.0",
org.eclipse.gemoc.dsl.debug.ide;bundle-version="3.0.1",
org.eclipse.gemoc.dsl.model
Export-Package: customExecutionContext,
engine
Fichier ajouté
package customExecutionContext;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gemoc.executionframework.engine.commons.DslHelper;
import org.eclipse.gemoc.executionframework.engine.commons.EngineContextException;
import org.eclipse.gemoc.executionframework.engine.core.ExecutionWorkspace;
import org.eclipse.gemoc.trace.commons.model.trace.MSEModel;
import org.eclipse.gemoc.xdsmlframework.api.core.ExecutionMode;
import org.eclipse.gemoc.xdsmlframework.api.core.IExecutionContext;
import org.eclipse.gemoc.xdsmlframework.api.core.IExecutionPlatform;
import org.eclipse.gemoc.xdsmlframework.api.core.IExecutionWorkspace;
import org.eclipse.gemoc.xdsmlframework.api.core.IRunConfiguration;
import org.eclipse.gemoc.xdsmlframework.api.extensions.languages.LanguageDefinitionExtension;
import org.osgi.framework.Bundle;
public abstract class CustomAbstractModelExecutionContext <R extends IRunConfiguration, P extends IExecutionPlatform, L extends LanguageDefinitionExtension> implements
IExecutionContext<R, P, L> {
protected R _runConfiguration;
protected P _executionPlatform;
protected L _languageDefinition;
protected Resource _resourceModel;
protected ExecutionMode _executionMode;
protected Bundle _dslBundle;
private IExecutionWorkspace _executionWorkspace;
public CustomAbstractModelExecutionContext(R runConfiguration, ExecutionMode executionMode) throws EngineContextException {
_runConfiguration = runConfiguration;
_executionMode = executionMode;
init();
}
/*HIBA_MODIF*/
public void init() throws EngineContextException {
try {
_executionWorkspace = new ExecutionWorkspace(_runConfiguration.getExecutedModelURI());
try {
_executionWorkspace.copyFileToExecutionFolder(_executionWorkspace.getModelPath());
} catch (CoreException e) {
// TODO throw warning that we couldn't copy the model
}
_languageDefinition = getLanguageDefinitionExtension(_runConfiguration.getLanguageName());
_dslBundle = DslHelper.getDslBundle(_runConfiguration.getLanguageName());
_executionPlatform = createExecutionPlatform(); // new
// DefaultExecutionPlatform(_languageDefinition,
// _runConfiguration);
} catch (CoreException e) {
EngineContextException exception = new EngineContextException("Cannot initialize the execution context, see inner exception.", e);
throw exception;
}
}
protected abstract P createExecutionPlatform() throws CoreException;
protected abstract L getLanguageDefinitionExtension(String languageName) throws EngineContextException;
@Override
public R getRunConfiguration() {
return _runConfiguration;
}
@Override
public P getExecutionPlatform() {
return _executionPlatform;
}
@Override
public L getLanguageDefinitionExtension() {
return _languageDefinition;
}
@Override
public void initializeResourceModel() {
_resourceModel = _executionPlatform.getModelLoader().loadModel(this);
setUpEditingDomain();
// checkResourceSetContent();
}
@Override
public Resource getResourceModel() {
return _resourceModel;
}
@Override
public void dispose() {
_executionPlatform.dispose();
}
@Override
public IExecutionWorkspace getWorkspace() {
return _executionWorkspace;
}
@Override
public ExecutionMode getExecutionMode() {
return _executionMode;
}
@Override
public Bundle getDslBundle() {
return _dslBundle;
}
/*HIBA_MODIF
protected void checkResourceSetContent() {
// check that the initial resource hasn't been loaded more than once
// (e.g. via melange)
// pure debug code: has no side effect on anything
boolean foundOnce = false;
for (Resource res : _resourceModel.getResourceSet().getResources()) {
boolean found = res.getURI().path().equals(_runConfiguration.getExecutedModelURI().path());
if (found && foundOnce) {
Activator.getDefault().error("Error: found more than one resource in the resourceSet with the following path :" + _runConfiguration.getExecutedModelURI().path());
for (Resource r : _resourceModel.getResourceSet().getResources()) {
Activator.getDefault().info(r.getURI().toString());
}
break;
} else if (found) {
foundOnce = true;
}
}
}*/
private ResourceSet getResourceSet() {
return _resourceModel.getResourceSet();
}
private void setUpEditingDomain() {
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(getResourceSet());
if (editingDomain == null) {
editingDomain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(getResourceSet());
}
}
}
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter