|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| FrameServiceProvider.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 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.adwt.service;
|
|
| 8 |
|
|
| 9 |
import java.awt.BorderLayout;
|
|
| 10 |
import java.awt.Container;
|
|
| 11 |
import java.awt.event.WindowListener;
|
|
| 12 |
import java.beans.beancontext.BeanContextServices;
|
|
| 13 |
import java.util.Iterator;
|
|
| 14 |
import java.util.Vector;
|
|
| 15 |
|
|
| 16 |
import javax.swing.ImageIcon;
|
|
| 17 |
import javax.swing.JFrame;
|
|
| 18 |
import javax.swing.JMenuBar;
|
|
| 19 |
import javax.swing.JScrollPane;
|
|
| 20 |
|
|
| 21 |
import org.apache.log4j.Logger;
|
|
| 22 |
import org.ejtools.beans.beancontext.CustomBeanContextServiceProvider;
|
|
| 23 |
|
|
| 24 |
/**
|
|
| 25 |
* Description of the Class
|
|
| 26 |
*
|
|
| 27 |
* @author Laurent Etiemble
|
|
| 28 |
* @version $Revision: 1.5 $
|
|
| 29 |
* @todo Javadoc to complete
|
|
| 30 |
*/
|
|
| 31 |
public abstract class FrameServiceProvider extends CustomBeanContextServiceProvider implements FrameService |
|
| 32 |
{
|
|
| 33 |
/** Description of the Field */
|
|
| 34 |
protected JFrame frame = new JFrame(); |
|
| 35 |
/** Description of the Field */
|
|
| 36 |
protected JScrollPane scrollPane = new JScrollPane(); |
|
| 37 |
/** Description of the Field */
|
|
| 38 |
protected FrameService service = null; |
|
| 39 |
/** Description of the Field */
|
|
| 40 |
private static Logger logger = Logger.getLogger(FrameServiceProvider.class); |
|
| 41 |
|
|
| 42 |
|
|
| 43 |
/**Constructor for the FrameServiceProvider object */
|
|
| 44 | 0 |
protected FrameServiceProvider()
|
| 45 |
{
|
|
| 46 | 0 |
this.service = this; |
| 47 |
} |
|
| 48 |
|
|
| 49 |
|
|
| 50 |
/**
|
|
| 51 |
* Adds a feature to the WindowListener attribute of the FrameServiceProvider object
|
|
| 52 |
*
|
|
| 53 |
* @param l The feature to be added to the WindowListener attribute
|
|
| 54 |
*/
|
|
| 55 | 0 |
public void addWindowListener(WindowListener l) |
| 56 |
{
|
|
| 57 | 0 |
this.frame.addWindowListener(l);
|
| 58 |
} |
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
/**
|
|
| 63 |
* Gets the container attribute of the FrameServiceProvider object
|
|
| 64 |
*
|
|
| 65 |
* @return The container value
|
|
| 66 |
*/
|
|
| 67 | 0 |
public Container getContainer()
|
| 68 |
{
|
|
| 69 | 0 |
return this.frame; |
| 70 |
} |
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
/**
|
|
| 75 |
* Gets the currentServiceSelectors attribute of the ApplicationServiceProvider object
|
|
| 76 |
*
|
|
| 77 |
* @param bcs Description of Parameter
|
|
| 78 |
* @param serviceClass Description of Parameter
|
|
| 79 |
* @return The currentServiceSelectors value
|
|
| 80 |
*/
|
|
| 81 | 0 |
public Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass)
|
| 82 |
{
|
|
| 83 | 0 |
return (new Vector().iterator()); |
| 84 |
} |
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
/**
|
|
| 89 |
* Gets the service attribute of the ApplicationServiceProvider object
|
|
| 90 |
*
|
|
| 91 |
* @param bcs Description of Parameter
|
|
| 92 |
* @param requestor Description of Parameter
|
|
| 93 |
* @param serviceClass Description of Parameter
|
|
| 94 |
* @param serviceSelector Description of Parameter
|
|
| 95 |
* @return The service value
|
|
| 96 |
*/
|
|
| 97 | 0 |
public Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector)
|
| 98 |
{
|
|
| 99 | 0 |
return this.service; |
| 100 |
} |
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
/**
|
|
| 105 |
* Description of the Method
|
|
| 106 |
*
|
|
| 107 |
* @param bcs Description of Parameter
|
|
| 108 |
* @param requestor Description of Parameter
|
|
| 109 |
* @param service Description of Parameter
|
|
| 110 |
*/
|
|
| 111 | 0 |
public void releaseService(BeanContextServices bcs, Object requestor, Object service) { } |
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
/**
|
|
| 116 |
* Description of the Method
|
|
| 117 |
*
|
|
| 118 |
* @param l Description of Parameter
|
|
| 119 |
*/
|
|
| 120 | 0 |
public void removeWindowListener(WindowListener l) |
| 121 |
{
|
|
| 122 | 0 |
this.frame.removeWindowListener(l);
|
| 123 |
} |
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
|
| 127 |
/**
|
|
| 128 |
* Setter for the title attribute
|
|
| 129 |
*
|
|
| 130 |
* @param title The new value
|
|
| 131 |
*/
|
|
| 132 | 0 |
public void setTitle(String title) |
| 133 |
{
|
|
| 134 | 0 |
this.frame.setTitle(title);
|
| 135 |
} |
|
| 136 |
|
|
| 137 |
|
|
| 138 |
/**
|
|
| 139 |
* Description of the Method
|
|
| 140 |
*
|
|
| 141 |
* @param menuBar Description of Parameter
|
|
| 142 |
*/
|
|
| 143 | 0 |
public void update(JMenuBar menuBar) |
| 144 |
{
|
|
| 145 | 0 |
this.frame.setJMenuBar(menuBar);
|
| 146 | 0 |
this.frame.setVisible(true); |
| 147 |
} |
|
| 148 |
|
|
| 149 |
|
|
| 150 |
/** Description of the Method */
|
|
| 151 | 0 |
protected void initializeBeanContextResources() |
| 152 |
{
|
|
| 153 | 0 |
super.initializeBeanContextResources();
|
| 154 |
|
|
| 155 | 0 |
ImageIcon icon = new ImageIcon(this.getClass().getResource("/frameGraphics/ejtools.gif")); |
| 156 | 0 |
if (icon != null) |
| 157 |
{
|
|
| 158 | 0 |
this.frame.setIconImage(icon.getImage());
|
| 159 |
} |
|
| 160 |
} |
|
| 161 |
|
|
| 162 |
|
|
| 163 |
/** Description of the Method */
|
|
| 164 | 0 |
protected void releaseBeanContextResources() |
| 165 |
{
|
|
| 166 | 0 |
BeanContextServices context = (BeanContextServices) getBeanContext(); |
| 167 | 0 |
this.frame.setVisible(false); |
| 168 | 0 |
this.releaseServices(context);
|
| 169 |
|
|
| 170 | 0 |
super.releaseBeanContextResources();
|
| 171 |
} |
|
| 172 |
|
|
| 173 |
|
|
| 174 |
/**
|
|
| 175 |
* Description of the Method
|
|
| 176 |
*
|
|
| 177 |
* @param context Description of Parameter
|
|
| 178 |
*/
|
|
| 179 | 0 |
protected void releaseServices(BeanContextServices context) { } |
| 180 |
|
|
| 181 |
|
|
| 182 |
/**
|
|
| 183 |
* Description of the Method
|
|
| 184 |
*
|
|
| 185 |
* @param context Description of Parameter
|
|
| 186 |
*/
|
|
| 187 | 0 |
protected void useServices(BeanContextServices context) |
| 188 |
{
|
|
| 189 |
// Set up MenuBar
|
|
| 190 | 0 |
if (context.hasService(MenuBarService.class)) |
| 191 |
{
|
|
| 192 | 0 |
logger.debug("Using service MenuBarService...");
|
| 193 | 0 |
try
|
| 194 |
{
|
|
| 195 | 0 |
MenuBarService service = (MenuBarService) context.getService(this, this, MenuBarService.class, this.frame, this); |
| 196 | 0 |
service.addMenuBarListener(this);
|
| 197 | 0 |
frame.setJMenuBar((JMenuBar) service.getContainer()); |
| 198 |
} |
|
| 199 |
catch (Exception e)
|
|
| 200 |
{
|
|
| 201 | 0 |
logger.error("Error during utilisation of service MenuBarService (" + e.getMessage() + ")"); |
| 202 | 0 |
e.printStackTrace(); |
| 203 |
} |
|
| 204 |
} |
|
| 205 |
|
|
| 206 |
// Set up ToolBar
|
|
| 207 | 0 |
if (context.hasService(ToolBarService.class)) |
| 208 |
{
|
|
| 209 | 0 |
logger.debug("Using service ToolBarService...");
|
| 210 | 0 |
try
|
| 211 |
{
|
|
| 212 | 0 |
ToolBarService service = (ToolBarService) context.getService(this, this, ToolBarService.class, this.frame, this); |
| 213 | 0 |
frame.getContentPane().add(BorderLayout.NORTH, service.getContainer()); |
| 214 |
} |
|
| 215 |
catch (Exception e)
|
|
| 216 |
{
|
|
| 217 | 0 |
logger.error("Error during utilisation of service ToolBarService (" + e.getMessage() + ")"); |
| 218 | 0 |
e.printStackTrace(); |
| 219 |
} |
|
| 220 |
} |
|
| 221 |
|
|
| 222 |
// Set up StatusBar
|
|
| 223 | 0 |
if (context.hasService(StatusBarService.class)) |
| 224 |
{
|
|
| 225 | 0 |
logger.debug("Using service StatusBarService...");
|
| 226 | 0 |
try
|
| 227 |
{
|
|
| 228 | 0 |
StatusBarService service = (StatusBarService) context.getService(this, this, StatusBarService.class, this.frame, this); |
| 229 | 0 |
frame.getContentPane().add(BorderLayout.SOUTH, service.getContainer()); |
| 230 |
} |
|
| 231 |
catch (Exception e)
|
|
| 232 |
{
|
|
| 233 | 0 |
logger.error("Error during utilisation of service StatusBarService (" + e.getMessage() + ")"); |
| 234 | 0 |
e.printStackTrace(); |
| 235 |
} |
|
| 236 |
} |
|
| 237 |
} |
|
| 238 |
} |
|
| 239 |
|
|
||||||||||