Programmatically create a compartment [message #85065] |
Wed, 13 December 2006 05:44  |
Eclipse User |
|
|
|
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 #85237 is a reply to message #85065] |
Wed, 13 December 2006 11:01  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03709 seconds