Search in sources :

Example 56 with LabelStack

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"));
}
Also used : AbstractOverrider(org.eclipse.nebula.widgets.nattable.layer.cell.AbstractOverrider) LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) Test(org.junit.Test)

Example 57 with LabelStack

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;
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) IDisplayConverter(org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter) HashSet(java.util.HashSet)

Example 58 with LabelStack

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;
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) ICellEditor(org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)

Example 59 with LabelStack

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;
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) NatEventData(org.eclipse.nebula.widgets.nattable.ui.NatEventData)

Example 60 with LabelStack

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;
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) IConfigLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator)

Aggregations

LabelStack (org.eclipse.nebula.widgets.nattable.layer.LabelStack)80 Test (org.junit.Test)30 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)14 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)13 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)11 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)10 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)10 HashMap (java.util.HashMap)9 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)9 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)9 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 GridLayout (org.eclipse.swt.layout.GridLayout)9 Composite (org.eclipse.swt.widgets.Composite)9 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)8 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)8 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)8 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)8 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)8