Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Top level node auto-created on diagram initialization that can not be deleted later
Top level node auto-created on diagram initialization that can not be deleted later [message #799008] Wed, 15 February 2012 10:29 Go to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member
This topic was extracted from question in this thread:

When i create a new "diagram" inside the GMF editor, i should create a config object. Here is the simple ecore model:

- class diagram
reference (1...1) conf: Config

- class config

What is the best way to create some new containing object automatically while creating a new diagram so this will be shown by startup in the plain diagram as a rectangle. How i can avoid the deletion of this object because a diagram must always contain this auto-created object?

[Updated on: Wed, 15 February 2012 10:29]

Report message to a moderator

Re: Top level node auto-created on diagram initialization that can not be deleted later [message #799031 is a reply to message #799008] Wed, 15 February 2012 10:58 Go to previous messageGo to next message
Andreas Muelder is currently offline Andreas MuelderFriend
Messages: 73
Registered: July 2011
Member
Hi Michael,

I have a simiar usecase in my project. I made a custom CreationWizard that creates the semantic and notation elements initialy. Maybe this code is a starting point for you

To avoid the deletion of an object, I did the following steps:

1. Disables deletion for multi selection
Override the SemanticEditPolicy and return false for method shouldProceed(DestroyRequest request)
2. disable deletion via kyeboard (This is unfortunatelly handled in a different way in GMF)
Override the ComponentEditPolicy and return an Unexecutable Command
in method createDeleteCommand() or install the RootComponentEditPolicy

Hope this helps,
Andreas





Re: Top level node auto-created on diagram initialization that can not be deleted later [message #799107 is a reply to message #799031] Wed, 15 February 2012 13:05 Go to previous messageGo to next message
Markus Knoop is currently offline Markus KnoopFriend
Messages: 14
Registered: January 2012
Junior Member
Hello,

thanks for help, this solution mostly works. I create the configuration object while create a new diagram. I return the UnexecutableCommand in the methode getDestroyElementCommand. I can't delete the model object, but i can delete the figure object inside the diagram by pressing the delete key. If i close the diagram and re-open again the config figure is still there and contains all settings made before.

Regards,
Markus Knoop
Re: Top level node auto-created on diagram initialization that can not be deleted later [message #799121 is a reply to message #799107] Wed, 15 February 2012 13:23 Go to previous messageGo to next message
Andreas Muelder is currently offline Andreas MuelderFriend
Messages: 73
Registered: July 2011
Member
Hi Markus,
I used the following code in the edit part of the undeleteable element. This worked for me:
protected void createDefaultEditPolicies() {
   super.createDefaultEditPolicies();
   installEditPolicy(EditPolicy.COMPONENT_ROLE,	new RootComponentEditPolicy());
}


Andreas
Re: Top level node auto-created on diagram initialization that can not be deleted later [message #799212 is a reply to message #799121] Wed, 15 February 2012 16:06 Go to previous messageGo to next message
Markus Knoop is currently offline Markus KnoopFriend
Messages: 14
Registered: January 2012
Junior Member
This works fine. Thanks for help.
Re: Top level node auto-created on diagram initialization that can not be deleted later [message #875274 is a reply to message #799212] Tue, 22 May 2012 12:59 Go to previous message
fatma ben salah is currently offline fatma ben salahFriend
Messages: 2
Registered: May 2012
Junior Member
please i don't undersatnd how i can do a top level node auto created on diagram initialization .please help me
Previous Topic:Create Figure by initiating Diagram
Next Topic:Duplicate command drop-down when dropping nestable widget from palette
Goto Forum:
  


Current Time: Mon Oct 26 11:06:05 GMT 2020

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

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

Back to the top