Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 07:11 Go to next message
Monical Lai is currently offline Monical LaiFriend
Messages: 8
Registered: March 2014
Junior Member
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 13:20 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2702
Registered: July 2012
Senior Member
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] Thu, 27 March 2014 02:51 Go to previous messageGo to next message
Monical Lai is currently offline Monical LaiFriend
Messages: 8
Registered: March 2014
Junior Member
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 07:39]

Report message to a moderator

Re: How can summaryrow change immediately after filter [message #1278346 is a reply to message #1278203] Thu, 27 March 2014 07:50 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2702
Registered: July 2012
Senior Member
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 07:35 Go to previous messageGo to next message
Monical Lai is currently offline Monical LaiFriend
Messages: 8
Registered: March 2014
Junior Member
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 07:39 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2702
Registered: July 2012
Senior Member
Which NatTable version?
Re: How can summaryrow change immediately after filter [message #1279073 is a reply to message #1279068] Fri, 28 March 2014 07:45 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2702
Registered: July 2012
Senior Member
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 11:02 Go to previous messageGo to next message
Monical Lai is currently offline Monical LaiFriend
Messages: 8
Registered: March 2014
Junior Member
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 11:51 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2702
Registered: July 2012
Senior Member
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] Mon, 31 March 2014 01:45 Go to previous messageGo to next message
Monical Lai is currently offline Monical LaiFriend
Messages: 8
Registered: March 2014
Junior Member
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 10:02 Go to previous messageGo to next message
Monical Lai is currently offline Monical LaiFriend
Messages: 8
Registered: March 2014
Junior Member
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 10:04 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2702
Registered: July 2012
Senior Member
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 10:06 Go to previous messageGo to next message
Monical Lai is currently offline Monical LaiFriend
Messages: 8
Registered: March 2014
Junior Member
Shocked
Re: How can summaryrow change immediately after filter [message #1281107 is a reply to message #1281071] Mon, 31 March 2014 11:18 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2702
Registered: July 2012
Senior Member
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] Tue, 01 April 2014 01:33 Go to previous message
Monical Lai is currently offline Monical LaiFriend
Messages: 8
Registered: March 2014
Junior Member
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: Mon Aug 19 14:27:55 GMT 2019

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

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

Back to the top