Class CombinePrimitiveResolverDialog
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Window
-
- java.awt.Dialog
-
- javax.swing.JDialog
-
- org.openstreetmap.josm.gui.conflict.tags.CombinePrimitiveResolverDialog
-
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
,RootPaneContainer
,WindowConstants
public class CombinePrimitiveResolverDialog extends JDialog
This dialog helps to resolve conflicts occurring when ways are combined or nodes are merged. Usage:launchIfNecessary(org.openstreetmap.josm.data.osm.TagCollection, java.util.Collection<? extends org.openstreetmap.josm.data.osm.OsmPrimitive>, java.util.Collection<? extends org.openstreetmap.josm.data.osm.OsmPrimitive>)
followed bybuildResolutionCommands()
. Prior tolaunchIfNecessary(org.openstreetmap.josm.data.osm.TagCollection, java.util.Collection<? extends org.openstreetmap.josm.data.osm.OsmPrimitive>, java.util.Collection<? extends org.openstreetmap.josm.data.osm.OsmPrimitive>)
, the following usage sequence was needed: The dialog uses two models: one for resolving tag conflicts, the other for resolving conflicts in relation memberships. For both models there are accessors, i.egetTagConflictResolverModel()
andgetRelationMemberConflictResolverModel()
. Models have to be populated before the dialog is launched. Example:CombinePrimitiveResolverDialog dialog = new CombinePrimitiveResolverDialog(MainApplication.getMainFrame()); dialog.getTagConflictResolverModel().populate(aTagCollection); dialog.getRelationMemberConflictResolverModel().populate(aRelationLinkCollection); dialog.prepareDefaultDecisions();
You should also set the target primitive which other primitives (ways or nodes) are merged to, seesetTargetPrimitive(OsmPrimitive)
. After the dialog is closed useisApplied()
to check whether the dialog has been applied. If it was applied you may build a collection ofCommand
objects which reflect the conflict resolution decisions the user made in the dialog: seebuildResolutionCommands()
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
CombinePrimitiveResolverDialog.AdjustDividerLocationAction
protected class
CombinePrimitiveResolverDialog.ApplyAction
Apply action.protected class
CombinePrimitiveResolverDialog.CancelAction
Cancel action.-
Nested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
-
Nested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityType
-
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.Type
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
applied
private JButton
btnApply
the apply buttonprivate ContextSensitiveHelpAction
helpAction
the private help actionprivate RelationMemberConflictResolverModel
modelRelConflictResolver
private TagConflictResolverModel
modelTagConflictResolver
private JPanel
pnlButtons
protected RelationMemberConflictResolver
pnlRelationMemberConflictResolver
protected TagConflictResolver
pnlTagConflictResolver
private CombinePrimitiveResolver
primitiveResolver
private AutoAdjustingSplitPane
spTagConflictTypes
protected OsmPrimitive
targetPrimitive
-
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
-
Fields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPE
-
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
-
-
Constructor Summary
Constructors Constructor Description CombinePrimitiveResolverDialog(Component parent)
Constructs a newCombinePrimitiveResolverDialog
.CombinePrimitiveResolverDialog(Component parent, TagConflictResolverModel tagModel, RelationMemberConflictResolverModel relModel)
Constructs a newCombinePrimitiveResolverDialog
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
adjustDividerLocation()
protected void
build()
Builds the components.protected CombinePrimitiveResolverDialog.ApplyAction
buildApplyAction()
Builds the "Apply" action.protected JPanel
buildButtonPanel()
Builds the button panel.protected JPanel
buildEmptyConflictsPanel()
Builds empty conflicts panel.protected JPanel
buildRelationMemberConflictResolverPanel()
Builds the relation member conflict resolver panel.List<Command>
buildResolutionCommands()
Replies the list ofcommands
needed to apply resolution choices.protected List<Command>
buildTagChangeCommand(OsmPrimitive primitive, TagCollection tc)
Builds the list of tag change commands.protected JPanel
buildTagConflictResolverPanel()
Builds the tag conflict resolver panel.void
dispose()
private static String
getKeyDescription(String key, TagCollection normalizedTags)
RelationMemberConflictResolverModel
getRelationMemberConflictResolverModel()
Replies the relation membership conflict resolver model.TagConflictResolverModel
getTagConflictResolverModel()
Replies the tag conflict resolver model.OsmPrimitive
getTargetPrimitive()
Replies the target primitive the collection of primitives is merged or combined to.protected static void
informAboutRelationMembershipConflicts(Collection<? extends OsmPrimitive> primitives, Set<Relation> parentRelations)
Inform a non-expert user about what relation membership conflict resolution means.protected static void
informAboutTagConflicts(Collection<? extends OsmPrimitive> primitives, TagCollection normalizedTags)
Inform a non-expert user about what tag conflict resolution means.boolean
isApplied()
Determines if this dialog has been closed with "Apply".boolean
isResolvedCompletely()
Replies true if all tag and relation member conflicts have been decided.static List<Command>
launchIfNecessary(TagCollection tagsOfPrimitives, Collection<? extends OsmPrimitive> primitives, Collection<? extends OsmPrimitive> targetPrimitives)
Replies the list ofcommands
needed to resolve specified conflicts, by displaying if necessary aCombinePrimitiveResolverDialog
to the user.void
prepareDefaultDecisions()
Prepares the default decisions for populated tag and relation membership conflicts.private void
prepareDefaultDecisions(boolean fireEvent)
Prepares the default decisions for populated tag and relation membership conflicts.protected void
prepareGUIBeforeConflictResolutionStarts()
Prepares GUI before conflict resolution starts.protected void
setApplied(boolean applied)
Sets whether this dialog has been closed with "Apply".void
setTargetPrimitive(OsmPrimitive primitive)
Sets the primitive the collection of primitives is merged or combined to.private void
setTargetPrimitive(OsmPrimitive primitive, boolean updateTitle)
Sets the primitive the collection of primitives is merged or combined to.void
setVisible(boolean visible)
protected void
updateTitle()
Updates the dialog title.-
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, 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, 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
-
spTagConflictTypes
private AutoAdjustingSplitPane spTagConflictTypes
-
modelTagConflictResolver
private final TagConflictResolverModel modelTagConflictResolver
-
pnlTagConflictResolver
protected TagConflictResolver pnlTagConflictResolver
-
modelRelConflictResolver
private final RelationMemberConflictResolverModel modelRelConflictResolver
-
pnlRelationMemberConflictResolver
protected RelationMemberConflictResolver pnlRelationMemberConflictResolver
-
primitiveResolver
private final CombinePrimitiveResolver primitiveResolver
-
applied
private boolean applied
-
pnlButtons
private JPanel pnlButtons
-
targetPrimitive
protected transient OsmPrimitive targetPrimitive
-
helpAction
private ContextSensitiveHelpAction helpAction
the private help action
-
-
Constructor Detail
-
CombinePrimitiveResolverDialog
public CombinePrimitiveResolverDialog(Component parent)
Constructs a newCombinePrimitiveResolverDialog
.- Parameters:
parent
- The parent component in which this dialog will be displayed.
-
CombinePrimitiveResolverDialog
public CombinePrimitiveResolverDialog(Component parent, TagConflictResolverModel tagModel, RelationMemberConflictResolverModel relModel)
Constructs a newCombinePrimitiveResolverDialog
.- Parameters:
parent
- The parent component in which this dialog will be displayed.tagModel
- tag conflict resolver modelrelModel
- relation member conflict resolver model- Since:
- 11772
-
-
Method Detail
-
getTargetPrimitive
public OsmPrimitive getTargetPrimitive()
Replies the target primitive the collection of primitives is merged or combined to.- Returns:
- the target primitive
- Since:
- 11772 (naming)
-
setTargetPrimitive
public void setTargetPrimitive(OsmPrimitive primitive)
Sets the primitive the collection of primitives is merged or combined to.- Parameters:
primitive
- the target primitive
-
setTargetPrimitive
private void setTargetPrimitive(OsmPrimitive primitive, boolean updateTitle)
Sets the primitive the collection of primitives is merged or combined to.- Parameters:
primitive
- the target primitiveupdateTitle
-true
to callupdateTitle()
in EDT (can be a slow operation)- Since:
- 11626
-
updateTitle
protected void updateTitle()
Updates the dialog title.
-
build
protected final void build()
Builds the components.
-
buildTagConflictResolverPanel
protected JPanel buildTagConflictResolverPanel()
Builds the tag conflict resolver panel.- Returns:
- the tag conflict resolver panel
-
buildRelationMemberConflictResolverPanel
protected JPanel buildRelationMemberConflictResolverPanel()
Builds the relation member conflict resolver panel.- Returns:
- the relation member conflict resolver panel
-
buildApplyAction
protected CombinePrimitiveResolverDialog.ApplyAction buildApplyAction()
Builds the "Apply" action.- Returns:
- the "Apply" action
-
buildButtonPanel
protected JPanel buildButtonPanel()
Builds the button panel.- Returns:
- the button panel
-
getTagConflictResolverModel
public TagConflictResolverModel getTagConflictResolverModel()
Replies the tag conflict resolver model.- Returns:
- The tag conflict resolver model.
-
getRelationMemberConflictResolverModel
public RelationMemberConflictResolverModel getRelationMemberConflictResolverModel()
Replies the relation membership conflict resolver model.- Returns:
- The relation membership conflict resolver model.
-
isResolvedCompletely
public boolean isResolvedCompletely()
Replies true if all tag and relation member conflicts have been decided.- Returns:
- true if all tag and relation member conflicts have been decided; false otherwise
-
buildTagChangeCommand
protected List<Command> buildTagChangeCommand(OsmPrimitive primitive, TagCollection tc)
Builds the list of tag change commands.- Parameters:
primitive
- target primitivetc
- all resolutions- Returns:
- the list of tag change commands
-
buildResolutionCommands
public List<Command> buildResolutionCommands()
Replies the list ofcommands
needed to apply resolution choices.- Returns:
- The list of
commands
needed to apply resolution choices.
-
prepareDefaultDecisions
public void prepareDefaultDecisions()
Prepares the default decisions for populated tag and relation membership conflicts.
-
prepareDefaultDecisions
private void prepareDefaultDecisions(boolean fireEvent)
Prepares the default decisions for populated tag and relation membership conflicts.- Parameters:
fireEvent
-true
to callfireTableDataChanged
(can be a slow operation)- Since:
- 11626
-
buildEmptyConflictsPanel
protected JPanel buildEmptyConflictsPanel()
Builds empty conflicts panel.- Returns:
- empty conflicts panel
-
prepareGUIBeforeConflictResolutionStarts
protected void prepareGUIBeforeConflictResolutionStarts()
Prepares GUI before conflict resolution starts.
-
setApplied
protected void setApplied(boolean applied)
Sets whether this dialog has been closed with "Apply".- Parameters:
applied
-true
if this dialog has been closed with "Apply"
-
isApplied
public boolean isApplied()
Determines if this dialog has been closed with "Apply".- Returns:
- true if this dialog has been closed with "Apply", false otherwise.
-
setVisible
public void setVisible(boolean visible)
- Overrides:
setVisible
in classDialog
-
adjustDividerLocation
private void adjustDividerLocation()
-
launchIfNecessary
public static List<Command> launchIfNecessary(TagCollection tagsOfPrimitives, Collection<? extends OsmPrimitive> primitives, Collection<? extends OsmPrimitive> targetPrimitives) throws UserCancelException
Replies the list ofcommands
needed to resolve specified conflicts, by displaying if necessary aCombinePrimitiveResolverDialog
to the user. This dialog will allow the user to choose conflict resolution actions. Non-expert users are informed first of the meaning of these operations, allowing them to cancel.- Parameters:
tagsOfPrimitives
- The tag collection of the primitives to be combined. Should generally be equal toTagCollection.unionOfAllPrimitives(primitives)
primitives
- The primitives to be combinedtargetPrimitives
- The primitives the collection of primitives are merged or combined to.- Returns:
- The list of
commands
needed to apply resolution actions. - Throws:
UserCancelException
- If the user cancelled a dialog.
-
informAboutRelationMembershipConflicts
protected static void informAboutRelationMembershipConflicts(Collection<? extends OsmPrimitive> primitives, Set<Relation> parentRelations) throws UserCancelException
Inform a non-expert user about what relation membership conflict resolution means.- Parameters:
primitives
- The primitives to be combinedparentRelations
- The parent relations of the primitives- Throws:
UserCancelException
- If the user cancels the dialog.
-
informAboutTagConflicts
protected static void informAboutTagConflicts(Collection<? extends OsmPrimitive> primitives, TagCollection normalizedTags) throws UserCancelException
Inform a non-expert user about what tag conflict resolution means.- Parameters:
primitives
- The primitives to be combinednormalizedTags
- The normalized tag collection of the primitives to be combined- Throws:
UserCancelException
- If the user cancels the dialog.
-
getKeyDescription
private static String getKeyDescription(String key, TagCollection normalizedTags)
-
-