Skip to content
Snippets Groups Projects
Commit 54fb41ad authored by Stefano puri's avatar Stefano puri Committed by Gerrit Code Review @ Polarsys.org
Browse files

Merge "Added a check in the PapyrusListener" into neon

parents 6f6968a8 1e33363e
No related branches found
No related tags found
No related merge requests found
...@@ -65,34 +65,37 @@ public class PapyrusListener implements IPapyrusListener { ...@@ -65,34 +65,37 @@ public class PapyrusListener implements IPapyrusListener {
if (eventType == StereotypeExtensionNotification.STEREOTYPE_APPLIED_TO_ELEMENT) { if (eventType == StereotypeExtensionNotification.STEREOTYPE_APPLIED_TO_ELEMENT) {
Property umlProperty = (Property) notifier; Property umlProperty = (Property) notifier;
if (contractEntityUtil.isContractProperty(umlProperty)) { if (contractEntityUtil.isContractProperty(umlProperty)) {
if (notification.getNewValue() instanceof ContractProperty) { if (notification.getNewValue() instanceof ContractProperty) {
ContractProperty newContractProperty = (ContractProperty) notification.getNewValue(); ContractProperty newContractProperty = (ContractProperty) notification.getNewValue();
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); if (newContractProperty.getBase_Property().getType() == null) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
boolean res = MessageDialog.openQuestion(shell, "Question", boolean res = MessageDialog.openQuestion(shell, "Question",
"Do you want to create a new contract or instantiate an existing one?"); "Do you want to create a new contract or instantiate an existing one?");
Class contract; Class contract;
if (res) { if (res) {
String contractName = newContractProperty.getBase_Property().getName().replace("Property", String contractName = newContractProperty.getBase_Property().getName()
"") + "Type"; .replace("Property", "") + "Type";
// create the class that will be converted as // create the class that will be converted as
// contract
contract = createContract((Class) umlProperty.getOwner(), contractName);
} else {
// assign as type of the new contract property
// the
// selected contract
contract = selectContract(umlProperty);
}
// assign to the type of the contractproperty the
// contract // contract
contract = createContract((Class) umlProperty.getOwner(), contractName); newContractProperty.getBase_Property().setType((Type) contract);
} else {
// assign as type of the new contract property the
// selected contract
contract = selectContract(umlProperty);
} }
// assign to the type of the contractproperty the
// contract
newContractProperty.getBase_Property().setType((Type) contract);
} }
} }
......
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