Class GenericRelationEditor
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Window
-
- java.awt.Dialog
-
- javax.swing.JDialog
-
- org.openstreetmap.josm.gui.ExtendedDialog
-
- org.openstreetmap.josm.gui.dialogs.relation.RelationEditor
-
- org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,javax.accessibility.Accessible,javax.swing.RootPaneContainer,javax.swing.WindowConstants,UndoRedoHandler.CommandQueueListener,IRelationEditor,IExtendedDialog
public class GenericRelationEditor extends RelationEditor implements UndoRedoHandler.CommandQueueListener
This dialog is for editing relations.- Since:
- 343
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGenericRelationEditor.AddAbortExceptionException thrown when user aborts add operation.(package private) static classGenericRelationEditor.LeftButtonToolbarThe toolbar with the buttons on the left(package private) classGenericRelationEditor.MemberTableDblClickAdapterprivate classGenericRelationEditor.RelationEditorActionAccess-
Nested classes/interfaces inherited from class javax.swing.JDialog
javax.swing.JDialog.AccessibleJDialog
-
Nested classes/interfaces inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
-
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
-
-
Field Summary
Fields Modifier and Type Field Description private GenericRelationEditor.RelationEditorActionAccessactionAccessprivate ApplyActionapplyActionAction for performing theApplyActionprivate CancelActioncancelActionAction for performing theCancelActionprivate java.util.ArrayList<java.awt.datatransfer.FlavorListener>clipboardListenersA list of listeners that need to be notified on clipboard content changes.private booleanisSavingFlag that signals that this instance of the relation editor is currently saving the relationprivate MemberTablememberTablethe member table and its modelprivate MemberTableModelmemberTableModelprivate ReferringRelationsBrowserreferrerBrowserprivate RefreshActionrefreshActionAction for performing theRefreshActionprivate SelectActionselectActionAction for performing theSelectActionprivate SelectionTableselectionTablethe selection table and its modelprivate SelectionTableModelselectionTableModelprivate TagEditorPaneltagEditorPanelthe tag table and its modelprivate AutoCompletingTextFieldtfRoleprivate javax.swing.JMenuItemwindowMenuItemthe menu item in the windows menu.-
Fields inherited from class org.openstreetmap.josm.gui.dialogs.relation.RelationEditor
RELATION_PROP, RELATION_SNAPSHOT_PROP
-
Fields inherited from class org.openstreetmap.josm.gui.ExtendedDialog
buttons, contentInsets, defaultButton, DialogClosedOtherwise
-
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
-
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
-
Constructor Summary
Constructors Constructor Description GenericRelationEditor(OsmDataLayer layer, Relation relation, java.util.Collection<RelationMember> selectedMembers)Creates a new relation editor for the given relation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CommandaddPrimitivesToRelation(Relation orig, java.util.Collection<? extends OsmPrimitive> primitivesToAdd)Adds primitives to a given relation.protected static javax.swing.JMenuItemaddToWindowMenu(IRelationEditor re, java.lang.String layerName)Adds current relation editor to the windows menu (in the "volatile" group)voidapply()Apply changes.(package private) static javax.swing.JPanelbuildMemberEditorPanel(GenericRelationEditor.LeftButtonToolbar leftButtonToolbar, IRelationEditorActionAccess editorAccess)builds the panel for the relation member editorprivate static IRelationEditorActionGroupbuildNativeGroup(int order, AbstractRelationEditorAction... actions)protected javax.swing.JPanelbuildOkCancelButtonPanel(OKAction okAction, DeleteCurrentRelationAction deleteAction, CancelAction cancelAction)builds the panel with the OK and the Cancel buttonprotected static AutoCompletingTextFieldbuildRoleTextField(IRelationEditor re)builds the role text fieldprotected static javax.swing.JToolBarbuildSelectionControlButtonToolbar(IRelationEditorActionAccess editorAccess)build the toolbar with the buttons for adding or removing the current selectionprotected static javax.swing.JPanelbuildSelectionTablePanel(SelectionTable selectionTable)builds the panel with the table displaying the currently selected primitivesprotected static javax.swing.JSplitPanebuildSplitPane(javax.swing.JPanel top, javax.swing.JPanel bottom, IRelationEditor re)builds theJSplitPanewhich divides the editor in an upper and a lower halfprotected static javax.swing.JPanelbuildTagEditorPanel(TagEditorPanel tagEditorPanel)builds the panel with the tag editorprotected static javax.swing.JToolBarbuildToolBar(AbstractRelationEditorAction... actions)Creates the toolbarvoidcancel()Cancel changes.protected static voidcleanSelfReferences(MemberTableModel memberTableModel, Relation relation)checks whether the current relation has members referring to itself.voidcommandChanged(int queueSize, int redoSize)Notifies the listener about the new queue sizestatic booleanconfirmAddingPrimitive(OsmPrimitive primitive)Asks confirmation before adding a primitive.voiddispose()protected java.awt.DimensionfindMaxDialogSize()Tries to find a good value of how large the dialog should beprotected static java.util.Set<java.lang.String>findSuggestedRoles(java.util.Collection<TaggingPreset> presets, OsmPrimitive p)booleanisDirtyEditor()Replies true if the relation has been changed in the editor (but not yet applied).private voidpopulateModels(Relation relation)private voidregisterCopyPasteAction(javax.swing.AbstractAction action, java.lang.Object actionName, javax.swing.KeyStroke shortcut, javax.swing.JRootPane rootPane, javax.swing.JTable... tables)voidreloadDataFromRelation()Reloads data from relation.voidselect()Select relation.voidsetIsSaving(boolean b)Set the isSaving flag to the given value.voidsetVisible(boolean visible)Override setVisible to be able to save the window geometry if requiredprivate voidupdateOkPanel(javax.swing.JButton okButton, javax.swing.JButton deleteButton)Update the OK panel area with a temporary relation that looks if it were to be saved now.static voidwarnOfCircularReferences(OsmPrimitive primitive)Warn about circular references.static voidwarnOfCircularReferences(OsmPrimitive primitive, java.util.List<Relation> loop)Warn about circular references.-
Methods inherited from class org.openstreetmap.josm.gui.dialogs.relation.RelationEditor
addPropertyChangeListener, getEditor, getLayer, getRelation, getRelationSnapshot, isDirtyRelation, isDirtyRelation, removePropertyChangeListener, setRelation, setRelationSnapshot, updateTitle
-
Methods inherited from class org.openstreetmap.josm.gui.ExtendedDialog
buttonAction, configureContextsensitiveHelp, createButtonAction, getValue, initWindowGeometry, rememberWindowGeometry, setButtonIcons, setButtonIcons, setCancelButton, setContent, setContent, setContent, setDefaultButton, setFocusOnDefaultButton, setIcon, setIcon, setRememberWindowGeometry, setToolTipTexts, setupDialog, showDialog, toggleCheckState, toggleEnable, toggleSaveState
-
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
-
Methods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, show, toBack
-
Methods inherited from class java.awt.Window
addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFront
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
tagEditorPanel
private final TagEditorPanel tagEditorPanel
the tag table and its model
-
referrerBrowser
private final ReferringRelationsBrowser referrerBrowser
-
memberTable
private final MemberTable memberTable
the member table and its model
-
memberTableModel
private final MemberTableModel memberTableModel
-
selectionTable
private final SelectionTable selectionTable
the selection table and its model
-
selectionTableModel
private final SelectionTableModel selectionTableModel
-
tfRole
private final AutoCompletingTextField tfRole
-
actionAccess
private final GenericRelationEditor.RelationEditorActionAccess actionAccess
-
windowMenuItem
private javax.swing.JMenuItem windowMenuItem
the menu item in the windows menu. Required to properly hide on dialog close.
-
refreshAction
private final RefreshAction refreshAction
Action for performing theRefreshAction
-
applyAction
private final ApplyAction applyAction
Action for performing theApplyAction
-
selectAction
private final SelectAction selectAction
Action for performing theSelectAction
-
cancelAction
private final CancelAction cancelAction
Action for performing theCancelAction
-
clipboardListeners
private final java.util.ArrayList<java.awt.datatransfer.FlavorListener> clipboardListeners
A list of listeners that need to be notified on clipboard content changes.
-
isSaving
private boolean isSaving
Flag that signals that this instance of the relation editor is currently saving the relation
-
-
Constructor Detail
-
GenericRelationEditor
public GenericRelationEditor(OsmDataLayer layer, Relation relation, java.util.Collection<RelationMember> selectedMembers)
Creates a new relation editor for the given relation. The relation will be saved if the user selects "ok" in the editor.If no relation is given, will create an editor for a new relation.
- Parameters:
layer- theOsmDataLayerthe new or edited relation belongs torelation- relation to edit, or null to create a new one.selectedMembers- a collection of members which shall be selected initially
-
-
Method Detail
-
reloadDataFromRelation
public void reloadDataFromRelation()
Description copied from interface:IRelationEditorReloads data from relation.- Specified by:
reloadDataFromRelationin interfaceIRelationEditor
-
populateModels
private void populateModels(Relation relation)
-
apply
public void apply()
Apply changes.- See Also:
ApplyAction
-
select
public void select()
Select relation.- Since:
- 12933
- See Also:
SelectAction
-
cancel
public void cancel()
Cancel changes.- See Also:
CancelAction
-
buildToolBar
protected static javax.swing.JToolBar buildToolBar(AbstractRelationEditorAction... actions)
Creates the toolbar- Parameters:
actions- relation toolbar actions- Returns:
- the toolbar
- Since:
- 12933
-
buildOkCancelButtonPanel
protected final javax.swing.JPanel buildOkCancelButtonPanel(OKAction okAction, DeleteCurrentRelationAction deleteAction, CancelAction cancelAction)
builds the panel with the OK and the Cancel button- Parameters:
okAction- OK actiondeleteAction- Delete actioncancelAction- Cancel action- Returns:
- the panel with the OK and the Cancel button
-
updateOkPanel
private void updateOkPanel(javax.swing.JButton okButton, javax.swing.JButton deleteButton)
Update the OK panel area with a temporary relation that looks if it were to be saved now.- Parameters:
okButton- The OK buttondeleteButton- The delete button
-
buildTagEditorPanel
protected static javax.swing.JPanel buildTagEditorPanel(TagEditorPanel tagEditorPanel)
builds the panel with the tag editor- Parameters:
tagEditorPanel- tag editor panel- Returns:
- the panel with the tag editor
-
buildRoleTextField
protected static AutoCompletingTextField buildRoleTextField(IRelationEditor re)
builds the role text field- Parameters:
re- relation editor- Returns:
- the role text field
-
buildMemberEditorPanel
static javax.swing.JPanel buildMemberEditorPanel(GenericRelationEditor.LeftButtonToolbar leftButtonToolbar, IRelationEditorActionAccess editorAccess)
builds the panel for the relation member editor- Parameters:
leftButtonToolbar- left button toolbareditorAccess- The relation editor- Returns:
- the panel for the relation member editor
-
buildSelectionTablePanel
protected static javax.swing.JPanel buildSelectionTablePanel(SelectionTable selectionTable)
builds the panel with the table displaying the currently selected primitives- Parameters:
selectionTable- selection table- Returns:
- panel with current selection
-
buildSplitPane
protected static javax.swing.JSplitPane buildSplitPane(javax.swing.JPanel top, javax.swing.JPanel bottom, IRelationEditor re)
builds theJSplitPanewhich divides the editor in an upper and a lower half- Parameters:
top- top panelbottom- bottom panelre- relation editor- Returns:
- the split panel
-
buildSelectionControlButtonToolbar
protected static javax.swing.JToolBar buildSelectionControlButtonToolbar(IRelationEditorActionAccess editorAccess)
build the toolbar with the buttons for adding or removing the current selection- Parameters:
editorAccess- relation editor- Returns:
- control buttons panel for selection/members
-
buildNativeGroup
private static IRelationEditorActionGroup buildNativeGroup(int order, AbstractRelationEditorAction... actions)
-
findMaxDialogSize
protected java.awt.Dimension findMaxDialogSize()
Description copied from class:ExtendedDialogTries to find a good value of how large the dialog should be- Overrides:
findMaxDialogSizein classExtendedDialog- Returns:
- Dimension Size of the parent component if visible or 2/3 of screen size if not available or hidden
-
setVisible
public void setVisible(boolean visible)
Description copied from class:ExtendedDialogOverride setVisible to be able to save the window geometry if required- Overrides:
setVisiblein classExtendedDialog
-
addToWindowMenu
protected static javax.swing.JMenuItem addToWindowMenu(IRelationEditor re, java.lang.String layerName)
Adds current relation editor to the windows menu (in the "volatile" group)- Parameters:
re- relation editorlayerName- layer name- Returns:
- created menu item
-
cleanSelfReferences
protected static void cleanSelfReferences(MemberTableModel memberTableModel, Relation relation)
checks whether the current relation has members referring to itself. If so, warns the users and provides an option for removing these members.- Parameters:
memberTableModel- member table modelrelation- relation
-
registerCopyPasteAction
private void registerCopyPasteAction(javax.swing.AbstractAction action, java.lang.Object actionName, javax.swing.KeyStroke shortcut, javax.swing.JRootPane rootPane, javax.swing.JTable... tables)
-
dispose
public void dispose()
- Overrides:
disposein classRelationEditor
-
confirmAddingPrimitive
public static boolean confirmAddingPrimitive(OsmPrimitive primitive) throws GenericRelationEditor.AddAbortException
Asks confirmation before adding a primitive.- Parameters:
primitive- primitive to add- Returns:
trueis user confirms the operation,falseotherwise- Throws:
GenericRelationEditor.AddAbortException- if user aborts operation
-
warnOfCircularReferences
public static void warnOfCircularReferences(OsmPrimitive primitive)
Warn about circular references.- Parameters:
primitive- the concerned primitive
-
warnOfCircularReferences
public static void warnOfCircularReferences(OsmPrimitive primitive, java.util.List<Relation> loop)
Warn about circular references.- Parameters:
primitive- the concerned primitiveloop- list of relation that form the circular dependencies. Only used to report the loop if more than one relation is involved.- Since:
- 16651
-
addPrimitivesToRelation
public static Command addPrimitivesToRelation(Relation orig, java.util.Collection<? extends OsmPrimitive> primitivesToAdd)
Adds primitives to a given relation.- Parameters:
orig- The relation to modifyprimitivesToAdd- The primitives to add as relation members- Returns:
- The resulting command
- Throws:
java.lang.IllegalArgumentException- if orig is null
-
findSuggestedRoles
protected static java.util.Set<java.lang.String> findSuggestedRoles(java.util.Collection<TaggingPreset> presets, OsmPrimitive p)
-
commandChanged
public void commandChanged(int queueSize, int redoSize)
Description copied from interface:UndoRedoHandler.CommandQueueListenerNotifies the listener about the new queue size- Specified by:
commandChangedin interfaceUndoRedoHandler.CommandQueueListener- Parameters:
queueSize- Undo stack sizeredoSize- Redo stack size
-
isDirtyEditor
public boolean isDirtyEditor()
Description copied from interface:IRelationEditorReplies true if the relation has been changed in the editor (but not yet applied). Reloading data from the relation would cause the pending changes to be lost.- Specified by:
isDirtyEditorin interfaceIRelationEditor- Returns:
- true if the currently edited relation has been changed in the editor.
-
setIsSaving
public void setIsSaving(boolean b)
Description copied from interface:IRelationEditorSet the isSaving flag to the given value. See #24444- Specified by:
setIsSavingin interfaceIRelationEditor- Parameters:
b- the flag value
-
-