use of org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn in project scout.rt by eclipse.
the class AbstractTable method handleKeyStroke.
protected boolean handleKeyStroke(String keyName, char keyChar) {
if (keyName == null) {
return false;
}
keyName = keyName.toLowerCase();
// check if there is no menu keystroke with that name
for (IMenu m : getMenus()) {
if (m.getKeyStroke() != null && m.getKeyStroke().equalsIgnoreCase(keyName)) {
return false;
}
}
// check if there is no keystroke with that name (ticket 78234)
for (IKeyStroke k : getKeyStrokes()) {
if (k.getKeyStroke() != null && k.getKeyStroke().equalsIgnoreCase(keyName)) {
return false;
}
}
if (keyChar > ' ' && (!keyName.contains("control")) && (!keyName.contains("ctrl")) && (!keyName.contains("alt"))) {
// select first/next line with corresponding character
String newText = "" + Character.toLowerCase(keyChar);
m_keyStrokeBuffer.append(newText);
String prefix = m_keyStrokeBuffer.getText();
IColumn<?> col = getContextColumn();
if (col == null) {
List<IColumn<?>> sortCols = getColumnSet().getSortColumns();
if (sortCols.size() > 0) {
col = CollectionUtility.lastElement(sortCols);
} else {
TreeMap<CompositeObject, IColumn<?>> sortMap = new TreeMap<CompositeObject, IColumn<?>>();
int index = 0;
for (IColumn<?> c : getColumnSet().getVisibleColumns()) {
if (c.getDataType() == String.class) {
sortMap.put(new CompositeObject(1, index), c);
} else if (c.getDataType() == Boolean.class) {
sortMap.put(new CompositeObject(3, index), c);
} else {
sortMap.put(new CompositeObject(2, index), c);
}
index++;
}
if (sortMap.size() > 0) {
col = sortMap.get(sortMap.firstKey());
}
}
}
if (col != null) {
int colIndex = col.getColumnIndex();
String pattern = StringUtility.toRegExPattern(prefix.toLowerCase());
pattern = pattern + ".*";
if (LOG.isInfoEnabled()) {
LOG.info("finding regex: '{}' in column '{}'", pattern, getColumnSet().getColumn(colIndex).getHeaderCell().getText());
}
// loop over values and find matching one
int rowCount = getRowCount();
ITableRow selRow = getSelectedRow();
int startIndex = 0;
if (selRow != null) {
if (prefix.length() <= 1) {
startIndex = selRow.getRowIndex() + 1;
} else {
startIndex = selRow.getRowIndex();
}
}
for (int i = 0; i < rowCount; i++) {
ITableRow row = m_rows.get((startIndex + i) % rowCount);
String text = row.getCell(colIndex).getText();
if (text != null && text.toLowerCase().matches(pattern)) {
// handled
selectRow(row, false);
return true;
}
}
}
}
return false;
}
use of org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn in project scout.rt by eclipse.
the class ColumnSet method resetColumnsViewOrder.
private void resetColumnsViewOrder() {
for (IColumn c : getColumns()) {
c.setVisibleColumnIndexHint(-1);
}
reorganizeIndexes();
fireColumnOrderChanged();
}
use of org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn in project scout.rt by eclipse.
the class ColumnSet method getSortSpec.
public SortSpec getSortSpec() {
ArrayList<IColumn<?>> sortColumns = new ArrayList<IColumn<?>>();
for (IColumn c : getSortColumns()) {
sortColumns.add(c);
}
if (sortColumns.size() > 0) {
int[] indexes = new int[sortColumns.size()];
boolean[] asc = new boolean[sortColumns.size()];
for (int i = 0; i < sortColumns.size(); i++) {
indexes[i] = sortColumns.get(i).getColumnIndex();
asc[i] = sortColumns.get(i).isSortAscending();
}
return new SortSpec(indexes, asc);
} else {
return null;
}
}
use of org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn in project scout.rt by eclipse.
the class ColumnSet method moveVisibleColumnToVisibleIndex.
public void moveVisibleColumnToVisibleIndex(int fromVisibleIndex, int toVisibleIndex) {
if (fromVisibleIndex != toVisibleIndex) {
IColumn fromCol = getVisibleColumn(fromVisibleIndex);
IColumn toCol = getVisibleColumn(toVisibleIndex);
if (fromCol != null && toCol != null) {
boolean traversedFrom = false;
ArrayList<IColumn<?>> list = new ArrayList<IColumn<?>>();
for (IColumn c : getAllColumnsInUserOrder()) {
if (c == fromCol) {
traversedFrom = true;
// nop
} else if (c == toCol) {
if (traversedFrom) {
list.add(c);
list.add(fromCol);
} else {
list.add(fromCol);
list.add(c);
}
} else {
list.add(c);
}
}
int viewHint = 0;
for (IColumn c : list) {
c.setVisibleColumnIndexHint(viewHint);
viewHint++;
}
reorganizeIndexes();
fireColumnOrderChanged();
}
}
}
use of org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn in project scout.rt by eclipse.
the class ColumnSet method clearPermanentTailSortColumns.
public void clearPermanentTailSortColumns() {
if (m_permanentTailSortColumns.size() == 0) {
return;
}
List<IColumn<?>> currentColumnList = new ArrayList<IColumn<?>>(m_permanentTailSortColumns);
m_permanentTailSortColumns.clear();
for (IColumn col : currentColumnList) {
HeaderCell cell = (HeaderCell) col.getHeaderCell();
cell.setSortActive(false);
cell.setSortPermanent(false);
cell.setGroupingActive(false);
}
for (IColumn col : currentColumnList) {
rebuildHeaderCell(col);
}
fireColumnHeadersUpdated(currentColumnList);
}
Aggregations