Skip to content
Snippets Groups Projects
Commit df25d1d5 authored by Nicholas Pacini's avatar Nicholas Pacini
Browse files

added javadoc. small refactoring: package

org.polarsys.chess.codegen.ada.service is not exported at runtime
parent b897b0fe
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,8 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Eclipse-LazyStart: true
Export-Package: org.polarsys.chess.codegen.ada,
org.polarsys.chess.codegen.ada.handlers,
org.polarsys.chess.codegen.ada.main,
org.polarsys.chess.codegen.ada.service
org.polarsys.chess.codegen.ada.transformations,
org.polarsys.chess.codegen.ada.util
......@@ -18,6 +18,7 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import org.polarsys.chess.codegen.ada.transformations.Transformations;
import org.polarsys.chess.codegen.ada.util.AdaGenUtil;
import org.polarsys.chess.core.util.CHESSProjectSupport;
import org.polarsys.chess.core.util.uml.ResourceUtils;
import org.polarsys.chess.m2m.Activator;
......@@ -40,15 +41,20 @@ import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.handlers.HandlerUtil;
/**
* The Class AdaGenUIHandler is the handler of the Ada code generation command (org.polarsys.chess.codegen.ada.ada.id)
* registered through the org.eclipse.ui.commands extension point
*/
public class AdaGenUIHandler extends AbstractHandler {
private IProject getActiveProject(IEditorPart editor) {
IFileEditorInput input = (IFileEditorInput) editor.getEditorInput();
IFile file = input.getFile();
return file.getProject();
}
/**
* implementation of the Ada code generation command as an Eclipse Job.
* Calls the internal implementation, refreshes the active project and prints messages to the CHESS console
*
* @param event the execution event
* @return the object (always null)
* @throws ExecutionException the execution exception
*/
public Object execute(final ExecutionEvent event) throws ExecutionException {
final IEditorPart editor = HandlerUtil.getActiveEditor(event);
......@@ -62,7 +68,7 @@ public class AdaGenUIHandler extends AbstractHandler {
} catch (Exception e) {
throw e;
} finally {
getActiveProject(editor).refreshLocal(IResource.DEPTH_INFINITE, monitor);
AdaGenUtil.getActiveProject(editor).refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
} catch (Exception e) {
e.printStackTrace();
......@@ -94,10 +100,18 @@ public class AdaGenUIHandler extends AbstractHandler {
return null;
}
public Object execute_(IEditorPart editor, IProgressMonitor monitor) throws Exception {
/**
* Internal implementation of the Ada code generation command.
* Loads the UML model and calls the code generation
*
* @param editor the active editor
* @param monitor the progress monitor
* @throws Exception if unable to load the UML model
*/
private void execute_(IEditorPart editor, IProgressMonitor monitor) throws Exception {
monitor.beginTask("Transforming", 4);
if (!(editor instanceof PapyrusMultiDiagramEditor))
return null;
return;
PapyrusMultiDiagramEditor cEditor = (PapyrusMultiDiagramEditor) editor;
Resource inResource = null;
try {
......@@ -111,6 +125,6 @@ public class AdaGenUIHandler extends AbstractHandler {
Transformations.performCodeGeneration((PapyrusMultiDiagramEditor)editor, inputFile, monitor);
//CHESSProjectSupport.fileReplace(newFile, inputFile);
return null;
return;
}
}
......@@ -310,11 +310,10 @@ public class GenerateInfrastructure extends AbstractAcceleoGenerator {
/**
* Adds a properties file in the list of properties files.
*
* @param propertiesFile
* The properties file to add.
* @generated
*
* @param propertiesFile The properties file to add.
* @since 3.1
* @generated
*/
@Override
public void addPropertiesFile(String propertiesFile) {
......
......@@ -55,16 +55,11 @@ public class AcceleoCodeGen {
/**
* Constructor.
*
* @param modelURI
* is the URI of the model.
* @param targetFolder
* is the output folder
* @param arguments
* are the other arguments
* @throws IOException
* Thrown when the output cannot be saved.
* @generated
*
* @param modelURI is the URI of the model.
* @param targetFolder is the output folder
* @param arguments are the other arguments
* @generated
*/
public AcceleoCodeGen(URI modelURI, IContainer targetFolder, List<? extends Object> arguments) {
this.modelURI = modelURI;
......@@ -96,14 +91,12 @@ public class AcceleoCodeGen {
/**
* Finds the template in the plug-in. Returns the template plug-in URI.
*
* @param bundleID
* is the plug-in ID
* @param relativePath
* is the relative path of the template in the plug-in
*
* @param bundleID is the plug-in ID
* @param relativePath is the relative path of the template in the plug-in
* @return the template URI
* @throws IOException
* @generated
* @throws IOException Signals that an I/O exception has occurred.
* @generated
*/
@SuppressWarnings("unused")
private URI getTemplateURI(final String bundleID, final IPath relativePath) throws IOException {
......@@ -143,6 +136,14 @@ public class AcceleoCodeGen {
return result;
}
/**
* Run codegen.
*
* @param model the model
* @param target the target folder
* @param monitor the monitor used to display progress information to the user
* @throws Exception the exception
*/
public static void runCodegen(IFile model, IContainer target, IProgressMonitor monitor) throws Exception {
URI modelURI = URI.createPlatformResourceURI(model.getFullPath().toString(), true);
AcceleoCodeGen generator = new AcceleoCodeGen(modelURI, target, new ArrayList<String>());
......
......@@ -14,60 +14,45 @@
package org.polarsys.chess.codegen.ada.transformations;
import org.polarsys.chess.codegen.ada.Activator;
import org.polarsys.chess.core.util.CHESSProjectSupport;
import org.polarsys.chess.m2m.TransUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.m2m.internal.qvt.oml.emf.util.ModelContent;
import org.eclipse.papyrus.editor.PapyrusMultiDiagramEditor;
import org.eclipse.uml2.uml.Model;
import org.polarsys.chess.core.util.CHESSProjectSupport;
import org.polarsys.chess.m2m.TransUtil;
/**
* The Class Transformations.
*/
@SuppressWarnings("restriction")
public class Transformations {
/**
* Load the model, sets up the environment and performs the Ada code generation.
*
* @param editor the editor
* @param model the model
* @param monitor the monitor
* @throws Exception the exception
*/
public static void performCodeGeneration(final PapyrusMultiDiagramEditor editor, IFile model, IProgressMonitor monitor) throws Exception {
ModelContent mc = TransUtil.loadModel(model);
final Model mi = (Model) mc.getContent().get(0);
// TransactionalEditingDomain editingDomain = editor.getServicesRegistry().getService(ModelSet.class).getTransactionalEditingDomain();
// final InternalValidator v = new InternalValidator(mi, editingDomain);
// int res = InternalValidator.GUI.validate(editor, v, mi);
// if (res != 0)
// return;
String codeGenDir = TransUtil.CODEGEN_DIR + "_" + mi.getName();
// IFolder transDir = model.getProject().getFolder(TransUtil.PIM_PSM_DIR);
IFolder srcDir = model.getProject().getFolder(codeGenDir);
CHESSProjectSupport.bundleToProjectCopy(org.polarsys.chess.codegen.ada.Activator.PLUGIN_ID, org.polarsys.chess.codegen.ada.Activator.getDefault(), "src-lib", model.getProject(), codeGenDir, false);
// Delete the working dir if it exists
// CHESSProjectSupport.deleteFolder(transDir);
// CHESSProjectSupport.createFolder(transDir);
CHESSProjectSupport.createFolder(model.getProject().getFolder(codeGenDir + "/obj"));
// Work on a copy of the model
// IFile modelCopy = CHESSProjectSupport.copyFile(model, TransUtil.PIM_PSM_DIR, model.getName());
// Remove the content of the RtAnalysisPackage
// TransUtil.purgeModel(modelCopy);
//TODO enable the transformation when it works
// Execute the various steps of the transformations
//QVToTransformation.launchPIM2PSM(modelCopy, monitor);
// QVToTransformation.launchCeilingAssignment(modelCopy, monitor);
// Replace the input model file with the transformed model
//CHESSProjectSupport.fileReplace(modelCopy, model);
AcceleoCodeGen.runCodegen(model/*Copy*/, srcDir, monitor);
// Finally delete the working dir
// CHESSProjectSupport.deleteFolder(transDir);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project default="generateInfrastructure" name="org.polarsys.chess.codegen.ada">
<property name="ECLIPSE_HOME" value="../../../../../Programs/CHESS_Luna/eclipse"/>
<property name="ECLIPSE_WORKSPACE" value="../.."/>
<property name="ECLIPSE_HOME" value="../../../../../../../../Programs/CHESS_Luna/eclipse"/>
<property name="ECLIPSE_WORKSPACE" value="../../../../../0.9.0_Workspace"/>
<!-- The classpath with only the dependencies used by the project -->
<path id="org.polarsys.chess.codegen.ada.libraryclasspath">
......@@ -36,13 +36,13 @@
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.acceleo.engine_3.5.1.201409021433.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.emf.codegen.ecore_2.10.2.v20150123-0452.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.emf.codegen_2.10.0.v20150123-0452.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.marte.static.profile_1.0.2.v201502181446.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.marte.static.profile_1.0.2.v201504031223.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.core.commands_3.6.100.v20140528-1422.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.core.resources_3.9.1.v20140825-1431.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.infra.core_1.0.2.v201502181349.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.infra.core.sasheditor_1.0.2.v201502181349.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.infra.core.sasheditor.di_1.0.2.v201502181349.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.editor_1.0.2.v201502181349.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.infra.core_1.0.2.v201504030953.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.infra.core.sasheditor_1.0.2.v201504030953.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.infra.core.sasheditor.di_1.0.2.v201504030953.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.editor_1.0.2.v201504030953.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.m2m.qvt.oml.common_3.4.0.v20140306-0649.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.m2m.qvt.oml.emf.util_3.4.0.v20140306-0718.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.ui_3.106.1.v20141002-1150.jar"/>
......@@ -52,7 +52,7 @@
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.ui.workbench_3.106.2.v20150204-1030.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.e4.ui.workbench3_0.12.0.v20140227-2118.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.ui.ide_3.10.2.v20141118-1227.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.sysml_1.0.2.v201502181349.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.sysml_1.0.2.v201504030953.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.uml2.uml.profile.standard_1.0.0.v20150202-0947.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.ui.views_3.7.0.v20140408-0703.jar"/>
</path>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment