Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Configure created Element
Configure created Element [message #1080207] Mon, 05 August 2013 16:05 Go to next message
Peter  is currently offline Peter
Messages: 85
Registered: July 2009
Member
Hi,
what is the right entry point to configure a created element? In this
case I want to add a Stereotype and the element should show the
Stereotype so I think I should execute the ApplyStereotypeCommand() and
the DefferedAppliedStereotypeToDisplayCommand() but where?
Normally the edit.commands are a good place but Papyrus donĀ“t call them?!
Thanks in advance
Peter
Re: Configure created Element [message #1084895 is a reply to message #1080207] Mon, 12 August 2013 07:32 Go to previous message
Simon Schwichtenberg is currently offline Simon Schwichtenberg
Messages: 126
Registered: September 2011
Senior Member
Consider the palette customization. There you can create your own tools for model elements with applied stereotypes.


Otherwise you can use the extension point for advices and add your code to the getAfterConfigureCommand.

	<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
		<metamodel nsURI="http://www.eclipse.org/uml2/4.0.0/UML">
			
			<adviceBinding id="de.upb.swt.rsdl.editor.ext.advice.ClassEditHelperAdviceDiagram"
				class="de.upb.swt.rsdl.editor.ext.advice.ClassEditHelperAdvice"
				inheritance="all" typeId="org.eclipse.papyrus.uml.diagram.clazz.Class_2008">
			</adviceBinding>
			<adviceBinding id="de.upb.swt.rsdl.editor.ext.advice.ClassEditHelperAdviceTypes"
				class="de.upb.swt.rsdl.editor.ext.advice.ClassEditHelperAdvice"
				inheritance="all" typeId="org.eclipse.papyrus.uml.Class">
			</adviceBinding>
		</metamodel>
	</extension>
<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
		<binding context="org.eclipse.papyrus.infra.services.edit.TypeContext">
			<advice ref="de.upb.swt.rsdl.editor.ext.advice.ClassEditHelperAdviceTypes" />
		</binding>
		<binding context="org.eclipse.papyrus.uml.diagram.clazz.TypeContext">
			<advice ref="de.upb.swt.rsdl.editor.ext.advice.ClassEditHelperAdviceDiagram" />
</binding>
</extension>


public class ClassEditHelperAdvice extends AbstractEditHelperAdvice {

	/**
	 * Context: diagram
	 */
	@Override
	protected ICommand getAfterConfigureCommand(ConfigureRequest request) {

		if(request.getElementToConfigure() instanceof Class){
			return new ClassCreateCommand(request);
		}
		return super.getAfterConfigureCommand(request);
	}


public class ClassCreateCommand extends org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand{
	
@Override
	protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
Class clazz = (Class) configureRequest.getElementToConfigure();
//apply stereotype
}

[Updated on: Mon, 12 August 2013 07:35]

Report message to a moderator

Previous Topic:Connection Handles gone in Papyrus 0.10.0
Next Topic:How in the world do you generate a papyrus model from an existing uml?
Goto Forum:
  


Current Time: Fri Oct 24 18:01:36 GMT 2014

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

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