org.openswing.swing.util.client
Class ClientUtils

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended byjava.applet.Applet
                  extended byjavax.swing.JApplet
                      extended byorg.openswing.swing.util.client.ClientUtils
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable

public class ClientUtils
extends javax.swing.JApplet

Title: OpenSwing Framework

Description: Help singleton class used to comunicate with the external environment, like the server side (via HTTP) or to fetch external resources (XML, images). It is also the main applet to execute: so this class can be derived to access to applet methods (start method...)

Copyright: Copyright (C) 2006 Mauro Carniel

This file is part of OpenSwing Framework. This library is free software; you can redistribute it and/or modify it under the terms of the (LGPL) Lesser General Public License as published by the Free Software Foundation; GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author may be contacted at: maurocarniel@tin.it

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ClientUtils()
           
 
Method Summary
static void addBusyListener(BusyListener busyListener)
          Add a listener of busy state events.
static void addTabListener(javax.swing.JComponent c)
          Utility method invoked by input controls in order to listen for a AS_TAB key event to translate in a TAB key event, to transfer focus to next component.
static void centerDialog(javax.swing.JFrame parentFrame, javax.swing.JDialog d)
          Place the dialog window in the middle of parentFrame.
static void centerFrame(javax.swing.JFrame frame)
          Place the window in the middle of the desktop.
static void centerWindow(javax.swing.JFrame parentFrame, java.awt.Window w)
          Place the window in the middle of parentFrame.
static java.lang.Object convertObject(java.lang.Object value, java.lang.Class targetType)
           
static void displayURL(java.lang.String url)
          Show a document in a specified viewer.
static void disposeComponents(java.awt.Component[] c)
          Remove components no more used.
static void fireBusyEvent(boolean busy)
           
static Response getData(java.lang.String serverMethodName, java.lang.Object param)
          Send a request to the server side via HTTP.
static java.awt.Image getImage(java.lang.String imageName)
           
static java.awt.Image getImage(java.lang.String imageName, java.lang.Class clazz)
           
static Form getLinkedForm(javax.swing.JComponent comp)
           
static javax.swing.JFrame getParentFrame(javax.swing.JComponent comp)
           
static javax.swing.JInternalFrame getParentInternalFrame(javax.swing.JComponent comp)
           
static java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.Class clazz, java.lang.String attributeName)
           
static java.lang.String getServerURL()
           
static java.lang.Object getValue(ValueObject vo, java.lang.String attributeName)
           
 void init()
           
static void removeBusyListener(BusyListener busyListener)
          Remove a listener of busy state events.
static void setObjectSender(ObjectSender objectSender)
          Set the sender to use inside "getData" method to comunicate with a remote site via HTTP.
static void setSessionId(java.lang.String id)
          Set the session id associated to the current client
static void showDocument(java.lang.String docId)
          Show the specified document in a browser window.
 
Methods inherited from class javax.swing.JApplet
getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, update
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClientUtils

public ClientUtils()
Method Detail

init

public final void init()

getParentFrame

public static javax.swing.JFrame getParentFrame(javax.swing.JComponent comp)
Parameters:
comp - graphic component which is contained into a JFrame
Returns:
JFrame object which contains the graphic component

getParentInternalFrame

public static javax.swing.JInternalFrame getParentInternalFrame(javax.swing.JComponent comp)
Parameters:
comp - graphic component which is contained into a JInternalFrame
Returns:
JInternalFrame object which contains the graphic component

getImage

public static java.awt.Image getImage(java.lang.String imageName)
Parameters:
imageName - image name; must be stored in the "image" folder accessible by the classpath
Returns:
Image object

getImage

public static java.awt.Image getImage(java.lang.String imageName,
                                      java.lang.Class clazz)
Parameters:
imageName - image name; must be stored in the "image" folder accessible by the classpath
Returns:
class already instantiated

centerDialog

public static void centerDialog(javax.swing.JFrame parentFrame,
                                javax.swing.JDialog d)
Place the dialog window in the middle of parentFrame.

Parameters:
parentFrame - parent frame containing the dialog
d - dialog window to center

centerWindow

public static void centerWindow(javax.swing.JFrame parentFrame,
                                java.awt.Window w)
Place the window in the middle of parentFrame.

Parameters:
parentFrame - parent frame containing the dialog
w - window to center

centerFrame

public static void centerFrame(javax.swing.JFrame frame)
Place the window in the middle of the desktop.

Parameters:
frame - frame to center

getServerURL

public static java.lang.String getServerURL()
                                     throws java.lang.Exception
Returns:
server URL, retrieved by "SERVERURL" parameter in the HTML/JNLP starting app file.
Throws:
java.lang.Exception

getData

public static final Response getData(java.lang.String serverMethodName,
                                     java.lang.Object param)
Send a request to the server side via HTTP.

Parameters:
serverMethodName - nome metodo lato server da contattare
param - parametro da passare al metodo
Returns:
risposta ritornata dal server

setSessionId

public static void setSessionId(java.lang.String id)
Set the session id associated to the current client

Parameters:
id - session id associated to the current client

showDocument

public static void showDocument(java.lang.String docId)
                         throws java.lang.Exception
Show the specified document in a browser window.

Parameters:
docId - document identifier
Throws:
java.lang.Exception

displayURL

public static void displayURL(java.lang.String url)
Show a document in a specified viewer.

Parameters:
url - local URI

getLinkedForm

public static Form getLinkedForm(javax.swing.JComponent comp)
Parameters:
comp - component linked to a Form object
Returns:
Form object that manages the current component; null if no Form is linked to the component

addBusyListener

public static final void addBusyListener(BusyListener busyListener)
Add a listener of busy state events.

Parameters:
busyListener - listener of busy state events

removeBusyListener

public static final void removeBusyListener(BusyListener busyListener)
Remove a listener of busy state events.

Parameters:
busyListener - listener of busy state events

fireBusyEvent

public static final void fireBusyEvent(boolean busy)

getPropertyDescriptor

public static final java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.Class clazz,
                                                                        java.lang.String attributeName)
                                                                 throws java.lang.Exception
Parameters:
clazz - Class to analyze
attributeName - attribute name defined within the clazz
Returns:
PropertyDescriptor property descriptor associated to the specified attribute name
Throws:
java.lang.Exception

setObjectSender

public static final void setObjectSender(ObjectSender objectSender)
Set the sender to use inside "getData" method to comunicate with a remote site via HTTP.

Parameters:
objectSender - ObjectSender to set

disposeComponents

public static final void disposeComponents(java.awt.Component[] c)
Remove components no more used.


convertObject

public static final java.lang.Object convertObject(java.lang.Object value,
                                                   java.lang.Class targetType)
Parameters:
value - data to check
targetType - type of data
Returns:
object to return, i.e. the orginal data, if it has the type specified by "targetType" (or some subtype) otherwise its convertion

getValue

public static java.lang.Object getValue(ValueObject vo,
                                        java.lang.String attributeName)
                                 throws java.lang.Exception
Parameters:
vo - ValueObject to analyze
attributeName - v.o. attribute name
Returns:
value stored in v.o. related to the specified attribute name
Throws:
java.lang.Exception

addTabListener

public static void addTabListener(javax.swing.JComponent c)
Utility method invoked by input controls in order to listen for a AS_TAB key event to translate in a TAB key event, to transfer focus to next component.

Parameters:
c - input control to whose add a KeyListener