Search in sources :

Example 6 with LabelStack

use of net.sourceforge.nattable.layer.LabelStack in project translationstudio8 by heartsome.

the class RowHeaderLayer method getConfigLabelsByPosition.

@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
    LabelStack labelStack = super.getConfigLabelsByPosition(columnPosition, rowPosition);
    final int selectionLayerRowPosition = LayerUtil.convertRowPosition(this, rowPosition, selectionLayer);
    if (selectionLayer.isRowFullySelected(selectionLayerRowPosition)) {
        labelStack.addLabel(SelectionStyleLabels.ROW_FULLY_SELECTED_STYLE);
    }
    return labelStack;
}
Also used : LabelStack(net.sourceforge.nattable.layer.LabelStack)

Example 7 with LabelStack

use of net.sourceforge.nattable.layer.LabelStack in project translationstudio8 by heartsome.

the class ColumnHeaderLayer method getConfigLabelsByPosition.

@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
    LabelStack labelStack = super.getConfigLabelsByPosition(columnPosition, rowPosition);
    final int selectionLayerColumnPosition = LayerUtil.convertColumnPosition(this, columnPosition, selectionLayer);
    if (selectionLayer.isColumnFullySelected(selectionLayerColumnPosition)) {
        labelStack.addLabel(SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE);
    }
    return labelStack;
}
Also used : LabelStack(net.sourceforge.nattable.layer.LabelStack)

Example 8 with LabelStack

use of net.sourceforge.nattable.layer.LabelStack in project translationstudio8 by heartsome.

the class SummaryRowLayer method getDataValueByPosition.

/**
	 * Calculates the summary for the column using the {@link ISummaryProvider} from the {@link IConfigRegistry}.<br/>
	 * In order to prevent the table from freezing (for large data sets), the summary is calculated in a separate Thread. While
	 * summary is being calculated {@link ISummaryProvider#DEFAULT_SUMMARY_VALUE} is returned.
	 * 
	 * NOTE: Since this is a {@link IUniqueIndexLayer} sitting close to the {@link DataLayer}, columnPosition == columnIndex
	 */
@Override
public Object getDataValueByPosition(final int columnPosition, final int rowPosition) {
    if (isSummaryRowPosition(rowPosition)) {
        if (getSummaryFromCache(columnPosition) != null) {
            return getSummaryFromCache(columnPosition);
        } else {
            // Get the summary provider from the configuration registry
            LabelStack labelStack = getConfigLabelsByPosition(columnPosition, rowPosition);
            String[] configLabels = labelStack.getLabels().toArray(ArrayUtil.STRING_TYPE_ARRAY);
            final ISummaryProvider summaryProvider = configRegistry.getConfigAttribute(SummaryRowConfigAttributes.SUMMARY_PROVIDER, DisplayMode.NORMAL, configLabels);
            // If there is no Summary provider - skip processing
            if (summaryProvider == ISummaryProvider.NONE) {
                return ISummaryProvider.DEFAULT_SUMMARY_VALUE;
            }
            // Start thread to calculate summary
            new Thread() {

                @Override
                public void run() {
                    Object summaryValue = calculateColumnSummary(columnPosition, summaryProvider);
                    addToCache(columnPosition, summaryValue);
                    fireLayerEvent(new RowUpdateEvent(SummaryRowLayer.this, rowPosition));
                }
            }.start();
        }
        return ISummaryProvider.DEFAULT_SUMMARY_VALUE;
    }
    return super.getDataValueByPosition(columnPosition, rowPosition);
}
Also used : LabelStack(net.sourceforge.nattable.layer.LabelStack) RowUpdateEvent(net.sourceforge.nattable.layer.event.RowUpdateEvent)

Example 9 with LabelStack

use of net.sourceforge.nattable.layer.LabelStack in project translationstudio8 by heartsome.

the class SortHeaderLayer method getConfigLabelsByPosition.

/**
	 * @return adds a special configuration label to the stack taking into account the following:<br/>
	 * 	<ol>
	 * 		<li>Is the column sorted ?</li>
	 * 		<li>What is the sort order of the column</li>
	 * 	</ol>
	 * A special painter is registered against the above labels to render the sort arrows
	 */
@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
    LabelStack configLabels = super.getConfigLabelsByPosition(columnPosition, rowPosition);
    if (sortModel != null) {
        int columnIndex = getColumnIndexByPosition(columnPosition);
        if (sortModel.isColumnIndexSorted(columnIndex)) {
            SortDirectionEnum sortDirection = sortModel.getSortDirection(columnIndex);
            switch(sortDirection) {
                case ASC:
                    configLabels.addLabel(DefaultSortConfiguration.SORT_UP_CONFIG_TYPE);
                    break;
                case DESC:
                    configLabels.addLabel(DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE);
                    break;
            }
            String sortConfig = DefaultSortConfiguration.SORT_SEQ_CONFIG_TYPE + sortModel.getSortOrder(columnIndex);
            configLabels.addLabel(sortConfig);
        }
    }
    return configLabels;
}
Also used : LabelStack(net.sourceforge.nattable.layer.LabelStack)

Aggregations

LabelStack (net.sourceforge.nattable.layer.LabelStack)9 PositionCoordinate (net.sourceforge.nattable.coordinate.PositionCoordinate)2 TimerTask (java.util.TimerTask)1 IEditableRule (net.sourceforge.nattable.config.IEditableRule)1 IndexCoordinate (net.sourceforge.nattable.coordinate.IndexCoordinate)1 ICellEditor (net.sourceforge.nattable.edit.editor.ICellEditor)1 RowUpdateEvent (net.sourceforge.nattable.layer.event.RowUpdateEvent)1 NatEventData (net.sourceforge.nattable.ui.NatEventData)1