KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > plugins > opentree > CMSTreeListener


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23  
24 package org.infoglue.cms.plugins.opentree;
25
26 import java.awt.event.MouseAdapter JavaDoc;
27 import java.awt.event.MouseEvent JavaDoc;
28
29 import javax.swing.JTree JavaDoc;
30 import javax.swing.event.TreeExpansionEvent JavaDoc;
31 import javax.swing.event.TreeWillExpandListener JavaDoc;
32 import javax.swing.tree.ExpandVetoException JavaDoc;
33 import javax.swing.tree.TreePath JavaDoc;
34
35
36 //import se.sprawl.cms.entities.content.ContentVO;
37

38 public class CMSTreeListener extends MouseAdapter JavaDoc implements TreeWillExpandListener JavaDoc
39 {
40     private JTree JavaDoc tree = null;
41     private Controller controller = null;
42     
43     public CMSTreeListener(JTree JavaDoc tree, Controller controller)
44     {
45         this.tree = tree;
46         this.controller = controller;
47     }
48     
49     public void mouseClicked(MouseEvent JavaDoc e)
50     {
51         int selRow = tree.getRowForLocation(e.getX(), e.getY());
52         TreePath JavaDoc selPath = tree.getPathForLocation(e.getX(), e.getY());
53         if(selRow != -1)
54         {
55             if(e.getClickCount() == 1)
56             {
57                 //System.out.println("There was no doubleclick so we don't do anything... for now..");
58
//Add later so that this triggers the call to the javascript
59
//mySingleClick(selRow, selPath);
60
}
61             /*
62             else if(e.getClickCount() == 2)
63             {
64                 System.out.println("There was a doubleclick - lets find his children if expanded");
65                 actOnDoubleClick(selRow, selPath);
66             }
67             */

68         }
69     }
70     
71     /*
72     private void actOnDoubleClick(int selRow, TreePath selPath)
73     {
74         CMSContent cmsContent = (CMSContent)selPath.getLastPathComponent();
75                     
76         contentController.addContentChildrenToParent(cmsContent);
77     }
78     */

79
80     public void treeWillExpand(TreeExpansionEvent JavaDoc e) throws ExpandVetoException JavaDoc
81     {
82         //System.out.println("The treeWillExpand fired:" + tree.getSize() + ":" + tree.getPreferredSize() + ":" + tree.getPreferredScrollableViewportSize());
83
/*
84         CMSContent cmsContent = (CMSContent)e.getPath().getLastPathComponent();
85         cmsContent.removeChildren();
86         contentController.addContentChildrenToParent(cmsContent);
87     */

88     }
89
90     public void treeWillCollapse(TreeExpansionEvent JavaDoc e)
91     {
92         //System.out.println("The treeWillCollapse fired..");
93
}
94  }
95
Popular Tags