Class AbstractGameComponentEditor<G extends GameComponent>
- 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<G>
-
- Type Parameters:
G- the type of game component to be edited
- All Implemented Interfaces:
Commandable,StrangeEonsEditor,java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,javax.accessibility.Accessible,javax.swing.RootPaneContainer,javax.swing.WindowConstants
- Direct Known Subclasses:
DeckEditor,DIYEditor,MarkerEditor
public abstract class AbstractGameComponentEditor<G extends GameComponent> extends AbstractStrangeEonsEditor
The abstract base class forGameComponenteditors. Editors for components based on compiled code will typically be a direct subclass ofAbstractGameComponentEditor. Editors for components based on DIY scripts useDIYEditors.- Since:
- 3.0
- 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 Modifier and Type Field Description protected javax.swing.JSplitPanepreviewSplitPaneprotected Sheet<G>[]sheetsprotected SheetViewer[]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
-
-
Constructor Summary
Constructors Constructor Description AbstractGameComponentEditor()Creates a new abstract game component editor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddFieldPopulationListener(StrangeEonsEditor.FieldPopulationListener fpl)Adds a newFieldPopulationListenerto this game component editor.booleancanPerformCommand(AbstractCommand command)Returnstrueif the commandable wishes to handle the given command.protected voidclearImpl()Clears the component by calling itsGameComponent.clearAll()method, then repopulating the editor controls.voiddispose()Releases resources when the editor will no longer be used.voidexport()Exports the editor content as a different file format.protected voidexportImpl()The default export implementation for game components.protected voidfireFieldPopulationEvent()Called to fire a field population event when the editor's controls are filled in to match the edited game component.voidforceRerender()Deprecated.Replaced byredrawPreview().javax.swing.border.BordergetBorder()protected java.lang.StringgetDefaultFileName()Returns a default file name for a game component that hasn't been saved.java.lang.StringgetFileNameExtension()Returns the standard file extension for the type of content displayed in this editor.java.lang.StringgetFileTypeDescription()Returns a description of the content displayed in this editor.javax.swing.IcongetFrameIcon()Returns the editor window icon.GgetGameComponent()Returns the edited game component.Sheet<G>getSelectedSheet()Returns the sheet displayed by the currently selected previewer.intgetSelectedSheetIndex()Returns the index of the sheet displayed by the currently selected previewer.Sheet<G>getSheet(int index)Returns the sheet being displayed by the sheet viewer with the specified index.intgetSheetCount()Returns the number ofSheets being previewed by this editor (may be 0).java.lang.String[]getSheetLabels()Returns an array of labels that can be used to describe the component's sheets.voidhandleOpenRequest(G newComponent, java.io.File path)After installing the component, make sure you update the component object.booleanhasUnsavedChanges()Returnstrueif the edited game component has unsaved changes.protected voidinitializeSheetViewers(javax.swing.JTabbedPane container)Initializes the sheet viewers for an editor.booleanisAttached()Returnstrueif this editor is currently attached to the document tab strip.booleanisCommandApplicable(AbstractCommand command)Returnstrueif thecommandcan be performed by this commandable in its current state.static voidlocalizeComboBoxLabels(javax.swing.JComboBox<java.lang.String> box, java.lang.String prefix)Iterates over the items in a combo box, replacing any whosetoString()value begins with the prefix string with a localized string.static voidlocalizeComboBoxLabels(Language lang, javax.swing.JComboBox<java.lang.String> box, java.lang.String prefix)toString()value begins with the prefix string with a localized string.static voidlocalizeComponentTree(javax.swing.JComponent root)Recursively adjust a tree of components in this editor for the host platform.protected voidlocalizeForPlatform()Make any special changes needed to localize this editor for the host platform.protected voidonHeartbeat()This method is called once for each tick of the heartbeat timer.voidperformCommand(AbstractCommand command)Performs the command.protected abstract voidpopulateComponentFromDelayedFields()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.voidpopulateFieldsFromComponent()Updates the editor with the current contents of the game component.protected voidprintImpl(java.awt.print.PrinterJob job)Implementation of the print command for standard game components.voidredrawPreview()Forces the editor to redraw its component preview.voidremoveFieldPopulationListener(StrangeEonsEditor.FieldPopulationListener fpl)Removes aFieldPopulationListenerfrom this game component editor.voidreplaceEditedComponent(G newComponent)Replace the currently edited component.voidsave()Saves this editor's content to its current save location.voidsaveAs()Saves this editor's content to a file selected by the user.protected voidsaveImpl(java.io.File f)Saves the editor content to the specified file.voidsetAttached(boolean attach)Sets whether this editor is attached to the document tab strip.voidsetDesignSupport(DesignSupport<G> ds)Sets the design support for this editor.voidsetFrameIcon(javax.swing.Icon icon)Sets the preferred icon to use for this editor window.voidsetGameComponent(G component)Sets the edited game component.voidsetSelectedSheetIndex(int index)Selects the previewer for the sheet with the specified index.voidsetUnsavedChanges(boolean isDirty)Marks whether the game component has unsaved changes.StrangeEonsEditorspinOff()Creates a duplicate of this editor.protected StrangeEonsEditorspinOffImpl()Subclasses should override this to clone the edited document if SPIN_OFF is a supported command.protected voidupdateSheetViewers()Refreshes the sheets being displayed by the sheet viewers within the container most recently passed toinitializeSheetViewers(javax.swing.JTabbedPane).-
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
-
-
-
-
Field Detail
-
previewSplitPane
protected javax.swing.JSplitPane previewSplitPane
-
sheets
protected Sheet<G extends GameComponent>[] sheets
-
viewers
protected SheetViewer[] viewers
-
-
Method Detail
-
localizeForPlatform
protected void localizeForPlatform()
Make any special changes needed to localize this editor for the host platform. The base implementation is intended for game component editors.
-
localizeComponentTree
public static void localizeComponentTree(javax.swing.JComponent root)
Recursively adjust a tree of components in this editor for the host platform.- Parameters:
root- the root of the tree to localize- See Also:
localizeForPlatform()
-
setDesignSupport
public void setDesignSupport(DesignSupport<G> ds)
Sets the design support for this editor. A design support provides feedback on the state of the design as the user edits it. Design supports provide a view component that is displayed below the standard editing tabs.- Parameters:
ds- the design support for this editor
-
replaceEditedComponent
public void replaceEditedComponent(G newComponent)
Replace the currently edited component. This consists of the following steps:- if
newComponenthas an on-install event in its private settings, then the on-install event is called - the editor is updated to point to
newComponentand it creates a new set of sheets fromnewComponentand installs them in the preview window - the current state of
newComponentis copied from the component to the editor controls
- Parameters:
newComponent- the new component to edit with this editor
- if
-
handleOpenRequest
public void handleOpenRequest(G newComponent, java.io.File path)
After installing the component, make sure you update the component object.- Parameters:
newComponent- the new component being openedpath- the file path from which the component was loaded
-
save
public void save()
Description copied from class:AbstractStrangeEonsEditorSaves this editor's content to its current save location. If it has not been saved previously, and the command is supported, the user will be prompted to select a file (seeStrangeEonsEditor.saveAs()).Note that an editor can support the SAVE_AS command without supporting the SAVE command, but not vice-versa. This implementation handles the details of determining the file to be written and exception handling. If
AbstractStrangeEonsEditor.getFile()returnsnull, this method callsAbstractStrangeEonsEditor.saveAs()to determine the file to save to. Otherwise, it callsAbstractStrangeEonsEditor.saveImpl(java.io.File)to write the file. To use it, overrideAbstractStrangeEonsEditor.saveImpl(java.io.File).- Specified by:
savein interfaceStrangeEonsEditor- Overrides:
savein classAbstractStrangeEonsEditor- See Also:
StrangeEonsEditor.canPerformCommand(ca.cgjennings.apps.arkham.commands.AbstractCommand)
-
saveAs
public void saveAs()
Description copied from class:AbstractStrangeEonsEditorSaves this editor's content to a file selected by the user. The user may cancel the operation. If the save is performed, then the selected file will become the new save path for the component. This implementation handles the details of determining the file to be written and exception handling. It shows a save dialog and, if the user accepts the dialog, callssetFileto set the save file based on the user's selection. It then callsAbstractStrangeEonsEditor.save()to save the file to the new destination. To use it, overrideStrangeEonsEditor.getFileNameExtension()andStrangeEonsEditor.getFileTypeDescription()to describe the file type's standard extension and type, and overrideAbstractStrangeEonsEditor.saveImpl(java.io.File)to write the file.- Specified by:
saveAsin interfaceStrangeEonsEditor- Overrides:
saveAsin classAbstractStrangeEonsEditor- See Also:
StrangeEonsEditor.canPerformCommand(ca.cgjennings.apps.arkham.commands.AbstractCommand)
-
saveImpl
protected void saveImpl(java.io.File f) throws java.io.IOExceptionDescription copied from class:AbstractStrangeEonsEditorSaves the editor content to the specified file. This method is called by {link #save} in response to save requests. Subclasses must override it to write an appropriate file for the document if the editor supports saving.- Overrides:
saveImplin classAbstractStrangeEonsEditor- Parameters:
f- the file to write content to- Throws:
java.io.IOException- if the save fails
-
getDefaultFileName
protected java.lang.String getDefaultFileName()
Returns a default file name for a game component that hasn't been saved.- Returns:
- a default file name, including extension, based on the name of the installed component
-
getSheetLabels
public java.lang.String[] getSheetLabels()
Returns an array of labels that can be used to describe the component's sheets. The returned array uses the same order asGameComponent.getSheets(). The base class implementation is equivalent to callinggetGameComponent().getSheetTitles().Note that the returned array is shared. If you need to modify its contents, clone the array first and modify the clone.
- Returns:
- a shared array of sheet labels
-
getSelectedSheet
public Sheet<G> getSelectedSheet()
Returns the sheet displayed by the currently selected previewer.- Returns:
- the selected sheet
-
getSelectedSheetIndex
public int getSelectedSheetIndex()
Returns the index of the sheet displayed by the currently selected previewer.- Returns:
- the selected sheet index, or -1
-
setSelectedSheetIndex
public void setSelectedSheetIndex(int index)
Selects the previewer for the sheet with the specified index. The selected previewer will be made visible.- Parameters:
index- the index of the sheet to select
-
canPerformCommand
public boolean canPerformCommand(AbstractCommand command)
Returnstrueif the commandable wishes to handle the given command. This method defines the set of commands that the commandable responds to. The commandable might not be able to act on the command at the current moment. For example, a commandable that responds to "Cut" could return true from this method, but false fromisCommandApplicable(ca.cgjennings.apps.arkham.commands.AbstractCommand)if there is currently no selection to cut.The base class for game component editors returns true for the following standard commands:
CLEAR,EXPORT,PRINT,SAVE,SAVE_AS, andSPIN_OFF.- Specified by:
canPerformCommandin interfaceCommandable- Specified by:
canPerformCommandin interfaceStrangeEonsEditor- Overrides:
canPerformCommandin classAbstractStrangeEonsEditor- Parameters:
command- the command to be performed- Returns:
trueif this commandable wishes to handle the command (even if it cannot execute the command currently)- See Also:
Commands
-
export
public void export()
Exports the editor content as a different file format. The procedure for exporting and the exact format(s) available will vary with the editor.This method simply checks that the EXPORT command is supported and applicable, and then calls
exportImpl()to perform the export.- Specified by:
exportin interfaceStrangeEonsEditor- Overrides:
exportin classAbstractStrangeEonsEditor- Throws:
java.lang.UnsupportedOperationException- if the EXPORT command is not supported- See Also:
canPerformCommand(ca.cgjennings.apps.arkham.commands.AbstractCommand)
-
exportImpl
protected void exportImpl()
The default export implementation for game components. This implementation displays an export dialog that allows selecting anExportContainer, image file format, and other options, and then writes the game component's sheet images as image files to the export container.- See Also:
ImageExporter,ExportContainer
-
populateFieldsFromComponent
public void populateFieldsFromComponent()
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.
-
populateComponentFromDelayedFields
protected abstract 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. If a component has no properties that fit this description, then subclasses can provide an empty implementation.
-
onHeartbeat
protected void onHeartbeat()
This method is called once for each tick of the heartbeat timer. It the game component is currentlynull, it returns immediately. Otherwise, it callspopulateComponentFromDelayedFields()and then determines if it the previews should be updated. The procedure for determining if previews should be updated is as follows:- If the component has changed since the last heartbeat, then there is an update pending and the previews are known to be out of date.
- If the component has not changed since the last heartbeat, and there is an update pending, then an update is performed as follows:
- If there is a design support attached to the editor, the design support is asked to update the support view
- If the component has any sheets, the preview components for all sheets that are out of date are told to update their sheet images. (They do not update right away unless they are currently visible.)
Note that this means that if the user is making a series of rapid changes, as might happen while typing in a text field, then the preview is not actually updated until there is a pause in editing of at least one heartbeat's duration.
If the editor is using the default label and tool tip for text for its document tab, these are also updated if they have changed.
-
redrawPreview
public void redrawPreview()
Forces the editor to redraw its component preview. Editors normally manage this redrawing automatically. However, if you make an indirect change to a component, such as changing a setting that affects how the card is drawn, the editor will have no way of knowing about this change and the preview will not reflect the change. Calling this method forces all editors to redraw their previews from scratch.- See Also:
StrangeEonsAppWindow.redrawPreviews()
-
forceRerender
@Deprecated public void forceRerender()
Deprecated.Replaced byredrawPreview().
-
initializeSheetViewers
protected void initializeSheetViewers(javax.swing.JTabbedPane container)
Initializes the sheet viewers for an editor. Editors for components that use sheets must call this method with the tabbed pane that will be used to display previewers for the sheets. A default set of sheets will be created for the component, and then the container's children will be replaced by previewers for those sheets. The supplied container will be remembered so that methods such asgetSelectedSheetIndex()work correctly.- Parameters:
container- the control that will house previewers for the sheets
-
updateSheetViewers
protected void updateSheetViewers()
Refreshes the sheets being displayed by the sheet viewers within the container most recently passed toinitializeSheetViewers(javax.swing.JTabbedPane). This can be called if the sheets set on the edited component are changed. Depending on how the sheet configuration changes, the existing sheet viewers may be updated to display the new sheets, or they may be replaced altogether as if by callinginitializeSheetViewers(javax.swing.JTabbedPane).
-
getSheetCount
public int getSheetCount()
Returns the number ofSheets being previewed by this editor (may be 0).- Returns:
- the number of sheet viewer tabs
-
getSheet
public Sheet<G> getSheet(int index)
Returns the sheet being displayed by the sheet viewer with the specified index. Note that since the sheet is being displayed, you should not request sheet images from the sheet yourself. If you wish to create an image of one or more sheets, the safest procedure is to clone the game component, request that it create a set of default sheets, and then use those to draw sheet images as desired.- Parameters:
index- the index of the desired sheet- Returns:
- the sheet at the requested index
- Throws:
java.lang.IndexOutOfBoundsException- if the index does not fall in0 ... {@link #getSheetCount()}-1, inclusive
-
addFieldPopulationListener
public void addFieldPopulationListener(StrangeEonsEditor.FieldPopulationListener fpl)
Adds a newFieldPopulationListenerto this game component editor. A field population event is fired after the editor's controls are modified to match the edited component. This typically happens as part of setting the game component for the editor.- Parameters:
fpl- the listener to add- Since:
- 2.00 (final)
- See Also:
removeFieldPopulationListener(ca.cgjennings.apps.arkham.StrangeEonsEditor.FieldPopulationListener)
-
removeFieldPopulationListener
public void removeFieldPopulationListener(StrangeEonsEditor.FieldPopulationListener fpl)
Removes aFieldPopulationListenerfrom this game component editor.- Parameters:
fpl- the listener to remove- Since:
- 2.00 (final)
- See Also:
addFieldPopulationListener(ca.cgjennings.apps.arkham.StrangeEonsEditor.FieldPopulationListener)
-
fireFieldPopulationEvent
protected final void fireFieldPopulationEvent()
Called to fire a field population event when the editor's controls are filled in to match the edited game component.
-
dispose
public void dispose()
Description copied from class:AbstractStrangeEonsEditorReleases resources when the editor will no longer be used. Note that although windows can typically be redisplayed after being disposed of by simply making them visible, editors are not designed to be used after this method is called.Note: This method should not typically be called by plug-in code. If you wish to close an open editor, call its
AbstractStrangeEonsEditor.close()method instead.- Overrides:
disposein classAbstractStrangeEonsEditor
-
localizeComboBoxLabels
public static void localizeComboBoxLabels(javax.swing.JComboBox<java.lang.String> box, java.lang.String prefix)Iterates over the items in a combo box, replacing any whosetoString()value begins with the prefix string with a localized string. The value of the string is determined by using the existing item'stoString()value as a key. This makes it easy to create localized combo boxes with fixed entries in the form editor. If prefix isnull, all items in the list will be localized.- Parameters:
box- the combo box whose labels should be localizedprefix- a prefix string that will identify labels that are string table keys
-
localizeComboBoxLabels
public static void localizeComboBoxLabels(Language lang, javax.swing.JComboBox<java.lang.String> box, java.lang.String prefix)
toString()value begins with the prefix string with a localized string. The value of the string is determined by using the existing item'stoString()value as a key. This makes it easy to create localized combo boxes with fixed entries in the form editor. If prefix isnull, all items in the list will be localized.- Parameters:
lang- the language to use, or null for the interface languagebox- the combo box whose labels should be localizedprefix- a prefix string that will identify labels that are string table keys
-
hasUnsavedChanges
public boolean hasUnsavedChanges()
Returnstrueif the edited game component has unsaved changes.- Specified by:
hasUnsavedChangesin interfaceStrangeEonsEditor- Overrides:
hasUnsavedChangesin classAbstractStrangeEonsEditor- Returns:
trueif the game component has been edited since the last time it was saved- See Also:
AbstractStrangeEonsEditor.setUnsavedChanges(boolean)
-
setUnsavedChanges
public void setUnsavedChanges(boolean isDirty)
Marks whether the game component has unsaved changes. This flag is cleared whenever the file is saved successfully.Note: The game component is updated to reflect this change so that it stays in synch with the editor. (The values of
hasUnsavedChanges()and the game component'sGameComponent.hasUnsavedChanges()will match.)- Overrides:
setUnsavedChangesin classAbstractStrangeEonsEditor- Parameters:
isDirty-trueif this game component has unsaved changes
-
printImpl
protected void printImpl(java.awt.print.PrinterJob job) throws javax.print.PrintException, java.awt.print.PrinterExceptionImplementation of the print command for standard game components. Lays out the sheets to be printed on one or more pages and then prints the layout.- Overrides:
printImplin classAbstractStrangeEonsEditor- Parameters:
job- a printer job; this value is ignored as this implementation will create its own printer job- Throws:
javax.print.PrintException- if an error occurs during printingjava.awt.print.PrinterException- if a printer error occurs during printing
-
getGameComponent
public G getGameComponent()
Returns the edited game component. If this editor is not editing a game component, returnsnull.- Specified by:
getGameComponentin interfaceStrangeEonsEditor- Overrides:
getGameComponentin classAbstractStrangeEonsEditor- Returns:
- the edited game component, or
nullif this editor is not editing a game component
-
setGameComponent
public void setGameComponent(G component)
Sets the edited game component. If the game component is not appropriate for the editor, the result is undefined.- Parameters:
component- the new game component
-
clearImpl
protected void clearImpl()
Clears the component by calling itsGameComponent.clearAll()method, then repopulating the editor controls.- Overrides:
clearImplin classAbstractStrangeEonsEditor- See Also:
populateFieldsFromComponent()
-
spinOff
public StrangeEonsEditor spinOff()
Description copied from class:AbstractStrangeEonsEditorCreates a duplicate of this editor. A new editor containing a copy of this editor's content will be created and added to the application. The new component is a deep copy, not a reference (changes to the new component do not affect the original, and vice-versa). This implementation callsAbstractStrangeEonsEditor.spinOffImpl()to create the new editor, then adds the editor to the application.- Specified by:
spinOffin interfaceStrangeEonsEditor- Overrides:
spinOffin classAbstractStrangeEonsEditor- Returns:
- the new, duplicate editor
- See Also:
StrangeEonsEditor.canPerformCommand(ca.cgjennings.apps.arkham.commands.AbstractCommand)
-
spinOffImpl
protected StrangeEonsEditor spinOffImpl()
Description copied from class:AbstractStrangeEonsEditorSubclasses should override this to clone the edited document if SPIN_OFF is a supported command.- Overrides:
spinOffImplin classAbstractStrangeEonsEditor- Returns:
- a new editor with an exact copy of this document
-
getFileNameExtension
public java.lang.String getFileNameExtension()
Description copied from interface:StrangeEonsEditorReturns the standard file extension for the type of content displayed in this editor.- Returns:
- a file extension, such as
"txt" - See Also:
StrangeEonsEditor.getFileTypeDescription()
-
getFileTypeDescription
public java.lang.String getFileTypeDescription()
Description copied from interface:StrangeEonsEditorReturns a description of the content displayed in this editor. For English descriptions, this should be plural as it is used to describe the file type in save dialogs.- Returns:
- a human-friendly description of the content associated with the editor, such as "Text Files"
- See Also:
StrangeEonsEditor.getFileNameExtension()
-
isCommandApplicable
public boolean isCommandApplicable(AbstractCommand command)
Description copied from class:AbstractStrangeEonsEditorReturnstrueif thecommandcan 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:
isCommandApplicablein interfaceCommandable- Specified by:
isCommandApplicablein interfaceStrangeEonsEditor- Overrides:
isCommandApplicablein classAbstractStrangeEonsEditor- Parameters:
command- the command to be performed- Returns:
trueif this commandable can currently perform the command
-
performCommand
public void performCommand(AbstractCommand command)
Description copied from class:AbstractStrangeEonsEditorPerforms the command. IfCommandable.isCommandApplicable(ca.cgjennings.apps.arkham.commands.AbstractCommand)would returnfalsefor this command, then this should do nothing.The base class provides a framework for handling common document commands. To use the framework, override
AbstractStrangeEonsEditor.canPerformCommand(ca.cgjennings.apps.arkham.commands.AbstractCommand)to return true for the commands you wish to support. Then this method will call the following methods (as appropriate): null null nullAbstractStrangeEonsEditor.clear(),AbstractStrangeEonsEditor.save(),AbstractStrangeEonsEditor.saveAs(),AbstractStrangeEonsEditor.export(),AbstractStrangeEonsEditor.spinOff(), orAbstractStrangeEonsEditor.print(). These methods handle common details of implementing these commands, then pass control to a matching implementation method which the subclass must override to perform those aspects of the command which are unique to the editor's content.For example, to implement document saving, a subclass would override
AbstractStrangeEonsEditor.canPerformCommand(ca.cgjennings.apps.arkham.commands.AbstractCommand)to return true for the SAVE and SAVE_AS commands, then overrideAbstractStrangeEonsEditor.saveImpl(java.io.File)to write the editor content to the provided file.- Specified by:
performCommandin interfaceCommandable- Specified by:
performCommandin interfaceStrangeEonsEditor- Overrides:
performCommandin classAbstractStrangeEonsEditor- Parameters:
command- the command to perform
-
getBorder
public final javax.swing.border.Border getBorder()
- Overrides:
getBorderin 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:
setFrameIconin 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:
getFrameIconin classjavax.swing.JInternalFrame- Returns:
- the icon for the editor, or
nullif 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()
Returnstrueif this editor is currently attached to the document tab strip.- Returns:
trueif the editor is attached- See Also:
setAttached(boolean)
-
-