    importPackage(Packages.javax.swing);
    importPackage(Packages.javax.swing.table);
    importPackage(Packages.javax.swing.event);

    importPackage(Packages.de.elo.client.scripting.constants);

    //@include lib_Class.js

    /**
     * Sord select table
     *
     * @author ELO Digital Office GmbH
     * @version 1.0
     *
     * @requires  sol.common.SordUtils
     *
     * @elojc
     */
    sol.define("sol.common.jc.SordSelectTable", {

      /**
       * @cfg {Array} columnsDefinition
       * Columns defintion
       */

      /**
       * @cfg {String} translationFileName
       * Translation file nama
       */

      initialize: function (params) {
        var me = this;

        me.$super("sol.Base", "initialize", [params]);
      },

      /**
       * Creates a Java Client table
       * @returns {com.sciapp.table.AdvancedJTable} Table
       */
      createSwingTable: function () {
        var me = this,
            tableStateParts = [],
            i, columnDefinition, language, shortDateFormat;

        if (!me.sords) {
          throw "Sords are empty";
        }

        me.selected = new Array(me.sords.length);

        me.model = new JavaAdapter(Packages.com.sciapp.table.ObjectTableModel, {

          isCellEditable: function (row, column) {
            var definition;

            definition = me.columnsDefinition[column];
            if (definition.type == "SELECT") {
              return true;
            } else {
              return false;
            }
          },

          getColumnCount: function () {
            return me.columnsDefinition.length;
          },

          getColumnName: function (column) {
            var definition, headerTranslationKey, columnName;

            definition = me.columnsDefinition[column];
            headerTranslationKey = definition.headerTranslationKey;
            if (!me.translationFileName) {
              throw "Translation file name is empty";
            }
            columnName = utils.getText(me.translationFileName, headerTranslationKey);
            return columnName;
          },

          getColumnClass: function (columnIndex) {
            var definition;

            definition = me.columnsDefinition[columnIndex];

            if (definition.type == "SELECT") {
              return java.lang.Boolean;
            } else if (definition.format == "DATE") {
              return java.util.Date;
            } else {
              return java.lang.String;
            }
          },

          getValueAt: function (param1, columnIndex) {
            var sord, definition, value, selected, rowIndex, date;

            if (typeof param1 == "number") {
              rowIndex = param1;
              sord = this.getRows().get(rowIndex);
            } else {
              sord = param1;
            }

            definition = me.columnsDefinition[columnIndex];
            if (definition.type == "SELECT") {
              selected = !!me.selected[rowIndex];
              return java.lang.Boolean(selected);
            } else {
              value = (sol.common.SordUtils.getValue(sord, definition) || "") + "";
              if (definition.format == "DATE") {
                date = ixConnect.isoToDate(value);
                return date;
              }
              return java.lang.String(value);
            }
          },

          setValueAt: function (value, rowIndex, columnIndex) {
            var definition;

            definition = me.columnsDefinition[columnIndex];
            if (definition.type == "SELECT") {
              me.selected[rowIndex] = !me.selected[rowIndex];
            }
          }
        });

        me.model.addRows(me.sords);

        for (i = 0; i < me.columnsDefinition.length; i++) {
          columnDefinition = me.columnsDefinition[i];
          tableStateParts.push(i + ":" + columnDefinition.state);
        }

        me.table = new Packages.com.sciapp.table.AdvancedJTable();

        language = ixConnect.loginResult.clientInfo.language;
        shortDateFormat = java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT, new java.util.Locale(language));
        me.table.setDefaultRenderer(java.util.Date, new Packages.com.sciapp.renderers.DateRenderer(shortDateFormat));

        me.sortTableModel = new Packages.com.sciapp.table.SortTableModel(me.model, me.table.tableHeader);

        me.table.model = me.sortTableModel;

        me.table.tableState = tableStateParts.join(",");

        me.table.rowSelectionAllowed = false;

        me.table.tableHeader.defaultRenderer.horizontalAlignment = javax.swing.JLabel.LEFT;

        me.adjustColumnHeaderWidth();

        me.table.showVerticalLines = false;
        me.table.showHorizontalLines = false;
        me.table.showGrid = false;
        me.table.fillsViewportHeight = true;
        me.scrollPane = new Packages.com.sciapp.table.AdvancedJScrollPane(me.table);
        me.scrollPane.viewportView = me.table;
        me.table.preferredScrollableViewportSize = new java.awt.Dimension(200, 200);

        me.deselectColumns();

        return me.table;
      },

      /**
       * @private
       * Adjusts the column header width
       */
      adjustColumnHeaderWidth: function () {
        var me = this,
            headerColumnModel, component, header, headerColumn, headerRenderer, width, newWidth, i;

        header = me.table.tableHeader;
        headerColumnModel = me.table.tableHeader.columnModel;
        for (i = 0; i < headerColumnModel.columnCount; i++) {
          headerColumn = headerColumnModel.getColumn(i);
          headerRenderer = headerColumn.headerRenderer;
          if (!headerRenderer) {
            headerRenderer = header.defaultRenderer;
          }
          component = headerRenderer.getTableCellRendererComponent(me.table, headerColumn.headerValue, false, false, -1, i);

          width = headerColumnModel.getColumn(i).width;
          newWidth = component.getPreferredSize().width + (2 * headerColumnModel.columnMargin) + 10;

          if (newWidth > width) {
            headerColumnModel.getColumn(i).preferredWidth = newWidth;
          }
        }
      },

      /**
       * @private
       * Hides columns
       */
      deselectColumns: function () {
        var me = this,
            columnDefinition, tableAssistant, i;

        tableAssistant = me.table.tableAssistant;

        for (i = 0; i < me.columnsDefinition.length; i++) {
          columnDefinition = me.columnsDefinition[i];
          if (columnDefinition.deselect) {
            tableAssistant.deselect(i);
          }
        }
      },

      /**
       * Returns the scroll pane
       * @returns {javax.swing.JScrollPane} Scroll pane
       */
      getScrollPane: function () {
        var me = this;

        return me.scrollPane;
      },

      /**
       * Select all
       */
      selectAll: function () {
        var me = this;

        me.setAll(true);
      },

      /**
       * Deselect all
       */
      deselectAll: function () {
        var me = this;

        me.setAll(false);
      },

      /**
       * Set all
       * @param {Boolean} select
       */
      setAll: function (select) {
        var me = this,
            i;

        for (i = 0; i < me.selected.length; i++) {
          me.selected[i] = select;
        }

        me.model.fireTableDataChanged();
      },

      /**
       * Returns the ObjIds of the selected Sords
       * @returns {String} ObjIds of the selcted Sords
       */
      getSelectedObjIds: function () {
        var me = this,
            objIds = [],
            selectedSords, i, sord;

        selectedSords = me.getSelectedSords();

        for (i = 0; i < selectedSords.length; i++) {
          sord = selectedSords[i];
          objIds.push(sord.id);
        }

        return objIds;
      },

      /**
       * Returns the selected Sords
       * @returns {de.elo.ix.client.Sord[]} Selected sords
       */
      getSelectedSords: function () {
        var me = this,
            sords = [],
            selected, i;

        for (i = 0; i < me.selected.length; i++) {
          selected = !!me.selected[i];
          if (selected) {
            sords.push(me.sords[i]);
          }
        }

        return sords;
      },

      /**
       * Returns a localized formated date string
       * @param {String} isoDate ISO date
       * @returns {String} Localized date string
       */
      formatLocalDate: function (isoDate) {
        var me = this,
            localPattern, date, localDateString;

        if (!isoDate) {
          return "";
        }

        date = Packages.org.apache.commons.lang.time.DateUtils.parseDate(isoDate, ["yyyyMMddHHmmss", "yyyyMMdd"]);

        localPattern = me.getLocalDateFormatPattern();

        localDateString = Packages.org.apache.commons.lang.time.DateFormatUtils.format(date, localPattern);

        return new java.lang.String(localDateString);
      },

      /**
       * Returns the local date format pattern
       * @param {Object} params Parameters
       * @param {String} [params.style=SHORT] Date format style
       * @returns {String} Local pattern
       */
      getLocalDateFormatPattern: function (params) {
        var formatter, locale, dateFormatStyle, localPattern;

        params = params || {};
        params.style = params.style || "SHORT";
        params.language = params.language || ixConnect.loginResult.clientInfo.language;

        locale = new java.util.Locale(params.language);

        dateFormatStyle = java.text.DateFormat[params.style];

        formatter = java.text.DateFormat.getDateInstance(dateFormatStyle, locale);
        localPattern = formatter.toPattern();

        return localPattern;
      }
    });