public class CombinePrimitiveResolverDialog extends javax.swing.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:
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 = 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, see
setTargetPrimitive(OsmPrimitive)
.
After the dialog is closed use isApplied()
to check whether the dialog has been
applied. If it was applied 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
Apply action.
|
protected class |
CombinePrimitiveResolverDialog.CancelAction
Cancel action.
|
javax.swing.JDialog.AccessibleJDialog
java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
Modifier and Type | Field and Description |
---|---|
private boolean |
applied |
private javax.swing.JButton |
btnApply
the apply button
|
private ContextSensitiveHelpAction |
helpAction
the private help action
|
private RelationMemberConflictResolverModel |
modelRelConflictResolver |
private TagConflictResolverModel |
modelTagConflictResolver |
private javax.swing.JPanel |
pnlButtons |
protected RelationMemberConflictResolver |
pnlRelationMemberConflictResolver |
protected TagConflictResolver |
pnlTagConflictResolver |
private CombinePrimitiveResolver |
primitiveResolver |
private AutoAdjustingSplitPane |
spTagConflictTypes |
protected OsmPrimitive |
targetPrimitive |
accessibleContext, rootPane, rootPaneCheckingEnabled
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Constructor and Description |
---|
CombinePrimitiveResolverDialog(java.awt.Component parent)
Constructs a new
CombinePrimitiveResolverDialog . |
CombinePrimitiveResolverDialog(java.awt.Component parent,
TagConflictResolverModel tagModel,
RelationMemberConflictResolverModel relModel)
Constructs a new
CombinePrimitiveResolverDialog . |
Modifier and Type | Method and Description |
---|---|
private void |
adjustDividerLocation() |
protected void |
build()
Builds the components.
|
protected CombinePrimitiveResolverDialog.ApplyAction |
buildApplyAction()
Builds the "Apply" action.
|
protected javax.swing.JPanel |
buildButtonPanel()
Builds the button panel.
|
protected javax.swing.JPanel |
buildEmptyConflictsPanel()
Builds empty conflicts panel.
|
protected javax.swing.JPanel |
buildRelationMemberConflictResolverPanel()
Builds the relation member conflict resolver panel.
|
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)
Builds the list of tag change commands.
|
protected javax.swing.JPanel |
buildTagConflictResolverPanel()
Builds the tag conflict resolver panel.
|
void |
dispose() |
private static java.lang.String |
getKeyDescription(java.lang.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(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 |
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 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.
|
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.
|
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, 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 AutoAdjustingSplitPane spTagConflictTypes
private final TagConflictResolverModel modelTagConflictResolver
protected TagConflictResolver pnlTagConflictResolver
private final RelationMemberConflictResolverModel modelRelConflictResolver
protected RelationMemberConflictResolver pnlRelationMemberConflictResolver
private final CombinePrimitiveResolver primitiveResolver
private boolean applied
private javax.swing.JPanel pnlButtons
protected transient OsmPrimitive targetPrimitive
private ContextSensitiveHelpAction helpAction
private javax.swing.JButton btnApply
public CombinePrimitiveResolverDialog(java.awt.Component parent)
CombinePrimitiveResolverDialog
.parent
- The parent component in which this dialog will be displayed.public CombinePrimitiveResolverDialog(java.awt.Component parent, TagConflictResolverModel tagModel, RelationMemberConflictResolverModel relModel)
CombinePrimitiveResolverDialog
.parent
- The parent component in which this dialog will be displayed.tagModel
- tag conflict resolver modelrelModel
- relation member conflict resolver modelpublic OsmPrimitive getTargetPrimitive()
public void setTargetPrimitive(OsmPrimitive primitive)
primitive
- the target primitiveprivate void setTargetPrimitive(OsmPrimitive primitive, boolean updateTitle)
primitive
- the target primitiveupdateTitle
- true
to call updateTitle()
in EDT (can be a slow operation)protected void updateTitle()
protected final void build()
protected javax.swing.JPanel buildTagConflictResolverPanel()
protected javax.swing.JPanel buildRelationMemberConflictResolverPanel()
protected CombinePrimitiveResolverDialog.ApplyAction buildApplyAction()
protected javax.swing.JPanel buildButtonPanel()
public TagConflictResolverModel getTagConflictResolverModel()
public RelationMemberConflictResolverModel getRelationMemberConflictResolverModel()
public boolean isResolvedCompletely()
protected java.util.List<Command> buildTagChangeCommand(OsmPrimitive primitive, TagCollection tc)
primitive
- target primitivetc
- all resolutionspublic java.util.List<Command> buildResolutionCommands()
commands
needed to apply resolution choices.commands
needed to apply resolution choices.public void prepareDefaultDecisions()
private void prepareDefaultDecisions(boolean fireEvent)
fireEvent
- true
to call fireTableDataChanged
(can be a slow operation)protected javax.swing.JPanel buildEmptyConflictsPanel()
protected void prepareGUIBeforeConflictResolutionStarts()
protected void setApplied(boolean applied)
applied
- true
if this dialog has been closed with "Apply"public boolean isApplied()
public void setVisible(boolean visible)
setVisible
in class java.awt.Dialog
private void adjustDividerLocation()
public static java.util.List<Command> launchIfNecessary(TagCollection tagsOfPrimitives, java.util.Collection<? extends OsmPrimitive> primitives, java.util.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(java.util.Collection<? extends OsmPrimitive> primitives, java.util.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(java.util.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.private static java.lang.String getKeyDescription(java.lang.String key, TagCollection normalizedTags)
public void dispose()
dispose
in class java.awt.Window