Ignore:
Timestamp:
2017-03-23T00:01:04+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #14475 - Deadlock while starting unit tests: remove the need to construct a CombinePrimitiveDialog to detect conflicts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/PasteTagsConflictResolverDialog.java

    r10791 r11772  
    5858    }
    5959
    60     private final TagConflictResolver allPrimitivesResolver = new TagConflictResolver();
     60    private final TagConflictResolverModel model = new TagConflictResolverModel();
    6161    private final transient Map<OsmPrimitiveType, TagConflictResolver> resolvers = new EnumMap<>(OsmPrimitiveType.class);
    6262    private final JTabbedPane tpResolvers = new JTabbedPane();
     
    8181        setTitle(tr("Conflicts in pasted tags"));
    8282        for (OsmPrimitiveType type: OsmPrimitiveType.dataValues()) {
    83             resolvers.put(type, new TagConflictResolver());
    84             resolvers.get(type).getModel().addPropertyChangeListener(this);
     83            TagConflictResolverModel tagModel = new TagConflictResolverModel();
     84            resolvers.put(type, new TagConflictResolver(tagModel));
     85            tagModel.addPropertyChangeListener(this);
    8586        }
    8687        getContentPane().setLayout(new GridBagLayout());
     
    106107        getContentPane().add(buildButtonPanel(), gc);
    107108        InputMapUtils.addEscapeAction(getRootPane(), new CancelAction());
    108 
    109109    }
    110110
     
    114114        // -- apply button
    115115        ApplyAction applyAction = new ApplyAction();
    116         allPrimitivesResolver.getModel().addPropertyChangeListener(applyAction);
     116        model.addPropertyChangeListener(applyAction);
    117117        for (TagConflictResolver r : resolvers.values()) {
    118118            r.getModel().addPropertyChangeListener(applyAction);
     
    141141     */
    142142    protected void initResolver(OsmPrimitiveType type, TagCollection tc, Map<OsmPrimitiveType, Integer> targetStatistics) {
    143         resolvers.get(type).getModel().populate(tc, tc.getKeysWithMultipleValues());
    144         resolvers.get(type).getModel().prepareDefaultTagDecisions();
     143        TagConflictResolver resolver = resolvers.get(type);
     144        resolver.getModel().populate(tc, tc.getKeysWithMultipleValues());
     145        resolver.getModel().prepareDefaultTagDecisions();
    145146        if (!tc.isEmpty() && targetStatistics.get(type) != null && targetStatistics.get(type) > 0) {
    146             tpResolvers.add(PANE_TITLES.get(type), resolvers.get(type));
     147            tpResolvers.add(PANE_TITLES.get(type), resolver);
    147148        }
    148149    }
     
    164165        // init the resolver
    165166        //
    166         allPrimitivesResolver.getModel().populate(tagsForAllPrimitives, tagsForAllPrimitives.getKeysWithMultipleValues());
    167         allPrimitivesResolver.getModel().prepareDefaultTagDecisions();
     167        model.populate(tagsForAllPrimitives, tagsForAllPrimitives.getKeysWithMultipleValues());
     168        model.prepareDefaultTagDecisions();
    168169
    169170        // prepare the dialog with one tag resolver
    170171        pnlTagResolver.removeAll();
    171         pnlTagResolver.add(allPrimitivesResolver, BorderLayout.CENTER);
     172        pnlTagResolver.add(new TagConflictResolver(model), BorderLayout.CENTER);
    172173
    173174        statisticsModel.reset();
     
    297298                setEnabled(false);
    298299            } else if (mode.equals(Mode.RESOLVING_ONE_TAGCOLLECTION_ONLY)) {
    299                 setEnabled(allPrimitivesResolver.getModel().isResolvedCompletely());
     300                setEnabled(model.isResolvedCompletely());
    300301            } else {
    301302                setEnabled(resolvers.values().stream().allMatch(val -> val.getModel().isResolvedCompletely()));
     
    329330     */
    330331    public TagCollection getResolution() {
    331         return allPrimitivesResolver.getModel().getResolution();
     332        return model.getResolution();
    332333    }
    333334
     
    340341    public void propertyChange(PropertyChangeEvent evt) {
    341342        if (evt.getPropertyName().equals(TagConflictResolverModel.NUM_CONFLICTS_PROP)) {
    342             TagConflictResolverModel model = (TagConflictResolverModel) evt.getSource();
     343            TagConflictResolverModel tagModel = (TagConflictResolverModel) evt.getSource();
    343344            for (int i = 0; i < tpResolvers.getTabCount(); i++) {
    344345                TagConflictResolver resolver = (TagConflictResolver) tpResolvers.getComponentAt(i);
    345                 if (model == resolver.getModel()) {
     346                if (tagModel == resolver.getModel()) {
    346347                    tpResolvers.setIconAt(i,
    347348                            (Integer) evt.getNewValue() == 0 ? iconResolved : iconUnresolved
Note: See TracChangeset for help on using the changeset viewer.