Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » when scroling horizontally, nattable filter stop working
when scroling horizontally, nattable filter stop working [message #1225810] Mon, 30 December 2013 21:41 Go to next message
Mohamed SADI is currently offline Mohamed SADIFriend
Messages: 38
Registered: December 2013
Member
I have 14 columns in my nattable example, to see the value of the lasts column (11 to 14) i should scroll horizontally.

When i filter my table without scrolling horizontally, every think work fine, but when i scroll to other columns and try filter, the inserted value (in the filter) is inserted in the the above column and the filter doesn't work.

19:57:12,880 ERROR [DefaultGlazedListsFilterStrategy] Error on applying a filter
java.lang.ArrayIndexOutOfBoundsException: -1
	at java.util.Arrays$ArrayList.get(Arrays.java:3381)
	at org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor.getColumnProperty(ReflectiveColumnPropertyAccessor.java:79)
	at org.eclipse.nebula.widgets.nattable.data.ExtendedReflectiveColumnPropertyAccessor.getDataValue(ExtendedReflectiveColumnPropertyAccessor.java:25)
	at org.eclipse.nebula.widgets.nattable.extension.glazedlists.filterrow.DefaultGlazedListsFilterStrategy$2.getFilterStrings(DefaultGlazedListsFilterStrategy.java:227)
	at ca.odell.glazedlists.impl.filter.TextMatchers.matches(TextMatchers.java:82)
	at ca.odell.glazedlists.impl.filter.TextMatcher.matches(TextMatcher.java:110)
	at ca.odell.glazedlists.impl.matchers.OrMatcher.matches(OrMatcher.java:23)
	at ca.odell.glazedlists.impl.matchers.AndMatcher.matches(AndMatcher.java:23)
	at ca.odell.glazedlists.FilterList.constrained(FilterList.java:391)
	at ca.odell.glazedlists.FilterList.changeMatcher(FilterList.java:295)
	at ca.odell.glazedlists.FilterList.changeMatcherWithLocks(FilterList.java:276)
	at ca.odell.glazedlists.FilterList.access$100(FilterList.java:51)
	at ca.odell.glazedlists.FilterList$PrivateMatcherEditorListener.changedMatcher(FilterList.java:453)
	at ca.odell.glazedlists.matchers.AbstractMatcherEditorListenerSupport.fireChangedMatcher(AbstractMatcherEditorListenerSupport.java:41)
	at ca.odell.glazedlists.matchers.AbstractMatcherEditor.fireConstrained(AbstractMatcherEditor.java:59)
	at ca.odell.glazedlists.matchers.CompositeMatcherEditor$MatcherEditorsListListener.listChanged(CompositeMatcherEditor.java:132)
	at ca.odell.glazedlists.event.ListEventAssembler$ListEventFormat.fire(ListEventAssembler.java:424)
	at ca.odell.glazedlists.event.ListEventAssembler$ListEventFormat.fire(ListEventAssembler.java:421)
	at ca.odell.glazedlists.event.SequenceDependenciesEventPublisher$SubjectAndListener.firePendingEvent(SequenceDependenciesEventPublisher.java:445)
	at ca.odell.glazedlists.event.SequenceDependenciesEventPublisher.fireEvent(SequenceDependenciesEventPublisher.java:344)
	at ca.odell.glazedlists.event.ListEventAssembler.commitEvent(ListEventAssembler.java:317)
	at ca.odell.glazedlists.BasicEventList.addAll(BasicEventList.java:167)
	at ca.odell.glazedlists.BasicEventList.addAll(BasicEventList.java:149)
	at org.eclipse.nebula.widgets.nattable.extension.glazedlists.filterrow.DefaultGlazedListsFilterStrategy.applyFilter(DefaultGlazedListsFilterStrategy.java:157)
	at org.eclipse.nebula.widgets.nattable.filterrow.FilterRowDataProvider.setDataValue(FilterRowDataProvider.java:168)
	at org.eclipse.nebula.widgets.nattable.layer.DataLayer.setDataValue(DataLayer.java:144)
	at org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommandHandler.doCommand(UpdateDataCommandHandler.java:54)
	at org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommandHandler.doCommand(UpdateDataCommandHandler.java:1)
	at org.eclipse.nebula.widgets.nattable.command.AbstractLayerCommandHandler.doCommand(AbstractLayerCommandHandler.java:19)
	at org.eclipse.nebula.widgets.nattable.layer.AbstractLayer.doCommand(AbstractLayer.java:162)
	at org.eclipse.nebula.widgets.nattable.layer.DataLayer.doCommand(DataLayer.java:422)
	at org.eclipse.nebula.widgets.nattable.filterrow.FilterRowDataLayer.doCommand(FilterRowDataLayer.java:68)
	at org.eclipse.nebula.widgets.nattable.grid.layer.DimensionallyDependentLayer.doCommand(DimensionallyDependentLayer.java:149)
	at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer.doCommandOnChildLayers(CompositeLayer.java:140)
Re: when scroling horizontally, nattable filter stop working [message #1225945 is a reply to message #1225810] Tue, 31 December 2013 08:00 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
I don't think that this is related to filtering. It looks more like some misconfiguration of your ReflectiveColumnPropertyAccessor. Did you check that there are as much entries in the map as in the array?

Otherwise can you see the same issue in our examples? Which version of NatTable do you use? What does your composition look like?
Re: when scroling horizontally, nattable filter stop working [message #1225982 is a reply to message #1225945] Tue, 31 December 2013 10:18 Go to previous messageGo to next message
Mohamed SADI is currently offline Mohamed SADIFriend
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 #1226010 is a reply to message #1225982] Tue, 31 December 2013 12:14 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Quite advanced composition. Can't tell you without debugging myself.

Try to check for which column property the exception is thrown. Maybe it is related to the client. property.
Re: when scroling horizontally, nattable filter stop working [message #1226028 is a reply to message #1226010] Tue, 31 December 2013 13:20 Go to previous messageGo to next message
Mohamed SADI is currently offline Mohamed SADIFriend
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 #1226036 is a reply to message #1226028] Tue, 31 December 2013 13:34 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
It looks like the exception is thrown because a column is requested that can not be resolved. The -1 index for accessing the array indicates that. So maybe there is just some typo.
Re: when scroling horizontally, nattable filter stop working [message #1226171 is a reply to message #1226036] Tue, 31 December 2013 23:28 Go to previous messageGo to next message
Mohamed SADI is currently offline Mohamed SADIFriend
Messages: 38
Registered: December 2013
Member
can we create a nattable that contains both group by composite and filter row composite ? when i try my code without grouping by data layer the problem disappear but when i mixe them the exception is thrown.

[Updated on: Wed, 01 January 2014 09:59]

Report message to a moderator

Re: when scroling horizontally, nattable filter stop working [message #1226277 is a reply to message #1226171] Wed, 01 January 2014 08:00 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
It should, but possibly the reflective data providers are not compatible in that case.

For grouping there are new groupby objects added to the list that build the tree structure. Maybe the exception is raised because of those objects. Does it only appear when a grouping is active?

[Updated on: Wed, 01 January 2014 08:23]

Report message to a moderator

icon7.gif  Re: when scroling horizontally, nattable filter stop working [message #1226345 is a reply to message #1226277] Wed, 01 January 2014 13:04 Go to previous messageGo to next message
Mohamed SADI is currently offline Mohamed SADIFriend
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

Re: when scroling horizontally, nattable filter stop working [message #1226439 is a reply to message #1226345] Wed, 01 January 2014 20:10 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
I will try to investigate after my vacation. Please describe when exactly the issue appears.

Is grouping active? For which column is filtering active? How can I reproduce the issue exactly?
Re: when scroling horizontally, nattable filter stop working [message #1226494 is a reply to message #1226439] Wed, 01 January 2014 23:16 Go to previous messageGo to next message
Mohamed SADI is currently offline Mohamed SADIFriend
Messages: 38
Registered: December 2013
Member
In my last post, i showed you two methods : one is filterWithoutGroupByExample and the other is filterWithGroupByExample :

To reproduce the exception, you should just run the method filterWithGroupByExample. The filter is active for all columns (14) like is shown in FilterConfiguration that i ve extended from AbstractRegistryConfiguration.

I wasn't able to apply color and underlying my code to show you differences between the filterWithoutGroupByExample and the filterWithGroupByExample method.

If you want that i send you the woole example including Facture Pojo object, i'll do it.
Re: when scroling horizontally, nattable filter stop working [message #1227195 is a reply to message #1226494] Fri, 03 January 2014 20:31 Go to previous messageGo to next message
Mohamed SADI is currently offline Mohamed SADIFriend
Messages: 38
Registered: December 2013
Member
I hope you'll have a nice vacation Wink
Re: when scroling horizontally, nattable filter stop working [message #1229825 is a reply to message #1227195] Fri, 10 January 2014 10:00 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
I created a new example that combines filter, groupby and sorting. It is not finished yet, so it isn't pushed. But it will be added to the repository soon.

In my example the described issue doesn't appear. Checking your code, the issue is that you are creating your own IDataProvider, while there is one generated by the GroupByDataLayer.

So this line in your code is wrong, as there is already a provider:
provider = new ListDataProvider<Facture>(filterList, derivedColumnPropertyAccessor);


You should change that to be:
provider = bodyDataLayer.getDataProvider();


The GroupByDataLayer is internally creating and applying a GlazedListsDataProvider with the internal created TreeList that is necessary to render the tree structure on grouping. By creating and using another IDataProvider in the rest of the layer composition, the issue seems to be raised.

At least this seems to be the issue. I can not run your code as there are too many classes missing.
Re: when scroling horizontally, nattable filter stop working [message #1230773 is a reply to message #1229825] Mon, 13 January 2014 02:55 Go to previous messageGo to next message
Mohamed SADI is currently offline Mohamed SADIFriend
Messages: 38
Registered: December 2013
Member
I've tried your proposition but steel not working. I'll show you next days the previous code with all used classes.
Re: when scroling horizontally, nattable filter stop working [message #1230815 is a reply to message #1230773] Mon, 13 January 2014 06:11 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Maybe you could first try if my example works or if you are able to bring up the issue there aswell.

And if not, compare my code with yours. Not sure if it is related to some filter configuration or the layer composition.
Re: when scroling horizontally, nattable filter stop working [message #1230897 is a reply to message #1230815] Mon, 13 January 2014 10:45 Go to previous messageGo to next message
Mohamed SADI is currently offline Mohamed SADIFriend
Messages: 38
Registered: December 2013
Member
Ok, i'all wait that you commit your new example that mix Filter and Group by column layers, many thanks
Re: when scroling horizontally, nattable filter stop working [message #1230905 is a reply to message #1230897] Mon, 13 January 2014 11:00 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Sorry, I forgot to mention that I already committed and pushed my example: _706_SortableGroupByWithFilterExample
Re: when scroling horizontally, nattable filter stop working [message #1231351 is a reply to message #1230905] Tue, 14 January 2014 12:44 Go to previous message
Mohamed SADI is currently offline Mohamed SADIFriend
Messages: 38
Registered: December 2013
Member
Ok, you've tell me in the Topic "Mixing Sort by and Filter in nattable : http://www.eclipse.org/forums/index.php/m/1230900/#msg_1230900" that you've added _706_SortableGroupByWithFilterExample, in this example you've helped me to resolve all my nattable problems. Thank you very much for your help
Previous Topic:Issue with ColumnReorder and Refresh
Next Topic:Change numbering of the rows
Goto Forum:
  


Current Time: Fri Apr 19 21:29:29 GMT 2024

Powered by FUDForum. Page generated in 0.05269 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top