コード例 #1
0
  public Canvas getViewPanel() {

    TileGrid tileGrid = new TileGrid();
    tileGrid.setTileWidth(194);
    tileGrid.setTileHeight(165);
    tileGrid.setHeight(400);
    tileGrid.setWidth100();
    tileGrid.setCanReorderTiles(true);
    tileGrid.setShowAllRecords(true);
    tileGrid.setData(CarData.getRecords());

    DetailViewerField pictureField = new DetailViewerField("picture");
    pictureField.setType("image");
    pictureField.setImageURLPrefix("cars/");
    pictureField.setImageWidth(186);
    pictureField.setImageHeight(120);

    DetailViewerField nameField = new DetailViewerField("name");
    DetailViewerField priceField = new DetailViewerField("price");

    tileGrid.setFields(pictureField, nameField, priceField);

    return tileGrid;
  }
コード例 #2
0
  public DocumentsTileGrid(final DataSource ds, final int totalRecords) {
    setTileWidth(200);
    setTileHeight(250);
    setAutoFetchData(true);
    setSelectionType(SelectionStyle.MULTIPLE);
    setShowAllRecords(false);
    setCanReorderTiles(false);
    setWidth100();

    DetailViewerField thumbnail = new DetailViewerField("thumbnail");
    thumbnail.setDetailFormatter(
        new DetailFormatter() {

          @Override
          public String format(Object value, Record record, DetailViewerField field) {
            int tileSize = 200;
            if (Session.get().getConfig("gui.tile.size") != null)
              tileSize = Integer.parseInt(Session.get().getConfig("gui.tile.size"));

            try {
              if ("folder".equals(record.getAttribute("type")))
                return Util.imageHTML("folder_tile.png", null, tileSize, null);
              else
                return Util.tileImgageHTML(
                    Session.get().getSid(),
                    Long.parseLong(record.getAttribute("id")),
                    null,
                    null,
                    tileSize);
            } catch (Throwable e) {
              return "";
            }
          }
        });

    DetailViewerField filename = new DetailViewerField("title");
    filename.setDetailFormatter(
        new DetailFormatter() {

          @Override
          public String format(Object value, Record record, DetailViewerField field) {
            try {
              String html =
                  "<table style='margin-top:2px' align='center' border='0' cellspacing='0'>";

              // The title row
              html +=
                  "<tr><td>"
                      + Util.imageHTML(record.getAttribute("icon") + ".png")
                      + "</td><td>"
                      + value
                      + "</td></tr></table>";
              html += "<table align='center' border='0' cellspacing='0'>";
              // The status row
              html +=
                  "<tr><td>"
                      + Util.imageHTML(record.getAttribute("indexed") + ".png")
                      + "</td><td>";
              html += "<td>" + Util.imageHTML(record.getAttribute("locked") + ".png") + "</td>";
              html += "<td>" + Util.imageHTML(record.getAttribute("immutable") + ".png") + "</td>";
              html += "<td>" + Util.imageHTML(record.getAttribute("signed") + ".png") + "</td>";
              html += "<td>" + Util.imageHTML(record.getAttribute("stamped") + ".png") + "</td>";
              html += "</tr></table>";

              return html;
            } catch (Throwable e) {
              return "";
            }
          }
        });

    setFields(thumbnail, filename);

    if (ds == null) {
      /*
       * We are searching
       */
      setSelectionType(SelectionStyle.SINGLE);
    } else {
      setDataSource(ds);
    }

    addDataArrivedHandler(
        new com.smartgwt.client.widgets.tile.events.DataArrivedHandler() {

          @Override
          public void onDataArrived(DataArrivedEvent event) {
            if (cursor != null) {
              cursor.setMessage(I18N.message("showndocuments", Integer.toString(getCount())));
              cursor.setTotalRecords(totalRecords);
            }
          }
        });
  }