Search in sources :

Example 1 with IConfigRegistry

use of org.eclipse.nebula.widgets.nattable.config.IConfigRegistry in project nebula.widgets.nattable by eclipse.

the class FormulaFillHandlePasteTest method setup.

@Before
public void setup() {
    InternalCellClipboard clipboard = new InternalCellClipboard();
    this.selectionLayer.registerCommandHandler(new InternalCopyDataCommandHandler(this.selectionLayer, clipboard));
    this.selectionLayer.registerCommandHandler(new FormulaFillHandlePasteCommandHandler(this.selectionLayer, clipboard, this.formulaDataProvider));
    this.natTable.addConfiguration(new DefaultFormulaConfiguration(this.formulaDataProvider, this.selectionLayer, clipboard));
    this.natTable.addConfiguration(new AbstractRegistryConfiguration() {

        @Override
        public void configureRegistry(IConfigRegistry configRegistry) {
            configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, EditableRule.ALWAYS_EDITABLE);
        }
    });
    this.natTable.configure();
}
Also used : InternalCellClipboard(org.eclipse.nebula.widgets.nattable.copy.InternalCellClipboard) DefaultFormulaConfiguration(org.eclipse.nebula.widgets.nattable.formula.config.DefaultFormulaConfiguration) AbstractRegistryConfiguration(org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration) FormulaFillHandlePasteCommandHandler(org.eclipse.nebula.widgets.nattable.formula.command.FormulaFillHandlePasteCommandHandler) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) InternalCopyDataCommandHandler(org.eclipse.nebula.widgets.nattable.copy.command.InternalCopyDataCommandHandler) Before(org.junit.Before)

Example 2 with IConfigRegistry

use of org.eclipse.nebula.widgets.nattable.config.IConfigRegistry in project nebula.widgets.nattable by eclipse.

the class MaxCellBoundsHelperTest method getPreferedRowHeights.

@Test
public void getPreferedRowHeights() throws Exception {
    DataLayerFixture dataLayer = new DataLayerFixture(3, 2, 10, 10);
    IDataProvider dataProvider = dataLayer.getDataProvider();
    // Row 0
    dataProvider.setDataValue(0, 0, "..");
    dataProvider.setDataValue(1, 0, "...");
    dataProvider.setDataValue(2, 0, "...");
    // Row 1
    dataProvider.setDataValue(0, 1, "Elephant");
    dataProvider.setDataValue(1, 1, "Cat");
    dataProvider.setDataValue(2, 1, "Rat");
    AutoResizeRowCommandFixture command = new AutoResizeRowCommandFixture();
    GCFactory gcFactory = command.getGCFactory();
    IConfigRegistry registry = command.getConfigRegistry();
    GC gc = gcFactory.createGC();
    int row0MaxTextHeight = new TextPainter().getPreferredHeight(new CellFixture(".."), gc, registry);
    int row1MaxTextHeight = new TextPainter().getPreferredHeight(new CellFixture("Elephant"), gc, registry);
    gc.dispose();
    int[] maxRowHeights = MaxCellBoundsHelper.getPreferredRowHeights(registry, gcFactory, dataLayer, new int[] { 0, 1 });
    // Adjust heights
    int row0AdjustedMaxHeight = dataLayer.getLayerPainter().adjustCellBounds(0, 0, new Rectangle(0, 0, 10, maxRowHeights[0])).height;
    int row1AdjustedMaxHeight = dataLayer.getLayerPainter().adjustCellBounds(0, 1, new Rectangle(0, 0, 10, maxRowHeights[1])).height;
    Assert.assertEquals(row0MaxTextHeight, row0AdjustedMaxHeight);
    Assert.assertEquals(row1MaxTextHeight, row1AdjustedMaxHeight);
}
Also used : GCFactory(org.eclipse.nebula.widgets.nattable.util.GCFactory) CellFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.CellFixture) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) Rectangle(org.eclipse.swt.graphics.Rectangle) AutoResizeRowCommandFixture(org.eclipse.nebula.widgets.nattable.test.fixture.command.AutoResizeRowCommandFixture) TextPainter(org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) GC(org.eclipse.swt.graphics.GC) Test(org.junit.Test)

Example 3 with IConfigRegistry

use of org.eclipse.nebula.widgets.nattable.config.IConfigRegistry in project nebula.widgets.nattable by eclipse.

the class MaxCellBoundsHelperTest method getPreferedColumnWidths.

@Test
public void getPreferedColumnWidths() throws Exception {
    DataLayerFixture dataLayer = new DataLayerFixture(2, 3, 10, 10);
    IDataProvider dataProvider = dataLayer.getDataProvider();
    // Col 0
    dataProvider.setDataValue(0, 0, "Long");
    dataProvider.setDataValue(0, 1, "Longer");
    dataProvider.setDataValue(0, 2, "Longest Text");
    // Col 1
    dataProvider.setDataValue(1, 0, "Elephant");
    dataProvider.setDataValue(1, 1, "Cat");
    dataProvider.setDataValue(1, 2, "Rat");
    AutoResizeColumnCommandFixture command = new AutoResizeColumnCommandFixture();
    GCFactory gcFactory = command.getGCFactory();
    IConfigRegistry registry = command.getConfigRegistry();
    GC gc = gcFactory.createGC();
    int col0MaxTextWidth = new TextPainter().getPreferredWidth(new CellFixture("Longest Text"), gc, registry);
    int col1MaxTextWidth = new TextPainter().getPreferredWidth(new CellFixture("Elephant"), gc, registry);
    gc.dispose();
    int[] maxColumnWidths = MaxCellBoundsHelper.getPreferredColumnWidths(registry, gcFactory, dataLayer, new int[] { 0, 1 });
    // Adjust widths
    int col0AdjustedMaxWidth = dataLayer.getLayerPainter().adjustCellBounds(0, 0, new Rectangle(0, 0, maxColumnWidths[0], 10)).width;
    int col1AdjustedMaxWidth = dataLayer.getLayerPainter().adjustCellBounds(1, 0, new Rectangle(0, 0, maxColumnWidths[1], 10)).width;
    Assert.assertEquals(col0MaxTextWidth, col0AdjustedMaxWidth);
    Assert.assertEquals(col1MaxTextWidth, col1AdjustedMaxWidth);
}
Also used : GCFactory(org.eclipse.nebula.widgets.nattable.util.GCFactory) CellFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.CellFixture) AutoResizeColumnCommandFixture(org.eclipse.nebula.widgets.nattable.test.fixture.command.AutoResizeColumnCommandFixture) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) Rectangle(org.eclipse.swt.graphics.Rectangle) TextPainter(org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) GC(org.eclipse.swt.graphics.GC) Test(org.junit.Test)

Example 4 with IConfigRegistry

use of org.eclipse.nebula.widgets.nattable.config.IConfigRegistry in project nebula.widgets.nattable by eclipse.

the class SummaryRowIntegrationTest method initLayerStackWithSummaryRow.

@Before
public void initLayerStackWithSummaryRow() {
    this.dataList = RowDataListFixture.getList().subList(0, 4);
    // Rows 0, 1, 2, 3; Summary row would be position 4
    assertEquals(4, this.dataList.size());
    this.dataProvider = new ListDataProvider<RowDataFixture>(this.dataList, new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()));
    IConfigRegistry configRegistry = new ConfigRegistry();
    this.dataLayer = new DataLayer(this.dataProvider);
    this.summaryRowLayer = new SummaryRowLayer(this.dataLayer, configRegistry);
    IUniqueIndexLayer columnReorderLayer = new ColumnReorderLayer(this.summaryRowLayer);
    IUniqueIndexLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
    IUniqueIndexLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
    this.layerStackWithSummary = new ViewportLayer(selectionLayer);
    // NatTableFixture initializes the client area
    this.natTable = new NatTableFixture(this.layerStackWithSummary, false);
    this.natTable.setConfigRegistry(configRegistry);
    this.natTable.addConfiguration(new TestSummaryRowConfiguration());
    this.natTable.configure();
}
Also used : NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) IUniqueIndexLayer(org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer) Before(org.junit.Before)

Example 5 with IConfigRegistry

use of org.eclipse.nebula.widgets.nattable.config.IConfigRegistry in project nebula.widgets.nattable by eclipse.

the class NatTable method getConfigRegistry.

/**
 * @return {@link IConfigRegistry} used to hold the configuration bindings
 *         by Layer, DisplayMode and Config labels.
 */
public IConfigRegistry getConfigRegistry() {
    if (this.configRegistry == null) {
        this.configRegistry = new ConfigRegistry();
        this.themeManager = new ThemeManager(this.configRegistry);
    }
    return this.configRegistry;
}
Also used : ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) ThemeManager(org.eclipse.nebula.widgets.nattable.style.theme.ThemeManager)

Aggregations

IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)64 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)42 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)42 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)38 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)37 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)34 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)31 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)29 HashMap (java.util.HashMap)28 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)27 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)26 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)24 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)24 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)24 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)23 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)23 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)23 GridLayout (org.eclipse.swt.layout.GridLayout)23 Composite (org.eclipse.swt.widgets.Composite)23 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)20