Nekit
v 0.9

com.nekhem.nekit
Class ListContext

java.lang.Object
  |
  +--com.nekhem.nekit.ListContext
All Implemented Interfaces:
CaretContext

public class ListContext
extends java.lang.Object
implements CaretContext

ListContext contains the code for managing bullet lists and numbered lists


Field Summary
static java.lang.Object[] listTags
          Convenience array for various pourposes
 
Constructor Summary
ListContext(NekitPane nekitPane, NekitDocument nekitDoc)
          Constructor Registers as a Context within NekitPane
 
Method Summary
 void addList(java.lang.String type)
          Build a completely new bullet list at the caret position
 void buttonsOk(java.lang.String whichOn)
          Set the toggle buttons according to the parameter
 java.lang.String currentType()
          The active type of list (is any)
 void fillToolBar(javax.swing.JToolBar tb, javax.swing.Action[] actions, java.lang.String[] labels, java.lang.String[] iconNames)
          Put the toggle buttons on the toolbar
 javax.swing.text.Element findContainingListElement(int start, int end)
          If the region from start to end is included in a single Element of type "UL" or "OL", return that element.
 boolean handleNewLine(int pos)
          A new line into a bullet list means: "add another bullet here", unless there's already a single bullet on the line: in that case it means: "end bullets and start a normal paragraph"
 boolean isActive()
          Is the caret in this Context?
 void newPosition()
          The caret has been moved to a new Position
 void setAllOff()
          Say that there's no list active
 void setBulletsOn()
          activate the button of bullets
 void setNumbersOn()
          Activate the button of numbers
 void setOff()
          Transform the current bullet lines in normal lines
 void setOn(java.lang.String id)
          Transform the current (selected) lines in a bullet/numbered list
 void splitList()
          divide the bullet line in 2 at the caret position
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listTags

public static java.lang.Object[] listTags
Convenience array for various pourposes

Constructor Detail

ListContext

public ListContext(NekitPane nekitPane,
                   NekitDocument nekitDoc)
Constructor Registers as a Context within NekitPane

Parameters:
nekitPane - the current Pane
nekitDoc - the current Document
Method Detail

handleNewLine

public boolean handleNewLine(int pos)
A new line into a bullet list means: "add another bullet here", unless there's already a single bullet on the line: in that case it means: "end bullets and start a normal paragraph"

Specified by:
handleNewLine in interface CaretContext
Parameters:
pos - the caret position
Returns:
true if completely handled

fillToolBar

public void fillToolBar(javax.swing.JToolBar tb,
                        javax.swing.Action[] actions,
                        java.lang.String[] labels,
                        java.lang.String[] iconNames)
Put the toggle buttons on the toolbar

Parameters:
tb - The toolbar
actions - the two Actions (bullets and numbers)
labels - the tooltips of the buttons
iconNames - the name of the corresponding icons

currentType

public java.lang.String currentType()
The active type of list (is any)

Returns:
the type

newPosition

public void newPosition()
Description copied from interface: CaretContext
The caret has been moved to a new Position

Specified by:
newPosition in interface CaretContext

isActive

public boolean isActive()
Description copied from interface: CaretContext
Is the caret in this Context?

Specified by:
isActive in interface CaretContext
Returns:
trivial

setAllOff

public void setAllOff()
Say that there's no list active


setNumbersOn

public void setNumbersOn()
Activate the button of numbers


setBulletsOn

public void setBulletsOn()
activate the button of bullets


buttonsOk

public void buttonsOk(java.lang.String whichOn)
Set the toggle buttons according to the parameter

Parameters:
whichOn - which type of list is on (bullets, numbers)

setOn

public void setOn(java.lang.String id)
Transform the current (selected) lines in a bullet/numbered list

Parameters:
id - type of list ("bullets" / "numbers")

setOff

public void setOff()
Transform the current bullet lines in normal lines


findContainingListElement

public javax.swing.text.Element findContainingListElement(int start,
                                                          int end)
If the region from start to end is included in a single Element of type "UL" or "OL", return that element.

Parameters:
start - start of the text region
end - end of the text region
Returns:
The Element found or null

splitList

public void splitList()
divide the bullet line in 2 at the caret position


addList

public void addList(java.lang.String type)
Build a completely new bullet list at the caret position

Parameters:
type - the type of list ("bullets", "numbers")

Nekit
v 0.9

Submit a bug or feature
Nekhem Technologies