Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » one kind of children in one editpart - limitation of gef???
one kind of children in one editpart - limitation of gef??? [message #192577] Fri, 19 August 2005 23:18 Go to next message
Yong cheng is currently offline Yong chengFriend
Messages: 46
Registered: July 2009
Member
Hi,

I have now one problem in my editpart. For example A has B and C as
children. The method getModelChildren in editpart of A can only return one
kind of children (B or C, but not together). The only solution seems to be
let B and C inherit one parent(e.g. D). But that means that B and C should
share one editpart. Is that correct? What I need is the totally different
editparts for B and C. How can I do this?

If I have understood gef correctly, there are a lot of limitations for
building models for gef. How can I hide some model elements in graphics?
For example A has B as children, and B has C as children. But I just want
to show A and C in my graphics. B is only important in model. And how can
I show children figures seprated from the parent figures?

Has anyone solutions for the problems mentioned above?

Thanks a lot

nice weekend

lucia
Re: one kind of children in one editpart - limitation of gef??? [message #192592 is a reply to message #192577] Sat, 20 August 2005 09:27 Go to previous messageGo to next message
Andreas Holtz is currently offline Andreas HoltzFriend
Messages: 53
Registered: July 2009
Member
lucia schrieb am 20.08.2005 01:18:
> Hi,
> I have now one problem in my editpart. For example A has B and C as
> children. The method getModelChildren in editpart of A can only return
> one kind of children (B or C, but not together).

getModelChildren returns a *List* with B and C in it. Based on this list, your EditpartFactory creates the corresponding editparts
(editPartB and editPartC).

> The only solution seems
> to be let B and C inherit one parent(e.g. D). But that means that B and
> C should share one editpart. Is that correct? What I need is the totally
> different editparts for B and C. How can I do this?

your editpartfactory tests on the instances of the model and returns the correct editpart:

<-- snip --->
public class ActivityDiagramEditPartFactory implements EditPartFactory {

private EditPart itsEditPart;

public EditPart createEditPart(EditPart context, Object model) {
if (model instanceof A) {
itsEditPart = new A_EditPart();
itsEditPart.setModel(model);
} else if (model instanceof B) {
itsEditPart = new B_EditPart();
itsEditPart.setModel(model);
} else if (model instanceof C) {
itsEditPart = new C_EditPart();
itsEditPart.setModel(model);
}
}
}
<--- snip -->

> If I have understood gef correctly, there are a lot of limitations for
> building models for gef.

really? i think the only limitation is, that your model must support the observer pattern.

> How can I hide some model elements in graphics?
> For example A has B as children, and B has C as children. But I just
> want to show A and C in my graphics. B is only important in model.

you can hide figures by using a layer (but i think they can't contain children with this solution).

protected IFigure createFigure() {
return new Layer();
}

or if it should contain children (like in your example B contains C):

protected IFigure createFigure() {
Figure figure = new Figure();
figure.setLayoutManager(new ADraw2DLayout());
return figure;
}

> And
> how can I show children figures seprated from the parent figures?
> Has anyone solutions for the problems mentioned above?
>
> Thanks a lot
>
> nice weekend
>
> lucia

Andreas

PS: you _should_ really inspect (or even recode) the given examples linked on the GEF page.
Re: one kind of children in one editpart - limitation of gef??? [message #192600 is a reply to message #192577] Sat, 20 August 2005 09:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: christian.sell.netcologne.de

> building models for gef. How can I hide some model elements in graphics?
> For example A has B as children, and B has C as children. But I just
> want to show A and C in my graphics. B is only important in model. And

in the getModelChildren() method of the A edit part, return the result
of summing up all C's from all B children, like

List result = ...
for all b children
for all b.c children
result.add(c)
return result;

Thus, the graphics will only show A's with C children.

> how can I show children figures seprated from the parent figures?
> Has anyone solutions for the problems mentioned above?

dont understand. What do you mean by "separated"?

christian
??: one kind of children in one editpart - limitation of gef??? [message #192608 is a reply to message #192592] Sat, 20 August 2005 10:37 Go to previous messageGo to next message
Yong cheng is currently offline Yong chengFriend
Messages: 46
Registered: July 2009
Member
Hi, Andreas,

Thank you for your answer. But...

I've tried this exactly as you said. My model is as following:
##############################################
public interface A extends EObject{
/**
* @model
*/
EList getBs();

/**
* @model
*/
EList getCs();
}
###############################################

And the editpart of A has the following method:
###############################################
protected List getModelChildren() {
List list = getA().getBs();
list.addAll(getA().getCs());
return list;
}
###############################################
And I got the error message:
############################################################ ###############
java.lang.ArrayStoreException
at org.eclipse.emf.common.util.BasicEList.assign(BasicEList.jav a:187)
at
org.eclipse.emf.common.util.BasicEList.addAllUnique(BasicELi st.java:772)
at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:428)
at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:367)
at org.eclipse.emf.common.util.BasicEList.addAll(BasicEList.jav a:686)
at
wzl.cosmos.engr.ganttcharteditor.parts.A_EditPart.getModelCh ildren(A_EditPart.java:75)
############################################################ ################

It will be ok if I just return getA().getBs() or getA().getCs().

Can you explain this?

thanks in advance

Lucia
Re: ??: one kind of children in one editpart - limitation of gef??? [message #192617 is a reply to message #192608] Sat, 20 August 2005 10:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Sebastian.Zarnekow.gmx.de

Hi Lucia,

A.getBs() returns the list by reference. If you try to add Cs to the list
of Bs, the underlying implementation of EList throws the exception.
Try the following:
protected List getModelChildren() {
List list = new ArrayList( getA().getBs() );
list.addAll(getA().getCs());
return list;
}
--
Cheers,
Sebastian


L> Hi, Andreas,
L>
L> Thank you for your answer. But...
L>
L> I've tried this exactly as you said. My model is as following:
L> ##############################################
L> public interface A extends EObject{
L> /**
L> * @model
L> */
L> EList getBs();
L> /**
L> * @model
L> */
L> EList getCs();
L> }
L> ###############################################
L>
L> And the editpart of A has the following method:
L> ###############################################
L> protected List getModelChildren() {
L> List list = getA().getBs();
L> list.addAll(getA().getCs());
L> return list;
L> }
L> ###############################################
L> And I got the error message:
L> ############################################################ #########
L> ######
L> java.lang.ArrayStoreException
L> at
L> org.eclipse.emf.common.util.BasicEList.assign(BasicEList.jav a:187)
L> at
L> org.eclipse.emf.common.util.BasicEList.addAllUnique(BasicELi st.java:7
L> 72)
L> at
L> org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(Not
L> ifyingListImpl.java:428)
L> at
L> org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(Not
L> ifyingListImpl.java:367)
L> at
L> org.eclipse.emf.common.util.BasicEList.addAll(BasicEList.jav a:686)
L> at
L> wzl.cosmos.engr.ganttcharteditor.parts.A_EditPart.getModelCh ildren(A_
L> EditPart.java:75)
L> ############################################################ #########
L> #######
L>
L> It will be ok if I just return getA().getBs() or getA().getCs().
L>
L> Can you explain this?
L>
L> thanks in advance
L>
L> Lucia
L>
Re: ??: one kind of children in one editpart - limitation of gef??? [message #192625 is a reply to message #192617] Sat, 20 August 2005 12:56 Go to previous messageGo to next message
Yong cheng is currently offline Yong chengFriend
Messages: 46
Registered: July 2009
Member
Hi, Sebastian,

that's it. Thanks.

Lucia
Thank you very much for all your help! [message #192945 is a reply to message #192577] Tue, 23 August 2005 19:48 Go to previous message
Yong cheng is currently offline Yong chengFriend
Messages: 46
Registered: July 2009
Member
Andreas, Christian, Sebastian,

Thank you very much for all your help!
Previous Topic:GuideLineFigure not visible
Next Topic:Curriculum Vitae
Goto Forum:
  


Current Time: Tue Jan 14 16:20:07 GMT 2025

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

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

Back to the top