Package ca.cgjennings.apps.arkham.diy
Class DIYEditor
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JInternalFrame
-
- ca.cgjennings.apps.arkham.AbstractStrangeEonsEditor
-
- ca.cgjennings.apps.arkham.AbstractGameComponentEditor<DIY>
-
- ca.cgjennings.apps.arkham.diy.DIYEditor
-
- All Implemented Interfaces:
Commandable
,StrangeEonsEditor
,java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
,javax.swing.RootPaneContainer
,javax.swing.WindowConstants
public class DIYEditor extends AbstractGameComponentEditor<DIY>
The game component editor used to edit scriptableDIY
components.- Since:
- 2.1
- Author:
- Chris Jennings
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JInternalFrame
javax.swing.JInternalFrame.AccessibleJInternalFrame, javax.swing.JInternalFrame.JDesktopIcon
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
-
Nested classes/interfaces inherited from interface ca.cgjennings.apps.arkham.StrangeEonsEditor
StrangeEonsEditor.EditorListener, StrangeEonsEditor.FieldPopulationListener, StrangeEonsEditor.HeartbeatListener
-
-
Field Summary
-
Fields inherited from class ca.cgjennings.apps.arkham.AbstractGameComponentEditor
previewSplitPane, sheets, viewers
-
Fields inherited from class ca.cgjennings.apps.arkham.AbstractStrangeEonsEditor
DEFAULT_EDITOR_ICON
-
Fields inherited from class javax.swing.JInternalFrame
closable, CONTENT_PANE_PROPERTY, desktopIcon, FRAME_ICON_PROPERTY, frameIcon, GLASS_PANE_PROPERTY, iconable, IS_CLOSED_PROPERTY, IS_ICON_PROPERTY, IS_MAXIMUM_PROPERTY, IS_SELECTED_PROPERTY, isClosed, isIcon, isMaximum, isSelected, LAYERED_PANE_PROPERTY, maximizable, MENU_BAR_PROPERTY, resizable, ROOT_PANE_PROPERTY, rootPane, rootPaneCheckingEnabled, title, TITLE_PROPERTY
-
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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.swing.border.Border
getBorder()
javax.swing.Icon
getFrameIcon()
Returns the editor window icon.PortraitPanel
getMarkerPanel()
Returns the portrait panel for the component's built-in marker portrait.PortraitPanel
getPortraitPanel()
Returns the portrait panel for the component's built-in portrait.SheetViewer
getSheetViewer(int index)
Returns the sheet viewer that is displaying the face with the specified index.javax.swing.JTabbedPane
getTabbedPane()
Returns the tabbed pane that component editing panels are placed in.boolean
hasUnsavedChanges()
Returnstrue
if the edited game component has unsaved changes.boolean
isAttached()
Returnstrue
if this editor is currently attached to the document tab strip.boolean
isCommandApplicable(AbstractCommand command)
Returnstrue
if thecommand
can be performed by this commandable in its current state.boolean
isTestModeEnabled()
Returnstrue
if test mode is enabled.protected void
populateComponentFromDelayedFields()
This method is called during heartbeats to allow the editor to update properties of the game component that either cannot be updated in response to events or that are more efficient when updated periodically instead of immediately.void
populateFieldsFromComponent()
Updates the editor with the current contents of the game component.void
removeCustomTabs()
Removes all editor tabs that were added using script code via theuilayout
library'sAbstractContainer.addToEditor
method.void
replaceEditedComponent(DIY diy)
Replace the currently edited component.void
setAttached(boolean attach)
Sets whether this editor is attached to the document tab strip.void
setFrameIcon(javax.swing.Icon icon)
Sets the preferred icon to use for this editor window.void
setTestModeEnabled(boolean enable)
Sets whether test mode is enabled.-
Methods inherited from class ca.cgjennings.apps.arkham.AbstractGameComponentEditor
addFieldPopulationListener, canPerformCommand, clearImpl, dispose, export, exportImpl, fireFieldPopulationEvent, forceRerender, getDefaultFileName, getFileNameExtension, getFileTypeDescription, getGameComponent, getSelectedSheet, getSelectedSheetIndex, getSheet, getSheetCount, getSheetLabels, handleOpenRequest, initializeSheetViewers, localizeComboBoxLabels, localizeComboBoxLabels, localizeComponentTree, localizeForPlatform, onHeartbeat, performCommand, printImpl, redrawPreview, removeFieldPopulationListener, save, saveAs, saveImpl, setDesignSupport, setGameComponent, setSelectedSheetIndex, setUnsavedChanges, spinOff, spinOffImpl, updateSheetViewers
-
Methods inherited from class ca.cgjennings.apps.arkham.AbstractStrangeEonsEditor
addEditorListener, addHeartbeatListener, clear, close, confirmLossOfUnsavedChanges, createTimer, createTimer, doDefaultCloseAction, fireHeartbeatEvent, getFile, getTabStripPopupMenu, getTitle, getToolTipText, print, removeAllStrangeEonsListeners, removeEditorListener, removeHeartbeatListener, resumeTimedUpdates, select, setFile, setTitle, setToolTipText, stopTimedUpdates, toString
-
Methods inherited from class javax.swing.JInternalFrame
addImpl, addInternalFrameListener, createRootPane, fireInternalFrameEvent, getAccessibleContext, getContentPane, getDefaultCloseOperation, getDesktopIcon, getDesktopPane, getFocusCycleRootAncestor, getFocusOwner, getGlassPane, getInternalFrameListeners, getJMenuBar, getLastCursor, getLayer, getLayeredPane, getMenuBar, getMostRecentFocusOwner, getNormalBounds, getRootPane, getUI, getUIClassID, getWarningString, hide, isClosable, isClosed, isFocusCycleRoot, isIcon, isIconifiable, isMaximizable, isMaximum, isResizable, isRootPaneCheckingEnabled, isSelected, moveToBack, moveToFront, pack, paintComponent, paramString, remove, removeInternalFrameListener, reshape, restoreSubcomponentFocus, setClosable, setClosed, setContentPane, setCursor, setDefaultCloseOperation, setDesktopIcon, setFocusCycleRoot, setGlassPane, setIcon, setIconifiable, setJMenuBar, setLayer, setLayer, setLayeredPane, setLayout, setMaximizable, setMaximum, setMenuBar, setNormalBounds, setResizable, setRootPane, setRootPaneCheckingEnabled, setSelected, setUI, show, toBack, toFront, 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, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, 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, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, 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, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, 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, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ca.cgjennings.apps.arkham.StrangeEonsEditor
getFrameIcon, isAttached, setAttached, setFrameIcon
-
-
-
-
Constructor Detail
-
DIYEditor
public DIYEditor(DIY diy)
-
DIYEditor
public DIYEditor()
-
-
Method Detail
-
setTestModeEnabled
public void setTestModeEnabled(boolean enable)
Sets whether test mode is enabled. When enabled, the editor will never indicate that it has unsaved changes and neither theSAVE
norSAVE_AS
commands will be considered applicable. Thediy
scripting library'stestDIYScript()
function will call this method to enable test mode on the editor it creates.- Parameters:
enable
- iftrue
, test mode will be enabled- See Also:
isTestModeEnabled()
,hasUnsavedChanges()
,isCommandApplicable(ca.cgjennings.apps.arkham.commands.AbstractCommand)
-
isTestModeEnabled
public boolean isTestModeEnabled()
Returnstrue
if test mode is enabled.- Returns:
true
if the editor's test mode is enabled
-
populateComponentFromDelayedFields
protected void populateComponentFromDelayedFields()
Description copied from class:AbstractGameComponentEditor
This method is called during heartbeats to allow the editor to update properties of the game component that either cannot be updated in response to events or that are more efficient when updated periodically instead of immediately. If a component has no properties that fit this description, then subclasses can provide an empty implementation.- Specified by:
populateComponentFromDelayedFields
in classAbstractGameComponentEditor<DIY>
-
populateFieldsFromComponent
public void populateFieldsFromComponent()
Description copied from class:AbstractGameComponentEditor
Updates the editor with the current contents of the game component. Subclasses should call the super implementation last to ensure that field population events are fired to any listeners.- Overrides:
populateFieldsFromComponent
in classAbstractGameComponentEditor<DIY>
-
removeCustomTabs
public void removeCustomTabs()
Removes all editor tabs that were added using script code via theuilayout
library'sAbstractContainer.addToEditor
method.
-
replaceEditedComponent
public void replaceEditedComponent(DIY diy)
Description copied from class:AbstractGameComponentEditor
Replace the currently edited component. This consists of the following steps:- if
newComponent
has an on-install event in its private settings, then the on-install event is called - the editor is updated to point to
newComponent
and it creates a new set of sheets fromnewComponent
and installs them in the preview window - the current state of
newComponent
is copied from the component to the editor controls
- Overrides:
replaceEditedComponent
in classAbstractGameComponentEditor<DIY>
- Parameters:
diy
- the new component to edit with this editor
- if
-
getPortraitPanel
public PortraitPanel getPortraitPanel()
Returns the portrait panel for the component's built-in portrait. If there is no built-in portrait, returnsnull
.- Returns:
- the portrait panel for the built-in portrait, or
null
-
getMarkerPanel
public PortraitPanel getMarkerPanel()
Returns the portrait panel for the component's built-in marker portrait. If there is no built-in marker portrait, returnsnull
.- Returns:
- the portrait panel for the built-in marker, or
null
-
getTabbedPane
public javax.swing.JTabbedPane getTabbedPane()
Returns the tabbed pane that component editing panels are placed in.- Returns:
- the tabbed pane that is the ancestor of the editing controls
-
getSheetViewer
public SheetViewer getSheetViewer(int index)
Returns the sheet viewer that is displaying the face with the specified index.- Parameters:
index
- the index of the face to obtain the view for- Returns:
- the requested sheet viewer
- Throws:
java.lang.IndexOutOfBoundsException
- if the sheet index is less than 0 or greater than or equal to the number of faces
-
hasUnsavedChanges
public boolean hasUnsavedChanges()
Description copied from class:AbstractGameComponentEditor
Returnstrue
if the edited game component has unsaved changes.- Specified by:
hasUnsavedChanges
in interfaceStrangeEonsEditor
- Overrides:
hasUnsavedChanges
in classAbstractGameComponentEditor<DIY>
- Returns:
true
if the game component has been edited since the last time it was saved- See Also:
AbstractStrangeEonsEditor.setUnsavedChanges(boolean)
-
isCommandApplicable
public boolean isCommandApplicable(AbstractCommand command)
Description copied from class:AbstractStrangeEonsEditor
Returnstrue
if thecommand
can be performed by this commandable in its current state. IfCommandable.canPerformCommand(ca.cgjennings.apps.arkham.commands.AbstractCommand)
would return false for this command, then this must also return false. The base class returns the value ofAbstractStrangeEonsEditor.canPerformCommand(ca.cgjennings.apps.arkham.commands.AbstractCommand)
, except that if the command is SAVE, it returns false if the editor does not have unsaved changes.- Specified by:
isCommandApplicable
in interfaceCommandable
- Specified by:
isCommandApplicable
in interfaceStrangeEonsEditor
- Overrides:
isCommandApplicable
in classAbstractGameComponentEditor<DIY>
- Parameters:
command
- the command to be performed- Returns:
true
if this commandable can currently perform the command
-
getBorder
public final javax.swing.border.Border getBorder()
- Overrides:
getBorder
in classjavax.swing.JComponent
-
setFrameIcon
public void setFrameIcon(javax.swing.Icon icon)
Sets the preferred icon to use for this editor window. This icon may be used to represent the window in various parts of the application interface. Possible example uses include the following: the document tab, the editor's item in the Window menu, and the frame icon of the editor's detached window. Note, however, that there is no guarantee that the icon will be used, or how. Furthermore, the icon may be used in modified form.- Overrides:
setFrameIcon
in classjavax.swing.JInternalFrame
- Parameters:
icon
- the preferred icon for the editor window- See Also:
JInternalFrame.getFrameIcon()
-
getFrameIcon
public javax.swing.Icon getFrameIcon()
Returns the editor window icon.- Overrides:
getFrameIcon
in classjavax.swing.JInternalFrame
- Returns:
- the icon for the editor, or
null
if no icon is set
-
setAttached
public void setAttached(boolean attach)
Sets whether this editor is attached to the document tab strip. Iftrue
, the editor is attached; this is the default state for new editors. Iffalse
, the editor is detached from the tab strip. When detached, the editor appears in its own floating window separate from the main application window. The editor reattaches when the window is closed.- Parameters:
attach
- iftrue
, attaches the window to the tab strip
-
isAttached
public boolean isAttached()
Returnstrue
if this editor is currently attached to the document tab strip.- Returns:
true
if the editor is attached- See Also:
setAttached(boolean)
-
-