Thanks! I actually was still using the old sourceforge repository.
Now my use case gives an dom node not found error, when old widget is
removed.
When I change this to use explicitly the dom parent of the element, it
works fine. Probably somewhere in my application code the dom parent /child
and the widget parent/child is mixed up... Or it may be something else.
The following change works for me. (I experienced the problem in vertical
panel, but it makes sense to use the same procedure for horizontal panel).
Now the DOM remove is done on DOM parent/child relation instead of widget
parent/child relation.
-Janjaap
root@pyl0:/opt/zx/src/pyjamas/library/pyjamas/ui# git diff
diff --git a/library/pyjamas/ui/HorizontalPanel.py
b/library/pyjamas/ui/HorizontalPanel.py
index 380e510..5674826 100644
--- a/library/pyjamas/ui/HorizontalPanel.py
+++ b/library/pyjamas/ui/HorizontalPanel.py
@@ -62,7 +62,8 @@ class HorizontalPanel(CellPanel):
return False
td = DOM.getParent(widget.getElement())
- DOM.removeChild(self.tableRow, td)
+ #DOM.removeChild(self.tableRow, td)
+ DOM.removeChild(DOM.getParent(td), td)
CellPanel.remove(self, widget)
return True
diff --git a/library/pyjamas/ui/VerticalPanel.py
b/library/pyjamas/ui/VerticalPanel.py
index 65a880a..a13c871 100644
--- a/library/pyjamas/ui/VerticalPanel.py
+++ b/library/pyjamas/ui/VerticalPanel.py
@@ -57,7 +57,8 @@ class VerticalPanel(CellPanel):
td = DOM.getParent(widget.getElement())
tr = DOM.getParent(td)
- DOM.removeChild(self.getBody(), tr)
+ #DOM.removeChild(self.getBody(), tr)
+ DOM.removeChild(DOM.getParent(tr), tr)
CellPanel.remove(self, widget)
return True
2012/3/5 lkcl luke <[email protected]>
> On Mon, Mar 5, 2012 at 8:11 PM, Janjaap Bos <[email protected]> wrote:
> > Ok. I've done that. Works fine for me:
>
> git pull. i'd already committed the changes.
>
> l.
>
> > diff --git a/library/pyjamas/ui/ComplexPanel.py
> > b/library/pyjamas/ui/ComplexPanel.py
> > index 190b747..8cfbf99 100644
> > --- a/library/pyjamas/ui/ComplexPanel.py
> > +++ b/library/pyjamas/ui/ComplexPanel.py
> > @@ -27,7 +27,20 @@ class ComplexPanel(Panel):
> > else:
> > self.insert(widget, self.getWidgetCount())
> >
> > - def insert(self, widget, container, beforeIndex):
> > + def insert(self, widget, container, beforeIndex=None):
> > + """ has two modes of operation:
> > + widget, beforeIndex
> > + widget, container, beforeIndex.
> > + if beforeIndex argument is not given, the 1st mode is
> assumed.
> > + this technique is less costly than using *args.
> > + """
> > + if widget.getParent() == self:
> > + return
> > +
> > + if beforeIndex is None:
> > + beforeIndex = container
> > + container = self.getElement()
> > +
> > if widget.getParent() == self:
> > return
> >
> > diff --git a/library/pyjamas/ui/HorizontalPanel.py
> > b/library/pyjamas/ui/HorizontalPanel.py
> > index 0f33618..380e510 100644
> > --- a/library/pyjamas/ui/HorizontalPanel.py
> > +++ b/library/pyjamas/ui/HorizontalPanel.py
> > @@ -27,11 +27,27 @@ class HorizontalPanel(CellPanel):
> > self.tableRow = DOM.createTR()
> > DOM.appendChild(self.getBody(), self.tableRow)
> >
> > - def insert(self, widget, beforeIndex):
> > + def insert(self, widget, container, beforeIndex=None):
> > + """ has two modes of operation:
> > + widget, beforeIndex
> > + widget, container, beforeIndex.
> > + if beforeIndex argument is not given, the 1st mode is
> assumed.
> > + this technique is less costly than using *args.
> > + """
> > + if widget.getParent() == self:
> > + return
> > +
> > + if beforeIndex is None:
> > + beforeIndex = container
> > + container = self.tableRow
> > +
> > + if widget.getParent() == self:
> > + return
> > +
> > widget.removeFromParent()
> >
> > td = DOM.createTD()
> > - DOM.insertChild(self.tableRow, td, beforeIndex)
> > + DOM.insertChild(container, td, beforeIndex)
> >
> > CellPanel.insert(self, widget, td, beforeIndex)
> >
> > diff --git a/library/pyjamas/ui/VerticalPanel.py
> > b/library/pyjamas/ui/VerticalPanel.py
> > index 9b122b6..f6e5b36 100644
> > --- a/library/pyjamas/ui/VerticalPanel.py
> > +++ b/library/pyjamas/ui/VerticalPanel.py
> > @@ -21,13 +21,29 @@ from pyjamas.ui import HasVerticalAlignment
> >
> > class VerticalPanel(CellPanel):
> >
> > - def insert(self, widget, beforeIndex):
> > + def insert(self, widget, container, beforeIndex=None):
> > + """ has two modes of operation:
> > + widget, beforeIndex
> > + widget, container, beforeIndex.
> > + if beforeIndex argument is not given, the 1st mode is
> assumed.
> > + this technique is less costly than using *args.
> > + """
> > + if widget.getParent() == self:
> > + return
> > +
> > + if beforeIndex is None:
> > + beforeIndex = container
> > + container = self.getBody()
> > +
> > + if widget.getParent() == self:
> > + return
> > +
> > widget.removeFromParent()
> >
> > tr = DOM.createTR()
> > td = DOM.createTD()
> >
> > - DOM.insertChild(self.getBody(), tr, beforeIndex)
> > + DOM.insertChild(container, tr, beforeIndex)
> > DOM.appendChild(tr, td)
> >
> > CellPanel.insert(self, widget, td, beforeIndex)
> >
> >
> >
> > 2012/3/5 lkcl luke <[email protected]>
> >>
> >> On Mon, Mar 5, 2012 at 5:34 PM, Janjaap Bos <[email protected]>
> wrote:
> >> > Looks good, but breaks for VerticalPanel and HorizontalPanel, because
> >> > they
> >> > redefine insert.
> >> > When I apply the change below also to them it works fine.
> >>
> >>
> >> ok waitwait.... err... what you have there is something which ignores
> >> the container argument (if it's set). what i'll do is slightly modify
> >> this so that if it's not set, it picks up self.getBody() rather than
> >> self.getElement() in the case of the Vert Panel and self.tableRow in
> >> the Horiz case.
> >>
> >> l.
> >>
> >> > diff --git a/library/pyjamas/ui/ComplexPanel.py
> >> > b/library/pyjamas/ui/ComplexPanel.py
> >> > index 190b747..8cfbf99 100644
> >> > --- a/library/pyjamas/ui/ComplexPanel.py
> >> > +++ b/library/pyjamas/ui/ComplexPanel.py
> >> > @@ -27,7 +27,20 @@ class ComplexPanel(Panel):
> >> > else:
> >> > self.insert(widget, self.getWidgetCount())
> >> >
> >> > - def insert(self, widget, container, beforeIndex):
> >> > + def insert(self, widget, container, beforeIndex=None):
> >> > + """ has two modes of operation:
> >> > + widget, beforeIndex
> >> > + widget, container, beforeIndex.
> >> > + if beforeIndex argument is not given, the 1st mode is
> >> > assumed.
> >> > + this technique is less costly than using *args.
> >> > + """
> >> > + if widget.getParent() == self:
> >> > + return
> >> > +
> >> > + if beforeIndex is None:
> >> > + beforeIndex = container
> >> > + container = self.getElement()
> >> > +
> >> > if widget.getParent() == self:
> >> > return
> >> >
> >> > diff --git a/library/pyjamas/ui/HorizontalPanel.py
> >> > b/library/pyjamas/ui/HorizontalPanel.py
> >> > index 0f33618..941e04e 100644
> >> > --- a/library/pyjamas/ui/HorizontalPanel.py
> >> > +++ b/library/pyjamas/ui/HorizontalPanel.py
> >> > @@ -27,7 +27,23 @@ class HorizontalPanel(CellPanel):
> >> > self.tableRow = DOM.createTR()
> >> > DOM.appendChild(self.getBody(), self.tableRow)
> >> >
> >> > - def insert(self, widget, beforeIndex):
> >> > + def insert(self, widget, container, beforeIndex=None):
> >> > + """ has two modes of operation:
> >> > + widget, beforeIndex
> >> > + widget, container, beforeIndex.
> >> > + if beforeIndex argument is not given, the 1st mode is
> >> > assumed.
> >> > + this technique is less costly than using *args.
> >> > + """
> >> > + if widget.getParent() == self:
> >> > + return
> >> > +
> >> > + if beforeIndex is None:
> >> > + beforeIndex = container
> >> > + container = self.getElement()
> >> > +
> >> > + if widget.getParent() == self:
> >> > + return
> >> > +
> >> > widget.removeFromParent()
> >> >
> >> > td = DOM.createTD()
> >> > diff --git a/library/pyjamas/ui/VerticalPanel.py
> >> > b/library/pyjamas/ui/VerticalPanel.py
> >> > index 9b122b6..f33f729 100644
> >> > --- a/library/pyjamas/ui/VerticalPanel.py
> >> > +++ b/library/pyjamas/ui/VerticalPanel.py
> >> > @@ -21,7 +21,23 @@ from pyjamas.ui import HasVerticalAlignment
> >> >
> >> > class VerticalPanel(CellPanel):
> >> >
> >> > - def insert(self, widget, beforeIndex):
> >> > + def insert(self, widget, container, beforeIndex=None):
> >> > + """ has two modes of operation:
> >> > + widget, beforeIndex
> >> > + widget, container, beforeIndex.
> >> > + if beforeIndex argument is not given, the 1st mode is
> >> > assumed.
> >> > + this technique is less costly than using *args.
> >> > + """
> >> > + if widget.getParent() == self:
> >> > + return
> >> > +
> >> > + if beforeIndex is None:
> >> > + beforeIndex = container
> >> > + container = self.getElement()
> >> > +
> >> > + if widget.getParent() == self:
> >> > + return
> >> > +
> >> > widget.removeFromParent()
> >> >
> >> > tr = DOM.createTR()
> >> >
> >> >
> >> >
> >> > -Janjaap
> >> >
> >> >
> >> >
> >> > 2012/3/5 lkcl luke <[email protected]>
> >> >>
> >> >> the bug's actually in ComplexPanel. let me know if this works.
> tests
> >> >> required to make sure nothing breaks because of this!
> >> >>
> >> >> l.
> >> >>
> >> >> lkcl@teenymac:~/pyjamas/library/pyjamas/ui$ git diff
> >> >> diff --git a/library/pyjamas/ui/ComplexPanel.py
> >> >> b/library/pyjamas/ui/ComplexPane
> >> >> index 190b747..4bc4cf2 100644
> >> >> --- a/library/pyjamas/ui/ComplexPanel.py
> >> >> +++ b/library/pyjamas/ui/ComplexPanel.py
> >> >> @@ -27,10 +27,20 @@ class ComplexPanel(Panel):
> >> >> else:
> >> >> self.insert(widget, self.getWidgetCount())
> >> >>
> >> >> - def insert(self, widget, container, beforeIndex):
> >> >> + def insert(self, widget, container, beforeIndex=None):
> >> >> + """ has two modes of operation:
> >> >> + widget, beforeIndex
> >> >> + widget, container, beforeIndex.
> >> >> + if beforeIndex argument is not given, the 1st mode is
> >> >> assumed.
> >> >> + this technique is less costly than using *args.
> >> >> + """
> >> >> if widget.getParent() == self:
> >> >> return
> >> >>
> >> >> + if beforeIndex is None:
> >> >> + beforeIndex = container
> >> >> + container = self.getElement()
> >> >> +
> >> >> self.adopt(widget, container)
> >> >> self.children.insert(beforeIndex, widget)
> >> >
> >> >
> >
> >
>