Export to GitHub

fest - issue #311

difficulties to click a jtree leaf


Posted on Feb 11, 2009 by Massive Panda

I want to doubleclick the leaf of a jtree in our application.

I tried myTreeFixture.selectPath(myPath).doubleclick() but the doubleclick method first moves the mouse pointer to the center of the jtree component and clicks into space.

I suggest that the doubleclick method should not move the mouse, respectively when a path in a jtree is selected, then the mouse should click the selected path.

Thanx.

Comment #1

Posted on Feb 11, 2009 by Quick Wombat

(No comment was entered for this change.)

Comment #2

Posted on Feb 11, 2009 by Swift Hippo

Hi guys,

JTreeFixture#doubleClick() is really an implementation of MouseInputSimulationFixture#doubleClick, which is meant to double-click the fixture's component. I believe it would be wrong to "break" the contract of the interface.

This also seems to me like a loss of original context in the fluent interface. See issue 115. The following code frame.tree().selectPath("path/to/node").doubleClick() simply doesn't read like "double-click the selected path," and frame.tree().doubleClick(), which by the way is also valid, even less so.

There's also the question of what would happen if there weren't any selection.

Instead, I would recommend clickPath(String path), doubleClickPath(String path) and similar methods, in the spirit of JPopupMenuFixture#showPopupMenuAt(String path).

Or even better, why not implement a fixture for a path? It could have methods like select, click, doubleClick, and showPopupMenu. See issue 170 and issue 185.

This would save us the trouble of bloated method names with the word "Path" at the end. It would also "read right" from a DSL point of view.

Just like the "statement" frame.tree().showPopupMenuAt("path/to/node").menuItemWithPath("...").click() sounds right, so would frame().tree().path("path/to/node").doubleClick().

To put it more precisely, in the first case it is clear that menuItemWithPath refers to the JMenuItemFixture created by showPopupMenuAt, and in the second case, that doubleClick refers to the path specified by path.

As a comment on issue 115, I don't think that it's necessarily a problem to introduce a new context in the same DSL statement, so long as the statement as a whole "reads right."

Thanks, Csabi

Comment #3

Posted on Feb 12, 2009 by Quick Wombat

Hi Csabi,

I agree. We don't want to break the current contract of the 'doubleClick' method. Fixing issue 185 and adding actions to a JTreePathFixture object is the best option.

I think it makes sense to merge this issue with issue 185.

Thanks, -Alex

Comment #4

Posted on Feb 12, 2009 by Quick Wombat

(No comment was entered for this change.)

Comment #5

Posted on Feb 12, 2009 by Swift Hippo

Hi Alex,

What do you think about a fixture for table cells? (See issue 170.)

Regards, Csabi

Status: Duplicate

Labels:
Module-fest-swing Type-Defect Priority-Critical Milestone-Release1.1 OpSys-All