use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class SummaryRowIntegrationTest method defaultConfigLabelsNotAddedForLayersBelow.
@Test
public void defaultConfigLabelsNotAddedForLayersBelow() throws Exception {
// the AbstractOverrider is set on the DataLayer. So on retrieving the
this.dataLayer.setConfigLabelAccumulator(new AbstractOverrider() {
@Override
public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
RowDataFixture rowObject = SummaryRowIntegrationTest.this.dataProvider.getRowObject(rowPosition);
configLabels.addLabel("myLabel " + rowObject.security_id);
}
});
LabelStack configLabels = this.natTable.getConfigLabelsByPosition(0, 4);
List<String> labels = configLabels.getLabels();
assertEquals(2, labels.size());
assertEquals(SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX + 0, labels.get(0));
assertEquals(SummaryRowLayer.DEFAULT_SUMMARY_ROW_CONFIG_LABEL, labels.get(1));
configLabels = this.natTable.getConfigLabelsByPosition(0, 3);
labels = configLabels.getLabels();
assertEquals(1, labels.size());
assertTrue("Label in default body does not start with myLabel", labels.get(0).startsWith("myLabel"));
}
use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class EditUtils method isConverterSame.
/**
* Checks if all selected cells have the same {@link IDisplayConverter}
* configured. This is needed for the multi edit feature to determine if a
* multi edit is possible. If the collection of selected cells is
* <code>null</code> or empty, this method will also return
* <code>true</code>.
* <p>
* Let's assume there are two columns, one containing an Integer, the other
* a Date. Both have a TextCellEditor configured, so if only the editor is
* checked, the multi edit dialog would open. On committing a changed value
* an error would occur because of wrong conversion.
* </p>
*
* @param selectedCells
* The collection of selected cells that should be checked.
* @param configRegistry
* The {@link IConfigRegistry} needed to access the configured
* {@link IDisplayConverter}s.
* @return <code>true</code> if all selected cells have the same
* {@link IDisplayConverter} configured, <code>false</code> if at
* least one cell has another {@link IDisplayConverter} configured.
*/
@SuppressWarnings("rawtypes")
public static boolean isConverterSame(Collection<ILayerCell> selectedCells, IConfigRegistry configRegistry) {
if (selectedCells != null) {
Set<Class> converterSet = new HashSet<Class>();
for (ILayerCell selectedCell : selectedCells) {
LabelStack labelStack = selectedCell.getConfigLabels();
IDisplayConverter dataTypeConverter = configRegistry.getConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, DisplayMode.EDIT, labelStack.getLabels());
if (dataTypeConverter != null) {
converterSet.add(dataTypeConverter.getClass());
}
if (converterSet.size() > 1)
return false;
}
}
return true;
}
use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class EditUtils method isEditorSame.
/**
* Checks if all selected cells have the same {@link ICellEditor}
* configured. This is needed for the multi edit feature to determine if a
* multi edit is possible. If the collection of selected cells is
* <code>null</code> or empty, this method will also return
* <code>true</code>.
*
* @param selectedCells
* The collection of selected cells that should be checked.
* @param configRegistry
* The {@link IConfigRegistry} needed to access the configured
* {@link ICellEditor}s.
* @return <code>true</code> if all selected cells have the same
* {@link ICellEditor} configured, <code>false</code> if at least
* one cell has another {@link ICellEditor} configured.
*/
public static boolean isEditorSame(Collection<ILayerCell> selectedCells, IConfigRegistry configRegistry) {
if (selectedCells != null) {
ICellEditor lastSelectedCellEditor = null;
for (ILayerCell selectedCell : selectedCells) {
LabelStack labelStack = selectedCell.getConfigLabels();
ICellEditor cellEditor = configRegistry.getConfigAttribute(EditConfigAttributes.CELL_EDITOR, DisplayMode.EDIT, labelStack.getLabels());
// anchor
if (lastSelectedCellEditor == null) {
lastSelectedCellEditor = cellEditor;
}
if (cellEditor != lastSelectedCellEditor) {
return false;
}
}
}
return true;
}
use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class FilterRowMouseEventMatcher method matches.
@Override
public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
NatEventData eventData = NatEventData.createInstanceFromEvent(event);
LabelStack labels = eventData.getRegionLabels();
if (isNotNull(labels)) {
return labels.getLabels().contains(GridRegion.FILTER_ROW);
}
return false;
}
use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class DimensionallyDependentLayer method getConfigLabelsByPosition.
@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
int baseColumnPosition = LayerUtil.convertColumnPosition(this, columnPosition, this.baseLayer);
int baseRowPosition = LayerUtil.convertRowPosition(this, rowPosition, this.baseLayer);
LabelStack labelStack = this.baseLayer.getConfigLabelsByPosition(baseColumnPosition, baseRowPosition);
IConfigLabelAccumulator configLabelAccumulator = getConfigLabelAccumulator();
if (configLabelAccumulator != null) {
configLabelAccumulator.accumulateConfigLabels(labelStack, columnPosition, rowPosition);
}
return labelStack;
}
Aggregations