Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » column header with multiple rows
column header with multiple rows [message #1008025] Fri, 08 February 2013 05:02 Go to next message
Martin Jacob is currently offline Martin Jacob
Messages: 116
Registered: July 2009
Senior Member
Hi,

I have to create a table with 3 rows in the column header. Plus having a ColumnGroupHeaderLayer and
ColumnGroupGroupHeaderLayer.

I imagine the ColumnHeaderLayer shall display 3 rows.

What I did so far:
I implement a ColHeaderDataProvider and getRowCount() return 3.
See the attached picture for the result.

Unfortunately it is still only one row in the column header but not 3.

How to implement the desired behavior?


Martin
Re: column header with multiple rows [message #1008050 is a reply to message #1008025] Fri, 08 February 2013 11:19 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1208
Registered: July 2012
Senior Member
Sorry, I don't understand. Do you need to have a ColumnHeader with 3 rows or do you need to have a ColumnHeaderLayer stacked up with ColumnGroupHeaderLayer and ColumnGroupGroupHeaderLayer?

For the last one there is the "Two level column groups example" that will show how this works.
Re: column header with multiple rows [message #1008069 is a reply to message #1008050] Fri, 08 February 2013 12:31 Go to previous messageGo to next message
Martin Jacob is currently offline Martin Jacob
Messages: 116
Registered: July 2009
Senior Member
The grouping is OK in row 0 and 1 of the column header.
Row 2 of the column header is also OK (Name, Type, 9,10,11,0,1,.....)
Furthermore I want a row 3 and 4 of the column header without grouping, just like in row 2 of the
column header.




schrieb Dirk Fauth, Am 08.02.2013 17:19:
> Sorry, I don't understand. Do you need to have a ColumnHeader with 3 rows or do you need to have a
> ColumnHeaderLayer stacked up with ColumnGroupHeaderLayer and ColumnGroupGroupHeaderLayer?
>
> For the last one there is the "Two level column groups example" that will show how this works.
Re: column header with multiple rows [message #1008161 is a reply to message #1008069] Mon, 11 February 2013 03:31 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1208
Registered: July 2012
Senior Member
Does your IDataProvider provide data for those 2 additional rows? In terms of height it seems to interpret the 3 rows correctly.
Re: column header with multiple rows [message #1008372 is a reply to message #1008161] Tue, 12 February 2013 03:13 Go to previous messageGo to next message
Martin Jacob is currently offline Martin Jacob
Messages: 116
Registered: July 2009
Senior Member
Thanks Dirk,

Yes the data provider provides data for all 3 rows but only row 0 get called. May be there is an
error in ColumnHeaderLayerStack?

here the code:

public ColumnHeaderLayerStack(IDataProvider dataProvider, BodyLayerStack pBodyLayer) {
DataLayer dataLayer = new DataLayer(dataProvider);
colHeaderLayer = new ColumnHeaderLayer(dataLayer, pBodyLayer, pBodyLayer.getSelectionLayer());

ColumnGroupModel columnGroupModelTrack = new ColumnGroupModel();
columnGroupHeaderLayerTrack = new ColumnGroupHeaderLayer(colHeaderLayer,
pBodyLayer.getSelectionLayer(), columnGroupModelTrack);
columnGroupHeaderLayerTrack.addColumnsIndexesToGroup("Track", 0, 1);

ColumnGroupModel columnGroupModelLine = new ColumnGroupModel();
columnGroupHeaderLayerLine = new ColumnGroupGroupHeaderLayer(columnGroupHeaderLayerTrack,
pBodyLayer.getSelectionLayer(),
columnGroupModelLine);
columnGroupHeaderLayerLine.addColumnsIndexesToGroup("Line", 0, 1);
}

Does this give you any hints of an error?

Martin

schrieb Dirk Fauth, Am 12.02.2013 06:10:
> Does your IDataProvider provide data for those 2 additional rows? In terms of height it seems to
> interpret the 3 rows correctly.
Re: column header with multiple rows [message #1008373 is a reply to message #1008372] Tue, 12 February 2013 03:29 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1208
Registered: July 2012
Senior Member
Looks reasonable, I think the code for the IDataProvider you implemented should provide more information on that.
Re: column header with multiple rows [message #1008378 is a reply to message #1008373] Tue, 12 February 2013 03:46 Go to previous messageGo to next message
Martin Jacob is currently offline Martin Jacob
Messages: 116
Registered: July 2009
Senior Member
public class ColHeaderDataProvider implements IDataProvider {// extends BodyDataProvider {

private LinkedHashMap<Integer, Object> colIndexToObject = new LinkedHashMap<Integer, Object>();

@Override
public Object getDataValue(int arg0, int arg1) {
Object lRet = colIndexToObject.get(arg0);
if (null == lRet) {
int lColIdx = arg0;
Vector<Network> lNwV = getProject().getJniProject().getNetworks();
if (0 == lColIdx) {
colIndexToObject.put(arg0, "Name");
return colIndexToObject.get(arg0);
} else {
lColIdx--;
}
if (0 == lColIdx) {
colIndexToObject.put(arg0, "Type");
return colIndexToObject.get(arg0);
} else {
lColIdx--;
}
for (Network lNw : lNwV) {
Vector<Line> lLineV = lNw.getLines();
for (Line lLine : lLineV) {
Vector<Track> lTrackV = lLine.getTracks();
for (Track lTrack : lTrackV) {
Vector<Connector> lConnV = lTrack.getLineConnectorsFrom();
for (Connector lConn : lConnV) {
if (0 == lColIdx) {
colIndexToObject.put(arg0, lConn);
return colIndexToObject.get(arg0);
} else {
lColIdx--;
}
}
}
}
}
}
// System.out.println(this.getClass().toString() + ": getDataValue( " + arg0 + ", " + arg1 + " ) =
" + lRet);
return lRet;
}

@Override
public int getRowCount() {
// System.out.println(this.getClass().toString() + ": getRowCount = " + 2);
return 3;
}

@Override
public void setDataValue(int arg0, int arg1, Object arg2) {
}

@Override
public int getColumnCount() {
int lRet = 2;// Name & Type column
if (getProject().isSetJniProject()) {
Vector<Network> lNetworkV = getProject().getJniProject().getNetworks();
for (Network lNetwork : lNetworkV) {
lRet += lNetwork.countLineConnectors();
}
}
// System.out.println(this.getClass().toString() + ": getColumnCount = " + mColumnCount);
return lRet;
}

}



schrieb Dirk Fauth, Am 12.02.2013 09:29:
> Looks reasonable, I think the code for the IDataProvider you implemented should provide more
> information on that.
Re: column header with multiple rows [message #1008384 is a reply to message #1008378] Tue, 12 February 2013 04:10 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1208
Registered: July 2012
Senior Member
Seems to be a bug in the ColumnGroupHeaderLayer and ColumnGroupGroupHeaderLayer. The spanning of cells seems to be calculated wrong. Please open a bug for this.
Re: column header with multiple rows [message #1008398 is a reply to message #1008384] Tue, 12 February 2013 05:24 Go to previous message
Martin Jacob is currently offline Martin Jacob
Messages: 116
Registered: July 2009
Senior Member
added: https://bugs.eclipse.org/bugs/show_bug.cgi?id=400548

schrieb Dirk Fauth, Am 12.02.2013 10:10:
> Seems to be a bug in the ColumnGroupHeaderLayer and ColumnGroupGroupHeaderLayer. The spanning of
> cells seems to be calculated wrong. Please open a bug for this.
Previous Topic:CellEditor on DoubleCLick?
Next Topic:Lazy Loading / Paging
Goto Forum:
  


Current Time: Wed Jul 23 12:08:44 EDT 2014

Powered by FUDForum. Page generated in 0.02432 seconds