- Timestamp:
- 2014-01-02T23:47:56+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java
r6597 r6600 9 9 import java.util.Arrays; 10 10 import java.util.Collection; 11 import java.util.Collections; 11 12 import java.util.HashMap; 12 13 import java.util.HashSet; … … 33 34 import org.openstreetmap.josm.data.osm.Way; 34 35 import org.openstreetmap.josm.gui.Notification; 36 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationTask; 35 37 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 36 38 import org.openstreetmap.josm.tools.Pair; … … 106 108 ? getSelectedMultipolygonRelation(selectedWays, selectedRelations) 107 109 : null; 108 if (multipolygonRelation != null && (multipolygonRelation.isIncomplete() || multipolygonRelation.hasIncompleteMembers())) { 109 new Notification( 110 tr("Cannot update multipolygon since relation is incomplete.")) 111 .setIcon(JOptionPane.WARNING_MESSAGE) 112 .setDuration(Notification.TIME_DEFAULT) 113 .show(); 114 return; 115 } 116 117 final Pair<SequenceCommand, Relation> commandAndRelation = createMultipolygonCommand(selectedWays, multipolygonRelation); 118 if (commandAndRelation == null) { 119 return; 120 } 121 final Command command = commandAndRelation.a; 122 final Relation relation = commandAndRelation.b; 123 Main.main.undoRedo.add(command); 124 125 // Use 'SwingUtilities.invokeLater' to make sure the relationListDialog 126 // knows about the new relation before we try to select it. 127 // (Yes, we are already in event dispatch thread. But DatasetEventManager 128 // uses 'SwingUtilities.invokeLater' to fire events so we have to do 129 // the same.) 130 SwingUtilities.invokeLater(new Runnable() { 110 111 // runnable to create/update multipolygon relation 112 final Runnable createOrUpdateMultipolygonTask = new Runnable() { 131 113 @Override 132 114 public void run() { 133 Main.map.relationListDialog.selectRelation(relation); 134 if (Main.pref.getBoolean("multipoly.show-relation-editor", false)) { 135 //Open relation edit window, if set up in preferences 136 RelationEditor editor = RelationEditor.getEditor(Main.main.getEditLayer(), relation, null); 137 138 editor.setModal(true); 139 editor.setVisible(true); 115 final Pair<SequenceCommand, Relation> commandAndRelation = createMultipolygonCommand(selectedWays, multipolygonRelation); 116 if (commandAndRelation == null) { 117 return; 140 118 } 141 } 142 }); 119 final Command command = commandAndRelation.a; 120 final Relation relation = commandAndRelation.b; 121 122 123 // to avoid EDT violations 124 SwingUtilities.invokeLater(new Runnable() { 125 @Override 126 public void run() { 127 Main.main.undoRedo.add(command); 128 } 129 }); 130 131 // Use 'SwingUtilities.invokeLater' to make sure the relationListDialog 132 // knows about the new relation before we try to select it. 133 // (Yes, we are already in event dispatch thread. But DatasetEventManager 134 // uses 'SwingUtilities.invokeLater' to fire events so we have to do 135 // the same.) 136 SwingUtilities.invokeLater(new Runnable() { 137 @Override 138 public void run() { 139 Main.map.relationListDialog.selectRelation(relation); 140 if (Main.pref.getBoolean("multipoly.show-relation-editor", false)) { 141 //Open relation edit window, if set up in preferences 142 RelationEditor editor = RelationEditor.getEditor(Main.main.getEditLayer(), relation, null); 143 144 editor.setModal(true); 145 editor.setVisible(true); 146 } 147 } 148 }); 149 } 150 }; 151 152 // download incomplete relation if necessary 153 if (multipolygonRelation != null && (multipolygonRelation.isIncomplete() || multipolygonRelation.hasIncompleteMembers())) { 154 Main.worker.submit(new DownloadRelationTask(Collections.singleton(multipolygonRelation), Main.main.getEditLayer())); 155 } 156 // create/update multipolygon relation 157 Main.worker.submit(createOrUpdateMultipolygonTask); 143 158 144 159 }
Note:
See TracChangeset
for help on using the changeset viewer.