Hi Tobe,
Sorry - what I meant was: can you give a use case example for what you are
trying to do.

I need more of an idea of how it will be used before I can get my head
around this.

For example, you might want to create a set of instructions (say a recipe)
where everything is done in order so you need to be able to insert/append
steps and move them up and down.

I had a look at your example code and some of it works, but I'm getting
NullPointerExceptions for addInner.

I don't understand why you need addinner and addouter. A real-world example
would help.

Cheers,

Ian

http://examples.roughian.com


2009/8/12 Tobe <[email protected]>

>
> @Ian:
> ok, I have an example what I created so far.I used FlexTables, because
> I think it's the right one for this problem.
> All starts with a FlexTable and a button inside for new outer
> elements. If the user clicks the button, there will be added one new
> row with a TextBox and a button inside a new inner FlexTable to add a
> new inner element and one row to add a new outer element at the end.
> The user can add new outer elements after the first outer button and
> at the end (after the second outer button) - so he can always add
> outer elements at any position. If the user adds the inner button
> there will be added, like the outer one, one new row to the inner
> FlexTable with a new TextBox and one new row with a button to add new
> inner elements. So shall be just this two layers and no third one, so
> there will be added just TextBoxes in the inner FlexTable and no new
> buttons to add inner-inner elements.
> Here is my code:
>
> package de.testgwt.client;
>
> import com.google.gwt.core.client.EntryPoint;
> import com.google.gwt.event.dom.client.ClickEvent;
> import com.google.gwt.event.dom.client.ClickHandler;
> import com.google.gwt.user.client.ui.AbsolutePanel;
> import com.google.gwt.user.client.ui.Button;
> import com.google.gwt.user.client.ui.FlexTable;
> import com.google.gwt.user.client.ui.HTML;
> import com.google.gwt.user.client.ui.RootPanel;
> import com.google.gwt.user.client.ui.TextBox;
> import com.google.gwt.user.client.ui.HTMLTable.Cell;
>
> public class TestGWT implements EntryPoint {
>
>        FlexTable tableOuter;
>        FlexTable tableInner;
>        AbsolutePanel divOuter;
>        AbsolutePanel divInner;
>
>        public void onModuleLoad() {
>                System.out.println("---------------");
>
>                Button buttonAddOuter = new Button("add uter");
>                buttonAddOuter.addClickHandler(new ClickHandler(){
>                        public void onClick(ClickEvent event){
>                                add(event);
>                        }
>                });
>
>                divOuter = new AbsolutePanel();
>                divOuter.add(buttonAddOuter);
>
>                tableOuter = new FlexTable();
>                tableOuter.setWidget(0, 0, divOuter);
>                RootPanel.get().add(tableOuter);
>        }
>
>        public void add(ClickEvent event){
>                Cell cellForEvent = tableOuter.getCellForEvent(event);
>                System.out.println("tableOuter: "+tableOuter.hashCode()+" /
> row:
> "+cellForEvent.getRowIndex());
>
>                divOuter = new AbsolutePanel();
>                divOuter.add(new TextBox());
>
>                tableInner = new FlexTable();
>
>                Button buttonAddInner = new Button("add Inner");
>                buttonAddInner.addClickHandler(new ClickHandler(){
>                        public void onClick(ClickEvent event){
>                                addInner(event);
>                        }
>                });
>
>
>                tableInner.setWidget(0, 0, buttonAddInner);
>                divOuter.add(tableInner);
>
>                tableOuter.insertRow(cellForEvent.getRowIndex()+1);
>                tableOuter.setWidget(cellForEvent.getRowIndex()+1, 0,
> divOuter);
>
>
>                Button buttonAddOuter = new Button("add outer");
>                buttonAddOuter.addClickHandler(new ClickHandler(){
>                        public void onClick(ClickEvent event){
>                                add(event);
>                        }
>                });
>
>                divOuter = new AbsolutePanel();
>                divOuter.add(buttonAddOuter);
>
>
>                tableOuter.insertRow(cellForEvent.getRowIndex()+2);
>                tableOuter.setWidget(cellForEvent.getRowIndex()+2, 0,
> divOuter);
>        }
>
>        public void addInner(ClickEvent event){
>                Cell cellForEvent = tableInner.getCellForEvent(event);
>                System.out.println("tableInner: "+tableInner.hashCode()+" /
> row:
> "+cellForEvent.getRowIndex());
>
>                divInner = new AbsolutePanel();
>                divInner.add(new TextBox());
>
>                tableInner.insertRow(cellForEvent.getRowIndex()+1);
>                tableInner.setWidget(cellForEvent.getRowIndex()+1, 0,
> divInner);
>
>                Button buttonAddInner = new Button("add inner");
>                buttonAddInner.addClickHandler(new ClickHandler(){
>                        public void onClick(ClickEvent event){
>                                addInner(event);
>                        }
>                });
>
>                divInner = new AbsolutePanel();
>                divInner.add(buttonAddInner);
>
>                tableInner.insertRow(cellForEvent.getRowIndex()+2);
>                tableInner.setWidget(cellForEvent.getRowIndex()+2, 0,
> divInner);
>         }
>
> }
>
>
>
> On Aug 10, 8:27 pm, Ian Bambury <[email protected]> wrote:
> > Hi Tobe,
> > You seem to have changed from divs in the root panel to a widget, which
> is
> > probably the right way to go - depends on what you are doing, and you
> don't
> > say.
> >
> > It does rather depend on how you are displaying things, and what you are
> > displaying. If there are columns (apart from the buttons) then are they
> > fixed-width or do they self-adjust? Are the items sorted in some way?
> >
> > If you could give (even a theoretical) example of what this list consists
> > of, then it will be easier to answer. I suspect that the lack of response
> is
> > because people have too many possibilities in mind to comment
> >
> > Ian
> >
> > http://examples.roughian.com
> >
> > 2009/8/10 Tobe <[email protected]>
> >
> >
> >
> >
> >
> > > I'm currently trying to do it with a FlexTable, but the problem is
> > > that I don't know how I can find out if the user really clicked the
> > > button or just somewhere inside the table.
> >
> > > On Aug 10, 3:41 pm, Tobe <[email protected]> wrote:
> > > > I don't really need to know how to create the Array. I already
> created
> > > > a Vector of button and adding the buttons to the Vector. But my
> > > > problem is that I don't know how to handle with it. How can I add the
> > > > new div at the position behind the corresponding button on the
> > > > RootPanel?
> >
> > > > On Aug 7, 5:22 pm, Tobe <[email protected]> wrote:
> >
> > > > > Hi,
> > > > > I have a list, which items are divs, and want the user to add new
> > > > > items at any position. So if there are 2 item there have to be 3
> > > > > button, one before the first, one between both and one after the
> last.
> > > > > Can somebody tell me how to create this "array" of buttons.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to