use of org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn in project scout.rt by eclipse.
the class AbstractTable method execCopy.
/**
* Called by a <code>CTRL-C</code> event on the table to copy the given rows into the clipboard.
* <p>
* Subclasses can override this method. The default creates a {@link TextTransferObject} of the table content (HTML
* table).
*
* @param rows
* The selected table rows to copy.
* @return A transferable object representing the given rows or null to not populate the clipboard.
*/
@ConfigOperation
@Order(30)
protected TransferObject execCopy(List<? extends ITableRow> rows) {
if (!CollectionUtility.hasElements(rows)) {
return null;
}
StringBuilder plainText = new StringBuilder();
List<IColumn<?>> columns = getColumnSet().getVisibleColumns();
boolean firstRow = true;
for (ITableRow row : rows) {
appendCopyTextForRow(plainText, row, firstRow, columns);
firstRow = false;
}
TextTransferObject transferObject = new TextTransferObject(plainText.toString());
return transferObject;
}
use of org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn in project scout.rt by eclipse.
the class ColumnSet method setVisibleColumns.
/**
* set visible columns and put them in specific order
*/
public void setVisibleColumns(Collection<? extends IColumn> columns) {
try {
m_table.setTableChanging(true);
//
List<IColumn<?>> resolvedColumns = resolveColumns(columns);
if (columns == null) {
columns = CollectionUtility.hashSet();
}
if (resolvedColumns.size() > 0 || columns.size() == 0) {
List<IColumn<?>> newColumns = new ArrayList<IColumn<?>>();
for (IColumn col : columns) {
if (col.isDisplayable()) {
// sanity check
if (col.getInitialWidth() == 0 && col.getWidth() == 0) {
col.setInitialWidth(60);
col.setWidth(60);
}
newColumns.add(col);
}
}
int viewHint = 0;
int nextNewIndex = 0;
for (IColumn col : getAllColumnsInUserOrder()) {
if (newColumns.contains(col)) {
// use next in list since the list is pre-ordered
IColumn nextSortedCol = newColumns.get(nextNewIndex);
nextNewIndex++;
nextSortedCol.setVisible(true);
nextSortedCol.setVisibleColumnIndexHint(viewHint);
} else {
col.setVisible(false);
col.setVisibleColumnIndexHint(viewHint);
}
viewHint++;
}
reorganizeIndexes();
List<IColumn<?>> displayableColumns = getDisplayableColumns();
for (IColumn col : displayableColumns) {
rebuildHeaderCell(col);
}
fireColumnHeadersUpdated(displayableColumns);
fireColumnStructureChanged();
checkMultiline();
}
} finally {
m_table.setTableChanging(false);
}
}
use of org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn in project scout.rt by eclipse.
the class ColumnSet method setSortSpec.
public void setSortSpec(SortSpec spec) {
if (spec != null) {
for (IColumn col : m_userSortColumns) {
HeaderCell cell = (HeaderCell) col.getHeaderCell();
cell.setSortActive(false);
cell.setSortAscending(false);
}
m_userSortColumns.clear();
List<IColumn<?>> colList = new ArrayList<IColumn<?>>();
for (int i = 0; i < spec.size(); i++) {
IColumn col = getColumn(spec.getColumnIndex(i));
if (col != null && (!isSortColumn(col))) {
HeaderCell cell = (HeaderCell) col.getHeaderCell();
cell.setSortActive(true);
cell.setSortAscending(spec.isColumnAscending(i));
colList.add(col);
}
}
m_userSortColumns.addAll(colList);
for (IColumn col : colList) {
rebuildHeaderCell(col);
}
fireColumnHeadersUpdated(colList);
} else {
clearSortColumns();
}
}
use of org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn in project scout.rt by eclipse.
the class ColumnSet method initialize.
public void initialize() {
ClientUIPreferences prefs = ClientUIPreferences.getInstance();
// clean up visible column index hints, make as permutation of model indices
int n = getColumnCount();
TreeMap<CompositeObject, IColumn> sortMap = new TreeMap<CompositeObject, IColumn>();
int viewIndex = 0;
for (int modelIndex = 0; modelIndex < n; modelIndex++) {
IColumn col = getColumn(modelIndex);
double viewHint = col.getVisibleColumnIndexHint();
if (viewHint < 0) {
viewHint = col.getOrder();
}
if (viewHint < 0) {
viewHint = viewIndex;
}
sortMap.put(new CompositeObject(viewHint, viewIndex), col);
// next
viewIndex++;
}
viewIndex = 0;
for (Map.Entry<CompositeObject, IColumn> e : sortMap.entrySet()) {
e.getValue().setVisibleColumnIndexHint(viewIndex);
viewIndex++;
}
reorganizeIndexes();
applySortingAndGrouping(null);
/*
* ticket 93309
* sanity check: when there is no visible column at all, reset visibilities to model init defaults
*/
if (getVisibleColumnCount() == 0) {
viewIndex = 0;
for (IColumn c : getColumns()) {
if (c.isDisplayable() && c.isInitialVisible()) {
c.setVisible(true);
} else {
c.setVisible(false);
}
c.setWidth(c.getInitialWidth());
c.setVisibleColumnIndexHint(viewIndex);
prefs.removeAllTableColumnPreferences(c, null, true);
// next
viewIndex++;
}
reorganizeIndexes();
}
checkMultiline();
}
use of org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn in project scout.rt by eclipse.
the class ColumnSet method handleSortEvent.
/*
* Sorting and Grouping
*/
/**
* @param col
* @param multiSort
* True: Multiple sort columns are supported, which means the given column is added to the list of sort
* columns, if not added yet.<br>
* False: The selected column is set as the (new) primary sort column.<br>
* @param ascending
* Specifies the new sort direction
*/
public void handleSortEvent(IColumn col, boolean multiSort, boolean ascending) {
col = resolveColumn(col);
if (col == null) {
return;
}
//
try {
m_table.setTableChanging(true);
//
if (multiSort) {
if (isSortColumn(col)) {
updateSortColumn(col, ascending);
} else {
addSortColumn(col, ascending);
}
} else {
for (IColumn c : m_userSortColumns) {
if (c != col) {
((HeaderCell) c.getHeaderCell()).setGroupingActive(false);
}
}
if (isSortColumn(col) && getSortColumnCount() == 1) {
updateSortColumn(col, ascending);
} else {
setSortColumn(col, ascending);
((HeaderCell) col.getHeaderCell()).setGroupingActive(false);
}
}
} finally {
m_table.setTableChanging(false);
}
}
Aggregations