Package adams.gui.tools
Class FileCommanderPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.gui.tools.FileCommanderPanel
-
- All Implemented Interfaces:
StatusMessageHandler
,StatusMessageHandlerExt
,Stoppable
,StoppableWithFeedback
,MenuBarProvider
,ImageObserver
,MenuContainer
,Serializable
,Accessible
public class FileCommanderPanel extends BasePanel implements MenuBarProvider, StatusMessageHandlerExt, StoppableWithFeedback
File manager with two-pane interface, similar to the Midnight Commander.- Version:
- $Revision$
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description protected List<AbstractFileCommanderAction>
m_Actions
the available actions.protected BaseSplitButton
m_ButtonAction
the action button.protected BaseFlatButton
m_ButtonCopy
the button for copying the file.protected BaseFlatButton
m_ButtonDelete
the button for deleting.protected BaseFlatButton
m_ButtonMkDir
the button for creating a directory.protected BaseFlatButton
m_ButtonMove
the button for moving.protected BaseFlatButton
m_ButtonQuit
the button for quitting.protected BaseFlatButton
m_ButtonReload
the button for reloading the files.protected BaseFlatButton
m_ButtonRename
the button for renaming.protected BaseFlatButton
m_ButtonStop
the button for stopping an operation.protected BaseFlatButton
m_ButtonView
the button for viewing the file.protected FileOperations
m_FileOperations
the current file operations.protected FileCommanderDirectoryPanel
m_FilesActive
the active panel.protected FileCommanderDirectoryPanel
m_FilesInactive
the inactive panel.protected JMenuBar
m_MenuBar
the menubar.protected JMenuItem
m_MenuItemLeftShowHidden
whether left panel shows hidden files.protected JMenuItem
m_MenuItemRightShowHidden
whether right panel shows hidden files.protected JPanel
m_PanelButtons
the panel with the buttons.protected FileCommanderDirectoryPanel
m_PanelLeft
the left panel.protected FileCommanderDirectoryPanel
m_PanelRight
the right panel.protected BaseStatusBar
m_StatusBar
the statusbar.protected boolean
m_Stopped
whether the operation was stopped by the user.protected SwingWorker
m_Worker
the worker thread.-
Fields inherited from class adams.gui.core.BasePanel
m_FileChooser
-
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
-
Fields inherited from class java.awt.Component
accessibleContext, 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
Constructors Constructor Description FileCommanderPanel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
chooserChanged(FileCommanderDirectoryPanel source)
Gets called when a panel's chooser changes.void
copy()
Copies the selected files to the other directory.void
delete()
Deletes the selected files.protected void
finishInit()
Finishes the initialization.FileCommanderDirectoryPanel
getActive()
Returns the currently active panel.String
getDirectory(boolean left)
Returns the current directory.FileCommanderDirectoryPanel
getInactive()
Returns the currently inactive panel.JMenuBar
getMenuBar()
Creates a menu bar (singleton per panel object).protected void
initGUI()
Initializes the widgets.protected void
initialize()
Initializes the members.boolean
isBusy()
Returns whether we're currently busy.boolean
isStopped()
Whether the execution has been stopped.void
mkdir()
Creates a new directory.void
move()
Moves multiple selected files to the other directory.void
quit()
Closes the commander.protected void
reload()
Reloads the files.void
rename()
Renames a file.void
setActive(FileCommanderDirectoryPanel active)
Updates the active state of the panel.void
setDirectory(String dir, boolean left)
Sets the current directory.protected void
setFilter(boolean left)
Prompts the user to enter a regular expression as filter.void
showStatus(boolean left, String msg)
Displays a message.void
showStatus(String msg)
Displays a message.void
stopExecution()
Stops the execution.protected void
updateButtons()
Updates the state of the buttons.protected void
updateFileOperations()
Updates the file operations object.protected void
view()
Views the selected file.-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, beforeShow, closeParent, getParentChild, getParentDialog, getParentFrame, getParentInternalFrame, getParentTitle, initFileChooser, main, printErrorMessage, printException, saveComponent, setEnabledCascade, setEnabledCascade, setParentTitle, setVisible
-
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, 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, 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
-
m_PanelLeft
protected FileCommanderDirectoryPanel m_PanelLeft
the left panel.
-
m_PanelRight
protected FileCommanderDirectoryPanel m_PanelRight
the right panel.
-
m_FilesActive
protected FileCommanderDirectoryPanel m_FilesActive
the active panel.
-
m_FilesInactive
protected FileCommanderDirectoryPanel m_FilesInactive
the inactive panel.
-
m_PanelButtons
protected JPanel m_PanelButtons
the panel with the buttons.
-
m_ButtonReload
protected BaseFlatButton m_ButtonReload
the button for reloading the files.
-
m_ButtonRename
protected BaseFlatButton m_ButtonRename
the button for renaming.
-
m_ButtonView
protected BaseFlatButton m_ButtonView
the button for viewing the file.
-
m_ButtonCopy
protected BaseFlatButton m_ButtonCopy
the button for copying the file.
-
m_ButtonMove
protected BaseFlatButton m_ButtonMove
the button for moving.
-
m_ButtonMkDir
protected BaseFlatButton m_ButtonMkDir
the button for creating a directory.
-
m_ButtonDelete
protected BaseFlatButton m_ButtonDelete
the button for deleting.
-
m_ButtonAction
protected BaseSplitButton m_ButtonAction
the action button.
-
m_ButtonStop
protected BaseFlatButton m_ButtonStop
the button for stopping an operation.
-
m_ButtonQuit
protected BaseFlatButton m_ButtonQuit
the button for quitting.
-
m_StatusBar
protected BaseStatusBar m_StatusBar
the statusbar.
-
m_MenuBar
protected JMenuBar m_MenuBar
the menubar.
-
m_MenuItemLeftShowHidden
protected JMenuItem m_MenuItemLeftShowHidden
whether left panel shows hidden files.
-
m_MenuItemRightShowHidden
protected JMenuItem m_MenuItemRightShowHidden
whether right panel shows hidden files.
-
m_Worker
protected SwingWorker m_Worker
the worker thread.
-
m_Actions
protected List<AbstractFileCommanderAction> m_Actions
the available actions.
-
m_FileOperations
protected FileOperations m_FileOperations
the current file operations.
-
m_Stopped
protected boolean m_Stopped
whether the operation was stopped by the user.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classBasePanel
-
finishInit
protected void finishInit()
Finishes the initialization.- Overrides:
finishInit
in classBasePanel
-
setActive
public void setActive(FileCommanderDirectoryPanel active)
Updates the active state of the panel.- Parameters:
active
- the new active panel
-
updateButtons
protected void updateButtons()
Updates the state of the buttons.
-
getMenuBar
public JMenuBar getMenuBar()
Creates a menu bar (singleton per panel object). Can be used in frames.- Specified by:
getMenuBar
in interfaceMenuBarProvider
- Returns:
- the menu bar
-
isBusy
public boolean isBusy()
Returns whether we're currently busy.- Returns:
- true if busy
-
setDirectory
public void setDirectory(String dir, boolean left)
Sets the current directory.- Parameters:
dir
- the directory to useleft
- if true the left panel gets updated
-
getDirectory
public String getDirectory(boolean left)
Returns the current directory.- Parameters:
left
- if true the directory of the left panel is retrieved- Returns:
- the current directory
-
reload
protected void reload()
Reloads the files.
-
view
protected void view()
Views the selected file.
-
copy
public void copy()
Copies the selected files to the other directory.
-
rename
public void rename()
Renames a file.
-
move
public void move()
Moves multiple selected files to the other directory.
-
mkdir
public void mkdir()
Creates a new directory.
-
delete
public void delete()
Deletes the selected files.
-
quit
public void quit()
Closes the commander.
-
setFilter
protected void setFilter(boolean left)
Prompts the user to enter a regular expression as filter.- Parameters:
left
- whether to apply it to the left or right panel
-
getActive
public FileCommanderDirectoryPanel getActive()
Returns the currently active panel.- Returns:
- the active panel
-
getInactive
public FileCommanderDirectoryPanel getInactive()
Returns the currently inactive panel.- Returns:
- the inactive panel
-
showStatus
public void showStatus(String msg)
Displays a message.- Specified by:
showStatus
in interfaceStatusMessageHandler
- Parameters:
msg
- the message to display
-
showStatus
public void showStatus(boolean left, String msg)
Displays a message.- Specified by:
showStatus
in interfaceStatusMessageHandlerExt
- Parameters:
left
- whether to show the message on the left or rightmsg
- the message to display
-
updateFileOperations
protected void updateFileOperations()
Updates the file operations object.
-
chooserChanged
protected void chooserChanged(FileCommanderDirectoryPanel source)
Gets called when a panel's chooser changes.- Parameters:
source
- the panel that triggered the event
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceStoppable
-
isStopped
public boolean isStopped()
Whether the execution has been stopped.- Specified by:
isStopped
in interfaceStoppableWithFeedback
- Returns:
- true if stopped
-
-