Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » write custom string port label/add property role programatically
write custom string port label/add property role programatically [message #651701] Tue, 01 February 2011 10:54 Go to next message
Andres  is currently offline Andres Friend
Messages: 57
Registered: July 2010
Member
Hi, i have two concrete questions=)...I have little knowledge about gmf and emf...

1-I want to write a "custom string" in the port label when i add a port to my diagram.I dont found in what method i would call to do this...


2-When i add a property elemento to a collaboration, i want that this property automatically be a collaboration role, i dont found what classes and what methods i would call to do a property role of collaboration programatically.(I dont want to use the element collaboration role)


Thanks

Andres
Re: write custom string port label/add property role programatically [message #653597 is a reply to message #651701] Thu, 10 February 2011 11:23 Go to previous messageGo to next message
Patrick Tessier is currently offline Patrick TessierFriend
Messages: 238
Registered: July 2009
Location: Paris Saclay, France
Senior Member
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 Go to previous message
Andres  is currently offline Andres Friend
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

Previous Topic:Newbie: Rename a diagram
Next Topic:Showing steretyopes values as comment
Goto Forum:
  


Current Time: Fri Jan 24 04:17:37 GMT 2020

Powered by FUDForum. Page generated in 0.02498 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top