Composite Diagram -default Apply Profile [message #631948] |
Sun, 10 October 2010 19:59  |
Eclipse User |
|
|
|
Hello, I write again...
I make a profile (file xxx.profile.uml), i customize the palette for the composite structure diagram for my profile, and make my own plugin like the tutorial palette customization using org.eclipse.papyrus.composite sources.
This work fine, but when i created a new composite diagram and add my elements to the canvas my elements are show without the stereotypes.
i need always first add my profile in the profile tab of diagram.(apply profile), and before my stereotypes are show when i add a new element on the canvas.
Is there any method than i can use to set a default apply profile for my diagrams plugin?
....
what class of the sources ,or extension points i should modify to do this?...
Andres
|
|
|
|
Re: Composite Diagram -default Apply Profile [message #641874 is a reply to message #634007] |
Sun, 28 November 2010 22:05   |
Eclipse User |
|
|
|
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 08:18   |
Eclipse User |
|
|
|
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
|
|
|
|
Re: Composite Diagram -default Apply Profile [message #643249 is a reply to message #643152] |
Mon, 06 December 2010 04:40   |
Eclipse User |
|
|
|
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
|
|
|
Re: Composite Diagram -default Apply Profile [message #645590 is a reply to message #643249] |
Sat, 18 December 2010 07:36  |
Eclipse User |
|
|
|
The solution=) :
I make my own common plugin (is the same that original common, with a new category and some added code)
And in the package oep.diagram.common.commands
in the class CreateUMLModelCommand, in the method initializeModel
i add this code at the end:
Profile myprofile = (Profile)PackageUtil.loadPackage(URI.createURI(" platform:/plugin/org.eclipse.papyrus.diagram.mydiagram/profi le/myprofile.profile.uml "), owner.eResource().getResourceSet());
if(myprofile != null) {
EList<Profile> ls=((org.eclipse.uml2.uml.Package)owner).getAllAppliedProfil es();
if(!ls.contains(myprofile))
PackageUtil.applyProfile(((org.eclipse.uml2.uml.Package)owne r), myprofile, true);
}
thanks for the help.
Andrés
|
|
|
Powered by
FUDForum. Page generated in 0.04613 seconds