KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > suberic > pooka > gui > MailTreeNode


1 package net.suberic.pooka.gui;
2 import javax.swing.tree.*;
3 import javax.swing.*;
4 import java.util.Hashtable JavaDoc;
5 import java.awt.event.*;
6 import net.suberic.util.gui.ConfigurablePopupMenu;
7 import net.suberic.pooka.Pooka;
8
9
10 public class MailTreeNode extends DefaultMutableTreeNode {
11
12   public Action[] defaultActions = null;
13
14   public Hashtable JavaDoc commands;
15
16   public JComponent parentContainer;
17
18   // this is only used for the FolderChooser
19
private boolean subscribed = false;
20
21   public ConfigurablePopupMenu popupMenu;
22
23   MailTreeNode(Object JavaDoc userObj, JComponent parent) {
24     super(userObj);
25
26     parentContainer = parent;
27
28   }
29
30   /**
31    * This shows the PopupMenu for this component. If no PopupMenu has
32    * been created yet, then one is created and shown.
33    */

34   public void showPopupMenu(JComponent component, MouseEvent e) {
35     configurePopupMenu();
36
37     if (popupMenu != null)
38       popupMenu.show(component, e.getX(), e.getY());
39
40   }
41
42   /**
43    * This updates the popupMenu's Theme, if necessary.
44    */

45   public void updatePopupTheme() {
46     if (popupMenu != null) {
47       SwingUtilities.invokeLater( new Runnable JavaDoc() {
48           public void run() {
49             try {
50               FolderPanel fp = ((FolderPanel)getParentContainer());
51               Pooka.getUIFactory().getPookaThemeManager().updateUI(fp, popupMenu, true);
52             } catch (Exception JavaDoc e) {
53
54             }
55           }
56         });
57     }
58   }
59
60   /**
61    * This creates the current PopupMenu if there is not one. It then
62    * will configure the PopupMenu with the current actions.
63    *
64    * This implementation simply returns; subclasses should override this
65    * method to create a custom PopupMenu.
66    */

67   public void configurePopupMenu() {
68
69   }
70
71   protected void setCommands() {
72     commands = new Hashtable JavaDoc();
73
74     Action[] actions = getActions();
75     if (actions != null) {
76       for (int i = 0; i < actions.length; i++) {
77         Action a = actions[i];
78         commands.put(a.getValue(Action.NAME), a);
79       }
80     }
81
82   }
83
84
85   public Action[] getActions() {
86     return getDefaultActions();
87   }
88
89   public Action getAction(String JavaDoc name) {
90     if (commands != null)
91       return (Action)commands.get(name);
92     else
93       return null;
94   }
95
96   public Action[] getDefaultActions() {
97     return defaultActions;
98   }
99
100   public JComponent getParentContainer() {
101     return parentContainer;
102   }
103
104   public boolean isSubscribed() {
105     return subscribed;
106   }
107
108   public void setSubscribed(boolean newValue) {
109     subscribed=newValue;
110   }
111 }
112
113
Popular Tags