org.openstreetmap.josm.gui.conflict.tags
Class CombinePrimitiveResolverDialog

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by org.openstreetmap.josm.gui.conflict.tags.CombinePrimitiveResolverDialog
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class CombinePrimitiveResolverDialog
extends javax.swing.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, java.util.Collection) followed by buildResolutionCommands(). Prior to launchIfNecessary(org.openstreetmap.josm.data.osm.TagCollection, java.util.Collection, java.util.Collection), the following usage sequence was needed: There is a singleton instance of this dialog which can be retrieved using getInstance(). 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.e getTagConflictResolverModel() and getRelationMemberConflictResolverModel(). Models have to be populated before the dialog is launched. Example:

    CombinePrimitiveResolverDialog dialog = CombinePrimitiveResolverDialog.getInstance();
    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, see setTargetPrimitive(OsmPrimitive). After the dialog is closed use isCanceled() to check whether the user canceled the dialog. If it wasn't canceled you may build a collection of Command objects which reflect the conflict resolution decisions the user made in the dialog: see buildResolutionCommands()

See Also:
Serialized Form

Nested Class Summary
(package private)  class CombinePrimitiveResolverDialog.AdjustDividerLocationAction
           
(package private)  class CombinePrimitiveResolverDialog.ApplyAction
           
(package private) static class CombinePrimitiveResolverDialog.AutoAdjustingSplitPane
           
(package private)  class CombinePrimitiveResolverDialog.CancelAction
           
 
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
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  SideButton btnApply
          the apply button
private  boolean canceled
           
private  ContextSensitiveHelpAction helpAction
          the private help action
private static CombinePrimitiveResolverDialog instance
          the unique instance of the dialog
private  javax.swing.JPanel pnlButtons
           
private  RelationMemberConflictResolver pnlRelationMemberConflictResolver
           
private  TagConflictResolver pnlTagConflictResolver
           
private  CombinePrimitiveResolverDialog.AutoAdjustingSplitPane spTagConflictTypes
           
private  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 javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
CombinePrimitiveResolverDialog(java.awt.Component parent)
          Constructs a new CombinePrimitiveResolverDialog.
 
Method Summary
protected  void build()
           
protected  javax.swing.JPanel buildButtonPanel()
           
protected  javax.swing.JPanel buildEmptyConflictsPanel()
           
protected  javax.swing.JPanel buildRelationMemberConflictResolverPanel()
           
 java.util.List<Command> buildResolutionCommands()
          Replies the list of commands needed to apply resolution choices.
protected  java.util.List<Command> buildTagChangeCommand(OsmPrimitive primitive, TagCollection tc)
           
protected  javax.swing.JPanel buildTagConflictResolverPanel()
           
static CombinePrimitiveResolverDialog getInstance()
          Deprecated. use launchIfNecessary(org.openstreetmap.josm.data.osm.TagCollection, java.util.Collection, java.util.Collection) instead.
 RelationMemberConflictResolverModel getRelationMemberConflictResolverModel()
          Replies the relation membership conflict resolver model.
 TagConflictResolverModel getTagConflictResolverModel()
          Replies the tag conflict resolver model.
 OsmPrimitive getTargetPrimitmive()
          Replies the target primitive the collection of primitives is merged or combined to.
protected static void informAboutRelationMembershipConflicts(java.util.Collection<? extends OsmPrimitive> primitives, java.util.Set<Relation> parentRelations)
          Inform a non-expert user about what relation membership conflict resolution means.
protected static void informAboutTagConflicts(java.util.Collection<? extends OsmPrimitive> primitives, TagCollection normalizedTags)
          Inform a non-expert user about what tag conflict resolution means.
 boolean isCanceled()
          Determines if this dialog has been cancelled.
static java.util.List<Command> launchIfNecessary(TagCollection tagsOfPrimitives, java.util.Collection<? extends OsmPrimitive> primitives, java.util.Collection<? extends OsmPrimitive> targetPrimitives)
          Replies the list of commands needed to resolve specified conflicts, by displaying if necessary a CombinePrimitiveResolverDialog to the user.
 void prepareDefaultDecisions()
          Prepares the default decisions for populated tag and relation membership conflicts.
protected  void prepareDefaultRelationDecisions()
           
protected  void prepareDefaultTagDecisions()
           
protected  void prepareGUIBeforeConflictResolutionStarts()
           
protected  void setCanceled(boolean canceled)
           
 void setTargetPrimitive(OsmPrimitive primitive)
          Sets the primitive the collection of primitives is merged or combined to.
 void setVisible(boolean visible)
           
protected  void updateTitle()
           
 
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, setModal, setModalityType, setResizable, setTitle, setUndecorated, show, toBack
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, 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, paint, 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, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, 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, isOpaque, 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, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

instance

private static CombinePrimitiveResolverDialog instance
the unique instance of the dialog


spTagConflictTypes

private CombinePrimitiveResolverDialog.AutoAdjustingSplitPane spTagConflictTypes

pnlTagConflictResolver

private TagConflictResolver pnlTagConflictResolver

pnlRelationMemberConflictResolver

private RelationMemberConflictResolver pnlRelationMemberConflictResolver

canceled

private boolean canceled

pnlButtons

private javax.swing.JPanel pnlButtons

targetPrimitive

private OsmPrimitive targetPrimitive

helpAction

private ContextSensitiveHelpAction helpAction
the private help action


btnApply

private SideButton btnApply
the apply button

Constructor Detail

CombinePrimitiveResolverDialog

public CombinePrimitiveResolverDialog(java.awt.Component parent)
Constructs a new CombinePrimitiveResolverDialog.

Parameters:
parent - The parent component in which this dialog will be displayed.
Method Detail

getInstance

@Deprecated
public static CombinePrimitiveResolverDialog getInstance()
Deprecated. use launchIfNecessary(org.openstreetmap.josm.data.osm.TagCollection, java.util.Collection, java.util.Collection) instead.

Replies the unique instance of the dialog

Returns:
the unique instance of the dialog

getTargetPrimitmive

public OsmPrimitive getTargetPrimitmive()
Replies the target primitive the collection of primitives is merged or combined to.

Returns:
the target primitive

setTargetPrimitive

public void setTargetPrimitive(OsmPrimitive primitive)
Sets the primitive the collection of primitives is merged or combined to.

Parameters:
primitive - the target primitive

updateTitle

protected void updateTitle()

build

protected void build()

buildTagConflictResolverPanel

protected javax.swing.JPanel buildTagConflictResolverPanel()

buildRelationMemberConflictResolverPanel

protected javax.swing.JPanel buildRelationMemberConflictResolverPanel()

buildButtonPanel

protected javax.swing.JPanel buildButtonPanel()

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.

buildTagChangeCommand

protected java.util.List<Command> buildTagChangeCommand(OsmPrimitive primitive,
                                                        TagCollection tc)

buildResolutionCommands

public java.util.List<Command> buildResolutionCommands()
Replies the list of commands needed to apply resolution choices.

Returns:
The list of commands needed to apply resolution choices.

prepareDefaultTagDecisions

protected void prepareDefaultTagDecisions()

prepareDefaultRelationDecisions

protected void prepareDefaultRelationDecisions()

prepareDefaultDecisions

public void prepareDefaultDecisions()
Prepares the default decisions for populated tag and relation membership conflicts.


buildEmptyConflictsPanel

protected javax.swing.JPanel buildEmptyConflictsPanel()

prepareGUIBeforeConflictResolutionStarts

protected void prepareGUIBeforeConflictResolutionStarts()

setCanceled

protected void setCanceled(boolean canceled)

isCanceled

public boolean isCanceled()
Determines if this dialog has been cancelled.

Returns:
true if this dialog has been cancelled, false otherwise.

setVisible

public void setVisible(boolean visible)
Overrides:
setVisible in class java.awt.Dialog

launchIfNecessary

public static java.util.List<Command> launchIfNecessary(TagCollection tagsOfPrimitives,
                                                        java.util.Collection<? extends OsmPrimitive> primitives,
                                                        java.util.Collection<? extends OsmPrimitive> targetPrimitives)
                                                 throws UserCancelException
Replies the list of commands needed to resolve specified conflicts, by displaying if necessary a CombinePrimitiveResolverDialog 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 to TagCollection.unionOfAllPrimitives(primitives)
primitives - The primitives to be combined
targetPrimitives - 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(java.util.Collection<? extends OsmPrimitive> primitives,
                                                             java.util.Set<Relation> parentRelations)
                                                      throws UserCancelException
Inform a non-expert user about what relation membership conflict resolution means.

Parameters:
primitives - The primitives to be combined
parentRelations - The parent relations of the primitives
Throws:
UserCancelException - If the user cancels the dialog.

informAboutTagConflicts

protected static void informAboutTagConflicts(java.util.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 combined
normalizedTags - The normalized tag collection of the primitives to be combined
Throws:
UserCancelException - If the user cancels the dialog.


JOSM