Ignore:
Timestamp:
2013-03-13T21:52:18+01:00 (11 years ago)
Author:
Don-vip
Message:

see #8503 - Allo plugins to warn about conflicts

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java

    r5416 r5775  
    55import static org.openstreetmap.josm.tools.I18n.marktr;
    66import static org.openstreetmap.josm.tools.I18n.tr;
     7import static org.openstreetmap.josm.tools.I18n.trn;
    78
    89import java.awt.Color;
     
    2324import javax.swing.AbstractAction;
    2425import javax.swing.JList;
     26import javax.swing.JOptionPane;
    2527import javax.swing.ListModel;
    2628import javax.swing.ListSelectionModel;
     
    4345import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
    4446import org.openstreetmap.josm.data.osm.visitor.Visitor;
     47import org.openstreetmap.josm.gui.HelpAwareOptionPane;
    4548import org.openstreetmap.josm.gui.MapView;
    4649import org.openstreetmap.josm.gui.NavigatableComponent;
    4750import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
    4851import org.openstreetmap.josm.gui.SideButton;
     52import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec;
    4953import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    5054import org.openstreetmap.josm.gui.util.GuiHelper;
     
    407411        }
    408412    }
    409 
     413   
     414    /**
     415     * Warns the user about the number of detected conflicts
     416     *
     417     * @param numNewConflicts the number of detected conflicts
     418     * @since 5775
     419     */
     420    public void warnNumNewConflicts(int numNewConflicts) {
     421        if (numNewConflicts == 0) return;
     422
     423        String msg1 = trn(
     424                "There was {0} conflict detected.",
     425                "There were {0} conflicts detected.",
     426                numNewConflicts,
     427                numNewConflicts
     428        );
     429
     430        final StringBuffer sb = new StringBuffer();
     431        sb.append("<html>").append(msg1).append("</html>");
     432        if (numNewConflicts > 0) {
     433            final ButtonSpec[] options = new ButtonSpec[] {
     434                    new ButtonSpec(
     435                            tr("OK"),
     436                            ImageProvider.get("ok"),
     437                            tr("Click to close this dialog and continue editing"),
     438                            null /* no specific help */
     439                    )
     440            };
     441            GuiHelper.runInEDT(new Runnable() {
     442                @Override
     443                public void run() {
     444                    HelpAwareOptionPane.showOptionDialog(
     445                            Main.parent,
     446                            sb.toString(),
     447                            tr("Conflicts detected"),
     448                            JOptionPane.WARNING_MESSAGE,
     449                            null, /* no icon */
     450                            options,
     451                            options[0],
     452                            ht("/Concepts/Conflict#WarningAboutDetectedConflicts")
     453                    );
     454                    unfurlDialog();
     455                    Main.map.repaint();
     456                }
     457            });
     458        }
     459    }
    410460}
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r5758 r5775  
    7474import org.openstreetmap.josm.data.validation.TestError;
    7575import org.openstreetmap.josm.gui.ExtendedDialog;
    76 import org.openstreetmap.josm.gui.HelpAwareOptionPane;
    77 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec;
    7876import org.openstreetmap.josm.gui.MapView;
    7977import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
     
    8179import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
    8280import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    83 import org.openstreetmap.josm.gui.util.GuiHelper;
    8481import org.openstreetmap.josm.tools.DateUtils;
    8582import org.openstreetmap.josm.tools.FilteredCollection;
     
    410407            Main.map.mapView.repaint();
    411408        }
    412         warnNumNewConflicts(numNewConflicts);
    413     }
    414 
    415     /**
    416      * Warns the user about the number of detected conflicts
    417      *
    418      * @param numNewConflicts the number of detected conflicts
    419      */
    420     protected void warnNumNewConflicts(int numNewConflicts) {
    421         if (numNewConflicts == 0) return;
    422 
    423         String msg1 = trn(
    424                 "There was {0} conflict detected.",
    425                 "There were {0} conflicts detected.",
    426                 numNewConflicts,
    427                 numNewConflicts
    428         );
    429 
    430         final StringBuffer sb = new StringBuffer();
    431         sb.append("<html>").append(msg1).append("</html>");
    432         if (numNewConflicts > 0) {
    433             final ButtonSpec[] options = new ButtonSpec[] {
    434                     new ButtonSpec(
    435                             tr("OK"),
    436                             ImageProvider.get("ok"),
    437                             tr("Click to close this dialog and continue editing"),
    438                             null /* no specific help */
    439                     )
    440             };
    441             GuiHelper.runInEDT(new Runnable() {
    442                 @Override
    443                 public void run() {
    444                     HelpAwareOptionPane.showOptionDialog(
    445                             Main.parent,
    446                             sb.toString(),
    447                             tr("Conflicts detected"),
    448                             JOptionPane.WARNING_MESSAGE,
    449                             null, /* no icon */
    450                             options,
    451                             options[0],
    452                             ht("/Concepts/Conflict#WarningAboutDetectedConflicts")
    453                     );
    454                     Main.map.conflictDialog.unfurlDialog();
    455                     Main.map.repaint();
    456                 }
    457             });
    458         }
    459     }
    460 
     409        Main.map.conflictDialog.warnNumNewConflicts(numNewConflicts);
     410    }
    461411
    462412    @Override public boolean isMergable(final Layer other) {
Note: See TracChangeset for help on using the changeset viewer.