Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Inconsistent API
icon5.gif  Inconsistent API [message #1723841] Thu, 18 February 2016 12:07 Go to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
Hello,

i noticed some inconsistence in the api.
(probably there is a good reason for this?)

ColumnHideCommand available!
ColumnShowCommand missing!

MultiColumnHideCommand available! [1]
MultiColumnShowCommand available! [2]

[1] MultiColumnHideCommand(ILayer layer, int[] columnPositions)
[2] MultiColumnShowCommand(Collection<Integer> columnIndexes)

i expected those constructors to be similar.
either both with layer as param or both without.
further once a int[] and the other an Collection<Integer>
thats not enough Wink
one uses Indizes, the other uses Positions

the same behaviour/Style is in ColumnHideShowLayer

i'd prefer the useage of indizes, as those are absolute and do not change...

[Updated on: Thu, 18 February 2016 12:08]

Report message to a moderator

Re: Inconsistent API [message #1723852 is a reply to message #1723841] Thu, 18 February 2016 13:40 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
I don't see a question here. Only blaming the API that exists for years.

I suppose there is no ColumnShowCommand because it was not needed until now.
Furthermore I suppose until now nobody requested the feature to programmatically hide/show columns. And using UI interactions it is not possible to perform show columns, because of position-index-transformation the position would not resolve.

And for sure you prefer the usage of indizes because it is easier to understand. But regarding UI interactions it doesn't match because of the transformation principles.

Looking at the implementation it should be easy to add those features. So feel free to contribute.

And instead of simply blaming something, ask a question or file a request. I don't like forum posts that simply point out that something might be wrong without adding a value.
Re: Inconsistent API [message #1723940 is a reply to message #1723852] Fri, 19 February 2016 07:43 Go to previous message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
first of all the post above was not intended to blame anyone (especially not you as you do serve really fast and accurate solutions/great work - sorry). to me the nattable code is not the simplest to understand, but its high performant and extremely configureable (and this is the most important parts)
my question was if there are reasons for this 'style' (which you answered with the UI)
As NatTable uses Commands it seemed obious to me that if a Show Command is available, also an equivalent Hide Command is available too.
i do prefer the indizes for one reason (and it is not easier understanding) its because an Command can be called twice and the state does not change. If i execute a Command referring to a Position, and this one gets called twice, then two Columns get affected (for hide).

ad contribution:
i had a look on the Commands, and those seem to go quite deep into nattable abstract code (hide is always done via positions? - makes sense if all hide stuff comes from UI)

i ended up in just adding one little method in the ColumnHideShowLayer (in my case i simply extended this class)
It is working fine in my usecase, iff you do think this is correct in all cases (not sure if this can cause problems due HideColumnPositionsEvents) feel free to add it to the default ColumnHideShowLayer

public class CustomColumnHideShowLayer extends ColumnHideShowLayer {

	public CustomColumnHideShowLayer(IUniqueIndexLayer underlyingLayer) {
		super(underlyingLayer);
	}

	public void hideColumnIndexes(Collection<Integer> columnIndexes) {
		Set<Integer> columnPositions = new HashSet<Integer>();
        for (Integer columnIndex : columnIndexes) {
        	columnPositions
                    .add(Integer
                            .valueOf(getColumnPositionByIndex(columnIndex
                                    .intValue())));
        }
        getHiddenColumnIndexes().addAll(columnIndexes);
        invalidateCache();
        fireLayerEvent(new HideColumnPositionsEvent(this, columnPositions));
    }
}

[Updated on: Fri, 19 February 2016 07:45]

Report message to a moderator

Previous Topic:Default sorting when no explicit sort is applied
Next Topic:header disappears on ubuntu when scrolling
Goto Forum:
  


Current Time: Wed Apr 24 22:36:26 GMT 2024

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

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

Back to the top