Class OrderEditor

  • All Implemented Interfaces:
    java.awt.event.FocusListener, java.awt.event.KeyListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.DocumentListener, javax.swing.Scrollable, SelectionListener, Changeable, EventListener, CacheableOrderEditor

    public class OrderEditor
    extends javax.swing.JTextPane
    implements javax.swing.event.DocumentListener, java.awt.event.KeyListener, SelectionListener, java.awt.event.FocusListener, CacheableOrderEditor, Changeable
    A text pane for convenient editing and handling of Eressea orders.
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JEditorPane

        javax.swing.JEditorPane.AccessibleJEditorPane, javax.swing.JEditorPane.AccessibleJEditorPaneHTML, javax.swing.JEditorPane.JEditorPaneAccessibleHypertextSupport
      • Nested classes/interfaces inherited from class javax.swing.text.JTextComponent

        javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.DropLocation, javax.swing.text.JTextComponent.KeyBinding
      • 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
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String S_COMMENT
      Text style COMMENT
      static java.lang.String S_COMMENT_INV
      Text style COMMENT inverted
      static java.lang.String S_ID
      Text style ID
      static java.lang.String S_ID_INV
      Text style ID inverted
      static java.lang.String S_KEYWORD
      Text style KEYWORD
      static java.lang.String S_KEYWORD_INV
      Text style KEYWORD inverted
      static java.lang.String S_LONGORDER
      Text style LONGORDER
      static java.lang.String S_LONGORDER_INV
      Text style LONGORDER inverted
      static java.lang.String S_NUMBER
      Text style NUMBER
      static java.lang.String S_NUMBER_INV
      Text style NUMBER inverted
      static java.lang.String S_REGULAR
      Text style REGULAR
      static java.lang.String S_REGULAR_INV
      Text style REGULAR inverted
      static java.lang.String S_STRING
      Text style STRING
      static java.lang.String S_STRING_INV
      Text style STRING inverted
      • Fields inherited from class javax.swing.JEditorPane

        HONOR_DISPLAY_PROPERTIES, W3C_LENGTH_UNITS
      • Fields inherited from class javax.swing.text.JTextComponent

        DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
      • 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
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
    • Constructor Summary

      Constructors 
      Constructor Description
      OrderEditor​(GameData data, java.util.Properties settings, javax.swing.undo.UndoManager _undoMgr, EventDispatcher d, OrderParser parser)
      Creates a new OrderEditor object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addOrder​(java.lang.String cmd)
      Adds a order to this text pane.
      void changedUpdate​(javax.swing.event.DocumentEvent e)  
      protected void finalize()  
      void fireOrdersChangedEvent()  
      void focusGained​(java.awt.event.FocusEvent e)  
      void focusLost​(java.awt.event.FocusEvent e)
      Update orders.
      void formatTokens()
      Format all tokens with regard to the token type colors.
      java.lang.Object getArgument()
      Returns the unit for this editor.
      int getChangeModes()
      ContextFactory getContextFactory()
      Returns a factory for creating the appropriate context menu.
      static java.lang.String getDefaultColor​(java.lang.String styleName)
      Return the default color as a string for the specified token style.
      java.util.List<java.lang.String> getOrders()
      Returns a list of the orders this text pane is currently containing.
      java.lang.String getText()
      Gives back the text in the text pane.
      Unit getUnit()
      Returns the unit currently registered with this editor.
      boolean getUseSyntaxHighlighting()
      Return whether syntax highlighting is enabled or disabled.
      void insertUpdate​(javax.swing.event.DocumentEvent e)
      DOCUMENT-ME
      boolean isModified()
      Indicates whether the contents of this editor have been modified.
      boolean keepVisible()
      DOCUMENT-ME
      void keyPressed​(java.awt.event.KeyEvent e)  
      void keyReleased​(java.awt.event.KeyEvent e)  
      void keyTyped​(java.awt.event.KeyEvent e)  
      void registerListener()
      registers an OrderListener with the event dispatcher
      boolean releaseListener()
      release an OrderListener with the event dispatcher
      void reloadOrders()
      Refresh the editor's contents.
      void removeUpdate​(javax.swing.event.DocumentEvent e)
      DOCUMENT-ME
      void selectionChanged​(SelectionEvent e)
      If the active object in the selection event is a unit it is registered with this editor.
      void setErrorBackround​(java.awt.Color c)
      Sets the background color for orders with errors.
      void setKeepVisible​(boolean b)
      DOCUMENT-ME
      void setOrders​(java.util.Collection<Order> c)
      Puts the list elements in c into this text pane, one at a time.
      void setTokenColor​(java.lang.String styleName, java.awt.Color color)
      Set the color of the specified token style used for syntax highlighting.
      void setUnit​(Unit u)
      Sets the unit for this editor component.
      void setUseSyntaxHighlighting​(boolean bool)
      Enable or disable syntax highlighting.
      • Methods inherited from class javax.swing.JTextPane

        addStyle, createDefaultEditorKit, getCharacterAttributes, getInputAttributes, getLogicalStyle, getParagraphAttributes, getStyle, getStyledDocument, getStyledEditorKit, getUIClassID, insertComponent, insertIcon, paramString, removeStyle, replaceSelection, setCharacterAttributes, setDocument, setEditorKit, setLogicalStyle, setParagraphAttributes, setStyledDocument
      • Methods inherited from class javax.swing.JEditorPane

        addHyperlinkListener, createEditorKitForContentType, fireHyperlinkUpdate, getAccessibleContext, getContentType, getEditorKit, getEditorKitClassNameForContentType, getEditorKitForContentType, getHyperlinkListeners, getPage, getPreferredSize, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getStream, read, registerEditorKitForContentType, registerEditorKitForContentType, removeHyperlinkListener, scrollToReference, setContentType, setEditorKitForContentType, setPage, setPage, setText
      • Methods inherited from class javax.swing.text.JTextComponent

        addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getActions, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, modelToView2D, moveCaretPosition, paste, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, restoreComposedText, saveComposedText, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, viewToModel2D, write
      • Methods inherited from class javax.swing.JComponent

        addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • S_REGULAR

        public static final java.lang.String S_REGULAR
        Text style REGULAR
        See Also:
        Constant Field Values
      • S_REGULAR_INV

        public static final java.lang.String S_REGULAR_INV
        Text style REGULAR inverted
        See Also:
        Constant Field Values
      • S_KEYWORD

        public static final java.lang.String S_KEYWORD
        Text style KEYWORD
        See Also:
        Constant Field Values
      • S_KEYWORD_INV

        public static final java.lang.String S_KEYWORD_INV
        Text style KEYWORD inverted
        See Also:
        Constant Field Values
      • S_STRING

        public static final java.lang.String S_STRING
        Text style STRING
        See Also:
        Constant Field Values
      • S_STRING_INV

        public static final java.lang.String S_STRING_INV
        Text style STRING inverted
        See Also:
        Constant Field Values
      • S_NUMBER

        public static final java.lang.String S_NUMBER
        Text style NUMBER
        See Also:
        Constant Field Values
      • S_NUMBER_INV

        public static final java.lang.String S_NUMBER_INV
        Text style NUMBER inverted
        See Also:
        Constant Field Values
      • S_ID_INV

        public static final java.lang.String S_ID_INV
        Text style ID inverted
        See Also:
        Constant Field Values
      • S_COMMENT

        public static final java.lang.String S_COMMENT
        Text style COMMENT
        See Also:
        Constant Field Values
      • S_COMMENT_INV

        public static final java.lang.String S_COMMENT_INV
        Text style COMMENT inverted
        See Also:
        Constant Field Values
      • S_LONGORDER

        public static final java.lang.String S_LONGORDER
        Text style LONGORDER
        See Also:
        Constant Field Values
      • S_LONGORDER_INV

        public static final java.lang.String S_LONGORDER_INV
        Text style LONGORDER inverted
        See Also:
        Constant Field Values
    • Constructor Detail

      • OrderEditor

        public OrderEditor​(GameData data,
                           java.util.Properties settings,
                           javax.swing.undo.UndoManager _undoMgr,
                           EventDispatcher d,
                           OrderParser parser)
        Creates a new OrderEditor object.
    • Method Detail

      • registerListener

        public void registerListener()
        registers an OrderListener with the event dispatcher
      • releaseListener

        public boolean releaseListener()
        release an OrderListener with the event dispatcher
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • changedUpdate

        public void changedUpdate​(javax.swing.event.DocumentEvent e)
        Specified by:
        changedUpdate in interface javax.swing.event.DocumentListener
      • insertUpdate

        public void insertUpdate​(javax.swing.event.DocumentEvent e)
        DOCUMENT-ME
        Specified by:
        insertUpdate in interface javax.swing.event.DocumentListener
        See Also:
        DocumentListener.insertUpdate(javax.swing.event.DocumentEvent)
      • removeUpdate

        public void removeUpdate​(javax.swing.event.DocumentEvent e)
        DOCUMENT-ME
        Specified by:
        removeUpdate in interface javax.swing.event.DocumentListener
        See Also:
        DocumentListener.removeUpdate(javax.swing.event.DocumentEvent)
      • isModified

        public boolean isModified()
        Indicates whether the contents of this editor have been modified.
        Specified by:
        isModified in interface CacheableOrderEditor
      • keyPressed

        public void keyPressed​(java.awt.event.KeyEvent e)
        Specified by:
        keyPressed in interface java.awt.event.KeyListener
        See Also:
        KeyListener.keyPressed(java.awt.event.KeyEvent)
      • keyReleased

        public void keyReleased​(java.awt.event.KeyEvent e)
        Specified by:
        keyReleased in interface java.awt.event.KeyListener
        See Also:
        KeyListener.keyReleased(java.awt.event.KeyEvent)
      • keyTyped

        public void keyTyped​(java.awt.event.KeyEvent e)
        Specified by:
        keyTyped in interface java.awt.event.KeyListener
        See Also:
        KeyListener.keyTyped(java.awt.event.KeyEvent)
      • focusGained

        public void focusGained​(java.awt.event.FocusEvent e)
        Specified by:
        focusGained in interface java.awt.event.FocusListener
        See Also:
        FocusListener.focusGained(java.awt.event.FocusEvent)
      • focusLost

        public void focusLost​(java.awt.event.FocusEvent e)
        Update orders.
        Specified by:
        focusLost in interface java.awt.event.FocusListener
        See Also:
        FocusListener.focusLost(java.awt.event.FocusEvent)
      • getUnit

        public Unit getUnit()
        Returns the unit currently registered with this editor.
      • setUnit

        public void setUnit​(Unit u)
        Sets the unit for this editor component. If the orders have been modified and there is a previous unit registered with this component, its orders are updated.
      • getOrders

        public java.util.List<java.lang.String> getOrders()
        Returns a list of the orders this text pane is currently containing. A order extending over more than one line is stripped of the trailing backslashes, concatenated and returned as one order.
      • setOrders

        public void setOrders​(java.util.Collection<Order> c)
        Puts the list elements in c into this text pane, one at a time.
      • addOrder

        public void addOrder​(java.lang.String cmd)
        Adds a order to this text pane.
      • getUseSyntaxHighlighting

        public boolean getUseSyntaxHighlighting()
        Return whether syntax highlighting is enabled or disabled.
      • setTokenColor

        public void setTokenColor​(java.lang.String styleName,
                                  java.awt.Color color)
        Set the color of the specified token style used for syntax highlighting.
        Specified by:
        setTokenColor in interface CacheableOrderEditor
      • setErrorBackround

        public void setErrorBackround​(java.awt.Color c)
        Sets the background color for orders with errors.
        Parameters:
        c -
      • getDefaultColor

        public static java.lang.String getDefaultColor​(java.lang.String styleName)
        Return the default color as a string for the specified token style.
      • getText

        public java.lang.String getText()
        Gives back the text in the text pane. Additionally \r is replaced by space. This is a so-called "minor incompatibility" introduced by jdk 1.4.
        Overrides:
        getText in class javax.swing.JEditorPane
      • formatTokens

        public void formatTokens()
        Format all tokens with regard to the token type colors.
        Specified by:
        formatTokens in interface CacheableOrderEditor
      • keepVisible

        public boolean keepVisible()
        DOCUMENT-ME
      • getArgument

        public java.lang.Object getArgument()
        Returns the unit for this editor.
        Specified by:
        getArgument in interface Changeable
        Returns:
        the game object for which this Changeable is responsible.
        See Also:
        Changeable.getArgument()