com.altair.hwm.beans.utils
Class HWMFileBrowser

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.AbstractButton
                  extended by javax.swing.JButton
                      extended by com.altair.hwm.beans.utils.HWMButton
                          extended by com.altair.hwm.beans.utils.HWMFileBrowser
All Implemented Interfaces:
HWMEventListener, IHWMControl, ITCLCodeCreator, java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Externalizable, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.SwingConstants

public class HWMFileBrowser
extends HWMButton
implements java.beans.PropertyChangeListener

Title: HWMFileBrowser

Description: A file chooser class -- This bean is essentially a button, that acts as a file browser button. The user can specify the file filters as properties of the bean

NOTE: Whenever using HWMFileBrowser on a modal HWMDialog follow 1. Donot use the mechanism of using addHWMCmdEventListener() and handling OnCmdSuccess() and OnCmdFailed() methods 2.Rather treat the HWMFileBrowser as a button, addActionListener and in actionPerformed() do fileBrowser.Browse(HWMDialog) Company: Altair Engineering, Inc.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
static int FILE_NOT_SELECTED
          This is returned if the user cancels the file selection
static int FILE_SELECTED
          This is returned if the user has selected a file
static int METH_BROWSE
           
static java.lang.String PROP_APPROVE_TXT
           
static java.lang.String PROP_CURRENT_WORKING_DIR
           
static java.lang.String PROP_DLG_TITLE
           
static java.lang.String PROP_FILE_FILTER
           
static java.lang.String PROP_FILENAME
           
static java.lang.String PROP_VALUE
           
static java.lang.String VERSION
           
 
Fields inherited from class com.altair.hwm.beans.utils.HWMButton
BTNTYPE_APPLY, BTNTYPE_APPLY_AND_NEXT, BTNTYPE_CANCEL, BTNTYPE_GENERIC, BTNTYPE_NEXT, BTNTYPE_PREV
 
Fields inherited from class javax.swing.AbstractButton
BORDER_PAINTED_CHANGED_PROPERTY, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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 javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
HWMFileBrowser()
          Constructor
 
Method Summary
 int Browse()
          Displays browser and returns the selected file.
 int Browse(java.awt.Component compParent)
          Displays browser and returns the selected file.
 java.lang.String GetApproveBtnText()
          Gets the approve button text.
 java.lang.String GetDialogTitle()
          Gets the dialog title.
 javax.swing.JFileChooser GetFileChooser()
          Get the file chooser which this class wraps
 java.util.Hashtable GetFileFilter()
          Retrieves info regarding all the file filters.
 java.lang.String GetSelectedFilename()
          Get the name of the file chosen by the file browser
 java.lang.String GetWorkingDir()
          Get the current working dir
 boolean IsFileValid(java.io.File file, java.io.File fileDir)
          Returns true if file selected is valid else false
 void OnAction()
          Callback function when the button is pressed.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          This method gets called when a bound property is changed.
 void readExternal(java.io.ObjectInput inp)
          De-Serialization -- read all the properties from file.
 void ReadProperties()
          Get the required properties from the datamodel and initialize self
 void SaveProperties()
          Save the required properties in the datamodel (so that they persist)
 void SetApproveBtnText(java.lang.String strApproveBtnTxt)
          Sets the approve button text.
 void SetBeanName(java.lang.String strBeanName)
          Set the name of the bean
 void SetDialogTitle(java.lang.String strTitle)
          Sets the dialog title.
 void SetFileFilter(java.util.Hashtable hashtblFilter)
          Adds file filter(s) with the given extension and description.
 void SetFrameWork(IHWMFrameWork hwmFrameWork)
          This method is called by the HWM Application to set the interface with which a bean can communicate directly with the HWM application.
 void SetSelectedFile(java.lang.String szFilename)
          Set the name of the file chosen by the file browser
 void SetWorkingDir(java.lang.String szWorkingDir)
          Set the current working dir
 java.lang.String TCLCreateAdditionalEventProcs()
          This method rerurns the TCL statement string for any additional procedures that is requred for the bean.
 void writeExternal(java.io.ObjectOutput objOutput)
          Serialization -- write all the properties to file.
 
Methods inherited from class com.altair.hwm.beans.utils.HWMButton
actionPerformed, addHWMCmdEventListener, Disable, Enable, GetActionScript, GetBeanName, GetButtonType, GetFrameWork, GetImageAlignment, GetImageFilename, GetImageVisibilityStatus, getToolTipText, HWMEventCallback, OnExit, Play, removeHWMCmdEventListener, Run, SetActionScript, SetButtonType, SetButtonType, setEnabled, SetIconOnButton, SetImageAlignment, SetImageFilename, SetImageFilename, SetImageVisibilityStatus, setPreferredSize, setSize, setText, setToolTipText, setVisible, TCLCreateExec, TCLCreateGetDataFromDataModel, TCLCreateMemberVariables, TCLCreateOnDataModelChanged, TCLCreateSetDataInDataModel, TCLCreateUI
 
Methods inherited from class javax.swing.JButton
getAccessibleContext, getUIClassID, isDefaultButton, isDefaultCapable, removeNotify, setDefaultCapable, updateUI
 
Methods inherited from class javax.swing.AbstractButton
addActionListener, addChangeListener, addItemListener, doClick, doClick, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, isSelected, removeActionListener, removeChangeListener, removeItemListener, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setFocusPainted, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setUI, setVerticalAlignment, setVerticalTextPosition
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setTransferHandler, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, 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, setName, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION

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

PROP_VALUE

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

PROP_FILENAME

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

PROP_FILE_FILTER

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

PROP_CURRENT_WORKING_DIR

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

PROP_DLG_TITLE

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

PROP_APPROVE_TXT

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

METH_BROWSE

public static final int METH_BROWSE
See Also:
Constant Field Values

FILE_NOT_SELECTED

public static final int FILE_NOT_SELECTED
This is returned if the user cancels the file selection

See Also:
Constant Field Values

FILE_SELECTED

public static final int FILE_SELECTED
This is returned if the user has selected a file

See Also:
Constant Field Values
Constructor Detail

HWMFileBrowser

public HWMFileBrowser()
Constructor

Method Detail

SetFrameWork

public void SetFrameWork(IHWMFrameWork hwmFrameWork)
This method is called by the HWM Application to set the interface with which a bean can communicate directly with the HWM application.

Specified by:
SetFrameWork in interface IHWMControl
Overrides:
SetFrameWork in class HWMButton
Parameters:
hwmFrameWork - The interface with which a bean can communicate with the HWM application.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
This method gets called when a bound property is changed.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class HWMButton
Parameters:
evt - - A PropertyChangeEvent object describing the event source and the property that has changed.

SaveProperties

public void SaveProperties()
Save the required properties in the datamodel (so that they persist)

Overrides:
SaveProperties in class HWMButton

ReadProperties

public void ReadProperties()
Get the required properties from the datamodel and initialize self

Overrides:
ReadProperties in class HWMButton

SetBeanName

public void SetBeanName(java.lang.String strBeanName)
Set the name of the bean

Specified by:
SetBeanName in interface IHWMControl
Overrides:
SetBeanName in class HWMButton
Parameters:
strBeanName - The name of this bean as the framework knows it to be. Will be useful, if the bean chooses to scope its data in the datamodel - especially if multiple instances of the same bean appear in the process

writeExternal

public void writeExternal(java.io.ObjectOutput objOutput)
                   throws java.io.IOException
Serialization -- write all the properties to file.

Specified by:
writeExternal in interface java.io.Externalizable
Overrides:
writeExternal in class HWMButton
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput inp)
                  throws java.lang.ClassNotFoundException,
                         java.io.IOException
De-Serialization -- read all the properties from file.

Specified by:
readExternal in interface java.io.Externalizable
Overrides:
readExternal in class HWMButton
Throws:
java.lang.ClassNotFoundException
java.io.IOException

SetFileFilter

public void SetFileFilter(java.util.Hashtable hashtblFilter)
Adds file filter(s) with the given extension and description.

Parameters:
hashtblFilter - The hash table containing all the extensions and the descriptions for each file filter

GetFileFilter

public java.util.Hashtable GetFileFilter()
Retrieves info regarding all the file filters.

Returns:
Hashtable The hash table containing all the extensions and the descriptions for each file filter

SetWorkingDir

public void SetWorkingDir(java.lang.String szWorkingDir)
Set the current working dir

Parameters:
szWorkingDir - The current working directory to use

GetWorkingDir

public java.lang.String GetWorkingDir()
Get the current working dir

Returns:
String The current working directory

SetSelectedFile

public void SetSelectedFile(java.lang.String szFilename)
Set the name of the file chosen by the file browser

Parameters:
szFilename - The name of the file

GetSelectedFilename

public java.lang.String GetSelectedFilename()
Get the name of the file chosen by the file browser

Returns:
The name of the file

SetDialogTitle

public void SetDialogTitle(java.lang.String strTitle)
Sets the dialog title.

Parameters:
strTitle - The title for the dialog

GetDialogTitle

public java.lang.String GetDialogTitle()
Gets the dialog title.


SetApproveBtnText

public void SetApproveBtnText(java.lang.String strApproveBtnTxt)
Sets the approve button text.

Parameters:
strApproveBtnTxt - The text for the approve button

GetApproveBtnText

public java.lang.String GetApproveBtnText()
Gets the approve button text.

Returns:
String The text for the approve button

GetFileChooser

public javax.swing.JFileChooser GetFileChooser()
Get the file chooser which this class wraps

Returns:
JFileChooser The file chooser that this class wraps

Browse

public int Browse()
Displays browser and returns the selected file.

Returns:
The filename or null if no file was chosen.

IsFileValid

public boolean IsFileValid(java.io.File file,
                           java.io.File fileDir)
Returns true if file selected is valid else false

Parameters:
file - The selected file
fileDir - The current directory in the file browser
Returns:
boolean Returns true if file selected is valid else false

Browse

public int Browse(java.awt.Component compParent)
Displays browser and returns the selected file.

Parameters:
compParent - The dialog will be centered in this component.
Returns:
The filename or null if no file was chosen.

OnAction

public void OnAction()
Callback function when the button is pressed. This callback has been setup by the base class HWMButton

Overrides:
OnAction in class HWMButton
Parameters:
actionEvt - The action event object

TCLCreateAdditionalEventProcs

public java.lang.String TCLCreateAdditionalEventProcs()
This method rerurns the TCL statement string for any additional procedures that is requred for the bean. For e.g: In the case of a "Browse" button, there should be a "OnBrowseFile" procedure which is the callback for the "Browse" button. The TCL equivalent code ffor creating that proceudre will be returned by this methos. The bean in question will implement the required procediures code generation.

Specified by:
TCLCreateAdditionalEventProcs in interface ITCLCodeCreator
Overrides:
TCLCreateAdditionalEventProcs in class HWMButton