Retrieving object/widget after its added to diagram

14 views
Skip to first unread message

JD

unread,
Mar 22, 2010, 9:32:54 AM3/22/10
to gwt-connectors
When I add a widget to my panel I do it as follows:

panel.add(widget,2,2);
Shape shapeWrapper = new Shape(widget);
shapeWrapper.showOnDiagram(diagram);

At some point in my app I will need to access that widget again to
change some of its properties. However it no longer is part of my
panel, but rather a shape on the diagram now. How can I get at the
widget to update it?

thanks

JD

unread,
Mar 22, 2010, 10:24:21 AM3/22/10
to gwt-connectors
I should clarify a bit more. Lets say I do:

panel.add(widget,2,2);
Window.alert(panel.getWidgetIndex(widget)+"");


Shape shapeWrapper = new Shape(widget);
shapeWrapper.showOnDiagram(diagram);

Window.alert(panel.getWidgetIndex(widget)+"");

The first alert will return a valid index and the second alert returns
-1. So at some point the widget gets removed from panel and placed
somewhere else. Saying that, how can I get access to the widget after.

thanks

KenJi_getpowered

unread,
Mar 22, 2010, 12:01:57 PM3/22/10
to gwt-connectors
just get the widget from the absolute pane you put on your diagram

final AbsolutePanel boundaryPanel = new AbsolutePanel();
boundaryPanel.getWidget(windowPanel1);

I know I can click ont the retrieved widget and remove it with that
function

JD

unread,
Mar 22, 2010, 12:37:35 PM3/22/10
to gwt-connectors
Not sure I understand. If you are referring to the absolute panel that
gets passed to the diagram object, then that is the "panel" object in
my previous post. And the widget seems to get removed from that panel
after calling:

shape.showOnDiagram(diagram);

JD

unread,
Mar 23, 2010, 6:51:54 PM3/23/10
to gwt-connectors
So I just added the connectors source code to my project to debug this
and I narrowed it down to this line of code in the
Shape.showOnDiagram() method:

connectionPointsPanel.add(widget, CP_MARGIN, CP_MARGIN);

This line of code adds the widget to another panel in this Shape class
and also removes it from its parent panel (my panel). Thats why I
couldnt access it.

Rizwan

unread,
Apr 22, 2010, 8:40:28 AM4/22/10
to gwt-connectors
So did you find any solution to change properties of the widget
wrapped into shape object ?
--
You received this message because you are subscribed to the Google Groups "gwt-connectors" group.
To post to this group, send email to gwt-con...@googlegroups.com.
To unsubscribe from this group, send email to gwt-connector...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gwt-connectors?hl=en.

JD

unread,
Apr 22, 2010, 8:13:44 PM4/22/10
to gwt-connectors
Yes. After the widget is added to shape, the showOnDiagram() method
removes the widget from its parent and its added to a panel in shape.
Then shape is added to the panel in diagram. So to access it again,
you have to retrieve it from the
Diagram.shapes[].connectionPointsPanel.

I had to dive into the connectors library source to discover that.

Muhammad Rizwan Saeed

unread,
Apr 23, 2010, 9:09:45 AM4/23/10
to gwt-con...@googlegroups.com
Ok but the problem I am facing right now is that I want to have a TextBox on the diagram. But when I wrap the TextBox into Shape object and put it on the diagram using showOnDiagram() method then I cannot enter any text into the TextBox. It seems to become read-only. 

On the other hand if I comment out the line 

diagram.shapeDragController.makeDraggable(this);

in Shape.java then I can enter text into the textbox but ofcourse it is not draggable anymore. But I want to have it draggable and editable at the same time.

Waiting for your prompt reply.

JD

unread,
Apr 23, 2010, 10:29:27 AM4/23/10
to gwt-connectors
Hmmm... not sure about that one. I would have to play around with what
I did to see if I can figure it out... maybe sometime over the
weekend. In my project I had put only and HTML widget into a Shape,
and I could update the content (<div>) of that widget from another
panel.

On Apr 23, 9:09 am, Muhammad Rizwan Saeed <rizzsaee...@gmail.com>
wrote:
> > gwt-connector...@googlegroups.com<gwt-connectors%2Bunsu...@googlegroups.com>
> > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/gwt-connectors?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "gwt-connectors" group.
> > To post to this group, send email to gwt-con...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > gwt-connector...@googlegroups.com<gwt-connectors%2Bunsu...@googlegroups.com>
> > .
Reply all
Reply to author
Forward
0 new messages