|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectARoad0.Gui2.GraphicViewBaseListenerImpl
public class GraphicViewBaseListenerImpl
This important class manages the GraphicView associated in the GUI to a ViewInBase, and it is the main manager of a specialized thread to update the view and its rights at every relevant base changing. It is created by ViewModel. Its structure is derived from ViewTreeBaseListenerImpl, but it is more complex. It is responsible for listening the events:
- fired after any relevant change in a ViewInBase object or in its ACS, through the ViewInBase or directly,
- fired by the RightsNetworkObserver associated to the view, and this includes the listening of the specific events from any AcsAddon ACS or any of its objects.
Each event source is registered only one time. EPRviewInBase and NoThanViewInBase are handled for a dedicated listening. The ViewInBase updatings activate all the changings in the GraphicView. The opening and closing of views are managed only by ActionClose. This class does not listen the relevant events, and it is finalized indirectly by ActionClose through ViewModel. To avoid an useless processing of view rights, ActionSave calls setListenEvents(false) before any saving. It restores the listening after the saving.
The thread management for the views is described hereinafter.
Using the view threads, the first aim is to update quickly the access paths of a view when a property has changed in a view node. This is why it is done outside the event dispatch thread and the main thread, in a pool of worker threads managed by Gui2.ViewModel. The worker thread works also at the view creation or opening. In all cases, after the paths search, the graphic view updating is done in the event dispatch thread. All the worker threads have the same priority.
The second aim of the thread management is to process the paths search only once, while a database editing may generate several property changes for the same user action. A TIMER_DELAY of 150 ms is set to not process immediatly the first property change. After the TIMER_DELAY, even if several change events have been fired, the access path search reads the current state of the base. The maximal number of worker threads is set to 3 in Gui2.ViewModel.
This class is running under the event dispatch thread (EVT), and the calling sequence is:
- calls to propertyChange() one or several times, by one or several objects in gBase or gWork, and updates the relevant listeners in the base for each base change
- propertyChange() updates the 2 booleans toChange_ and toUpdated_, starts a timer at the first firing, and restarts it at each firing,
- the timer calls actionPerformed() when the TIMER_DELAY is expired, after 150 milliseconds,
- actionPerformed() reads toChange_ and toUpdate_, and it calls changeFrameView(), changeTabView() or updateFrameViewRights(); then it stops the timer,
- changeTabView() and sometimes actionPerformed() calls GraphicViewPropertyEditor.PropertyChangeEvent() if the view is in a JTabbedPane, which uses a worker thread to update the view, then run a task in the EVT to terminate the GUI updating through a call to repaint(),
- changeFrameView() and updateFrameViewRights() use also a worker thread to update the view, then to run a task in the EVT; this task terminates the GUI updating by the way of a call to repaint(),
- actionPerformed() resets the instance for the next firings on propertyChange().
In all cases after the view creation, the worker thread is run to call GraphicView.resetRights() or resetGraphicView(), and there is a call to GraphicView.setWhyText() in the EVT. The task in the worker thread is then ended. Since the worker thread is in a pool which is provided by ViewModel, the same thread is able to process a new task for another GraphicViewBaseListenerImpl instance, or for the same instance.
Field Summary | |
---|---|
private boolean |
listenEvents_
|
private RightsMediator |
rightsNetworkObserver_
|
private javax.swing.Timer |
timer_
|
private static int |
TIMER_DELAY
|
private boolean |
toChange_
|
private boolean |
toUpdate_
|
private ViewInBase |
view_
|
private ImmutableName |
viewName_
|
private java.lang.Thread |
worker_
This is used by propertyChange to create a worker thread which resets the view. |
Constructor Summary | |
---|---|
GraphicViewBaseListenerImpl()
Public constructor. |
|
GraphicViewBaseListenerImpl(ViewInBase _source)
With this constructor, the GraphicViewBaseListenerImpl is registered as a listener for the view and a RightsNetworkObserver. |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent _evt)
Receives the event from timer_ when the last event has been received by propertyChange() at TIMER_DELAY, and calls an updating method for the view. |
private void |
changeFrameView()
Resets the graphic view which has a different set of nodes, and the 'See why' frame if it is open, but not the explorer. |
private void |
changeTabView()
Updates the RightsMediator and the view tab (GraphicView and 'See why'). |
void |
finalizeForUser()
Unregisters the instance as a listener for all registered sources. |
ImmutableName |
getEorMainEventSource()
Get the main event source associated to the instance in its construction. |
void |
propertyChange(java.beans.PropertyChangeEvent _evt)
Receives all the events about the view property changes, adds and removes this instance as property listener in the changing base objects, and calls actionPerformed() after a delay to avoid multiple unuseful calls for the same basic event. |
boolean |
setListenEvents(boolean _listen)
To listen or not the events in propertyChange(). |
java.lang.String |
toString()
|
private void |
updateFrameViewRights()
Resets the rights without node changing. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ARoad0.Gui2.BaseListener |
---|
hashCode |
Field Detail |
---|
private static int TIMER_DELAY
private boolean listenEvents_
private ViewInBase view_
private ImmutableName viewName_
private RightsMediator rightsNetworkObserver_
private java.lang.Thread worker_
private javax.swing.Timer timer_
private boolean toChange_
private boolean toUpdate_
Constructor Detail |
---|
public GraphicViewBaseListenerImpl()
public GraphicViewBaseListenerImpl(ViewInBase _source)
_source
- is the view to manageMethod Detail |
---|
public ImmutableName getEorMainEventSource()
getEorMainEventSource
in interface BaseListener
public boolean setListenEvents(boolean _listen)
setListenEvents
in interface BaseListener
_listen
- true to listen the events in this instance, through propertyChange()
public void actionPerformed(java.awt.event.ActionEvent _evt)
actionPerformed
in interface java.awt.event.ActionListener
_evt
- contains a null commandpublic void propertyChange(java.beans.PropertyChangeEvent _evt)
propertyChange
in interface java.beans.PropertyChangeListener
_evt
- PropertyChangeEventprivate void changeFrameView()
private void updateFrameViewRights()
private void changeTabView()
public void finalizeForUser()
finalizeForUser
in interface BaseListener
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |