Rational Developer for Power Systems Software
V7.6

com.ibm.etools.iseries.edit.language.model
Class DdsCursorListener

java.lang.Object
  extended by com.ibm.etools.iseries.edit.language.model.DdsCursorListener
All Implemented Interfaces:
IDdsParserAdapter, ILpexViewInitializer

public class DdsCursorListener
extends Object
implements IDdsParserAdapter, ILpexViewInitializer

This class listens to element changes in the currently active Lpex view and notifies a set of listeners which DdsModel statement is currently selected.


Field Summary
 
Fields inherited from interface com.ibm.etools.iseries.edit.views.IDdsParserAdapter
copyright
 
Constructor Summary
DdsCursorListener(LpexTextEditor editor, DdsModelLpexAdapter modelAdapter)
          Construct a LpexView cursor listener that will broadcast to registered listeners the newly selected DDS element
 
Method Summary
 void addStatementSelectionListener(IDdsParserListener listener)
          The adapter is to add a selection listener to its list of listeners.
 void elementChanged(LpexView lpexView)
          We spin off the updating of views dependent on the cursor position to a separate thread so that the cursor movement itself is not bogged down by synchronous updates.
 IDdsElementWithSource getCurrentSelection()
          Get the currently selected DDS element
 IDdsElementWithSource getDdsElementOnLine(int currentLine)
          From the line index of the selection in the LpexView compute the selected DDS Model object and return it.
 DdsModel getDdsModel()
          Returns DDS Model and returns null if it has not been parsed yet
 DdsType getDdsType()
          Return the type of DDS in the DDS member being edited
 boolean getReadOnlyState()
          Is the DDS source read-only/
 void initializeLpexView(LpexView newView)
           
protected  void lineDeleted(int elementBeingDeleted, LpexView view)
          Let the updating thread know that the given element has been deleted so it should update the cursored line accordingly
protected  void notifyParserListenerOfDisable()
          Notify all DDS Parser listeners that the DDS model is out of synch The UI can then disable itself
protected  void notifyParserListenerOfRefresh(IDdsElementWithSource ddsElement)
          Notify all DDS Parser listeners that the DDS model selection has changed.
protected  void notifyParserListenerOfRefresh(int lineInLpex)
          Notify all DDS Parser listeners that the DDS model selection has changed.
protected  void notifyParserListenerOfSelect(IDdsElementWithSource ddsElement)
          Notify all DDS Parser listeners that the DDS model selection has changed If nothing is selected, it will be called with null Convenience method that does not skip any listeners
protected  void notifyParserListenerOfSelect(IDdsElementWithSource ddsElement, boolean[] initiatingListeners)
          Notify all DDS Parser listeners that the DDS model selection has changed.
 void removeSelectionListener(IDdsParserListener listener)
          The adapter is to remove a listener from its list of listeners.
 void setEditor(LpexTextEditor editor)
          Set up listeners so cursor in editor will synchronize with Outline View and WebSetting View.
 void setUndoCheckpoint()
          Set undo checkpoint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DdsCursorListener

public DdsCursorListener(LpexTextEditor editor,
                         DdsModelLpexAdapter modelAdapter)
Construct a LpexView cursor listener that will broadcast to registered listeners the newly selected DDS element

Method Detail

setEditor

public void setEditor(LpexTextEditor editor)
Set up listeners so cursor in editor will synchronize with Outline View and WebSetting View.

Parameters:
editor -

addStatementSelectionListener

public void addStatementSelectionListener(IDdsParserListener listener)
Description copied from interface: IDdsParserAdapter
The adapter is to add a selection listener to its list of listeners. Whenever the cursor in the editor moves on top of a DDS statement in the editor (which can happen as a side effect of selecting it in the outline view) the listener's IDdsParserListener.selected() method is called. If the DDS model is being rebuilt the IDdsParserListener.disable() method will be called so the UI can disable itself until it receives another selected() call. If the entire adapter has to go away (unfortunately Lpex editor blows away the parser under some circumstances) then the IDdsParserListener.disconnect() method will be called. When a listener is added, this will have the side effect of making sure a DDS model is created for the associated editer

Specified by:
addStatementSelectionListener in interface IDdsParserAdapter

removeSelectionListener

public void removeSelectionListener(IDdsParserListener listener)
Description copied from interface: IDdsParserAdapter
The adapter is to remove a listener from its list of listeners.

Specified by:
removeSelectionListener in interface IDdsParserAdapter

getCurrentSelection

public IDdsElementWithSource getCurrentSelection()
Description copied from interface: IDdsParserAdapter
Get the currently selected DDS element

Specified by:
getCurrentSelection in interface IDdsParserAdapter

getReadOnlyState

public boolean getReadOnlyState()
Description copied from interface: IDdsParserAdapter
Is the DDS source read-only/

Specified by:
getReadOnlyState in interface IDdsParserAdapter

notifyParserListenerOfSelect

protected void notifyParserListenerOfSelect(IDdsElementWithSource ddsElement)
Notify all DDS Parser listeners that the DDS model selection has changed If nothing is selected, it will be called with null Convenience method that does not skip any listeners

Parameters:
ddsElement -

notifyParserListenerOfSelect

protected void notifyParserListenerOfSelect(IDdsElementWithSource ddsElement,
                                            boolean[] initiatingListeners)
Notify all DDS Parser listeners that the DDS model selection has changed. If nothing is selected, it will be called with null.

Parameters:
ddsElement - - selected DdsStatement
initiatingListeners - - array of boolean indicating if we should skip the initating listener

notifyParserListenerOfRefresh

protected void notifyParserListenerOfRefresh(int lineInLpex)
Notify all DDS Parser listeners that the DDS model selection has changed.

Parameters:
lineInLpex - - the current line in Lpex

notifyParserListenerOfRefresh

protected void notifyParserListenerOfRefresh(IDdsElementWithSource ddsElement)
Notify all DDS Parser listeners that the DDS model selection has changed. If nothing is selected, it will be called with null.

Parameters:
ddsElement - - selected IDdsElementWithSource
skipListener - - array of boolean indicating if we should skip the indexed listener

notifyParserListenerOfDisable

protected void notifyParserListenerOfDisable()
Notify all DDS Parser listeners that the DDS model is out of synch The UI can then disable itself


getDdsElementOnLine

public IDdsElementWithSource getDdsElementOnLine(int currentLine)
From the line index of the selection in the LpexView compute the selected DDS Model object and return it.

Returns:
DdsStatement containing the selected line

getDdsModel

public DdsModel getDdsModel()
Returns DDS Model and returns null if it has not been parsed yet

See Also:
com.ibm.etools.iseries.editor.views.IDdsParserAdapter#getDdsModel()

getDdsType

public DdsType getDdsType()
Description copied from interface: IDdsParserAdapter
Return the type of DDS in the DDS member being edited

Specified by:
getDdsType in interface IDdsParserAdapter

setUndoCheckpoint

public void setUndoCheckpoint()
Set undo checkpoint

Specified by:
setUndoCheckpoint in interface IDdsParserAdapter

elementChanged

public void elementChanged(LpexView lpexView)
We spin off the updating of views dependent on the cursor position to a separate thread so that the cursor movement itself is not bogged down by synchronous updates. This requires a thread safe manner of keeping track of the current position. We have two variables which cannot be updated without synchronized access. _isElementChangeUpdatePending - keeps track of whether a thread is scheduled to do an update and it is still safe to update the target value to broadcast. _lineChangedTo - keeps track of the new cursor line number that the dependent views need to become aware of. Before any threads are scheduled, these two are initialized to true, current line respectively If the line number changes before the thread has a chance to update dependent views, then the _lineChangedTo is updated for the thread to broadcast the more up-to-date value otherwise a new thread is scheduled to do the job. When the updating thread acquires the value of the new line, it turns _isElementChangeUpdatePending to false, so any further changes will result in a new thread. We also need to keep track if any of the listeners were the ones who initiate the element change, if so we will skip them in the notify to avoid infinite loops. The cursor has changed

See Also:
com.ibm.etools.iseries.editor.ISeriesEditorParser#elementChanged(com.ibm.lpex.core.LpexView)

lineDeleted

protected void lineDeleted(int elementBeingDeleted,
                           LpexView view)
Let the updating thread know that the given element has been deleted so it should update the cursored line accordingly


initializeLpexView

public void initializeLpexView(LpexView newView)
Specified by:
initializeLpexView in interface ILpexViewInitializer

Rational Developer for Power Systems Software
V7.6

Copyright 2011 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.