Class ProjectView
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- ca.cgjennings.apps.arkham.project.ProjectView
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
public final class ProjectView extends javax.swing.JPanel
A view that displays the open project.- Author:
- Chris Jennings
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ProjectView.ProjectViewEvent
The event object supplied to listeners of project view events when an event is fired.static interface
ProjectView.SelectionListener
A listener that is notified of changes to the project selection.-
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 static java.lang.String
VIEW_CLOSING_PROPERTY
The property name of a property change event that is fired when this view is about to close.-
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
-
-
Constructor Summary
Constructors Constructor Description ProjectView()
Creates a new project view.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSelectionListener(ProjectView.SelectionListener li)
Adds a new selection listener that will be notified when then project selection changes.void
addToSelection(Member m)
Selects the specified member in the project view without clearing the current selection.void
clearSelection()
Clears the current project member selection.void
collapseAll(Member folder)
Collapses the specified folder and all of its children.void
collapseFolder(Member m)
If the specified member is a folder, task, or project with children, the member's visual representation will be collapsed to make those children invisible.void
copy()
Copies the currently selected members to the clipboard as a file selection.void
cut()
Cuts the currently selected members to the clipboard as a file selection.void
dispose()
Releases resources held by this view.void
ensureVisible(Member m)
Scrolls the view, if required, so that the specified member is visible.void
expandAll(Member folder)
Expands the specified folder and all of its children.void
expandFolder(Member m)
If the specified member is a folder, task, or project with children, the member's visual representation will be expanded to make those children visible.protected void
fireProjectSelectionChanged()
Notifies registered listeners that the selection has changed.Project
getProject()
Member[]
getSelectedMembers()
Returns an array of the currently selected members.boolean
isFolderCollpased(Member m)
Returnstrue
if the specified member is a folder, task, or project with children, and the member's visual representation is currently collapsed.void
moveToLocusOfAttention(java.awt.Window window)
Place a window near the (inferred) locus of attention in the project view.void
moveToLocusOfAttention(java.awt.Window window, int cascade)
Place a window near the (inferred) locus of attention in the project view.void
paste()
Pastes the current clipboard contents into the selected project member, is possible.static void
registerViewTab(ViewTab viewTab)
Registers a new custom view tab to be displayed in project views.void
removeSelectionListener(ProjectView.SelectionListener li)
Removes a previously registered selection listener.void
repaint(Member m)
Updates the visual representation of the specified member.void
select(Member m)
Selects the specified member in the project view.void
setAccelerator(TaskAction ta, java.lang.String keystroke, boolean command)
Sets an accelerator used by this view for aTaskAction
.void
setFindInProjectsVisible(boolean visible)
void
setProject(Project project)
static void
unregisterViewTab(ViewTab viewTab)
Unregisters a previously registered custom view tab.-
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, 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
-
VIEW_CLOSING_PROPERTY
public static final java.lang.String VIEW_CLOSING_PROPERTY
The property name of a property change event that is fired when this view is about to close. To listen for the active project being closed, rather than a specific view, register aProjectEventListener
with the application window instead.
-
-
Method Detail
-
setFindInProjectsVisible
public void setFindInProjectsVisible(boolean visible)
-
setProject
public void setProject(Project project)
-
getProject
public Project getProject()
-
repaint
public void repaint(Member m)
Updates the visual representation of the specified member.- Parameters:
m
- the member whose visual representation should be repainted
-
ensureVisible
public void ensureVisible(Member m)
Scrolls the view, if required, so that the specified member is visible.- Parameters:
m
- the member to scroll into view
-
select
public void select(Member m)
Selects the specified member in the project view.- Parameters:
m
- the member to select
-
addToSelection
public void addToSelection(Member m)
Selects the specified member in the project view without clearing the current selection.- Parameters:
m
- the member to add to the current selection
-
clearSelection
public void clearSelection()
Clears the current project member selection.
-
getSelectedMembers
public Member[] getSelectedMembers()
Returns an array of the currently selected members. If no members are selected, an empty array is returned.- Returns:
- an array of the selected members
-
addSelectionListener
public void addSelectionListener(ProjectView.SelectionListener li)
Adds a new selection listener that will be notified when then project selection changes.- Parameters:
li
- the listener to add- See Also:
removeSelectionListener(ca.cgjennings.apps.arkham.project.ProjectView.SelectionListener)
-
removeSelectionListener
public void removeSelectionListener(ProjectView.SelectionListener li)
Removes a previously registered selection listener.- Parameters:
li
- the listener to remove- See Also:
addSelectionListener(ca.cgjennings.apps.arkham.project.ProjectView.SelectionListener)
-
fireProjectSelectionChanged
protected void fireProjectSelectionChanged()
Notifies registered listeners that the selection has changed.
-
expandFolder
public void expandFolder(Member m)
If the specified member is a folder, task, or project with children, the member's visual representation will be expanded to make those children visible.- Parameters:
m
- the member whose children should be displayed- See Also:
collapseFolder(ca.cgjennings.apps.arkham.project.Member)
,isFolderCollpased(ca.cgjennings.apps.arkham.project.Member)
-
collapseFolder
public void collapseFolder(Member m)
If the specified member is a folder, task, or project with children, the member's visual representation will be collapsed to make those children invisible.If the view displays project members as a tree with nodes that can be opened and closed to display or hide their contents, then this method closes the tree node that represents the member. Other possible view implementations might use a different representation for tree nodes, in which case this method will have a different visual interpretation or may even have no effect at all.
- Parameters:
m
- the member whose children should be displayed
-
isFolderCollpased
public boolean isFolderCollpased(Member m)
Returnstrue
if the specified member is a folder, task, or project with children, and the member's visual representation is currently collapsed.- Parameters:
m
- the member whose status is being queried- Returns:
true
if the member is visually collapsed
-
collapseAll
public void collapseAll(Member folder)
Collapses the specified folder and all of its children.- Parameters:
folder
- the folder to collapse- See Also:
collapseFolder(ca.cgjennings.apps.arkham.project.Member)
-
expandAll
public void expandAll(Member folder)
Expands the specified folder and all of its children.- Parameters:
folder
- the folder to expand- See Also:
expandFolder(ca.cgjennings.apps.arkham.project.Member)
-
copy
public void copy()
Copies the currently selected members to the clipboard as a file selection.
-
cut
public void cut()
Cuts the currently selected members to the clipboard as a file selection. Note that the members are not deleted immediately, but will only be deleted if the clipboard contents are pasted. On some platforms, cut will only work delete the original files when they are pasted within the application; otherwise they will be copied instead.
-
paste
public void paste()
Pastes the current clipboard contents into the selected project member, is possible. The following clipboard data types can be pasted into a project:- files
- The appropriate file is copied into the destination folder.
- images
- The image will be written into a new .png image file. Be aware that some operating systems (notably Windows) do not include transparency information (the alpha channel) for images on the clipboard. Typically this means that if the copied image has transparency it will be placed on the clipboard as if drawn over a solid black background).
- URLs (as copied text)
- If the text on the clipboard appears to be a URL, then the contents of the URL will be downloaded and written to a new file in the folder.
-
moveToLocusOfAttention
public void moveToLocusOfAttention(java.awt.Window window)
Place a window near the (inferred) locus of attention in the project view. This would be used, for example, to open a small editor or dialog box in response to the user selecting a command in the project view. This is a convenince formoveToLocusOfAttention( w, 0 )
.- Parameters:
window
- the window to position
-
moveToLocusOfAttention
public void moveToLocusOfAttention(java.awt.Window window, int cascade)
Place a window near the (inferred) locus of attention in the project view. This would be used, for example, to open a small editor or dialog box in response to the user selecting a command in the project view.- Parameters:
window
- the window to positioncascade
- if positioning multiple related windows, use this to offset the resulting windows
-
setAccelerator
public void setAccelerator(TaskAction ta, java.lang.String keystroke, boolean command)
Sets an accelerator used by this view for aTaskAction
. Ifcommand
is true, then a key stroke should represent a plain key (such as "F1"); a modifier key prefix will be added automatically based on the platform.- Parameters:
ta
- the action to set an accelerator forkeystroke
- a description of the accelerator keycommand
- whether modifiers should be generated automatically
-
dispose
public void dispose()
Releases resources held by this view. Failure to call this when closing a project could result in a resource leak. After calling this method, this view should not be added to a container or otherwise made visible.
-
registerViewTab
public static void registerViewTab(ViewTab viewTab)
Registers a new custom view tab to be displayed in project views.- Parameters:
viewTab
- the view tab instance to register- Throws:
java.lang.NullPointerException
- if the view tab isnull
java.lang.IllegalArgumentException
- if the view tab's name isnull
- See Also:
ViewTab.getViewTabName()
-
unregisterViewTab
public static void unregisterViewTab(ViewTab viewTab)
Unregisters a previously registered custom view tab.- Parameters:
viewTab
- the view tab instance to unregister
-
-