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.IconDEFAULT_EDITOR_ICONThe 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 voidaddEditorListener(StrangeEonsEditor.EditorListener eal)Adds a newStrangeEonsEditor.EditorListenerto this editor.voidaddHeartbeatListener(StrangeEonsEditor.HeartbeatListener hl)Adds a newHeartbeatListenerto this editor.booleancanPerformCommand(AbstractCommand command)Returnstrueif the commandable wishes to handle the given command.voidclear()Clears the contents of this component to a blank state, if the user gives permission.protected voidclearImpl()Subclasses should override this to clear the edited document if CLEAR is a supported command.booleanclose()Closes the editor window.protected booleanconfirmLossOfUnsavedChanges()IfhasUnsavedChanges()returnstrue, this will display a dialog box asking the user to confirm whether it is acceptable to lose unsaved changes.protected voidcreateTimer()Creates a heartbeat timer that ticks at the default rate.protected voidcreateTimer(int updatePeriod)Creates a heartbeat timer at the specified rate, in milliseconds.voiddispose()Releases resources when the editor will no longer be used.voiddoDefaultCloseAction()voidexport()Exports the editor content as a different file format.protected booleanfireHeartbeatEvent()This method is called byonHeartbeat()to notify heartbeat listeners.javax.swing.border.BordergetBorder()java.io.FilegetFile()Returns the file used to save this component, ornullif it is a new, unsaved file or the editor is not associated with any particular file.javax.swing.IcongetFrameIcon()Returns the editor window icon.GameComponentgetGameComponent()Returns the edited game component, ornullif this editor is not editing a game component.javax.swing.JPopupMenugetTabStripPopupMenu()Returns a popup menu for this editor when the editor's tab is right clicked in the document tab strip.java.lang.StringgetTitle()Returns the title used to describe this editor.java.lang.StringgetToolTipText()Returns the tool tip text displayed for the editor's tab.booleanhasUnsavedChanges()Returns true if this document has unsaved changes.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.protected voidonHeartbeat()This method is called to allow the editor to perform heartbeat processing.voidperformCommand(AbstractCommand command)Performs the command.voidprint()Open the print dialog for this editor, allowing the user to print the edited component.protected voidprintImpl(java.awt.print.PrinterJob job)Subclasses should override this to print the edited document if PRINT is a supported command.protected voidremoveAllStrangeEonsListeners()Removes all listeners for events specific to Strange Eons.voidremoveEditorListener(StrangeEonsEditor.EditorListener eal)Removes a newStrangeEonsEditor.EditorListenerfrom this editor.voidremoveHeartbeatListener(StrangeEonsEditor.HeartbeatListener hl)Removes aHeartbeatListenerfrom this editor.voidresumeTimedUpdates()Resumes stopped preview updates.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.voidselect()Selects this editor, making it the active editor.voidsetAttached(boolean attach)Sets whether this editor is attached to the document tab strip.voidsetFile(java.io.File newFile)Sets the preferred file to use when saving the edited component.voidsetFrameIcon(javax.swing.Icon icon)Sets the preferred icon to use for this editor window.voidsetTitle(java.lang.String title)Sets the title of this document.voidsetToolTipText(java.lang.String toolTipText)Sets the title of this document.voidsetUnsavedChanges(boolean isDirty)Marks whether the document 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.voidstopTimedUpdates()Stops updating the preview pane when the game component is modified.java.lang.StringtoString()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:StrangeEonsEditorSelects this editor, making it the active editor.- Specified by:
selectin interfaceStrangeEonsEditor- See Also:
StrangeEonsAppWindow.getActiveEditor()
-
close
public boolean close()
Description copied from interface:StrangeEonsEditorCloses the editor window. If there are unsaved changes, the user will be prompted first and may cancel the close attempt.- Specified by:
closein interfaceStrangeEonsEditor- Returns:
- returns
trueif the editor was actually closed, orfalseif 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. Thetitlevalue may benull, which is equivalent to an empty title.- Specified by:
setTitlein 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 anulltitle 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:
getTitlein 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. Thetitlevalue may benull, which is equivalent to an empty title.- Specified by:
setToolTipTextin 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-nullvalue, or else the localized interface text with keyae-unsaved("Untitled").- Specified by:
getToolTipTextin interfaceStrangeEonsEditor- Returns:
- the tool tip text to display, or
nullto clear the tool tip
-
getTabStripPopupMenu
public javax.swing.JPopupMenu getTabStripPopupMenu()
Description copied from interface:StrangeEonsEditorReturns 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:
getTabStripPopupMenuin 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, ornullif this editor is not editing a game component.The
AbstractStrangeEonsEditorimplementation always returnsnull.- Specified by:
getGameComponentin interfaceStrangeEonsEditor- Returns:
- the game component currently being edited by this editor, or
null
-
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 fromhandlesCommand, but false fromCommandable.isCommandApplicable(ca.cgjennings.apps.arkham.commands.AbstractCommand)if there is currently no selection to cut.The base class will return
falsefor all commands.- Specified by:
canPerformCommandin interfaceCommandable- Specified by:
canPerformCommandin interfaceStrangeEonsEditor- Parameters:
command- the command to be performed- Returns:
trueif this commandable wishes to handle the command (even if it cannot execute the command currently)
-
isCommandApplicable
public boolean isCommandApplicable(AbstractCommand command)
Returnstrueif 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 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:
isCommandApplicablein interfaceCommandable- Specified by:
isCommandApplicablein interfaceStrangeEonsEditor- Parameters:
command- the command to be performed- Returns:
trueif 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 returnfalsefor 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:
performCommandin interfaceCommandable- Specified by:
performCommandin 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 returnstrueif the user wants to continue (and lose the unsaved changes), otherwisefalse. IfhasUnsavedChanges()returnsfalse, then this method will returntruewithout showing a dialog.Note: If the application is running in bundle test mode, then the method will return
truewithout 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:
trueif the operation can proceed- See Also:
CommandLineArguments.plugintest
-
setFile
public void setFile(java.io.File newFile)
Description copied from interface:StrangeEonsEditorSets the preferred file to use when saving the edited component.- Specified by:
setFilein interfaceStrangeEonsEditor- Parameters:
newFile- the file to use for Save operations- See Also:
StrangeEonsEditor.getFile()
-
getFile
public java.io.File getFile()
Description copied from interface:StrangeEonsEditorReturns the file used to save this component, ornullif it is a new, unsaved file or the editor is not associated with any particular file.- Specified by:
getFilein 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:
hasUnsavedChangesin interfaceStrangeEonsEditor- Returns:
trueif 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:
savein 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, callssetFileto 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:
saveAsin interfaceStrangeEonsEditor- See Also:
StrangeEonsEditor.canPerformCommand(ca.cgjennings.apps.arkham.commands.AbstractCommand)
-
saveImpl
protected void saveImpl(java.io.File f) throws java.io.IOExceptionSaves 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 callsclearImplto handle the details of clearing the edited content. To use it, overrideclearImpl()to perform the clear operation.- Specified by:
clearin 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:
exportin 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, anUnsupportedOperationExceptionis thrown. This implementation creates a defaultPrinterJoband then passes it toprintImpl(java.awt.print.PrinterJob). It also performs exception handling, including thePrinterAbortExceptionthat is thrown if the user cancels a print. To implement printing, overrideprintImplto print the content using the provided job. Note that this method does not display a print dialog; you can do this fromprintImplusingjob.printDialog().- Specified by:
printin interfaceStrangeEonsEditor- See Also:
printImpl(java.awt.print.PrinterJob)
-
printImpl
protected void printImpl(java.awt.print.PrinterJob job) throws javax.print.PrintException, java.awt.print.PrinterExceptionSubclasses 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:
spinOffin 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:StrangeEonsEditorAdds a newStrangeEonsEditor.EditorListenerto 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:
addEditorListenerin interfaceStrangeEonsEditor- Parameters:
eal- the listener to add
-
removeEditorListener
public void removeEditorListener(StrangeEonsEditor.EditorListener eal)
Description copied from interface:StrangeEonsEditorRemoves a newStrangeEonsEditor.EditorListenerfrom this editor.- Specified by:
removeEditorListenerin 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 thePreferencesdialog.- 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:
trueif any registered listener returnstrueto indicate content changes
-
addHeartbeatListener
public void addHeartbeatListener(StrangeEonsEditor.HeartbeatListener hl)
Adds a newHeartbeatListenerto this editor.- Parameters:
hl- the listener to add- Since:
- 2.00 (final)
-
removeHeartbeatListener
public void removeHeartbeatListener(StrangeEonsEditor.HeartbeatListener hl)
Removes aHeartbeatListenerfrom 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:
toStringin 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:
disposein classjavax.swing.JInternalFrame
-
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)
-
-