Class ViewController

Object
ViewController

public class ViewController extends Object
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 Details

    • engine

      private final EvoLudoGWT engine
      EvoLudo engine powering the views.
    • deck

      private final DeckLayoutPanel deck
      Deck widget hosting the views.
    • selector

      private final ListBox selector
      List box controlling the active view selection.
    • console

      private final Console console
      Console view that is always present.
    • onViewChanged

      private final Runnable onViewChanged
      Callback invoked whenever the view changes.
    • activeViews

      private Map<String, AbstractView<?>> activeViews
      Registry of active views keyed by name.
    • activeView

      private AbstractView<?> activeView
      Currently active view.
    • initialView

      private String initialView
      Initial view specification (index or name with optional args).
    • cloView

      private final CLOption 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 views
      deck - deck widget hosting the views
      selector - list box changing the active view
      console - console view (always included)
      onViewChanged - callback invoked whenever a view change completes
  • Method Details

    • getCloView

      public CLOption 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 --view option has been provided.
      Returns:
      true if the option is set, false otherwise
    • getActiveView

      public AbstractView<?> getActiveView()
      Retrieves the currently active view.
      Returns:
      active view instance, or null if none selected
    • getConsoleView

      public AbstractView<?> 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 -1 if no view is active
    • getActiveViews

      public List<AbstractView<?>> getActiveViews()
      Provides a snapshot of all active views, including the console.
      Returns:
      list of active views
    • containsView

      public boolean containsView(AbstractView<?> view)
      Checks whether the supplied view is managed by this controller.
      Parameters:
      view - view instance to verify
      Returns:
      true if the view is present, false otherwise
    • getFirstView

      public AbstractView<?> getFirstView()
      Returns the first available view in the registry.
      Returns:
      first view or null if none exist
    • getViewByName

      public AbstractView<?> getViewByName(String name)
      Finds a view by name.
      Parameters:
      name - view name
      Returns:
      matching view or null if 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

      public boolean changeViewByName(String name)
      Change the active view by name.
      Parameters:
      name - the view name
      Returns:
      true if the view actually changed
    • changeViewTo

      public boolean changeViewTo(AbstractView<?> newView)
      Change the currently active view.
      Parameters:
      newView - the new view
      Returns:
      true when a change occurred
    • changeViewTo

      public boolean changeViewTo(AbstractView<?> newView, boolean force)
      Change the currently active view.
      Parameters:
      newView - the new view
      force - force activation even when unchanged
      Returns:
      true when a change occurred
    • resolveInitialView

      public AbstractView<?> resolveInitialView(Logger logger)
      Parse the initial view specification (if provided) and resolve the matching view.
      Parameters:
      logger - logger for diagnostics (optional)
      Returns:
      the initial view or null if the --view option 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 module
      isODESDE - true if current model is an ODE/SDE
      oldViews - 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 module
      isODESDE - true if current model is an ODE/SDE
      oldViews - 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 module
      isODESDE - true if current model is an ODE/SDE
      oldViews - 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 module
      model - active model
      oldViews - map holding recycled views
    • addView

      private void addView(AbstractView<?> view, Map<String, AbstractView<?>> oldViews)
      Registers a view and inserts it into the deck, reusing an existing instance if available.
      Parameters:
      view - view to add
      oldViews - map that may contain reusable instances
    • updateSelector

      private void updateSelector()
      Rebuilds the selector entries so they match the deck layout.