Bug 504077 - [Table] Papyrus table to support percentage sizing offered by NatTable
Summary: [Table] Papyrus table to support percentage sizing offered by NatTable
Status: RESOLVED FIXED
Alias: None
Product: Papyrus
Classification: Modeling
Component: Table (show other bugs)
Version: 2.0.0   Edit
Hardware: PC Windows NT
: P3 normal (vote)
Target Milestone: 3.0.0   Edit
Assignee: Nicolas FAUVERGUE CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 495352
  Show dependency tree
 
Reported: 2016-10-05 10:01 EDT by Young-Soo Roh CLA
Modified: 2017-05-10 04:18 EDT (History)
5 users (show)

See Also:


Attachments
snapshot (67.31 KB, image/jpeg)
2016-12-01 10:08 EST, Young-Soo Roh CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Young-Soo Roh CLA 2016-10-05 10:01:44 EDT
PercentageSizing is useful feature that NatTable supports to fill the columns and resize when parent window resizes. Similar functionality is implemented by oep.infra.nattable.manager.table.doFillColumnsSize but does not seem to work well. 

It is possible to set percentage sizing from sub classes. 

		 DataLayer bodyDataLayer = manager.getBodyLayerStack().getBodyDataLayer();
		 int columnCount = manager.getColumnCount();
		 int width = 100 / columnCount;
		 bodyDataLayer.setColumnPercentageSizing(true);
		 for (int i = 0; i < columnCount; i++) {
		 // width percentage must be set for each column if setColumnPercentageSizing is set to true.
		 bodyDataLayer.setColumnWidthPercentageByPosition(i, width);
		 }


It works except one problem. Users cannot resize column width.
Columns disappear except the first one when users resize column width manually. If I remove columnsResizeListener that persist column axis then percentage sizing works as expected. Not sure why this causes table to be messed up but at least this could be a good start point to look at.

In addition, there should be way to override ColumnResizeListener so that sub classes have choice not to persist the table column size.
Comment 1 Young-Soo Roh CLA 2016-10-05 10:19:41 EDT
Also doFillColumnsSize conflicts with percentage sizing so the column width changing itself indefinitely.
Comment 2 Young-Soo Roh CLA 2016-10-05 14:20:00 EDT
Also current fillColumnsStyle does not support auto resizing of columns when users resize containing window.
Comment 3 Young-Soo Roh CLA 2016-10-05 14:22:34 EDT
doFillColumns style works with https://bugs.eclipse.org/bugs/show_bug.cgi?id=503083 fix patch. However the table look a bit bigger horizontally so it always creates scroll bar. Also columns do not resize when window resizes. So supporting percentage sizing should solve this problem.

(In reply to Young-Soo Roh from comment #0)
> PercentageSizing is useful feature that NatTable supports to fill the
> columns and resize when parent window resizes. Similar functionality is
> implemented by oep.infra.nattable.manager.table.doFillColumnsSize but does
> not seem to work well. 
> 
> It is possible to set percentage sizing from sub classes. 
> 
> 		 DataLayer bodyDataLayer = manager.getBodyLayerStack().getBodyDataLayer();
> 		 int columnCount = manager.getColumnCount();
> 		 int width = 100 / columnCount;
> 		 bodyDataLayer.setColumnPercentageSizing(true);
> 		 for (int i = 0; i < columnCount; i++) {
> 		 // width percentage must be set for each column if
> setColumnPercentageSizing is set to true.
> 		 bodyDataLayer.setColumnWidthPercentageByPosition(i, width);
> 		 }
> 
> 
> It works except one problem. Users cannot resize column width.
> Columns disappear except the first one when users resize column width
> manually. If I remove columnsResizeListener that persist column axis then
> percentage sizing works as expected. Not sure why this causes table to be
> messed up but at least this could be a good start point to look at.
> 
> In addition, there should be way to override ColumnResizeListener so that
> sub classes have choice not to persist the table column size.
Comment 4 Young-Soo Roh CLA 2016-10-06 10:02:26 EDT
When user resize column width then the table looses fillColumnsWidth style because it is set to false from createSetColumnSizeCommand. This prevents NattablePropertyEditor from displaying correct initial table size after user manually resize columns width. Users expect to see the correct fill table columns size for subsequent table display. There must be a reason why the fillColumnsWidth style is foreced turned off but this is bug since it is not the intention of the users when they set this style to true.
Comment 5 Charles Rivet CLA 2016-11-10 16:18:32 EST
Rémi, could this be fixd for Neon.2? This represents a UX issue for Papyrus-RT
Comment 6 Vincent Lorenzo CLA 2016-11-18 06:47:39 EST
Hi Young-Soo, 
   to resume, you would like that Papyrus Table framework use percentage method provided by NatTable instead of calculating itself the size of the column
 In addition, you want that resizing the property update the size of the column (should alre

please could you confirm these points: 
  - you would prefer (and I agree with that), we use the percentage sizing provided by NatTable. We consider this point as enhancement, so I would prefer to it for Papyrus Oxygen version

When you wrote: 
1.Also doFillColumnsSize conflicts with percentage sizing so the column width changing itself indefinitely.

>>I assume you patched Papyrus Table to support percentage, so I'm not surprized you get bug between these features


2.Also current fillColumnsStyle does not support auto resizing of columns when users resize containing window.
>> Yes
Comment 7 Vincent Lorenzo CLA 2016-11-18 06:48:29 EST
Please ignore the previous message, I will rewrite it!
Comment 8 Vincent Lorenzo CLA 2016-11-18 07:01:16 EST
Hi Young-Soo, 
   to resume, you would like that Papyrus Table framework use percentage method provided by NatTable instead of calculating itself the size of the column. Right ?

It should work with these usecases: 
   - you want that resizing the property view updates the size of the columns (should already work with NatTable percentage)
   - the user must be able to resize column
 

Reading Comment4, I understood that the resizing of the column must not be save for the next opening, right ? 
If right, this is not the wanted behavior in Papyrus. We want to save all
custmizations done by the user for the next usage of the same table in the same context, so we keep columns size, columns order, existing columns, ...

Nevertheless, we could try to provide a way to restore automatically to the table config provided by the developper. But it should be done an enhancement, so better for Oxygen version. 


(+ Papyrus Team must think to check columns size after an add/remove columns of the property view)
Comment 9 Young-Soo Roh CLA 2016-11-18 08:38:17 EST
Please see comments inline


(In reply to vincent lorenzo from comment #8)
> Hi Young-Soo, 
>    to resume, you would like that Papyrus Table framework use percentage
> method provided by NatTable instead of calculating itself the size of the
> column. Right ?

No. Not exactly. What I want is that allow users to choose percentage sizing at least when they create their own table. Currently I can set my own table using percentage sizing but it conflicts with table framework.

If you can just provide subclass to override your column resize listener and allow users to choose not to persist column width then that should be good enough. You don't have to change behaviour of existing table framework.

Again. You don't have to change Papyrus table framework to use percentage sizing for all tables. Just allow users to at least be able to use the percentage sizing.

> 
> It should work with these usecases: 
>    - you want that resizing the property view updates the size of the
> columns (should already work with NatTable percentage)


>    - the user must be able to resize column



>  
> 
> Reading Comment4, I understood that the resizing of the column must not be
> save for the next opening, right ? 

At least for table used for property view and that's our use case. It may be useful for other tables but not property view table.

> If right, this is not the wanted behavior in Papyrus. We want to save all
> custmizations done by the user for the next usage of the same table in the
> same context, so we keep columns size, columns order, existing columns,

I understand so can you give a option? through table configuration?
similar to doFillColumnWidth? Something like saveColumnWidth???
We definitely do not need to save the width since it should be reset every time when the table is open and that is what percentage sizing is doing anyways. 


 ...
> 
> Nevertheless, we could try to provide a way to restore automatically to the
> table config provided by the developper. But it should be done an
> enhancement, so better for Oxygen version. 
> 


> 
> (+ Papyrus Team must think to check columns size after an add/remove columns
> of the property view)
Comment 10 Young-Soo Roh CLA 2016-11-18 08:41:44 EST
And I think this is rather a bug and could be fixed rather easily so prefer to be fixed soon if it is possible.
Comment 11 Eclipse Genie CLA 2016-11-22 18:46:44 EST
New Gerrit change created: https://git.eclipse.org/r/85543
Comment 12 Eclipse Genie CLA 2016-11-28 08:33:06 EST
New Gerrit change created: https://git.eclipse.org/r/85863
Comment 13 Eclipse Genie CLA 2016-11-30 09:55:14 EST
Gerrit change https://git.eclipse.org/r/85863 was merged to [streams/2.0-maintenance].
Commit: http://git.eclipse.org/c/papyrus/org.eclipse.papyrus.git/commit/?id=6e9101fcda37f09fcc0d98289dc44360b9f4d63a
Comment 14 Vincent Lorenzo CLA 2016-11-30 09:57:53 EST
(In reply to Eclipse Genie from comment #13)
> Gerrit change https://git.eclipse.org/r/85863 was merged to
> [streams/2.0-maintenance].
> Commit:
> http://git.eclipse.org/c/papyrus/org.eclipse.papyrus.git/commit/
> ?id=6e9101fcda37f09fcc0d98289dc44360b9f4d63a

Hi Young-Soo, 
   I just pushed the fix in streams/2.0-maintenance:
- The API has been opened
- we replace our old behavior by the new one
- named style have been created:

   - 'columnsWidthAsPercentage' to manage axis width with percentage. If this named style is managed as true, the 'axisWidth' are managed as percentage too. 
   - 'saveColumnsWidth' to determinate if the 'axisWidth' must be used for the table columns width initialization 

Please could you test and validate these changes ?
Comment 15 Young-Soo Roh CLA 2016-11-30 11:22:22 EST
(In reply to vincent lorenzo from comment #14)
> (In reply to Eclipse Genie from comment #13)
> > Gerrit change https://git.eclipse.org/r/85863 was merged to
> > [streams/2.0-maintenance].
> > Commit:
> > http://git.eclipse.org/c/papyrus/org.eclipse.papyrus.git/commit/
> > ?id=6e9101fcda37f09fcc0d98289dc44360b9f4d63a
> 
> Hi Young-Soo, 
>    I just pushed the fix in streams/2.0-maintenance:
> - The API has been opened
> - we replace our old behavior by the new one
> - named style have been created:
> 
>    - 'columnsWidthAsPercentage' to manage axis width with percentage. If
> this named style is managed as true, the 'axisWidth' are managed as
> percentage too. 
>    - 'saveColumnsWidth' to determinate if the 'axisWidth' must be used for
> the table columns width initialization 
> 
> Please could you test and validate these changes ?

Thanks Vincent, I will test and let you know.
Comment 16 Young-Soo Roh CLA 2016-12-01 10:07:16 EST
(In reply to vincent lorenzo from comment #14)
> (In reply to Eclipse Genie from comment #13)
> > Gerrit change https://git.eclipse.org/r/85863 was merged to
> > [streams/2.0-maintenance].
> > Commit:
> > http://git.eclipse.org/c/papyrus/org.eclipse.papyrus.git/commit/
> > ?id=6e9101fcda37f09fcc0d98289dc44360b9f4d63a
> 
> Hi Young-Soo, 
>    I just pushed the fix in streams/2.0-maintenance:
> - The API has been opened
> - we replace our old behavior by the new one
> - named style have been created:
> 
>    - 'columnsWidthAsPercentage' to manage axis width with percentage. If
> this named style is managed as true, the 'axisWidth' are managed as
> percentage too. 
>    - 'saveColumnsWidth' to determinate if the 'axisWidth' must be used for
> the table columns width initialization 
> 
> Please could you test and validate these changes ?

Percentage sizing works now with latest merge. The only thing I found is that for non even number columns they don't seem to add up to 100%. As a result there is small space not lined up with the table size at the end. Please see attached snapshot. If columns are odd number then the last one should include left over from the calculation. e.g., for three columns 33% + 33% + 34% something like this.
Comment 17 Young-Soo Roh CLA 2016-12-01 10:08:24 EST
Created attachment 265678 [details]
snapshot

table not lined up.
Comment 18 Young-Soo Roh CLA 2016-12-01 10:37:46 EST
You still seem to set fillColumnsSize to true automatically if not found in the configuration. I assume that this value does not play a role if percentage sizing is set to true?
Comment 19 Nicolas FAUVERGUE CLA 2016-12-02 03:57:34 EST
(In reply to Young-Soo Roh from comment #16)
> Percentage sizing works now with latest merge. The only thing I found is
> that for non even number columns they don't seem to add up to 100%. As a
> result there is small space not lined up with the table size at the end.
> Please see attached snapshot. If columns are odd number then the last one
> should include left over from the calculation. e.g., for three columns 33% +
> 33% + 34% something like this.

An optimization of pourcentage calculation can be done. This comes from a round problem. I will take a look on this.


(In reply to Young-Soo Roh from comment #18)
> You still seem to set fillColumnsSize to true automatically if not found in
> the configuration. I assume that this value does not play a role if
> percentage sizing is set to true?

Of course, for the table in the properties view, all the size must be fill, so the default named style fillColumnsSize is set to true.
But this is only use when the percentage sizing named style is set to false.
Comment 20 Eclipse Genie CLA 2016-12-02 04:55:55 EST
New Gerrit change created: https://git.eclipse.org/r/86215
Comment 21 Eclipse Genie CLA 2016-12-02 07:58:20 EST
New Gerrit change created: https://git.eclipse.org/r/86235
Comment 22 Eclipse Genie CLA 2016-12-05 08:13:56 EST
Gerrit change https://git.eclipse.org/r/86235 was merged to [streams/2.0-maintenance].
Commit: http://git.eclipse.org/c/papyrus/org.eclipse.papyrus.git/commit/?id=8c0dfdb1d3bd4dafbd9ae522a133107d96a347a1
Comment 23 Vincent Lorenzo CLA 2016-12-05 08:35:38 EST
Hi Young-Soo, I just pushed a fix to get 34% + 33% + 33%. Is it OK for you ?
Comment 24 Nicolas FAUVERGUE CLA 2016-12-05 08:40:07 EST
And for more columns, the rest of pourcentage must be divide in the X first columns.

For example, 8 columns with the same size:
13% + 13% + 13% + 13% + 12% + 12% + 12% + 12%
Comment 26 Young-Soo Roh CLA 2016-12-05 10:12:23 EST
(In reply to vincent lorenzo from comment #23)
> Hi Young-Soo, I just pushed a fix to get 34% + 33% + 33%. Is it OK for you ?

Hi Vincent,

Yes that's perfect.
Comment 27 Eclipse Genie CLA 2016-12-05 10:40:29 EST
New Gerrit change created: https://git.eclipse.org/r/86375
Comment 29 Vincent Lorenzo CLA 2016-12-06 04:11:01 EST
This bug can now be marked as resolved fixed.
Comment 30 Young-Soo Roh CLA 2016-12-09 12:41:00 EST
(In reply to vincent lorenzo from comment #29)
> This bug can now be marked as resolved fixed.

Vincent,, Is the latest change merged to 2.0 maintenance branch???
Comment 31 Nicolas FAUVERGUE CLA 2016-12-15 07:35:34 EST
(In reply to Young-Soo Roh from comment #30)
> (In reply to vincent lorenzo from comment #29)
> > This bug can now be marked as resolved fixed.
> 
> Vincent,, Is the latest change merged to 2.0 maintenance branch???

Hi Young-Soo,

All the gerrit were merged on streams/2.0-maintenance and master:
On master :
-	https://git.eclipse.org/r/#/c/85543/
-	https://git.eclipse.org/r/#/c/86375/
On streams/2.0-maintenance : 
-	https://git.eclipse.org/r/#/c/85863/
-	https://git.eclipse.org/r/#/c/86235/
Comment 32 Young-Soo Roh CLA 2016-12-15 09:19:15 EST
(In reply to Nicolas FAUVERGUE from comment #31)
> (In reply to Young-Soo Roh from comment #30)
> > (In reply to vincent lorenzo from comment #29)
> > > This bug can now be marked as resolved fixed.
> > 
> > Vincent,, Is the latest change merged to 2.0 maintenance branch???
> 
> Hi Young-Soo,
> 
> All the gerrit were merged on streams/2.0-maintenance and master:
> On master :
> -	https://git.eclipse.org/r/#/c/85543/
> -	https://git.eclipse.org/r/#/c/86375/
> On streams/2.0-maintenance : 
> -	https://git.eclipse.org/r/#/c/85863/
> -	https://git.eclipse.org/r/#/c/86235/

Verified working. Thanks.