Home » Modeling » Papyrus » Composite Diagram -default Apply Profile (Palete customization tutorial, add default profile for the new diagrams )
|
Re: Composite Diagram -default Apply Profile [message #634007 is a reply to message #631948] |
Wed, 20 October 2010 09:13 |
|
Hi Andres,
Perhaps you could try to create a new kind of post action for the elements in the palette, which could apply the profile to the root package of the nearest one if required before adding the stereotype.
All post actions are defined in the oep.diagram.common plugin. All the code is located in the org.eclipse.papyrus.diagram.common.service.palette package, and there are some extension points to add also.
Regards,
Rémi
Remi Schnekenburger
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
|
|
|
Re: Composite Diagram -default Apply Profile [message #641874 is a reply to message #634007] |
Mon, 29 November 2010 03:05 |
Andres Messages: 57 Registered: July 2010 |
Member |
|
|
Hi again=), i continue tryng do this without success..
how can i get the root package? what is the meanning of root package of the nearest one?...
i do this, in the constructor of the COnfiguration class (oep.common.service.palette), adding a new parameter editPart, i pass it from the run method of StereotypePostAction CLASS.
i try to load my file with my profile from a profile.uml file:
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
URI fileURI = URI.createFileURI(new File("c:/SoaML.profile.uml").getAbsolutePath());
Resource resource = resourceSet.getResource(fileURI, true);
//
SoaML = (Profile) EcoreUtil.getObjectByType(
resource.getContents(), UMLPackage.Literals.PROFILE);
final EObject objectToEdit = ((View)editPart.getModel()).getElement();
¿this is the correct way to obtain the root package?
then i instance the PackageUtil class from oep.umlutils
and invoke method
applyProfile(((org.eclipse.uml2.uml.Package)packageContainer ), SoaML, false);
This code not work, you can oriented me about the correct steps to do this?
Thanks
|
|
|
Re: Composite Diagram -default Apply Profile [message #642225 is a reply to message #641874] |
Tue, 30 November 2010 13:18 |
|
Hi Andres,
T have common terms:
- the root package is the main element of your model. Usually, in Papyrus, this is the model, the first element you see in the model explorer. This is the place where profiles are usually applied, as the packages see all profiles applied on them and their container packages. If you apply a profile on the root package, you will have access to the profile every where in your model.
- the nearest package is a utility method provided by UML2 project. It is based on the containement feature. When you follow the containement feature, you will get the first package which contains your element.
Imagine this model:
Model1
+ Package 1
+ Package 2
+ + Package 21
+ + Class 211
+ + + Property 2111
+ + Package 22
Root Package : Model 1
Nearest package for Property 2111: Package 21
Nearest package for Class 211: Package 21
Nearest package for Package 21: Package 21
To retrieve the root package, on which you should apply your profile, you can use the org.eclipse.papyrus.umlutils.PackageUtil#getRootPackage(Elem ent) method. when you get your Element using Quote: | final EObject objectToEdit = ((View)editPart.getModel()).getElement();
| : Try to cast the objectToEdit in a UML Element. If it is possible, you should retrieve the root package using the getRootPackage method. On this root package, apply your profile.
HTH,
Rémi
Remi Schnekenburger
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
|
|
| |
Re: Composite Diagram -default Apply Profile [message #643249 is a reply to message #643152] |
Mon, 06 December 2010 09:40 |
|
Hi Andres,
to modify the model, you need to open a transaction. Papyrus is based on the EMFT transaction project, which means that all modifications on the model are based on transaction. This ensure a better stability for the tool, as a command that is not a succes will be undone and the tool will get in the previous stable state.
To open a write transaction, you can use this code snippet: (with command being a subclass of an AbstractTransactionnalCommand)
if(command.canExecute() && !(TransactionUtil.isReadTransactionInProgress(editingDomain, true, true))) {
try {
OperationHistoryFactory.getOperationHistory().execute(command, new NullProgressMonitor(), null);
} catch (ExecutionException e) {
log.error(e);
}
}
HTH,
Rémi
Remi Schnekenburger
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
|
|
| |
Goto Forum:
Current Time: Thu Apr 25 06:16:05 GMT 2024
Powered by FUDForum. Page generated in 0.03300 seconds
|