Search in sources :

Example 1 with DefaultDisplayConverter

use of org.eclipse.nebula.widgets.nattable.data.convert.DefaultDisplayConverter in project nebula.widgets.nattable by eclipse.

the class HierarchicalTreeLayerTest method testUnhideOnSearch.

@Test
public void testUnhideOnSearch() {
    this.treeLayer.setExpandOnSearch(false);
    this.treeLayer.doCommand(new TreeExpandCollapseCommand(9, 2));
    assertEquals(10, this.treeLayer.getRowCount());
    assertEquals(1, this.treeLayer.collapsedNodes.size());
    HierarchicalTreeNode node = this.treeLayer.collapsedNodes.iterator().next();
    assertEquals(2, node.columnIndex);
    assertEquals(9, node.rowIndex);
    assertNotNull(node.rowObject);
    assertEquals(10, this.treeLayer.getHiddenRowIndexes().iterator().next().intValue());
    // search for the collapsed row
    ConfigRegistry configRegistry = new ConfigRegistry();
    configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultDisplayConverter());
    GridSearchStrategy gridSearchStrategy = new GridSearchStrategy(configRegistry, false, true);
    SearchCommand searchCommand = new SearchCommand("sing", this.selectionLayer, gridSearchStrategy, ISearchDirection.SEARCH_FORWARD, false, false, false, false, false, false, new CellValueAsStringComparator<>());
    this.treeLayer.doCommand(searchCommand);
    assertEquals(11, this.treeLayer.getRowCount());
    assertEquals(1, this.treeLayer.collapsedNodes.size());
    node = this.treeLayer.collapsedNodes.iterator().next();
    assertEquals(2, node.columnIndex);
    assertEquals(9, node.rowIndex);
    assertNotNull(node.rowObject);
    assertEquals(0, this.treeLayer.getHiddenRowIndexes().size());
}
Also used : ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) HierarchicalTreeNode(org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeLayer.HierarchicalTreeNode) GridSearchStrategy(org.eclipse.nebula.widgets.nattable.search.strategy.GridSearchStrategy) TreeExpandCollapseCommand(org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandCollapseCommand) DefaultDisplayConverter(org.eclipse.nebula.widgets.nattable.data.convert.DefaultDisplayConverter) SearchCommand(org.eclipse.nebula.widgets.nattable.search.command.SearchCommand) Test(org.junit.Test)

Example 2 with DefaultDisplayConverter

use of org.eclipse.nebula.widgets.nattable.data.convert.DefaultDisplayConverter in project nebula.widgets.nattable by eclipse.

the class HierarchicalTreeLayerTest method testExpandAllLevelsOnSearchWithoutLevelHeader.

@Test
public void testExpandAllLevelsOnSearchWithoutLevelHeader() {
    this.treeLayer.setShowTreeLevelHeader(false);
    this.treeLayer.doCommand(new TreeExpandCollapseCommand(9, 2));
    this.treeLayer.doCommand(new TreeExpandCollapseCommand(6, 0));
    assertEquals(7, this.treeLayer.getRowCount());
    assertEquals(2, this.treeLayer.collapsedNodes.size());
    assertEquals(4, this.treeLayer.getHiddenRowIndexes().size());
    // search for the collapsed row
    ConfigRegistry configRegistry = new ConfigRegistry();
    configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultDisplayConverter());
    GridSearchStrategy gridSearchStrategy = new GridSearchStrategy(configRegistry, false, true);
    SearchCommand searchCommand = new SearchCommand("sing", this.selectionLayer, gridSearchStrategy, ISearchDirection.SEARCH_FORWARD, false, false, false, false, false, false, new CellValueAsStringComparator<>());
    this.treeLayer.doCommand(searchCommand);
    assertEquals(11, this.treeLayer.getRowCount());
    assertEquals(0, this.treeLayer.collapsedNodes.size());
    assertEquals(0, this.treeLayer.getHiddenRowIndexes().size());
}
Also used : ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) GridSearchStrategy(org.eclipse.nebula.widgets.nattable.search.strategy.GridSearchStrategy) TreeExpandCollapseCommand(org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandCollapseCommand) DefaultDisplayConverter(org.eclipse.nebula.widgets.nattable.data.convert.DefaultDisplayConverter) SearchCommand(org.eclipse.nebula.widgets.nattable.search.command.SearchCommand) Test(org.junit.Test)

Example 3 with DefaultDisplayConverter

use of org.eclipse.nebula.widgets.nattable.data.convert.DefaultDisplayConverter in project nebula.widgets.nattable by eclipse.

the class ColumnSearchStrategyTest method setUp.

@Before
public void setUp() {
    this.gridLayer = new GridLayerFixture();
    this.layer = this.gridLayer.getBodyLayer().getSelectionLayer();
    this.configRegistry = new ConfigRegistry();
    this.configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultDisplayConverter());
}
Also used : ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) GridLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture) DefaultDisplayConverter(org.eclipse.nebula.widgets.nattable.data.convert.DefaultDisplayConverter) Before(org.junit.Before)

Example 4 with DefaultDisplayConverter

use of org.eclipse.nebula.widgets.nattable.data.convert.DefaultDisplayConverter in project nebula.widgets.nattable by eclipse.

the class DefaultFilterRowConfiguration method configureRegistry.

@Override
public void configureRegistry(IConfigRegistry configRegistry) {
    // Plug in custom painter
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new PaddingDecorator(this.cellPainter, 0, 0, 0, 5), DisplayMode.NORMAL, GridRegion.FILTER_ROW);
    configRegistry.registerConfigAttribute(CellConfigAttributes.RENDER_GRID_LINES, Boolean.TRUE, DisplayMode.NORMAL, GridRegion.FILTER_ROW);
    // Make cells editable
    configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE, DisplayMode.NORMAL, GridRegion.FILTER_ROW);
    // Default text matching mode
    configRegistry.registerConfigAttribute(FilterRowConfigAttributes.TEXT_MATCHING_MODE, this.textMatchingMode);
    // Default display converter. Used to convert the values typed into the
    // text boxes into String objects.
    configRegistry.registerConfigAttribute(FilterRowConfigAttributes.FILTER_DISPLAY_CONVERTER, new DefaultDisplayConverter());
    // Default comparator. Used to compare objects in the column during
    // threshold matching.
    configRegistry.registerConfigAttribute(FilterRowConfigAttributes.FILTER_COMPARATOR, DefaultComparator.getInstance());
}
Also used : PaddingDecorator(org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator) DefaultDisplayConverter(org.eclipse.nebula.widgets.nattable.data.convert.DefaultDisplayConverter)

Example 5 with DefaultDisplayConverter

use of org.eclipse.nebula.widgets.nattable.data.convert.DefaultDisplayConverter in project nebula.widgets.nattable by eclipse.

the class EditorConfiguration method registerColumnElevenComboBox.

/**
 * The following will register a ComboBoxCellEditor for the column that
 * carries the favourite food information. This ComboBoxCellEditor will
 * support multiple selection. It also adds a different icon for the combo
 * in edit mode.
 *
 * @param configRegistry
 */
private void registerColumnElevenComboBox(IConfigRegistry configRegistry) {
    // register a combobox for the city names
    ComboBoxCellEditor comboBoxCellEditor = new ComboBoxCellEditor(Arrays.asList(PersonService.getFoodList()), -1);
    comboBoxCellEditor.setMultiselect(true);
    comboBoxCellEditor.setUseCheckbox(true);
    // change the multi selection brackets that are added to the String that
    // is shown in the editor
    comboBoxCellEditor.setMultiselectTextBracket("", "");
    // register a special converter that removes the brackets in case the
    // returned value is a Collection
    // this is necessary because editing and displaying are not directly
    // coupled to each other
    configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultDisplayConverter() {

        @Override
        public Object canonicalToDisplayValue(Object canonicalValue) {
            if (canonicalValue instanceof Collection) {
                // Collection.toString() will add [ and ] around the
                // values in the Collection
                // So by removing the leading and ending character,
                // we remove the brackets
                String result = canonicalValue.toString();
                result = result.substring(1, result.length() - 1);
                return result;
            }
            // ComboBox correctly
            return super.canonicalToDisplayValue(canonicalValue);
        }
    }, DisplayMode.NORMAL, EditorExample.COLUMN_ELEVEN_LABEL);
    comboBoxCellEditor.setIconImage(GUIHelper.getImage("plus"));
    configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, comboBoxCellEditor, DisplayMode.EDIT, EditorExample.COLUMN_ELEVEN_LABEL);
}
Also used : ComboBoxCellEditor(org.eclipse.nebula.widgets.nattable.edit.editor.ComboBoxCellEditor) Collection(java.util.Collection) DefaultDisplayConverter(org.eclipse.nebula.widgets.nattable.data.convert.DefaultDisplayConverter)

Aggregations

DefaultDisplayConverter (org.eclipse.nebula.widgets.nattable.data.convert.DefaultDisplayConverter)12 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)7 SearchCommand (org.eclipse.nebula.widgets.nattable.search.command.SearchCommand)6 GridSearchStrategy (org.eclipse.nebula.widgets.nattable.search.strategy.GridSearchStrategy)6 TreeExpandCollapseCommand (org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandCollapseCommand)6 Test (org.junit.Test)6 HierarchicalTreeNode (org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeLayer.HierarchicalTreeNode)4 PaddingDecorator (org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)1 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)1 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)1 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)1 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)1 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)1 ReflectiveColumnPropertyAccessor (org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor)1 DefaultBooleanDisplayConverter (org.eclipse.nebula.widgets.nattable.data.convert.DefaultBooleanDisplayConverter)1