Exemplo n.º 1
0
  private void initializeStatusGrid() {
    // Creacion del Grid Base
    StatusItemProperties props = GWT.create(StatusItemProperties.class);
    statusStore = new ListStore<StatusItem>(props.key());
    statusStore.setAutoCommit(true);

    ColumnConfig<StatusItem, String> nameCol =
        new ColumnConfig<StatusItem, String>(
            props.name(), 75, UIMessages.INSTANCE.fedColumnNameText());

    ColumnConfig<StatusItem, String> valueCol =
        new ColumnConfig<StatusItem, String>(
            props.value(), 150, UIMessages.INSTANCE.fedNewAttributeDefaultNameText());

    List<ColumnConfig<StatusItem, ?>> columns = new ArrayList<ColumnConfig<StatusItem, ?>>();
    columns.add(nameCol);
    columns.add(valueCol);

    statusGrid = new Grid<StatusItem>(statusStore, new ColumnModel<StatusItem>(columns));
    statusGrid.setSelectionModel(new CellSelectionModel<StatusItem>());
    statusGrid.getColumnModel().getColumn(1).setHideable(false);
    statusGrid.setHideHeaders(true);
    statusGrid.setAllowTextSelection(true);
    statusGrid.getView().setStripeRows(true);
    statusGrid.getView().setColumnLines(true);
    statusGrid.setBorders(false);

    statusStore.add(new StatusItem(LON_LABEL, null));
    statusStore.add(new StatusItem(LAT_LABEL, null));
    statusStore.add(new StatusItem(SCALE_LABEL, null));
    statusStore.add(new StatusItem(CLICK_COORD_X, null));
    statusStore.add(new StatusItem(CLICK_COORD_Y, null));
  }
Exemplo n.º 2
0
  @Override
  public Widget asWidget() {
    ColumnConfig<ModelPropertyModel, String> name =
        new ColumnConfig<TableInfoTab.ModelPropertyModel, String>(props.name(), 100, "Name");
    ColumnConfig<ModelPropertyModel, String> value =
        new ColumnConfig<TableInfoTab.ModelPropertyModel, String>(props.value(), 180, "Value");
    value.setCell(
        new TitledCell() {
          @Override
          public void render(
              com.google.gwt.cell.client.Cell.Context context, String value, SafeHtmlBuilder sb) {
            if (value == null) value = "";
            if (value.startsWith("http://") || value.startsWith("https://")) {
              sb.appendHtmlConstant(
                      "<a title=\""
                          + value
                          + "\""
                          + "href=\""
                          + value
                          + "\" target=\"_blank\""
                          + ">")
                  .appendHtmlConstant(value)
                  .appendHtmlConstant("</a>");
            } else {
              super.render(context, value, sb);
            }
          }
        });
    List<ColumnConfig<ModelPropertyModel, ?>> colList =
        new ArrayList<ColumnConfig<ModelPropertyModel, ?>>(2);
    colList.add(name);
    colList.add(value);

    ColumnModel<ModelPropertyModel> colModel =
        new ColumnModel<TableInfoTab.ModelPropertyModel>(colList);
    Grid<ModelPropertyModel> grid = new Grid<TableInfoTab.ModelPropertyModel>(getStore(), colModel);
    grid.setAllowTextSelection(true);
    grid.getView().setForceFit(true);
    grid.getView().setAutoFill(true);
    final GridEditing<ModelPropertyModel> editing = new GridInlineEditing<ModelPropertyModel>(grid);
    editing.addEditor(value, new TextField());
    editing.getEditor(value).setReadOnly(true);

    return grid;
  }