/*
(non-Javadoc)

@see qc.automation.framework.widget.ITable#getTableRowColumnData(int,
int)
762904
@Override
    public String getTableRowColumnData(int rowNumber, int columnNumber) throws WidgetException {
        try {
            String[] data = getTableRowDataArray(rowNumber);
            return data[columnNumber - 1];
        } catch (Exception e) {
            throw new WidgetException("Error while getting table row column data at row="
                    + rowNumber + " column=" + columnNumber, generateXPathLocator(), e);
        }
    }
1194474
public int getRowCount() {
    if (DataTable_Type.featOkTst && ((DataTable_Type)jcasType).casFeat_rowCount == null)
      jcasType.jcas.throwFeatMissing("rowCount", "ch.epfl.bbp.uima.types.DataTable");
    return jcasType.ll_cas.ll_getIntValue(addr, ((DataTable_Type)jcasType).casFeatCode_rowCount);}
1003439
private ZapTable getTableExtension() {
		if (tableExt == null) {
			tableExt = new ZapTable() {

				private static final long serialVersionUID = 1L;

				@Override
				protected AutoScrollAction createAutoScrollAction() {
					return null;
				}
			};
			tableExt.setAutoScrollOnNewValues(false);
			tableExt.setModel(getExtensionModel());
			tableExt.setRowHeight(DisplayUtils.getScaledSize(18));
			tableExt.getColumnModel().getColumn(0).setPreferredWidth(DisplayUtils.getScaledSize(70));
			tableExt.getColumnModel().getColumn(1).setPreferredWidth(DisplayUtils.getScaledSize(70));
			tableExt.getColumnModel().getColumn(2).setPreferredWidth(DisplayUtils.getScaledSize(120));
			tableExt.getColumnModel().getColumn(3).setPreferredWidth(DisplayUtils.getScaledSize(220));
			tableExt.setSortOrder(3, SortOrder.ASCENDING);
			
			ListSelectionListener sl = new ListSelectionListener() {

				@Override
				public void valueChanged(ListSelectionEvent arg0) {
	        		int selectedRow = tableExt.getSelectedRow();
	        		if (selectedRow > -1) {
	        			Extension ext = getExtensionModel().getExtension(tableExt.convertRowIndexToModel(selectedRow));
	        			if (ext != null) {
	        				try {
								extName.setText(ext.getUIName());
								boolean addOnExtension = ext.getAddOn() != null;
								addOnNameLabel.setVisible(addOnExtension);
								addOnName.setVisible(addOnExtension);
								addOnName.setText(addOnExtension ? ext.getAddOn().getName() : "");
								extDescription.setText(ext.getDescription());
								if (ext.getAuthor() != null) {
									extAuthor.setText(ext.getAuthor());
								} else {
									extAuthor.setText("");
								}
								if (ext.getURL() != null) {
									extURL.setText(ext.getURL().toString());
									getUrlLaunchButton().setEnabled(true);
								} else {
									extURL.setText("");
									getUrlLaunchButton().setEnabled(false);
								}
							} catch (Exception e) {
								// Just to be safe
								log.error(e.getMessage(), e);
							}
	        			}
	        		}
				}};
			
			tableExt.getSelectionModel().addListSelectionListener(sl);
			tableExt.setColumnControlVisible(true);
		}
		return tableExt;
	}
783522
String getTableName() {
        if (opType == OpTypes.MULTICOLUMN) {
            return tableName;
        }

        if (opType == OpTypes.COLUMN) {
            if (rangeVariable == null) {
                return tableName;
            }
            return rangeVariable.getTable().getName().name;
        }
        return "";
    }
240054
private JTable getTable() {
    if (table == null) {
      table = new JTable();
      table.setModel(getModel());
      ProgressBarRenderer.applyTo(table);
    }
    return table;
  }
973833
@Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        LogRecord log = logRecords.get(rowIndex);
        if (log != null) {
            Object[] params = log.getParameters();
            switch (columnIndex) {
                case 0:
                    return Integer.parseInt((String) log.getParameters()[0]);
                case 1:
                    if (params != null) {
                        return log.getParameters()[1];
                    }
                    break;
                case 2:
                	if (params != null) {
                        Automaton aut = (Automaton) params[5];
                        return aut.getAgent().getId();
                    }
                    return log.getLoggerName();
                case 3:
                    if (params != null) {
                        return params[2];
                    }
                    break;
                case 4:
                    if (params != null) {
                        return params[3];
                    }
                    break;
                case 5:
                    if (params != null) {
                        return params[4];
                    }
                    break;
                case 6:
                    if (params != null) {
                        Automaton aut = (Automaton) params[5];
                        return aut.getFinishCondition();
                    }
                    break;
                case 7:
                    return log.getMessage();
            }
        }
        return "";
    }
936816
public String getColumnClassName(int column) throws SQLException
    {
        sourceResultSet.checkColumnBounds(column);
        VoltType type = sourceResultSet.table.getColumnType(column - 1);
        String result = type.getJdbcClass();
        if (result == null) {
            throw SQLError.get(SQLError.TRANSLATION_NOT_FOUND, type);
        }
        return result;
    }
728067
public static <T extends UserColumn> T getColumn(UserCoreRow<T, ?> row,
			DublinCoreType type) {
		return getColumn(row.getTable(), type);
	}
736571
private ColumnInfo getColumn(TableInfo tableInfo, Attribute column, PropertyIndex indexedColumn,
            String[] orderByColumns)
    {
        ColumnInfo columnInfo = new ColumnInfo();

        if (column.getJavaType().isAnnotationPresent(OrderBy.class))
        {
            OrderBy order = (OrderBy) column.getJavaType().getAnnotation(OrderBy.class);
            orderByColumns = order.value().split("\\s*,\\s*");

        }
        columnInfo.setOrderBy(getOrderByColumn(orderByColumns, column));

        if (column.getJavaType().isEnum())
        {
            columnInfo.setType(String.class);
        }
        else
        {
            columnInfo.setType(column.getJavaType());
        }
        columnInfo.setColumnName(((AbstractAttribute) column).getJPAColumnName());
        if (indexedColumn != null && indexedColumn.getName() != null)
        {
            columnInfo.setIndexable(true);
            IndexInfo indexInfo = new IndexInfo(((AbstractAttribute) column).getJPAColumnName(), indexedColumn.getMax(),
                    indexedColumn.getMin(), indexedColumn.getIndexType(), indexedColumn.getName());
            tableInfo.addToIndexedColumnList(indexInfo);
            // Add more if required
        }

        return columnInfo;
    }
834987
private void processColumnData(ProjectFile file, Table table, byte[] data)
   {
      //System.out.println("Table=" + table.getName());
      //System.out.println(ByteArrayHelper.hexdump(data, 8, data.length-8, false, 12, ""));
      if (data != null)
      {
         int columnCount = MPPUtility.getShort(data, 4) + 1;
         int index = 8;
         int columnTitleOffset;
         Column column;
         int alignment;

         for (int loop = 0; loop < columnCount; loop++)
         {
            column = new Column(file);
            int fieldType = MPPUtility.getShort(data, index);
            if (table.getResourceFlag() == false)
            {
               column.setFieldType(MPPTaskField.getInstance(fieldType));
            }
            else
            {
               column.setFieldType(MPPResourceField.getInstance(fieldType));
            }

            //                        if (column.getFieldType() == null)
            //                        {
            //                           System.out.println(loop + ": Unknown column type " + fieldType);
            //                        }
            //                        else
            //                        {
            //                           System.out.println(loop + ": " + column.getFieldType());
            //                        }

            column.setWidth(MPPUtility.getByte(data, index + 4));

            columnTitleOffset = MPPUtility.getShort(data, index + 6);
            if (columnTitleOffset != 0)
            {
               column.setTitle(MPPUtility.getUnicodeString(data, columnTitleOffset));
            }

            alignment = MPPUtility.getByte(data, index + 8);
            if ((alignment & 0x0F) == 0x00)
            {
               column.setAlignTitle(Column.ALIGN_LEFT);
            }
            else
            {
               if ((alignment & 0x0F) == 0x01)
               {
                  column.setAlignTitle(Column.ALIGN_CENTER);
               }
               else
               {
                  column.setAlignTitle(Column.ALIGN_RIGHT);
               }
            }

            alignment = MPPUtility.getByte(data, index + 10);
            if ((alignment & 0x0F) == 0x00)
            {
               column.setAlignData(Column.ALIGN_LEFT);
            }
            else
            {
               if ((alignment & 0x0F) == 0x01)
               {
                  column.setAlignData(Column.ALIGN_CENTER);
               }
               else
               {
                  column.setAlignData(Column.ALIGN_RIGHT);
               }
            }

            table.addColumn(column);
            index += 12;
         }
      }
   }
963149
@Override
    public int findColumn(String columnLabel) throws SQLException {
        checkClosed();
        try {
            return table.getColumnIndex(columnLabel) + 1;
        } catch (IllegalArgumentException iax) {
            throw SQLError.get(iax, SQLError.COLUMN_NOT_FOUND, columnLabel);
        } catch (Exception x) {
            throw SQLError.get(x);
        }
    }
504847
public int getMappedColumn(final int renderCol) {
        if (columnMapping == null || renderCol == -1) {
            return renderCol;
        }
        else {
            final Integer result = columnMapping.get(renderCol);
            if (result == null) {
                throw new IllegalArgumentException("Invalid index " + renderCol);
            }
            return result;
        }
    }
78610
public String getColumnName(int column) throws SQLException
    {
        sourceResultSet.checkColumnBounds(column);
        return sourceResultSet.table.getColumnName(column - 1);
    }
922395
@Override
    public List<String[]> getTableDataInArray() throws WidgetException {
        try {
            List<String[]> list = new ArrayList<String[]>();
            NodeList nodes = getNodeListUsingJavaXPath(getTableXPath(generateXPathLocator()) + "/tbody[1]");
            NodeList tbodyChildNodes = nodes.item(0).getChildNodes();
            for (int i = 0; i < tbodyChildNodes.getLength(); i++) {
                Node n = tbodyChildNodes.item(i);
                if (n != null && n.getNodeName() != null && n.getNodeName() != null
                        && n.getNodeName().equalsIgnoreCase("tr")) {
                    NamedNodeMap trNodeAttributes = n.getAttributes();
                    Node trStyleAttr = trNodeAttributes.getNamedItem("style");
                    boolean proceed = true;
                    if (trStyleAttr != null) {
                        String style = trStyleAttr.getTextContent();
                        style = style.toLowerCase();
                        if (style.contains("display: none") || style.contains("display:none")
                                || style.contains("visibility: hidden")) {
                            proceed = false;
                        }
                    }

                    if (proceed) {
                        List<String> rowData = new ArrayList<String>();
                        NodeList cnl = n.getChildNodes();
                        for (int j = 0; j < cnl.getLength(); j++) {
                            Node cn = cnl.item(j);

                            if (cn != null && cn.getNodeName() != null && cn.getNodeName() != null
                                    && cn.getNodeName().equalsIgnoreCase("td")) {
                                NamedNodeMap tdNodeAttributes = cn.getAttributes();
                                Node tdStyleAttr = tdNodeAttributes.getNamedItem("style");
                                if (tdStyleAttr != null) {
                                    String style = tdStyleAttr.getTextContent();
                                    style = style.toLowerCase();
                                    if (!(style.contains("display: none")
                                            || style.contains("display:none") || style
                                                .contains("visibility: hidden"))) {
                                        rowData.add(getRecursiveTextContext(cn).trim());
                                    }
                                } else {
                                    rowData.add(getRecursiveTextContext(cn).trim());
                                }
                            }
                        }

                        // If rowData size == 0 that means there were no TDs
                        // inside of TR.
                        // It triggers that the row was used as headers
                        if (rowData.size() > 0) {
                            list.add(rowData.toArray(new String[rowData.size()]));
                        }
                    }
                }
            }

            return list;
        } catch (Exception e) {
            throw new WidgetException("Error while getting table data in array", generateXPathLocator(), e);
        }
    }
909743
public double getColunmSum(final int col) {
		double sum = 0;
		for (int i = 0; i < getRowCount(); i++) {
			final double number = getValueAtAsDouble(i, col);
			sum = JKNumbersUtil.addAmounts(sum, number);
		}
		return sum;
	}
1310247
public int getColumnIndex(final String name) {
		for (int i = 0; i < this.columnsValues.size(); i++) {
			final JKTableColumnValue value = this.columnsValues.get(i);
			if (value.getTableColumn().getName().toLowerCase().equals(name.toLowerCase())) {
				return i;
			}
		}
		return -1;
	}
254971
function getTableItemByIndex(table, index) {
      if (table.isPanel) {
        table = table.getView();
      }
      var el = table.getRow(index);
      return el;
    }