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());
}
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());
}
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());
}
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());
}
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);
}
Aggregations