Ignore:
Timestamp:
2017-02-26T00:59:32+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #3346 - improve drastically the performance of fixing duplicate nodes by:

  • caching data sources area computation
  • moving layer invalidation from UndoRedoHandler.addNoRedraw to UndoRedoHandler.add
  • avoiding any EDT call when building tag conflict dialog if it's not meant to be displayed
File:
1 edited

Legend:

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

    r11601 r11627  
    129129        case 4: /* decision */
    130130            d.decide((RelationMemberConflictDecisionType) value);
    131             refresh();
     131            refresh(false);
    132132            break;
    133133        default: // Do nothing
     
    159159     */
    160160    public void populate(Collection<Relation> relations, Collection<? extends OsmPrimitive> memberPrimitives) {
     161        populate(relations, memberPrimitives, true);
     162    }
     163
     164    /**
     165     * Populates the model with the relation members belonging to one of the relations in <code>relations</code>
     166     * and referring to one of the primitives in <code>memberPrimitives</code>.
     167     *
     168     * @param relations  the parent relations. Empty list assumed if null.
     169     * @param memberPrimitives the child primitives. Empty list assumed if null.
     170     * @param fireEvent {@code true} to call {@code fireTableDataChanged} (can be a slow operation)
     171     * @since 11626
     172     */
     173    void populate(Collection<Relation> relations, Collection<? extends OsmPrimitive> memberPrimitives, boolean fireEvent) {
    161174        decisions.clear();
    162175        relations = relations == null ? Collections.<Relation>emptyList() : relations;
     
    169182        this.relations = relations;
    170183        this.primitives = memberPrimitives;
    171         refresh();
     184        refresh(fireEvent);
    172185    }
    173186
     
    199212     */
    200213    public void prepareDefaultRelationDecisions() {
    201 
     214        prepareDefaultRelationDecisions(true);
     215    }
     216
     217    /**
     218     * Prepare the default decisions for the current model.
     219     *
     220     * Keep/delete decisions are made if every member has the same role and the members are in consecutive order within the relation.
     221     * For multiple occurrences those conditions are tested stepwise for each occurrence.
     222     *
     223     * @param fireEvent {@code true} to call {@code fireTableDataChanged} (can be a slow operation)
     224     * @since 11626
     225     */
     226    void prepareDefaultRelationDecisions(boolean fireEvent) {
    202227        if (primitives.stream().allMatch(Node.class::isInstance)) {
    203228            final Collection<OsmPrimitive> primitivesInDecisions = new HashSet<>();
     
    256281        }
    257282
    258         refresh();
     283        refresh(fireEvent);
    259284    }
    260285
     
    300325     */
    301326    public void refresh() {
     327        refresh(true);
     328    }
     329
     330    /**
     331     * Refreshes the model state. Invoke this method to trigger necessary change
     332     * events after an update of the model data.
     333     * @param fireEvent {@code true} to call {@code fireTableDataChanged} (can be a slow operation)
     334     * @since 11626
     335     */
     336    void refresh(boolean fireEvent) {
    302337        updateNumConflicts();
    303         GuiHelper.runInEDTAndWait(this::fireTableDataChanged);
     338        if (fireEvent) {
     339            GuiHelper.runInEDTAndWait(this::fireTableDataChanged);
     340        }
    304341    }
    305342
Note: See TracChangeset for help on using the changeset viewer.