Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2015-06-08 13:22:05 +0000
committerAnsgar Radermacher2015-06-08 13:22:05 +0000
commit77977781e803fe1f306d05898c18be1c8ee66746 (patch)
tree045ce426e711f37be841ea513f170b9b66eb4714 /extraplugins/codegen
parente16cd56839809bd4fbd64e6ef34b4e317a5a6ad8 (diff)
downloadorg.eclipse.papyrus-77977781e803fe1f306d05898c18be1c8ee66746.tar.gz
org.eclipse.papyrus-77977781e803fe1f306d05898c18be1c8ee66746.tar.xz
org.eclipse.papyrus-77977781e803fe1f306d05898c18be1c8ee66746.zip
464481 - [C++ codegen] Bad change detection in C/C++ view
Diffstat (limited to 'extraplugins/codegen')
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.cdtproject/src/org/eclipse/papyrus/cpp/cdtproject/C_CppProjectSupport.java2
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppBehaviorPanel.java58
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppClassPanel.java26
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppGeneralizationPanel.java33
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppOperationPanel.java11
5 files changed, 61 insertions, 69 deletions
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.cdtproject/src/org/eclipse/papyrus/cpp/cdtproject/C_CppProjectSupport.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.cdtproject/src/org/eclipse/papyrus/cpp/cdtproject/C_CppProjectSupport.java
index 54a677c2d6c..5acea591ecf 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.cpp.cdtproject/src/org/eclipse/papyrus/cpp/cdtproject/C_CppProjectSupport.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.cdtproject/src/org/eclipse/papyrus/cpp/cdtproject/C_CppProjectSupport.java
@@ -199,7 +199,7 @@ public class C_CppProjectSupport implements ILangProjectSupport {
Element owner = implementation.getOwner();
while (owner instanceof Package) {
ExternLibrary cppLibrary = UMLUtil.getStereotypeApplication(owner, ExternLibrary.class);
- if (cppLibrary != null) {
+ if ((cppLibrary != null) && (settings != null)) {
settings.includePaths.addAll(cppLibrary.getIncludes());
for (String libPath : cppLibrary.getLibPaths()) {
if (libPath.startsWith("/")) {
diff --git a/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppBehaviorPanel.java b/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppBehaviorPanel.java
index 098f7eba187..0224f59689f 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppBehaviorPanel.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppBehaviorPanel.java
@@ -15,7 +15,6 @@ import org.eclipse.jface.text.IDocument;
import org.eclipse.papyrus.C_Cpp.Virtual;
import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil;
import org.eclipse.papyrus.views.cpp.CommandSupport;
-import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
@@ -40,10 +39,10 @@ public class CppBehaviorPanel extends CppAbstractPanel {
private Behavior selectedBehavior;
- private Button verifyAcceleo;
-
Element selectedEOwner;
+ protected String origBody;
+
public CppBehaviorPanel(Composite parent, int style) {
super(parent, style);
}
@@ -99,14 +98,14 @@ public class CppBehaviorPanel extends CppAbstractPanel {
docBody = createDocumentC();
groupBody = createGroup(
- this
- , "Method body"
- , verifyAcceleo
- , null
- , true
- , 0
- , 0
- , true);
+ this,
+ "Method body", //$NON-NLS-1$
+ buttonSave,
+ null,
+ true,
+ 0,
+ 0,
+ true);
// Use CDT CEditor coloration
createViewerC(docBody, groupBody);
@@ -134,6 +133,7 @@ public class CppBehaviorPanel extends CppAbstractPanel {
public void run() {
// Body
setCppBody(selectedBehavior, docBody.get());
+ origBody = docBody.get();
}
});
}
@@ -208,14 +208,9 @@ public class CppBehaviorPanel extends CppAbstractPanel {
@Override
public boolean checkModifications() {
- // check if ConstInit has changed
-
- String methodBody = getCppBody(selectedBehavior);
-
- if (!(docBody.get().equals(methodBody))) {
+ if (!(docBody.get().equals(origBody))) {
return true;
}
-
return false;
}
@@ -223,9 +218,10 @@ public class CppBehaviorPanel extends CppAbstractPanel {
protected void refreshPanel() {
if (selectedBehavior == null) {
/* Log.debug("resetBody : selectedOperation is null"); */
- } else {
-
+ }
+ else {
String body = getCppBody(selectedBehavior);
+ origBody = body;
docBody.set(body);
}
}
@@ -258,7 +254,7 @@ public class CppBehaviorPanel extends CppAbstractPanel {
@Override
protected void updateModel()
{
- CommandSupport.exec("C++ operation save", new Runnable() {
+ CommandSupport.exec("C++ behavior save", new Runnable() {
@Override
public void run()
@@ -267,31 +263,9 @@ public class CppBehaviorPanel extends CppAbstractPanel {
return;
}
if (selectedEOwner instanceof Class) {
- // toggle Stereotypes pure virtual if element is abstract
- if (selectedBehavior.isAbstract()) {
- if (!StereotypeUtil.isApplied(selectedBehavior, Virtual.class)) {
- // selectedOperation.toggleStereotype("VirtualPure", true);
- // selectedOperation.toggleStereotype("Virtual", false);
- } else {
- // selectedOperation.toggleStereotype("Virtual", false);
- }
- }
-
- // if element is abstract and has VirtualPure, set to Virtual only
- if (!selectedBehavior.isAbstract()) {
- if (StereotypeUtil.isApplied(selectedBehavior, Virtual.class)) {
- // selectedOperation.toggleStereotype("VirtualPure", false);
- // selectedOperation.toggleStereotype("Virtual", true);
- } else {
- // selectedOperation.toggleStereotype("VirtualPure", false);
- // selectedOperation.toggleStereotype("Virtual", false);
- }
- }
}
else {
selectedBehavior.setIsAbstract(true);
- // selectedOperation.toggleStereotype("Virtual", false);
- // selectedOperation.toggleStereotype("VirtualPure", true);
}
}
});
diff --git a/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppClassPanel.java b/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppClassPanel.java
index 3dcc99eee41..6f94852ee3c 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppClassPanel.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppClassPanel.java
@@ -49,6 +49,10 @@ public class CppClassPanel extends CppAbstractPanel {
// Current selection
private Class selectedClass;
+ protected String origHeader;
+
+ protected String origBody;
+
public CppClassPanel(Composite parent, int style) {
super(parent, style);
}
@@ -145,7 +149,9 @@ public class CppClassPanel extends CppAbstractPanel {
} else {
Include cppInclude = StereotypeUtil.applyApp(selectedClass, Include.class);
cppInclude.setHeader(headerDocument.get());
+ origHeader = headerDocument.get();
cppInclude.setBody(bodyDocument.get());
+ origBody = bodyDocument.get();
}
}
});
@@ -170,17 +176,19 @@ public class CppClassPanel extends CppAbstractPanel {
*/
@Override
public boolean checkModifications() {
- String headerInModel = "";
- String bodyInModel = "";
+ // String headerInModel = "";
+ // String bodyInModel = "";
+ /*
Include cppInclude = UMLUtil.getStereotypeApplication(selectedClass, Include.class);
if (cppInclude != null) {
headerInModel = cppInclude.getHeader();
bodyInModel = cppInclude.getBody();
}
-
- boolean headerChanged = !headerDocument.get().equals(headerInModel);
- boolean bodyChanged = !bodyDocument.get().equals(bodyInModel);
+ */
+
+ boolean headerChanged = !headerDocument.get().equals(origHeader);
+ boolean bodyChanged = !bodyDocument.get().equals(origBody);
return (headerChanged | bodyChanged);
}
@@ -199,12 +207,16 @@ public class CppClassPanel extends CppAbstractPanel {
if (cppInclude != null) {
// get the text in the tagged value
String currentHI = cppInclude.getHeader();
+ origHeader = currentHI;
headerDocument.set(currentHI);
String currentBI = cppInclude.getBody();
+ origBody = currentBI;
bodyDocument.set(currentBI);
} else {
- headerDocument.set("");
- bodyDocument.set("");
+ origHeader = ""; //$NON-NLS-1$
+ headerDocument.set(""); //$NON-NLS-1$
+ origBody = ""; //$NON-NLS-1$
+ bodyDocument.set(""); //$NON-NLS-1$
}
}
}
diff --git a/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppGeneralizationPanel.java b/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppGeneralizationPanel.java
index 05b6115a152..085554c903b 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppGeneralizationPanel.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppGeneralizationPanel.java
@@ -34,6 +34,12 @@ import org.eclipse.uml2.uml.util.UMLUtil;
*/
public class CppGeneralizationPanel extends CppAbstractPanel {
+ private static final String PROTECTED = "protected"; //$NON-NLS-1$
+
+ private static final String PUBLIC = "public"; //$NON-NLS-1$
+
+ private static final String PRIVATE = "private"; //$NON-NLS-1$
+
/** Combo box to display visibility */
private Combo vPropCombo;
@@ -90,7 +96,7 @@ public class CppGeneralizationPanel extends CppAbstractPanel {
// Visibility properties combo box
vPropCombo = new Combo(qualifierGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
- String items[] = { "public", "protected", "private" };
+ String items[] = { PUBLIC, PROTECTED, PRIVATE };
vPropCombo.setItems(items);
vPropCombo.addSelectionListener(new SelectionAdapter() {
@@ -115,16 +121,16 @@ public class CppGeneralizationPanel extends CppAbstractPanel {
final String visibilityVal;
switch (comboSelected) {
case 0: /* public */
- visibilityVal = "public";
+ visibilityVal = PUBLIC;
break;
case 1: /* protected */
- visibilityVal = "protected";
+ visibilityVal = PROTECTED;
break;
case 2: /* private */
- visibilityVal = "private";
+ visibilityVal = PRIVATE;
break;
default: /* public */
- visibilityVal = "public";
+ visibilityVal = PUBLIC;
break;
}
final Visibility visibility = UMLUtil.getStereotypeApplication(selectedGeneralization, Visibility.class);
@@ -182,11 +188,11 @@ public class CppGeneralizationPanel extends CppAbstractPanel {
if (visibility != null) {
String vis = visibility.getValue();
- if (vis.equals("public")) {
+ if (vis.equals(PUBLIC)) {
vPropCombo.select(0);
- } else if (vis.equals("protected")) {
+ } else if (vis.equals(PROTECTED)) {
vPropCombo.select(1);
- } else if (vis.equals("private")) {
+ } else if (vis.equals(PRIVATE)) {
vPropCombo.select(2);
} else {
Activator.log(new RuntimeException("Generalization: should never happen, model should be corrected before"));
@@ -215,11 +221,11 @@ public class CppGeneralizationPanel extends CppAbstractPanel {
if (visibility != null) {
String vis = visibility.getValue();
- if (!(vis.equals("public")) || !(vis.equals("protected")) || !(vis.equals("private"))) {
- return false;
+ if ((vis.equals(PUBLIC) || vis.equals(PROTECTED)) || vis.equals(PRIVATE)) {
+ return true;
}
else {
- return true;
+ return false;
}
}
else {
@@ -241,13 +247,12 @@ public class CppGeneralizationPanel extends CppAbstractPanel {
final Visibility visibility = UMLUtil.getStereotypeApplication(selectedGeneralization, Visibility.class);
if (visibility != null) {
- String vis = visibility.getValue();
- if (!(vis.equals("public")) || !(vis.equals("protected")) || !(vis.equals("private"))) {
+ if (!isModelValid()) {
CommandSupport.exec("Correct illegal visibility value", new Runnable() {
@Override
public void run() {
- visibility.setValue("public");
+ visibility.setValue(PUBLIC);
}
});
}
diff --git a/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppOperationPanel.java b/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppOperationPanel.java
index 6fe0d0ed461..e58cad84f77 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppOperationPanel.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.views.cpp/src/org/eclipse/papyrus/views/panels/CppOperationPanel.java
@@ -80,10 +80,10 @@ public class CppOperationPanel extends CppAbstractPanel {
private Operation selectedOperation;
- private Button verifyAcceleo;
-
Element selectedEOwner;
+ protected String origBody;
+
public CppOperationPanel(Composite parent, int style) {
super(parent, style);
}
@@ -255,6 +255,7 @@ public class CppOperationPanel extends CppAbstractPanel {
// Body
setCppBody(selectedOperation, docBody.get());
+ origBody = docBody.get();
}
});
}
@@ -485,9 +486,8 @@ public class CppOperationPanel extends CppAbstractPanel {
return true;
}
- String methodBody = getCppBody(selectedOperation);
-
- if (!(docBody.get().equals(methodBody))) {
+ // String methodBody = getCppBody(selectedOperation);
+ if (!(docBody.get().equals(origBody))) {
return true;
}
@@ -518,6 +518,7 @@ public class CppOperationPanel extends CppAbstractPanel {
}
String body = getCppBody(selectedOperation);
+ origBody = body;
docBody.set(body);
// Combo Box

Back to the top