Ejemplo n.º 1
0
  @Override
  public void initialize() {
    container =
        Panels.content(
            null,
            false,
            Layouts.vBoxLayout(
                VBoxLayout.VBoxLayoutAlign.STRETCH, new Layouts.LayoutOptions(new Padding(10))),
            "x-border-layout-ct");
    container.setScrollMode(Style.Scroll.AUTOY);
    container.addStyleName("contact-details-container");
    add(container);

    saveButton = Forms.button(I18N.CONSTANTS.save(), IconImageBundle.ICONS.save());
    deleteButton = Forms.button(I18N.CONSTANTS.delete(), IconImageBundle.ICONS.remove());
    exportButton = Forms.button(I18N.CONSTANTS.export(), IconImageBundle.ICONS.excel());

    toolBar = new ToolBar();
    toolBar.setAlignment(Style.HorizontalAlignment.LEFT);
    toolBar.setBorders(false);
    toolBar.add(saveButton);
    toolBar.add(deleteButton);
    toolBar.add(exportButton);

    container.setTopComponent(toolBar);
  }
Ejemplo n.º 2
0
  @Override
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);

    setLayout(new FlowLayout(10));

    Folder model = TestData.getTreeModel();

    TreeStore<ModelData> store = new TreeStore<ModelData>();

    store.add(model.getChildren(), true);

    ColumnConfig name = new ColumnConfig("name", "Name", 100);
    name.setRenderer(new TreeGridCellRenderer<ModelData>());

    ColumnConfig date = new ColumnConfig("author", "Author", 100);

    ColumnConfig size = new ColumnConfig("genre", "Genre", 100);

    ColumnModel cm = new ColumnModel(Arrays.asList(name, date, size));

    ContentPanel cp = new ContentPanel();
    cp.setBodyBorder(false);
    cp.setHeading("TreeGrid");
    cp.setButtonAlign(HorizontalAlignment.CENTER);
    cp.setLayout(new FitLayout());
    cp.setFrame(true);
    cp.setSize(600, 300);

    TreeGrid<ModelData> tree = new TreeGrid<ModelData>(store, cm);
    tree.setBorders(true);
    tree.getStyle().setLeafIcon(Resources.ICONS.music());
    tree.setAutoExpandColumn("name");
    tree.setTrackMouseOver(false);

    cp.add(tree);

    add(cp);

    StoreFilterField<ModelData> filter =
        new StoreFilterField<ModelData>() {

          @Override
          protected boolean doSelect(
              Store<ModelData> store,
              ModelData parent,
              ModelData record,
              String property,
              String filter) {
            // only match leaf nodes
            if (record instanceof Folder) {
              return false;
            }
            String name = record.get("name");
            name = name.toLowerCase();
            if (name.startsWith(filter.toLowerCase())) {
              return true;
            }
            return false;
          }
        };
    filter.bind(store);

    ToolBar toolBar = new ToolBar();
    toolBar.setBorders(true);
    toolBar.add(new LabelToolItem("Filter:"));
    toolBar.add(filter);

    cp.setTopComponent(toolBar);
  }