Class ToggleDialog

All Implemented Interfaces:
AWTEventListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, Helpful, ShowHideButtonListener, PreferenceChangedListener, Destroyable
Direct Known Subclasses:
ChangesetDialog, CommandStackDialog, ConflictDialog, FilterDialog, ImageViewerDialog, LayerListDialog, MapPaintDialog, MinimapDialog, NotesDialog, PropertiesDialog, RelationListDialog, SelectionListDialog, UserListDialog, ValidatorDialog

This class is a toggle dialog that can be turned on and off.
Since:
8
See Also:
  • Field Details

  • Constructor Details

    • ToggleDialog

      public ToggleDialog(String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight)
      Constructor
      Parameters:
      name - the name of the dialog
      iconName - the name of the icon to be displayed
      tooltip - the tool tip
      shortcut - the shortcut
      preferredHeight - the preferred height for the dialog
    • ToggleDialog

      public ToggleDialog(String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight, boolean defShow)
      Constructor
      Parameters:
      name - the name of the dialog
      iconName - the name of the icon to be displayed
      tooltip - the tool tip
      shortcut - the shortcut
      preferredHeight - the preferred height for the dialog
      defShow - if the dialog should be shown by default, if there is no preference
    • ToggleDialog

      public ToggleDialog(String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight, boolean defShow, Class<? extends PreferenceSetting> prefClass)
      Constructor
      Parameters:
      name - the name of the dialog
      iconName - the name of the icon to be displayed
      tooltip - the tool tip
      shortcut - the shortcut
      preferredHeight - the preferred height for the dialog
      defShow - if the dialog should be shown by default, if there is no preference
      prefClass - the preferences settings class, or null if not applicable
    • ToggleDialog

      public ToggleDialog(String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight, boolean defShow, Class<? extends PreferenceSetting> prefClass, boolean isExpert)
      Constructor
      Parameters:
      name - the name of the dialog
      iconName - the name of the icon to be displayed
      tooltip - the tool tip
      shortcut - the shortcut
      preferredHeight - the preferred height for the dialog
      defShow - if the dialog should be shown by default, if there is no preference
      prefClass - the preferences settings class, or null if not applicable
      isExpert - true if this dialog should only be displayed in expert mode
      Since:
      15650
  • Method Details

    • registerInWindowMenu

      protected void registerInWindowMenu(boolean isExpert)
      Registers this dialog in the window menu. Called in the constructor.
      Parameters:
      isExpert - true if this dialog should only be displayed in expert mode
      Since:
      15650
    • showDialog

      public void showDialog()
      Shows the dialog
    • unfurlDialog

      public void unfurlDialog()
      Changes the state of the dialog such that the user can see the content. (takes care of the panel reconstruction)
    • buttonHidden

      public void buttonHidden()
      Description copied from interface: ShowHideButtonListener
      Called when the button is hidden
      Specified by:
      buttonHidden in interface ShowHideButtonListener
    • buttonShown

      public void buttonShown()
      Description copied from interface: ShowHideButtonListener
      Called when the button is shown
      Specified by:
      buttonShown in interface ShowHideButtonListener
    • hideDialog

      public void hideDialog()
      Hides the dialog
    • dock

      protected void dock()
      Displays the toggle dialog in the toggle dialog view on the right of the main map window.
    • detach

      protected void detach()
      Display the dialog in a detached window.
    • collapse

      public void collapse()
      Collapses the toggle dialog to the title bar only
    • expand

      protected void expand()
      Expands the toggle dialog
    • setContentVisible

      protected void setContentVisible(boolean visible)
      Sets the visibility of all components in this toggle dialog, except the title bar
      Parameters:
      visible - true, if the components should be visible; false otherwise
    • destroy

      public void destroy()
      Description copied from interface: Destroyable
      Called when the object has been destroyed.
      Specified by:
      destroy in interface Destroyable
    • closeDetachedDialog

      public void closeDetachedDialog()
      Closes the detached dialog if this toggle dialog is currently displayed in a detached dialog.
    • showNotify

      public void showNotify()
      Called when toggle dialog is shown (after it was created or expanded). Descendants may overwrite this method, it's a good place to register listeners needed to keep dialog updated
    • hideNotify

      public void hideNotify()
      Called when toggle dialog is hidden (collapsed, removed, MapFrame is removed, ...). Good place to unregister listeners
    • getToggleAction

      Replies the action to toggle the visible state of this toggle dialog
      Returns:
      the action to toggle the visible state of this toggle dialog
    • getPreferencePrefix

      Replies the prefix for the preference settings of this dialog.
      Returns:
      the prefix for the preference settings of this dialog.
    • setDialogsPanel

      public void setDialogsPanel(DialogsPanel dialogsPanel)
      Sets the dialogsPanel managing all toggle dialogs.
      Parameters:
      dialogsPanel - The panel managing all toggle dialogs
    • getName

      public String getName()
      Replies the name of this toggle dialog
      Overrides:
      getName in class Component
    • setTitle

      public void setTitle(String title)
      Sets the title.
      Parameters:
      title - The dialog's title
    • setIsShowing

      protected void setIsShowing(boolean val)
    • setIsDocked

      protected void setIsDocked(boolean val)
    • setIsCollapsed

      protected void setIsCollapsed(boolean val)
    • setIsButtonHiding

    • getPreferredHeight

      public int getPreferredHeight()
      Returns the preferred height of this dialog.
      Returns:
      The preferred height if the toggle dialog is expanded
    • helpTopic

      public String helpTopic()
      Description copied from interface: Helpful
      Returns the help topic on JOSM wiki for this feature.
      Specified by:
      helpTopic in interface Helpful
      Returns:
      the help topic on JOSM wiki for this feature
    • toString

      public String toString()
      Overrides:
      toString in class Component
    • isDialogShowing

      public boolean isDialogShowing()
      Determines if this dialog is showing either as docked or as detached dialog.
      Returns:
      true if this dialog is showing either as docked or as detached dialog
    • isDialogInDefaultView

      public boolean isDialogInDefaultView()
      Determines if this dialog is docked and expanded.
      Returns:
      true if this dialog is docked and expanded
    • isDialogInCollapsedView

      public boolean isDialogInCollapsedView()
      Determines if this dialog is docked and collapsed.
      Returns:
      true if this dialog is docked and collapsed
    • setButton

      public void setButton(JToggleButton button)
      Sets the button from the button list that is used to display this dialog.

      Note: This is ignored by the ToggleDialog for now.

      Parameters:
      button - The button for this dialog.
    • getButton

      Gets the button from the button list that is used to display this dialog.
      Returns:
      button The button for this dialog.
    • getDefaultDetachedSize

      Returns the default size of the detached dialog. Override this method to customize the initial dialog size.
      Returns:
      the default size of the detached dialog
    • toggleButtonHook

      protected void toggleButtonHook()
      Do something when the toggleButton is pressed.
    • dockWhenClosingDetachedDlg

      protected boolean dockWhenClosingDetachedDlg()
    • stateChanged

      protected void stateChanged()
      primitive stateChangedListener for subclasses
    • createLayout

      protected Component createLayout(Component data, boolean scroll, Collection<SideButton> buttons)
      Create a component with the given layout for this component.
      Parameters:
      data - The content to be displayed
      scroll - true if it should be wrapped in a JScrollPane
      buttons - The buttons to add.
      Returns:
      The component.
    • createLayout

      @SafeVarargs protected final Component createLayout(Component data, boolean scroll, Collection<SideButton> firstButtons, Collection<SideButton>... nextButtons)
    • clearButtonActions

      public void clearButtonActions()
      Clear button actions. Should be used when recreating the layout with sidebuttons, and the previous sidebuttons are no longer desired.
      Since:
      16113
    • eventDispatched

      public void eventDispatched(AWTEvent event)
      Specified by:
      eventDispatched in interface AWTEventListener
    • preferenceChanged

      Description copied from interface: PreferenceChangedListener
      Triggered when a preference entry value changes.
      Specified by:
      preferenceChanged in interface PreferenceChangedListener
      Parameters:
      e - the preference change event
    • dynamicButtonsPropertyChanged

    • refreshHidingButtons

      private void refreshHidingButtons()
    • getLastHeight

      public int getLastHeight()
      Returns the last used height stored in preferences or preferredHeight.
      Returns:
      the last used height stored in preferences or preferredHeight
      Since:
      14425
    • rememberHeight

      public void rememberHeight()
      Store the current height in preferences so that we can restore it.
      Since:
      14425