com.borland.primetime.editor
Class Gutter

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--com.borland.primetime.editor.Gutter
All Implemented Interfaces:
javax.accessibility.Accessible, javax.swing.event.ChangeListener, javax.swing.event.DocumentListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.beans.PropertyChangeListener, java.io.Serializable

public class Gutter
extends javax.swing.JPanel
implements javax.swing.event.ChangeListener, javax.swing.event.DocumentListener, java.awt.event.MouseListener, java.beans.PropertyChangeListener

The Gutter is a panel which sits on the left edge of a TextView. It displays special marks and such that are associated with the document currently viewed in the editor.

See Also:
TextView, Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  int clickRow
           
protected  java.util.ArrayList gutterListeners
           
static int GUTTERWIDTH
          The width of the gutter, by default set to 20.
protected static java.util.ArrayList staticGutterListeners
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
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
Gutter()
          Create a new Gutter object.
 
Method Summary
 void addGutterListener(GutterListener l)
          Add a listener for gutter events.
 void addMark(int row, LineMark mark)
          Add a mark to the gutter.
static void addStaticGutterListener(GutterListener l)
          Add a listener for static gutter events.
 void changedUpdate(javax.swing.event.DocumentEvent e)
          Part of the DocumentListener interface.
protected  void fireLineClicked(int line, java.awt.event.MouseEvent e)
          This method is called when the mouse was clicked on a particular row.
protected  void fireLinesChanged()
          This method is called when the number of lines has changed in the document of the attached editor.
 EditorPane getEditor()
          Return the editor associated with this gutter.
 int getMarkLine(LineMark mark)
          Get the current location of a mark.
 LineMark[] getMarks(int lineNumber)
          This method is returns an array of the marks on a particular line.
 java.awt.Dimension getPreferredSize()
          This method is overridden because this component's actual size should always be its preferred size.
 void insertUpdate(javax.swing.event.DocumentEvent e)
          Part of the DocumentListener interface.
 void mouseClicked(java.awt.event.MouseEvent e)
          Part of the MouseListener interface.
 void mouseEntered(java.awt.event.MouseEvent e)
          Part of the MouseListener interface.
 void mouseExited(java.awt.event.MouseEvent e)
          Part of the MouseListener interface.
 void mousePressed(java.awt.event.MouseEvent e)
          Part of the MouseListener interface.
 void mouseReleased(java.awt.event.MouseEvent e)
          Part of the MouseListener interface.
protected  void paintComponent(java.awt.Graphics g)
           
protected  void paintMark(java.awt.Graphics g, int index)
          Paint the mark for a particular index
 void propertyChange(java.beans.PropertyChangeEvent e)
          Implementation of the PropertyChangeListener interface.
 void removeGutterListener(GutterListener l)
          Remove a listener for gutter events.
 void removeMark(LineMark mark)
          Remove a mark from the gutter.
static void removeStaticGutterListener(GutterListener l)
          Remove a static listener for gutter events.
 void removeUpdate(javax.swing.event.DocumentEvent e)
          Part of the DocumentListener interface.
 void setEditor(EditorPane editor)
          Set the editor to associate with this gutter.
 void setFont(java.awt.Font f)
          This is only used to remain synchronized with the font height of the associated editor.
 void stateChanged(javax.swing.event.ChangeEvent e)
          This is the implementation of the ChangeListener interface.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

gutterListeners

protected java.util.ArrayList gutterListeners

staticGutterListeners

protected static java.util.ArrayList staticGutterListeners

GUTTERWIDTH

public static int GUTTERWIDTH
The width of the gutter, by default set to 20.

clickRow

protected int clickRow
Constructor Detail

Gutter

public Gutter()
Create a new Gutter object. At this point, it has no editor associated with it.
Method Detail

setEditor

public void setEditor(EditorPane editor)
Set the editor to associate with this gutter.
Parameters:
editor - The editor associated with this gutter.

getEditor

public EditorPane getEditor()
Return the editor associated with this gutter.
Returns:
the editor associated with this gutter.

setFont

public void setFont(java.awt.Font f)
This is only used to remain synchronized with the font height of the associated editor.
Overrides:
setFont in class javax.swing.JComponent
Parameters:
f - The new font.

addGutterListener

public void addGutterListener(GutterListener l)
Add a listener for gutter events.
Parameters:
l - the new listener.

removeGutterListener

public void removeGutterListener(GutterListener l)
Remove a listener for gutter events.
Parameters:
l - the listener that should be removed.

addStaticGutterListener

public static void addStaticGutterListener(GutterListener l)
Add a listener for static gutter events.
Parameters:
l - The new static listener.

removeStaticGutterListener

public static void removeStaticGutterListener(GutterListener l)
Remove a static listener for gutter events.
Parameters:
l - The static listener that wants to be removed.

fireLineClicked

protected void fireLineClicked(int line,
                               java.awt.event.MouseEvent e)
This method is called when the mouse was clicked on a particular row.
Parameters:
line - The 1-based index of the row that was clicked on.
e - The MouseEvent that caused the click.

fireLinesChanged

protected void fireLinesChanged()
This method is called when the number of lines has changed in the document of the attached editor.

getMarkLine

public int getMarkLine(LineMark mark)
Get the current location of a mark.
Parameters:
mark - The mark of interest.
Returns:
the current line number of the specified mark; this value is 1-based. returns -1 if the mark is not found.

addMark

public void addMark(int row,
                    LineMark mark)
Add a mark to the gutter.
Parameters:
row - The 1-based row at which to add the mark.
mark - The mark to add.

removeMark

public void removeMark(LineMark mark)
Remove a mark from the gutter.
Parameters:
mark - The mark to remove.

getMarks

public LineMark[] getMarks(int lineNumber)
This method is returns an array of the marks on a particular line. If any of the marks are editor specific, meaning they should only show in one single editorPane, return only the marks for the editor belonging to this gutter.
Parameters:
lineNumber - The 1-based index of the line of interest.
Returns:
an array of the marks on the specified line.

getPreferredSize

public java.awt.Dimension getPreferredSize()
This method is overridden because this component's actual size should always be its preferred size.
Overrides:
getPreferredSize in class javax.swing.JComponent

paintComponent

protected void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

paintMark

protected void paintMark(java.awt.Graphics g,
                         int index)
Paint the mark for a particular index

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
This is the implementation of the ChangeListener interface.
Specified by:
stateChanged in interface javax.swing.event.ChangeListener
Parameters:
e - The event describing what has changed.

insertUpdate

public void insertUpdate(javax.swing.event.DocumentEvent e)
Part of the DocumentListener interface.
Specified by:
insertUpdate in interface javax.swing.event.DocumentListener
Parameters:
e - The event that describes the insert changes.

removeUpdate

public void removeUpdate(javax.swing.event.DocumentEvent e)
Part of the DocumentListener interface.
Specified by:
removeUpdate in interface javax.swing.event.DocumentListener
Parameters:
e - The event that describes the remove changes.

changedUpdate

public void changedUpdate(javax.swing.event.DocumentEvent e)
Part of the DocumentListener interface.
Specified by:
changedUpdate in interface javax.swing.event.DocumentListener
Parameters:
e - The event that describes the changedUpdate changes.

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Part of the MouseListener interface.
Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - The event that describes the mouse event.

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Part of the MouseListener interface.
Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e - The event that describes the mouse event.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Part of the MouseListener interface.
Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
e - The event that describes the mouse event.

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Part of the MouseListener interface.
Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
e - The event that describes the mouse event.

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Part of the MouseListener interface.
Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
e - The event that describes the mouse event.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Implementation of the PropertyChangeListener interface.
Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
e - The event that describes the property change.