params = new Hashtable<String, Object>();
}
params.put("child", new ParameterHolder(pChild));
// TF:27/9/07:Revamped this logic as our renderers are now in panels.
ArrayField owningArray = ArrayFieldCellHelper.getArrayField(pChild);
int row = 0;
int column = 0;
// Extract the X and Y co-ordinate from the event which may be in array coordinates
ParameterHolder pX = (ParameterHolder)params.get("x");
ParameterHolder pY = (ParameterHolder)params.get("y");
/*
* There are 2 cases when considering children events of array fields:
* 1) The component cell renderer/editor is attached to the array field as a child. This is typically when the
* editor is active. In this case the click we get is in the coordinate space of the child, but the row
* and column are not set properly. We can map the coordinate space of the child to the coordinate space
* of the array and then determine the row and column from there.
*
* 2) The component cell renderer/editor is not attached to the array field. In this case, the component will
* have a client property set which refers to the array and the location is in the coordinate space of the
* array. We can use this to determine the row and column and then map the coordinate down to the
* coordinate space of the child.
*/
while (mum != null){
if (mum == owningArray) {
if (pX != null && pY != null) {
// We are a direct child of the table, remap the coordinate space to the array to get the row and column
Point p = new Point(UIutils.milsToPixels(pX.getInt()), UIutils.milsToPixels(pY.getInt()));
Point arrayPoint = SwingUtilities.convertPoint(pChild, p, mum);
row = owningArray.rowAtPoint(arrayPoint);
column = owningArray.columnAtPoint(arrayPoint);
// Store the real row and column in the array. This isn't actually done in Forte, but makes life
// much easier if we want to determine which cell generated the click.
params.put( "row", new ParameterHolder(row+1) );
params.put( "column", new ParameterHolder(column+1) );
}
owningArray = null;
}
pList.add(new EventHandle(mum, pEventName, params));
// TF:18/06/2008:Fixed this so menus work properly
if (mum instanceof JPopupMenu)
mum = (Container)((JPopupMenu)mum).getInvoker();
else
mum = mum.getParent();
}
if (owningArray != null) {
// Now the X and Y coordinates are in the array space, we need to translate them to the child coordinate space and get
// the correct row and column
if (pX != null && pY != null) {
Point p = new Point(UIutils.milsToPixels(pX.getInt()), UIutils.milsToPixels(pY.getInt()));
row = owningArray.rowAtPoint(p);
column = owningArray.columnAtPoint(p);
// Store the real row and column in the array. This isn't actually done in Forte, but makes life
// much easier if we want to determine which cell generated the click.
params.put( "row", new ParameterHolder(row+1) );
params.put( "column", new ParameterHolder(column+1) );
Rectangle r = owningArray.getCellRect(row, column, false);
p.x -= r.x;
p.y -= r.y;
// Now X and Y are in owningArray coordinate space, need to translate them into pChild's
// Point childLoc = SwingUtilities.convertPoint(owningArray, p, pChild);
Point childLoc = p;