KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > jndi > browser > frame > ServerInternalFrame


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package org.ejtools.jndi.browser.frame;
8
9 import java.awt.BorderLayout JavaDoc;
10 import java.beans.PropertyChangeEvent JavaDoc;
11 import java.util.ResourceBundle JavaDoc;
12
13 import javax.swing.JMenuBar JavaDoc;
14
15 import org.apache.log4j.Logger;
16 import org.ejtools.adwt.BeanContextTreePanel;
17 import org.ejtools.adwt.action.Command;
18 import org.ejtools.adwt.action.action.RefreshAction;
19 import org.ejtools.adwt.service.BeanContextInternalFrame;
20 import org.ejtools.adwt.service.MenuBarServiceProvider;
21 import org.ejtools.adwt.service.ToolBarServiceProvider;
22 import org.ejtools.jndi.browser.action.SelectFactoryAction;
23 import org.ejtools.jndi.browser.model.Server;
24 import org.ejtools.jndi.browser.model.service.JMSConnectionService;
25 import org.ejtools.jndi.browser.model.service.JMSConnectionServiceProvider;
26 import org.ejtools.util.service.Profile;
27 import org.ejtools.util.service.ProfileHolder;
28
29 /**
30  * Description of the Class
31  *
32  * @author <a HREF="mailto:letiemble@users.sourceforge.net">Laurent Etiemble</a>
33  * @version $Revision: 1.2 $
34  * @created 5 septembre 2002
35  */

36 public class ServerInternalFrame extends BeanContextInternalFrame implements ProfileHolder
37 {
38    /** Description of the Field */
39    protected JMSConnectionServiceProvider connectionProvider;
40    /** Description of the Field */
41    protected MenuBarServiceProvider menubarProvider;
42    /** Description of the Field */
43    protected Profile profile = null;
44    /** Description of the Field */
45    protected Server server = null;
46    /** Description of the Field */
47    protected ToolBarServiceProvider toolbarProvider;
48    /** Description of the Field */
49    private static Logger logger = Logger.getLogger(ServerInternalFrame.class);
50    /** Bundle for I18N */
51    private static ResourceBundle JavaDoc resources = ResourceBundle.getBundle("org.ejtools.jndi.browser.Resources");
52
53    public void setProfile(Profile profile)
54    {
55       this.profile = profile;
56    }
57
58    public Profile getProfile()
59    {
60       return this.profile;
61    }
62
63    /**
64     * Constructor for ServerInternalFrame.
65     *
66     * @param profile Description of the Parameter
67     */

68    public ServerInternalFrame()
69    {
70       super();
71    }
72    
73     public void setServer(Server server)
74     {
75       this.connectionProvider = new JMSConnectionServiceProvider();
76       this.menubarProvider = new MenuBarServiceProvider();
77       this.toolbarProvider = new ToolBarServiceProvider();
78
79       this.server = server;
80       this.server.setProfile(profile);
81
82       this.add(this.connectionProvider);
83       this.add(this.menubarProvider);
84       this.add(this.toolbarProvider);
85
86       this.add(this.server);
87       this.server.addPropertyChangeListener("name", this);
88
89       this.add(new RefreshAction(
90          new Command()
91          {
92             /** */
93             public void execute()
94             {
95                ServerInternalFrame.this.server.refresh();
96             }
97          }));
98
99       this.add(new SelectFactoryAction("action.options.selectQueueFactory",
100          new Command()
101          {
102             public void execute()
103             {
104                ServerInternalFrame.this.connectionProvider.selectFactory(JMSConnectionService.QUEUE_CONNECTION_FACTORY);
105             }
106          }
107          ));
108
109       this.add(new SelectFactoryAction("action.options.selectTopicFactory",
110          new Command()
111          {
112             public void execute()
113             {
114                ServerInternalFrame.this.connectionProvider.selectFactory(JMSConnectionService.TOPIC_CONNECTION_FACTORY);
115             }
116          }
117          ));
118
119       BeanContextTreePanel panel = new BeanContextTreePanel(this.server);
120       panel.selectRoot();
121
122       this.frame.setJMenuBar((JMenuBar JavaDoc) this.menubarProvider.getContainer());
123       this.frame.getContentPane().add(BorderLayout.NORTH, this.toolbarProvider.getContainer());
124       this.frame.getContentPane().add(BorderLayout.CENTER, panel);
125    }
126
127
128
129    /**
130     * @param event Description of the Parameter
131     */

132    public void propertyChange(PropertyChangeEvent JavaDoc event)
133    {
134       if (event.getPropertyName().equals("name"))
135       {
136          String JavaDoc newName = (String JavaDoc) event.getNewValue();
137          this.setTitle(resources.getString("connection.text.prefix") + " : " + newName);
138       }
139    }
140
141
142    /** */
143    protected void initializeBeanContextResources()
144    {
145       super.initializeBeanContextResources();
146
147       // Hack to update the window title
148
this.server.setName("");
149         this.server.setName(resources.getString("connection.text.untitled"));
150    }
151
152
153    /** */
154    protected void releaseBeanContextResources()
155    {
156       logger.debug("In releaseBeanContextResources...");
157
158       this.server.clear();
159
160       super.releaseBeanContextResources();
161    }
162 }
163
Popular Tags