Home » Eclipse Projects » NatTable » addColumnsIndexesToGroup
| |
Re: addColumnsIndexesToGroup [message #902230 is a reply to message #902225] |
Thu, 16 August 2012 12:55 |
Martin Jacob Messages: 191 Registered: July 2009 |
Senior Member |
|
|
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 15:43 |
Martin Jacob Messages: 191 Registered: July 2009 |
Senior Member |
|
|
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
|
|
| | |
Goto Forum:
Current Time: Thu Sep 19 05:19:17 GMT 2024
Powered by FUDForum. Page generated in 0.04265 seconds
|