Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2014-05-07 07:56:43 +0000
committerAnsgar Radermacher2014-05-07 09:26:33 +0000
commit42e4f56af102f9442b5a40f23257b37633b95b1a (patch)
tree9959a429ac8c69dbc84fa225e2dbc1630a6e9291 /extraplugins
parent163e2c7030ea08bc3712f889ac38c8f667431f2f (diff)
downloadorg.eclipse.papyrus-42e4f56af102f9442b5a40f23257b37633b95b1a.tar.gz
org.eclipse.papyrus-42e4f56af102f9442b5a40f23257b37633b95b1a.tar.xz
org.eclipse.papyrus-42e4f56af102f9442b5a40f23257b37633b95b1a.zip
434286 - [C++ codegen] Generate into separate project instead of current project
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/build.acceleo2
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenConstants.java5
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenPreferenceInitializer.java1
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/LocateCppProject.java50
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/Messages.java6
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/messages.properties6
-rw-r--r--extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/deployment/Deploy.java2
-rw-r--r--extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/deployment/GatherConfigData.java2
-rw-r--r--extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/generate/GenerateCode.java2
-rw-r--r--extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/transformations/InstantiateDepPlan.java30
-rw-r--r--extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/transformations/TrafoAndCodegenPackage.java4
11 files changed, 84 insertions, 26 deletions
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/build.acceleo b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/build.acceleo
index 8c148cc5dcd..26abe5ae4c9 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/build.acceleo
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/build.acceleo
@@ -18,7 +18,7 @@
<acceleoCompiler
sourceFolder="${target.folder}"
outputFolder="${target.folder}"
- dependencies="${target.folder}/../../org.eclipse.papyrus.cpp.profile;${target.folder}/../../org.eclipse.papyrus.acceleo;"
+ dependencies="${target.folder}/../../org.eclipse.papyrus.cpp.profile;${target.folder}/../../org.eclipse.papyrus.acceleo;${target.folder}/../../org.eclipse.papyrus.uml.tools.utils;${target.folder}/../../org.eclipse.papyrus.codegen.extensionpoints;"
binaryResource="false"
packagesToRegister="">
</acceleoCompiler>
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenConstants.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenConstants.java
index 6da7ce34190..d67a305a2a8 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenConstants.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenConstants.java
@@ -32,5 +32,10 @@ public class CppCodeGenConstants {
* User defined comment header in generated files
*/
public static final String P_COMMENT_HEADER = "commentHeader"; //$NON-NLS-1$
+
+ /**
+ * Suffix for generated header files
+ */
+ public static final String P_PROJECT_PREFIX = "projectPrefix"; //$NON-NLS-1$
}
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenPreferenceInitializer.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenPreferenceInitializer.java
index 86a582619b5..0cb5cff263c 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenPreferenceInitializer.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/preferences/CppCodeGenPreferenceInitializer.java
@@ -28,6 +28,7 @@ public class CppCodeGenPreferenceInitializer extends AbstractPreferenceInitializ
store.setDefault(CppCodeGenConstants.P_HEADER_SUFFIX, "h"); //$NON-NLS-1$
store.setDefault(CppCodeGenConstants.P_IMPLEM_SUFFIX, "cpp"); //$NON-NLS-1$
store.setDefault(CppCodeGenConstants.P_OUT_INOUT_OP, "*"); //$NON-NLS-1$
+ store.setDefault(CppCodeGenConstants.P_PROJECT_PREFIX, "org.eclipse.papyrus.cppgen."); //$NON-NLS-1$
// Default value for P_COMMENT_HEADER
String NL = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/LocateCppProject.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/LocateCppProject.java
index 2bcb3f1856a..570ba6a0727 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/LocateCppProject.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/LocateCppProject.java
@@ -16,13 +16,20 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.emf.common.util.URI;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.codegen.extensionpoints.ILangSupport;
+import org.eclipse.papyrus.codegen.extensionpoints.LanguageSupport;
import org.eclipse.papyrus.cpp.codegen.Activator;
+import org.eclipse.papyrus.cpp.codegen.preferences.CppCodeGenConstants;
+import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.PackageableElement;
public class LocateCppProject {
+ public static final String LANGUAGE_NAME = "C++"; //$NON-NLS-1$
+
/**
* Locate and return the target project for the given packageable element. Return null if
* no target project can be found.
@@ -35,22 +42,45 @@ public class LocateCppProject {
* @return the associated project, if the C++ nature is applied.
*/
public static IProject getTargetProject(PackageableElement pe, boolean interactive) {
- URI uri = pe.eResource().getURI();
-
+ // URI uri = pe.eResource().getURI();
+ Package rootPkg = PackageUtil.getRootPackage(pe);
+
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- if(uri.segmentCount() < 2)
- return null;
-
- IProject modelProject = root.getProject(uri.segment(1));
- if(!modelProject.exists())
+ /*
+ if(uri.segmentCount() < 2) {
return null;
+ }
+ */
+
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ String prefix = store != null ? store.getString(CppCodeGenConstants.P_PROJECT_PREFIX) : "bad preferences."; //$NON-NLS-1$
+ String projectName = prefix + rootPkg.getName();
+ IProject modelProject = root.getProject(projectName);
+ if(!modelProject.exists()) {
+ boolean create = interactive && MessageDialog.openQuestion(new Shell(),
+ Messages.LocateCppProject_CreateTargetProjectTitle,
+ String.format(Messages.LocateCppProject_CreateTargetProjectDesc, projectName));
+ if (create) {
+ ILangSupport langSupport = LanguageSupport.getLangSupport(LANGUAGE_NAME);
+ if (langSupport != null) {
+ langSupport.resetConfigurationData();
+ modelProject = langSupport.createProject(projectName, null);
+ }
+ else {
+ return null;
+ }
+ }
+ else {
+ return null;
+ }
+ }
// Make sure the target project has the C and C++ build natures.
try {
if(!modelProject.hasNature(CCProjectNature.CC_NATURE_ID)) {
boolean apply = interactive && MessageDialog.openQuestion(new Shell(),
- Messages.LocateCppProject_0,
- Messages.LocateCppProject_1);
+ Messages.LocateCppProject_ApplyCNatureTitle,
+ Messages.LocateCppProject_ApplyCNatureDesc);
if (!apply) {
return null;
}
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/Messages.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/Messages.java
index b353472df03..aa1c639f0c9 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/Messages.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/Messages.java
@@ -4,8 +4,10 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.papyrus.cpp.codegen.utils.messages"; //$NON-NLS-1$
- public static String LocateCppProject_0;
- public static String LocateCppProject_1;
+ public static String LocateCppProject_ApplyCNatureTitle;
+ public static String LocateCppProject_ApplyCNatureDesc;
+ public static String LocateCppProject_CreateTargetProjectTitle;
+ public static String LocateCppProject_CreateTargetProjectDesc;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/messages.properties b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/messages.properties
index d1d2a0f42a9..617270b5e1e 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/messages.properties
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/messages.properties
@@ -1,2 +1,4 @@
-LocateCppProject_0=Need to apply C++ nature
-LocateCppProject_1=Code generation requires that the underlying project has a C++ nature. Do you want to apply this nature?
+LocateCppProject_ApplyCNatureTitle=Need to apply C++ nature
+LocateCppProject_ApplyCNatureDesc=Code generation requires that the underlying project has a C++ nature. Do you want to apply this nature?
+LocateCppProject_CreateTargetProjectDesc=Code generation needs to create a CDT project called "%s". Do you want to do this?
+LocateCppProject_CreateTargetProjectTitle=Target project does not exist
diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/deployment/Deploy.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/deployment/Deploy.java
index b639ecf61e4..2f4f56482d5 100644
--- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/deployment/Deploy.java
+++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/deployment/Deploy.java
@@ -16,7 +16,7 @@ package org.eclipse.papyrus.qompass.designer.core.deployment;
import java.util.Stack;
-import org.eclipse.papyrus.acceleo.extensions.ILangSupport;
+import org.eclipse.papyrus.codegen.extensionpoints.ILangSupport;
import org.eclipse.papyrus.qompass.designer.core.Messages;
import org.eclipse.papyrus.qompass.designer.core.extensions.InstanceConfigurator;
import org.eclipse.papyrus.qompass.designer.core.transformations.LazyCopier;
diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/deployment/GatherConfigData.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/deployment/GatherConfigData.java
index d4ae03eca5c..ac8ea3b5a51 100644
--- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/deployment/GatherConfigData.java
+++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/deployment/GatherConfigData.java
@@ -15,7 +15,7 @@
package org.eclipse.papyrus.qompass.designer.core.deployment;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.acceleo.extensions.ILangSupport;
+import org.eclipse.papyrus.codegen.extensionpoints.ILangSupport;
import org.eclipse.papyrus.qompass.designer.core.listeners.PreCopyListener;
import org.eclipse.papyrus.qompass.designer.core.transformations.LazyCopier;
import org.eclipse.uml2.uml.Class;
diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/generate/GenerateCode.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/generate/GenerateCode.java
index 80d17abc9d7..5715bc9ca6c 100644
--- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/generate/GenerateCode.java
+++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/generate/GenerateCode.java
@@ -19,7 +19,7 @@ import org.eclipse.emf.compare.match.service.MatchService;
import org.eclipse.emf.compare.util.ModelUtils;
*/
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.acceleo.extensions.ILangSupport;
+import org.eclipse.papyrus.codegen.extensionpoints.ILangSupport;
import org.eclipse.papyrus.qompass.designer.core.Messages;
import org.eclipse.papyrus.qompass.designer.core.ModelManagement;
import org.eclipse.papyrus.qompass.designer.core.transformations.TransformationException;
diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/transformations/InstantiateDepPlan.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/transformations/InstantiateDepPlan.java
index 2974b580659..6a24ca63003 100644
--- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/transformations/InstantiateDepPlan.java
+++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/transformations/InstantiateDepPlan.java
@@ -27,10 +27,12 @@ import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.papyrus.FCM.Configuration;
+import org.eclipse.papyrus.FCM.OperatingSystem;
+import org.eclipse.papyrus.FCM.Target;
import org.eclipse.papyrus.FCM.util.MapUtil;
import org.eclipse.papyrus.acceleo.AcceleoDriver;
-import org.eclipse.papyrus.acceleo.extensions.ILangSupport;
-import org.eclipse.papyrus.acceleo.extensions.LanguageSupport;
+import org.eclipse.papyrus.codegen.extensionpoints.ILangSupport;
+import org.eclipse.papyrus.codegen.extensionpoints.LanguageSupport;
import org.eclipse.papyrus.qompass.designer.core.Log;
import org.eclipse.papyrus.qompass.designer.core.Messages;
import org.eclipse.papyrus.qompass.designer.core.ModelManagement;
@@ -58,6 +60,7 @@ import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.PackageableElement;
import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.util.UMLUtil;
/**
* This class executes all transformations during the instantiation of a
@@ -373,16 +376,31 @@ public class InstantiateDepPlan {
String modelName = getModelName(existingModel, node);
IProject genProject = ProjectManagement.getNamedProject(modelName);
if ((genProject == null) || !genProject.exists()) {
- genProject = langSupport.createProject(modelName, node);
+ genProject = langSupport.createProject(modelName, getTargetOS(node));
} else {
langSupport.setProject(genProject);
if ((generationOptions & GenerationOptions.REWRITE_SETTINGS) != 0) {
- langSupport.setSettings(node);
+ langSupport.setSettings(getTargetOS(node));
}
}
return langSupport;
}
+ protected String getTargetOS(InstanceSpecification node) {
+ Target target = UMLUtil.getStereotypeApplication(node, Target.class);
+ if(target == null) {
+ // get information from node referenced by the instance
+ target = UMLUtil.getStereotypeApplication(DepUtils.getClassifier(node), Target.class);
+ }
+ if(target != null) {
+ OperatingSystem os = target.getUsedOS();
+ if(os != null) {
+ return os.getBase_Class().getName();
+ }
+ }
+ return null;
+ }
+
private void destroyDeploymentPlanFolder(Model generatedModel) {
PackageableElement deploymentPlanFolder = generatedModel
.getPackagedElement(DeployConstants.depPlanFolderHw);
@@ -456,9 +474,9 @@ public class InstantiateDepPlan {
private void printAndDisplayErrorMessage(Exception e, final String title,
final boolean consultConsole) {
- String message = e.toString(); //$NON-NLS-1$
+ String message = e.toString();
if (consultConsole) {
- message = message + "\n\n"
+ message = message + "\n\n" //$NON-NLS-1$
+ Messages.InstantiateDepPlan_ConsultConsole;
}
diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/transformations/TrafoAndCodegenPackage.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/transformations/TrafoAndCodegenPackage.java
index b9abb9f1ae5..e72e25e2e7e 100644
--- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/transformations/TrafoAndCodegenPackage.java
+++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.designer.core/src/org/eclipse/papyrus/qompass/designer/core/transformations/TrafoAndCodegenPackage.java
@@ -31,8 +31,8 @@ import org.eclipse.papyrus.FCM.ContainerRule;
import org.eclipse.papyrus.FCM.ContainerRuleKind;
import org.eclipse.papyrus.FCM.util.FCMUtil;
import org.eclipse.papyrus.acceleo.AcceleoDriver;
-import org.eclipse.papyrus.acceleo.extensions.ILangSupport;
-import org.eclipse.papyrus.acceleo.extensions.LanguageSupport;
+import org.eclipse.papyrus.codegen.extensionpoints.ILangSupport;
+import org.eclipse.papyrus.codegen.extensionpoints.LanguageSupport;
import org.eclipse.papyrus.qompass.designer.core.Log;
import org.eclipse.papyrus.qompass.designer.core.Messages;
import org.eclipse.papyrus.qompass.designer.core.ModelManagement;

Back to the top