Changeset 1814 in josm for trunk/src/org/openstreetmap/josm/actions
- Timestamp:
- 2009-07-19T19:04:49+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 37 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AbstractInfoAction.java
r1779 r1814 46 46 47 47 protected void launchBrowser() { 48 ArrayList<OsmPrimitive> primitivesToShow = new ArrayList<OsmPrimitive>( Main.ds.getSelected());48 ArrayList<OsmPrimitive> primitivesToShow = new ArrayList<OsmPrimitive>(getCurrentDataSet().getSelected()); 49 49 50 50 // filter out new primitives which are not yet uploaded to the server -
trunk/src/org/openstreetmap/josm/actions/AddNodeAction.java
r1807 r1814 79 79 /* Now execute the commands to add the dupicated contents of the paste buffer to the map */ 80 80 Main.main.undoRedo.add(new AddCommand(nnew)); 81 Main.ds.setSelected(nnew);81 getCurrentDataSet().setSelected(nnew); 82 82 Main.map.mapView.repaint(); 83 83 } -
trunk/src/org/openstreetmap/josm/actions/AlignInCircleAction.java
r1768 r1814 79 79 80 80 public void actionPerformed(ActionEvent e) { 81 Collection<OsmPrimitive> sel = Main.ds.getSelected();81 Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected(); 82 82 Collection<Node> nodes = new LinkedList<Node>(); 83 83 Collection<Way> ways = new LinkedList<Way>(); -
trunk/src/org/openstreetmap/josm/actions/AlignInLineAction.java
r1640 r1814 31 31 public AlignInLineAction() { 32 32 super(tr("Align Nodes in Line"), "alignline", tr("Move the selected nodes in to a line."), 33 Shortcut.registerShortcut("tools:alignline", tr("Tool: {0}", tr("Align Nodes in Line")), KeyEvent.VK_L, Shortcut.GROUP_EDIT), true);33 Shortcut.registerShortcut("tools:alignline", tr("Tool: {0}", tr("Align Nodes in Line")), KeyEvent.VK_L, Shortcut.GROUP_EDIT), true); 34 34 } 35 35 … … 40 40 */ 41 41 public void actionPerformed(ActionEvent e) { 42 Collection<OsmPrimitive> sel = Main.ds.getSelected();42 Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected(); 43 43 Collection<Node> nodes = new LinkedList<Node>(); 44 44 Collection<Node> itnodes = new LinkedList<Node>(); … … 50 50 // special case if no single nodes are selected and exactly one way is: 51 51 // then use the way's nodes 52 if ((nodes.size() == 0) && (sel.size() == 1)) 52 if ((nodes.size() == 0) && (sel.size() == 1)) { 53 53 for (OsmPrimitive osm : sel) 54 54 if (osm instanceof Way) { … … 56 56 itnodes.addAll(((Way)osm).nodes); 57 57 } 58 } 58 59 if (nodes.size() < 3) { 59 60 JOptionPane.showMessageDialog(Main.parent, tr("Please select at least three nodes.")); -
trunk/src/org/openstreetmap/josm/actions/ApiPreconditionChecker.java
r1693 r1814 100 100 List<OsmPrimitive> newNodes = new LinkedList<OsmPrimitive>(); 101 101 newNodes.add(osmPrimitive); 102 Main. ds.setSelected(newNodes);102 Main.main.getCurrentDataSet().setSelected(newNodes); 103 103 return false; 104 104 } … … 120 120 newNodes.add(osmPrimitive); 121 121 122 Main. ds.setSelected(newNodes);122 Main.main.getCurrentDataSet().setSelected(newNodes); 123 123 return false; 124 124 } -
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r1797 r1814 79 79 Collection<OsmPrimitive> sel = new HashSet<OsmPrimitive>(); 80 80 if (mode.equals("selection")) { 81 sel = Main.ds.getSelected();81 sel = getCurrentDataSet().getSelected(); 82 82 } else if (mode.equals("conflict")) { 83 83 if (Main.map.conflictDialog.getConflicts() != null) { -
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r1621 r1814 52 52 public CombineWayAction() { 53 53 super(tr("Combine Way"), "combineway", tr("Combine several ways into one."), 54 Shortcut.registerShortcut("tools:combineway", tr("Tool: {0}", tr("Combine Way")), KeyEvent.VK_C, Shortcut.GROUP_EDIT), true);54 Shortcut.registerShortcut("tools:combineway", tr("Tool: {0}", tr("Combine Way")), KeyEvent.VK_C, Shortcut.GROUP_EDIT), true); 55 55 DataSet.selListeners.add(this); 56 56 } 57 57 58 58 public void actionPerformed(ActionEvent event) { 59 Collection<OsmPrimitive> selection = Main.ds.getSelected();59 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 60 60 LinkedList<Way> selectedWays = new LinkedList<Way>(); 61 61 62 62 for (OsmPrimitive osm : selection) 63 if (osm instanceof Way) 63 if (osm instanceof Way) { 64 64 selectedWays.add((Way)osm); 65 } 65 66 66 67 if (selectedWays.size() < 2) { … … 82 83 new HashMap<Pair<Relation,String>, HashSet<Way>>(); 83 84 HashSet<Relation> relationsUsingWays = new HashSet<Relation>(); 84 for (Relation r : Main.ds.relations) { 85 if (r.deleted || r.incomplete) continue; 85 for (Relation r : getCurrentDataSet().relations) { 86 if (r.deleted || r.incomplete) { 87 continue; 88 } 86 89 for (RelationMember rm : r.members) { 87 90 if (rm.member instanceof Way) { … … 112 115 tr("Combine ways with different memberships?"), 113 116 tr("The selected ways have differing relation memberships. " 114 + "Do you still want to combine them?"), 115 new String[] {tr("Combine Anyway"), tr("Cancel")}, 116 new String[] {"combineway.png", "cancel.png"}).getValue(); 117 if (option == 1) break; 117 + "Do you still want to combine them?"), 118 new String[] {tr("Combine Anyway"), tr("Cancel")}, 119 new String[] {"combineway.png", "cancel.png"}).getValue(); 120 if (option == 1) { 121 break; 122 } 118 123 119 124 return; … … 125 130 for (Way w : selectedWays) { 126 131 for (Entry<String,String> e : w.entrySet()) { 127 if (!props.containsKey(e.getKey())) 132 if (!props.containsKey(e.getKey())) { 128 133 props.put(e.getKey(), new TreeSet<String>()); 134 } 129 135 props.get(e.getKey()).add(e.getValue()); 130 136 } … … 139 145 if (secondTry instanceof List) { 140 146 int option = new ExtendedDialog(Main.parent, 141 tr("Change directions?"),142 tr("The ways can not be combined in their current directions. "143 + "Do you want to reverse some of them?"),144 new String[] {tr("Reverse and Combine"), tr("Cancel")},145 new String[] {"wayflip.png", "cancel.png"}).getValue();147 tr("Change directions?"), 148 tr("The ways can not be combined in their current directions. " 149 + "Do you want to reverse some of them?"), 150 new String[] {tr("Reverse and Combine"), tr("Cancel")}, 151 new String[] {"wayflip.png", "cancel.png"}).getValue(); 146 152 if (option != 1) return; 147 153 nodeList = (List<Node>) secondTry; … … 160 166 for (Way w : selectedWays) { 161 167 modifyWay = w; 162 if (w.id != 0) break; 168 if (w.id != 0) { 169 break; 170 } 163 171 } 164 172 Way newWay = new Way(modifyWay); … … 188 196 if (!components.isEmpty()) { 189 197 int answer = new ExtendedDialog(Main.parent, 190 tr("Enter values for all conflicts."),191 p,192 new String[] {tr("Solve Conflicts"), tr("Cancel")},193 new String[] {"dialogs/conflict.png", "cancel.png"}).getValue();198 tr("Enter values for all conflicts."), 199 p, 200 new String[] {tr("Solve Conflicts"), tr("Cancel")}, 201 new String[] {"dialogs/conflict.png", "cancel.png"}).getValue(); 194 202 if (answer != 1) return; 195 203 196 for (Entry<String, JComboBox> e : components.entrySet()) 204 for (Entry<String, JComboBox> e : components.entrySet()) { 197 205 newWay.put(e.getKey(), e.getValue().getEditor().getItem().toString()); 206 } 198 207 } 199 208 … … 224 233 } 225 234 Main.main.undoRedo.add(new SequenceCommand(tr("Combine {0} ways", selectedWays.size()), cmds)); 226 Main.ds.setSelected(modifyWay);235 getCurrentDataSet().setSelected(modifyWay); 227 236 } 228 237 … … 242 251 243 252 HashSet<Pair<Node,Node>> chunkSet = new HashSet<Pair<Node,Node>>(); 244 for (Way w : ways) 253 for (Way w : ways) { 245 254 chunkSet.addAll(w.getNodePairs(ignoreDirection)); 255 } 246 256 247 257 LinkedList<Pair<Node,Node>> chunks = new LinkedList<Pair<Node,Node>>(chunkSet); 248 258 249 if (chunks.isEmpty()) {259 if (chunks.isEmpty()) 250 260 return tr("All the ways were empty"); 251 }252 261 253 262 List<Node> nodeList = Pair.toArrayList(chunks.poll()); … … 273 282 break; 274 283 } 275 if (!foundChunk) break; 276 } 277 278 if (!chunks.isEmpty()) { 284 if (!foundChunk) { 285 break; 286 } 287 } 288 289 if (!chunks.isEmpty()) 279 290 return tr("Could not combine ways " 280 + "(They could not be merged into a single string of nodes)"); 281 } 291 + "(They could not be merged into a single string of nodes)"); 282 292 283 293 return nodeList; -
trunk/src/org/openstreetmap/josm/actions/CopyAction.java
r1750 r1814 45 45 46 46 public void actionPerformed(ActionEvent e) { 47 if( noSelection()) return;47 if(isEmptySelection()) return; 48 48 49 49 Main.pasteBuffer = copyData(); 50 Main.pasteSource = Main.main.createOrGetEditLayer();50 Main.pasteSource = getEditLayer(); 51 51 Main.main.menu.paste.setEnabled(true); /* now we have a paste buffer we can make paste available */ 52 52 … … 56 56 } 57 57 58 public staticDataSet copyData() {58 public DataSet copyData() { 59 59 /* New pasteBuffer - will be assigned to the global one at the end */ 60 60 final DataSet pasteBuffer = new DataSet(); … … 62 62 /* temporarily maps old nodes to new so we can do a true deep copy */ 63 63 64 if( noSelection()) return pasteBuffer;64 if(isEmptySelection()) return pasteBuffer; 65 65 66 66 /* scan the selected objects, mapping them to copies; when copying a way or relation, … … 71 71 * or a way and a node in that way is selected, we'll see it twice, once via the 72 72 * way and once directly; and so on. */ 73 if (map.containsKey(n)) { return; } 73 if (map.containsKey(n)) 74 return; 74 75 Node nnew = new Node(n); 75 76 map.put(n, nnew); … … 78 79 public void visit(Way w) { 79 80 /* check if already in pasteBuffer - could have come from a relation, and directly etc. */ 80 if (map.containsKey(w)) { return; } 81 if (map.containsKey(w)) 82 return; 81 83 Way wnew = new Way(); 82 84 wnew.cloneFrom(w); … … 93 95 } 94 96 public void visit(Relation e) { 95 if (map.containsKey(e)) { return; } 97 if (map.containsKey(e)) 98 return; 96 99 Relation enew = new Relation(e); 97 100 List<RelationMember> members = new ArrayList<RelationMember>(); … … 108 111 } 109 112 public void visitAll() { 110 for (OsmPrimitive osm : Main.ds.getSelected())113 for (OsmPrimitive osm : getCurrentDataSet().getSelected()) { 111 114 osm.visit(this); 115 } 112 116 113 117 // Used internally only (in PasteTagsAction), therefore no need to translate these 114 if( Main.ds.getSelectedNodes().size() > 0)118 if(getCurrentDataSet().getSelectedNodes().size() > 0) { 115 119 pasteBuffer.dataSources.add(new DataSource(null, "Copied Nodes")); 116 if(Main.ds.getSelectedWays().size() > 0) 120 } 121 if(getCurrentDataSet().getSelectedWays().size() > 0) { 117 122 pasteBuffer.dataSources.add(new DataSource(null, "Copied Ways")); 118 if(Main.ds.getSelectedRelations().size() > 0) 123 } 124 if(getCurrentDataSet().getSelectedRelations().size() > 0) { 119 125 pasteBuffer.dataSources.add(new DataSource(null, "Copied Relations")); 126 } 120 127 } 121 128 }.visitAll(); … … 128 135 } 129 136 130 private static boolean noSelection() {131 Collection<OsmPrimitive> sel = Main.ds.getSelected();137 private boolean isEmptySelection() { 138 Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected(); 132 139 if (sel.isEmpty()) { 133 JOptionPane.showMessageDialog(Main.parent, 134 tr("Please select something to copy.")); 140 JOptionPane.showMessageDialog( 141 Main.parent, 142 tr("Please select something to copy.") 143 ); 135 144 return true; 136 145 } -
trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java
r1741 r1814 80 80 } 81 81 82 Collection<OsmPrimitive> sel = Main.ds.getSelected();82 Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected(); 83 83 Collection<Node> nodes = new LinkedList<Node>(); 84 84 Way existingWay = null; … … 170 170 if (a1 < 999) { 171 171 // if it is, delete it 172 CollectBackReferencesVisitor refs = new CollectBackReferencesVisitor( Main.ds);172 CollectBackReferencesVisitor refs = new CollectBackReferencesVisitor(getCurrentDataSet()); 173 173 refs.visit(n1); 174 174 if (refs.data.isEmpty() || ((refs.data.size() == 1) && (refs.data.contains(existingWay)))) { -
trunk/src/org/openstreetmap/josm/actions/DistributeAction.java
r1640 r1814 29 29 public DistributeAction() { 30 30 super(tr("Distribute Nodes"), "distribute", tr("Distribute the selected nodes to equal distances along a line."), 31 Shortcut.registerShortcut("tools:distribute", tr("Tool: {0}", tr("Distribute Nodes")), KeyEvent.VK_B, Shortcut.GROUP_EDIT), true);31 Shortcut.registerShortcut("tools:distribute", tr("Tool: {0}", tr("Distribute Nodes")), KeyEvent.VK_B, Shortcut.GROUP_EDIT), true); 32 32 } 33 33 … … 38 38 */ 39 39 public void actionPerformed(ActionEvent e) { 40 Collection<OsmPrimitive> sel = Main.ds.getSelected();40 Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected(); 41 41 Collection<Node> nodes = new LinkedList<Node>(); 42 42 Collection<Node> itnodes = new LinkedList<Node>(); … … 48 48 // special case if no single nodes are selected and exactly one way is: 49 49 // then use the way's nodes 50 if ((nodes.size() == 0) && (sel.size() == 1)) 50 if ((nodes.size() == 0) && (sel.size() == 1)) { 51 51 for (OsmPrimitive osm : sel) 52 52 if (osm instanceof Way) { … … 54 54 itnodes.addAll(((Way)osm).nodes); 55 55 } 56 } 56 57 57 58 if (nodes.size() < 3) { -
trunk/src/org/openstreetmap/josm/actions/DuplicateAction.java
r1750 r1814 9 9 import java.util.Collection; 10 10 11 import org.openstreetmap.josm.actions.CopyAction;12 import org.openstreetmap.josm.actions.PasteAction;13 11 import org.openstreetmap.josm.data.SelectionChangedListener; 14 12 import org.openstreetmap.josm.data.osm.DataSet; 15 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 import org.openstreetmap.josm.gui.layer.Layer; 15 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener; 16 16 import org.openstreetmap.josm.tools.Shortcut; 17 import org.openstreetmap.josm.Main;18 17 19 public final class DuplicateAction extends JosmAction implements SelectionChangedListener {18 public final class DuplicateAction extends JosmAction implements SelectionChangedListener, LayerChangeListener { 20 19 21 20 public DuplicateAction() { 22 21 super(tr("Duplicate"), "duplicate", 23 tr("Duplicate selection by copy and immediate paste."),24 Shortcut.registerShortcut("system:duplicate", tr("Edit: {0}", tr("Duplicate")), KeyEvent.VK_D, Shortcut.GROUP_MENU), true);22 tr("Duplicate selection by copy and immediate paste."), 23 Shortcut.registerShortcut("system:duplicate", tr("Edit: {0}", tr("Duplicate")), KeyEvent.VK_D, Shortcut.GROUP_MENU), true); 25 24 setEnabled(false); 26 25 DataSet.selListeners.add(this); 26 Layer.listeners.add(this); 27 27 } 28 28 29 29 public void actionPerformed(ActionEvent e) { 30 PasteAction.pasteData(CopyAction.copyData(), Main.main.createOrGetEditLayer(), e);30 new PasteAction().pasteData(new CopyAction().copyData(), getEditLayer(), e); 31 31 } 32 32 33 34 protected void refreshEnabled() { 35 setEnabled(getCurrentDataSet() != null 36 && ! getCurrentDataSet().getSelected().isEmpty() 37 ); 38 } 39 40 /* ---------------------------------------------------------------------------------- */ 41 /* Interface SelectionChangeListener */ 42 /* ---------------------------------------------------------------------------------- */ 33 43 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 34 setEnabled(! newSelection.isEmpty()); 44 refreshEnabled(); 45 } 46 47 /* ---------------------------------------------------------------------------------- */ 48 /* Interface LayerChangeListener */ 49 /* ---------------------------------------------------------------------------------- */ 50 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 51 refreshEnabled(); 52 } 53 54 public void layerAdded(Layer newLayer) { 55 refreshEnabled(); 56 } 57 58 public void layerRemoved(Layer oldLayer) { 59 refreshEnabled(); 35 60 } 36 61 } -
trunk/src/org/openstreetmap/josm/actions/GpxExportAction.java
r1808 r1814 84 84 public void export(Layer layer) { 85 85 if (layer == null) 86 throw new IllegalArgumentException(tr("paramenter ''{0 '' must not be null", "layer"));86 throw new IllegalArgumentException(tr("paramenter ''{0}'' must not be null", "layer")); 87 87 if (! (layer instanceof OsmDataLayer) && ! (layer instanceof GpxLayer)) 88 88 throw new IllegalArgumentException(tr("expected instance of OsmDataLayer or GpxLayer. Got ''{0}''.", layer.getClass().getName())); … … 98 98 } 99 99 100 public static void exportGpx(File file, Layer layer) { 100 /** 101 * Exports a layer to a file. 102 * 103 * <code>layer</code> must not be null. <code>layer</code> must be an instance of 104 * {@see OsmDataLayer} or {@see GpxLayer}. 105 * 106 * @param layer the layer 107 * @exception IllegalArgumentException thrown if layer is null 108 * @exception IllegalArgumentException thrown if layer is neither an instance of {@see OsmDataLayer} 109 * nor of {@see GpxLayer} 110 */ 111 112 public void exportGpx(File file, Layer layer) { 113 if (layer == null) 114 throw new IllegalArgumentException(tr("paramenter ''{0}'' must not be null", "layer")); 115 if (! (layer instanceof OsmDataLayer) && ! (layer instanceof GpxLayer)) 116 throw new IllegalArgumentException(tr("expected instance of OsmDataLayer or GpxLayer. Got ''{0}''.", layer.getClass().getName())); 117 if (file == null) 118 throw new IllegalArgumentException(tr("paramenter ''{0}'' must not be null", "file")); 119 101 120 String fn = file.getPath(); 102 121 if (fn.indexOf('.') == -1) { … … 172 191 gpxData = ((GpxLayer)layer).data; 173 192 } else { 174 gpxData = OsmDataLayer.toGpxData( Main.ds, file);193 gpxData = OsmDataLayer.toGpxData(getCurrentDataSet(), file); 175 194 } 176 195 -
trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java
r1725 r1814 28 28 public JoinNodeWayAction() { 29 29 super(tr("Join Node to Way"), "joinnodeway", tr("Join a node into the nearest way segments"), 30 Shortcut.registerShortcut("tools:joinnodeway", tr("Tool: {0}", tr("Join Node to Way")), KeyEvent.VK_J, Shortcut.GROUP_EDIT), true);30 Shortcut.registerShortcut("tools:joinnodeway", tr("Tool: {0}", tr("Join Node to Way")), KeyEvent.VK_J, Shortcut.GROUP_EDIT), true); 31 31 } 32 32 33 33 public void actionPerformed(ActionEvent e) { 34 Collection<OsmPrimitive> sel = Main.ds.getSelected();34 Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected(); 35 35 if (sel.size() != 1 || !(sel.iterator().next() instanceof Node)) return; 36 36 Node node = (Node) sel.iterator().next(); 37 37 38 38 List<WaySegment> wss = Main.map.mapView.getNearestWaySegments( 39 Main.map.mapView.getPoint(node));39 Main.map.mapView.getPoint(node)); 40 40 HashMap<Way, List<Integer>> insertPoints = new HashMap<Way, List<Integer>>(); 41 41 for (WaySegment ws : wss) { … … 60 60 List<Integer> is = insertPoint.getValue(); 61 61 pruneSuccsAndReverse(is); 62 for (int i : is) wnew.nodes.add(i+1, node); 62 for (int i : is) { 63 wnew.nodes.add(i+1, node); 64 } 63 65 cmds.add(new ChangeCommand(w, wnew)); 64 66 } -
trunk/src/org/openstreetmap/josm/actions/JosmAction.java
r1415 r1814 9 9 import org.openstreetmap.josm.Main; 10 10 import org.openstreetmap.josm.data.osm.DataSet; 11 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 11 12 import org.openstreetmap.josm.tools.Destroyable; 12 13 import org.openstreetmap.josm.tools.ImageProvider; … … 61 62 putValue(SHORT_DESCRIPTION, Main.platform.makeTooltip(tooltip, sc)); 62 63 putValue("toolbar", iconName); 63 if (register) 64 if (register) { 64 65 Main.toolbar.register(this); 66 } 65 67 } 66 68 … … 92 94 private void setHelpId() { 93 95 String helpId = "Action/"+getClass().getName().substring(getClass().getName().lastIndexOf('.')+1); 94 if (helpId.endsWith("Action")) 96 if (helpId.endsWith("Action")) { 95 97 helpId = helpId.substring(0, helpId.length()-6); 98 } 96 99 putValue("help", helpId); 97 100 } 101 102 /** 103 * Replies the current edit layer 104 * 105 * @return the current edit layer. null, if no edit layer exists 106 */ 107 protected OsmDataLayer getEditLayer() { 108 return Main.main.getEditLayer(); 109 } 110 111 /** 112 * Replies the current dataset 113 * 114 * @return the current dataset. null, if no current dataset exists 115 */ 116 protected DataSet getCurrentDataSet() { 117 return Main.main.getCurrentDataSet(); 118 } 98 119 } -
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r1677 r1814 55 55 public MergeNodesAction() { 56 56 super(tr("Merge Nodes"), "mergenodes", tr("Merge nodes into the oldest one."), 57 Shortcut.registerShortcut("tools:mergenodes", tr("Tool: {0}", tr("Merge Nodes")), KeyEvent.VK_M, Shortcut.GROUP_EDIT), true);57 Shortcut.registerShortcut("tools:mergenodes", tr("Tool: {0}", tr("Merge Nodes")), KeyEvent.VK_M, Shortcut.GROUP_EDIT), true); 58 58 DataSet.selListeners.add(this); 59 59 } 60 60 61 61 public void actionPerformed(ActionEvent event) { 62 Collection<OsmPrimitive> selection = Main.ds.getSelected();62 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 63 63 LinkedList<Node> selectedNodes = new LinkedList<Node>(); 64 64 … … 67 67 // anyway as long as we have at least two nodes 68 68 for (OsmPrimitive osm : selection) 69 if (osm instanceof Node) 69 if (osm instanceof Node) { 70 70 selectedNodes.add((Node)osm); 71 } 71 72 72 73 if (selectedNodes.size() < 2) { … … 93 94 } 94 95 } 95 if (useNode == null) 96 if (useNode == null) { 96 97 useNode = selectedNodes.iterator().next(); 98 } 97 99 98 100 mergeNodes(selectedNodes, useNode); … … 102 104 * really do the merging - returns the node that is left 103 105 */ 104 public staticNode mergeNodes(LinkedList<Node> allNodes, Node dest) {106 public Node mergeNodes(LinkedList<Node> allNodes, Node dest) { 105 107 Node newNode = new Node(dest); 106 108 … … 118 120 new HashMap<Pair<Relation,String>, HashSet<Node>>(); 119 121 HashSet<Relation> relationsUsingNodes = new HashSet<Relation>(); 120 for (Relation r : Main.ds.relations) { 121 if (r.deleted || r.incomplete) continue; 122 for (Relation r : getCurrentDataSet().relations) { 123 if (r.deleted || r.incomplete) { 124 continue; 125 } 122 126 for (RelationMember rm : r.members) { 123 127 if (rm.member instanceof Node) { … … 148 152 tr("Merge nodes with different memberships?"), 149 153 tr("The selected nodes have differing relation memberships. " 150 + "Do you still want to merge them?"), 151 new String[] {tr("Merge Anyway"), tr("Cancel")}, 152 new String[] {"mergenodes.png", "cancel.png"}).getValue(); 153 if (option == 1) break; 154 + "Do you still want to merge them?"), 155 new String[] {tr("Merge Anyway"), tr("Cancel")}, 156 new String[] {"mergenodes.png", "cancel.png"}).getValue(); 157 if (option == 1) { 158 break; 159 } 154 160 return null; 155 161 } … … 160 166 for (Node n : allNodes) { 161 167 for (Entry<String,String> e : n.entrySet()) { 162 if (!props.containsKey(e.getKey())) 168 if (!props.containsKey(e.getKey())) { 163 169 props.put(e.getKey(), new TreeSet<String>()); 170 } 164 171 props.get(e.getKey()).add(e.getValue()); 165 172 } … … 187 194 if (!components.isEmpty()) { 188 195 int answer = new ExtendedDialog(Main.parent, 189 tr("Enter values for all conflicts."),190 p,191 new String[] {tr("Solve Conflicts"), tr("Cancel")},192 new String[] {"dialogs/conflict.png", "cancel.png"}).getValue();196 tr("Enter values for all conflicts."), 197 p, 198 new String[] {tr("Solve Conflicts"), tr("Cancel")}, 199 new String[] {"dialogs/conflict.png", "cancel.png"}).getValue(); 193 200 if (answer != 1) 194 201 return null; 195 for (Entry<String, JComboBox> e : components.entrySet()) 202 for (Entry<String, JComboBox> e : components.entrySet()) { 196 203 newNode.put(e.getKey(), e.getValue().getEditor().getItem().toString()); 204 } 197 205 } 198 206 … … 202 210 Collection<OsmPrimitive> del = new HashSet<OsmPrimitive>(); 203 211 204 for (Way w : Main.ds.ways) { 205 if (w.deleted || w.incomplete || w.nodes.size() < 1) continue; 212 for (Way w : getCurrentDataSet().ways) { 213 if (w.deleted || w.incomplete || w.nodes.size() < 1) { 214 continue; 215 } 206 216 boolean modify = false; 207 217 for (Node sn : allNodes) { 208 if (sn == dest) continue; 218 if (sn == dest) { 219 continue; 220 } 209 221 if (w.nodes.contains(sn)) { 210 222 modify = true; 211 223 } 212 224 } 213 if (!modify) continue; 225 if (!modify) { 226 continue; 227 } 214 228 // OK - this way contains one or more nodes to change 215 229 ArrayList<Node> nn = new ArrayList<Node>(); … … 227 241 if (nn.size() < 2) { 228 242 CollectBackReferencesVisitor backRefs = 229 new CollectBackReferencesVisitor( Main.ds, false);243 new CollectBackReferencesVisitor(getCurrentDataSet(), false); 230 244 w.visit(backRefs); 231 245 if (!backRefs.data.isEmpty()) { 232 246 JOptionPane.showMessageDialog(Main.parent, 233 tr("Cannot merge nodes: " +247 tr("Cannot merge nodes: " + 234 248 "Would have to delete a way that is still used.")); 235 249 return null; … … 247 261 del.addAll(allNodes); 248 262 del.remove(dest); 249 if (!del.isEmpty()) cmds.add(new DeleteCommand(del)); 263 if (!del.isEmpty()) { 264 cmds.add(new DeleteCommand(del)); 265 } 250 266 251 267 // modify all relations containing the now-deleted nodes … … 270 286 271 287 Main.main.undoRedo.add(new SequenceCommand(tr("Merge {0} nodes", allNodes.size()), cmds)); 272 Main.ds.setSelected(dest);288 getCurrentDataSet().setSelected(dest); 273 289 274 290 return dest; -
trunk/src/org/openstreetmap/josm/actions/MirrorAction.java
r1722 r1814 14 14 import org.openstreetmap.josm.Main; 15 15 import org.openstreetmap.josm.command.Command; 16 import org.openstreetmap.josm.command.ChangeCommand;17 16 import org.openstreetmap.josm.command.MoveCommand; 18 17 import org.openstreetmap.josm.command.SequenceCommand; 19 import org.openstreetmap.josm.data.coor.EastNorth;20 18 import org.openstreetmap.josm.data.osm.Node; 21 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 34 32 public MirrorAction() { 35 33 super(tr("Mirror"), "mirror", tr("Mirror selected nodes and ways."), 36 Shortcut.registerShortcut("tools:mirror", tr("Tool: {0}", tr("Mirror")),37 KeyEvent.VK_M, Shortcut.GROUP_EDIT, Shortcut.SHIFT_DEFAULT), true);34 Shortcut.registerShortcut("tools:mirror", tr("Tool: {0}", tr("Mirror")), 35 KeyEvent.VK_M, Shortcut.GROUP_EDIT, Shortcut.SHIFT_DEFAULT), true); 38 36 } 39 37 40 38 public void actionPerformed(ActionEvent e) { 41 Collection<OsmPrimitive> sel = Main.ds.getSelected();39 Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected(); 42 40 HashSet<Node> nodes = new HashSet<Node>(); 43 41 … … 66 64 Collection<Command> cmds = new LinkedList<Command>(); 67 65 68 for (Node n : nodes) 66 for (Node n : nodes) { 69 67 cmds.add(new MoveCommand(n, 2 * (middle - n.getEastNorth().east()), 0.0)); 68 } 70 69 71 70 Main.main.undoRedo.add(new SequenceCommand(tr("Mirror"), cmds)); -
trunk/src/org/openstreetmap/josm/actions/MoveAction.java
r1750 r1814 85 85 } 86 86 87 Collection<OsmPrimitive> selection = Main.ds.getSelected();87 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 88 88 Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection); 89 89 -
trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
r1640 r1814 38 38 public OrthogonalizeAction() { 39 39 super(tr("Orthogonalize Shape"), 40 "ortho",41 tr("Move nodes so all angles are 90 or 270 degree"),42 Shortcut.registerShortcut("tools:orthogonalize", tr("Tool: {0}", tr("Orthogonalize Shape")),43 KeyEvent.VK_Q,44 Shortcut.GROUP_EDIT), true);40 "ortho", 41 tr("Move nodes so all angles are 90 or 270 degree"), 42 Shortcut.registerShortcut("tools:orthogonalize", tr("Tool: {0}", tr("Orthogonalize Shape")), 43 KeyEvent.VK_Q, 44 Shortcut.GROUP_EDIT), true); 45 45 } 46 46 47 47 public void actionPerformed(ActionEvent e) { 48 48 49 Collection<OsmPrimitive> sel = Main.ds.getSelected();49 Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected(); 50 50 51 51 ArrayList<Node> dirnodes = new ArrayList<Node>(); … … 84 84 double angle2 = Math.abs(way.nodes.get(i2).getEastNorth().heading(way.nodes.get(i3).getEastNorth())); 85 85 double delta = Math.abs(angle2 - angle1); 86 while(delta > Math.PI) delta -= Math.PI; 86 while(delta > Math.PI) { 87 delta -= Math.PI; 88 } 87 89 if(delta < Math.PI/4) { 88 90 JOptionPane.showMessageDialog(Main.parent, tr("Please select ways with almost right angles to orthogonalize.")); … … 96 98 "to undesirable results when doing rectangular alignments.<br>" + 97 99 "Change your projection to get rid of this warning.<br>" + 98 99 100 if (!DontShowAgainInfo.show("align_rectangular_4326", msg, false)) {100 "Do you want to continue?"); 101 102 if (!DontShowAgainInfo.show("align_rectangular_4326", msg, false)) 101 103 return; 102 }103 104 } 104 105 // Check, if selection held neither none nor two nodes … … 122 123 123 124 for (OsmPrimitive osm : sel) { 124 if(!(osm instanceof Way)) 125 if(!(osm instanceof Way)) { 125 126 continue; 127 } 126 128 127 129 Way way = (Way)osm; … … 158 160 diff = heading_diff(headings[i], headings[i - 1]); 159 161 } 160 if (diff > angle_diff_max) angle_diff_max = diff; 162 if (diff > angle_diff_max) { 163 angle_diff_max = diff; 164 } 161 165 } 162 166 … … 164 168 // rearrange headings: everything < 0 gets PI/2-rotated 165 169 for (int i=0; i < sides; i++) { 166 if (headings[i] < 0) 170 if (headings[i] < 0) { 167 171 headings[i] += Math.PI/2; 172 } 168 173 } 169 174 } … … 217 222 // been duplicated 218 223 219 if (u == 0) continue; 224 if (u == 0) { 225 continue; 226 } 220 227 221 228 // q is a number between 0 and 1 … … 257 264 double llimit = -Math.PI/4; 258 265 double ulimit = Math.PI/4; 259 while (h - align_to > ulimit) h -= Math.PI/2; 260 while (h - align_to < llimit) h += Math.PI/2; 266 while (h - align_to > ulimit) { 267 h -= Math.PI/2; 268 } 269 while (h - align_to < llimit) { 270 h += Math.PI/2; 271 } 261 272 262 273 return h; -
trunk/src/org/openstreetmap/josm/actions/PasteAction.java
r1750 r1814 31 31 public PasteAction() { 32 32 super(tr("Paste"), "paste", tr("Paste contents of paste buffer."), 33 Shortcut.registerShortcut("system:paste", tr("Edit: {0}", tr("Paste")), KeyEvent.VK_V, Shortcut.GROUP_MENU), true);33 Shortcut.registerShortcut("system:paste", tr("Edit: {0}", tr("Paste")), KeyEvent.VK_V, Shortcut.GROUP_MENU), true); 34 34 setEnabled(false); 35 35 } … … 39 39 } 40 40 41 public staticvoid pasteData(DataSet pasteBuffer, Layer source, ActionEvent e) {41 public void pasteData(DataSet pasteBuffer, Layer source, ActionEvent e) { 42 42 /* Find the middle of the pasteBuffer area */ 43 43 double maxEast = -1E100, minEast = 1E100, maxNorth = -1E100, minNorth = 1E100; … … 63 63 64 64 HashMap<OsmPrimitive,OsmPrimitive> map = new HashMap<OsmPrimitive,OsmPrimitive>(); 65 65 /* temporarily maps old nodes to new so we can do a true deep copy */ 66 66 67 67 /* do the deep copy of the paste buffer contents, leaving the pasteBuffer unchanged */ … … 69 69 Node nnew = new Node(n); 70 70 nnew.id = 0; 71 if (Main.ma in.createOrGetEditLayer() == source) {71 if (Main.map.mapView.getEditLayer() == source) { 72 72 nnew.setEastNorth(nnew.getEastNorth().add(offsetEast, offsetNorth)); 73 73 } … … 113 113 114 114 Main.main.undoRedo.add(new SequenceCommand(tr("Paste"), clist)); 115 Main.ds.setSelected(osms);115 getCurrentDataSet().setSelected(osms); 116 116 Main.map.mapView.repaint(); 117 117 } -
trunk/src/org/openstreetmap/josm/actions/PasteTagsAction.java
r1613 r1814 27 27 public PasteTagsAction(JosmAction copyAction) { 28 28 super(tr("Paste Tags"), "pastetags", 29 tr("Apply tags of contents of paste buffer to all selected items."),30 Shortcut.registerShortcut("system:pastestyle", tr("Edit: {0}", tr("Paste Tags")), KeyEvent.VK_V, Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT), true);29 tr("Apply tags of contents of paste buffer to all selected items."), 30 Shortcut.registerShortcut("system:pastestyle", tr("Edit: {0}", tr("Paste Tags")), KeyEvent.VK_V, Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT), true); 31 31 DataSet.selListeners.add(this); 32 32 copyAction.addListener(this); … … 43 43 OsmPrimitive osm = it.next(); 44 44 Map<String, String> m = osm.keys; 45 if(m == null) 45 if(m == null) { 46 46 continue; 47 } 47 48 48 49 for (String key : m.keySet()) { … … 55 56 Collection<Command> clist = new LinkedList<Command>(); 56 57 String pbSource = "Multiple Sources"; 57 if(Main.pasteBuffer.dataSources.size() == 1) 58 if(Main.pasteBuffer.dataSources.size() == 1) { 58 59 pbSource = ((DataSource) Main.pasteBuffer.dataSources.toArray()[0]).origin; 60 } 59 61 60 62 boolean pbNodes = Main.pasteBuffer.nodes.size() > 0; 61 63 boolean pbWays = Main.pasteBuffer.ways.size() > 0; 62 64 63 boolean seNodes = Main.ds.getSelectedNodes().size() > 0;64 boolean seWays = Main.ds.getSelectedWays().size() > 0;65 boolean seRels = Main.ds.getSelectedRelations().size() > 0;65 boolean seNodes = getCurrentDataSet().getSelectedNodes().size() > 0; 66 boolean seWays = getCurrentDataSet().getSelectedWays().size() > 0; 67 boolean seRels = getCurrentDataSet().getSelectedRelations().size() > 0; 66 68 67 69 if(!seNodes && seWays && !seRels && pbNodes && pbSource.equals("Copied Nodes")) { 68 70 // Copy from nodes to ways 69 pasteKeys(clist, Main.pasteBuffer.nodes, Main.ds.getSelectedWays());71 pasteKeys(clist, Main.pasteBuffer.nodes, getCurrentDataSet().getSelectedWays()); 70 72 } else if(seNodes && !seWays && !seRels && pbWays && pbSource.equals("Copied Ways")) { 71 73 // Copy from ways to nodes 72 pasteKeys(clist, Main.pasteBuffer.ways, Main.ds.getSelectedNodes());74 pasteKeys(clist, Main.pasteBuffer.ways, getCurrentDataSet().getSelectedNodes()); 73 75 } else { 74 76 // Copy from equal to equal 75 pasteKeys(clist, Main.pasteBuffer.nodes, Main.ds.getSelectedNodes());76 pasteKeys(clist, Main.pasteBuffer.ways, Main.ds.getSelectedWays());77 pasteKeys(clist, Main.pasteBuffer.relations, Main.ds.getSelectedRelations());77 pasteKeys(clist, Main.pasteBuffer.nodes, getCurrentDataSet().getSelectedNodes()); 78 pasteKeys(clist, Main.pasteBuffer.ways, getCurrentDataSet().getSelectedWays()); 79 pasteKeys(clist, Main.pasteBuffer.relations, getCurrentDataSet().getSelectedRelations()); 78 80 } 79 81 Main.main.undoRedo.add(new SequenceCommand(tr("Paste Tags"), clist)); 80 Main.ds.setSelected(Main.ds.getSelected()); // to force selection listeners, in particular the tag panel, to update82 getCurrentDataSet().setSelected(getCurrentDataSet().getSelected()); // to force selection listeners, in particular the tag panel, to update 81 83 Main.map.mapView.repaint(); 82 84 } … … 86 88 for (Iterator<? extends OsmPrimitive> it = osms.iterator(); it.hasNext();) { 87 89 OsmPrimitive osm = it.next(); 88 if (osm.keys == null || osm.keys.isEmpty()) 90 if (osm.keys == null || osm.keys.isEmpty()) { 89 91 continue; 92 } 90 93 for (String key : osm.keys.keySet()) { 91 94 String value = osm.keys.get(key); 92 if (! kvSeen.containsKey(key)) 95 if (! kvSeen.containsKey(key)) { 93 96 kvSeen.put(key, value); 94 else if (! kvSeen.get(key).equals(value))97 } else if (! kvSeen.get(key).equals(value)) 95 98 return true; 96 99 } … … 110 113 ! selection.isEmpty() && 111 114 ! pasteBuffer.allPrimitives().isEmpty() && 112 ( Main.ds.getSelectedNodes().isEmpty() ||113 ! containsSameKeysWithDifferentValues(pasteBuffer.nodes)) &&114 (Main.ds.getSelectedWays().isEmpty() ||115 ! containsSameKeysWithDifferentValues(pasteBuffer.ways)) &&116 (Main.ds.getSelectedRelations().isEmpty() ||117 ! containsSameKeysWithDifferentValues(pasteBuffer.relations)));115 (getCurrentDataSet().getSelectedNodes().isEmpty() || 116 ! containsSameKeysWithDifferentValues(pasteBuffer.nodes)) && 117 (getCurrentDataSet().getSelectedWays().isEmpty() || 118 ! containsSameKeysWithDifferentValues(pasteBuffer.ways)) && 119 (getCurrentDataSet().getSelectedRelations().isEmpty() || 120 ! containsSameKeysWithDifferentValues(pasteBuffer.relations))); 118 121 } 119 122 120 123 @Override public void pasteBufferChanged(DataSet newPasteBuffer) { 121 possiblyEnable( Main.ds.getSelected(), newPasteBuffer);124 possiblyEnable(getCurrentDataSet().getSelected(), newPasteBuffer); 122 125 } 123 126 -
trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java
r1613 r1814 30 30 public ReverseWayAction() { 31 31 super(tr("Reverse Ways"), "wayflip", tr("Reverse the direction of all selected ways."), 32 Shortcut.registerShortcut("tools:reverse", tr("Tool: {0}", tr("Reverse Ways")), KeyEvent.VK_R, Shortcut.GROUP_EDIT), true);32 Shortcut.registerShortcut("tools:reverse", tr("Tool: {0}", tr("Reverse Ways")), KeyEvent.VK_R, Shortcut.GROUP_EDIT), true); 33 33 } 34 34 … … 47 47 48 48 public void visitAll() { 49 for (OsmPrimitive osm : Main.ds.getSelected())49 for (OsmPrimitive osm : getCurrentDataSet().getSelected()) { 50 50 osm.visit(this); 51 } 51 52 } 52 53 }.visitAll(); … … 69 70 final Collection<Command> changePropertyCommands = reverseWayTagCorrector.execute(w, wnew); 70 71 propertiesUpdated = propertiesUpdated 71 72 || (changePropertyCommands != null && !changePropertyCommands.isEmpty()); 72 73 c.addAll(changePropertyCommands); 73 74 } … … 80 81 } 81 82 Main.main.undoRedo.add(new SequenceCommand(tr("Reverse ways"), c)); 82 if (propertiesUpdated) 83 DataSet.fireSelectionChanged(Main.ds.getSelected()); 83 if (propertiesUpdated) { 84 DataSet.fireSelectionChanged(getCurrentDataSet().getSelected()); 85 } 84 86 Main.map.repaint(); 85 87 } -
trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java
r1808 r1814 160 160 OsmBzip2Importer osmBzip2Importer = new OsmBzip2Importer(); 161 161 if (gpxImExporter.acceptFile(file)) { 162 GpxExportAction.exportGpx(file, layer);162 new GpxExportAction().exportGpx(file, layer); 163 163 } else if (osmImExporter.acceptFile(file) 164 164 || osmGzipImporter.acceptFile(file) -
trunk/src/org/openstreetmap/josm/actions/SelectAllAction.java
r1808 r1814 7 7 import java.awt.event.KeyEvent; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.gui.layer.Layer; 11 10 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener; … … 24 23 if (!isEnabled()) 25 24 return; 26 Main.ds.setSelected(Main.ds.allNonDeletedCompletePrimitives());25 getCurrentDataSet().setSelected(getCurrentDataSet().allNonDeletedCompletePrimitives()); 27 26 } 28 27 … … 32 31 */ 33 32 protected void refreshEnabled() { 34 setEnabled(Main.map != null 35 && Main.map.mapView !=null 36 && Main.map.mapView.getEditLayer() != null 37 ); 33 setEnabled(getEditLayer() != null); 38 34 } 39 35 -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r1809 r1814 32 32 import org.openstreetmap.josm.data.osm.Way; 33 33 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor; 34 import org.openstreetmap.josm.data.osm.visitor.NameVisitor;35 34 import org.openstreetmap.josm.data.osm.visitor.Visitor; 35 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 36 36 import org.openstreetmap.josm.tools.Shortcut; 37 37 … … 65 65 public void actionPerformed(ActionEvent e) { 66 66 67 Collection<OsmPrimitive> selection = Main.ds.getSelected();67 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 68 68 69 69 if (!checkSelection(selection)) { … … 99 99 HashMap<Way, Integer> wayOccurenceCounter = new HashMap<Way, Integer>(); 100 100 for (Node n : selectedNodes) { 101 for (Way w : Main.ds.ways) {101 for (Way w : getCurrentDataSet().ways) { 102 102 if (w.deleted || w.incomplete) { 103 103 continue; … … 272 272 Boolean warnme=false; 273 273 // now copy all relations to new way also 274 for (Relation r : Main.ds.relations) { 274 275 for (Relation r : getCurrentDataSet().relations) { 275 276 if (r.deleted || r.incomplete) { 276 277 continue; … … 329 330 } 330 331 331 NameVisitor v = new NameVisitor();332 v.visit(selectedWay);333 332 Main.main.undoRedo.add( 334 333 new SequenceCommand(tr("Split way {0} into {1} parts", 335 v.name, wayChunks.size()),334 new PrimitiveNameFormatter().getName(selectedWay), wayChunks.size()), 336 335 commandList)); 337 Main.ds.setSelected(newSelection);336 getCurrentDataSet().setSelected(newSelection); 338 337 } 339 338 -
trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
r1722 r1814 50 50 public UnGlueAction() { 51 51 super(tr("UnGlue Ways"), "unglueways", tr("Duplicate nodes that are used by multiple ways."), 52 Shortcut.registerShortcut("tools:unglue", tr("Tool: {0}", tr("UnGlue Ways")), KeyEvent.VK_G, Shortcut.GROUP_EDIT), true);52 Shortcut.registerShortcut("tools:unglue", tr("Tool: {0}", tr("UnGlue Ways")), KeyEvent.VK_G, Shortcut.GROUP_EDIT), true); 53 53 //DataSet.selListeners.add(this); 54 54 } … … 61 61 public void actionPerformed(ActionEvent e) { 62 62 63 Collection<OsmPrimitive> selection = Main.ds.getSelected();63 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 64 64 65 65 String errMsg = null; 66 66 if (checkSelection(selection)) { 67 67 int count = 0; 68 for (Way w : Main.ds.ways) { 69 if (w.deleted || w.incomplete || w.nodes.size() < 1) continue; 70 if (!w.nodes.contains(selectedNode)) continue; 68 for (Way w : getCurrentDataSet().ways) { 69 if (w.deleted || w.incomplete || w.nodes.size() < 1) { 70 continue; 71 } 72 if (!w.nodes.contains(selectedNode)) { 73 continue; 74 } 71 75 count++; 72 76 } … … 74 78 // If there aren't enough ways, maybe the user wanted to unglue the nodes 75 79 // (= copy tags to a new node) 76 if(checkForUnglueNode(selection)) 80 if(checkForUnglueNode(selection)) { 77 81 unglueNode(e); 78 else82 } else { 79 83 errMsg = tr("This node is not glued to anything else."); 84 } 80 85 } else { 81 86 // and then do the work. … … 86 91 for (Node n : selectedNodes) { 87 92 int count = 0; 88 for (Way w : Main.ds.ways) { 89 if (w.deleted || w.incomplete || w.nodes.size() < 1) continue; 90 if (!w.nodes.contains(n)) continue; 93 for (Way w : getCurrentDataSet().ways) { 94 if (w.deleted || w.incomplete || w.nodes.size() < 1) { 95 continue; 96 } 97 if (!w.nodes.contains(n)) { 98 continue; 99 } 91 100 count++; 92 101 } … … 118 127 "\n"+ 119 128 tr("Note: If a way is selected, this way will get fresh copies of the unglued\n"+ 120 "nodes and the new nodes will be selected. Otherwise, all ways will get their\n"+121 122 } 123 124 if(errMsg != null) 129 "nodes and the new nodes will be selected. Otherwise, all ways will get their\n"+ 130 "own copy and all nodes will be selected."); 131 } 132 133 if(errMsg != null) { 125 134 JOptionPane.showMessageDialog(Main.parent, errMsg); 135 } 126 136 127 137 selectedNode = null; … … 156 166 157 167 Main.main.undoRedo.add(new SequenceCommand(tr("Unglued Node"), cmds)); 158 Main.ds.setSelected(n);168 getCurrentDataSet().setSelected(n); 159 169 Main.map.mapView.repaint(); 160 170 } … … 176 186 return false; 177 187 boolean isPartOfWay = false; 178 for(Way w : Main.ds.ways) {188 for(Way w : getCurrentDataSet().ways) { 179 189 if(w.nodes.contains(n)) { 180 190 isPartOfWay = true; … … 250 260 for (OsmPrimitive p : selection) { 251 261 if (p instanceof Way) { 252 if (selectedWay != null) {262 if (selectedWay != null) 253 263 return false; 254 }255 264 selectedWay = (Way) p; 256 265 } 257 266 } 258 if (selectedWay == null) { 259 return false; 260 } 267 if (selectedWay == null) 268 return false; 261 269 262 270 selectedNodes = new ArrayList<Node>(); … … 264 272 if (p instanceof Node) { 265 273 Node n = (Node) p; 266 if (!selectedWay.nodes.contains(n)) {274 if (!selectedWay.nodes.contains(n)) 267 275 return false; 268 }269 276 selectedNodes.add(n); 270 277 } … … 311 318 Relation newRel = null; 312 319 HashSet<String> rolesToReAdd = null; 313 for (Relation r : Main.ds.relations) { 314 if (r.deleted || r.incomplete) continue; 320 for (Relation r : getCurrentDataSet().relations) { 321 if (r.deleted || r.incomplete) { 322 continue; 323 } 315 324 newRel = null; 316 325 rolesToReAdd = null; … … 330 339 for (RelationMember rm : r.members) { 331 340 //if (rm.member != selectedNode) { 332 341 newRel.members.add(rm); 333 342 //} 334 343 } … … 356 365 boolean firstway = true; 357 366 // modify all ways containing the nodes 358 for (Way w : Main.ds.ways) { 359 if (w.deleted || w.incomplete || w.nodes.size() < 1) continue; 360 if (!w.nodes.contains(selectedNode)) continue; 361 if (!firstway) cmds.add(new ChangeCommand(w, modifyWay(selectedNode, w, cmds, newNodes))); 367 for (Way w : getCurrentDataSet().ways) { 368 if (w.deleted || w.incomplete || w.nodes.size() < 1) { 369 continue; 370 } 371 if (!w.nodes.contains(selectedNode)) { 372 continue; 373 } 374 if (!firstway) { 375 cmds.add(new ChangeCommand(w, modifyWay(selectedNode, w, cmds, newNodes))); 376 } 362 377 firstway = false; 363 378 } … … 372 387 newNodes.add(selectedNode); 373 388 } // if a node and a way has been selected, new selection is only the new node that was added to the selected way 374 Main.ds.setSelected(newNodes);389 getCurrentDataSet().setSelected(newNodes); 375 390 } 376 391 … … 393 408 394 409 Main.main.undoRedo.add(new SequenceCommand(tr("Dupe {0} nodes into {1} nodes", selectedNodes.size(), selectedNodes.size()+allNewNodes.size()), cmds)); 395 Main.ds.setSelected(allNewNodes); 396 } 397 398 // Disabled because we have such a nice help text that would not be shown otherwise. 399 // 400 // /** 401 // * Enable the menu option if the selection looks like we could use it. 402 // */ 403 // public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 404 // setEnabled(checkSelection(newSelection) || checkSelection2(newSelection)); 405 // selectedNode = null; 406 // selectedWay = null; 407 // selectedNodes = null; 408 // } 410 getCurrentDataSet().setSelected(allNewNodes); 411 } 409 412 } -
trunk/src/org/openstreetmap/josm/actions/UnselectAllAction.java
r1808 r1814 44 44 if (!isEnabled()) 45 45 return; 46 Main.ds.setSelected();46 getCurrentDataSet().setSelected(); 47 47 } 48 48 /** … … 51 51 */ 52 52 protected void refreshEnabled() { 53 setEnabled(Main.map != null 54 && Main.map.mapView !=null 55 && Main.map.mapView.getEditLayer() != null 56 ); 53 setEnabled(getEditLayer() != null); 57 54 } 58 55 -
trunk/src/org/openstreetmap/josm/actions/UpdateDataAction.java
r1808 r1814 16 16 import org.openstreetmap.josm.data.osm.DataSource; 17 17 import org.openstreetmap.josm.gui.layer.Layer; 18 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 18 19 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener; 19 20 import org.openstreetmap.josm.tools.Shortcut; … … 38 39 */ 39 40 protected void refreshEnabled() { 40 setEnabled(Main.main != null 41 && Main.map != null 42 && Main.map.mapView !=null 43 && Main.map.mapView.getEditLayer() != null 44 ); 41 setEnabled(getEditLayer() != null); 45 42 } 46 43 … … 50 47 int bboxCount = 0; 51 48 List<Area> areas = new ArrayList<Area>(); 52 for(DataSource ds : Main.ma in.createOrGetEditLayer().data.dataSources) {49 for(DataSource ds : Main.map.mapView.getEditLayer().data.dataSources) { 53 50 areas.add(new Area(ds.bounds.asRect())); 54 51 } -
trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
r1811 r1814 42 42 protected void handlePrimitiveGoneException(long id) { 43 43 MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader(); 44 reader.append( Main.main.createOrGetEditLayer().data,id);44 reader.append(getCurrentDataSet(),id); 45 45 DataSet ds = null; 46 46 try { … … 194 194 */ 195 195 protected void refreshEnabled() { 196 setEnabled(Main.main != null 197 && Main.map != null 198 && Main.map.mapView !=null 199 && Main.map.mapView.getEditLayer() != null 200 && ! Main.map.mapView.getEditLayer().data.getSelected().isEmpty() 196 setEnabled(getCurrentDataSet() != null 197 && ! getCurrentDataSet().getSelected().isEmpty() 201 198 ); 202 199 } … … 208 205 if (! isEnabled()) 209 206 return; 210 Collection<OsmPrimitive> selection = Main.ds.getSelected();207 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 211 208 if (selection.size() == 0) { 212 209 JOptionPane.showMessageDialog( -
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r1811 r1814 178 178 } 179 179 180 ConflictCollection conflicts = Main.ma in.createOrGetEditLayer().getConflicts();180 ConflictCollection conflicts = Main.map.mapView.getEditLayer().getConflicts(); 181 181 if (conflicts !=null && !conflicts.isEmpty()) { 182 182 JOptionPane.showMessageDialog(Main.parent,tr("There are unresolved conflicts. You have to resolve these first.")); … … 189 189 final LinkedList<OsmPrimitive> update = new LinkedList<OsmPrimitive>(); 190 190 final LinkedList<OsmPrimitive> delete = new LinkedList<OsmPrimitive>(); 191 for (OsmPrimitive osm : Main.ds.allPrimitives()) {191 for (OsmPrimitive osm : getCurrentDataSet().allPrimitives()) { 192 192 if (osm.get("josm/ignore") != null) { 193 193 continue; … … 231 231 @Override protected void realRun() throws SAXException, IOException { 232 232 try { 233 server.uploadOsm( Main.ds.version, all, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));234 Main.main.createOrGetEditLayer().cleanData(server.processed, !add.isEmpty());233 server.uploadOsm(getCurrentDataSet().version, all, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)); 234 getEditLayer().cleanData(server.processed, !add.isEmpty()); 235 235 } catch (Exception sxe) { 236 236 if (uploadCancelled) { -
trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
r1750 r1814 77 77 Command c; 78 78 if (ctrl) { 79 c = DeleteCommand.deleteWithReferences( Main.ds.getSelected());79 c = DeleteCommand.deleteWithReferences(getCurrentDataSet().getSelected()); 80 80 } else { 81 c = DeleteCommand.delete( Main.ds.getSelected(), !alt);81 c = DeleteCommand.delete(getCurrentDataSet().getSelected(), !alt); 82 82 } 83 83 if (c != null) { … … 85 85 } 86 86 87 Main.ds.setSelected();87 getCurrentDataSet().setSelected(); 88 88 Main.map.repaint(); 89 89 } … … 124 124 } 125 125 126 Main.ds.setSelected();126 getCurrentDataSet().setSelected(); 127 127 Main.map.mapView.repaint(); 128 128 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r1750 r1814 94 94 // Add extra shortcut N 95 95 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 96 Shortcut.registerShortcut("mapmode:drawfocus", tr("Mode: Draw Focus"), KeyEvent.VK_N, Shortcut.GROUP_EDIT).getKeyStroke(), tr("Draw"));96 Shortcut.registerShortcut("mapmode:drawfocus", tr("Mode: Draw Focus"), KeyEvent.VK_N, Shortcut.GROUP_EDIT).getKeyStroke(), tr("Draw")); 97 97 98 98 cursorCrosshair = getCursor(); … … 124 124 return; 125 125 switch(c) { 126 127 128 129 130 131 132 133 134 126 case way: 127 Main.map.mapView.setCursor(cursorJoinWay); 128 break; 129 case node: 130 Main.map.mapView.setCursor(cursorJoinNode); 131 break; 132 default: 133 Main.map.mapView.setCursor(cursorCrosshair); 134 break; 135 135 } 136 136 } … … 162 162 163 163 // This happens when nothing is selected, but we still want to highlight the "target node" 164 if (mouseOnExistingNode == null && Main.ds.getSelected().size() == 0165 && mousePos != null) 164 if (mouseOnExistingNode == null && getCurrentDataSet().getSelected().size() == 0 165 && mousePos != null) { 166 166 mouseOnExistingNode = Main.map.mapView.getNearestNode(mousePos); 167 } 167 168 168 169 if (mouseOnExistingNode != null) { … … 170 171 // We also need this list for the statusbar help text 171 172 oldHighlights.add(mouseOnExistingNode); 172 if(drawTargetHighlight) 173 if(drawTargetHighlight) { 173 174 mouseOnExistingNode.highlighted = true; 175 } 174 176 return; 175 177 } … … 259 261 260 262 private void tryAgain(MouseEvent e) { 261 Main.ds.setSelected();263 getCurrentDataSet().setSelected(); 262 264 mouseClicked(e); 263 265 } … … 306 308 mousePos = e.getPoint(); 307 309 308 Collection<OsmPrimitive> selection = Main.ds.getSelected();310 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 309 311 Collection<Command> cmds = new LinkedList<Command>(); 310 312 311 313 ArrayList<Way> reuseWays = new ArrayList<Way>(), 312 314 replacedWays = new ArrayList<Way>(); 313 315 boolean newNode = false; 314 316 Node n = null; 315 317 316 if (!ctrl) 318 if (!ctrl) { 317 319 n = Main.map.mapView.getNearestNode(mousePos); 320 } 318 321 319 322 if (n != null) { … … 323 326 // (this is just a convenience option so that people don't 324 327 // have to switch modes) 325 Main.ds.setSelected(n);326 selection = Main.ds.getSelected();328 getCurrentDataSet().setSelected(n); 329 selection = getCurrentDataSet().getSelected(); 327 330 // The user explicitly selected a node, so let him continue drawing 328 331 wayIsFinished = false; … … 334 337 if (n.getCoor().isOutSideWorld()) { 335 338 JOptionPane.showMessageDialog(Main.parent, 336 tr("Cannot add a node outside of the world."));339 tr("Cannot add a node outside of the world.")); 337 340 return; 338 341 } … … 366 369 367 370 pruneSuccsAndReverse(is); 368 for (int i : is) segSet.add( 369 Pair.sort(new Pair<Node,Node>(w.nodes.get(i), w.nodes.get(i+1)))); 370 for (int i : is) wnew.addNode(i + 1, n); 371 for (int i : is) { 372 segSet.add( 373 Pair.sort(new Pair<Node,Node>(w.nodes.get(i), w.nodes.get(i+1)))); 374 } 375 for (int i : is) { 376 wnew.addNode(i + 1, n); 377 } 371 378 372 379 // If ALT is pressed, a new way should be created and that new way should get … … 375 382 // but pressing ALT prevents this. Therefore we must de-select the way manually 376 383 // here so /only/ the new way will be selected after this method finishes. 377 if(alt) wnew.selected = false; 384 if(alt) { 385 wnew.selected = false; 386 } 378 387 379 388 cmds.add(new ChangeCommand(insertPoint.getKey(), wnew)); … … 450 459 int nodeCount=0; 451 460 for (Node p : way.nodes) 452 if(p.equals(n0)) nodeCount++; 453 if(nodeCount > 1) way = null; 461 if(p.equals(n0)) { 462 nodeCount++; 463 } 464 if(nodeCount > 1) { 465 way = null; 466 } 454 467 } 455 468 … … 476 489 477 490 // Add new node to way 478 if (way.nodes.get(way.nodes.size() - 1) == n0) 491 if (way.nodes.get(way.nodes.size() - 1) == n0) { 479 492 way.addNode(n); 480 else493 } else { 481 494 way.addNode(0, n); 495 } 482 496 483 497 extendedWay = true; 484 Main.ds.setSelected(way);498 getCurrentDataSet().setSelected(way); 485 499 } 486 500 } … … 488 502 String title; 489 503 if (!extendedWay) { 490 if (!newNode) {504 if (!newNode) 491 505 return; // We didn't do anything. 492 }else if (reuseWays.isEmpty()) {506 else if (reuseWays.isEmpty()) { 493 507 title = tr("Add node"); 494 508 } else { 495 509 title = tr("Add node into way"); 496 for (Way w : reuseWays) w.selected = false; 497 } 498 Main.ds.setSelected(n); 510 for (Way w : reuseWays) { 511 w.selected = false; 512 } 513 } 514 getCurrentDataSet().setSelected(n); 499 515 } else if (!newNode) { 500 516 title = tr("Connect existing way to node"); … … 508 524 509 525 Main.main.undoRedo.add(c); 510 if(!wayIsFinished) lastUsedNode = n; 526 if(!wayIsFinished) { 527 lastUsedNode = n; 528 } 511 529 512 530 computeHelperLine(); … … 534 552 int posn0 = selectedWay.nodes.indexOf(currentNode); 535 553 if( posn0 != -1 && // n0 is part of way 536 (posn0 >= 1 && targetNode.equals(selectedWay.nodes.get(posn0-1))) || // previous node537 (posn0 < selectedWay.nodes.size()-1) && targetNode.equals(selectedWay.nodes.get(posn0+1))) { // next node538 Main.ds.setSelected(targetNode);554 (posn0 >= 1 && targetNode.equals(selectedWay.nodes.get(posn0-1))) || // previous node 555 (posn0 < selectedWay.nodes.size()-1) && targetNode.equals(selectedWay.nodes.get(posn0+1))) { // next node 556 getCurrentDataSet().setSelected(targetNode); 539 557 lastUsedNode = targetNode; 540 558 return true; … … 618 636 double angle = -1; 619 637 620 Collection<OsmPrimitive> selection = Main.ds.getSelected();638 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 621 639 622 640 Node selectedNode = null; … … 638 656 if(!ctrl && currentMouseNode == null) { 639 657 List<WaySegment> wss = Main.map.mapView.getNearestWaySegments(mousePos); 640 for(WaySegment ws : wss) 658 for(WaySegment ws : wss) { 641 659 mouseOnExistingWays.add(ws.way); 660 } 642 661 } 643 662 … … 692 711 if (previousNode != null) { 693 712 angle = hdg - Math.toDegrees(previousNode.getCoor().heading(currentBaseNode.getCoor())); 694 if (angle < 0) angle += 360; 713 if (angle < 0) { 714 angle += 360; 715 } 695 716 } 696 717 Main.map.statusLine.setAngle(angle); … … 715 736 * <code>null</code> otherwise. 716 737 */ 717 public staticWay getWayForNode(Node n) {738 public Way getWayForNode(Node n) { 718 739 Way way = null; 719 for (Way w : Main.ds.ways) { 720 if (w.deleted || w.incomplete || w.nodes.size() < 1) continue; 740 for (Way w : getCurrentDataSet().ways) { 741 if (w.deleted || w.incomplete || w.nodes.size() < 1) { 742 continue; 743 } 721 744 Node firstNode = w.nodes.get(0); 722 745 Node lastNode = w.nodes.get(w.nodes.size() - 1); … … 805 828 default: 806 829 EastNorth P = n.getEastNorth(); 807 808 809 810 811 812 813 814 830 seg = segs.iterator().next(); 831 A = seg.a.getEastNorth(); 832 B = seg.b.getEastNorth(); 833 double a = P.distanceSq(B); 834 double b = P.distanceSq(A); 835 double c = A.distanceSq(B); 836 q = (a - b + c) / (2*c); 837 n.setEastNorth(new EastNorth(B.east() + q * (A.east() - B.east()), B.north() + q * (A.north() - B.north()))); 815 838 } 816 839 } … … 883 906 // oldHighlights may store a node or way, check if it's a node 884 907 OsmPrimitive x = oldHighlights.iterator().next(); 885 if (x instanceof Node) 908 if (x instanceof Node) { 886 909 rv = tr("Select node under cursor."); 887 else910 } else { 888 911 rv = trn("Insert new node into way.", "Insert new node into {0} ways.", 889 oldHighlights.size(), oldHighlights.size()); 912 oldHighlights.size(), oldHighlights.size()); 913 } 890 914 } 891 915 … … 894 918 */ 895 919 if (currentBaseNode != null && !wayIsFinished) { 896 if (alt) 920 if (alt) { 897 921 rv += " " + tr("Start new way from last node."); 898 else922 } else { 899 923 rv += " " + tr("Continue way from last node."); 924 } 900 925 } 901 926 … … 904 929 * Handle special case: Highlighted node == selected node => finish drawing 905 930 */ 906 if (n != null && Main.ds.getSelectedNodes().contains(n)) {907 if (wayIsFinished) 931 if (n != null && getCurrentDataSet().getSelectedNodes().contains(n)) { 932 if (wayIsFinished) { 908 933 rv = tr("Select node under cursor."); 909 else934 } else { 910 935 rv = tr("Finish drawing."); 936 } 911 937 } 912 938 … … 914 940 * Handle special case: Self-Overlapping or closing way 915 941 */ 916 if ( Main.ds.getSelectedWays().size() > 0 && !wayIsFinished && !alt) {917 Way w = (Way) Main.ds.getSelectedWays().iterator().next();942 if (getCurrentDataSet().getSelectedWays().size() > 0 && !wayIsFinished && !alt) { 943 Way w = (Way) getCurrentDataSet().getSelectedWays().iterator().next(); 918 944 for (Node m : w.nodes) { 919 945 if (m.equals(mouseOnExistingNode) || mouseOnExistingWays.contains(w)) { -
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r1750 r1814 77 77 super(tr("Extrude"), "extrude/extrude", tr("Create areas"), 78 78 Shortcut.registerShortcut("mapmode:extrude", tr("Mode: {0}", tr("Extrude")), KeyEvent.VK_X, Shortcut.GROUP_EDIT), 79 mapFrame,80 getCursor("normal", "rectangle", Cursor.DEFAULT_CURSOR));79 mapFrame, 80 getCursor("normal", "rectangle", Cursor.DEFAULT_CURSOR)); 81 81 putValue("help", "Action/Extrude/Extrude"); 82 82 initialMoveDelay = Main.pref.getInteger("edit.initial-move-delay",200); … … 160 160 161 161 double u = ((en3.east() - en1.east()) * (en2.east() - en1.east()) + 162 163 162 (en3.north() - en1.north()) * (en2.north() - en1.north())) / 163 en2.distanceSq(en1); 164 164 // the point on the segment from which the distance to mouse pos is shortest 165 165 EastNorth base = new EastNorth(en1.east() + u * (en2.east() - en1.east()), 166 166 en1.north() + u * (en2.north() - en1.north())); 167 167 168 168 // find out the distance, in metres, between the base point and the mouse cursor … … 219 219 initialMousePos = e.getPoint(); 220 220 221 if(selectedSegment != null) 222 Main.ds.setSelected(selectedSegment.way); 221 if(selectedSegment != null) { 222 getCurrentDataSet().setSelected(selectedSegment.way); 223 } 223 224 } 224 225 … … 241 242 wnew.addNode(selectedSegment.lowerIndex+1, n3); 242 243 wnew.addNode(selectedSegment.lowerIndex+1, n4); 243 if (wnew.nodes.size() == 4) wnew.addNode(n1); 244 if (wnew.nodes.size() == 4) { 245 wnew.addNode(n1); 246 } 244 247 Collection<Command> cmds = new LinkedList<Command>(); 245 248 cmds.add(new AddCommand(n4)); … … 258 261 259 262 @Override public String getModeHelpText() { 260 if (mode == Mode.select) {263 if (mode == Mode.select) 261 264 return tr("Release the mouse button to select the objects in the rectangle."); 262 } else if (mode == Mode.EXTRUDE) {265 else if (mode == Mode.EXTRUDE) 263 266 return tr("Draw a rectangle of the desired size, then release the mouse button."); 264 } else if (mode == Mode.rotate) {267 else if (mode == Mode.rotate) 265 268 return tr("Release the mouse button to stop rotating."); 266 } else {269 else 267 270 return tr("Drag a way segment to make a rectangle."); 268 } 269 } 270 271 @Override public boolean layerIsSupported(Layer l) { 272 return l instanceof OsmDataLayer; 273 } 271 } 272 273 @Override public boolean layerIsSupported(Layer l) { 274 return l instanceof OsmDataLayer; 275 } 274 276 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r1750 r1814 207 207 // Currently we support moving and rotating, which do not affect relations. 208 208 // So don't add them in the first place to make handling easier 209 Collection<OsmPrimitive> selection = Main.ds.getSelectedNodesAndWays();209 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelectedNodesAndWays(); 210 210 Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection); 211 211 … … 355 355 356 356 if (ctrl && shift) { 357 if ( Main.ds.getSelected().isEmpty()) {357 if (getCurrentDataSet().getSelected().isEmpty()) { 358 358 selectPrims(osmColl, true, false, false, false); 359 359 } … … 366 366 // move. 367 367 selectPrims(osmColl, 368 shift || Main.ds.getSelected().containsAll(osmColl),368 shift || getCurrentDataSet().getSelected().containsAll(osmColl), 369 369 ctrl, false, false); 370 370 mode = Mode.move; … … 403 403 404 404 // Select Draw Tool if no selection has been made 405 if( Main.ds.getSelected().size() == 0 && !cancelDrawMode) {405 if(getCurrentDataSet().getSelected().size() == 0 && !cancelDrawMode) { 406 406 Main.map.selectDrawTool(true); 407 407 return; … … 419 419 420 420 // If the user double-clicked a node, change to draw mode 421 List<OsmPrimitive> sel = new ArrayList<OsmPrimitive>( Main.ds.getSelected());421 List<OsmPrimitive> sel = new ArrayList<OsmPrimitive>(getCurrentDataSet().getSelected()); 422 422 if(e.getClickCount() >=2 && sel.size() == 1 && sel.get(0) instanceof Node) { 423 423 // We need to do it like this as otherwise drawAction will see a double … … 431 431 } 432 432 } else { 433 Collection<OsmPrimitive> selection = Main.ds.getSelected();433 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 434 434 Collection<OsmPrimitive> s = new TreeSet<OsmPrimitive>(); 435 435 int max = Main.pref.getInteger("warn.move.maxelements", 20); … … 469 469 if (selNodes.size() > 0) { 470 470 selNodes.add(n); 471 MergeNodesAction.mergeNodes(selNodes, n);471 new MergeNodesAction().mergeNodes(selNodes, n); 472 472 } 473 473 } … … 496 496 curSel = new LinkedList<OsmPrimitive>(); // new selection will replace the old. 497 497 } else { 498 curSel = Main.ds.getSelected();498 curSel = getCurrentDataSet().getSelected(); 499 499 } 500 500 … … 512 512 } 513 513 } 514 Main.ds.setSelected(curSel);514 getCurrentDataSet().setSelected(curSel); 515 515 Main.map.mapView.repaint(); 516 516 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/ZoomAction.java
r1722 r1814 7 7 import java.awt.event.KeyEvent; 8 8 9 import org.openstreetmap.josm.data.coor.EastNorth;10 9 import org.openstreetmap.josm.gui.MapFrame; 11 10 import org.openstreetmap.josm.gui.MapView; … … 47 46 public ZoomAction(MapFrame mapFrame) { 48 47 super(tr("Zoom"), "zoom", tr("Zoom and move map"), 49 Shortcut.registerShortcut("mapmode:zoom", tr("Mode: {0}", tr("Zoom")), KeyEvent.VK_Z, Shortcut.GROUP_EDIT),50 mapFrame, ImageProvider.getCursor("normal", "zoom"));48 Shortcut.registerShortcut("mapmode:zoom", tr("Mode: {0}", tr("Zoom")), KeyEvent.VK_Z, Shortcut.GROUP_EDIT), 49 mapFrame, ImageProvider.getCursor("normal", "zoom")); 51 50 mv = mapFrame.mapView; 52 51 selectionManager = new SelectionManager(this, true, mv); … … 57 56 */ 58 57 public void selectionEnded(Rectangle r, boolean alt, boolean shift, boolean ctrl) { 59 if (r.width >= 3 && r.height >= 3) 58 if (r.width >= 3 && r.height >= 3) { 60 59 mv.zoomToFactor(mv.getEastNorth(r.x+r.width/2, r.y+r.height/2), r.getWidth()/mv.getWidth()); 60 } 61 61 } 62 62 -
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r1808 r1814 164 164 } 165 165 try { 166 Collection<OsmPrimitive> sel = Main. ds.getSelected();166 Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected(); 167 167 SearchCompiler.Match matcher = SearchCompiler.compile(search, caseSensitive, regexSearch); 168 168 int foundMatches = 0; 169 for (OsmPrimitive osm : Main. ds.allNonDeletedCompletePrimitives()) {169 for (OsmPrimitive osm : Main.main.getCurrentDataSet().allNonDeletedCompletePrimitives()) { 170 170 if (mode == SearchMode.replace) { 171 171 if (matcher.match(osm)) { … … 183 183 } 184 184 } 185 Main. ds.setSelected(sel);185 Main.main.getCurrentDataSet().setSelected(sel); 186 186 if (foundMatches == 0) { 187 187 String msg = null; … … 241 241 */ 242 242 protected void refreshEnabled() { 243 setEnabled(Main.map != null 244 && Main.map.mapView !=null 245 && Main.map.mapView.getEditLayer() != null 246 ); 243 setEnabled(getEditLayer() != null); 247 244 } 248 245 -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r1786 r1814 133 133 String value = null; 134 134 135 if (key.equals("timestamp")) 135 if (key.equals("timestamp")) { 136 136 value = DateUtils.fromDate(osm.getTimestamp()); 137 else137 } else { 138 138 value = osm.get(key); 139 } 139 140 140 141 if (value == null) … … 169 170 170 171 public ExactKeyValue(boolean regexp, String key, String value) throws ParseError { 171 if (key == "") {172 if (key == "") 172 173 throw new ParseError(tr("Key cannot be empty when tag operator is used. Sample use: key=value")); 173 }174 174 this.key = key; 175 175 this.value = value; … … 223 223 public boolean match(OsmPrimitive osm) throws ParseError { 224 224 225 if (osm.keys == null || osm.keys.isEmpty()) {225 if (osm.keys == null || osm.keys.isEmpty()) 226 226 return mode == Mode.NONE; 227 }228 227 229 228 switch (mode) { … … 238 237 case ANY_KEY: 239 238 for (String v:osm.keys.values()) { 240 if (v.equals(value)) {239 if (v.equals(value)) 241 240 return true; 242 }243 241 } 244 242 return false; … … 247 245 case ANY_KEY_REGEXP: 248 246 for (String v:osm.keys.values()) { 249 if (valuePattern.matcher(v).matches()) {247 if (valuePattern.matcher(v).matches()) 250 248 return true; 251 }252 249 } 253 250 return false; … … 257 254 if (keyPattern.matcher(entry.getKey()).matches()) { 258 255 if (mode == Mode.ANY_VALUE_REGEXP 259 || valuePattern.matcher(entry.getValue()).matches()) {256 || valuePattern.matcher(entry.getValue()).matches()) 260 257 return true; 261 }262 258 } 263 259 } … … 265 261 case MISSING_KEY_REGEXP: 266 262 for (String k:osm.keys.keySet()) { 267 if (keyPattern.matcher(k).matches()) {263 if (keyPattern.matcher(k).matches()) 268 264 return false; 269 }270 265 } 271 266 return true; … … 337 332 // is not Java 1.5 338 333 //String name = java.text.Normalizer.normalize(name, java.text.Normalizer.Form.NFC); 339 if (!caseSensitive) 334 if (!caseSensitive) { 340 335 name = name.toLowerCase(); 336 } 341 337 if (name.indexOf(search) != -1) 342 338 return true; … … 356 352 } else if ("relation".equals(type)) { 357 353 this.type = Relation.class; 358 } else {354 } else 359 355 throw new ParseError(tr("Unknown primitive type: {0}. Allowed values are node, way or relation", 360 356 type)); 361 }362 357 } 363 358 @Override public boolean match(OsmPrimitive osm) { … … 441 436 // "parent" (null) should mean the same as "parent()" 442 437 // (Always). I.e. match everything 443 if (child == null) 438 if (child == null) { 444 439 child = new Always(); 440 } 445 441 446 442 if (osm instanceof Way) { 447 for (Node n : ((Way)osm).nodes) 443 for (Node n : ((Way)osm).nodes) { 448 444 isParent |= child.match(n); 445 } 449 446 } else if (osm instanceof Relation) { 450 447 for (RelationMember member : ((Relation)osm).members) { 451 if (member.member != null) 448 if (member.member != null) { 452 449 isParent |= child.match(member.member); 450 } 453 451 } 454 452 } … … 464 462 // "child" (null) should mean the same as "child()" 465 463 // (Always). I.e. match everything 466 if (parent == null) 464 if (parent == null) { 467 465 parent = new Always(); 466 } 468 467 469 468 boolean isChild = false; 470 CollectBackReferencesVisitor backRefs = new CollectBackReferencesVisitor(Main. ds);469 CollectBackReferencesVisitor backRefs = new CollectBackReferencesVisitor(Main.main.getCurrentDataSet()); 471 470 osm.visit(backRefs); 472 471 for (OsmPrimitive p : backRefs.data) { … … 485 484 486 485 public static Match compile(String searchStr, boolean caseSensitive, boolean regexSearch) 487 486 throws ParseError { 488 487 return new SearchCompiler(caseSensitive, regexSearch, 489 488 new PushbackTokenizer( 490 new PushbackReader(new StringReader(searchStr))))491 489 new PushbackReader(new StringReader(searchStr)))) 490 .parse(); 492 491 } 493 492 494 493 public Match parse() throws ParseError { 495 494 Match m = parseJuxta(); 496 if (!tokenizer.readIfEqual(null)) {495 if (!tokenizer.readIfEqual(null)) 497 496 throw new ParseError(tr("Unexpected token: {0}", tokenizer.nextToken())); 498 }499 497 return m; 500 498 } … … 515 513 if (tokenizer.readIfEqual("|")) { 516 514 Match b = parseNot(); 517 if (a == null || b == null) {515 if (a == null || b == null) 518 516 throw new ParseError(tr("Missing arguments for or.")); 519 }520 517 return new Or(a, b); 521 518 } … … 526 523 if (tokenizer.readIfEqual("-")) { 527 524 Match m = parseParens(); 528 if (m == null) {525 if (m == null) 529 526 throw new ParseError(tr("Missing argument for not.")); 530 }531 527 return new Not(m); 532 528 } … … 537 533 if (tokenizer.readIfEqual("(")) { 538 534 Match m = parseJuxta(); 539 if (!tokenizer.readIfEqual(")")) {535 if (!tokenizer.readIfEqual(")")) 540 536 throw new ParseError(tr("Expected closing parenthesis.")); 541 }542 537 return m; 543 538 } … … 550 545 if (tokenizer.readIfEqual(":")) { 551 546 String tok2 = tokenizer.readText(); 552 if (tok == null) tok = ""; 553 if (tok2 == null) tok2 = ""; 547 if (tok == null) { 548 tok = ""; 549 } 550 if (tok2 == null) { 551 tok2 = ""; 552 } 554 553 return parseKV(tok, tok2); 555 554 } … … 557 556 if (tokenizer.readIfEqual("=")) { 558 557 String tok2 = tokenizer.readText(); 559 if (tok == null) tok = ""; 560 if (tok2 == null) tok2 = ""; 558 if (tok == null) { 559 tok = ""; 560 } 561 if (tok2 == null) { 562 tok2 = ""; 563 } 561 564 return new ExactKeyValue(regexSearch, tok, tok2); 562 565 } 563 566 564 if (tok == null) {567 if (tok == null) 565 568 return null; 566 } else if (tok.equals("modified")) {569 else if (tok.equals("modified")) 567 570 return new Modified(); 568 } else if (tok.equals("incomplete")) {571 else if (tok.equals("incomplete")) 569 572 return new Incomplete(); 570 } else if (tok.equals("untagged")) {573 else if (tok.equals("untagged")) 571 574 return new Untagged(); 572 } else if (tok.equals("selected")) {575 else if (tok.equals("selected")) 573 576 return new Selected(); 574 } else if (tok.equals("child")) {577 else if (tok.equals("child")) 575 578 return new Child(parseParens()); 576 } else if (tok.equals("parent")) {579 else if (tok.equals("parent")) 577 580 return new Parent(parseParens()); 578 } else {581 else 579 582 return new Any(tok); 580 }581 583 } 582 584 583 585 private Match parseKV(String key, String value) throws ParseError { 584 if (key.equals("type")) {586 if (key.equals("type")) 585 587 return new ExactType(value); 586 } else if (key.equals("user")) {588 else if (key.equals("user")) 587 589 return new UserMatch(value); 588 }else if (key.equals("nodes")) {590 else if (key.equals("nodes")) { 589 591 try { 590 592 String[] range = value.split("-"); 591 if (range.length == 1) {593 if (range.length == 1) 592 594 return new NodeCount(Integer.parseInt(value)); 593 } else if (range.length == 2) {595 else if (range.length == 2) 594 596 return new NodeCountRange(Integer.parseInt(range[0]), Integer.parseInt(range[1])); 595 } else {597 else 596 598 throw new ParseError(tr("Wrong number of parameters for nodes operator.")); 597 }598 599 } catch (NumberFormatException e) { 599 600 throw new ParseError(tr("Incorrect value of nodes operator: {0}. Nodes operator expects number of nodes or range, for example nodes:10-20", value)); … … 606 607 throw new ParseError(tr("Incorrect value of id operator: {0}. Number is expected.", value)); 607 608 } 608 } else {609 } else 609 610 return new KeyValue(key, value); 610 }611 611 } 612 612 … … 627 627 // insensitively, but the OSM data is in Unicode. With 628 628 // UNICODE_CASE casefolding is made Unicode-aware. 629 if (!caseSensitive) 629 if (!caseSensitive) { 630 630 searchFlags |= (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); 631 } 631 632 632 633 return searchFlags; -
trunk/src/org/openstreetmap/josm/actions/search/SelectionWebsiteLoader.java
r1811 r1814 40 40 @Override protected void realRun() { 41 41 progressMonitor.setTicksCount(2); 42 sel = mode != SearchAction.SearchMode.remove ? new LinkedList<OsmPrimitive>() : Main. ds.allNonDeletedPrimitives();42 sel = mode != SearchAction.SearchMode.remove ? new LinkedList<OsmPrimitive>() : Main.main.getCurrentDataSet().allNonDeletedPrimitives(); 43 43 try { 44 44 URLConnection con = url.openConnection(); … … 47 47 progressMonitor.subTask(tr("Downloading...")); 48 48 Map<Long, String> ids = idReader.parseIds(in); 49 for (OsmPrimitive osm : Main. ds.allNonDeletedPrimitives()) {49 for (OsmPrimitive osm : Main.main.getCurrentDataSet().allNonDeletedPrimitives()) { 50 50 if (ids.containsKey(osm.id) && osm.getClass().getName().toLowerCase().endsWith(ids.get(osm.id))) { 51 51 if (mode == SearchAction.SearchMode.remove) { … … 86 86 @Override protected void finish() { 87 87 if (sel != null) { 88 Main. ds.setSelected(sel);88 Main.main.getCurrentDataSet().setSelected(sel); 89 89 } 90 90 }
Note:
See TracChangeset
for help on using the changeset viewer.