Package PamView

Class GuiFrameManager

java.lang.Object
PamView.GuiFrameManager
All Implemented Interfaces:
PAMControllerGUI, PamSettings, SettingsNameProvider, PamViewInterface

public class GuiFrameManager extends Object implements PamSettings, PAMControllerGUI
The GuiFrameManager manages multiple PamGui frames, each of which may contain multiple tabs of module information and a side panel.

The user can move tabs between the various frames and create new frames by right clicking on the tabs themselves.

Author:
Doug Gillespie
See Also:
  • Constructor Details

    • GuiFrameManager

      public GuiFrameManager(PamController pamController)
  • Method Details

    • getFrameList

      public List<Integer> getFrameList()
    • makeFrameList

      public void makeFrameList()
      Make a list of Gui frames - that is all PamView's with a frame number > 0 which indicates they are a GUI frame. Other frames, such as the model view, have a frame number invalid input: '<' 0.
    • getNumFrames

      public int getNumFrames()
      Get the total number of frames
      Returns:
      number of frames.
    • getFrame

      public JFrame getFrame(int iFrame)
      Get a frame
      Parameters:
      iFrame - frame number
      Returns:
      frame.
    • closeExtraFrame

      public void closeExtraFrame(PamGui pamGui)
      Closes a PamGui FRame (not the main one) All tabs are first moved to the main frame (No. 0) then the frame is removed from the list of frames then the frame is closed.
      Parameters:
      pamGui - reference to frame to close.
    • getAllFrameParameters

      public void getAllFrameParameters()
      Goes through all open frames before they start closing and gets their parameters into the structure which will be written to the psf file.
    • getFrameGui

      public PamGui getFrameGui(int iFrame)
      Get a frame GUI. This is a single frame whihc holds a GUI with tabs etc.
      Parameters:
      iFram - e- the frame index to get.
      Returns:
      the frame GUI to get.
    • getTabPopupMenu

      public JPopupMenu getTabPopupMenu(PamGui pamGui, int tabIndex)
    • getMenuFrameName

      public String getMenuFrameName(int iFrame)
    • getFrameName

      public String getFrameName(int iFrame)
      Get a name for a frame which can be used in their titles and in menus, etc.
      Parameters:
      iFrame - frame Number
      Returns:
      names String
    • sortFrameTitles

      public void sortFrameTitles()
    • addControlledUnit

      public void addControlledUnit(PamControlledUnit controlledUnit)
      Description copied from interface: PamViewInterface
      Called whenever a pamcontrolled unit is added ot the model.
      Specified by:
      addControlledUnit in interface PamViewInterface
      Parameters:
      controlledUnit - - the added controlled unit.
    • removeControlledUnit

      public void removeControlledUnit(PamControlledUnit controlledUnit)
      Description copied from interface: PamViewInterface
      Called whenever a controlled unit is removed.
      Specified by:
      removeControlledUnit in interface PamViewInterface
    • addView

      public void addView(PamViewInterface newView)
      Description copied from interface: PAMControllerGUI
      Add a PAMView Interface. This mirrors many of the functions in PAMControllerGUI
      Specified by:
      addView in interface PAMControllerGUI
    • removeView

      public void removeView(PamViewInterface oldView)
    • showControlledUnit

      public void showControlledUnit(PamControlledUnit unit)
      Description copied from interface: PamViewInterface
      Show the GUI for a specific controlled unit
      Specified by:
      showControlledUnit in interface PamViewInterface
      Parameters:
      unit - -the controlled unit to show.
    • pamStart

      public void pamStart()
    • pamStop

      public void pamStop()
    • notifyModelChanged

      public void notifyModelChanged(int changeType)
      Description copied from interface: PAMControllerGUI
      Notification flag that the model has changed
      Specified by:
      notifyModelChanged in interface PAMControllerGUI
    • destroyModel

      public void destroyModel()
      Description copied from interface: PAMControllerGUI
      Called to destroy model
      Specified by:
      destroyModel in interface PAMControllerGUI
    • getSettingsReference

      public Serializable getSettingsReference()
      Specified by:
      getSettingsReference in interface PamSettings
      Returns:
      The serialisable object that will be stored
    • getSettingsVersion

      public long getSettingsVersion()
      Specified by:
      getSettingsVersion in interface PamSettings
      Returns:
      An integer version number for the settings
    • getUnitName

      public String getUnitName()
      Specified by:
      getUnitName in interface SettingsNameProvider
      Returns:
      A Name specific to this instance of the particular class, e.g. Sperm whale detector, Beaked whale detector, etc.
    • getUnitType

      public String getUnitType()
      Specified by:
      getUnitType in interface PamSettings
      Returns:
      A Name specific to the type, e.g. Click detector
    • restoreSettings

      public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings)
      Specified by:
      restoreSettings in interface PamSettings
      Returns:
      true if successful The object performs final checks (if needed) and then casts the settings data pamcontrolledunitSettings.settings into the correct type and uses as required
    • enableGUIControl

      public void enableGUIControl(boolean enable)
      Description copied from interface: PamViewInterface
      Enable and disable the entire GUI.
      Specified by:
      enableGUIControl in interface PamViewInterface
      Parameters:
      enable - - true to enable the GUI/
    • getCollapseMenuItem

      public JMenuItem getCollapseMenuItem()
    • notifyLoadProgress

      public void notifyLoadProgress(PamTaskUpdate progress)
      Description copied from interface: PAMControllerGUI
      Notify the GUI that some loading is taking place
      Specified by:
      notifyLoadProgress in interface PAMControllerGUI
      Parameters:
      progress - - the progress.
    • getInitialSettings

      public PamSettings getInitialSettings()
      Description copied from interface: PAMControllerGUI
      Called on startup to grab pamsettings/database from somewhere.
      Specified by:
      getInitialSettings in interface PAMControllerGUI
      Returns:
      the pamsettings/database.
    • init

      public void init()
      Description copied from interface: PAMControllerGUI
      Called immediately after the creation of the GUI in the PAMController.
      Specified by:
      init in interface PAMControllerGUI
    • hasCallBack

      public boolean hasCallBack()
      Description copied from interface: PAMControllerGUI
      The GUI may have a callback into the PamController once it has all been set up. If this is the case then on init() PAMController stops and relies on the GUI code to call the relevant setupPAMGuard folder once the GUI thread is happy everything is being set up properly.
      Specified by:
      hasCallBack in interface PAMControllerGUI
      Returns:
    • initPrimaryView

      public PamViewInterface initPrimaryView(PamController pamController, PamModel pamModelInterface)
      Description copied from interface: PAMControllerGUI
      Called when the controller is ready for the fire view.
      Specified by:
      initPrimaryView in interface PAMControllerGUI
      Returns:
      init and retuirn the first view
    • getModuleName

      public String getModuleName(Object parentFrame, PamModuleInfo moduleInfo)
      Description copied from interface: PAMControllerGUI
      Get the name for a controlled unit from user input.
      Specified by:
      getModuleName in interface PAMControllerGUI
      Parameters:
      parentFrame - - an object which can be the parent frame for the dialog.
      moduleInfo - - the type of controlled unit.
      Returns:
      the name of the module.
    • pamStarted

      public void pamStarted()
      Specified by:
      pamStarted in interface PamViewInterface
    • pamEnded

      public void pamEnded()
      Specified by:
      pamEnded in interface PamViewInterface
    • modelChanged

      public void modelChanged(int changeType)
      Specified by:
      modelChanged in interface PamViewInterface
    • setTitle

      public void setTitle(String title)
      Specified by:
      setTitle in interface PamViewInterface
    • getFrameNumber

      public int getFrameNumber()
      Specified by:
      getFrameNumber in interface PamViewInterface
      Returns:
      Frame number used by the multiple GUI frames. All other objects, such as the model view should return invalid input: '<' 0.
    • getGuiFrame

      public JFrame getGuiFrame()
      Specified by:
      getGuiFrame in interface PamViewInterface
    • setDefaultFrameIcon

      public void setDefaultFrameIcon(Image frameIcon)
    • getDefaultFrameIcon

      public Image getDefaultFrameIcon()
    • findGUI

      public void findGUI()
      Function that can move GUI frames back onto the main window. Can be used to recover a GUI if it's on a monitor that is not present.