/** * Get the column layout for the table * * @param gid ID of the table layout * @return column layout */ public ITableColumnLayout[] getTableColumnLayout(String gid) { if (lguiItem == null && lguiItem.getLayoutAccess() == null) { return new ITableColumnLayout[0]; } final BigInteger[] cids = getCids(gid); // layoutColumns are sorted by cids final ColumnlayoutType[] layoutColumns = lguiItem.getLayoutAccess().getLayoutColumsToCids(cids, gid); final ITableColumnLayout[] tableColumnLayouts = new ITableColumnLayout[layoutColumns.length]; for (int i = 0; i < layoutColumns.length; i++) { final ColumnlayoutType column = layoutColumns[i]; if (column != null) { String style = null; final String sort = getColumnSortProperty(getTable(gid), cids, i); // when there is a change if (column.getSorted() != null && column.getSorted().value() != null && sort != null) { if (sort.equals(ILMLCoreConstants.TABLECOLUMN_NUMERIC)) { style = ITableColumnLayout.COLUMN_STYLE_RIGHT; } else if (sort.equals(ILMLCoreConstants.TABLECOLUMN_ALPHA)) { style = ITableColumnLayout.COLUMN_STYLE_LEFT; } else { style = ITableColumnLayout.COLUMN_STYLE_CENTER; } } tableColumnLayouts[i] = new TableColumnLayout( column.getKey(), column.getWidth(), style, column.isActive(), sort); } } return tableColumnLayouts; }
public TableType generateDefaultTable(String gid) { final TableType table = new TableType(); table.setId(gid); table.setTitle(ILMLCoreConstants.TITLE_PREFIX + gid); final ContentType ct = ContentType.fromValue(ILguiItem.CONTENT_JOBS); table.setContenttype(ct); for (final ColumnlayoutType columnLayout : lguiItem.getLayoutAccess().getTableLayout(gid).getColumn()) { if (columnLayout.isActive()) { final ColumnType column = new ColumnType(); column.setId(columnLayout.getCid()); column.setName(columnLayout.getKey()); generateDefaultSorting(column); if (columnLayout.getKey().equals(ILguiItem.JOB_STATUS)) { column.setType(ITableColumnLayout.COLUMN_TYPE_MANDATORY); if (gid.equals(ILMLCoreConstants.ID_ACTIVE_JOBS_VIEW)) { generateDefaultPattern(JobStatusData.RUNNING, ILMLCoreConstants.EQ, columnLayout); } else { generateDefaultPattern(JobStatusData.RUNNING, ILMLCoreConstants.NEQ, columnLayout); } } table.getColumn().add(column); } } jaxbUtil.addTable(lgui, table); return table; }
/** Currently unused */ public int getNumberOfTableColumns(String gid) { final TablelayoutType layout = lguiItem.getLayoutAccess().getTableLayout(gid); int activeColumn = 0; for (final ColumnlayoutType column : layout.getColumn()) { if (column.isActive()) { activeColumn++; } } return activeColumn; }
/** * Change the table column widths * * @param gid ID of the table layout * @param widths new column widths */ public void changeTableColumnsWidth(String gid, Double[] widths) { final BigInteger[] cids = getCids(gid); for (int i = 0; i < widths.length; i++) { for (final ColumnlayoutType column : lguiItem.getLayoutAccess().getLayoutColumsToCids(cids, gid)) { if (column.getPos() != null && BigInteger.valueOf(i).equals(column.getPos()) && column.isActive()) { column.setWidth(widths[i]); break; } } } }
/** * Get column indexes of active columns for the table layout * * @param gid ID of the table layout * @return array of column indexes */ private BigInteger[] getCidsActiveColumns(String gid) { final TablelayoutType layout = lguiItem.getLayoutAccess().getTableLayout(gid); final List<BigInteger> cids = new ArrayList<BigInteger>(); for (int i = 0; i < layout.getColumn().size(); i++) { for (final ColumnlayoutType column : layout.getColumn()) { if (column.getPos() != null && column.getPos().equals(BigInteger.valueOf(i)) && column.isActive()) { cids.add(column.getCid()); } } } return cids.toArray(new BigInteger[cids.size()]); }