Business Objects
Quark Platform Documentation
Version 1.7.0_0
Business Objects

org.openquark.gems.client.caleditor
Class AdvancedCALEditor

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.text.JTextComponent
                  extended by javax.swing.JEditorPane
                      extended by org.openquark.gems.client.caleditor.CALEditor
                          extended by org.openquark.gems.client.caleditor.AdvancedCALEditor
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

public class AdvancedCALEditor
extends CALEditor

This is an extension of the CALEditor class, providing support for interaction with code elements such as supercombinators, class methods, data types, data constructors type classes and arguments. The editor has the following features: - uses metadata to display descriptive tooltips for code elements - facilitates identification and resolution of ambiguous elements (these are unqualified elements which belong to multiple external modules) - provides accessibility for custom menus

Author:
Iulian Radu
See Also:
Serialized Form

Nested Class Summary
static class AdvancedCALEditor.AmbiguityOffset
          A convenience class for storing an ambiguous identifier and its position.
static class AdvancedCALEditor.EditorLocation
          A convenience class for locating a portion of cal code within the buffer of the text editor.
static interface AdvancedCALEditor.IdentifierPopupMenuProvider
          Interface to define a provider for a popup menu for interacting with identifiers.
static class AdvancedCALEditor.PositionlessIdentifier
          Class representing an analysed identifier without position.
 class AdvancedCALEditor.SymbolHighlighter
          Maintains highlights over the specified symbols in the current editor.
static interface AdvancedCALEditor.SymbolRenamerListener
          Listener notified when symbol renaming completes.
static class AdvancedCALEditor.UnderlineHighlightPainter
          This class draws a little squiggly underline as the highlight.
 
Nested classes/interfaces inherited from class javax.swing.JEditorPane
JEditorPane.AccessibleJEditorPane, JEditorPane.AccessibleJEditorPaneHTML, JEditorPane.JEditorPaneAccessibleHypertextSupport
 
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent
JTextComponent.AccessibleJTextComponent, JTextComponent.KeyBinding
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
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
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
AdvancedCALEditor(ModuleTypeInfo workingModuleTypeInfo, CALWorkspace workspace)
          Constructor with module
 
Method Summary
 org.openquark.util.Pair<AdvancedCALEditor.SymbolHighlighter,AdvancedCALEditor.SymbolHighlighter> createLocalVariableHighlighters(CodeAnalyser.AnalysedIdentifier identifier)
          Create highlighters for a local variable reference or definition.
 void enterRenameMode(CodeAnalyser.AnalysedIdentifier identifier, AdvancedCALEditor.SymbolRenamerListener renameListener)
          Causes the editor to switch interaction mode to rename the specified identifier.
 List<AdvancedCALEditor.AmbiguityOffset> getAmbiguityOffsets()
          Retrieves the list of ambiguities highlighted in the editor
 AdvancedCALEditor.EditorLocation getEditorTokenOffset(int codeLine, int codeColumn, int length)
          Given a code line and column, calculates the position of a code token within the editor text buffer.
 CodeAnalyser.AnalysedIdentifier getIdentifierAtPosition(int textOffset)
           
 String getMetadataToolTipText(String unqualifiedName, ModuleName moduleName, SourceIdentifier.Category type, ModuleTypeInfo workingModuleTypeInfo)
          Retrieve formatted metadata tooltip for the specified qualification.
static String getMetadataToolTipText(String unqualifiedName, ModuleName moduleName, SourceIdentifier.Category type, ModuleTypeInfo workingModuleTypeInfo, CALWorkspace workspace, JComponent parent)
          Retrieve formatted metadata tooltip for the specified qualification.
 AdvancedCALEditor.IdentifierPopupMenuProvider getPopupMenuProvider()
           
 String getQualifiedCodeText(int offsetStart, int offsetEnd, CodeAnalyser codeAnalyser)
          Returns the fully qualified text which can be produced from the specified editor text.
 List<CodeAnalyser.AnalysedIdentifier> getSelectedIdentifiers(int offsetStart, int offsetEnd)
          Returns list of identifiers contained by the specified offsets of editor selection.
 int getTabSize()
           
 String getToolTipText(MouseEvent e)
          Retrieves tooltip text from the metadata of the identifier pointed to.
 void setModuleTypeInfo(ModuleTypeInfo moduleTypeInfo)
          Sets the module type info used
 void setPopupMenuProvider(AdvancedCALEditor.IdentifierPopupMenuProvider popupProvider)
          Set the provider for popup menus
 void setSourceIdentifiers(List<CodeAnalyser.AnalysedIdentifier> analysedIdentifiers)
          Sets the source identifiers
 void updateAmbiguityIndicators()
          Clears ambiguity identifiers, then repopulates the list of ambiguities from the analyzed identifiers.
 
Methods inherited from class org.openquark.gems.client.caleditor.CALEditor
addCALSyntaxStyleListener, removeCALSyntaxStyleListener
 
Methods inherited from class javax.swing.JEditorPane
addHyperlinkListener, createDefaultEditorKit, createEditorKitForContentType, fireHyperlinkUpdate, getAccessibleContext, getContentType, getEditorKit, getEditorKitClassNameForContentType, getEditorKitForContentType, getHyperlinkListeners, getPage, getPreferredSize, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getStream, getText, getUIClassID, paramString, read, registerEditorKitForContentType, registerEditorKitForContentType, removeHyperlinkListener, replaceSelection, scrollToReference, setContentType, setEditorKit, 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, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDocument, setDragEnabled, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, 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, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, 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, transferFocusBackward, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AdvancedCALEditor

public AdvancedCALEditor(ModuleTypeInfo workingModuleTypeInfo,
                         CALWorkspace workspace)
Constructor with module

Method Detail

getToolTipText

public String getToolTipText(MouseEvent e)
Retrieves tooltip text from the metadata of the identifier pointed to.

Overrides:
getToolTipText in class JTextComponent

getMetadataToolTipText

public String getMetadataToolTipText(String unqualifiedName,
                                     ModuleName moduleName,
                                     SourceIdentifier.Category type,
                                     ModuleTypeInfo workingModuleTypeInfo)
Retrieve formatted metadata tooltip for the specified qualification.

Parameters:
unqualifiedName - unqualified name of identifier
moduleName - identifier module name. Can be null.
type - identifier type
workingModuleTypeInfo - type info for the current module.
Returns:
metadata tooltip text

getMetadataToolTipText

public static String getMetadataToolTipText(String unqualifiedName,
                                            ModuleName moduleName,
                                            SourceIdentifier.Category type,
                                            ModuleTypeInfo workingModuleTypeInfo,
                                            CALWorkspace workspace,
                                            JComponent parent)
Retrieve formatted metadata tooltip for the specified qualification.

Parameters:
unqualifiedName - unqualified name of identifier
moduleName - identifier module name. Can be null.
type - identifier type
workingModuleTypeInfo - type info for the current module.
workspace - the related workspace.
parent - component displaying the tooltip
Returns:
metadata tooltip text

getTabSize

public int getTabSize()
Returns:
the tab size of used in this document

getIdentifierAtPosition

public CodeAnalyser.AnalysedIdentifier getIdentifierAtPosition(int textOffset)
Parameters:
textOffset - text offset of the item
Returns:
analysed identifier that the offset refers to, or null if none is found.

setSourceIdentifiers

public void setSourceIdentifiers(List<CodeAnalyser.AnalysedIdentifier> analysedIdentifiers)
Sets the source identifiers

Parameters:
analysedIdentifiers -

setModuleTypeInfo

public void setModuleTypeInfo(ModuleTypeInfo moduleTypeInfo)
Sets the module type info used

Parameters:
moduleTypeInfo -

updateAmbiguityIndicators

public void updateAmbiguityIndicators()
Clears ambiguity identifiers, then repopulates the list of ambiguities from the analyzed identifiers.


getAmbiguityOffsets

public List<AdvancedCALEditor.AmbiguityOffset> getAmbiguityOffsets()
Retrieves the list of ambiguities highlighted in the editor

Returns:
List of ambiguity offsets

getSelectedIdentifiers

public List<CodeAnalyser.AnalysedIdentifier> getSelectedIdentifiers(int offsetStart,
                                                                    int offsetEnd)
Returns list of identifiers contained by the specified offsets of editor selection. Note: identifiers are not adjusted to match the selection offsets

Parameters:
offsetStart -
offsetEnd -
Returns:
identifiers within the selected text portion

getQualifiedCodeText

public String getQualifiedCodeText(int offsetStart,
                                   int offsetEnd,
                                   CodeAnalyser codeAnalyser)
Returns the fully qualified text which can be produced from the specified editor text.

Parameters:
offsetStart -
offsetEnd -
codeAnalyser -
Returns:
fully qualified text (including local symbols)

getEditorTokenOffset

public AdvancedCALEditor.EditorLocation getEditorTokenOffset(int codeLine,
                                                             int codeColumn,
                                                             int length)
                                                      throws BadLocationException
Given a code line and column, calculates the position of a code token within the editor text buffer.

Parameters:
codeLine -
codeColumn -
length - length of text to select (-1 will auto-detect end bound)
Returns:
buffer location of the selected token
Throws:
BadLocationException - if supplied location is invalid

setPopupMenuProvider

public void setPopupMenuProvider(AdvancedCALEditor.IdentifierPopupMenuProvider popupProvider)
Set the provider for popup menus

Parameters:
popupProvider -

getPopupMenuProvider

public AdvancedCALEditor.IdentifierPopupMenuProvider getPopupMenuProvider()
Returns:
provider for popup menus

enterRenameMode

public void enterRenameMode(CodeAnalyser.AnalysedIdentifier identifier,
                            AdvancedCALEditor.SymbolRenamerListener renameListener)
Causes the editor to switch interaction mode to rename the specified identifier.

Parameters:
identifier - identifier to rename

createLocalVariableHighlighters

public org.openquark.util.Pair<AdvancedCALEditor.SymbolHighlighter,AdvancedCALEditor.SymbolHighlighter> createLocalVariableHighlighters(CodeAnalyser.AnalysedIdentifier identifier)
Create highlighters for a local variable reference or definition. If the uniformHighlightAllRelated flag is True, then all references and definition of this variable are highlighted with the same color. Otherwise, if the identifier is a reference then different colors are used for highlighting the definition and references.

Parameters:
identifier - local variable to highlight
Returns:
Pair of highlighters for references and definitions respectively