1 7 package org.ejtools.jndi.browser.frame; 8 9 import java.awt.BorderLayout ; 10 import java.beans.PropertyChangeEvent ; 11 import java.util.ResourceBundle ; 12 13 import javax.swing.JMenuBar ; 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 36 public class ServerInternalFrame extends BeanContextInternalFrame implements ProfileHolder 37 { 38 39 protected JMSConnectionServiceProvider connectionProvider; 40 41 protected MenuBarServiceProvider menubarProvider; 42 43 protected Profile profile = null; 44 45 protected Server server = null; 46 47 protected ToolBarServiceProvider toolbarProvider; 48 49 private static Logger logger = Logger.getLogger(ServerInternalFrame.class); 50 51 private static ResourceBundle 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 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 ) 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 132 public void propertyChange(PropertyChangeEvent event) 133 { 134 if (event.getPropertyName().equals("name")) 135 { 136 String newName = (String ) 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 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 |