Skip to main content



      Home
Home » Eclipse Projects » NatTable » How can summaryrow change immediately after filter
How can summaryrow change immediately after filter [message #1277583] Wed, 26 March 2014 03:11 Go to next message
Eclipse UserFriend
Summaryrow doesn't make changes after filter, but it works when I resize column after filter.
Any help is appreciated.
Thanks in advance.

public class StaticFilterGridLayer<T> extends GridLayer {

	private final ListDataProvider<T> bodyDataProvider;
	private final DataLayer bodyDataLayer;
	private final CompositeFreezeLayer bodyLayer;
	private final SelectionLayer selectionLayer;

	public StaticFilterGridLayer(EventList<T> eventList,
			String[] propertyNames, Map<String, String> propertyToLabelMap,
			IConfigRegistry configRegistry) {
		super(true);

		// Underlying data source
		TransformedList<T, T> rowObjectsGlazedList = GlazedLists
				.threadSafeList(eventList);
		SortedList<T> sortedList = new SortedList<T>(rowObjectsGlazedList, null);
		FilterList<T> filterList = new FilterList<T>(sortedList);

		// Body layer
		IColumnPropertyAccessor<T> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<T>(
				propertyNames);

		bodyDataProvider = new ListDataProvider<T>(filterList,
				columnPropertyAccessor);


		bodyDataLayer = new DataLayer(bodyDataProvider);


		GlazedListsEventLayer<T> glazedListsEventLayer = new GlazedListsEventLayer<T>(
				bodyDataLayer, eventList);

		RowHideShowLayer rowHideShowLayer = new RowHideShowLayer(
				glazedListsEventLayer);
		SummaryRowLayer summaryRowLayer = new SummaryRowLayer(
				glazedListsEventLayer, configRegistry, false);
		 summaryRowLayer
		 .addConfiguration(new CalculatingSummaryRowConfiguration(
		 bodyDataProvider));
		selectionLayer = new SelectionLayer(summaryRowLayer);
		final ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
		final FreezeLayer freezeLayer = new FreezeLayer(selectionLayer);
		bodyLayer = new CompositeFreezeLayer(freezeLayer, viewportLayer,
				selectionLayer);
		// bodyLayer = new DefaultBodyLayerStack(glazedListsEventLayer);
		ColumnOverrideLabelAccumulator bodyLabelAccumulator = new ColumnOverrideLabelAccumulator(bodyDataLayer);
		bodyDataLayer.setConfigLabelAccumulator(bodyLabelAccumulator);
		


		
		// Column header layer
		IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
		DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
		ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(
				columnHeaderDataLayer, bodyLayer, selectionLayer);
		
		SortHeaderLayer<T> sortHeaderLayer = new SortHeaderLayer<T>(
				columnHeaderLayer, 
 new GlazedListsSortModel<T>(
						sortedList, 
						columnPropertyAccessor,
						configRegistry, 
						columnHeaderDataLayer), false);
		sortHeaderLayer.addConfiguration(new SingleClickSortConfiguration());

		//	Note: The column header layer is wrapped in a filter row composite.
		//	This plugs in the filter row functionality
		CompositeMatcherEditor<T> autoFilterMatcherEditor = new CompositeMatcherEditor<T>();
		filterList.setMatcherEditor(autoFilterMatcherEditor);
		
		// DefaultGlazedListsFilterStrategy<T> filterStrategy =
		// new DefaultGlazedListsFilterStrategy<T>(autoFilterMatcherEditor,
		// columnPropertyAccessor, configRegistry);
		DefaultGlazedListsStaticFilterStrategy<T> filterStrategy = new DefaultGlazedListsStaticFilterStrategy<T>(
				autoFilterMatcherEditor, columnPropertyAccessor, configRegistry);

		
		FilterRowHeaderComposite<T> filterRowHeaderLayer = new FilterRowHeaderComposite<T>(
				filterStrategy, sortHeaderLayer, columnHeaderDataProvider,
				configRegistry
			);

		ColumnOverrideLabelAccumulator labelAccumulator = new ColumnOverrideLabelAccumulator(columnHeaderDataLayer);
		columnHeaderDataLayer.setConfigLabelAccumulator(labelAccumulator);

		// Row header layer
		IDataProvider rowHeaderDataProvider = new DefaultSummaryRowHeaderDataProvider(
				bodyDataProvider, "\u2211");
		DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(
				rowHeaderDataProvider);
		RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer,
				bodyLayer, selectionLayer);

		// Corner layer
		DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
		DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
		CornerLayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, filterRowHeaderLayer);

		// Grid
		setBodyLayer(bodyLayer);
		// 	Note: Set the filter row as the column header
		setColumnHeaderLayer(filterRowHeaderLayer);
		setRowHeaderLayer(rowHeaderLayer);
		setCornerLayer(cornerLayer);
	}

	public SelectionLayer getSelectionLayer() {
		return selectionLayer;
	}
	
	@Override
	public void setClientAreaProvider(IClientAreaProvider clientAreaProvider) {
		super.setClientAreaProvider(clientAreaProvider);
	}


	public ListDataProvider<T> getBodyDataProvider() {
		return bodyDataProvider;
	}

	public DataLayer getBodyDataLayer() {
		return bodyDataLayer;
	}

	public final CompositeFreezeLayer getBodyLayerStack() {
		return bodyLayer;
	}


	class CalculatingSummaryRowConfiguration extends
			DefaultSummaryRowConfiguration {

		private final IDataProvider dataProvider;

		public CalculatingSummaryRowConfiguration(IDataProvider dataProvider) {
			this.dataProvider = dataProvider;
			summaryRowBgColor = GUIHelper.COLOR_BLUE;
			summaryRowFgColor = GUIHelper.COLOR_WHITE;
		}

		@Override
		public void addSummaryProviderConfig(IConfigRegistry configRegistry) {
			// Labels are applied to the summary row and cells by default to
			// make configuration easier.
			// See the Javadoc for the SummaryRowLayer

			// Default summary provider
			configRegistry.registerConfigAttribute(
					SummaryRowConfigAttributes.SUMMARY_PROVIDER,
					new SummationSummaryProvider(dataProvider),
					DisplayMode.NORMAL,
					SummaryRowLayer.DEFAULT_SUMMARY_ROW_CONFIG_LABEL);

		}

	}

}
Re: How can summaryrow change immediately after filter [message #1277788 is a reply to message #1277583] Wed, 26 March 2014 09:20 Go to previous messageGo to next message
Eclipse UserFriend
1. Create your GlazedListsEventLayer using the FilterList, otherwise filter events don't get propagated further in the layer stack.
2. Why is there a RowHideShowLayer? When using GlazedLists you need to use the GlazedListsRowHideShowLayer, everything else won't work.
Re: How can summaryrow change immediately after filter [message #1278203 is a reply to message #1277788] Wed, 26 March 2014 22:51 Go to previous messageGo to next message
Eclipse UserFriend
It works now. Thanks for your help and reminding.
I have another issue that the summary row data is still the same even though I hide/show any column.

[Updated on: Thu, 27 March 2014 03:39] by Moderator

Re: How can summaryrow change immediately after filter [message #1278346 is a reply to message #1278203] Thu, 27 March 2014 03:50 Go to previous messageGo to next message
Eclipse UserFriend
Quote:
I have another issue that the summary row data is still the same even though I hide/show any column.


Why should hiding a column have impact on the summary row?
Re: How can summaryrow change immediately after filter [message #1279066 is a reply to message #1278346] Fri, 28 March 2014 03:35 Go to previous messageGo to next message
Eclipse UserFriend
It's strange that the summary data of which column I have hided show as if it's another's.
Re: How can summaryrow change immediately after filter [message #1279068 is a reply to message #1279066] Fri, 28 March 2014 03:39 Go to previous messageGo to next message
Eclipse UserFriend
Which NatTable version?
Re: How can summaryrow change immediately after filter [message #1279073 is a reply to message #1279068] Fri, 28 March 2014 03:45 Go to previous messageGo to next message
Eclipse UserFriend
Oh, and where is your ColumnHideShowLayer in your layer composition? In the example above there is no such layer.
Re: How can summaryrow change immediately after filter [message #1279187 is a reply to message #1279073] Fri, 28 March 2014 07:02 Go to previous messageGo to next message
Eclipse UserFriend
GlazedListsEventLayer<T> glazedListsEventLayer = new GlazedListsEventLayer<T>(
				bodyDataLayer, filterList);
		ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(
				glazedListsEventLayer);
		
		SummaryRowLayer summaryRowLayer = new SummaryRowLayer(
				columnHideShowLayer, configRegistry, false);
		summaryRowLayer
				.addConfiguration(new CalculatingSummaryRowConfiguration(
						bodyDataProvider));
Re: How can summaryrow change immediately after filter [message #1279209 is a reply to message #1279187] Fri, 28 March 2014 07:51 Go to previous messageGo to next message
Eclipse UserFriend
Create the SummaryRowLayer as much on the bottom as possible. In your case, directly above the GlazedListsEventLayer. Otherwise the transformations will get calculated wrong.
Re: How can summaryrow change immediately after filter [message #1280835 is a reply to message #1279209] Sun, 30 March 2014 21:45 Go to previous messageGo to next message
Eclipse UserFriend
It's ok now, thank you for your patient help.
Re: How can summaryrow change immediately after filter [message #1281066 is a reply to message #1280835] Mon, 31 March 2014 06:02 Go to previous messageGo to next message
Eclipse UserFriend
Hi Dirk, I have another question, the exported excel includes summary row but summary data.

Re: How can summaryrow change immediately after filter [message #1281068 is a reply to message #1281066] Mon, 31 March 2014 06:04 Go to previous messageGo to next message
Eclipse UserFriend
You mean no summary data right?

https://bugs.eclipse.org/bugs/show_bug.cgi?id=417078
Re: How can summaryrow change immediately after filter [message #1281071 is a reply to message #1281068] Mon, 31 March 2014 06:06 Go to previous messageGo to next message
Eclipse UserFriend
Shocked
Re: How can summaryrow change immediately after filter [message #1281107 is a reply to message #1281071] Mon, 31 March 2014 07:18 Go to previous messageGo to next message
Eclipse UserFriend
Monical Lai wrote on Mon, 31 March 2014 12:06
Shocked


I'm not sure what you are trying to tell me with that smiley. It is at least not helpful.

The export issue you described is a known bug that has already been fixed in the current code base. So it is gone with the upcoming 1.1 release. If you need it know, try to use a current development snapshot.
Re: How can summaryrow change immediately after filter [message #1281518 is a reply to message #1281107] Mon, 31 March 2014 21:33 Go to previous message
Eclipse UserFriend
Yeah, I got what you mean, just surprised it's a bug, nothing more.
Previous Topic:Handling very large data with Nattable
Next Topic:NatTable Auto Focus functionality
Goto Forum:
  


Current Time: Sun Jul 27 02:27:01 EDT 2025

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

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

Back to the top