Home » Eclipse Projects » NatTable » when scroling horizontally, nattable filter stop working
| |
Re: when scroling horizontally, nattable filter stop working [message #1225982 is a reply to message #1225945] |
Tue, 31 December 2013 10:18 |
Mohamed SADI Messages: 38 Registered: December 2013 |
Member |
|
|
Hello Dirk Fauth, thank you for your fast reply, i use the last version of nattable (1.0.1).
The first think that come to my mind was the size of the array and the map but the size size is the same.
Here is my code :
propertyNames = new String[] { "numero_facture", "date_facture",
"date_echeance", "montant_facture", "montant_ttc", "remise",
"montant_remise", "montant_regle", "montant_non_regle",
"client.nom_prenom", "timbre", "montantTva", "etat",
"mode_paiement" };
propertyToLabels = new HashMap<String, String>();
propertyToLabels.put("numero_facture", "numero");
propertyToLabels.put("date_facture", "date");
propertyToLabels.put("date_echeance", "date_echeance");
propertyToLabels.put("montant_facture", "montant_facture");
propertyToLabels.put("montant_ttc", "montant_ttc");
propertyToLabels.put("remise", "remise");
propertyToLabels.put("montant_remise", "montant_remise");
propertyToLabels.put("montant_regle", "montant_regle");
propertyToLabels.put("montant_non_regle", "montant_non_regle");
propertyToLabels.put("client.nom_prenom", "client");
propertyToLabels.put("timbre", "timbre");
propertyToLabels.put("montantTva", "montantTva");
propertyToLabels.put("etat", "etat");
propertyToLabels.put("mode_paiement", "mode_paiement");
derivedColumnPropertyAccessor = new ExtendedReflectiveColumnPropertyAccessor<Facture>(
propertyNames);
EventList<Facture> model = GlazedLists.eventList(DataManager
.chargerFactureVente());
filterList = new FilterList<Facture>(model);
provider = new ListDataProvider<Facture>(filterList,
derivedColumnPropertyAccessor);
DefaultColumnHeaderDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(
propertyNames, propertyToLabels);
// Creation de la pile de layers centrale
IConfigRegistry configRegistry = new ConfigRegistry();
// Modele de groupement des donnees
GroupByModel groupByModel = new GroupByModel();
GroupByDataLayer<Facture> bodyDataLayer = new GroupByDataLayer(
groupByModel, filterList, derivedColumnPropertyAccessor);
// Creation de la ligne "sommaire" au travers d'un layer
bodyDataLayer.setConfigLabelAccumulator(new ColumnLabelAccumulator());
ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(
bodyDataLayer);
ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(
columnReorderLayer);
SelectionLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
// SelectionLayer selectionLayer = new SelectionLayer(summaryRowLayer);
TreeLayer treeLayer = new TreeLayer(selectionLayer,
bodyDataLayer.getTreeRowModel());
ViewportLayer bodyLayer = new ViewportLayer(treeLayer);
// Creation des colonnes
DefaultColumnHeaderDataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(
columnHeaderDataProvider);
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(
columnHeaderDataLayer, bodyLayer, selectionLayer);
// Ajout des filtres
DefaultGlazedListsFilterStrategy<Facture> filterStrategy = new DefaultGlazedListsFilterStrategy<Facture>(
filterList, derivedColumnPropertyAccessor, configRegistry);
FilterRowHeaderComposite<Facture> filterHeaderLayer = new FilterRowHeaderComposite(
filterStrategy, columnHeaderLayer, columnHeaderDataProvider,
configRegistry);
// Creation des lignes
DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(
provider);
RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(
new DefaultRowHeaderDataLayer(rowHeaderDataProvider),
bodyLayer, selectionLayer);
// Creation du coin superieur
DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(
columnHeaderDataProvider, rowHeaderDataProvider);
CornerLayer cornerLayer = new CornerLayer(new DataLayer(
cornerDataProvider), rowHeaderLayer, filterHeaderLayer);
// Creation du layer global
GridLayer gridLayer = new GridLayer(bodyLayer, filterHeaderLayer,
rowHeaderLayer, cornerLayer, true);
CompositeLayer compositeGridLayer = new CompositeLayer(1, 2);
final GroupByHeaderLayer groupByHeaderLayer = new GroupByHeaderLayer(
groupByModel, gridLayer, columnHeaderDataProvider);
compositeGridLayer.setChildLayer(GroupByHeaderLayer.GROUP_BY_REGION,
groupByHeaderLayer, 0, 0);
compositeGridLayer.setChildLayer("Grid", gridLayer, 0, 1);
final NatTable natTable = new NatTable(parent, compositeGridLayer,
false);
natTable.setConfigRegistry(configRegistry);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
// Configuration de la ligne "sommaire"
// natTable.addConfiguration(new LandingsSummaryRowConfig(provider));
// Configuration du tri sur les lignes
natTable.addConfiguration(new HeaderMenuConfiguration(natTable));
// Configuration des filtres
natTable.addConfiguration(new LandingsFilterConfiguration());
// Configuration du groupement de donnees
natTable.addConfiguration(new GroupByHeaderMenuConfiguration(natTable,
groupByHeaderLayer));
natTable.addConfiguration(new HeaderMenuConfiguration(natTable) {
@Override
protected PopupMenuBuilder createCornerMenu(NatTable natTable) {
return super.createCornerMenu(natTable)
.withStateManagerMenuItemProvider();
}
});
natTable.configure();
natTable.registerCommandHandler(new DisplayPersistenceDialogCommandHandler(
natTable));
// Creation des evenements de selection
ISelectionProvider selectionProvider = new RowSelectionProvider(
selectionLayer, provider, false);
selectionProvider
.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event
.getSelection();
Iterator<?> it = selection.iterator();
while (it.hasNext()) {
Facture data = (Facture) it.next();
System.out.println("Selection of data: "
+ data.getNumero_facture()
+ data.getDate_facture() + " client"
+ data.getClient().getNom_prenom());
}
}
});
return natTable;
thank you in advance
|
|
| |
Re: when scroling horizontally, nattable filter stop working [message #1226028 is a reply to message #1226010] |
Tue, 31 December 2013 13:20 |
Mohamed SADI Messages: 38 Registered: December 2013 |
Member |
|
|
Thank you for your help, the exception is not thrown for the first columns (1 to 7) that are visible (without right scrolling). But for the columns that need scrolling to the right, the exception is thrown. the client property is a POJO object it is mapped like this : propertyToLabels.put("client.nom_prenom", "client");
I will check my code again and compare it with your examples.
Thank you in advance.
[Updated on: Tue, 31 December 2013 13:22] Report message to a moderator
|
|
| | | |
Re: when scroling horizontally, nattable filter stop working [message #1226345 is a reply to message #1226277] |
Wed, 01 January 2014 13:04 |
Mohamed SADI Messages: 38 Registered: December 2013 |
Member |
|
|
Hello , after a very deep code analyse, i realise when adding the FreezeLayer to the nattable, the problem has gone. But without adding the freezeLayer, the problem appear when the grouping is active. Here is the code of an example that work fine with and without grouping :
protected NatTable createNatTable(Composite parent) {
propertyAndMapperDefinition();
final NatTable natTable = filterWithGroupByExample(parent);
// final NatTable natTable = filterWithoutGroupByExample(parent);
return natTable;
}
protected NatTable filterWithGroupByExample(Composite parent) {
// create a new ConfigRegistry which will be needed for GlazedLists
// handling
List<Facture> factureList = DataManager
.chargerFactureVente();
EventList<Facture> eventList = GlazedLists.eventList(factureList);
filterList = new FilterList<Facture>(eventList);
GroupByModel groupByModel = new GroupByModel();
ConfigRegistry configRegistry = new ConfigRegistry();
derivedColumnPropertyAccessor = new ExtendedReflectiveColumnPropertyAccessor<Facture>(
propertyNames);
configRegistry.registerConfigAttribute(
GroupByConfigAttributes.GROUP_BY_SUMMARY_PROVIDER,
new SummationGroupBySummaryProvider<Facture>(
derivedColumnPropertyAccessor), DisplayMode.NORMAL,
GroupByDataLayer.GROUP_BY_COLUMN_PREFIX + "3");
configRegistry.registerConfigAttribute(
GroupByConfigAttributes.GROUP_BY_SUMMARY_PROVIDER,
new SummationGroupBySummaryProvider<Facture>(
derivedColumnPropertyAccessor), DisplayMode.NORMAL,
GroupByDataLayer.GROUP_BY_COLUMN_PREFIX + "4");
GroupByDataLayer<Facture> bodyDataLayer = new GroupByDataLayer<Facture>(
groupByModel, filterList, derivedColumnPropertyAccessor,
configRegistry);
// Body layer
ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(
bodyDataLayer);
ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(
columnReorderLayer);
SelectionLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
TreeLayer treeLayer = new TreeLayer(selectionLayer,
bodyDataLayer.getTreeRowModel());
/*
FreezeLayer freeze = new FreezeLayer(treeLayer);
*/
ViewportLayer viewportLayer = new ViewportLayer(treeLayer);
/*
CompositeFreezeLayer compFreeze = new CompositeFreezeLayer(freeze, viewportLayer, selectionLayer);
*/
provider = new ListDataProvider<Facture>(filterList,
derivedColumnPropertyAccessor);
// Column header layer
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(
propertyNames, propertyToLabels);
DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(
columnHeaderDataProvider);
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(
columnHeaderDataLayer, /*compFreeze*/ viewportLayer, selectionLayer);
// Note: The column header layer is wrapped in a filter row composite.
// This plugs in the filter row functionality
DefaultGlazedListsFilterStrategy<Facture> filterStrategy = new DefaultGlazedListsFilterStrategy<Facture>(
filterList, derivedColumnPropertyAccessor, configRegistry);
FilterRowHeaderComposite<Facture> filterHeaderLayer = new FilterRowHeaderComposite<Facture>(
filterStrategy, columnHeaderLayer,
columnHeaderDataLayer.getDataProvider(), configRegistry);
ColumnOverrideLabelAccumulator bodyLabelAccumulator = new ColumnOverrideLabelAccumulator(
columnHeaderDataLayer);
bodyDataLayer.setConfigLabelAccumulator(bodyLabelAccumulator);
// Row header layer
IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(
provider);
DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(
rowHeaderDataLayer,
viewportLayer, selectionLayer);
// Corner layer
DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(
columnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(
cornerDataProvider);
CornerLayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, filterHeaderLayer);
// Grid
GridLayer gridLayer = new GridLayer(/*compFreeze*/viewportLayer, filterHeaderLayer,
rowHeaderLayer, cornerLayer,true);
CompositeLayer compositeGridLayer = new CompositeLayer(1, 2);
final GroupByHeaderLayer groupByHeaderLayer = new GroupByHeaderLayer(
groupByModel, gridLayer, columnHeaderDataProvider);
compositeGridLayer.setChildLayer(GroupByHeaderLayer.GROUP_BY_REGION,
groupByHeaderLayer, 0, 0);
compositeGridLayer.setChildLayer("Grid", gridLayer, 0, 1);
final NatTable natTable = new NatTable(parent, compositeGridLayer,
false);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new GroupByHeaderMenuConfiguration(natTable,
groupByHeaderLayer));
natTable.addConfiguration(new HeaderMenuConfiguration(natTable));
natTable.addConfiguration(new HoverAndHeaderStyleConfiguration());
natTable.addConfiguration(new LandingsFilterConfiguration());
natTable.setConfigRegistry(configRegistry);
natTable.configure();
natTable.registerCommandHandler(new DisplayPersistenceDialogCommandHandler(
natTable));
// Creation des evenements de selection
ISelectionProvider selectionProvider = new RowSelectionProvider<Facture>(
selectionLayer, provider, false);
selectionProvider
.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event
.getSelection();
Iterator<?> it = selection.iterator();
while (it.hasNext()) {
Facture data = (Facture) it.next();
System.out.println("Selection of data: "
+ data.getNumero_facture()
+ data.getDate_facture() + " client"
+ data.getClient().getNom_prenom());
}
}
});
return natTable;
}
protected NatTable filterWithoutGroupByExample(Composite parent) {
// create a new ConfigRegistry which will be needed for GlazedLists
// handling
ConfigRegistry configRegistry = new ConfigRegistry();
derivedColumnPropertyAccessor = new ExtendedReflectiveColumnPropertyAccessor<Facture>(
propertyNames);
List<Facture> facturesList = DataManager.chargerFactureVente();
BodyLayerStack<Facture> bodyDataLayer = new BodyLayerStack<Facture>(
facturesList, derivedColumnPropertyAccessor);
// build the column header layer
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(
propertyNames, propertyToLabels);
DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(
columnHeaderDataProvider);
ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer,
bodyDataLayer, bodyDataLayer.getSelectionLayer());
// Note: The column header layer is wrapped in a filter row composite.
// This plugs in the filter row functionality
DefaultGlazedListsFilterStrategy<Facture> filterStrategy = new DefaultGlazedListsFilterStrategy<Facture>(
bodyDataLayer.getFilterList(), derivedColumnPropertyAccessor,
configRegistry);
FilterRowHeaderComposite<Facture> filterHeaderLayer = new FilterRowHeaderComposite<Facture>(
filterStrategy, columnHeaderLayer,
columnHeaderDataLayer.getDataProvider(), configRegistry);
// build the row header layer
IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(
bodyDataLayer.getBodyDataProvider());
ILayer rowHeaderLayer = new RowHeaderLayer(
new DefaultRowHeaderDataLayer(rowHeaderDataProvider),
bodyDataLayer, bodyDataLayer.getSelectionLayer());
// build the corner layer
IDataProvider cornerDataProvider = new DefaultCornerDataProvider(
columnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer,
filterHeaderLayer);
// build the grid layer
GridLayer gridLayer = new GridLayer(bodyDataLayer, filterHeaderLayer,
rowHeaderLayer, cornerLayer);
// turn the auto configuration off as we want to add our header menu
// configuration
final NatTable natTable = new NatTable(parent, gridLayer, false);
// as the autoconfiguration of the NatTable is turned off, we have to
// add the
// DefaultNatTableStyleConfiguration and the ConfigRegistry manually
natTable.setConfigRegistry(configRegistry);
// Configuration des filtres
natTable.addConfiguration(new HoverAndHeaderStyleConfiguration());
natTable.addConfiguration(new LandingsFilterConfiguration());
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new HeaderMenuConfiguration(natTable) {
@Override
protected PopupMenuBuilder createCornerMenu(NatTable natTable) {
return super.createCornerMenu(natTable)
.withStateManagerMenuItemProvider();
}
});
natTable.configure();
natTable.registerCommandHandler(new DisplayPersistenceDialogCommandHandler(
natTable));
return natTable;
}
protected void propertyAndMapperDefinition() {
propertyNames = new String[] { "numero_facture", "date_facture",
"date_echeance", "montant_facture", "montant_ttc",
"client.nom_prenom", "remise", "montant_remise",
"montant_regle", "montant_non_regle",
"timbre", "montantTva", "etat", "mode_paiement" };
propertyToLabels = new HashMap<String, String>();
propertyToLabels.put("numero_facture", "numero");
propertyToLabels.put("date_facture", "date");
propertyToLabels.put("date_echeance", "date_echeance");
propertyToLabels.put("montant_facture", "montant_facture");
propertyToLabels.put("montant_ttc", "montant_ttc");
propertyToLabels.put("client.nom_prenom", "client");
propertyToLabels.put("remise", "remise");
propertyToLabels.put("montant_remise", "montant_remise");
propertyToLabels.put("montant_regle", "montant_regle");
propertyToLabels.put("montant_non_regle", "montant_non_regle");
propertyToLabels.put("timbre", "timbre");
propertyToLabels.put("montantTva", "montantTva");
propertyToLabels.put("etat", "etat");
propertyToLabels.put("mode_paiement", "mode_paiement");
}
public class FilterConfiguration extends
AbstractRegistryConfiguration {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
// Affichage de l'icone de tri meme si inactif
// configRegistry.registerConfigAttribute(
// CellConfigAttributes.CELL_PAINTER,
// new FilterRowPainter(new FilterIconPainter(GUIHelper
// .getImage("filter"))), DisplayMode.NORMAL,
// GridRegion.FILTER_ROW);
/*
* "numero_facture", "date_facture", "date_echeance",
* "montant_facture", "montant_ttc", "remise", "montant_remise",
* "montant_regle", "montant_non_regle", "client", "timbre",
* "montantTva", "etat", "mode_paiement" };
*/
configRegistry.registerConfigAttribute(
FilterRowConfigAttributes.TEXT_MATCHING_MODE,
TextMatchingMode.EXACT, DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 0);
configRegistry.registerConfigAttribute(
FilterRowConfigAttributes.TEXT_MATCHING_MODE,
TextMatchingMode.EXACT, DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 1);
configRegistry.registerConfigAttribute(
FilterRowConfigAttributes.TEXT_MATCHING_MODE,
TextMatchingMode.EXACT, DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 2);
configRegistry.registerConfigAttribute(
FilterRowConfigAttributes.FILTER_DISPLAY_CONVERTER,
doubleDisplayConverter, DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 3);
ICellEditor textCell = new TextFilter();
configRegistry.registerConfigAttribute(
EditConfigAttributes.CELL_EDITOR, textCell,
DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 3);
configRegistry.registerConfigAttribute(
FilterRowConfigAttributes.TEXT_MATCHING_MODE,
TextMatchingMode.REGULAR_EXPRESSION, DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 3);
configRegistry.registerConfigAttribute(
FilterRowConfigAttributes.TEXT_MATCHING_MODE,
TextMatchingMode.STARTS_WITH, DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 4);
configRegistry.registerConfigAttribute(
FilterRowConfigAttributes.TEXT_MATCHING_MODE,
TextMatchingMode.EXACT, DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 5);
configRegistry.registerConfigAttribute(
FilterRowConfigAttributes.TEXT_MATCHING_MODE,
TextMatchingMode.EXACT, DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 6);
configRegistry.registerConfigAttribute(
FilterRowConfigAttributes.TEXT_MATCHING_MODE,
TextMatchingMode.EXACT, DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 7);
configRegistry.registerConfigAttribute(
FilterRowConfigAttributes.TEXT_MATCHING_MODE,
TextMatchingMode.EXACT, DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 8);
configRegistry.registerConfigAttribute(
FilterRowConfigAttributes.TEXT_MATCHING_MODE,
TextMatchingMode.CONTAINS, DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 9);
configRegistry.registerConfigAttribute(
FilterRowConfigAttributes.TEXT_MATCHING_MODE,
TextMatchingMode.EXACT, DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 10);
configRegistry.registerConfigAttribute(
FilterRowConfigAttributes.TEXT_MATCHING_MODE,
TextMatchingMode.EXACT, DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 11);
ICellEditor comboBoxCellEditor = new ComboBoxCellEditor(
Arrays.asList(Messages.getString("factureReglee"),
Messages.getString("factureNonReglee")));
configRegistry.registerConfigAttribute(
EditConfigAttributes.CELL_EDITOR, comboBoxCellEditor,
DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 12);
configRegistry.registerConfigAttribute(
FilterRowConfigAttributes.TEXT_MATCHING_MODE,
TextMatchingMode.EXACT, DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 13);
// Application
// du
// style
// sur
// le
// background
// de
// la
// ligne
// de
// filtre
final Style rowStyle = new Style();
rowStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR,
GUIHelper.getColor(197, 212, 231));
configRegistry.registerConfigAttribute(
CellConfigAttributes.CELL_STYLE, rowStyle,
DisplayMode.NORMAL, GridRegion.FILTER_ROW);
configRegistry.registerConfigAttribute(
FilterRowConfigAttributes.TEXT_DELIMITER, "et"); //$NON-NLS-1$
}
}
[Updated on: Thu, 02 January 2014 12:13] Report message to a moderator
|
|
| | | | | | | | | |
Goto Forum:
Current Time: Mon Sep 23 17:14:53 GMT 2024
Powered by FUDForum. Page generated in 0.05485 seconds
|