Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Programmatically create a compartment
Programmatically create a compartment [message #85065] Wed, 13 December 2006 10:44 Go to next message
Eclipse UserFriend
Originally posted by: zuegg.hotmail.it

Hi,
I'm trying to create a collapsable compartment in my editpart but I
cannot do this by the emf model, so I must add it programmatically. The
compartment should be collapsable and it will contain a list... I tried
many solutions for the problem but with no results. At the end my edit
part should look like this example:

Compartment collapsed:
____________________
| EditPart label |
|--------------------|
|^ |
|--------------------|
| |
| |
| |
|____________________|

Compartment expanded:

____________________
| EditPart label |
|--------------------|
| Object1 |
| Object2 |
| Object3 |
| |
| ^ |
|--------------------|
| |
| |
| |
|____________________|

Hope someone can help me!

Thanks,
Massimo
Re: Programmatically create a compartment [message #85152 is a reply to message #85065] Wed, 13 December 2006 13:20 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello d3K4!n,

And what is the problem with adding compartments in .gmfmap file and then
generating the code?

-----------------
Alex Shatalin
Re: Programmatically create a compartment [message #85237 is a reply to message #85065] Wed, 13 December 2006 16:01 Go to previous message
Mohammed Mostafa is currently offline Mohammed MostafaFriend
Messages: 143
Registered: July 2009
Senior Member
Hi ;

Edit parts will be created automatically when the model exists
Usually the code creating the compartment views exists in the
ViewFactory, the view factory decorate the view during creating it with
compartments. If the compartment exists and there is an edit part
provider for it then the edit part will be created

Another approach will be to override the refreshChildren method on your
edit part, call super then create the compartment edit part if it does
not exists

The third approach will be to play with the getModelChildren method on
the GraphicalEditPart and make it returns the elements you like, the
default implementation looks like this :

protected List getModelChildren() {
Object model = getModel();
if(model!=null && model instanceof View){
return new ArrayList(((View)model).getVisibleChildren());
}
return Collections.EMPTY_LIST;
}

and of course, the obvious way it make the model you use for generation
reflect the fact that there a compartment in this edit part.

There are many ways to implement this behavior, it just depends on where
do you want to do it.



d3K4!n wrote:
> Hi,
> I'm trying to create a collapsable compartment in my editpart but I
> cannot do this by the emf model, so I must add it programmatically. The
> compartment should be collapsable and it will contain a list... I tried
> many solutions for the problem but with no results. At the end my edit
> part should look like this example:
>
> Compartment collapsed:
> ____________________
> | EditPart label |
> |--------------------|
> |^ |
> |--------------------|
> | |
> | |
> | |
> |____________________|
>
> Compartment expanded:
>
> ____________________
> | EditPart label |
> |--------------------|
> | Object1 |
> | Object2 |
> | Object3 |
> | |
> | ^ |
> |--------------------|
> | |
> | |
> | |
> |____________________|
>
> Hope someone can help me!
>
> Thanks,
> Massimo
Previous Topic:GMF: palette and diagram
Next Topic:Adding child automatically when parent is added
Goto Forum:
  


Current Time: Sat Oct 19 13:57:35 GMT 2024

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

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

Back to the top