org.apache.wsrp4j.consumer.app.driver
Class SwingConsumer

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Frame
                  extended byjavax.swing.JFrame
                      extended byorg.apache.wsrp4j.consumer.app.driver.SwingConsumer
All Implemented Interfaces:
javax.accessibility.Accessible, javax.swing.event.ChangeListener, java.util.EventListener, javax.swing.event.HyperlinkListener, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class SwingConsumer
extends javax.swing.JFrame
implements javax.swing.event.HyperlinkListener, javax.swing.event.ChangeListener

Stand alone WSRP consumer with a swing based GUI.

Version:
$Id: SwingConsumer.java,v 1.6 2005/08/15 12:31:09 cziegeler Exp $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  Aggregation aggregation
           
static java.lang.String CHANGE_MODE
           
static java.lang.String CHANGE_STATE
           
static java.lang.String CLONE_PORTLET
           
private  ConsumerEnvironment consumerEnv
           
private  java.lang.String consumerURL
           
private  javax.swing.JEditorPane currentEditor
           
private  java.lang.String currentPageID
           
private  java.lang.String currentUserID
           
private static SwingConsumer instance
           
private  Logger logger
           
private  PageRegistry pageRegistry
           
private  java.lang.String PROPERTY_FILE_NAME
           
private  PropertyConsole propertyConsole
           
private  Request request
           
private  javax.swing.JSplitPane splitPane
           
private  java.util.Map tabes
           
static java.lang.String VIEW_PROP
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Window
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
private SwingConsumer()
           
 
Method Summary
private  void clonePortlet(WSRPPortlet portlet)
          Methods clones an portlet and updates the portlet registry and puts the new portlet on the currently displayed page.
 void deregisterAllProducers()
          Deregister the consumer at all registered producers.
 void destroyAllClonedPortlets()
          Destroy all clones.
 java.lang.String getConsumerURL()
           
private  Page getCurrentPage()
          Get the currently displayed page.
 java.lang.String getCurrentUserID()
          Get the user id of the logged in user.
private  oasis.names.tc.wsrp.v1.types.UserContext getDefaultUserContext(java.lang.String userKey)
          Helper method for obtaining a user context in case of an empty user registry.
static SwingConsumer getInstance()
          Get an instance of the Swing consumer object.
private  java.lang.String getParameterValue(java.lang.String link, java.lang.String token)
          Method searches a parameter string for a certain key and returns the value to the given key or null if the key wasn't found in the string
 SimplePortletWindowSession getSimplePortletWindowSession(WSRPPortlet portlet, java.lang.String portletInstanceKey)
           
 void hyperlinkUpdate(javax.swing.event.HyperlinkEvent event)
          Called when a hypertext link is updated.
private  void initConsumerEnvironment()
          Load the consumer environment implementation according to entry in config file.
private  void initLayout()
          Init the GUI
private  void integrateURLParameter(java.lang.String link, SimplePortletWindowSession windowSession)
          Process all parameters in a link
static void main(java.lang.String[] args)
           
private  void onLink(java.lang.String link)
          This method is called if any link on a page is clicked and dispatches the according action.
private  void performBlockingInteraction(WSRPPortlet portlet, SimplePortletWindowSession windowSession)
          Performs an blocking interaction with the given portlet and session.
 void refresh()
          Repaint the currently displayed page
 void releaseAllSessions()
          Release all use producer sessions.
 void stateChanged(javax.swing.event.ChangeEvent event)
          Called if a tab pane was selected.
private  void updatePortletContext(oasis.names.tc.wsrp.v1.types.PortletContext portletContext, WSRPPortlet portlet, java.lang.String instanceKey)
           
private  void viewProperties(WSRPPortlet portlet)
          Method onViewProperties.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

CHANGE_MODE

public static final java.lang.String CHANGE_MODE
See Also:
Constant Field Values

CHANGE_STATE

public static final java.lang.String CHANGE_STATE
See Also:
Constant Field Values

CLONE_PORTLET

public static final java.lang.String CLONE_PORTLET
See Also:
Constant Field Values

VIEW_PROP

public static final java.lang.String VIEW_PROP
See Also:
Constant Field Values

PROPERTY_FILE_NAME

private final java.lang.String PROPERTY_FILE_NAME
See Also:
Constant Field Values

tabes

private java.util.Map tabes

currentPageID

private java.lang.String currentPageID

currentUserID

private java.lang.String currentUserID

currentEditor

private javax.swing.JEditorPane currentEditor

propertyConsole

private PropertyConsole propertyConsole

splitPane

private javax.swing.JSplitPane splitPane

request

private Request request

consumerEnv

private ConsumerEnvironment consumerEnv

consumerURL

private java.lang.String consumerURL

pageRegistry

private PageRegistry pageRegistry

aggregation

private Aggregation aggregation

instance

private static SwingConsumer instance

logger

private Logger logger
Constructor Detail

SwingConsumer

private SwingConsumer()
Method Detail

getInstance

public static SwingConsumer getInstance()
Get an instance of the Swing consumer object.

Returns:
SwingConsumer object

initConsumerEnvironment

private void initConsumerEnvironment()
                              throws WSRPException
Load the consumer environment implementation according to entry in config file.

Throws:
WSRPException

getCurrentPage

private Page getCurrentPage()
Get the currently displayed page.

Returns:
Page object of the currently displayed page

getCurrentUserID

public java.lang.String getCurrentUserID()
Get the user id of the logged in user.

Returns:
The user ID of the logged in user

refresh

public void refresh()
Repaint the currently displayed page


getDefaultUserContext

private oasis.names.tc.wsrp.v1.types.UserContext getDefaultUserContext(java.lang.String userKey)
Helper method for obtaining a user context in case of an empty user registry. The given userKey is set as UserContextKey.

Parameters:
userKey - The Key of the user to be set as UserContextKey
Returns:
Any user context object with the UserContextKey set to the given userKey

getConsumerURL

public java.lang.String getConsumerURL()

deregisterAllProducers

public void deregisterAllProducers()
Deregister the consumer at all registered producers. This method is called if the option dialog on exit is answered with 'yes'.


releaseAllSessions

public void releaseAllSessions()
Release all use producer sessions. This method is called if the option dialog on exit is answered with 'yes'.


destroyAllClonedPortlets

public void destroyAllClonedPortlets()
Destroy all clones. This method is called if the option dialog on exit is answered with 'yes'.


onLink

private void onLink(java.lang.String link)
             throws WSRPException
This method is called if any link on a page is clicked and dispatches the according action.

Parameters:
link - A string representation of the url of the clicked link.
Throws:
WSRPException

getParameterValue

private java.lang.String getParameterValue(java.lang.String link,
                                           java.lang.String token)
Method searches a parameter string for a certain key and returns the value to the given key or null if the key wasn't found in the string

Parameters:
link - The string containing parameter name and value pairs
token - The parameter name
Returns:
The value of the given parameter

integrateURLParameter

private void integrateURLParameter(java.lang.String link,
                                   SimplePortletWindowSession windowSession)
Process all parameters in a link

Parameters:
link - The link with the parameters
windowSession - The window session where values should be set

clonePortlet

private void clonePortlet(WSRPPortlet portlet)
Methods clones an portlet and updates the portlet registry and puts the new portlet on the currently displayed page.

Parameters:
portlet - The portlet which should be cloned

performBlockingInteraction

private void performBlockingInteraction(WSRPPortlet portlet,
                                        SimplePortletWindowSession windowSession)
Performs an blocking interaction with the given portlet and session. If the response to this call is a redirect URL's it won't be followed. An optionally returned markup context is store in the window session and should be processed by the portlet driver instead of making a new getMarkup() call.

Parameters:
portlet - The portlet on which this action should be performed.
windowSession - The window session of the portlet on which the action should be performed.

updatePortletContext

private void updatePortletContext(oasis.names.tc.wsrp.v1.types.PortletContext portletContext,
                                  WSRPPortlet portlet,
                                  java.lang.String instanceKey)

hyperlinkUpdate

public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent event)
Called when a hypertext link is updated.

Specified by:
hyperlinkUpdate in interface javax.swing.event.HyperlinkListener
Parameters:
event - The event responsible for the update

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent event)
Called if a tab pane was selected.

Specified by:
stateChanged in interface javax.swing.event.ChangeListener
Parameters:
event - The event responsible for the change

initLayout

private void initLayout()
Init the GUI


viewProperties

private void viewProperties(WSRPPortlet portlet)
Method onViewProperties.


getSimplePortletWindowSession

public SimplePortletWindowSession getSimplePortletWindowSession(WSRPPortlet portlet,
                                                                java.lang.String portletInstanceKey)
                                                         throws WSRPException
Throws:
WSRPException

main

public static void main(java.lang.String[] args)


--