Class AbstractStrangeEonsEditor
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JInternalFrame
-
- ca.cgjennings.apps.arkham.AbstractStrangeEonsEditor
-
- 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:
AbstractGameComponentEditor
,AbstractSupportEditor
public abstract class AbstractStrangeEonsEditor extends javax.swing.JInternalFrame implements StrangeEonsEditor
The abstract base class from which all editors that can appear in the document tab strip are derived.- 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 static javax.swing.Icon
DEFAULT_EDITOR_ICON
The default icon used by new editors.-
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 AbstractStrangeEonsEditor()
Creates a new abstract editor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEditorListener(StrangeEonsEditor.EditorListener eal)
Adds a newStrangeEonsEditor.EditorListener
to this editor.void
addHeartbeatListener(StrangeEonsEditor.HeartbeatListener hl)
Adds a newHeartbeatListener
to this editor.boolean
canPerformCommand(AbstractCommand command)
Returnstrue
if the commandable wishes to handle the given command.void
clear()
Clears the contents of this component to a blank state, if the user gives permission.protected void
clearImpl()
Subclasses should override this to clear the edited document if CLEAR is a supported command.boolean
close()
Closes the editor window.protected boolean
confirmLossOfUnsavedChanges()
IfhasUnsavedChanges()
returnstrue
, this will display a dialog box asking the user to confirm whether it is acceptable to lose unsaved changes.protected void
createTimer()
Creates a heartbeat timer that ticks at the default rate.protected void
createTimer(int updatePeriod)
Creates a heartbeat timer at the specified rate, in milliseconds.void
dispose()
Releases resources when the editor will no longer be used.void
doDefaultCloseAction()
void
export()
Exports the editor content as a different file format.protected boolean
fireHeartbeatEvent()
This method is called byonHeartbeat()
to notify heartbeat listeners.javax.swing.border.Border
getBorder()
java.io.File
getFile()
Returns the file used to save this component, ornull
if it is a new, unsaved file or the editor is not associated with any particular file.javax.swing.Icon
getFrameIcon()
Returns the editor window icon.GameComponent
getGameComponent()
Returns the edited game component, ornull
if this editor is not editing a game component.javax.swing.JPopupMenu
getTabStripPopupMenu()
Returns a popup menu for this editor when the editor's tab is right clicked in the document tab strip.java.lang.String
getTitle()
Returns the title used to describe this editor.java.lang.String
getToolTipText()
Returns the tool tip text displayed for the editor's tab.boolean
hasUnsavedChanges()
Returns true if this document 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.protected void
onHeartbeat()
This method is called to allow the editor to perform heartbeat processing.void
performCommand(AbstractCommand command)
Performs the command.void
print()
Open the print dialog for this editor, allowing the user to print the edited component.protected void
printImpl(java.awt.print.PrinterJob job)
Subclasses should override this to print the edited document if PRINT is a supported command.protected void
removeAllStrangeEonsListeners()
Removes all listeners for events specific to Strange Eons.void
removeEditorListener(StrangeEonsEditor.EditorListener eal)
Removes a newStrangeEonsEditor.EditorListener
from this editor.void
removeHeartbeatListener(StrangeEonsEditor.HeartbeatListener hl)
Removes aHeartbeatListener
from this editor.void
resumeTimedUpdates()
Resumes stopped preview updates.void
save()
Saves this editor's content to its current save location.void
saveAs()
Saves this editor's content to a file selected by the user.protected void
saveImpl(java.io.File f)
Saves the editor content to the specified file.void
select()
Selects this editor, making it the active editor.void
setAttached(boolean attach)
Sets whether this editor is attached to the document tab strip.void
setFile(java.io.File newFile)
Sets the preferred file to use when saving the edited component.void
setFrameIcon(javax.swing.Icon icon)
Sets the preferred icon to use for this editor window.void
setTitle(java.lang.String title)
Sets the title of this document.void
setToolTipText(java.lang.String toolTipText)
Sets the title of this document.void
setUnsavedChanges(boolean isDirty)
Marks whether the document has unsaved changes.StrangeEonsEditor
spinOff()
Creates a duplicate of this editor.protected StrangeEonsEditor
spinOffImpl()
Subclasses should override this to clone the edited document if SPIN_OFF is a supported command.void
stopTimedUpdates()
Stops updating the preview pane when the game component is modified.java.lang.String
toString()
Returns a string describing the editor, including the class name, size, edited file, and game component (if any).-
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
getFileNameExtension, getFileTypeDescription, getFrameIcon, isAttached, setAttached, setFrameIcon
-
-
-
-
Method Detail
-
select
public final void select()
Description copied from interface:StrangeEonsEditor
Selects this editor, making it the active editor.- Specified by:
select
in interfaceStrangeEonsEditor
- See Also:
StrangeEonsAppWindow.getActiveEditor()
-
close
public boolean close()
Description copied from interface:StrangeEonsEditor
Closes the editor window. If there are unsaved changes, the user will be prompted first and may cancel the close attempt.- Specified by:
close
in interfaceStrangeEonsEditor
- Returns:
- returns
true
if the editor was actually closed, orfalse
if the user cancelled the attempt or closing was otherwise prevented
-
doDefaultCloseAction
public void doDefaultCloseAction()
-
setTitle
public void setTitle(java.lang.String title)
Sets the title of this document. As it shown in the document's tab, the title text should be kept short. Thetitle
value may benull
, which is equivalent to an empty title.- Specified by:
setTitle
in interfaceStrangeEonsEditor
- Parameters:
title
- the text of the title to display
-
getTitle
public java.lang.String getTitle()
Returns the title used to describe this editor. The returned value is nevernull
; if anull
title is set withsetTitle(java.lang.String)
then this method returns an empty string.If no title has been explicitly set, then a default title will be returned. The default title will be the game component name for game component editors, and otherwise the file name. If there is no name or file available, then a dummy title consisting of a single space is returned.
- Specified by:
getTitle
in interfaceStrangeEonsEditor
- Returns:
- the current title, which is guaranteed not to be
null
-
setToolTipText
public void setToolTipText(java.lang.String toolTipText)
Sets the title of this document. As it shown in the document's tab, the title text should be kept short. Thetitle
value may benull
, which is equivalent to an empty title.- Specified by:
setToolTipText
in interfaceStrangeEonsEditor
- Parameters:
toolTipText
- the text of the title to display
-
getToolTipText
public java.lang.String getToolTipText()
Returns the tool tip text displayed for the editor's tab. If no tool tip has been explicitly set, a default tool tip will be returned. The default tool tip will get the name of the file, ifgetFile()
returns a non-null
value, or else the localized interface text with keyae-unsaved
("Untitled").- Specified by:
getToolTipText
in interfaceStrangeEonsEditor
- Returns:
- the tool tip text to display, or
null
to clear the tool tip
-
getTabStripPopupMenu
public javax.swing.JPopupMenu getTabStripPopupMenu()
Description copied from interface:StrangeEonsEditor
Returns a popup menu for this editor when the editor's tab is right clicked in the document tab strip. Because a new menu instance is created each time it is called, subclasses may call a super implementation to obtain a default menu and then modify it.- Specified by:
getTabStripPopupMenu
in interfaceStrangeEonsEditor
- Returns:
- the popup menu that will be displayed when the user right clicks on the document's tab
-
getGameComponent
public GameComponent getGameComponent()
Returns the edited game component, ornull
if this editor is not editing a game component.The
AbstractStrangeEonsEditor
implementation always returnsnull
.- Specified by:
getGameComponent
in interfaceStrangeEonsEditor
- Returns:
- the game component currently being edited by this editor, or
null
-
canPerformCommand
public boolean canPerformCommand(AbstractCommand command)
Returnstrue
if 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 fromhandlesCommand
, but false fromCommandable.isCommandApplicable(ca.cgjennings.apps.arkham.commands.AbstractCommand)
if there is currently no selection to cut.The base class will return
false
for all commands.- Specified by:
canPerformCommand
in interfaceCommandable
- Specified by:
canPerformCommand
in interfaceStrangeEonsEditor
- Parameters:
command
- the command to be performed- Returns:
true
if this commandable wishes to handle the command (even if it cannot execute the command currently)
-
isCommandApplicable
public boolean isCommandApplicable(AbstractCommand command)
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 ofcanPerformCommand(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
- Parameters:
command
- the command to be performed- Returns:
true
if this commandable can currently perform the command
-
performCommand
public void performCommand(AbstractCommand command)
Performs the command. IfCommandable.isCommandApplicable(ca.cgjennings.apps.arkham.commands.AbstractCommand)
would returnfalse
for this command, then this should do nothing.The base class provides a framework for handling common document commands. To use the framework, override
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 nullclear()
,save()
,saveAs()
,export()
,spinOff()
, orprint()
. 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
canPerformCommand(ca.cgjennings.apps.arkham.commands.AbstractCommand)
to return true for the SAVE and SAVE_AS commands, then overridesaveImpl(java.io.File)
to write the editor content to the provided file.- Specified by:
performCommand
in interfaceCommandable
- Specified by:
performCommand
in interfaceStrangeEonsEditor
- Parameters:
command
- the command to perform
-
confirmLossOfUnsavedChanges
protected boolean confirmLossOfUnsavedChanges()
IfhasUnsavedChanges()
returnstrue
, this will display a dialog box asking the user to confirm whether it is acceptable to lose unsaved changes. The method returnstrue
if the user wants to continue (and lose the unsaved changes), otherwisefalse
. IfhasUnsavedChanges()
returnsfalse
, then this method will returntrue
without showing a dialog.Note: If the application is running in bundle test mode, then the method will return
true
without showing a dialog box. (This makes testing faster since the tester can experiment with the tested plug-in without having to click on confirm buttons when the test finishes and the test application instance is closed.)- Returns:
true
if the operation can proceed- See Also:
CommandLineArguments.plugintest
-
setFile
public void setFile(java.io.File newFile)
Description copied from interface:StrangeEonsEditor
Sets the preferred file to use when saving the edited component.- Specified by:
setFile
in interfaceStrangeEonsEditor
- Parameters:
newFile
- the file to use for Save operations- See Also:
StrangeEonsEditor.getFile()
-
getFile
public java.io.File getFile()
Description copied from interface:StrangeEonsEditor
Returns the file used to save this component, ornull
if it is a new, unsaved file or the editor is not associated with any particular file.- Specified by:
getFile
in interfaceStrangeEonsEditor
- Returns:
- the save file
- See Also:
StrangeEonsEditor.setFile(java.io.File)
-
hasUnsavedChanges
public boolean hasUnsavedChanges()
Returns true if this document has unsaved changes. calling{@link #setUnsavedChanges}( true )
.- Specified by:
hasUnsavedChanges
in interfaceStrangeEonsEditor
- Returns:
true
if changes would be lost if the document was closed without saving- See Also:
setUnsavedChanges(boolean)
-
setUnsavedChanges
public void setUnsavedChanges(boolean isDirty)
Marks whether the document has unsaved changes. The application uses this to determine whether it is safe to close an editor without saving and to update the document's visual state. This flag is cleared whenever the file is saved successfully.- Parameters:
isDirty
- iftrue
, tells the application that this editor has unsaved changes
-
save
public void save()
Saves 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
getFile()
returnsnull
, this method callssaveAs()
to determine the file to save to. Otherwise, it callssaveImpl(java.io.File)
to write the file. To use it, overridesaveImpl(java.io.File)
.- Specified by:
save
in interfaceStrangeEonsEditor
- See Also:
StrangeEonsEditor.canPerformCommand(ca.cgjennings.apps.arkham.commands.AbstractCommand)
-
saveAs
public void saveAs()
Saves 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, callssetFile
to set the save file based on the user's selection. It then callssave()
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 overridesaveImpl(java.io.File)
to write the file.- Specified by:
saveAs
in interfaceStrangeEonsEditor
- See Also:
StrangeEonsEditor.canPerformCommand(ca.cgjennings.apps.arkham.commands.AbstractCommand)
-
saveImpl
protected void saveImpl(java.io.File f) throws java.io.IOException
Saves 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.- Parameters:
f
- the file to write content to- Throws:
java.io.IOException
- if the save fails
-
clear
public void clear()
Clears the contents of this component to a blank state, if the user gives permission. This implementation allows the user to cancel the clear operation if there are unsaved changes, and then callsclearImpl
to handle the details of clearing the edited content. To use it, overrideclearImpl()
to perform the clear operation.- Specified by:
clear
in interfaceStrangeEonsEditor
- See Also:
StrangeEonsEditor.canPerformCommand(ca.cgjennings.apps.arkham.commands.AbstractCommand)
-
clearImpl
protected void clearImpl()
Subclasses should override this to clear the edited document if CLEAR is a supported command.
-
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.The base class does not support exports, and will throw an exception if this method is called. Subclasses that support the EXPORT command must override this method to implement appropriate behaviour.
- Specified by:
export
in interfaceStrangeEonsEditor
- Throws:
java.lang.AssertionError
- if called when the EXPORT command is supported- See Also:
StrangeEonsEditor.canPerformCommand(ca.cgjennings.apps.arkham.commands.AbstractCommand)
-
print
public void print()
Open the print dialog for this editor, allowing the user to print the edited component. If this operation is not supported by this editor, anUnsupportedOperationException
is thrown. This implementation creates a defaultPrinterJob
and then passes it toprintImpl(java.awt.print.PrinterJob)
. It also performs exception handling, including thePrinterAbortException
that is thrown if the user cancels a print. To implement printing, overrideprintImpl
to print the content using the provided job. Note that this method does not display a print dialog; you can do this fromprintImpl
usingjob.printDialog()
.- Specified by:
print
in interfaceStrangeEonsEditor
- See Also:
printImpl(java.awt.print.PrinterJob)
-
printImpl
protected void printImpl(java.awt.print.PrinterJob job) throws javax.print.PrintException, java.awt.print.PrinterException
Subclasses should override this to print the edited document if PRINT is a supported command.- Parameters:
job
- the printer job to use for printing- Throws:
javax.print.PrintException
- if a printing error occursjava.awt.print.PrinterException
- if a printing error occurs
-
spinOff
public StrangeEonsEditor spinOff()
Creates 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 callsspinOffImpl()
to create the new editor, then adds the editor to the application.- Specified by:
spinOff
in interfaceStrangeEonsEditor
- Returns:
- the new, duplicate editor
- See Also:
StrangeEonsEditor.canPerformCommand(ca.cgjennings.apps.arkham.commands.AbstractCommand)
-
spinOffImpl
protected StrangeEonsEditor spinOffImpl()
Subclasses should override this to clone the edited document if SPIN_OFF is a supported command.- Returns:
- a new editor with an exact copy of this document
-
addEditorListener
public void addEditorListener(StrangeEonsEditor.EditorListener eal)
Description copied from interface:StrangeEonsEditor
Adds a newStrangeEonsEditor.EditorListener
to this editor. An editor listener can also be added usingStrangeEonsAppWindow.addEditorListener(ca.cgjennings.apps.arkham.StrangeEonsEditor.EditorListener)
interface, in which case it will apply to all editors. If a listener is removed, it must be removed through the same interface as it was added (the application or a specific editor).- Specified by:
addEditorListener
in interfaceStrangeEonsEditor
- Parameters:
eal
- the listener to add
-
removeEditorListener
public void removeEditorListener(StrangeEonsEditor.EditorListener eal)
Description copied from interface:StrangeEonsEditor
Removes a newStrangeEonsEditor.EditorListener
from this editor.- Specified by:
removeEditorListener
in interfaceStrangeEonsEditor
- Parameters:
eal
- the listener to remove
-
createTimer
protected void createTimer()
Creates a heartbeat timer that ticks at the default rate. The default rate is determined from the setting keyupdate-rate
, and can be changed in thePreferences
dialog.- See Also:
createTimer(int)
-
createTimer
protected void createTimer(int updatePeriod)
Creates a heartbeat timer at the specified rate, in milliseconds. Note that an update period of longer than a few seconds may cause the interface to appear to be responding sluggishly.- Parameters:
updatePeriod
- the approximate time between heartbeats, in milliseconds
-
stopTimedUpdates
public void stopTimedUpdates()
Stops updating the preview pane when the game component is modified.- See Also:
resumeTimedUpdates()
-
resumeTimedUpdates
public void resumeTimedUpdates()
Resumes stopped preview updates.- See Also:
stopTimedUpdates()
-
onHeartbeat
protected void onHeartbeat()
This method is called to allow the editor to perform heartbeat processing. The base class will callfireHeartbeatEvent()
to notify any attached listeners.
-
fireHeartbeatEvent
protected final boolean fireHeartbeatEvent()
This method is called byonHeartbeat()
to notify heartbeat listeners. Subclasses that override the default heartbeat handling without calling the super implementation must call this to ensure that registered listeners are correctly notified.- Returns:
true
if any registered listener returnstrue
to indicate content changes
-
addHeartbeatListener
public void addHeartbeatListener(StrangeEonsEditor.HeartbeatListener hl)
Adds a newHeartbeatListener
to this editor.- Parameters:
hl
- the listener to add- Since:
- 2.00 (final)
-
removeHeartbeatListener
public void removeHeartbeatListener(StrangeEonsEditor.HeartbeatListener hl)
Removes aHeartbeatListener
from this editor.- Parameters:
hl
- the listener to remove- Since:
- 2.00 (final)
-
removeAllStrangeEonsListeners
protected void removeAllStrangeEonsListeners()
Removes all listeners for events specific to Strange Eons. This method is called when the editor is being disposed of. It removes any editor and heartbeat event listeners that were added through the editor. Subclasses are responsible for overriding this method to remove any additional listener types that they define and to call the superclass implementation.
-
toString
public java.lang.String toString()
Returns a string describing the editor, including the class name, size, edited file, and game component (if any).- Overrides:
toString
in classjava.awt.Component
- Returns:
- a string describing the editor
-
dispose
public void dispose()
Releases 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
close()
method instead.- Overrides:
dispose
in classjavax.swing.JInternalFrame
-
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)
-
-