Hi

I think we had the same problem, and solved it with subclassing the
ULCTableTree and on client side the UITableTree.
At the client side, we fireActionPerformedULC when the leftMouseButton is
released.

The client class look like this:

public class UISingleClickTableTree extends UITableTree {

      @Override
      protected void postInitializeState() {

            super.postInitializeState();

            JTableTree tableTree = getBasicTableTree();
            tableTree.addMouseListener(new SingleClickHandler());
      }

      private class SingleClickHandler extends MouseAdapter {

            public void mouseReleased(MouseEvent event) {

                  super.mouseReleased(event);

                  if (event.getClickCount() == 1 &&
SwingUtilities.isLeftMouseButton(event)) {
                        singleClick(event);
                  }
            }
      }

      private void singleClick(MouseEvent event) {

            if (!isLocationInExpandControl(event.getX())) {
                  fireActionPerformedULC(null, event.getModifiers());
            }
      }

      /**
       * Checks, if mouseX is in the expandControllAreal (with +- icons).
In this case, do nothing, because swing already expanded or collapsed.
       *
       */
      private boolean isLocationInExpandControl(int mouseX) {

            BasicTableTree tree = getBasicTableTree();
            TreePath path = tree.getSelectedPath();

            if (path == null) {
                  return false;
            }
            if (tree.getModel().isLeaf(path.getLastPathComponent())) {
                  return false;
            }

            BasicTreeUI ui = (BasicTreeUI) tree.getBasicTree().getUI();

            int boxWidth = 8;
            if (ui.getExpandedIcon() != null) {
                  boxWidth = ui.getExpandedIcon().getIconWidth();
            }

            int totalIndent = ui.getLeftChildIndent() +
ui.getRightChildIndent();
            int boxLeftX = (totalIndent * (path.getPathCount() - 1)) -
ui.getRightChildIndent() - boxWidth / 2;

            boxLeftX = boxLeftX + tree.getInsets().left;
            int boxRightX = boxLeftX + boxWidth;

            return mouseX >= boxLeftX && mouseX <= boxRightX;
      }

}



Hope to help
Stefan


--
mailto:[email protected]  /  http://www.dvbern.ch
Nussbaumstrasse 21, Postfach 106, CH-3000 Bern 22
Telefon:  ++41 +31 378 24 24 / Telefax:  ++41 +31 378 24 74


|------------>
| Von:       |
|------------>
  
>-----------------------------------------------------------------------------------------------------------------------------------------|
  |"Sambare Pavan (KCAB 116)" <[email protected]>                 
                                                            |
  
>-----------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| An:        |
|------------>
  
>-----------------------------------------------------------------------------------------------------------------------------------------|
  |<[email protected]>, "Christian Ribeaud" 
<[email protected]>                                                   
    |
  
>-----------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Datum:     |
|------------>
  
>-----------------------------------------------------------------------------------------------------------------------------------------|
  |14.08.2009 14:46                                                             
                                                            |
  
>-----------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Betreff:   |
|------------>
  
>-----------------------------------------------------------------------------------------------------------------------------------------|
  |RE: [ULC-developer] Events for ULCTree                                       
                                                            |
  
>-----------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Gesendet   |
| von:       |
|------------>
  
>-----------------------------------------------------------------------------------------------------------------------------------------|
  |[email protected]                                          
                                                            |
  
>-----------------------------------------------------------------------------------------------------------------------------------------|





Hi Christian,

In the tree, on a left click we want to open a page and on the right
click, we have the context menu. However, since a single click (either
left or right) triggers the selection event, the page opens even on a
right click. We want to avoid this.

Thanks & Regards,
Pavan

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Christian
Ribeaud
Sent: Friday, August 14, 2009 2:41 PM
To: [email protected]
Subject: Re: [ULC-developer] Events for ULCTree

Hi Pavan,

in ULC one click triggers the selection and two clicks an action
event. The selection is the consequence of a mouse click
but should not have any connection to it. This is the same in Swing.
Usually the right click is reserved for activating the context menu.
What do you want to achieve with a right click on the tree? Best,

christian
--
Canoo - Your Solution Provider for Rich Internet Applications

     Christian Ribeaud
     Canoo Engineering AG
     Kirschgartenstrasse 5
     CH-4051 Basel

     Tel: +41 61 228 94 44
     Fax: +41 61 228 94 49

     [email protected]
     http://www.canoo.com/

On Aug 12, 2009, at 4:31 PM, Sambare Pavan (KCAB 116) wrote:

> Hi,
>
> How is it possible to differentiate between Right click and Left
> click mouse events on a ULCTree component? The TreeSelectionListener
> has the same event type for both clicks.
>
> Thanks & Regards,
> Pavan Sambare
> Office :  +41 (0)44 33 42178
> Mobile: +41 (0)76 75 33363
>

_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer
_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer


_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to