|
Re: write custom string port label/add property role programatically [message #653597 is a reply to message #651701] |
Thu, 10 February 2011 11:23 |
|
1) yes you can add a editpolicy that will manage the display of your label.
We have done that for exemple for role of association see in the class diagram:
AssociationName3EditPart
the editpolicy in charge to do that is:
installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_L ABEL_EDIT_POLICY, new DisplayAssociationEndTargetEditPolicy());
2) it is more complex. in the context of the diagram, you have to find the compartment of the collaboration that contains your property;
Then replace the editpolicy role=EditPolicyRoles.SEMANTIC_ROLE with your own
see example the editppolicy for the creation creation of an attribute into the compartment of attributre
/*****************************************************************************
* Copyright (c) 2010 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
*/
package org.eclipse.papyrus.diagram.clazz.edit.policies;
import org.eclipse.gef.commands.Command;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.papyrus.diagram.clazz.edit.commands.Property4CreateCommand;
import org.eclipse.papyrus.diagram.clazz.providers.UMLElementTypes;
/**
* @generated
*/
public class ClassAttributeCompartment2ItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
/**
* @generated
*/
public ClassAttributeCompartment2ItemSemanticEditPolicy() {
super(UMLElementTypes.Class_2008);
}
/**
* @generated
*/
protected Command getCreateCommand(CreateElementRequest req) {
if(UMLElementTypes.Property_3012 == req.getElementType()) {
return getGEFWrapper(new Property4CreateCommand(req));
}
return super.getCreateCommand(req);
}
}
in you owned editpolicy call your command that create and associate the property to the role of your collaboration
Patrick
|
|
|
Re: write custom string port label/add property role programatically [message #656927 is a reply to message #651701] |
Tue, 01 March 2011 02:51 |
Andres Messages: 57 Registered: July 2010 |
Member |
|
|
Thanks!
Following your instructions, i modificate in my custom common plugin, the class
AppliedStereotypeExternalNodeEditPolicy
and the method refreshStereotypeDisplay() ,
and i can write a string in the port label.
I have a new doubt, when a type is asigned to the port,
i want know the name of the type of the port, and i want know the the classes that the type extends, and the interfaces that the type implements.
For example if i have a class X that extends a class A, and implements Interface I, and the type of my port is X.
How can get this values(A,I), i am trying with the function ((Element)getView().getElement(); ) and casting the return type to TypeElement, but i cant obtain this values..
Can you help me?
Andres
[Updated on: Tue, 01 March 2011 02:51] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03286 seconds