Changeset 5790 in josm for trunk/src


Ignore:
Timestamp:
2013-03-21T14:41:44+01:00 (11 years ago)
Author:
akks
Message:

fix #8426: add_tags in remote control: better changed tags detection,
fix EDT violations and NPE when layer is closed while adding tags
added GuiHelper.executeByMainWorkerInEDT to execute GUI-related tasks sequentially from non-EDT threads

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java

    r5741 r5790  
    4747            }
    4848        }
     49    }
     50   
     51    public static void executeByMainWorkerInEDT(final Runnable task) {
     52        Main.worker.submit(new Runnable() {
     53            public void run() {
     54                runInEDTAndWait(task);
     55            }
     56        });
    4957    }
    5058
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java

    r5784 r5790  
    8080            count[i] = 0;
    8181            String key = tags[i][0];
     82            String value = tags[i][1];
    8283            Boolean b = Boolean.TRUE;
    8384            for (OsmPrimitive osm : sel) {
    84                 if (osm.keySet().contains(key)) {
     85                if (osm.keySet().contains(key) && !osm.get(key).equals(value)) {
    8586                    b = Boolean.FALSE;
    8687                    count[i]++;
     
    141142        for (int i=0; i<tm.getRowCount(); i++) {
    142143            String key = (String)tm.getValueAt(i, 1);
     144            String value = (String)tm.getValueAt(i, 1);
    143145            count[i] = 0;
    144146            for (OsmPrimitive osm : sel) {
    145                 if (osm.keySet().contains(key)) {
     147                if (osm.keySet().contains(key) && !osm.get(key).equals(value)) {
    146148                    count[i]++;
    147149                    break;
     
    158160    @Override
    159161    protected void buttonAction(int buttonIndex, ActionEvent evt) {
    160         if (buttonIndex != 2) {
     162        // if layer all layers were closed, ignore all actions
     163        if (Main.main.getCurrentDataSet() != null  && buttonIndex != 2) {
    161164            TableModel tm = propertyTable.getModel();
    162165            for (int i=0; i<tm.getRowCount(); i++) {
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java

    r5707 r5790  
    2727import org.openstreetmap.josm.data.osm.Way;
    2828import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
     29import org.openstreetmap.josm.gui.util.GuiHelper;
    2930import org.openstreetmap.josm.io.remotecontrol.AddTagsDialog;
    3031import org.openstreetmap.josm.io.remotecontrol.PermissionPrefWithDefault;
     
    132133         */
    133134        if (args.containsKey("addtags")) {
    134             Main.worker.execute(new Runnable() {
     135            GuiHelper.executeByMainWorkerInEDT(new Runnable() {
    135136                public void run() {
    136137                    DataSet ds = Main.main.getCurrentDataSet();
     
    145146        if (args.containsKey("select") && PermissionPrefWithDefault.CHANGE_SELECTION.isAllowed()) {
    146147            // select objects after downloading, zoom to selection.
    147             Main.worker.execute(new Runnable() {
     148            GuiHelper.executeByMainWorkerInEDT(new Runnable() {
    148149                public void run() {
    149150                    HashSet<OsmPrimitive> newSel = new HashSet<OsmPrimitive>();
     
    199200    static void addTags(final Map<String, String> args) {
    200201        if (args.containsKey("addtags")) {
    201             Main.worker.execute(new Runnable() {
     202            GuiHelper.executeByMainWorkerInEDT(new Runnable() {
    202203
    203204                public void run() {
     
    235236        // make sure this isn't called unless there *is* a MapView
    236237        if (Main.isDisplayingMapView()) {
    237             Main.worker.execute(new Runnable() {
     238            GuiHelper.executeByMainWorkerInEDT(new Runnable() {
    238239                public void run() {
    239240                    BoundingXYVisitor bbox = new BoundingXYVisitor();
Note: See TracChangeset for help on using the changeset viewer.