Class ToggleDialog
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.openstreetmap.josm.gui.dialogs.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
public class ToggleDialog
extends JPanel
implements ShowHideButtonListener, Helpful, AWTEventListener, Destroyable, PreferenceChangedListener
This class is a toggle dialog that can be turned on and off.
- Since:
- 8
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe button-hiding strategy in toggler dialogs.private classThe dialog class used to display toggle dialogs in a detached window.protected classThe title bar displayed in docked modefinal classThe action to toggle the visibility state of this toggle dialog.Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final JRadioButtonMenuItemprivate final JRadioButtonMenuItemprotected JToggleButtonprotected ToggleDialog.ButtonHidingTypeIndicates whether dynamic button hiding is active or not.private JPanelprotected JDialogthe JDialog displaying the toggle dialog as undocked dialogprotected DialogsPanelDialogsPanel that manages all ToggleDialogsprivate final JRadioButtonMenuItemprotected booleanIf isShowing and isDocked are true, indicates whether the dialog is currently minimized or not.protected booleanIf isShowing is true, indicates whether the dialog is docked or not, e.protected booleanIndicates whether the dialog is showing or not.protected final Stringprotected Class<? extends PreferenceSetting>The linked preferences class (optional).protected Stringprivate final intthe preferred height if the toggle dialog is expandedstatic final BooleanPropertyProperty to enable dynamic buttons globally.private final ParametrizedEnumProperty<ToggleDialog.ButtonHidingType>private static final Stringprotected ToggleDialog.TitleBarprotected final ToggleDialog.ToggleDialogActionThe action to toggle this dialogprotected JCheckBoxMenuItemholds the menu entry in the windows menu.Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionToggleDialog(String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight) ConstructorToggleDialog(String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight, boolean defShow) ConstructorToggleDialog(String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight, boolean defShow, Class<? extends PreferenceSetting> prefClass) ConstructorToggleDialog(String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight, boolean defShow, Class<? extends PreferenceSetting> prefClass, boolean isExpert) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled when the button is hiddenvoidCalled when the button is shownvoidClear button actions.voidCloses the detached dialog if this toggle dialog is currently displayed in a detached dialog.voidcollapse()Collapses the toggle dialog to the title bar onlyprotected ComponentcreateLayout(Component data, boolean scroll, Collection<SideButton> buttons) Create a component with the given layout for this component.protected final ComponentcreateLayout(Component data, boolean scroll, Collection<SideButton> firstButtons, Collection<SideButton>... nextButtons) voiddestroy()Called when the object has been destroyed.protected voiddetach()Display the dialog in a detached window.protected voiddock()Displays the toggle dialog in the toggle dialog view on the right of the main map window.protected booleanprivate voidvoideventDispatched(AWTEvent event) protected voidexpand()Expands the toggle dialogGets the button from the button list that is used to display this dialog.protected DimensionReturns the default size of the detached dialog.intReturns the last used height stored in preferences or preferredHeight.getName()Replies the name of this toggle dialogReplies the prefix for the preference settings of this dialog.intReturns the preferred height of this dialog.Replies the action to toggle the visible state of this toggle dialogReturns the help topic on JOSM wiki for this feature.voidHides the dialogvoidCalled when toggle dialog is hidden (collapsed, removed, MapFrame is removed, ...).booleanDetermines if this dialog is docked and collapsed.booleanDetermines if this dialog is docked and expanded.booleanDetermines if this dialog is showing either as docked or as detached dialog.voidTriggered when a preference entry value changes.private voidprotected voidregisterInWindowMenu(boolean isExpert) Registers this dialog in the window menu.voidStore the current height in preferences so that we can restore it.voidsetButton(JToggleButton button) Sets the button from the button list that is used to display this dialog.protected voidsetContentVisible(boolean visible) Sets the visibility of all components in this toggle dialog, except the title barvoidsetDialogsPanel(DialogsPanel dialogsPanel) Sets the dialogsPanel managing all toggle dialogs.protected voidprotected voidsetIsCollapsed(boolean val) protected voidsetIsDocked(boolean val) protected voidsetIsShowing(boolean val) voidSets the title.voidShows the dialogvoidCalled when toggle dialog is shown (after it was created or expanded).protected voidprimitive stateChangedListener for subclassesprotected voidDo something when the toggleButton is pressed.toString()voidChanges the state of the dialog such that the user can see the content.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
PROP_DYNAMIC_BUTTONS
Property to enable dynamic buttons globally.- Since:
- 6752
-
SELECTED
- See Also:
-
propButtonHiding
-
toggleAction
The action to toggle this dialog -
preferencePrefix
-
name
-
dialogsPanel
DialogsPanel that manages all ToggleDialogs -
titleBar
-
isShowing
Indicates whether the dialog is showing or not. -
isDocked
If isShowing is true, indicates whether the dialog is docked or not, e. g. shown as part of the main window or as a separate dialog window. -
isCollapsed
If isShowing and isDocked are true, indicates whether the dialog is currently minimized or not. -
buttonHiding
Indicates whether dynamic button hiding is active or not. -
preferredHeight
the preferred height if the toggle dialog is expanded -
detachedDialog
the JDialog displaying the toggle dialog as undocked dialog -
button
-
buttonsPanel
-
buttonActions
-
windowMenuItem
holds the menu entry in the windows menu. Required to properly toggle the checkbox on show/hide -
alwaysShown
-
dynamic
-
alwaysHidden
-
preferenceClass
The linked preferences class (optional). If set, accessible from the title bar with a dedicated button
-
-
Constructor Details
-
ToggleDialog
public ToggleDialog(String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight) Constructor- Parameters:
name- the name of the dialogiconName- the name of the icon to be displayedtooltip- the tool tipshortcut- the shortcutpreferredHeight- 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 dialogiconName- the name of the icon to be displayedtooltip- the tool tipshortcut- the shortcutpreferredHeight- the preferred height for the dialogdefShow- 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 dialogiconName- the name of the icon to be displayedtooltip- the tool tipshortcut- the shortcutpreferredHeight- the preferred height for the dialogdefShow- if the dialog should be shown by default, if there is no preferenceprefClass- 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 dialogiconName- the name of the icon to be displayedtooltip- the tool tipshortcut- the shortcutpreferredHeight- the preferred height for the dialogdefShow- if the dialog should be shown by default, if there is no preferenceprefClass- the preferences settings class, or null if not applicableisExpert-trueif this dialog should only be displayed in expert mode- Since:
- 15650
-
-
Method Details
-
registerInWindowMenu
Registers this dialog in the window menu. Called in the constructor.- Parameters:
isExpert-trueif this dialog should only be displayed in expert mode- Since:
- 15650
-
showDialog
Shows the dialog -
unfurlDialog
Changes the state of the dialog such that the user can see the content. (takes care of the panel reconstruction) -
buttonHidden
Description copied from interface:ShowHideButtonListenerCalled when the button is hidden- Specified by:
buttonHiddenin interfaceShowHideButtonListener
-
buttonShown
Description copied from interface:ShowHideButtonListenerCalled when the button is shown- Specified by:
buttonShownin interfaceShowHideButtonListener
-
hideDialog
Hides the dialog -
dock
Displays the toggle dialog in the toggle dialog view on the right of the main map window. -
detach
Display the dialog in a detached window. -
collapse
Collapses the toggle dialog to the title bar only -
expand
Expands the toggle dialog -
setContentVisible
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
Description copied from interface:DestroyableCalled when the object has been destroyed.- Specified by:
destroyin interfaceDestroyable
-
closeDetachedDialog
Closes the detached dialog if this toggle dialog is currently displayed in a detached dialog. -
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
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
Sets the dialogsPanel managing all toggle dialogs.- Parameters:
dialogsPanel- The panel managing all toggle dialogs
-
getName
Replies the name of this toggle dialog -
setTitle
Sets the title.- Parameters:
title- The dialog's title
-
setIsShowing
-
setIsDocked
-
setIsCollapsed
-
setIsButtonHiding
-
getPreferredHeight
Returns the preferred height of this dialog.- Returns:
- The preferred height if the toggle dialog is expanded
-
helpTopic
Description copied from interface:HelpfulReturns the help topic on JOSM wiki for this feature. -
toString
-
isDialogShowing
Determines if this dialog is showing either as docked or as detached dialog.- Returns:
trueif this dialog is showing either as docked or as detached dialog
-
isDialogInDefaultView
Determines if this dialog is docked and expanded.- Returns:
trueif this dialog is docked and expanded
-
isDialogInCollapsedView
Determines if this dialog is docked and collapsed.- Returns:
trueif this dialog is docked and collapsed
-
setButton
Sets the button from the button list that is used to display this dialog.Note: This is ignored by the
ToggleDialogfor 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
Do something when the toggleButton is pressed. -
dockWhenClosingDetachedDlg
-
stateChanged
primitive stateChangedListener for subclasses -
createLayout
Create a component with the given layout for this component.- Parameters:
data- The content to be displayedscroll-trueif it should be wrapped in aJScrollPanebuttons- The buttons to add.- Returns:
- The component.
-
createLayout
@SafeVarargs protected final Component createLayout(Component data, boolean scroll, Collection<SideButton> firstButtons, Collection<SideButton>... nextButtons) -
clearButtonActions
Clear button actions. Should be used when recreating the layout with sidebuttons, and the previous sidebuttons are no longer desired.- Since:
- 16113
-
eventDispatched
- Specified by:
eventDispatchedin interfaceAWTEventListener
-
preferenceChanged
Description copied from interface:PreferenceChangedListenerTriggered when a preference entry value changes.- Specified by:
preferenceChangedin interfacePreferenceChangedListener- Parameters:
e- the preference change event
-
dynamicButtonsPropertyChanged
-
refreshHidingButtons
-
getLastHeight
Returns the last used height stored in preferences or preferredHeight.- Returns:
- the last used height stored in preferences or preferredHeight
- Since:
- 14425
-
rememberHeight
Store the current height in preferences so that we can restore it.- Since:
- 14425
-