ggeorg / gwt-mosaic

Automatically exported from code.google.com/p/gwt-mosaic
1 stars 0 forks source link

LiveTable and WindowPanel #61

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello George,

    I do some tests and I would like to check with you if there is
something to be done to display the full window.

When I click the button, only the header of the window appears.

If i change the window size there is no problem and entire table is displayed.

Can you help me.

Thank's

Guy

Specifications :
gwt-mosaic 0.2.2
gwt 1.6.4
gwt-incubator-trunk-r1684

Code :
public class LiveTableWindowPanelTest implements EntryPoint {

    private class Foo implements IsSerializable{
        private String col0;
        private String col1;
        private String col2;
        public String getCol0() {
            return col0;
        }
        public void setCol0(String col0) {
            this.col0 = col0;
        }
        public String getCol1() {
            return col1;
        }
        public void setCol1(String col1) {
            this.col1 = col1;
        }
        public String getCol2() {
            return col2;
        }
        public void setCol2(String col2) {
            this.col2 = col2;
        }

    }

      private void createWindowPanel() {

            WindowPanel w = new WindowPanel("Test");

            LayoutPanel panel = new LayoutPanel();
            panel.add(new LiveTable<Foo>(getTableModel(), createTableDefinition()));

            w.setWidget(panel);

            w.pack();
            w.center();

          }

      private MutableTableModel<Foo> getTableModel(){
          MutableTableModel<Foo> tableModel = new MutableTableModel<Foo>(){

                @Override
                protected boolean onRowInserted(int beforeRow) {
                    return true;
                }

                @Override
                protected boolean onRowRemoved(int row) {
                    return true;
                }

                @Override
                protected boolean onSetRowValue(int row, Foo rowValue) {
                    return true;
                }

                @Override
                public void requestRows(
                        Request request,
                        com.google.gwt.gen2.table.client.TableModel.Callback<Foo> callback) {

                    ArrayList<Foo> fooList = new ArrayList<Foo>();
                    Foo foo = new Foo();
                    foo.setCol0("Desc 0");
                    foo.setCol1("Desc 1");
                    foo.setCol2("Desc 2");

                    fooList.add(foo);

                    SerializableResponse<Foo> response = new
SerializableResponse<Foo>(fooList);
                    callback.onRowsReady(request, response);
                }

            }; 

            return tableModel;

      }

        private TableDefinition<Foo> createTableDefinition() {

            DefaultTableDefinition<Foo> tableDef = new DefaultTableDefinition<Foo>();

            DefaultColumnDefinition<Foo, String> colDef0 = new
DefaultColumnDefinition<Foo, String>(
                    "Col 0") {
              @Override
              public String getCellValue(Foo rowValue) {
                return rowValue.col0;
              }
            };
            colDef0.setColumnSortable(false);
            tableDef.addColumnDefinition(colDef0);

            DefaultColumnDefinition<Foo, String> colDef1 = new
DefaultColumnDefinition<Foo, String>(
                "Col 1") {
              @Override
              public String getCellValue(Foo rowValue) {
                return rowValue.getCol1();
              }
            };
            colDef1.setColumnSortable(false);
            tableDef.addColumnDefinition(colDef1);

            DefaultColumnDefinition<Foo, String> colDef2 = new
DefaultColumnDefinition<Foo, String>(
                "Col 2") {
              @Override
              public String getCellValue(Foo rowValue) {
                return rowValue.getCol2();
              }
            };
            colDef2.setColumnSortable(false);
            tableDef.addColumnDefinition(colDef2);

            return tableDef;
          }

      public void onModuleLoad() {
            RootPanel.get().add(new Button("Create WindowPanel",new ClickHandler(){

                public void onClick(ClickEvent event) {
                    createWindowPanel();

                }

            }));
          }

  }

Original issue reported on code.google.com by administ...@galippe.com on 8 Aug 2009 at 2:15

GoogleCodeExporter commented 9 years ago
hi,

try this:

    panel.add(new LiveTable<Foo>(getTableModel(), createTableDefinition()) {
      @Override
      public Dimension getPreferredSize() {
        return new Dimension(512, 384);
      }
    });

----------------------------------------

Just some hints about WindowPanel:

WindowPanel supports two methods for sizing. 

1. One is to set the size explicitly with WindowPanel.setSize() and call
show()/center()/showModal(false) but NOT pack. In that case the window content 
will
be forced to fit in.

2. By using pack()/showModal()/showModal(true). In that case WindowPanel is 
asking
the child widgets about the preferred size they want. LiveTable and all table 
widgets
do not return a proper value (at least I don't know how to calculate it so far).

Kind Regards,
George.

Original comment by georgopo...@gmail.com on 8 Aug 2009 at 3:11

GoogleCodeExporter commented 9 years ago

Original comment by georgopo...@gmail.com on 8 Aug 2009 at 3:11