Class ViewController
Object
ViewController
Controller that manages the set of
AbstractView instances displayed
in the EvoLudo web client. Responsibilities include creating and recycling
views, keeping the deck and selector widgets in sync, processing the
--view CLO, and switching between views while ensuring proper
activation/deactivation.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AbstractView<?> Currently active view.private Map<String, AbstractView<?>> Registry of active views keyed by name.private final CLOptionCLO option controlling the initial view selection.private final ConsoleConsole view that is always present.private final DeckLayoutPanelDeck widget hosting the views.private final EvoLudoGWTEvoLudo engine powering the views.private StringInitial view specification (index or name with optional args).private final RunnableCallback invoked whenever the view changes.private final ListBoxList box controlling the active view selection. -
Constructor Summary
ConstructorsConstructorDescriptionViewController(EvoLudoGWT engine, DeckLayoutPanel deck, ListBox selector, Console console, Runnable onViewChanged) Create a controller instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddFitnessViews(Module<?> module, boolean isODESDE, Map<String, AbstractView<?>> oldViews) Adds fitness-related views based on module capabilities.private voidaddStatisticsViews(Module<?> module, Model model, Map<String, AbstractView<?>> oldViews) Adds statistics-related views based on model permissions.private voidaddStrategyViews(Module<?> module, boolean isODESDE, Map<String, AbstractView<?>> oldViews) Adds strategy-related views according to module capabilities.private voidaddStructureViews(Module<?> module, boolean isODESDE, Map<String, AbstractView<?>> oldViews) Adds structure-related views when available.private voidaddView(AbstractView<?> view, Map<String, AbstractView<?>> oldViews) Registers a view and inserts it into the deck, reusing an existing instance if available.booleanchangeViewByName(String name) Change the active view by name.booleanchangeViewTo(AbstractView<?> newView) Change the currently active view.booleanchangeViewTo(AbstractView<?> newView, boolean force) Change the currently active view.booleancontainsView(AbstractView<?> view) Checks whether the supplied view is managed by this controller.AbstractView<?> Retrieves the currently active view.intReports the index of the active view inside the deck.List<AbstractView<?>> Provides a snapshot of all active views, including the console.Returns the CLO option controlling the initial view displayed in the GUI.AbstractView<?> Provides access to the console view.AbstractView<?> Returns the first available view in the registry.AbstractView<?> getViewByName(String name) Finds a view by name.booleanDetermines whether the--viewoption has been provided.voidEnsure the console is present while applying CLO changes and temporarily show it while parsing options.voidUpdates the list of available views based on the current module and model.voidResets the selection state when modules/models unload.AbstractView<?> resolveInitialView(Logger logger) Parse the initial view specification (if provided) and resolve the matching view.private voidRebuilds the selector entries so they match the deck layout.
-
Field Details
-
engine
EvoLudo engine powering the views. -
deck
Deck widget hosting the views. -
selector
List box controlling the active view selection. -
console
Console view that is always present. -
onViewChanged
Callback invoked whenever the view changes. -
activeViews
Registry of active views keyed by name. -
activeView
Currently active view. -
initialView
Initial view specification (index or name with optional args). -
cloView
CLO option controlling the initial view selection.
-
-
Constructor Details
-
ViewController
public ViewController(EvoLudoGWT engine, DeckLayoutPanel deck, ListBox selector, Console console, Runnable onViewChanged) Create a controller instance.- Parameters:
engine- EvoLudo engine powering the viewsdeck- deck widget hosting the viewsselector- list box changing the active viewconsole- console view (always included)onViewChanged- callback invoked whenever a view change completes
-
-
Method Details
-
getCloView
Returns the CLO option controlling the initial view displayed in the GUI.- Returns:
- command-line option that selects the view
-
isInitialViewSet
public boolean isInitialViewSet()Determines whether the--viewoption has been provided.- Returns:
trueif the option is set,falseotherwise
-
getActiveView
Retrieves the currently active view.- Returns:
- active view instance, or
nullif none selected
-
getConsoleView
Provides access to the console view.- Returns:
- console view instance
-
getActiveViewIndex
public int getActiveViewIndex()Reports the index of the active view inside the deck.- Returns:
- zero-based deck index or
-1if no view is active
-
getActiveViews
Provides a snapshot of all active views, including the console.- Returns:
- list of active views
-
containsView
Checks whether the supplied view is managed by this controller.- Parameters:
view- view instance to verify- Returns:
trueif the view is present,falseotherwise
-
getFirstView
Returns the first available view in the registry.- Returns:
- first view or
nullif none exist
-
getViewByName
Finds a view by name.- Parameters:
name- view name- Returns:
- matching view or
nullif absent
-
resetSelection
public void resetSelection()Resets the selection state when modules/models unload. -
prepareForCLO
public void prepareForCLO()Ensure the console is present while applying CLO changes and temporarily show it while parsing options. -
refreshViews
public void refreshViews()Updates the list of available views based on the current module and model. -
changeViewByName
Change the active view by name.- Parameters:
name- the view name- Returns:
trueif the view actually changed
-
changeViewTo
Change the currently active view.- Parameters:
newView- the new view- Returns:
truewhen a change occurred
-
changeViewTo
Change the currently active view.- Parameters:
newView- the new viewforce- force activation even when unchanged- Returns:
truewhen a change occurred
-
resolveInitialView
Parse the initial view specification (if provided) and resolve the matching view.- Parameters:
logger- logger for diagnostics (optional)- Returns:
- the initial view or
nullif the--viewoption was not provided - See Also:
-
addStrategyViews
private void addStrategyViews(Module<?> module, boolean isODESDE, Map<String, AbstractView<?>> oldViews) Adds strategy-related views according to module capabilities.- Parameters:
module- active moduleisODESDE-trueif current model is an ODE/SDEoldViews- map holding recycled views
-
addFitnessViews
private void addFitnessViews(Module<?> module, boolean isODESDE, Map<String, AbstractView<?>> oldViews) Adds fitness-related views based on module capabilities.- Parameters:
module- active moduleisODESDE-trueif current model is an ODE/SDEoldViews- map holding recycled views
-
addStructureViews
private void addStructureViews(Module<?> module, boolean isODESDE, Map<String, AbstractView<?>> oldViews) Adds structure-related views when available.- Parameters:
module- active moduleisODESDE-trueif current model is an ODE/SDEoldViews- map holding recycled views
-
addStatisticsViews
private void addStatisticsViews(Module<?> module, Model model, Map<String, AbstractView<?>> oldViews) Adds statistics-related views based on model permissions.- Parameters:
module- active modulemodel- active modeloldViews- map holding recycled views
-
addView
Registers a view and inserts it into the deck, reusing an existing instance if available.- Parameters:
view- view to addoldViews- map that may contain reusable instances
-
updateSelector
private void updateSelector()Rebuilds the selector entries so they match the deck layout.
-