Example usage for com.google.gwt.user.cellview.client CellTable CellTable

List of usage examples for com.google.gwt.user.cellview.client CellTable CellTable

Introduction

In this page you can find the example usage for com.google.gwt.user.cellview.client CellTable CellTable.

Prototype

public CellTable() 

Source Link

Document

Constructs a table with a default page size of 15.

Usage

From source file:com.ootb.client.application.home.HomePageView.java

License:Apache License

@Inject
public HomePageView(final Binder uiBinder, final MyEntityEditor myEntityEditor,
        final ListDataProvider<MyEntityProxy> dataProvider) {
    this.myEntityEditor = myEntityEditor;
    this.dataProvider = dataProvider;
    this.myTable = new CellTable<MyEntityProxy>();

    initWidget(uiBinder.createAndBindUi(this));

    initCellTable();//w  w  w  .j  av  a 2s.  c  om
    dataProvider.addDataDisplay(myTable);
}

From source file:com.vividcode.imap.app.client.web.application.home.HomePageView.java

License:Apache License

@Inject
HomePageView(Binder uiBinder, MyEntityEditor myEntityEditor, ListDataProvider<MyEntityVO> dataProvider,
        ValidationErrorPopup errorPopup) {
    super(errorPopup);

    this.myEntityEditor = myEntityEditor;
    this.dataProvider = dataProvider;
    this.myTable = new CellTable<MyEntityVO>();
    this.dateFormat = DateTimeFormat.getFormat("dd/MM/yyyy");

    initWidget(uiBinder.createAndBindUi(this));
    initCellTable();//from  w  w  w.  ja  v a 2 s.  co  m
    dataProvider.addDataDisplay(myTable);
}

From source file:de.fhrt.codenvy.bpmn.part.bpmnProperties.widgets.AbstractBpmnDataTableWidget.java

License:Open Source License

public AbstractBpmnDataTableWidget(BpmnPropertiesView.CurrentJsoAccess jsoAccess) {
    Log.info(AbstractBpmnDataTableWidget.class, "constructor()");
    this.jsoAccess = jsoAccess;

    table = new CellTable<T>();
    table.addStyleName("bpmnPropertiesWidget-cellTable");
    table.setWidth("100%");

    buttonPanel = new HorizontalPanel();

    buttonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);

    rootPanel = new VerticalPanel();
    rootPanel.setSize("100%", "auto");
    rootPanel.add(table);/* w  w  w. ja v a 2 s.  co m*/
    rootPanel.add(buttonPanel);

    initWidget(rootPanel);

    dataProvider = new ListDataProvider<T>();
    dataProvider.addDataDisplay(table);
}

From source file:de.fhrt.codenvy.bpmn.part.properties.widgets.AbstractBpmnDataTableWidget.java

License:Open Source License

public AbstractBpmnDataTableWidget(BpmnElementPropertiesView.CurrentJsoAccess jsoAccess) {
    this.jsoAccess = jsoAccess;

    table = new CellTable<T>();
    table.addStyleName("bpmnPropertiesWidget-cellTable");
    table.setWidth("100%");

    buttonPanel = new HorizontalPanel();

    buttonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);

    rootPanel = new VerticalPanel();
    rootPanel.setSize("100%", "auto");
    rootPanel.add(table);//from  ww w  .j a v a 2  s .  c o m
    rootPanel.add(buttonPanel);

    initWidget(rootPanel);

    dataProvider = new ListDataProvider<T>();
    dataProvider.addDataDisplay(table);
}

From source file:n3phele.client.view.CommandListGridView.java

License:Open Source License

public CommandListGridView() {
    super(new MenuItem(N3phele.n3pheleResource.commandIcon(), "Commands", null));
    String html = "<img style='border:none; vertical-align:bottom; margin:-2px; padding-right:2px;' width=20 height=20 src='"
            + N3phele.n3pheleResource.commandIcon().getURL() + "'/>create a new command";
    Button addDataSet = new Button(html, new ClickHandler() {

        @Override//from   w  w w.  ja v a 2  s . c  o m
        public void onClick(ClickEvent event) {
            createUploadPopup();
        }
    });
    addDataSet.setStyleName(N3phele.n3pheleResource.css().newCommandButton());
    this.strip.add(addDataSet);
    HorizontalPanel heading = new HorizontalPanel();
    heading.setWidth("500px");
    heading.setStyleName(N3phele.n3pheleResource.css().sectionPanelHeader());
    add(heading);
    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    simplePager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
    heading.add(simplePager);

    textBox = new TextBox();
    textBox.setTitle("search for a command");
    heading.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    heading.add(textBox);
    heading.setCellHorizontalAlignment(textBox, HorizontalPanel.ALIGN_RIGHT);
    textBox.addKeyPressHandler(new KeyPressHandler() {
        public void onKeyPress(KeyPressEvent event) {
            if (KeyCodes.KEY_ENTER == event.getNativeEvent().getKeyCode()) {
                commandActivity.fetch(0, searchText = textBox.getText(), !allVersions.getValue());
            }
        }
    });

    Image searchIcon = new Image(N3phele.n3pheleResource.searchIcon().getURL());
    searchIcon.setPixelSize(20, 20);
    PushButton search = new PushButton(searchIcon);
    search.setTitle("search for a command");
    search.setStyleName(N3phele.n3pheleResource.css().commandSearchButton());
    heading.add(search);
    search.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            commandActivity.fetch(0, searchText = textBox.getText(), !allVersions.getValue());

        }
    });

    heading.setCellHorizontalAlignment(simplePager, HorizontalPanel.ALIGN_CENTER);
    DisclosurePanel more = new DisclosurePanel("advanced");
    more.setStyleName(N3phele.n3pheleResource.css().sectionPanelHeader());
    heading.add(more);
    heading.setCellHorizontalAlignment(more, HorizontalPanel.ALIGN_LEFT);
    HorizontalPanel disclosed = new HorizontalPanel();
    more.add(disclosed);
    disclosed.add(new InlineLabel("Search all versions"));

    allVersions = new SimpleCheckBox();
    allVersions.setName("allVersions");
    allVersions.setFormValue("Search all versions");
    disclosed.add(allVersions);

    grid = new CellTable<List<Command>>();
    grid.setWidth("100%", true);
    HasCell<Command, ?> nameHasCell = new HasCell<Command, Command>() {

        @Override
        public Cell<Command> getCell() {
            return new CommandTextCell(CommandNameRenderer.getInstance());
        }

        @Override
        public FieldUpdater<Command, Command> getFieldUpdater() {
            return new FieldUpdater<Command, Command>() {

                @Override
                public void update(int index, Command object, Command value) {
                    //                  if(value != null) {
                    //                     GWT.log("got-139 "+index+" "+value.getName());
                    //                     commandActivity.goTo(new CommandPlace(value.getUri()));
                    //                  }

                }
            };
        }

        @Override
        public Command getValue(Command object) {
            return object;
        }

    };
    HasCell<Command, ?> versionHasCell = new HasCell<Command, Command>() {

        @Override
        public Cell<Command> getCell() {
            return new CommandTextCell(CommandVersionRenderer.getInstance());
        }

        @Override
        public FieldUpdater<Command, Command> getFieldUpdater() {
            return new FieldUpdater<Command, Command>() {

                @Override
                public void update(int index, Command object, Command value) {
                    //                  if(value != null) {
                    //                     GWT.log("got-166 "+index+" "+value.getName());
                    //                     commandActivity.goTo(new CommandPlace(value.getUri()));
                    //                  }

                }
            };
        }

        @Override
        public Command getValue(Command object) {
            return object;
        }

    };

    List<HasCell<Command, ?>> hasCells = new ArrayList<HasCell<Command, ?>>(2);
    hasCells.add(nameHasCell);
    hasCells.add(versionHasCell);
    for (int i = 0; i < ROWLENGTH; i++) {
        Column<List<Command>, Command> c = new Column<List<Command>, Command>(new CommandIconTextCell(
                N3phele.n3pheleResource.scriptIcon(), new CompositeCell<Command>(hasCells), i)) {

            @Override
            public Command getValue(List<Command> object) {
                int index = ((CommandIconTextCell) this.getCell()).getIndex();
                if (index < object.size()) {
                    return object.get(index);
                } else {
                    return null;
                }
            }
        };
        c.setFieldUpdater(new FieldUpdater<List<Command>, Command>() {

            @Override
            public void update(int index, List<Command> object, Command value) {
                if (value != null) {
                    GWT.log("got-201 " + index + " " + value.getName());
                    commandActivity.goTo(new CommandPlace(value.getUri()));
                }

            }
        });
        grid.addColumn(c);
        grid.setColumnWidth(c, 100.0 / ROWLENGTH, Unit.PCT);
    }

    grid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    simplePager.setDisplay(grid);
    simplePager.setPageSize(PAGESIZE);
    grid.addRangeChangeHandler(new RangeChangeEvent.Handler() {

        /* (non-Javadoc)
         * @see com.google.gwt.view.client.RangeChangeEvent.Handler#onRangeChange(com.google.gwt.view.client.RangeChangeEvent)
         */
        @Override
        public void onRangeChange(RangeChangeEvent event) {
            if (suppressEvent)
                return;
            Range range = grid.getVisibleRange();
            GWT.log("Table range is " + range.getStart() + " length " + range.getLength());
            int start = range.getStart();
            if (start > total)
                start = total;
            //            if(data == null || (data.size() < start) ){

            commandActivity.fetch(start, searchText, !allVersions.getValue());
            //            } else {
            //               if(length+start > data.size())
            //                  length = data.size()-start;
            //               GWT.log("data available start="+start);
            //               grid.setRowData(start, chunk(data.subList(start, start+length)));
            //            }
        }

    });
    this.add(grid);
}

From source file:n3phele.client.view.CommandListView.java

License:Open Source License

public CommandListView() {
    super(new MenuItem(N3phele.n3pheleResource.commandIcon(), "Commands", null));
    cellTable = new CellTable<Command>();
    cellTable.setSize("455px", "");

    //      TextColumn<Command> nameColumn = new TextColumn<Command>() {
    //         @Override
    //         public String getValue(Command command) {
    //            String result = "";
    //            if(command != null)
    //               return command.getName();
    //            return result;
    //         }/* ww w . j  a  v  a2 s  . co  m*/
    //      };
    //      cellTable.addColumn(nameColumn, "Name");

    Column<Command, Hyperlink> nameColumn = new Column<Command, Hyperlink>(new HyperlinkCell()) {

        @Override
        public Hyperlink getValue(Command command) {
            if (command == null)
                return null;
            String name = command.getName();
            String historyToken = commandActivity.getToken(command);
            return new Hyperlink(name, historyToken);
        }

    };

    nameColumn.setFieldUpdater(new FieldUpdater<Command, Hyperlink>() {
        @Override
        public void update(int index, Command object, Hyperlink value) {
            CommandListView.this.commandActivity.goTo(new CommandPlace(object.getUri()));
        }
    });
    cellTable.addColumn(nameColumn, "Name");

    TextColumn<Command> descriptionColumn = new TextColumn<Command>() {
        @Override
        public String getValue(Command command) {
            String result = "";
            if (command != null)
                return command.getDescription();
            return result;
        }
    };
    cellTable.addColumn(descriptionColumn, "Description");
    //       // Add a selection model to handle user selection.
    //       final SingleSelectionModel<Command> selectionModel = new SingleSelectionModel<Command>();
    //       cellTable.setSelectionModel(selectionModel);
    //       selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
    //         public void onSelectionChange(SelectionChangeEvent event) {
    //           Command selected = selectionModel.getSelectedObject();
    //           if (selected != null) {
    //             if(commandActivity != null) {
    //               commandActivity.onSelect(selected);
    //             }
    //           }
    //         }
    //       });

    cellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    this.add(cellTable);

}

From source file:n3phele.client.view.RepoContentView.java

License:Open Source License

protected Widget createDatasetTable() {
    grid = new CellTable<List<FileNode>>();
    grid.setWidth("100%");
    grid.setTableLayoutFixed(true);/*ww w.j  a v  a2 s .  co m*/

    for (int i = 0; i < ROWLENGTH; i++) {

        Column<List<FileNode>, FileNode> icon = new Column<List<FileNode>, FileNode>(new FileNodeIconCell(i)) {
            @Override
            public FileNode getValue(List<FileNode> object) {
                int index = ((FileNodeIconCell) this.getCell()).getIndex();
                if (index < object.size()) {
                    FileNode value = object.get(index);
                    return value;
                } else {
                    return null;
                }
            }
        };
        icon.setFieldUpdater(new FieldUpdater<List<FileNode>, FileNode>() {

            @Override
            public void update(int index, List<FileNode> object, FileNode value) {
                if (value != null) {
                    String type = value.getMime();
                    PopupPanel popup;
                    if (!type.endsWith("Folder") && !type.endsWith("Placeholder")) {
                        GWT.log("got filename on row " + index + " " + value.toFormattedString());
                        popup = createFileDetailsPopup(value);
                    } else {
                        GWT.log("got folder on row " + index + " " + value.toFormattedString());
                        popup = createFileDetailsPopup(value);
                    }
                    if (popup != null) {
                        int column = 0;
                        for (int i = 0; i < ROWLENGTH && i < object.size(); i++) {
                            FileNode n = object.get(i);
                            if (n.getName() != null && n.getName().equals(value.getName())) {
                                column = i;
                                GWT.log("Found at " + column);
                                break;
                            }
                        }

                        popup.showRelativeTo(new ElementWrapper(grid.getRowElement(index).getChild(column * 2)
                                .getFirstChild().getParentElement().getFirstChildElement()));
                        popup.addAutoHidePartner(grid.getRowElement(index).getChild(column * 2).getFirstChild()
                                .getParentElement());
                    }
                }
            }
        });

        Column<List<FileNode>, FileNode> text = new Column<List<FileNode>, FileNode>(new FileNodeTextCell(i)) {
            @Override
            public FileNode getValue(List<FileNode> object) {
                int index = ((FileNodeTextCell) this.getCell()).getIndex();
                if (index < object.size()) {
                    FileNode value = object.get(index);
                    return value;
                } else {
                    return null;
                }
            }
        };
        text.setFieldUpdater(new FieldUpdater<List<FileNode>, FileNode>() {

            @Override
            public void update(int index, List<FileNode> object, FileNode value) {
                if (value != null) {
                    if (isFile(value)) {
                        GWT.log("got filename on row " + index + " " + value.toFormattedString());
                    } else {
                        GWT.log("got folder on row " + index + " " + value.toFormattedString());
                        RepoContentView.this.presenter.selectFolder(value);
                    }
                }
            }
        });

        grid.addColumn(icon);
        grid.setColumnWidth(icon, 50, Unit.PX);
        grid.addColumn(text);
        text.setCellStyleNames(N3phele.n3pheleResource.css().repoTextCell());
        grid.setColumnWidth(text, (100.0 / ROWLENGTH), Unit.PCT);

    }
    grid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    emptyTable = grid.getEmptyTableWidget();
    return grid;
}

From source file:n3phele.client.view.ServiceDetailsView.java

License:Open Source License

public ServiceDetailsView() {
    super(new MenuItem(N3phele.n3pheleResource.serviceIcon(), "Service Details", null));

    // *******************************************

    table = new FlexTable();
    table.setCellPadding(10);/*from   w w w.  j av  a2  s .  c om*/
    noStack = new Label("There's no stacks on this service!");

    // Selected service.
    lblNewLabel = new Label("");
    table.setWidget(0, 0, lblNewLabel);

    table.setWidget(1, 2, cancel);
    table.getFlexCellFormatter().setHorizontalAlignment(1, 2, HasHorizontalAlignment.ALIGN_RIGHT);
    table.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    table.getFlexCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);

    table.getColumnFormatter().setWidth(0, "25%");
    table.getColumnFormatter().setWidth(1, "18px");
    table.getColumnFormatter().setWidth(4, "16px");
    table.setCellPadding(1);
    table.setCellSpacing(5);

    HorizontalPanel heading = new HorizontalPanel();
    heading.setWidth("500px");
    heading.setStyleName(N3phele.n3pheleResource.css().sectionPanelHeader());
    //add(heading);
    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    simplePager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
    heading.add(simplePager);

    textBox = new TextBox();
    textBox.setTitle("search for a command");
    heading.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    heading.add(textBox);
    heading.setCellHorizontalAlignment(textBox, HorizontalPanel.ALIGN_RIGHT);
    textBox.addKeyPressHandler(new KeyPressHandler() {
        public void onKeyPress(KeyPressEvent event) {
            if (KeyCodes.KEY_ENTER == event.getNativeEvent().getKeyCode()) {
                commandActivity.getProcess();
            }
        }
    });

    grid = new CellTable<List<Stack>>();
    grid.setWidth("100%", true);
    HasCell<Stack, ?> nameHasCell = new HasCell<Stack, Stack>() {

        @Override
        public Cell<Stack> getCell() {
            return new StackTextCell(StackNameRenderer.getInstance());
        }

        @Override
        public FieldUpdater<Stack, Stack> getFieldUpdater() {
            return new FieldUpdater<Stack, Stack>() {
                @Override
                public void update(int index, Stack object, Stack value) {
                    presenter.onSelect(value);
                }
            };
        }

        @Override
        public Stack getValue(Stack object) {
            return object;
        }

    };
    HasCell<Stack, ?> versionHasCell = new HasCell<Stack, Stack>() {

        @Override
        public Cell<Stack> getCell() {
            return new StackTextCell(StackVersionRenderer.getInstance());
        }

        @Override
        public FieldUpdater<Stack, Stack> getFieldUpdater() {
            return new FieldUpdater<Stack, Stack>() {

                @Override
                public void update(int index, Stack object, Stack value) {
                    presenter.onSelect(value);
                }
            };
        }

        @Override
        public Stack getValue(Stack object) {
            return object;
        }

    };

    List<HasCell<Stack, ?>> hasCells = new ArrayList<HasCell<Stack, ?>>(2);
    hasCells.add(nameHasCell);
    hasCells.add(versionHasCell);
    for (int i = 0; i < ROWLENGTH; i++) {
        Column<List<Stack>, Stack> c = new Column<List<Stack>, Stack>(new CommandIconTextCell(
                N3phele.n3pheleResource.stackIcon(), new CompositeCell<Stack>(hasCells), i)) {

            @Override
            public Stack getValue(List<Stack> object) {
                int index = ((CommandIconTextCell) this.getCell()).getIndex();
                if (index < object.size()) {
                    return object.get(index);
                } else {
                    return null;
                }
            }
        };
        c.setFieldUpdater(new FieldUpdater<List<Stack>, Stack>() {

            @Override
            public void update(int index, List<Stack> object, Stack value) {
                presenter.onSelect(value);

                if (value != null) {
                    GWT.log("got-201 " + index + " " + value.getName());
                }

            }
        });
        grid.addColumn(c);
        grid.setColumnWidth(c, 100.0 / ROWLENGTH, Unit.PCT);
    }

    grid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    simplePager.setDisplay(grid);
    simplePager.setPageSize(PAGESIZE);
    grid.addRangeChangeHandler(new RangeChangeEvent.Handler() {

        /*
         * (non-Javadoc)
         * 
         * @see
         * com.google.gwt.view.client.RangeChangeEvent.Handler#onRangeChange
         * (com.google.gwt.view.client.RangeChangeEvent)
         */
        @Override
        public void onRangeChange(RangeChangeEvent event) {
            if (suppressEvent)
                return;
            Range range = grid.getVisibleRange();
            GWT.log("Table range is " + range.getStart() + " length " + range.getLength());
            int start = range.getStart();
            if (start > total)
                start = total;
            commandActivity.getProcess();
        }

    });
    this.add(table);
    this.add(grid);
    this.add(noStack);
}

From source file:n3phele.client.widgets.FileNodeBrowserCore.java

License:Open Source License

public FileNodeBrowserCore(BrowserPresenter presenter, boolean isInput, int rowLength, int width,
        MenuItem heading) {/*from   www.  j  a  v  a2s .c o  m*/
    this.setWidth(width + "px");
    this.ROWLENGTH = rowLength;
    this.isInput = isInput;
    this.isOptional = !isInput;
    this.presenter = presenter;
    header = new HorizontalPanel();
    header.setWidth("100%");
    if (heading != null) {
        Cell<MenuItem> cell = new IconTextCell<MenuItem>(32, 32);
        CellWidget<MenuItem> headerIcon = new CellWidget<MenuItem>(cell, heading);
        headerIcon.addStyleName(N3phele.n3pheleResource.css().workspacePanelHeader());
        header.add(headerIcon);
    }

    if (!isInput) {
        newFolderPanel = new DisclosurePanel("New Folder");
        newFolderView = NewFolderView.newInstance();
        newFolderPanel.add(newFolderView);
        newFolderPanel.addOpenHandler(new OpenHandler<DisclosurePanel>() {

            @Override
            public void onOpen(OpenEvent<DisclosurePanel> event) {
                FileNodeBrowserCore.this.newFolderView.clearName();

            }
        });
        newFolderPanel.addCloseHandler(new CloseHandler<DisclosurePanel>() {

            @Override
            public void onClose(CloseEvent<DisclosurePanel> event) {
                String name = FileNodeBrowserCore.this.newFolderView.getFolderName();
                if (name != null) {
                    FileNodeBrowserCore.this.newFolder(name);
                }

            }

        });
        newFolderView.setDisclosurePanel(newFolderPanel);
        header.add(newFolderPanel);
    }
    this.add(header);
    actions = new FlexTable();
    this.add(actions);
    actions.setWidth("100%");

    crumbs = new FlowPanel();
    crumbs.setWidth("100%");
    actions.setWidget(0, 0, crumbs);

    ScrollPanel gridPanel = new ScrollPanel();
    gridPanel.setHeight("200px");
    grid = new CellTable<List<FileNode>>();
    grid.setWidth("100%");
    grid.setTableLayoutFixed(true);
    for (int i = 0; i < ROWLENGTH; i++) {
        Column<List<FileNode>, FileNode> c = new Column<List<FileNode>, FileNode>(
                new FileNodeIconTextCell(N3phele.n3pheleResource.folderIcon(), new FileNodeTextCell(), i)) {

            @Override
            public FileNode getValue(List<FileNode> object) {
                int index = ((FileNodeIconTextCell) this.getCell()).getIndex();
                if (index < object.size()) {
                    return object.get(index);
                } else {
                    return null;
                }
            }
        };
        c.setFieldUpdater(new FieldUpdater<List<FileNode>, FileNode>() {

            @Override
            public void update(int index, List<FileNode> object, FileNode value) {
                if (value != null) {
                    if (!value.getMime().endsWith("Folder") && !value.getMime().endsWith("Placeholder")) {
                        FileNodeBrowserCore.this.filename.setText(value.getName());
                        FileNodeBrowserCore.this.openButtonValidate(!isZip);
                    } else {
                        FileNodeBrowserCore.this.filename.setText(null);
                        if (FileNodeBrowserCore.this.presenter != null) {
                            FileNodeBrowserCore.this.openButtonValidate(isZip);
                            FileNodeBrowserCore.this.presenter.selectFolder(value);
                        }
                    }
                }
                GWT.log("got " + index + " " + value.toFormattedString());

            }
        });
        grid.addColumn(c);
        grid.setColumnWidth(c, 100.0 / ROWLENGTH, Unit.PCT);
    }
    grid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    gridPanel.add(grid);
    actions.setWidget(1, 0, gridPanel);

    repoList = new ListBox(false);
    repoList.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            FileNodeBrowserCore.this.filename.setText(null);
            FileNodeBrowserCore.this.openButtonValidate(false);
            if (FileNodeBrowserCore.this.presenter != null) {
                int selected = FileNodeBrowserCore.this.repoList.getSelectedIndex()
                        + (FileNodeBrowserCore.this.isOptional ? -1 : 0);
                if (selected >= 0 && selected < FileNodeBrowserCore.this.repos.size()) {
                    FileNodeBrowserCore.this.presenter
                            .selectFolder(FileNodeBrowserCore.this.repos.get(selected));
                } else {
                    FileNodeBrowserCore.this.presenter.selectFolder((Repository) null);
                }
            }

        }
    });
    actions.setWidget(2, 0, repoList);

    filename = new TextBox();
    filename.addKeyUpHandler(new KeyUpHandler() {

        @Override
        public void onKeyUp(KeyUpEvent event) {
            FileNodeBrowserCore.this.enableOpenButton(false);
            String filename = FileNodeBrowserCore.this.filename.getText();
            String repoURI = FileNodeBrowserCore.this.repoList
                    .getValue(FileNodeBrowserCore.this.repoList.getSelectedIndex());
            GWT.log("save " + filename + " on " + repoURI);
            if (repoURI.length() == 0)
                repoURI = null;
            if (FileNodeBrowserCore.this.presenter != null) {
                validateAndEnableOpenButton(filename, repoURI);
            }
        }
    });
    actions.setWidget(2, 1, filename);
    filename.setWidth((width - 50) + "px");

    this.openButton = getOpenButton(this.isInput);
    if (this.openButton != null)
        actions.setWidget(3, 2, this.openButton);

    this.cancelButton = getCancelButton();
    if (this.cancelButton != null)
        actions.setWidget(3, 3, cancelButton);
    errorIndicator = new Image(N3phele.n3pheleResource.inputErrorIcon());
    setErrorText();

    actions.setWidget(3, 1, errorIndicator);
    actions.getCellFormatter().setHorizontalAlignment(3, 1, HasHorizontalAlignment.ALIGN_RIGHT);
    actions.getFlexCellFormatter().setWidth(3, 3, "80px");
    actions.getFlexCellFormatter().setWidth(3, 2, "80px");
    actions.getFlexCellFormatter().setWidth(3, 1, (width - 100) + "px");

    actions.getFlexCellFormatter().setColSpan(0, 0, 4);
    actions.getFlexCellFormatter().setColSpan(1, 0, 4);
    actions.getFlexCellFormatter().setColSpan(2, 1, 3);
}

From source file:org.apache.luke.client.LukeInspector.java

License:Apache License

public void onModuleLoad() {
    final RootPanel rootPanel = RootPanel.get();

    CaptionPanel cptnpnlNewPanel = new CaptionPanel("New panel");
    cptnpnlNewPanel.setCaptionHTML("Luke version 5.0");
    rootPanel.add(cptnpnlNewPanel, 10, 10);
    cptnpnlNewPanel.setSize("959px", "652px");

    TabPanel tabPanel = new TabPanel();
    cptnpnlNewPanel.setContentWidget(tabPanel);
    tabPanel.setSize("5cm", "636px");

    //LuceneIndexLoader.loadIndex(pName, this);

    SplitLayoutPanel splitLayoutPanel = new SplitLayoutPanel();
    tabPanel.add(splitLayoutPanel, "Index overview", false);
    tabPanel.setVisible(true);/*  w w w  . jav  a 2  s. c o m*/
    splitLayoutPanel.setSize("652px", "590px");

    SplitLayoutPanel splitLayoutPanel_1 = new SplitLayoutPanel();
    splitLayoutPanel.addNorth(splitLayoutPanel_1, 288.0);

    Label lblIndexStatistics = new Label("Index statistics");
    lblIndexStatistics.setDirectionEstimator(true);
    lblIndexStatistics.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    splitLayoutPanel_1.addNorth(lblIndexStatistics, 26.0);

    VerticalPanel verticalPanel = new VerticalPanel();
    splitLayoutPanel_1.addWest(verticalPanel, 125.0);

    Label lblTest = new Label("Index name:");
    verticalPanel.add(lblTest);
    lblTest.setWidth("109px");

    Label lblTest_1 = new Label("# fields:");
    verticalPanel.add(lblTest_1);

    Label lblNumber = new Label("# documents:");
    verticalPanel.add(lblNumber);
    lblNumber.setWidth("101px");

    Label lblTerms = new Label("# terms:");
    verticalPanel.add(lblTerms);

    Label lblHasDeletions = new Label("Has deletions?");
    verticalPanel.add(lblHasDeletions);

    Label lblNewLabel = new Label("Optimised?");
    verticalPanel.add(lblNewLabel);

    Label lblIndexVersion = new Label("Index version:");
    verticalPanel.add(lblIndexVersion);

    SplitLayoutPanel splitLayoutPanel_2 = new SplitLayoutPanel();
    splitLayoutPanel.addWest(splitLayoutPanel_2, 240.0);

    // Create name column.
    TextColumn<Field> nameColumn = new TextColumn<Field>() {
        @Override
        public String getValue(Field field) {
            return field.getName();
        }
    };

    // Make the name column sortable.
    nameColumn.setSortable(true);

    // Create termCount column.
    TextColumn<Field> termCountColumn = new TextColumn<Field>() {
        @Override
        public String getValue(Field contact) {
            return contact.getTermCount();
        }
    };

    // Create decoder column.
    TextColumn<Field> decoderColumn = new TextColumn<Field>() {
        @Override
        public String getValue(Field contact) {
            return contact.getDecoder();
        }
    };

    final CellTable<Field> cellTable = new CellTable<Field>();

    cellTable.addColumn(nameColumn, "Name");
    cellTable.addColumn(termCountColumn, "Term count");
    cellTable.addColumn(decoderColumn, "Decoder");

    cellTable.setRowCount(FieldsDummyData.Fields.size(), true);
    // Set the range to display. In this case, our visible range is smaller than
    // the data set.
    cellTable.setVisibleRange(0, 3);

    // Create a data provider.
    AsyncDataProvider<Field> dataProvider = new AsyncDataProvider<Field>() {
        @Override
        protected void onRangeChanged(HasData<Field> display) {
            final Range range = display.getVisibleRange();

            // Get the ColumnSortInfo from the table.
            final ColumnSortList sortList = cellTable.getColumnSortList();

            // This timer is here to illustrate the asynchronous nature of this data
            // provider. In practice, you would use an asynchronous RPC call to
            // request data in the specified range.
            new Timer() {
                @Override
                public void run() {
                    int start = range.getStart();
                    int end = start + range.getLength();
                    // This sorting code is here so the example works. In practice, you
                    // would sort on the server.
                    Collections.sort(FieldsDummyData.Fields, new Comparator<Field>() {
                        public int compare(Field o1, Field o2) {
                            if (o1 == o2) {
                                return 0;
                            }

                            // Compare the name columns.
                            int diff = -1;
                            if (o1 != null) {
                                diff = (o2 != null) ? o1.getName().compareTo(o2.getName()) : 1;
                            }
                            return sortList.get(0).isAscending() ? diff : -diff;
                        }
                    });
                    List<Field> dataInRange = FieldsDummyData.Fields.subList(start, end);

                    // Push the data back into the list.
                    cellTable.setRowData(start, dataInRange);
                }
            }.schedule(2000);
        }
    };

    // Connect the list to the data provider.
    dataProvider.addDataDisplay(cellTable);

    // Add a ColumnSortEvent.AsyncHandler to connect sorting to the
    // AsyncDataPRrovider.
    AsyncHandler columnSortHandler = new AsyncHandler(cellTable);
    cellTable.addColumnSortHandler(columnSortHandler);

    // We know that the data is sorted alphabetically by default.
    cellTable.getColumnSortList().push(nameColumn);

    splitLayoutPanel_2.add(cellTable);

    SplitLayoutPanel splitLayoutPanel_3 = new SplitLayoutPanel();
    splitLayoutPanel.addEast(splitLayoutPanel_3, 215.0);

    StackPanel stackPanel = new StackPanel();
    rootPanel.add(stackPanel, 714, 184);
    stackPanel.setSize("259px", "239px");

    FlowPanel flowPanel = new FlowPanel();
    stackPanel.add(flowPanel, "Open index", false);
    flowPanel.setSize("100%", "100%");

    TextBox textBox = new TextBox();
    flowPanel.add(textBox);

    Button btnNewButton = new Button("...");
    btnNewButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            DirectoryLister directoryLister = new DirectoryLister();
            directoryLister.setPopupPosition(rootPanel.getAbsoluteLeft() + rootPanel.getOffsetWidth() / 2,
                    rootPanel.getAbsoluteTop() + rootPanel.getOffsetHeight() / 2);
            directoryLister.show();

        }
    });
    flowPanel.add(btnNewButton);

    // exception handling
    // credits: http://code.google.com/p/mgwt/source/browse/src/main/java/com/googlecode/mgwt/examples/showcase/client/ShowCaseEntryPoint.java?repo=showcase
    GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {

        @Override
        public void onUncaughtException(Throwable e) {
            Window.alert("uncaught: " + e.getMessage());
            String s = buildStackTrace(e, "RuntimeExceotion:\n");
            Window.alert(s);
            e.printStackTrace();

        }
    });

}