ARoad0.Gui2
Class ViewModel

java.lang.Object
  extended by ARoad0.Gui2.ViewModel
All Implemented Interfaces:
MVC_Model, StaticClass

public class ViewModel
extends java.lang.Object
implements MVC_Model, StaticClass

This class is responsible for managing the gWork.RightsMediator instances, the GraphicViewBaseListeners, the closing tab buttons which may be associated to views, and to manage the pool of view worker threads. It handles both Architecture, Full and NoThan views. When a dedicated view frame is used, the GraphicViewPropertyEditor and the GraphicView are also managed. The Architecture view is based on a ViewInBaseImpl, the 'NoThan' view on a NoThanViewInBaseImpl, and the 'full' view on a EPRViewInBaseImpl. The 'NoThan' view is put in a tab with ' ' at the beginning of the title, and all the views use their name last component in the title. The Sketch view is not managed there (see InternalFrameModel).

A worker threads pool is provided by this class. It is used by GraphicViewBaseListenerImpl and GraphicViewPropertyEditor to process the view updatings. The maximal number of worker threads is 3, and this allows to use efficiently a modern processor having from 2 to 4 cores. For a given computer, the number of worker threads may be increased or decreased in the code to speed up the updating of the views.

This class is invoked by several Action classes.

All methods are static, following the StaticClass pattern.

See Also:
GraphicViewBaseListenerImpl, InternalFrameModel

Nested Class Summary
private static class ViewModel.SimpleThreadFactory
           
 
Field Summary
private static java.util.concurrent.ExecutorService executor__
          This is a pool of worker threads which reset the views, and it is used by GraphicViewBaseListenerImpl and GraphicViewPropertyEditor.
private static javax.swing.JTabbedPane FullViewsJTabbedPane__
          the 'All Full views' JTabbedPane.
private static int INITIAL_CAPACITY
           
private static java.util.List l_graphicViewBaseListener__
          list of GraphicViewBaseListeners to control
private static java.util.List l_onGoingClosingOnAllFullViews__
          dynamic list of names for the views for which ActionClose is closing the tab in the 'All Full views' JTabbedPane.
private static java.util.List l_onGoingClosingOnAllNoThanViews__
          dynamic list of names for the views for which ActionClose is closing the tab in the 'All NoThan views' JTabbedPane.
private static java.util.List l_rightsMediators__
          list of RightsMediators to control
private static java.util.Map m_closingFullViewTabButtons__
          current closing tab JButtons associated to views when one of the 'All full views' JTabbedPane is used; the view name is the key.
private static java.util.Map m_closingNoThanViewTabButtons__
          current closing tab JButtons associated to views when the 'All NoThan views' JTabbedPane is used; the view name is the key.
private static java.util.Map m_graphicViewOfViews__
          current GraphicViews associated to views; the view name is the key does not include the beamer.
private static java.util.Map m_graphicViewPropertyEditors__
          current GraphicViewPropertyEditors associated to views when one of the two 'All views' JTabbedPane is used; the view name.toString() is the key does not include the beamer property editors used for views.
private static javax.swing.JTabbedPane NoThanViewsJTabbedPane__
          the 'All NoThan views' JTabbedPane.
private static int numberOfViewThreads__
           
 
Constructor Summary
private ViewModel()
          only one private constructor
 
Method Summary
static void addClosingTabButtonInTabbedPane(ImmutableName _name, javax.swing.JButton _component)
          Update m_closingFullViewTabButtons__ or m_closingNoThanViewTabButtons__.
static void addGraphicViewPropertyEditor(java.lang.String _viewName, GraphicViewPropertyEditor _component)
          Update m_GraphicViewPropertyEditor__.
static void addOnGoingClosingOnView(ImmutableName _name)
          Update the dynamic list of names for the Full and NoThan views which ActionClose is closing.
static void changeNonCoreAlgorithms(ViewInBase _view)
          Change the instances of NodeRightsImpl and LinkRightsImpl of the nodes, when theses nodes have changed.
static void changeRightsNetworkObserver(ViewInBase _view, GraphicView _gview)
          Register a new GraphicView, and reset the main RightsMediator rights network when the paths may have changed, from _gview.getRightsRelatedBaseObjects().
static void createGraphicViewBaseListener(ViewInBase _view, GraphicView _gview)
          Creates and registers the GraphicViewBaseListener.
static void createViewRightsMediator(ViewInBase _view)
          Creates and registers the RightsMediator associated to the view.
static javax.swing.JTabbedPane getAllFullViewsJTabbedPane()
          Gets the tabbed pane in the 'All full views' window.
static javax.swing.JTabbedPane getAllNoThanViewsJTabbedPane()
          Gets the tabbed pane in the 'All NoThan views' window.
static javax.swing.JButton getClosingTabButtonInTabbedPane(ImmutableName _name)
          Used by ActionClose.
static BaseListener getGraphicViewBaseListener(ViewInBase _view)
          Gets the main GraphicViewBaseListener associated to a view in the GUI.
static GraphicView getGraphicViewOfView(ImmutableName _name)
          Used by GraphicViewPropertyEditor.valueOf().
static GraphicViewPropertyEditor getGraphicViewPropertyEditor(java.lang.String _viewName)
          Used by BeamerManager.
static java.util.List getL_GraphicViewBaseListener()
          Gets the list of GraphicViewBaseListener associated to all the views in the GUI, excepted for the sketch view that has not any GraphicViewBaseListener.
static java.util.List getOnGoingClosingOnView()
          Used by BeamerManager.
static java.lang.String getTabTitleFromViewName(ImmutableName _name)
          Gets the tab title in the 'All views' or 'NoThan views' JTabbedPane, as two or three name components with ':: ' as separator.
static ImmutableName getViewNameFromTabTitle(java.lang.String _title)
          Gets the ViewInBase name from the tab title in the 'All full views' or from the 'All NoThan views' JTabbedPane.
static RightsMediator getViewRightsMediator(ViewInBase _view)
          Gets the main RightsNetworkObserver associated to a view in the GUI.
static java.util.concurrent.ExecutorService getViewsThreadsExecutor()
          Gets the pool of worker threads which reset the views.
static void removeClosingTabButtonInTabbedPane(ImmutableName _name)
          Update m_closingFullViewTabButtons__ or m_closingNoThanViewTabButtons__ without any check.
static void removeGraphicViewBaseListener(ViewInBase _source)
          Removes the view the GraphicViewBaseListenerImpl and the GraphicView which are associated to a view.
static void removeGraphicViewPropertyEditor(java.lang.String _viewName)
          Update m_GraphicViewPropertyEditor__.
static void removeOnGoingClosingOnView(ImmutableName _name)
          Remove a name among the Full and NoThan views which are closing.
static void removeViewRightsMediator(ViewInBase _source)
          Removes the view RightsMediator and the GraphicView which are associated to a view.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_CAPACITY

private static final int INITIAL_CAPACITY
See Also:
Constant Field Values

l_rightsMediators__

private static java.util.List l_rightsMediators__
list of RightsMediators to control


l_graphicViewBaseListener__

private static java.util.List l_graphicViewBaseListener__
list of GraphicViewBaseListeners to control


m_graphicViewOfViews__

private static java.util.Map m_graphicViewOfViews__
current GraphicViews associated to views; the view name is the key does not include the beamer.


m_graphicViewPropertyEditors__

private static java.util.Map m_graphicViewPropertyEditors__
current GraphicViewPropertyEditors associated to views when one of the two 'All views' JTabbedPane is used; the view name.toString() is the key does not include the beamer property editors used for views.


m_closingFullViewTabButtons__

private static java.util.Map m_closingFullViewTabButtons__
current closing tab JButtons associated to views when one of the 'All full views' JTabbedPane is used; the view name is the key. does not include the beamer property editors used for views.


m_closingNoThanViewTabButtons__

private static java.util.Map m_closingNoThanViewTabButtons__
current closing tab JButtons associated to views when the 'All NoThan views' JTabbedPane is used; the view name is the key. does not include the beamer property editors used for views.


FullViewsJTabbedPane__

private static javax.swing.JTabbedPane FullViewsJTabbedPane__
the 'All Full views' JTabbedPane. May be null. Updated only by ActionOpenAllFullViews.openAllFullViews().


NoThanViewsJTabbedPane__

private static javax.swing.JTabbedPane NoThanViewsJTabbedPane__
the 'All NoThan views' JTabbedPane. May be null.


l_onGoingClosingOnAllFullViews__

private static java.util.List l_onGoingClosingOnAllFullViews__
dynamic list of names for the views for which ActionClose is closing the tab in the 'All Full views' JTabbedPane. The closing has not to produce the call of the relevant ActionClose class. Used by an inner class in ViewModel and by gDMak.ActionClose.


l_onGoingClosingOnAllNoThanViews__

private static java.util.List l_onGoingClosingOnAllNoThanViews__
dynamic list of names for the views for which ActionClose is closing the tab in the 'All NoThan views' JTabbedPane. The closing has not to produce the call of the relevant ActionClose class. Used by an inner class in ViewModel and by gDMak.ActionClose.


executor__

private static java.util.concurrent.ExecutorService executor__
This is a pool of worker threads which reset the views, and it is used by GraphicViewBaseListenerImpl and GraphicViewPropertyEditor.


numberOfViewThreads__

private static int numberOfViewThreads__
Constructor Detail

ViewModel

private ViewModel()
only one private constructor

Method Detail

createViewRightsMediator

public static final void createViewRightsMediator(ViewInBase _view)
Creates and registers the RightsMediator associated to the view. Called before the GraphicView creation by ActionOpenGraphicView, ActionOpenArchitecture ActionNewView and ActionOpenSketcher.

Parameters:
_view - to process

createGraphicViewBaseListener

public static final void createGraphicViewBaseListener(ViewInBase _view,
                                                       GraphicView _gview)
Creates and registers the GraphicViewBaseListener. Registers the graphic view and updates the RightsMediator from _gview.getRightsRelatedBaseObjects(). Called after the GraphicView creation by ActionOpenGraphicView, ActionOpenArchitecture and ActionNewView. Not called by ActionOpenSketcher.

Parameters:
_view - to process
_gview - is used only for calling _gview.getRightsRelatedBaseObjects() and for updating the RightsMediator

changeRightsNetworkObserver

public static final void changeRightsNetworkObserver(ViewInBase _view,
                                                     GraphicView _gview)
Register a new GraphicView, and reset the main RightsMediator rights network when the paths may have changed, from _gview.getRightsRelatedBaseObjects(). No GraphicViewBaseListener changing since this method is called by that.

Parameters:
_view - to process
_gview - is a new or updated graphic view

changeNonCoreAlgorithms

public static final void changeNonCoreAlgorithms(ViewInBase _view)
Change the instances of NodeRightsImpl and LinkRightsImpl of the nodes, when theses nodes have changed. This method has to be called before any updating in the graphic view. Called by GraphicViewBaseListener.changeTabView() and changeFrameView(). Calls RightsMediatorImpl.updateNonCoreAlgorithmsForViewNodes().

Parameters:
_view - to process

getL_GraphicViewBaseListener

public static final java.util.List getL_GraphicViewBaseListener()
Gets the list of GraphicViewBaseListener associated to all the views in the GUI, excepted for the sketch view that has not any GraphicViewBaseListener. Used by ActionSave.

Returns:
unmodifiable list. May be empty, not null.

getViewRightsMediator

public static final RightsMediator getViewRightsMediator(ViewInBase _view)
Gets the main RightsNetworkObserver associated to a view in the GUI. Used by GraphicViewBaseListenerImpl, ActionSave, ActionOpenMainFrame, and numerous classes in the packages gWork and AcsAddon gWork.

Parameters:
_view - the view
Returns:
a RightsMediator or null

getGraphicViewBaseListener

public static final BaseListener getGraphicViewBaseListener(ViewInBase _view)
Gets the main GraphicViewBaseListener associated to a view in the GUI.

Parameters:
_view - the view
Returns:
a GraphicViewBaseListener or null

removeViewRightsMediator

public static final void removeViewRightsMediator(ViewInBase _source)
                                           throws SmallError
Removes the view RightsMediator and the GraphicView which are associated to a view. Used also for the sketch view. Called by ActionClose.

Parameters:
_source - is the ViewInBase
Throws:
SmallError - if the observer is unknown

removeGraphicViewBaseListener

public static final void removeGraphicViewBaseListener(ViewInBase _source)
                                                throws SmallError
Removes the view the GraphicViewBaseListenerImpl and the GraphicView which are associated to a view. No use for the sketch view. Called by ActionClose.

Parameters:
_source - is the ViewInBase
Throws:
SmallError - if the graphic view is unknown

addGraphicViewPropertyEditor

public static void addGraphicViewPropertyEditor(java.lang.String _viewName,
                                                GraphicViewPropertyEditor _component)
Update m_GraphicViewPropertyEditor__. Used by GraphicViewPropertyEditor.

Parameters:
_viewName - is ViewInBase.getName().toString()
_component - is associated to _object

removeGraphicViewPropertyEditor

public static void removeGraphicViewPropertyEditor(java.lang.String _viewName)
Update m_GraphicViewPropertyEditor__. Used by GraphicViewPropertyEditor.

Parameters:
_viewName - is ViewInBase.getName().toString()

getGraphicViewPropertyEditor

public static GraphicViewPropertyEditor getGraphicViewPropertyEditor(java.lang.String _viewName)
Used by BeamerManager.

Parameters:
_viewName - is ViewInBase.getName().toString()
Returns:
the GraphicViewPropertyEditor or null

getGraphicViewOfView

public static GraphicView getGraphicViewOfView(ImmutableName _name)
Used by GraphicViewPropertyEditor.valueOf().

Parameters:
_name - of a ViewInBase
Returns:
the GraphicView or null

addOnGoingClosingOnView

public static void addOnGoingClosingOnView(ImmutableName _name)
Update the dynamic list of names for the Full and NoThan views which ActionClose is closing. Used by gDMak.ActionClose.

Parameters:
_name - of the view which is closing

removeOnGoingClosingOnView

public static void removeOnGoingClosingOnView(ImmutableName _name)
Remove a name among the Full and NoThan views which are closing.

Parameters:
_name - to remove

getOnGoingClosingOnView

public static java.util.List getOnGoingClosingOnView()
Used by BeamerManager.

Returns:
unmodifiableList of the Full and NoThan views which are closing

addClosingTabButtonInTabbedPane

public static void addClosingTabButtonInTabbedPane(ImmutableName _name,
                                                   javax.swing.JButton _component)
Update m_closingFullViewTabButtons__ or m_closingNoThanViewTabButtons__. Check if it is a full view name or a NoThan view name, to update the right map. Called by BeamerManager.initializeViewTabComponent().

Parameters:
_name - of the ViewInBase
_component - is the closing button in the tab associated to the ViewInBase

removeClosingTabButtonInTabbedPane

public static void removeClosingTabButtonInTabbedPane(ImmutableName _name)
Update m_closingFullViewTabButtons__ or m_closingNoThanViewTabButtons__ without any check. Used by ActionClose.

Parameters:
_name - of the ViewInBase for which the tab is removed

getClosingTabButtonInTabbedPane

public static javax.swing.JButton getClosingTabButtonInTabbedPane(ImmutableName _name)
Used by ActionClose.

Parameters:
_name - of a full or NoThan view
Returns:
the JButton which closes the view tab, or null

getAllFullViewsJTabbedPane

public static javax.swing.JTabbedPane getAllFullViewsJTabbedPane()
Gets the tabbed pane in the 'All full views' window.

Returns:
the tabbed pane

getAllNoThanViewsJTabbedPane

public static javax.swing.JTabbedPane getAllNoThanViewsJTabbedPane()
Gets the tabbed pane in the 'All NoThan views' window.

Returns:
the tabbed pane

getTabTitleFromViewName

public static java.lang.String getTabTitleFromViewName(ImmutableName _name)
Gets the tab title in the 'All views' or 'NoThan views' JTabbedPane, as two or three name components with ':: ' as separator. For a NoThanViewInBase where the name has 3 components, the title contains the component ViewInBase_Facade.NOTHAN_VIEW_INDICATOR. The title is like the String form of a Name, without the start and the end.

Parameters:
_name - of a ViewInBase
Returns:
the title. Null if _name is null.

getViewNameFromTabTitle

public static ImmutableName getViewNameFromTabTitle(java.lang.String _title)
Gets the ViewInBase name from the tab title in the 'All full views' or from the 'All NoThan views' JTabbedPane. Called by BeamerManager.setJTabbedPane(), initializeViewTabComponent(), ActionOpenAllFull/NoThanViews.stateChanged(). Calls ViewInBase_Facade.getAllStandardOpenViews() and isNoThanViewName().

Parameters:
_title - of the tab
Returns:
ImmutableName of the view. Null only if a null argument.
Throws:
java.lang.InternalError - if the name is not found with a non-null argument

getViewsThreadsExecutor

public static java.util.concurrent.ExecutorService getViewsThreadsExecutor()
Gets the pool of worker threads which reset the views. It is used by GraphicViewBaseListenerImpl and GraphicViewPropertyEditor.

Returns:
the thread pool