diff --git a/plugins/contracts/org.polarsys.chess.contracts.contractPropertyManager/src/org/polarsys/chess/contracts/contractPropertyManager/profile/listener/PapyrusListener.java b/plugins/contracts/org.polarsys.chess.contracts.contractPropertyManager/src/org/polarsys/chess/contracts/contractPropertyManager/profile/listener/PapyrusListener.java index d0500126bfb2e1968948c3232b6d84769929b6d8..6a3a5480800163233117a8a6b020d0f83f892bde 100644 --- a/plugins/contracts/org.polarsys.chess.contracts.contractPropertyManager/src/org/polarsys/chess/contracts/contractPropertyManager/profile/listener/PapyrusListener.java +++ b/plugins/contracts/org.polarsys.chess.contracts.contractPropertyManager/src/org/polarsys/chess/contracts/contractPropertyManager/profile/listener/PapyrusListener.java @@ -65,34 +65,37 @@ public class PapyrusListener implements IPapyrusListener { if (eventType == StereotypeExtensionNotification.STEREOTYPE_APPLIED_TO_ELEMENT) { Property umlProperty = (Property) notifier; - + if (contractEntityUtil.isContractProperty(umlProperty)) { if (notification.getNewValue() instanceof ContractProperty) { 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", - "Do you want to create a new contract or instantiate an existing one?"); + boolean res = MessageDialog.openQuestion(shell, "Question", + "Do you want to create a new contract or instantiate an existing one?"); - Class contract; + Class contract; - if (res) { - String contractName = newContractProperty.getBase_Property().getName().replace("Property", - "") + "Type"; - // create the class that will be converted as + if (res) { + String contractName = newContractProperty.getBase_Property().getName() + .replace("Property", "") + "Type"; + // 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 = createContract((Class) umlProperty.getOwner(), contractName); - } else { - // assign as type of the new contract property the - // selected contract - contract = selectContract(umlProperty); + newContractProperty.getBase_Property().setType((Type) contract); } - // assign to the type of the contractproperty the - // contract - newContractProperty.getBase_Property().setType((Type) contract); - } }