private ComponentGVO createImage(
     DataGrid dataGrid, String id, String imageUrl, String description, String parent) {
   ImageGVO imageGVO = new ImageGVO();
   imageGVO.setParent(parent);
   imageGVO.setDescription(description);
   imageGVO.setImageLocation(imageUrl);
   imageGVO.setId(dataGrid.getId() + "." + id);
   return imageGVO;
 }
  // CHECKSTYLE.OFF: CyclomaticComplexity
  public ComponentGVO convert(
      Component object,
      Window currentWindow,
      ApplicationMapping applicationMapping,
      ApplicationContext context,
      SessionContainer ss) {
    ComponentGVO vo = null;
    if (object != null) {
      if (object instanceof DataGrid) {
        DataGrid dataGrid = (DataGrid) object;
        DataGridGVO voTemp = new DataGridGVO();
        UIAssemblerHelper.copyFields(
            dataGrid, currentWindow, voTemp, applicationMapping, context, ss);
        // extra check on the dimension of the width:
        // Since the datagrid is inspired by the Flex Datagrid, we apply the same rules.

        if (voTemp.getWidth() == null || voTemp.getWidth().trim().length() == 0) {
          voTemp.setWidth(
              "300px"); // http://livedocs.adobe.com/flex/3/langref/mx/controls/DataGrid.html
        }
        if (voTemp.getHeight() == null || voTemp.getHeight().trim().length() == 0) {
          voTemp.setHeight(
              "140px"); // 7x 20 http://livedocs.adobe.com/flex/3/langref/mx/controls/DataGrid.html
        }

        voTemp.setMaxRows(dataGrid.getMaxRows());
        voTemp.setPageSize(dataGrid.getPageSize());
        voTemp.setPageScroll(dataGrid.getPageScroll());
        voTemp.setMinRows(dataGrid.getMinRows());
        voTemp.setDelete(dataGrid.getDelete());
        voTemp.setAdd(dataGrid.getAdd());
        voTemp.setExport(dataGrid.getExport());
        voTemp.setImportEnabled(dataGrid.getImportEnabled());
        voTemp.setMultipleSelect(dataGrid.getMultipleSelect());

        if (dataGrid.getRowColors() != null) {
          voTemp.setRowColors((dataGrid.getRowColors().trim()).split(","));
        }

        if (dataGrid.hasOverflow()) {
          voTemp.setOverflow(
              (PanelGVO)
                  ComponentUIAssembler.convert(
                      dataGrid.getOverflow(), currentWindow, applicationMapping, context, ss));
        }

        if (dataGrid.getColumns() != null) {
          Iterator<DataGridColumn> itr = dataGrid.getColumns().iterator();
          DataGridColumnGVO[] columns = new DataGridColumnGVO[dataGrid.getColumns().size()];

          int index = 0;
          while (itr.hasNext()) {
            columns[index] =
                (DataGridColumnGVO)
                    ComponentUIAssembler.convert(
                        (Component) itr.next(), currentWindow, applicationMapping, context, ss);
            columns[index].setParentName(dataGrid.getId());
            //						 if (columns[index].getIdentifyingField().booleanValue()){
            //							 voTemp.getIdFields().add(columns[index].getFieldName());
            //						 }
            index++;
          }

          /*if (dataGrid.getDelete()!=null && dataGrid.getDelete().booleanValue()){
          	columns[index] = (DataGridColumnGVO)ComponentUIAssembler.convert(createDeleteColumn(),applicationMapping);
          	columns[index].setParentName(dataGrid.getId());
          }*/

          voTemp.setColumns(columns);
        }
        if (dataGrid.getDelete().booleanValue()
            || dataGrid.getAdd().booleanValue()
            || dataGrid.getEditable().booleanValue()) {
          voTemp.setSaveComponent(
              createImage(dataGrid, "save", "images/save.png", "Save changes", dataGrid.getId()));
          voTemp.setRefreshComponent(
              createImage(
                  dataGrid, "refresh", "images/refresh.png", "Refresh Data", dataGrid.getId()));
          voTemp.setCancelComponent(
              createImage(dataGrid, "cancel", "images/undo.png", "Undo changes", dataGrid.getId()));
        }

        if (dataGrid.getDelete().booleanValue()) {
          voTemp.setDeleteComponent(
              createImage(
                  dataGrid, "delete", "images/delete.png", "Delete record(s)", dataGrid.getId()));
        }
        if (dataGrid.getAdd().booleanValue()) {
          voTemp.setAddComponent(
              createImage(dataGrid, "add", "images/add.gif", "Add a new record", dataGrid.getId()));
        }

        if (dataGrid.getExport().booleanValue()) {
          voTemp.setExportComponent(
              createImage(dataGrid, "export", "images/export.gif", "Export", dataGrid.getId()));
        }

        if (dataGrid.getPageSize() != null && dataGrid.getPageSize().intValue() > 0) {
          voTemp.setPageSizeComponent(
              createHiddenComponent(dataGrid, "pagesize", dataGrid.getPageSize()));
          voTemp.setPageSize(dataGrid.getPageSize());
          voTemp.setOffSetComponent(createHiddenComponent(dataGrid, "offset", "0"));
        }

        vo = voTemp;
      }
    }
    return vo;
  }
 private ComponentGVO createHiddenComponent(DataGrid dataGrid, String id, Object value) {
   HiddenGVO hiddenGVO = new HiddenGVO();
   hiddenGVO.setId(dataGrid.getId() + "." + id);
   hiddenGVO.setValue(value.toString());
   return hiddenGVO;
 }