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 class
GenericRelationEditor.AddAbortException
Exception thrown when user aborts add operation.(package private) static class
GenericRelationEditor.LeftButtonToolbar
The toolbar with the buttons on the left(package private) class
GenericRelationEditor.MemberTableDblClickAdapter
private class
GenericRelationEditor.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.RelationEditorActionAccess
actionAccess
private ApplyAction
applyAction
Action for performing theApplyAction
private CancelAction
cancelAction
Action for performing theCancelAction
private java.util.ArrayList<java.awt.datatransfer.FlavorListener>
clipboardListeners
A list of listeners that need to be notified on clipboard content changes.private MemberTable
memberTable
the member table and its modelprivate MemberTableModel
memberTableModel
private ReferringRelationsBrowser
referrerBrowser
private RefreshAction
refreshAction
Action for performing theRefreshAction
private SelectAction
selectAction
Action for performing theSelectAction
private java.awt.Component
selectedTabPane
private SelectionTable
selectionTable
the selection table and its modelprivate SelectionTableModel
selectionTableModel
private javax.swing.JTabbedPane
tabbedPane
private TagEditorPanel
tagEditorPanel
the tag table and its modelprivate AutoCompletingTextField
tfRole
private javax.swing.JMenuItem
windowMenuItem
the 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 Command
addPrimitivesToRelation(Relation orig, java.util.Collection<? extends OsmPrimitive> primitivesToAdd)
Adds primitives to a given relation.protected static javax.swing.JMenuItem
addToWindowMenu(IRelationEditor re, java.lang.String layerName)
Adds current relation editor to the windows menu (in the "volatile" group)void
apply()
Apply changes.(package private) static javax.swing.JPanel
buildMemberEditorPanel(GenericRelationEditor.LeftButtonToolbar leftButtonToolbar, IRelationEditorActionAccess editorAccess)
builds the panel for the relation member editorprivate static IRelationEditorActionGroup
buildNativeGroup(int order, AbstractRelationEditorAction... actions)
protected javax.swing.JPanel
buildOkCancelButtonPanel(OKAction okAction, DeleteCurrentRelationAction deleteAction, CancelAction cancelAction)
builds the panel with the OK and the Cancel buttonprotected static AutoCompletingTextField
buildRoleTextField(IRelationEditor re)
builds the role text fieldprotected static javax.swing.JToolBar
buildSelectionControlButtonToolbar(IRelationEditorActionAccess editorAccess)
build the toolbar with the buttons for adding or removing the current selectionprotected static javax.swing.JPanel
buildSelectionTablePanel(SelectionTable selectionTable)
builds the panel with the table displaying the currently selected primitivesprotected static javax.swing.JSplitPane
buildSplitPane(javax.swing.JPanel top, javax.swing.JPanel bottom, IRelationEditor re)
builds theJSplitPane
which divides the editor in an upper and a lower halfprotected static javax.swing.JPanel
buildTagEditorPanel(TagEditorPanel tagEditorPanel)
builds the panel with the tag editorprotected static javax.swing.JToolBar
buildToolBar(AbstractRelationEditorAction... actions)
Creates the toolbarvoid
cancel()
Cancel changes.protected static void
cleanSelfReferences(MemberTableModel memberTableModel, Relation relation)
checks whether the current relation has members referring to itself.void
commandChanged(int queueSize, int redoSize)
Notifies the listener about the new queue sizestatic boolean
confirmAddingPrimitive(OsmPrimitive primitive)
Asks confirmation before adding a primitive.void
dispose()
protected java.awt.Dimension
findMaxDialogSize()
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)
private void
populateModels(Relation relation)
private void
registerCopyPasteAction(javax.swing.AbstractAction action, java.lang.Object actionName, javax.swing.KeyStroke shortcut, javax.swing.JRootPane rootPane, javax.swing.JTable... tables)
private void
registerMain()
void
reloadDataFromRelation()
Reloads data from relation.void
select()
Select relation.void
setVisible(boolean visible)
Override setVisible to be able to save the window geometry if requiredprivate void
unregisterMain()
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.static void
warnOfCircularReferences(OsmPrimitive primitive)
Warn about circular references.static void
warnOfCircularReferences(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, 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.
-
selectedTabPane
private java.awt.Component selectedTabPane
-
tabbedPane
private final javax.swing.JTabbedPane tabbedPane
-
-
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
- theOsmDataLayer
the 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
-
registerMain
private void registerMain()
-
unregisterMain
private void unregisterMain()
-
reloadDataFromRelation
public void reloadDataFromRelation()
Description copied from interface:IRelationEditor
Reloads data from relation.- Specified by:
reloadDataFromRelation
in 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 theJSplitPane
which 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:ExtendedDialog
Tries to find a good value of how large the dialog should be- Overrides:
findMaxDialogSize
in 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:ExtendedDialog
Override setVisible to be able to save the window geometry if required- Overrides:
setVisible
in 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:
dispose
in classRelationEditor
-
confirmAddingPrimitive
public static boolean confirmAddingPrimitive(OsmPrimitive primitive) throws GenericRelationEditor.AddAbortException
Asks confirmation before adding a primitive.- Parameters:
primitive
- primitive to add- Returns:
true
is user confirms the operation,false
otherwise- 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.CommandQueueListener
Notifies the listener about the new queue size- Specified by:
commandChanged
in interfaceUndoRedoHandler.CommandQueueListener
- Parameters:
queueSize
- Undo stack sizeredoSize
- Redo stack size
-
-