Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Model change problem
Model change problem [message #228515] Tue, 26 December 2006 14:07 Go to next message
Eclipse UserFriend
Originally posted by: jiri.dudek.unicorn.cz

Hi,
i'am developing eclipse view which should display some model via GEF. The model is changed by another thread.
<b>1st problem:</b>
When i add new child to diagram in thread and call refreshChildren() on editpart i get this exception):
Exception in thread "Thread-2" java.lang.NullPointerException
at org.eclipse.draw2d.DeferredUpdateManager.sendUpdateRequest(D eferredUpdateManager.java:225)
at org.eclipse.draw2d.DeferredUpdateManager.queueWork(DeferredU pdateManager.java:215)
at org.eclipse.draw2d.DeferredUpdateManager.addInvalidFigure(De ferredUpdateManager.java:123)
at org.eclipse.draw2d.Figure.revalidate(Figure.java:1347)
at org.eclipse.draw2d.Figure.revalidate(Figure.java:1349)
at org.eclipse.draw2d.Figure.revalidate(Figure.java:1349)
at org.eclipse.draw2d.Figure.revalidate(Figure.java:1349)
at org.eclipse.draw2d.Figure.revalidate(Figure.java:1349)
at org.eclipse.draw2d.Figure.revalidate(Figure.java:1349)
at org.eclipse.draw2d.Figure.revalidate(Figure.java:1349)
at org.eclipse.draw2d.Figure.add(Figure.java:158)
at org.eclipse.draw2d.Figure.add(Figure.java:179)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.addChild Visual(AbstractGraphicalEditPart.java:198)
at org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:197)
at org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(A bstractEditPart.java:727)
at testik.views.ControllerFlowEditPart.add(ControllerFlowEditPa rt.java:52)
at testik.views.ControllerFlowModel.addController(ControllerFlo wModel.java:32)
at testik.views.Adder.run(SampleView.java:94)
at java.lang.Thread.run(Unknown Source)

<b>2nd problem:</b>
When i try to add new child via toolbar button then new child is created without exception but incoming connection has source edit part set to null.
Re: Model change problem [message #228539 is a reply to message #228515] Tue, 26 December 2006 19:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.unknown.com

Figures should be updated on the display thread. Use Display.asyncExec()
when making the model change. Search this newsgroup if you're not sure how.

It isn't clear to me what your second problem is.

"Dudek" <jiri.dudek@unicorn.cz> wrote in message
news:7158394.1167142075168.JavaMail.root@cp1.javalobby.org...
> Hi,
> i'am developing eclipse view which should display some model via GEF. The
> model is changed by another thread.
> <b>1st problem:</b>
> When i add new child to diagram in thread and call refreshChildren() on
> editpart i get this exception):
> Exception in thread "Thread-2" java.lang.NullPointerException
> at
> org.eclipse.draw2d.DeferredUpdateManager.sendUpdateRequest(D eferredUpdateManager.java:225)
> at
> org.eclipse.draw2d.DeferredUpdateManager.queueWork(DeferredU pdateManager.java:215)
> at
> org.eclipse.draw2d.DeferredUpdateManager.addInvalidFigure(De ferredUpdateManager.java:123)
> at org.eclipse.draw2d.Figure.revalidate(Figure.java:1347)
> at org.eclipse.draw2d.Figure.revalidate(Figure.java:1349)
> at org.eclipse.draw2d.Figure.revalidate(Figure.java:1349)
> at org.eclipse.draw2d.Figure.revalidate(Figure.java:1349)
> at org.eclipse.draw2d.Figure.revalidate(Figure.java:1349)
> at org.eclipse.draw2d.Figure.revalidate(Figure.java:1349)
> at org.eclipse.draw2d.Figure.revalidate(Figure.java:1349)
> at org.eclipse.draw2d.Figure.add(Figure.java:158)
> at org.eclipse.draw2d.Figure.add(Figure.java:179)
> at
> org.eclipse.gef.editparts.AbstractGraphicalEditPart.addChild Visual(AbstractGraphicalEditPart.java:198)
> at
> org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:197)
> at
> org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(A bstractEditPart.java:727)
> at testik.views.ControllerFlowEditPart.add(ControllerFlowEditPa rt.java:52)
> at
> testik.views.ControllerFlowModel.addController(ControllerFlo wModel.java:32)
> at testik.views.Adder.run(SampleView.java:94)
> at java.lang.Thread.run(Unknown Source)
>
> <b>2nd problem:</b>
> When i try to add new child via toolbar button then new child is created
> without exception but incoming connection has source edit part set to
> null.
Re: Model change problem [message #228555 is a reply to message #228539] Wed, 27 December 2006 08:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jiri.dudek.unicorn.cz

Thakns for reply. (i debug also it myself after few hours ;) ). As u cas see im new to GEF and elipse plugins also. i try to decribe second problem.

I wanna have view like one in attachment(sampleView.png). New model items should be added in thread. When i add new item than it also create connection between previous and new item. src looks like :
class Model{
List children;
public void add(Item i){
children.add(i); createConnection(children.get(children.size()-2),children.ge t(children.size()-1));
for(Listener l : listeners){
l.fireAddEvent();
}
}
}

there are only one listener : Model editpart.

class ModelEdipart extends AbstractGraphicalEditPart implements Listener {
public void fireAddEvent(){
refreshChildren();
}
}

The problem is that connection looks like in attachment wrong.png. Why ? Because GEF does not find source edit part(getSource() on connection editpart return null)). For now i fix it by fake.

class ConnetionEditPart extends AbstractConnectionEditPart {
protected IFigure createFigure() {
if(getSource()==null){
setSource(getEditPart(((Connection)getModel()).src,getTarget ()));
}
if(getTarget()==null){
setTarget(getEditPart(((Connection)getModel()).dest,getSourc e()));
}
PolylineConnection con = new PolylineConnection();
con.setTargetDecoration(new PolygonDecoration());
return con;
}

private EditPart getEditPart(Controller model,EditPart beginPart){
EditPart par = beginPart;
//find model editpart
while(!(par instanceof ControllerFlowEditPart)){
par = par.getParent();
}
EditPart res=null;
Iterator<EditPart> i = par.getChildren().iterator();
//iterate throught children to find one with same model as model parameter
while(i.hasNext()){
res = i.next();
if(res.getModel() == model){
break;
}
res = null;
}
return res;
}

}
Re: Model change problem [message #228655 is a reply to message #228515] Wed, 03 January 2007 14:15 Go to previous message
Eclipse UserFriend
Originally posted by: jakub.jurkiewicz.gmail.com

Could you explain that more clearly? I understand that the child figure
is created. And when you try to add an incoming connection, than you
cannot do that, yes? Does any exception occures? Could you show the
source how you add the connection to the edit part?

regards

>Dudek wrote:
> <b>2nd problem:</b>
> When i try to add new child via toolbar button then new child is created without exception but incoming connection has source edit part set to null.
Previous Topic:combining SWT widgets and Draw2d Figures
Next Topic:"Static" GEF Figures?
Goto Forum:
  


Current Time: Sun Dec 21 08:37:24 GMT 2014

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

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