Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Problems with creations of Metamodel or Specialization Types with Palette
Problems with creations of Metamodel or Specialization Types with Palette [message #200812] Wed, 06 August 2008 12:24 Go to next message
Eclipse UserFriend
Originally posted by: christian.curie.wanadoo.fr

Hello,

I want to customize programmatically the creation of items, especially the
automatic creation of subitems and properties when the item is created per
palette tool entry.

As explained in the GMF Help, I tried to use the Extensible Type Registry to
extend the default behaviour of an element creation with an
EditHelperAdvice.
(see chapter 'Specifying a Specialization Type' in Eclipse Help->GMF
Developer Guide->Tutorials->Runtime->Extensible Type Registry)

My problem is that the new element with Specialization Type cannot be
created: a 'forbidden' symbol is shown on the screen.



As simple example, I have a state machine with states. The state is the item
I specialize with a Specialization Type.

I instantiate the tool with a CreationTool (or a
UnspecifiedTypeCreationTool, none of the two works)


ElementTypeRegistry registry = ElementTypeRegistry.getInstance();
IElementType elementType =
registry.getType("StateMachine.diagram.specializationState");


// CreationTool creationTool = new CreationTool(elementType);


List types = new ArrayList<IElementType>();

types.add(elementType);

UnspecifiedTypeCreationTool creationTool = new
UnspecifiedTypeCreationTool(types);


with the original state type (created by GMF):

<metamodel nsURI="http://www.example.org/fsm">

<metamodelType

id="StateMachine.diagram.State_2001"

name="%metatype.name.State_2001"

kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"

eclass="State"

edithelper="fsm.diagram.edit.helpers.StateEditHelper">

<param name="semanticHint" value="2001"/>

</metamodelType>

</metamodel>


and one of my tries for the Specialization Type:

<metamodel nsURI="http://www.example.org/fsm">

<specializationType

edithelperadvice="fsm.diagram.ext.SpecialStateEditHelperAdvice "

id="StateMachine.diagram.specializationState"

kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"

name="Special State">

<specializes

id="StateMachine.diagram.State_2001">

</specializes>

<param

name="semanticHint"

value="2001">

</param>

</specializationType>

</metamodel>


Why is the creation of the specialization type excluded? Did I put wrong
values or must I overwrite specific methods in the EditHelperAdvice to get
rid of the 'forbidden' symbol?

Regards
Christian Curie
Re: Problems with creations of Metamodel or Specialization Types with Palette [message #201068 is a reply to message #200812] Thu, 07 August 2008 17:46 Go to previous message
Eclipse UserFriend
Originally posted by: christian.curie.wanadoo.fr

Ok, after deep Debugging, I managed to get rid of the 'forbidden' symbol
and create a customized Specialization Type item with call of its
EditHelperAdvice.

Therefore I had to patch two generated classes:
StateMachineItemSemanticEditPolicy and FSMElementTypes

In getCreateCommand() of StateMachineItemSemanticEditPolicy :

/**

* @generated NOT

*/

protected Command getCreateCommand(CreateElementRequest req) {

if (FSMElementTypes.State_2001 == req.getElementType()

--> || (req.getElementType() instanceof ISpecializationType &&

--> ((ISpecializationType)req.getElementType()).getMetamodelType ()
== FSMElementTypes.State_2001))

{

if (req.getContainmentFeature() == null) {

req.setContainmentFeature(FsmPackage.eINSTANCE

.getStateMachine_States());

}

return getGEFWrapper(new StateCreateCommand(req));

}

return super.getCreateCommand(req);

}


In isKnownElementType() of FSMElementTypes :

/**

* @generated NOT

*/

public static boolean isKnownElementType(IElementType elementType) {

if (KNOWN_ELEMENT_TYPES == null) {

KNOWN_ELEMENT_TYPES = new HashSet();

...

KNOWN_ELEMENT_TYPES.add(State_2001);

...

-->
KNOWN_ELEMENT_TYPES.add(getElementType("StateMachine.diagram.specializationState "));

}

return KNOWN_ELEMENT_TYPES.contains(elementType);

}


But this cannot be the solution, because I want to use the Extensible Type
Registry in a separated plugin and therefore without changing the
originally created diagram code.


I made without success some experiments with the extension points
'org.eclipse.gmf.runtime.diagram.ui.editpolicyProviders' and
'org.eclipse.gmf.runtime.diagram.core.viewProviders'

I looked already in the provided 'Logic' example, but it was not of great
help for me, because it was not based on a generated diagram.

Can someone tell me how to do this with extension points or give me a hint
where to look for?

Regards
Christian Curie
Previous Topic:is the Layout Service example not compatible with GMF 2.1?
Next Topic:scroll bar doesn't want to go away
Goto Forum:
  


Current Time: Tue Jan 28 15:02:15 GMT 2025

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

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

Back to the top