Home » Eclipse Projects » NatTable » addColumnsIndexesToGroup
addColumnsIndexesToGroup [message #902214] |
Thu, 16 August 2012 07:54  |
Eclipse User |
|
|
|
Hi,
I found when I add a column indexes to group the name of the column group name must be unique. In my
case the group name displayed in the table has the same name more then once.
How can I resolve this?
The wanted table layout
+-----------------------+
| A | B | C |
+-----------------------+
| a | b | a | b | a | b |
+-----------------------+
| | | | | | |
+-----------------------+
| | | | | | |
+-----------------------+
| | | | | | |
+-----------------------+
Martin
|
|
| |
Re: addColumnsIndexesToGroup [message #902230 is a reply to message #902225] |
Thu, 16 August 2012 08:55   |
Eclipse User |
|
|
|
Yes you are right. I missed one group level to simplify the example. Actually I need 4 header rows
using groups. The final design is.
One problem I found is to give unique names to the column group and the other is the number of group
layers. There is the class ColumnGroupGroupHeaderLayer which need a ColumnGroupHeaderLayer as
constructor argument but cant handle ColumnGroupGroupHeaderLayer as argument to construct multi
level groups.
+-----------------------------------------------+
| AAA | BBB |
+-----------------------------------------------+
| AA | BB | AA |
+-----------------------------------------------+
| A | B | C | C | C | C |
+-----------------------------------------------+
| a | b | a | b | a | b | a | b | a | b | a | b |
+-----------------------------------------------+
| | | | | | | | | | | | |
+-----------------------------------------------+
| | | | | | | | | | | | |
+-----------------------------------------------+
| | | | | | | | | | | | |
+-----------------------------------------------+
What I did so fare:
IDataProvider dataProvider = new BodyDataProvider();
IDataProvider colHeaderDataProvider = new ColHeaderDataProvider();
IDataProvider rowHeaderDataProvider = new RowHeaderDataProvider();
BodyLayerStack bodyLayer = new BodyLayerStack(dataProvider);
ColumnHeaderLayerStack columnHeaderLayer = new ColumnHeaderLayerStack(colHeaderDataProvider, bodyLayer);
RowHeaderLayerStack rowHeaderLayer = new RowHeaderLayerStack(rowHeaderDataProvider, bodyLayer);
DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(colHeaderDataProvider,
rowHeaderDataProvider);
CornerLayer cornerLayer = new CornerLayer(new DataLayer(cornerDataProvider), rowHeaderLayer,
columnGroupHeaderLayerNetwork);
GridLayer gridLayer = new GridLayer(bodyLayer, columnGroupHeaderLayerNetwork, rowHeaderLayer,
cornerLayer);
natTable = new NatTable(parent, gridLayer);
public class ColumnHeaderLayerStack extends AbstractLayerTransform {
public ColumnHeaderLayerStack(IDataProvider dataProvider, BodyLayerStack pBodyLayer) {
DataLayer dataLayer = new DataLayer(dataProvider);
ColumnHeaderLayer colHeaderLayer = new ColumnHeaderLayer(dataLayer, pBodyLayer,
pBodyLayer.getSelectionLayer());
ColumnGroupModel columnGroupModelTrack = new ColumnGroupModel();
columnGroupHeaderLayerTrack = new ColumnGroupHeaderLayer(colHeaderLayer,
pBodyLayer.getSelectionLayer(), columnGroupModelTrack);
columnGroupHeaderLayerTrack.addColumnsIndexesToGroup("", 0, 1);
ColumnGroupModel columnGroupModelLine = new ColumnGroupModel();
ColumnGroupHeaderLayer columnGroupHeaderLayerLine = new
ColumnGroupHeaderLayer(columnGroupHeaderLayerTrack, pBodyLayer.getSelectionLayer(),
columnGroupModelLine);
columnGroupHeaderLayerLine.addColumnsIndexesToGroup("", 0, 1);
ColumnGroupModel columnGroupModelNetwork = new ColumnGroupModel();
columnGroupHeaderLayerNetwork = new ColumnGroupGroupHeaderLayer(columnGroupHeaderLayerLine,
pBodyLayer.getSelectionLayer(), columnGroupModelNetwork);
columnGroupHeaderLayerNetwork.addColumnsIndexesToGroup("", 0, 1);
....
addColumnsIndexesToGroup to all 3 group level
....
setUnderlyingLayer(colHeaderLayer);
}
}
Dirk Fauth wrote, On 16.08.2012 14:32:
> Hi,
>
> looking at your table layout, what you want to do is create column groups with the name A, B and C
> that contain columns with that have same names. This is working fine with NatTable. So I don't
> understand what is not working for you?
>
> Greez,
> Dirk
|
|
| | | | | |
Re: addColumnsIndexesToGroup [message #902646 is a reply to message #902645] |
Thu, 16 August 2012 11:43   |
Eclipse User |
|
|
|
The DisplayConverter works now, see the picture and coresponding code below:
natTable = new NatTable(sashForm_1, gridLayer, false);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.getConfigRegistry().registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER,
new DisplayConverter() {
@Override
public Object canonicalToDisplayValue(Object canonicalValue) {
if (canonicalValue instanceof String) {
String[] lStrings = ((String) canonicalValue).split("/");
if (lStrings.length > 2) {
return lStrings[lStrings.length - 1];
}
}
return canonicalValue;
}
@Override
public Object displayToCanonicalValue(Object displayValue) {
return displayValue;
}
}, DisplayMode.NORMAL, GridRegion.COLUMN_GROUP_HEADER);
natTable.configure();
Martin
Martin Jacob wrote, On 16.08.2012 16:19:
> OK got it how to satisfy the linker:
> natTable = new NatTable(sashForm_1, gridLayer);
> natTable.getConfigRegistry().registerConfigAttribute(new ConfigAttribute<DisplayConverter>(),
> new DisplayConverter() {
> @Override
> public Object canonicalToDisplayValue(Object canonicalValue) {
> return "canonicalValue";
> }
> @Override
> public Object displayToCanonicalValue(Object displayValue) {
> return "displayValue";
> }
> }, GridRegion.COLUMN_GROUP_HEADER);
>
>
> but the above specified DisplayConverter get never called. What to do to get it work?
>
> Martin
>
> Martin Jacob wrote, On 16.08.2012 16:06:
>> I try the DisplayConverter but not sure how to register. I try:
>> natTable.getConfigRegistry().registerConfigAttribute(GridRegion.COLUMN_GROUP_HEADER, new
>> DisplayConverter(){
>> @Override
>> public Object canonicalToDisplayValue(Object canonicalValue) {
>> return "canonicalValue";
>> }
>> @Override
>> public Object displayToCanonicalValue(Object displayValue) {
>> return "displayValue";
>> }});
>>
>> but this does not compile.
>>
>> Where and how should I register my own display converter?
>>
>> Martin
>>
>> Dirk Fauth wrote, On 16.08.2012 15:37:
>>> Something like that. You can configure your own CellPainter for the column groups. You have to set
>>> another configuration to your instance of ColumnGroupHeaderLayer. The default is
>>> DefaultColumnGroupHeaderLayerConfiguration where the ColumnGroupHeaderTextPainter is configured as
>>> cell painter. You can either create your own configuration and set this instead of the default, or
>>> override the cell painter configuration for the ColumnGroupHeaderLayer by registering your own
>>> painter. In your own painter you can then interprete your unique key to the value you want to show.
>>>
>>> Writing this there might be another more easy solution. You can write a DisplayConverter which you
>>> have to attach to the GridRegion.COLUMN_GROUP_HEADER. And your DisplayConverter is than responsible
>>> for converting your keys to the display values you want to show.
>>>
>>> Hope this helps.
>>>
>>> Greez,
>>> Dirk
|
|
| |
Re: addColumnsIndexesToGroup [message #902731 is a reply to message #902650] |
Mon, 20 August 2012 03:44  |
Eclipse User |
|
|
|
Hi,
I will have a look at this after my vacation. For the moment just a hint on configurations. Every layer has its own configuration. Therefore it's more NatTable Style to override the ColumnGroupHeaderLayer configuration (think it is the DefaultColumnGroupHeaderConfiguration) instead of registering directly on the NatTable. But this is just a hint, your way also works.
Greez,
Dirk
|
|
|
Goto Forum:
Current Time: Wed Jul 09 09:11:19 EDT 2025
Powered by FUDForum. Page generated in 0.14498 seconds
|