Class EdalFileChooser
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Window
-
- java.awt.Dialog
-
- javax.swing.JDialog
-
- de.ipk_gatersleben.bit.bi.edal.rmi.client.util.EdalTitleDialog
-
- de.ipk_gatersleben.bit.bi.edal.rmi.client.gui.EdalFileChooser
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,javax.accessibility.Accessible,javax.swing.RootPaneContainer,javax.swing.WindowConstants
public class EdalFileChooser extends EdalTitleDialog
EDALFileChooserprovides a simple mechanism for the user to choose a file from EDAL File System. The following code pops up a file chooser for the user that sees only .jpg and .gif images:EDALFileChooser chooser = new EDALFileChooser((Frame) window, rootDirectory); EdalFileNameExtensionFilter filter = new EdalFileNameExtensionFilter("JPG & GIF Images", "jpg", "gif"); chooser.setFileFilter(filter); int returnVal = chooser.showOpenDialog(); if (returnVal == EDALFileChooser.APPROVE_OPTION) { System.out.println("You chose to open this file: " + chooser.getSelectedFile().getName()); }attribute: isContainer false description: A component which allows for the interactive selection of a file.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JDialog
javax.swing.JDialog.AccessibleJDialog
-
Nested classes/interfaces inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
-
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
-
-
Field Summary
Fields Modifier and Type Field Description static intAPPROVE_OPTIONReturn value if approve (yes, ok) is chosen.static intCANCEL_OPTIONReturn value if cancel is chosen.protected ClientPrimaryDataDirectorycurrentdirstatic intDIRECTORIES_ONLYInstruction to display only directories.static intERROR_OPTIONReturn value if an error occured.static intFILES_AND_DIRECTORIESInstruction to display both files and directories.static intFILES_ONLYInstruction to display only files.protected javax.swing.JButtonokbuttonprotected javax.swing.JTextFieldpathtextprotected ClientPrimaryDataEntityselectedFile-
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
-
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
-
Constructor Summary
Constructors Constructor Description EdalFileChooser(java.awt.Dialog owner, ClientDataManager client)Constructs aEDALFileChooserthat is initialized withowneras the swing container owner(JDialog),rootDirectoryas the root directory, andclientas the rmi client datamanager.EdalFileChooser(java.awt.Frame owner, ClientDataManager client)Constructs aEDALFileChooserthat is initialized withowneras the swing container owner(JFrame),rootDirectoryas the root directory, andclientas the rmi client datamanager.
-
Method Summary
Modifier and Type Method Description EdalAbstractFileFiltergetFileFilter()Returns the currently selected file filter.intgetFileSelectionMode()Returns the current file-selection mode.ClientPrimaryDataEntitygetSelectedFile()Returns the selected file.ClientPrimaryDataEntity[]getSelectedFiles()Returns a list of selected files if the file chooser is set to allow multiple selection.protected voidinit(ClientPrimaryDataDirectory rootDirectory)protected voidinitViewers()voidsetFileFilter(EdalAbstractFileFilter filter)Sets the current file filter.voidsetFileSelectionMode(int mode)Sets theEDALFileChooserto allow the user to just select files, just select directories, or select both files and directories.voidsetMultiSelectionEnabled(boolean b)Sets the file chooser to allow multiple file selections.voidshowConnectionButton(boolean showconnbutton)show the "changeconnection" or not.intshowOpenDialog()Pops up an "Open File" file chooser dialog.intshowSaveDialog()Pops up a "Save File" file chooser dialog.-
Methods inherited from class de.ipk_gatersleben.bit.bi.edal.rmi.client.util.EdalTitleDialog
getContentPane, getTitleComponent, setContentPane, setIconImage, setResizable, setTitle, setUndecorated
-
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
-
Methods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setShape, setVisible, show, toBack
-
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, 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, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
pathtext
protected final javax.swing.JTextField pathtext
-
selectedFile
protected ClientPrimaryDataEntity selectedFile
-
currentdir
protected ClientPrimaryDataDirectory currentdir
-
okbutton
protected javax.swing.JButton okbutton
-
CANCEL_OPTION
public static final int CANCEL_OPTION
Return value if cancel is chosen.- See Also:
- Constant Field Values
-
APPROVE_OPTION
public static final int APPROVE_OPTION
Return value if approve (yes, ok) is chosen.- See Also:
- Constant Field Values
-
ERROR_OPTION
public static final int ERROR_OPTION
Return value if an error occured.- See Also:
- Constant Field Values
-
FILES_ONLY
public static final int FILES_ONLY
Instruction to display only files.- See Also:
- Constant Field Values
-
DIRECTORIES_ONLY
public static final int DIRECTORIES_ONLY
Instruction to display only directories.- See Also:
- Constant Field Values
-
FILES_AND_DIRECTORIES
public static final int FILES_AND_DIRECTORIES
Instruction to display both files and directories.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EdalFileChooser
public EdalFileChooser(java.awt.Dialog owner, ClientDataManager client)Constructs aEDALFileChooserthat is initialized withowneras the swing container owner(JDialog),rootDirectoryas the root directory, andclientas the rmi client datamanager. If any of the parameters arenullthis method will not initialize.- Parameters:
owner- the swing container ownerclient- the rmi client datamanager
-
EdalFileChooser
public EdalFileChooser(java.awt.Frame owner, ClientDataManager client)Constructs aEDALFileChooserthat is initialized withowneras the swing container owner(JFrame),rootDirectoryas the root directory, andclientas the rmi client datamanager. If any of the parameters arenullthis method will not initialize.- Parameters:
owner- the swing container ownerclient- the rmi client datamanager
-
-
Method Detail
-
getFileFilter
public EdalAbstractFileFilter getFileFilter()
Returns the currently selected file filter.- Returns:
- the current file filter
- See Also:
setFileFilter(de.ipk_gatersleben.bit.bi.edal.rmi.client.util.EdalAbstractFileFilter)
-
getFileSelectionMode
public int getFileSelectionMode()
Returns the current file-selection mode. The default isEDALFileChooser.FILES_ONLY.- Returns:
- the type of files to be displayed, one of the following:
- EDALFileChooser.FILES_ONLY
- EDALFileChooser.DIRECTORIES_ONLY
- EDALFileChooser.FILES_AND_DIRECTORIES
- See Also:
setFileSelectionMode(int)
-
getSelectedFile
public ClientPrimaryDataEntity getSelectedFile()
Returns the selected file. This can be set by a user action, such as selecting the file from a list in the UI.- Returns:
- the selected file
-
getSelectedFiles
public ClientPrimaryDataEntity[] getSelectedFiles()
Returns a list of selected files if the file chooser is set to allow multiple selection.- Returns:
- the selected files
-
init
protected void init(ClientPrimaryDataDirectory rootDirectory)
-
initViewers
protected void initViewers()
-
setFileFilter
public void setFileFilter(EdalAbstractFileFilter filter)
Sets the current file filter. The file filter is used by the file chooser to filter out files from the user's view. Beaninfo preferred: true bound: true description: Sets the File Filter used to filter out files of type.- Parameters:
filter- the new current file filter to use- See Also:
getFileFilter()
-
setFileSelectionMode
public void setFileSelectionMode(int mode)
Sets theEDALFileChooserto allow the user to just select files, just select directories, or select both files and directories. The default isEDALFileChooser.FILES_ONLY.- Parameters:
mode- the type of files to be displayed:- EDALFileChooser.FILES_ONLY
- EDALFileChooser.DIRECTORIES_ONLY
- EDALFileChooser.FILES_AND_DIRECTORIES
- Throws:
java.lang.IllegalArgumentException- ifmodeis an illegal file selection mode Beaninfo preferred: true bound: true description: Sets the types of files that the JFileChooser can choose. enum: FILES_ONLY EDALFileChooser.FILES_ONLY DIRECTORIES_ONLY EDALFileChooser.DIRECTORIES_ONLY EDALFileChooser.FILES_AND_DIRECTORIES- See Also:
getFileSelectionMode()
-
setMultiSelectionEnabled
public void setMultiSelectionEnabled(boolean b)
Sets the file chooser to allow multiple file selections.- Parameters:
b- true if multiple files may be selected Beaninfo bound: true description: Sets multiple file selection mode.
-
showOpenDialog
public int showOpenDialog()
Pops up an "Open File" file chooser dialog. Note that the text that appears in the approve button is determined by the L and F.- Returns:
- the return state of the file chooser on popdown:
- EDALFileChooser.CANCEL_OPTION
- EDALFileChooser.APPROVE_OPTION
- EDALFileChooser.ERROR_OPTION if an error occurs or the dialog is dismissed
-
showSaveDialog
public int showSaveDialog()
Pops up a "Save File" file chooser dialog. Note that the text that appears in the approve button is determined by the L and F.- Returns:
- the return state of the file chooser on popdown:
- EDALFileChooser.CANCEL_OPTION
- EDALFileChooser.APPROVE_OPTION
- EDALFileChooser.ERROR_OPTION if an error occurs or the dialog is dismissed
-
showConnectionButton
public void showConnectionButton(boolean showconnbutton)
show the "changeconnection" or not.- Parameters:
showconnbutton- false if you want to hidden the button
-
-