Search in sources :

Example 16 with IColumn

use of org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn in project scout.rt by eclipse.

the class ColumnSet method calculateKeyIndexes.

private void calculateKeyIndexes() {
    List<Integer> keyIndexes = new ArrayList<Integer>();
    for (int modelIndex = 0; modelIndex < getColumnCount(); modelIndex++) {
        IColumn col = getColumn(modelIndex);
        if (col.isPrimaryKey()) {
            keyIndexes.add(modelIndex);
        }
    }
    m_keyIndexes = new int[keyIndexes.size()];
    int viewIndex = 0;
    for (int modelIndex : keyIndexes) {
        m_keyIndexes[viewIndex++] = modelIndex;
    }
}
Also used : IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) ArrayList(java.util.ArrayList)

Example 17 with IColumn

use of org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn in project scout.rt by eclipse.

the class ColumnSet method calculateVisibleIndexes.

private void calculateVisibleIndexes() {
    int viewIndex = 0;
    Map<CompositeObject, Integer> visibleMap = new TreeMap<CompositeObject, Integer>();
    for (int modelIndex = 0; modelIndex < getColumnCount(); modelIndex++) {
        IColumn col = getColumn(modelIndex);
        if (col.isDisplayable() && col.isVisible()) {
            double viewHint = col.getVisibleColumnIndexHint();
            if (viewHint < 0) {
                viewHint = col.getOrder();
            }
            if (viewHint < 0) {
                viewHint = viewIndex;
            }
            visibleMap.put(new CompositeObject(viewHint, viewIndex), modelIndex);
            viewIndex++;
        }
    }
    m_visibleIndexes = new int[visibleMap.size()];
    viewIndex = 0;
    for (int modelIndex : visibleMap.values()) {
        m_visibleIndexes[viewIndex++] = modelIndex;
    }
}
Also used : CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject) IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) TreeMap(java.util.TreeMap)

Example 18 with IColumn

use of org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn in project scout.rt by eclipse.

the class ColumnSet method checkMultiline.

private void checkMultiline() {
    if (m_table != null && !m_table.isInitialMultilineText() && !ConfigurationUtility.isMethodOverwrite(AbstractTable.class, "getConfiguredMultilineText", null, m_table.getClass())) {
        // do automatic check for wrapping columns
        boolean m = false;
        for (IColumn col : getVisibleColumns()) {
            if (col instanceof IStringColumn && ((IStringColumn) col).isTextWrap()) {
                m = true;
                break;
            }
        }
        m_table.setMultilineText(m);
    }
}
Also used : IStringColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IStringColumn) IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn)

Example 19 with IColumn

use of org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn in project scout.rt by eclipse.

the class ColumnSet method applySortingAndGroupingInternal.

private void applySortingAndGroupingInternal(Map<IColumn, P_SortingAndGroupingConfig> columnConfigs) {
    TreeMap<CompositeObject, IColumn> sortMap = new TreeMap<CompositeObject, IColumn>();
    int index = 0;
    for (IColumn col : getColumns()) {
        int sortIndex = -1;
        if (col.isInitialAlwaysIncludeSortAtBegin()) {
            sortIndex = col.getInitialSortIndex();
            if (sortIndex < 0) {
                LOG.warn("AlwaysIncludeSortAtBegin is set but no sort index configured. Table: {}", m_table.getClass().getName());
            }
        } else if (col.isInitialAlwaysIncludeSortAtEnd()) {
            sortIndex = col.getInitialSortIndex();
            if (sortIndex < 0) {
                LOG.warn("AlwaysIncludeSortAtEnd is set but no sort index configured. Table: {}", m_table.getClass().getName());
            }
        } else {
            sortIndex = columnConfigs.get(col).getSortIndex();
        }
        if (sortIndex >= 0) {
            sortMap.put(new CompositeObject(sortIndex, index), col);
        }
        // aggregation function:
        if (col instanceof INumberColumn) {
            ((INumberColumn) col).setAggregationFunction(columnConfigs.get(col).getAggregationFunction());
        }
        index++;
    }
    clearSortColumns();
    clearPermanentHeadSortColumns();
    clearPermanentTailSortColumns();
    boolean asc;
    for (IColumn col : sortMap.values()) {
        if (col.isInitialAlwaysIncludeSortAtBegin()) {
            asc = col.isInitialSortAscending();
            addPermanentHeadSortColumn(col, asc);
        } else if (col.isInitialAlwaysIncludeSortAtEnd()) {
            asc = col.isInitialSortAscending();
            addPermanentTailSortColumn(col, asc);
        } else {
            asc = columnConfigs.get(col).isAscending();
            addSortColumn(col, asc);
        }
    }
    applyGrouping(columnConfigs);
}
Also used : CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject) INumberColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.INumberColumn) IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) TreeMap(java.util.TreeMap)

Example 20 with IColumn

use of org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn in project scout.rt by eclipse.

the class ColumnSet method clearSortColumns.

/**
 * only clears user sort columns.
 * <p>
 * see also {@link #clearPermanentHeadSortColumns()} and {@link #clearPermanentTailSortColumns()}
 */
public void clearSortColumns() {
    if (m_userSortColumns.size() == 0) {
        return;
    }
    List<IColumn<?>> userSortColumnsBackup = new ArrayList<IColumn<?>>(m_userSortColumns);
    m_userSortColumns.clear();
    for (IColumn col : userSortColumnsBackup) {
        HeaderCell cell = (HeaderCell) col.getHeaderCell();
        cell.setSortActive(false);
        cell.setGroupingActive(false);
    }
    for (IColumn c : userSortColumnsBackup) {
        rebuildHeaderCell(c);
    }
    fireColumnHeadersUpdated(userSortColumnsBackup);
}
Also used : IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) ArrayList(java.util.ArrayList)

Aggregations

IColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn)49 ArrayList (java.util.ArrayList)10 TreeMap (java.util.TreeMap)8 CompositeObject (org.eclipse.scout.rt.platform.util.CompositeObject)7 Test (org.junit.Test)6 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)5 JSONObject (org.json.JSONObject)5 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)4 IFormField (org.eclipse.scout.rt.client.ui.form.fields.IFormField)4 INumberColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.INumberColumn)3 HashMap (java.util.HashMap)2 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 Method (java.lang.reflect.Method)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 TreeSet (java.util.TreeSet)1 ClientUIPreferences (org.eclipse.scout.rt.client.ui.ClientUIPreferences)1 IKeyStroke (org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke)1