Package de.sciss.gui
Class PathField
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- de.sciss.gui.SpringPanel
-
- de.sciss.gui.PathField
-
- All Implemented Interfaces:
EventManager.Processor,PathListener,java.awt.event.ActionListener,java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,java.util.EventListener,javax.accessibility.Accessible
- Direct Known Subclasses:
PrefPathField
public class PathField extends SpringPanel implements java.awt.event.ActionListener, PathListener, EventManager.Processor
This class is an updated (slim) version of FScape'sPathFieldand provides a GUI object that displays a file's or folder's path, optionally with format information, and allows the user to browse the harddisk to change to a different file.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classPathField.IOTextField-
Nested classes/interfaces inherited from class de.sciss.gui.SpringPanel
SpringPanel.ComponentHeightRatioSpring, SpringPanel.ComponentWidthRatioSpring, SpringPanel.RatioSpring
-
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
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.awt.ColorCOLOR_PROPSETprotected PathButtonggChooseprotected ColouredTextFieldggFormatprotected PathField.IOTextFieldggPathprotected javax.swing.JLabellbWarnprotected static intmyMetaprotected java.lang.StringprotoSchemeprotected java.lang.Stringschemestatic intTYPE_BASICMASKtype flag : the bitmask for all path typesstatic intTYPE_FOLDERtype flag : path to be chosen is a folderstatic intTYPE_FORMATFIELDtype flag : request an extra gadget to view file informationstatic intTYPE_INPUTFILEtype flag : file is used for input / readingstatic intTYPE_OUTPUTFILEtype flag : file is used for output / writingprotected static PathListuserPaths-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringabbrScheme(java.lang.String orig)voidactionPerformed(java.awt.event.ActionEvent e)voidaddPathListener(PathListener listener)Registers aPathListenerwhich will be informed about changes of the path (i.e.protected PathButtoncreatePathButton(int buttonType)voidderiveFrom(PathField[] sp, java.lang.String s)PathFieldoffers a mechanism to automatically derive a path name from a "mother"PathField.protected java.lang.StringevalScheme(java.lang.String s)protected java.lang.StringexpandScheme(java.lang.String orig)java.io.FilenameFiltergetFilter()Queries the current item filter for the file dialog.java.lang.StringgetFormat()Get the string displayed in the format gadget.java.io.FilegetPath()Returns the path displayed in the gadget.intgetType()Gets the type of the path field.voidpathChanged(PathEvent e)Notifies the listener that a path changed occured.voidprocessEvent(BasicEvent e)Processes the next event in the queue.voidremovePathListener(PathListener listener)Unregisters aPathListenerfrom receiving path change events.booleanrequestFocusInWindow()voidselectFileName(boolean extention)Selects the file name portion of the text contents.voidsetErrWhenExistsOn(boolean onOff)voidsetErrWhenWriteProtected(boolean onOff)voidsetFilter(java.io.FilenameFilter filter)Sets the filter to use for enabling or disabling items in the file dialog.voidsetFormat(java.lang.String txt, boolean success)Change the contents of the format gadget.voidsetPath(java.io.File path)Sets the gadget's path.protected voidsetPathAndDispatchEvent(java.io.File path)Sets a new path and dispatches aPathEventto registered listenersvoidsetWarnWhenExists(boolean onOff)protected java.lang.StringudirScheme(java.lang.String orig, int idx)-
Methods inherited from class de.sciss.gui.SpringPanel
gridAdd, gridAdd, gridAdd, makeCompactGrid, makeCompactGrid, makeGrid, setInitialX, setInitialY, setPadding, setTitle, setXPad, setYPad
-
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, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, 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, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
TYPE_BASICMASK
public static final int TYPE_BASICMASK
type flag : the bitmask for all path types- See Also:
- Constant Field Values
-
TYPE_INPUTFILE
public static final int TYPE_INPUTFILE
type flag : file is used for input / reading- See Also:
- Constant Field Values
-
TYPE_FORMATFIELD
public static final int TYPE_FORMATFIELD
type flag : request an extra gadget to view file information- See Also:
- Constant Field Values
-
TYPE_OUTPUTFILE
public static final int TYPE_OUTPUTFILE
type flag : file is used for output / writing- See Also:
- Constant Field Values
-
TYPE_FOLDER
public static final int TYPE_FOLDER
type flag : path to be chosen is a folder- See Also:
- Constant Field Values
-
userPaths
protected static PathList userPaths
-
ggPath
protected final PathField.IOTextField ggPath
-
ggChoose
protected final PathButton ggChoose
-
lbWarn
protected final javax.swing.JLabel lbWarn
-
ggFormat
protected ColouredTextField ggFormat
-
COLOR_PROPSET
protected static final java.awt.Color COLOR_PROPSET
-
scheme
protected java.lang.String scheme
-
protoScheme
protected java.lang.String protoScheme
-
myMeta
protected static final int myMeta
-
-
Constructor Detail
-
PathField
public PathField()
-
PathField
public PathField(int type)
-
PathField
public PathField(int type, java.lang.String dlgTxt)Create a newPathField- Parameters:
type- one of the types covered by TYPE_BASICMASK bitwise-OR optional displays like TYPE_FORMATFIELDdlgTxt- the text string to display in the filechooser ornull
-
-
Method Detail
-
setPath
public void setPath(java.io.File path)
Sets the gadget's path. This is path will be used as default setting when the file chooser is shown- Parameters:
path- the new path for the button
-
setWarnWhenExists
public void setWarnWhenExists(boolean onOff)
-
setErrWhenExistsOn
public void setErrWhenExistsOn(boolean onOff)
-
setErrWhenWriteProtected
public void setErrWhenWriteProtected(boolean onOff)
-
setPathAndDispatchEvent
protected void setPathAndDispatchEvent(java.io.File path)
Sets a new path and dispatches aPathEventto registered listeners- Parameters:
path- the new path for the gadget and the event
-
getPath
public java.io.File getPath()
Returns the path displayed in the gadget.- Returns:
- the
Filecorresponding to the path string in the gadget
-
setFormat
public void setFormat(java.lang.String txt, boolean success)Change the contents of the format gadget.- Parameters:
txt- Text to be displayed in the format gadgetsuccess-falseindicates file format parse error and will render the format gadget red.- Throws:
java.lang.IllegalStateException- if the path field doesn't have a format gadget
-
getFormat
public java.lang.String getFormat()
Get the string displayed in the format gadget.- Returns:
- the currently displayed format text or
nullif the path field has no format gadget.
-
getType
public int getType()
Gets the type of the path field.- Returns:
- the gadget's type as specified in the constructor
use bitwise-AND with
TYPE_BASICMASKto query the file access type.
-
setFilter
public void setFilter(java.io.FilenameFilter filter)
Sets the filter to use for enabling or disabling items in the file dialog.- Parameters:
filter- the new filter or null to remove an existing filter
-
getFilter
public java.io.FilenameFilter getFilter()
Queries the current item filter for the file dialog.- Returns:
- the current filter or null if no filter is installed
-
selectFileName
public void selectFileName(boolean extention)
Selects the file name portion of the text contents.- Parameters:
extention- whether to include the file name suffix or not
-
requestFocusInWindow
public boolean requestFocusInWindow()
- Overrides:
requestFocusInWindowin classjavax.swing.JComponent
-
deriveFrom
public void deriveFrom(PathField[] sp, java.lang.String s)
PathFieldoffers a mechanism to automatically derive a path name from a "mother"PathField. This applies usually to output files whose names are derived from PathFields which represent input paths. The provided 'scheme' String can contain the Tags$Dx = Directory of superPath x; $Fx = Filename; $E = Extension; $Bx = Brief filename
where 'x' is the index in the provided array of mother PathFields. Whenever the mother contents changes, the child PathField will recalculate its name. When the user changes the contents of the child PathField, an algorithm tries to find out which components are related to the mother's pathname, parts that cannot be identified will not be automatically changing any more unless the user completely clears the PathField (i.e. restores full automation).The user can abbreviate or extend filenames by pressing the appropriate key; in this case the $F and $B tags are exchanged in the scheme.
- Parameters:
sp- array of mother path fields to listen tos- automatic formatting scheme which can incorporate placeholders for the mother fields' paths.
-
addPathListener
public void addPathListener(PathListener listener)
Registers aPathListenerwhich will be informed about changes of the path (i.e. user selections in the file chooser or text editing).- Parameters:
listener- thePathListenerto register- See Also:
EventManager.addListener( Object )
-
removePathListener
public void removePathListener(PathListener listener)
Unregisters aPathListenerfrom receiving path change events.- Parameters:
listener- thePathListenerto unregister- See Also:
EventManager.removeListener( Object )
-
processEvent
public void processEvent(BasicEvent e)
Description copied from interface:EventManager.ProcessorProcesses the next event in the queue. This gets called in the event thread. Usually implementing classes should loop through all listeners by calling elm.countListeners() and elm.getListener(), and invoke specific dispatching methods on these listeners.- Specified by:
processEventin interfaceEventManager.Processor
-
evalScheme
protected java.lang.String evalScheme(java.lang.String s)
-
abbrScheme
protected java.lang.String abbrScheme(java.lang.String orig)
-
expandScheme
protected java.lang.String expandScheme(java.lang.String orig)
-
udirScheme
protected java.lang.String udirScheme(java.lang.String orig, int idx)
-
createPathButton
protected PathButton createPathButton(int buttonType)
-
pathChanged
public void pathChanged(PathEvent e)
Description copied from interface:PathListenerNotifies the listener that a path changed occured.- Specified by:
pathChangedin interfacePathListener- Parameters:
e- the event describing the path change
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
- Specified by:
actionPerformedin interfacejava.awt.event.ActionListener
-
-