org.formaria.editor.project.pages
Class PageResource

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.formaria.editor.project.pages.PageResource
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class PageResource
extends javax.swing.JPanel

A holder for a page's resources on behalf of the editor. The class is used as a holder for individual instances of Aria pages. Extra information about the pages used by the editor is maintained by this class. The class is necessary as it is not possible to subclass individual pages in a live system as the actual pages may themselves be subclasses of the Page class.

When used the page is actually places within one of the PageDesigner's Target areas.

Copyright (c) Formaria Ltd., 1998-2006

$Revision: 1.24 $ License: see license.txt

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  EditorProject currentProject
          The owner project and the context in which this object operates.
protected  IPagePanel pagePanel
           
protected  java.lang.String pageXML
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
PageResource(java.lang.String name, java.lang.String ext, java.lang.String path, java.lang.String pagePackageName)
           
 
Method Summary
 void addCtlEvent(java.awt.Component c, java.lang.Class klass, java.lang.String methodName)
          Store the name of an event in the ctlEvents Hashtable.
 void addCtlEvent(java.awt.Component c, long eventMask, java.lang.String methodName)
          Store the name of an event in the ctlEvents Hashtable.
 void addDataBinding(java.awt.Component c, DataBinding binding)
           
 void changeClassName()
          When a template file is created we need to change the class name and the ctor.
static void generate(PageResource page, java.io.Writer w)
          Write a project to a stream
 java.lang.String getBaseClassName()
           
 java.lang.String getCtlEvent(java.awt.Component c, java.lang.Class klass)
          Get the name of the event associated with the component parameter with the eventmask corresponding to the eventMask parameter
 java.lang.String getCtlEvent(java.awt.Component c, long eventMask)
          Get the name of the event associated with the component parameter with the eventmask corresponding to the eventMask parameter
 DataBinding getDataBinding(java.awt.Component c)
          Get the current data binding for an existing component
 DataBinding getDataBinding(java.awt.Component c, java.lang.String type)
          Get the current data binding for an existing component
 java.lang.String getExtension()
          Get the file name extension
 boolean getIsModified()
          Returns the modification state of this page
 java.lang.String getJavaSource()
          Get the Java source for this screen.
 java.io.File getJavaSourceFile()
           
 java.lang.String getJavaSourceFileName()
           
 java.lang.String getName()
          Get the name of the managed page
 java.lang.String getPackageName()
          Get the package to which the page belongs
 Page getPage()
          Get the current page.
 java.lang.String getPageAttribute(java.lang.String attribName)
          Get an attribute of the page
 java.util.Hashtable getPageAttributes()
          Retrive the page attributes
 int getPageChildCount()
           
 IPagePanel getPagePanel()
           
 java.lang.String getPageXML()
           
 java.awt.Dimension getPreferredSize()
          Get the preferred size of the page, when edited as a single page
 EditorProject getProject()
           
 java.lang.Object getSourceCodeEditor()
          Get the source code editor
 java.lang.Object getSourceEditor()
          Get the source code editor's top component
 java.lang.String getStyleName(java.awt.Component comp)
           
 java.lang.String getStyleName(java.awt.Component comp, java.lang.String styleName)
           
 java.lang.String getTargetName()
          Get the target area name
 boolean isModified()
           
 void openPage()
          Ask NetBeans to open the page
 void openSourceFile(java.lang.String methodName, boolean create)
          Open the Java source file for the screen specified by pageName and return it's contents.
 void reloadPage()
           
 void removeCtlEvent(java.awt.Component c, java.lang.Class klass)
          Remove the components event handler.
 void removeCtlEvent(java.awt.Component c, long eventMask)
          Remove the components event handler.
 void reset()
           
 void resetStyles()
          Iterate through all the componet-style references and refresh the components so that the reflect the current set of styles.
protected  void saveSource()
          Save the Java source associated with the screen.
 void setBaseClassName(java.lang.String className)
           
static void setEditorUtility(IEditorUtility eu, boolean isEclipse)
           
 void setIsModified()
          Marks this page as being modified
 void setJavaSource(java.lang.String src)
          Sets the Java source for this screen.
 void setModified(boolean newState)
           
 void setName(java.lang.String s)
           
 void setPage(Page newPage)
          Set the current page
 void setPageAttribute(java.lang.String attribName, java.lang.String value)
          Set an attribute of the page
 void setPagePanel(IPagePanel pp)
           
 void setPageXML(java.lang.String xml)
           
 void setPreferredSize(java.awt.Dimension d, boolean override)
          Set the preferred size of the page, when edited as a single page
 void setSourceCodeEditor(java.lang.Object sce)
          Set the source code editor
 void setSourceEditor(java.lang.Object tc)
          Set the source code editor
 void setStyleName(java.awt.Component comp, java.lang.String styleName)
           
 void setStyleName(java.awt.Component comp, java.lang.String styleName, java.lang.String styleValue)
           
 boolean sourceFileExists()
          Check to see if the Java source file exists for the specified screen
 void writePage(EditorProject currentProject, java.lang.String path)
          Saves the XML which defines a screen and any associated source files.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pagePanel

protected IPagePanel pagePanel

pageXML

protected java.lang.String pageXML

currentProject

protected EditorProject currentProject
The owner project and the context in which this object operates.

Constructor Detail

PageResource

public PageResource(java.lang.String name,
                    java.lang.String ext,
                    java.lang.String path,
                    java.lang.String pagePackageName)
Method Detail

getProject

public EditorProject getProject()

getPageChildCount

public int getPageChildCount()

setPageXML

public void setPageXML(java.lang.String xml)

getPageXML

public java.lang.String getPageXML()

getPagePanel

public IPagePanel getPagePanel()

setPagePanel

public void setPagePanel(IPagePanel pp)

generate

public static void generate(PageResource page,
                            java.io.Writer w)
                     throws java.io.IOException
Write a project to a stream

Throws:
java.io.IOException

isModified

public boolean isModified()

setModified

public void setModified(boolean newState)

setName

public void setName(java.lang.String s)
Overrides:
setName in class java.awt.Component

getPreferredSize

public java.awt.Dimension getPreferredSize()
Get the preferred size of the page, when edited as a single page

Overrides:
getPreferredSize in class javax.swing.JComponent
Returns:
the size

setPreferredSize

public void setPreferredSize(java.awt.Dimension d,
                             boolean override)
Set the preferred size of the page, when edited as a single page

Parameters:
s - the size
override - set the size of an open page

setPage

public void setPage(Page newPage)
Set the current page

Parameters:
newPage - the page

getPage

public Page getPage()
Get the current page.

Returns:
the page or null if it hasn't been loaded yet

reset

public void reset()

reloadPage

public void reloadPage()

getName

public java.lang.String getName()
Get the name of the managed page

Overrides:
getName in class java.awt.Component
Returns:

getExtension

public java.lang.String getExtension()
Get the file name extension

Returns:
the extension, e.g. .xml

getTargetName

public java.lang.String getTargetName()
Get the target area name

Returns:
the name of the target area if the page resources has been added to one.

setPageAttribute

public void setPageAttribute(java.lang.String attribName,
                             java.lang.String value)
Set an attribute of the page

Parameters:
attribName - the attribute name
value - the new value

getPageAttributes

public java.util.Hashtable getPageAttributes()
Retrive the page attributes

Returns:
The page attributes Hashtable

getPageAttribute

public java.lang.String getPageAttribute(java.lang.String attribName)
Get an attribute of the page

Parameters:
attribName - the attribute name
Returns:
the attribute value or null if it is not present

getPackageName

public java.lang.String getPackageName()
Get the package to which the page belongs

Returns:
the package name, usingthe '.' notation

getIsModified

public boolean getIsModified()
Returns the modification state of this page

Returns:
true if the page has been modified

setIsModified

public void setIsModified()
Marks this page as being modified


setJavaSource

public void setJavaSource(java.lang.String src)
Sets the Java source for this screen.

Parameters:
src - the source for the file

getJavaSource

public java.lang.String getJavaSource()
Get the Java source for this screen.

Returns:
the source for the file

addCtlEvent

public void addCtlEvent(java.awt.Component c,
                        long eventMask,
                        java.lang.String methodName)
Store the name of an event in the ctlEvents Hashtable. The entry itself is another Hashtable as controls will potentially have multiple event. The key into the main Hashtable is the component while the key into the second one is a Long constructed from the event mask we are interested in.

Parameters:
c - the component we are adding the event reference for. Used as the lookup for the main Hashtable
eventMask - the event mask which is being dealt with. Used as the lookup for the sub Hashtable
methodName - the name of the method which is called when the event is triggered

removeCtlEvent

public void removeCtlEvent(java.awt.Component c,
                           long eventMask)
Remove the components event handler. This is for the situation where a handler exists for a component and the user sets it to blank in the property editor.

Parameters:
c - the component we are adding the event reference for. Used as the lookup for the main Hashtable
eventMask - the event mask which is being dealt with. Used as the lookup for the sub Hashtable

getCtlEvent

public java.lang.String getCtlEvent(java.awt.Component c,
                                    long eventMask)
Get the name of the event associated with the component parameter with the eventmask corresponding to the eventMask parameter

Parameters:
c - the component we are looking up
eventMask - the event mask for the component
Returns:
null if none found otherwise the name of the method which is to be called when the event is triggered.

addCtlEvent

public void addCtlEvent(java.awt.Component c,
                        java.lang.Class klass,
                        java.lang.String methodName)
Store the name of an event in the ctlEvents Hashtable. The entry itself is another Hashtable as controls will potentially have multiple event. The key into the main Hashtable is the component while the key into the second one is a Long constructed from the event mask we are interested in.

Parameters:
c - the component we are adding the event reference for. Used as the lookup for the main Hashtable
klass - the event class for the component
methodName - the name of the method which is called when the event is triggered

removeCtlEvent

public void removeCtlEvent(java.awt.Component c,
                           java.lang.Class klass)
Remove the components event handler. This is for the situation where a handler exists for a component and the user sets it to blank in the property editor.

Parameters:
c - the component we are adding the event reference for. Used as the lookup for the main Hashtable
klass - the event class for the component

getCtlEvent

public java.lang.String getCtlEvent(java.awt.Component c,
                                    java.lang.Class klass)
Get the name of the event associated with the component parameter with the eventmask corresponding to the eventMask parameter

Parameters:
c - the component we are looking up
klass - the event class for the component
Returns:
null if none found otherwise the name of the method which is to be called when the event is triggered.

addDataBinding

public void addDataBinding(java.awt.Component c,
                           DataBinding binding)

getDataBinding

public DataBinding getDataBinding(java.awt.Component c)
Get the current data binding for an existing component

Parameters:
c - the component
Returns:
the data binding

getDataBinding

public DataBinding getDataBinding(java.awt.Component c,
                                  java.lang.String type)
Get the current data binding for an existing component

Parameters:
c - the component
type - the name of the data type
Returns:
the data binding

getStyleName

public java.lang.String getStyleName(java.awt.Component comp)

getStyleName

public java.lang.String getStyleName(java.awt.Component comp,
                                     java.lang.String styleName)

setStyleName

public void setStyleName(java.awt.Component comp,
                         java.lang.String styleName)

setStyleName

public void setStyleName(java.awt.Component comp,
                         java.lang.String styleName,
                         java.lang.String styleValue)

resetStyles

public void resetStyles()
Iterate through all the componet-style references and refresh the components so that the reflect the current set of styles.


writePage

public void writePage(EditorProject currentProject,
                      java.lang.String path)
Saves the XML which defines a screen and any associated source files.

Parameters:
path - the file path to use in saving
packageName - the package to which this page belongs

getBaseClassName

public java.lang.String getBaseClassName()

setBaseClassName

public void setBaseClassName(java.lang.String className)

saveSource

protected void saveSource()
Save the Java source associated with the screen.


getJavaSourceFile

public java.io.File getJavaSourceFile()

getJavaSourceFileName

public java.lang.String getJavaSourceFileName()

openSourceFile

public void openSourceFile(java.lang.String methodName,
                           boolean create)
Open the Java source file for the screen specified by pageName and return it's contents. If the source file doesn't currently exist and the create flag is true then create a template file.

Parameters:
pd - the page designer
methodName - the name of the method, or null if the method belongs to the page
create - Create a template file if it doesn't already exist

openPage

public void openPage()
Ask NetBeans to open the page


changeClassName

public void changeClassName()
When a template file is created we need to change the class name and the ctor. These are specified in the source by 'NEW_CLASS_NAME', 'PROJECT_PACKAGE_NAME'


sourceFileExists

public boolean sourceFileExists()
Check to see if the Java source file exists for the specified screen

Parameters:
packagePath - the path to the source files
Returns:
true if it exists otherwise false.

setSourceCodeEditor

public void setSourceCodeEditor(java.lang.Object sce)
Set the source code editor

Parameters:
sce - the editor reference

setSourceEditor

public void setSourceEditor(java.lang.Object tc)
Set the source code editor

Parameters:
sce - the editor top component reference

getSourceCodeEditor

public java.lang.Object getSourceCodeEditor()
Get the source code editor

Returns:
the editor reference

getSourceEditor

public java.lang.Object getSourceEditor()
Get the source code editor's top component

Returns:
the stop component reference

setEditorUtility

public static void setEditorUtility(IEditorUtility eu,
                                    boolean isEclipse)