예제 #1
0
 private <C> void addColumn(
     Cell<C> cell,
     String headerText,
     final GetValue<C> getter,
     FieldUpdater<MaterialListProxy, C> fieldUpdater) {
   Column<MaterialListProxy, C> column =
       new Column<MaterialListProxy, C>(cell) {
         @Override
         public C getValue(MaterialListProxy object) {
           return getter.getValue(object);
         }
       };
   column.setFieldUpdater(fieldUpdater);
   if (cell instanceof AbstractEditableCell<?, ?>) {
     editableCells.add((AbstractEditableCell<?, ?>) cell);
   }
   table.addColumn(column);
 }
예제 #2
0
  public void init() {

    ResolutionSettings.setSplitLayoutPanelPosition(splitLayoutPanel, true);
    //		int splitLeft = (OsMaMainNav.getMenuStatus() == 0) ? 40 : 225;
    //
    //		DOM.setElementAttribute(splitLayoutPanel.getElement(), "style",
    //				"position: absolute; left: "+splitLeft+"px; top: 30px; right: 5px; bottom: 0px;");
    //
    //		if(OsMaMainNav.getMenuStatus() == 0)
    //			splitLayoutPanel.setWidgetSize(splitLayoutPanel.getWidget(0), 1412);
    //		else
    //			splitLayoutPanel.setWidgetSize(splitLayoutPanel.getWidget(0), 1220);

    // @SPEC

    paths.add("name");
    paths.add("");
    table.addColumn(
        new TextColumn<MaterialListProxy>() {
          {
            this.setSortable(true);
          }

          Renderer<java.lang.String> renderer =
              new AbstractRenderer<java.lang.String>() {

                public String render(java.lang.String obj) {
                  return obj == null ? "" : String.valueOf(obj);
                }
              };

          @Override
          public String getValue(MaterialListProxy materialListProxy) {
            return renderer.render(
                (materialListProxy.getName() == null) ? "" : materialListProxy.getName());
          }
        },
        constants.roomMaterialName());

    paths.add("type");
    paths.add("");
    table.addColumn(
        new TextColumn<MaterialListProxy>() {
          {
            this.setSortable(true);
          }

          Renderer<MaterialType> renderer = new EnumRenderer<MaterialType>();

          @Override
          public String getValue(MaterialListProxy materialListProxy) {
            return renderer.render(materialListProxy.getType());
          }
        },
        constants.roomMaterialType());

    paths.add("price");
    paths.add("");
    table.addColumn(
        new TextColumn<MaterialListProxy>() {
          {
            this.setSortable(true);
          }

          Renderer<String> renderer =
              new AbstractRenderer<String>() {

                public String render(String obj) {
                  return obj == null ? "" : String.valueOf(obj);
                }
              };

          @Override
          public String getValue(MaterialListProxy materialListProxy) {
            return renderer.render(
                (materialListProxy.getPrice() == null)
                    ? ""
                    : materialListProxy.getPrice().toString());
          }
        },
        constants.roomMaterialPrice());

    paths.add("priceType");
    paths.add("");
    table.addColumn(
        new TextColumn<MaterialListProxy>() {
          {
            this.setSortable(true);
          }

          Renderer<PriceType> renderer = new EnumRenderer<PriceType>();

          @Override
          public String getValue(MaterialListProxy materialListProxy) {
            return renderer.render(materialListProxy.getPriceType());
          }
        },
        constants.roomMaterialPriceType());

    // // Edit Button
    // addColumn(new ActionCell<MaterialListProxy>("Edit",
    // new ActionCell.Delegate<MaterialListProxy>() {
    // public void execute(MaterialListProxy specialization) {
    // // Window.alert("You clicked " +
    // // institution.getInstitutionName());
    // if (Window.confirm(constants.reallyDelete()))
    // delegate.
    // deleteClicked(specialization);
    // }
    // }), "", new GetValue<MaterialListProxy>() {
    // public MaterialListProxy getValue(MaterialListProxy specialization) {
    // return specialization;
    // }
    // }, null);
    // table.addColumnStyleName(1, "iconCol");

    // Delete button
    addColumn(
        new ActionCell<MaterialListProxy>(
            OsMaConstant.DELETE_ICON,
            new ActionCell.Delegate<MaterialListProxy>() {
              public void execute(final MaterialListProxy materialListProxy) {
                // Window.alert("You clicked " +
                // institution.getInstitutionName());
                /*if (Window.confirm(constants.reallyDelete()))
                delegate.deleteClicked(materialListProxy);*/
                // Issue Role
                final MessageConfirmationDialogBox dialogBox =
                    new MessageConfirmationDialogBox(constants.success());
                dialogBox.showYesNoDialog(constants.reallyDelete());
                dialogBox
                    .getYesBtn()
                    .addClickHandler(
                        new ClickHandler() {

                          @Override
                          public void onClick(ClickEvent event) {
                            dialogBox.hide();
                            Log.info("yes click");
                            delegate.deleteClicked(materialListProxy);
                            return;
                          }
                        });

                dialogBox
                    .getNoBtnl()
                    .addClickHandler(
                        new ClickHandler() {

                          @Override
                          public void onClick(ClickEvent event) {
                            dialogBox.hide();
                            Log.info("no click");
                            return;
                          }
                        });
                // E: Issue Role
              }
            }),
        "",
        new GetValue<MaterialListProxy>() {
          public MaterialListProxy getValue(MaterialListProxy materialListProxy) {
            return materialListProxy;
          }
        },
        null);
    table.addColumnStyleName(1, "iconCol");
    table.addColumnStyleName(3, "iconCol");
    table.addColumnStyleName(5, "iconCol");
    table.addColumnStyleName(7, "iconCol");
    table.addColumnStyleName(8, "iconCol");
  }