sivarajankumar / google-web-toolkit-incubator

Automatically exported from code.google.com/p/google-web-toolkit-incubator
0 stars 0 forks source link

FastTreeItem Selection problem #297

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What version of gwt and gwt-incubator are you using?

GWT 1.7 plus , I check out the trunk of Jul 26 2009

What OS and browser are you using?

Mac OS X 10.5.7

Do you see this error in hosted mode, web mode, or both?
 both

(If possible, please include a test case that shows the problem)

  I dont have a test case but any FastTree item code will do you can use
the FastTree Demo just make the addSelectionHandler call a Window.alert

Hopefully using the test case you have generously provided, what steps will
reproduce the problem? 

1.Create a FastTree and add SelectionHandler that calls a window.alert
2. Select one of the nodes of the tree, and the alert will show
3. Click again on the node and the alert will not show 

What is the expected output? What do you see instead?

 The alert should be displayed every time you click on the item

Workaround if you have one:

Change the 
onSelection(FastTreeItem item, boolean fireEvents,
                      boolean moveFocus, Element targetElem) 
of the FastTree from private to protected and then override the method to
something like this

@Override
protected void onSelection(FastTreeItem item, boolean fireEvents,
                      boolean moveFocus, Element targetElem){
 //this method is overridden to allow clicking on a already selected item 
    if (item  == getSelectedItem()){
        // add logic to fire your action here
        return;
    }
    super.onSelection(item, fireEvents, moveFocus,targetElem);
     }

Please provide any additional information below,  and thank you for taking
the time and effort to report this issue, as good issue reports are
critical for our quest to make GWT's new widgets and libraries shine.

From
http://groups.google.com/group/Google-Web-Toolkit-Contributors/browse_thread/thr
ead/6f8249c2d98d7788

Currently the FasTree when a addSelectionHandler is added is  only
executed when a FastTreeItem is selected, if the user clicks again in
a already selected item it will not be triggered again.

      In my app i use the tree to open tabs or dialogs , so sometimes
the user closes the tab or window and click again in the already
selected item so I need the action to be reexecuted.

    The logic that causes this behavior is the following method in the
FastTree

  private void onSelection(FastTreeItem item, boolean fireEvents,
      boolean moveFocus, Element targetElem) {
    // 'root' isn't a real item, so don't let it be selected
    // (some cases in the keyboard handler will try to do this)
    if (item == getTreeRoot()) {
      return;
    }

    // Don't fire events if the selection hasn't changed, but do move
the
    // focusable element to the new target.
    if (curSelection == item) {
      moveFocusable(curSelection, targetElem);
      return;
    }

What I use to do to overcome this was to override the method  to make
it execute the action even if the item was already selected, but in
the lastest version of the incubator this method is now private so I
can't override it my only option is to build my own jar of the
incubator with the method changed to protected.

So my request is, could you guys make the addSelectionHandler be
executed even if the item is already selected? I personaly think it
should be that way but I guess you guys had your reasons to make it
the way it is, in that case maybe add another method like a
addItemClickHandler that will behave this way? or maybe change the method
to be protected again so people can override the logic if they need

Cheers
Gabriel

Original issue reported on code.google.com by gabrield...@gmail.com on 5 Aug 2009 at 11:21