sidekick.util
Class ElementUtil

java.lang.Object
  extended by sidekick.util.ElementUtil

public class ElementUtil
extends java.lang.Object


Constructor Summary
ElementUtil()
           
 
Method Summary
static void convert(org.gjt.sp.jedit.Buffer buffer, javax.swing.tree.DefaultMutableTreeNode node)
          Assumes the user objects in the given node, and child nodes, are objects that implement SideKickElement.
static javax.swing.text.Position createEndPosition(org.gjt.sp.jedit.Buffer buffer, SideKickElement element)
          Convert the end of a Location to a Position.
static javax.swing.text.Position createPosition(int line_offset, int column_offset)
           
static javax.swing.text.Position createStartPosition(org.gjt.sp.jedit.Buffer buffer, SideKickElement element)
          Convert the start of a Location to a Position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElementUtil

public ElementUtil()
Method Detail

createStartPosition

public static javax.swing.text.Position createStartPosition(org.gjt.sp.jedit.Buffer buffer,
                                                            SideKickElement element)
Convert the start of a Location to a Position. Need to create Positions for each node. The javacc parser finds line and column location, need to convert this to a Position in the buffer. The SideKickElement contains a column offset based on the current tab size as set in the Buffer, need to use getOffsetOfVirtualColumn to account for soft and hard tab handling. Note that this method will also set the start position in the given SideKickElement.

Parameters:
buffer - the buffer containing the child element/text in question
element - the SideKickElement representing some text in the buffer
Returns:
a Position representing the offset from the start of the buffer to the start of the element

createEndPosition

public static javax.swing.text.Position createEndPosition(org.gjt.sp.jedit.Buffer buffer,
                                                          SideKickElement element)
Convert the end of a Location to a Position. Need to create Positions for each node. The javacc parser finds line and column location, need to convert this to a Position in the buffer. The SideKickElement contains a column offset based on the current tab size as set in the Buffer, need to use getOffsetOfVirtualColumn to account for soft and hard tab handling. Note that this method will also set the end position in the given SideKickElement.

Parameters:
buffer - the buffer containing the child element/text in question
element - the SideKickElement representing some text in the buffer
Returns:
a Position representing the offset from the start of the buffer to the end of the element

createPosition

public static javax.swing.text.Position createPosition(int line_offset,
                                                       int column_offset)

convert

public static void convert(org.gjt.sp.jedit.Buffer buffer,
                           javax.swing.tree.DefaultMutableTreeNode node)
Assumes the user objects in the given node, and child nodes, are objects that implement SideKickElement. This method removes the SideKickElement from each node and replaces it with a SideKickAsset that wraps the original SideKickElement.

Parameters:
buffer - the Buffer representing the text that is to be displayed in SideKick. This is used to calculate positions for the individual tree nodes.
node - the root node of the tree to convert.