public class CombinePrimitiveResolverDialog extends JDialog
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 by buildResolutionCommands()
.
Prior to 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>)
, 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()
Modifier and Type | Class and Description |
---|---|
(package private) class |
CombinePrimitiveResolverDialog.AdjustDividerLocationAction |
protected class |
CombinePrimitiveResolverDialog.ApplyAction |
(package private) static class |
CombinePrimitiveResolverDialog.AutoAdjustingSplitPane |
(package private) class |
CombinePrimitiveResolverDialog.CancelAction |
JDialog.AccessibleJDialog
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityType
Window.AccessibleAWTWindow, Window.Type
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
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 JPanel |
pnlButtons |
protected RelationMemberConflictResolver |
pnlRelationMemberConflictResolver |
private TagConflictResolver |
pnlTagConflictResolver |
private CombinePrimitiveResolverDialog.AutoAdjustingSplitPane |
spTagConflictTypes |
protected OsmPrimitive |
targetPrimitive |
accessibleContext, rootPane, rootPaneCheckingEnabled
DEFAULT_MODALITY_TYPE
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
CombinePrimitiveResolverDialog(Component parent)
Constructs a new
CombinePrimitiveResolverDialog . |
Modifier and Type | Method and Description |
---|---|
protected void |
build() |
protected CombinePrimitiveResolverDialog.ApplyAction |
buildApplyAction() |
protected JPanel |
buildButtonPanel() |
protected JPanel |
buildEmptyConflictsPanel() |
protected JPanel |
buildRelationMemberConflictResolverPanel() |
List<Command> |
buildResolutionCommands()
Replies the list of
commands needed to apply resolution choices. |
protected List<Command> |
buildTagChangeCommand(OsmPrimitive primitive,
TagCollection tc) |
protected JPanel |
buildTagConflictResolverPanel() |
static CombinePrimitiveResolverDialog |
getInstance()
|
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(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 |
isCanceled()
Determines if this dialog has been cancelled.
|
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 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() |
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
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, show, toBack
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, 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
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
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, 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, 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, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
private static CombinePrimitiveResolverDialog instance
private CombinePrimitiveResolverDialog.AutoAdjustingSplitPane spTagConflictTypes
private TagConflictResolver pnlTagConflictResolver
protected RelationMemberConflictResolver pnlRelationMemberConflictResolver
private boolean canceled
private JPanel pnlButtons
protected OsmPrimitive targetPrimitive
private ContextSensitiveHelpAction helpAction
private SideButton btnApply
public CombinePrimitiveResolverDialog(Component parent)
CombinePrimitiveResolverDialog
.parent
- The parent component in which this dialog will be displayed.@Deprecated public static CombinePrimitiveResolverDialog getInstance()
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>)
instead.public OsmPrimitive getTargetPrimitmive()
public void setTargetPrimitive(OsmPrimitive primitive)
primitive
- the target primitiveprotected void updateTitle()
protected final void build()
protected JPanel buildTagConflictResolverPanel()
protected JPanel buildRelationMemberConflictResolverPanel()
protected CombinePrimitiveResolverDialog.ApplyAction buildApplyAction()
protected JPanel buildButtonPanel()
public TagConflictResolverModel getTagConflictResolverModel()
public RelationMemberConflictResolverModel getRelationMemberConflictResolverModel()
public boolean isResolvedCompletely()
protected List<Command> buildTagChangeCommand(OsmPrimitive primitive, TagCollection tc)
public List<Command> buildResolutionCommands()
commands
needed to apply resolution choices.commands
needed to apply resolution choices.protected void prepareDefaultTagDecisions()
protected void prepareDefaultRelationDecisions()
public void prepareDefaultDecisions()
protected JPanel buildEmptyConflictsPanel()
protected void prepareGUIBeforeConflictResolutionStarts()
protected void setCanceled(boolean canceled)
public boolean isCanceled()
public void setVisible(boolean visible)
setVisible
in class Dialog
public static List<Command> launchIfNecessary(TagCollection tagsOfPrimitives, Collection<? extends OsmPrimitive> primitives, Collection<? extends OsmPrimitive> targetPrimitives) throws UserCancelException
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.tagsOfPrimitives
- The tag collection of the primitives to be combined.
Should generally be equal to TagCollection.unionOfAllPrimitives(primitives)
primitives
- The primitives to be combinedtargetPrimitives
- The primitives the collection of primitives are merged or combined to.commands
needed to apply resolution actions.UserCancelException
- If the user cancelled a dialog.protected static void informAboutRelationMembershipConflicts(Collection<? extends OsmPrimitive> primitives, Set<Relation> parentRelations) throws UserCancelException
primitives
- The primitives to be combinedparentRelations
- The parent relations of the primitivesUserCancelException
- If the user cancels the dialog.protected static void informAboutTagConflicts(Collection<? extends OsmPrimitive> primitives, TagCollection normalizedTags) throws UserCancelException
primitives
- The primitives to be combinednormalizedTags
- The normalized tag collection of the primitives to be combinedUserCancelException
- If the user cancels the dialog.