Пример #1
0
  /** builds the UI */
  protected final void build() {
    tabbedPane = new JTabbedPane();

    propertiesMerger = new PropertiesMerger();
    propertiesMerger.setName("panel.propertiesmerger");
    propertiesMerger.getModel().addPropertyChangeListener(this);
    tabbedPane.add(tr("Properties"), propertiesMerger);

    tagMerger = new TagMerger();
    tagMerger.setName("panel.tagmerger");
    tagMerger.getModel().addPropertyChangeListener(this);
    tabbedPane.add(tr("Tags"), tagMerger);

    nodeListMerger = new NodeListMerger();
    nodeListMerger.setName("panel.nodelistmerger");
    nodeListMerger.getModel().addPropertyChangeListener(this);
    tabbedPane.add(tr("Nodes"), nodeListMerger);

    relationMemberMerger = new RelationMemberMerger();
    relationMemberMerger.setName("panel.relationmembermerger");
    relationMemberMerger.getModel().addPropertyChangeListener(this);
    tabbedPane.add(tr("Members"), relationMemberMerger);

    setLayout(new BorderLayout());
    add(tabbedPane, BorderLayout.CENTER);

    conflictResolvers.add(propertiesMerger);
    conflictResolvers.add(tagMerger);
    conflictResolvers.add(nodeListMerger);
    conflictResolvers.add(relationMemberMerger);
  }
Пример #2
0
 /** Updates the state of the property {@link #RESOLVED_COMPLETELY_PROP} */
 protected void updateResolvedCompletely() {
   boolean oldValueResolvedCompletely = resolvedCompletely;
   if (my instanceof Node) {
     // resolve the version conflict if this is a node and all tag
     // conflicts have been resolved
     //
     this.resolvedCompletely =
         tagMerger.getModel().isResolvedCompletely()
             && propertiesMerger.getModel().isResolvedCompletely();
   } else if (my instanceof Way) {
     // resolve the version conflict if this is a way, all tag
     // conflicts have been resolved, and conflicts in the node list
     // have been resolved
     //
     this.resolvedCompletely =
         tagMerger.getModel().isResolvedCompletely()
             && propertiesMerger.getModel().isResolvedCompletely()
             && nodeListMerger.getModel().isFrozen();
   } else if (my instanceof Relation) {
     // resolve the version conflict if this is a relation, all tag
     // conflicts and all conflicts in the member list
     // have been resolved
     //
     this.resolvedCompletely =
         tagMerger.getModel().isResolvedCompletely()
             && propertiesMerger.getModel().isResolvedCompletely()
             && relationMemberMerger.getModel().isFrozen();
   }
   if (this.resolvedCompletely != oldValueResolvedCompletely) {
     firePropertyChange(
         RESOLVED_COMPLETELY_PROP, oldValueResolvedCompletely, this.resolvedCompletely);
   }
 }
Пример #3
0
  /**
   * Builds the resolution command(s) for the resolved conflicts in this ConflictResolver
   *
   * @return the resolution command
   */
  public Command buildResolveCommand() {
    List<Command> commands = new ArrayList<>();

    if (tagMerger.getModel().getNumResolvedConflicts() > 0) {
      commands.add(tagMerger.getModel().buildResolveCommand(conflict));
    }
    commands.addAll(propertiesMerger.getModel().buildResolveCommand(conflict));
    if (my instanceof Way && nodeListMerger.getModel().isFrozen()) {
      NodeListMergeModel model = (NodeListMergeModel) nodeListMerger.getModel();
      commands.add(model.buildResolveCommand(conflict));
    } else if (my instanceof Relation && relationMemberMerger.getModel().isFrozen()) {
      RelationMemberListMergeModel model =
          (RelationMemberListMergeModel) relationMemberMerger.getModel();
      commands.add(model.buildResolveCommand((Relation) my, (Relation) their));
    }
    if (isResolvedCompletely()) {
      commands.add(new VersionConflictResolveCommand(conflict));
      commands.add(new ModifiedConflictResolveCommand(conflict));
    }
    return new SequenceCommand(tr("Conflict Resolution"), commands);
  }
Пример #4
0
 /**
  * handles property change events
  *
  * @param evt the event
  * @see TagMergeModel
  * @see ListMergeModel
  * @see PropertiesMergeModel
  */
 @Override
 public void propertyChange(PropertyChangeEvent evt) {
   if (evt.getPropertyName().equals(TagMergeModel.PROP_NUM_UNDECIDED_TAGS)) {
     int newValue = (Integer) evt.getNewValue();
     if (newValue == 0) {
       tabbedPane.setTitleAt(1, tr("Tags"));
       tabbedPane.setToolTipTextAt(1, tr("No pending tag conflicts to be resolved"));
       tabbedPane.setIconAt(1, mergeComplete);
     } else {
       tabbedPane.setTitleAt(
           1, trn("Tags({0} conflict)", "Tags({0} conflicts)", newValue, newValue));
       tabbedPane.setToolTipTextAt(
           1,
           trn(
               "{0} pending tag conflict to be resolved",
               "{0} pending tag conflicts to be resolved", newValue, newValue));
       tabbedPane.setIconAt(1, mergeIncomplete);
     }
     updateResolvedCompletely();
   } else if (evt.getPropertyName().equals(ListMergeModel.FROZEN_PROP)) {
     boolean frozen = (Boolean) evt.getNewValue();
     if (evt.getSource() == nodeListMerger.getModel() && my instanceof Way) {
       if (frozen) {
         tabbedPane.setTitleAt(2, tr("Nodes(resolved)"));
         tabbedPane.setToolTipTextAt(
             2, tr("Merged node list frozen. No pending conflicts in the node list of this way"));
         tabbedPane.setIconAt(2, mergeComplete);
       } else {
         tabbedPane.setTitleAt(2, tr("Nodes(with conflicts)"));
         tabbedPane.setToolTipTextAt(2, tr("Pending conflicts in the node list of this way"));
         tabbedPane.setIconAt(2, mergeIncomplete);
       }
     } else if (evt.getSource() == relationMemberMerger.getModel() && my instanceof Relation) {
       if (frozen) {
         tabbedPane.setTitleAt(3, tr("Members(resolved)"));
         tabbedPane.setToolTipTextAt(
             3,
             tr(
                 "Merged member list frozen. No pending conflicts in the member list of this relation"));
         tabbedPane.setIconAt(3, mergeComplete);
       } else {
         tabbedPane.setTitleAt(3, tr("Members(with conflicts)"));
         tabbedPane.setToolTipTextAt(
             3, tr("Pending conflicts in the member list of this relation"));
         tabbedPane.setIconAt(3, mergeIncomplete);
       }
     }
     updateResolvedCompletely();
   } else if (evt.getPropertyName().equals(PropertiesMergeModel.RESOLVED_COMPLETELY_PROP)) {
     boolean resolved = (Boolean) evt.getNewValue();
     if (resolved) {
       tabbedPane.setTitleAt(0, tr("Properties"));
       tabbedPane.setToolTipTextAt(0, tr("No pending property conflicts"));
       tabbedPane.setIconAt(0, mergeComplete);
     } else {
       tabbedPane.setTitleAt(0, tr("Properties(with conflicts)"));
       tabbedPane.setToolTipTextAt(0, tr("Pending property conflicts to be resolved"));
       tabbedPane.setIconAt(0, mergeIncomplete);
     }
     updateResolvedCompletely();
   } else if (PropertiesMergeModel.DELETE_PRIMITIVE_PROP.equals(evt.getPropertyName())) {
     for (IConflictResolver resolver : conflictResolvers) {
       resolver.deletePrimitive((Boolean) evt.getNewValue());
     }
   }
 }