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:
ImageObserver,MenuContainer,Serializable,Accessible,RootPaneContainer,WindowConstants,UndoRedoHandler.CommandQueueListener,IRelationEditor,IExtendedDialog
public class GenericRelationEditor
extends RelationEditor
implements UndoRedoHandler.CommandQueueListener
This dialog is for editing relations.
- Since:
- 343
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classException thrown when user aborts add operation.(package private) static classThe toolbar with the buttons on the left(package private) classprivate final classNested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialogNested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityTypeNested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.TypeNested 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 GenericRelationEditor.RelationEditorActionAccessprivate final ApplyActionAction for performing theApplyActionprivate final CancelActionAction for performing theCancelActionprivate final ArrayList<FlavorListener>A list of listeners that need to be notified on clipboard content changes.private booleanFlag that signals that this instance of the relation editor is currently saving the relationprivate final MemberTablethe member table and its modelprivate final MemberTableModelprivate final ReferringRelationsBrowserprivate final RefreshActionAction for performing theRefreshActionprivate final SelectActionAction for performing theSelectActionprivate final SelectionTablethe selection table and its modelprivate final SelectionTableModelprivate final TagEditorPanelthe tag table and its modelprivate final AutoCompletingTextFieldprivate JMenuItemthe menu item in the windows menu.Fields inherited from class org.openstreetmap.josm.gui.dialogs.relation.RelationEditor
RELATION_PROP, RELATION_SNAPSHOT_PROPFields inherited from class org.openstreetmap.josm.gui.ExtendedDialog
buttons, contentInsets, defaultButton, DialogClosedOtherwiseFields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabledFields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPEFields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE -
Constructor Summary
ConstructorsConstructorDescriptionGenericRelationEditor(OsmDataLayer layer, Relation relation, Collection<RelationMember> selectedMembers) Creates a new relation editor for the given relation. -
Method Summary
Modifier and TypeMethodDescriptionstatic CommandaddPrimitivesToRelation(Relation orig, Collection<? extends OsmPrimitive> primitivesToAdd) Adds primitives to a given relation.protected static JMenuItemaddToWindowMenu(IRelationEditor re, String layerName) Adds current relation editor to the windows menu (in the "volatile" group)voidapply()Apply changes.(package private) static JPanelbuildMemberEditorPanel(GenericRelationEditor.LeftButtonToolbar leftButtonToolbar, IRelationEditorActionAccess editorAccess) builds the panel for the relation member editorprivate static IRelationEditorActionGroupbuildNativeGroup(int order, AbstractRelationEditorAction... actions) protected final JPanelbuildOkCancelButtonPanel(OKAction okAction, DeleteCurrentRelationAction deleteAction, CancelAction cancelAction) builds the panel with the OK and the Cancel buttonprotected static AutoCompletingTextFieldbuilds the role text fieldprotected static JToolBarbuild the toolbar with the buttons for adding or removing the current selectionprotected static JPanelbuildSelectionTablePanel(SelectionTable selectionTable) builds the panel with the table displaying the currently selected primitivesprotected static JSplitPanebuildSplitPane(JPanel top, JPanel bottom, IRelationEditor re) builds theJSplitPanewhich divides the editor in an upper and a lower halfprotected static JPanelbuildTagEditorPanel(TagEditorPanel tagEditorPanel) builds the panel with the tag editorprotected static 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 DimensionTries to find a good value of how large the dialog should befindSuggestedRoles(Collection<TaggingPreset> presets, OsmPrimitive p) booleanReplies true if the relation has been changed in the editor (but not yet applied).private voidpopulateModels(Relation relation) private voidregisterCopyPasteAction(AbstractAction action, Object actionName, KeyStroke shortcut, JRootPane rootPane, JTable... tables) voidReloads 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(JButton okButton, 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, 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, updateTitleMethods 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, toggleSaveStateMethods 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, updateMethods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, show, toBackMethods 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, toFrontMethods 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, validateTreeMethods 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 Details
-
tagEditorPanel
the tag table and its model -
referrerBrowser
-
memberTable
the member table and its model -
memberTableModel
-
selectionTable
the selection table and its model -
selectionTableModel
-
tfRole
-
actionAccess
-
windowMenuItem
the menu item in the windows menu. Required to properly hide on dialog close. -
refreshAction
Action for performing theRefreshAction -
applyAction
Action for performing theApplyAction -
selectAction
Action for performing theSelectAction -
cancelAction
Action for performing theCancelAction -
clipboardListeners
A list of listeners that need to be notified on clipboard content changes. -
isSaving
Flag that signals that this instance of the relation editor is currently saving the relation
-
-
Constructor Details
-
GenericRelationEditor
public GenericRelationEditor(OsmDataLayer layer, Relation relation, 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 Details
-
reloadDataFromRelation
Description copied from interface:IRelationEditorReloads data from relation.- Specified by:
reloadDataFromRelationin interfaceIRelationEditor
-
populateModels
-
apply
Apply changes.- See Also:
-
select
Select relation.- Since:
- 12933
- See Also:
-
cancel
Cancel changes.- See Also:
-
buildToolBar
Creates the toolbar- Parameters:
actions- relation toolbar actions- Returns:
- the toolbar
- Since:
- 12933
-
buildOkCancelButtonPanel
protected final 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
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
builds the panel with the tag editor- Parameters:
tagEditorPanel- tag editor panel- Returns:
- the panel with the tag editor
-
buildRoleTextField
builds the role text field- Parameters:
re- relation editor- Returns:
- the role text field
-
buildMemberEditorPanel
static 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
builds the panel with the table displaying the currently selected primitives- Parameters:
selectionTable- selection table- Returns:
- panel with current selection
-
buildSplitPane
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 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
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
Description copied from class:ExtendedDialogOverride setVisible to be able to save the window geometry if required- Overrides:
setVisiblein classExtendedDialog
-
addToWindowMenu
Adds current relation editor to the windows menu (in the "volatile" group)- Parameters:
re- relation editorlayerName- layer name- Returns:
- created menu item
-
cleanSelfReferences
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(AbstractAction action, Object actionName, KeyStroke shortcut, JRootPane rootPane, JTable... tables) -
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
Warn about circular references.- Parameters:
primitive- the concerned primitive
-
warnOfCircularReferences
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, 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:
IllegalArgumentException- if orig is null
-
findSuggestedRoles
-
commandChanged
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
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
Description copied from interface:IRelationEditorSet the isSaving flag to the given value. See #24444- Specified by:
setIsSavingin interfaceIRelationEditor- Parameters:
b- the flag value
-