Changeset 30177 in osm for applications/editors/josm/plugins/utilsplugin2/src/org
- Timestamp:
- 2014-01-04T09:54:56+01:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/AddIntersectionsAction.java
r28028 r30177 23 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; 24 24 import org.openstreetmap.josm.data.osm.Way; 25 import org.openstreetmap.josm.gui.Notification; 25 26 import org.openstreetmap.josm.tools.Geometry; 26 27 import org.openstreetmap.josm.tools.Shortcut; … … 39 40 List<Way> ways = OsmPrimitive.getFilteredList(getCurrentDataSet().getSelected(), Way.class); 40 41 if (ways.isEmpty()) { 41 JOptionPane.showMessageDialog( 42 Main.parent, 43 tr("Please select one or more ways with intersections of segments."), 44 tr("Information"), 45 JOptionPane.INFORMATION_MESSAGE 46 ); 42 new Notification( 43 tr("Please select one or more ways with intersections of segments.")) 44 .setIcon(JOptionPane.INFORMATION_MESSAGE) 45 .show(); 47 46 return; 48 47 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/AlignWayNodesAction.java
r28028 r30177 10 10 import javax.swing.JOptionPane; 11 11 import org.openstreetmap.josm.actions.JosmAction; 12 import org.openstreetmap.josm.gui.Notification; 12 13 import static org.openstreetmap.josm.tools.I18n.tr; 13 14 … … 36 37 Way way = ways.iterator().next(); 37 38 if( way.getNodesCount() < (way.isClosed() ? 4 : 3) ) { 38 JOptionPane.showMessageDialog(Main.parent, tr("The way with selected nodes can not be straightened."), TITLE, JOptionPane.ERROR_MESSAGE); 39 new Notification(tr("The way with selected nodes can not be straightened.")) 40 .setIcon(JOptionPane.ERROR_MESSAGE).show(); 39 41 return; 40 42 } … … 66 68 67 69 if( nodes.size() < 3 ) { 68 JOptionPane.showMessageDialog(Main.parent, tr("Internal error: number of nodes is {0}.", nodes.size()),69 TITLE, JOptionPane.ERROR_MESSAGE);70 new Notification(tr("Internal error: number of nodes is {0}.", nodes.size())) 71 .setIcon(JOptionPane.ERROR_MESSAGE).show(); 70 72 return; 71 73 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/ExtractPointAction.java
r30002 r30177 20 20 import org.openstreetmap.josm.command.SequenceCommand; 21 21 import org.openstreetmap.josm.data.osm.*; 22 import org.openstreetmap.josm.gui.Notification; 22 23 23 24 import org.openstreetmap.josm.tools.Shortcut; … … 37 38 } 38 39 40 @Override 39 41 public void actionPerformed(ActionEvent e) { 40 42 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 41 43 List<Node> selectedNodes = OsmPrimitive.getFilteredList(selection, Node.class); 42 44 if (selectedNodes.size()!=1) { 43 JOptionPane.showMessageDialog(Main.parent, 44 tr("This tool extracts node from its ways and requires single node to be selected."), 45 tr("Extract node"), JOptionPane.INFORMATION_MESSAGE); 45 new Notification(tr("This tool extracts node from its ways and requires single node to be selected.")) 46 .setIcon(JOptionPane.WARNING_MESSAGE).show(); 46 47 return; 47 48 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitObjectAction.java
r29121 r30177 25 25 import org.openstreetmap.josm.data.osm.OsmPrimitive; 26 26 import org.openstreetmap.josm.data.osm.Way; 27 import org.openstreetmap.josm.gui.Notification; 28 27 29 import org.openstreetmap.josm.tools.Shortcut; 28 30 … … 63 65 64 66 if (!checkSelection(selection)) { 65 JOptionPane.showMessageDialog( 66 Main.parent, 67 tr("The current selection cannot be used for splitting."), 68 tr("Warning"), 69 JOptionPane.WARNING_MESSAGE 70 ); 67 showWarningNotification(tr("The current selection cannot be used for splitting.")); 71 68 return; 72 69 } … … 118 115 } 119 116 if (wayOccurenceCounter.isEmpty()) { 120 JOptionPane.showMessageDialog(Main.parent, 121 trn("The selected node is not in the middle of any way.", 122 "The selected nodes are not in the middle of any way.", 123 selectedNodes.size()), 124 tr("Warning"), 125 JOptionPane.WARNING_MESSAGE); 117 showWarningNotification( 118 trn("The selected node is not in the middle of any way.", 119 "The selected nodes are not in the middle of any way.", 120 selectedNodes.size())); 126 121 return; 127 122 } … … 130 125 if (entry.getValue().equals(selectedNodes.size())) { 131 126 if (selectedWay != null) { 132 JOptionPane.showMessageDialog(Main.parent, 133 trn("There is more than one way using the node you selected. Please select the way also.", 134 "There is more than one way using the nodes you selected. Please select the way also.", 135 selectedNodes.size()), 136 tr("Warning"), 137 JOptionPane.WARNING_MESSAGE); 127 showWarningNotification( 128 trn("There is more than one way using the node you selected. Please select the way also.", 129 "There is more than one way using the nodes you selected. Please select the way also.", 130 selectedNodes.size()) 131 ); 138 132 return; 139 133 } … … 143 137 144 138 if (selectedWay == null) { 145 JOptionPane.showMessageDialog(Main.parent, 146 tr("The selected nodes do not share the same way."), 147 tr("Warning"), 148 JOptionPane.WARNING_MESSAGE); 139 showWarningNotification(tr("The selected nodes do not share the same way.")); 149 140 return; 150 141 } … … 154 145 } else if (selectedWay != null && !selectedNodes.isEmpty()) { 155 146 if (!selectedWay.isClosed()) { 156 JOptionPane.showMessageDialog(Main.parent, 157 tr("The selected way is not closed."), 158 tr("Warning"), 159 JOptionPane.WARNING_MESSAGE); 147 showWarningNotification(tr("The selected way is not closed.")); 160 148 return; 161 149 } … … 163 151 nds.removeAll(selectedWay.getNodes()); 164 152 if (!nds.isEmpty()) { 165 JOptionPane.showMessageDialog(Main.parent, 166 trn("The selected way does not contain the selected node.", 167 "The selected way does not contain all the selected nodes.", 168 selectedNodes.size()), 169 tr("Warning"), 170 JOptionPane.WARNING_MESSAGE); 153 showWarningNotification( 154 trn("The selected way does not contain the selected node.", 155 "The selected way does not contain all the selected nodes.", 156 selectedNodes.size())); 171 157 return; 172 158 } 173 159 } else if (selectedWay != null && selectedNodes.isEmpty()) { 174 JOptionPane.showMessageDialog(Main.parent, 175 tr("The selected way is not a split way, please select split points or split way too."), 176 tr("Warning"), 177 JOptionPane.WARNING_MESSAGE); 160 showWarningNotification( 161 tr("The selected way is not a split way, please select split points or split way too.")); 178 162 return; 179 163 } … … 200 184 (nodeIndex1 == 0 && nodeIndex2 == selectedWay.getNodesCount() - 2) || 201 185 (nodeIndex2 == 0 && nodeIndex1 == selectedWay.getNodesCount() - 2)) { 202 JOptionPane.showMessageDialog(Main.parent, 203 tr("The selected nodes can not be consecutive nodes in the object."), 204 tr("Warning"), 205 JOptionPane.WARNING_MESSAGE); 186 showWarningNotification( 187 tr("The selected nodes can not be consecutive nodes in the object.")); 206 188 return; 207 189 } … … 278 260 setEnabled(checkSelection(selection)); 279 261 } 262 263 void showWarningNotification(String msg) { 264 new Notification(msg) 265 .setIcon(JOptionPane.WARNING_MESSAGE).show(); 266 } 280 267 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitOnIntersectionsAction.java
r30002 r30177 13 13 import org.openstreetmap.josm.actions.JosmAction; 14 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 import org.openstreetmap.josm.gui.Notification; 15 16 import static org.openstreetmap.josm.tools.I18n.tr; 16 17 … … 65 66 } 66 67 } else if( refs.size() > 1 ) { 67 JOptionPane.showMessageDialog( 68 Main.parent, 69 tr("There are several ways containing one of the splitting nodes. Select ways participating in this operation."), 70 tr("Warning"), 71 JOptionPane.WARNING_MESSAGE); 68 new Notification( 69 tr("There are several ways containing one of the splitting nodes. Select ways participating in this operation.") 70 ).setIcon(JOptionPane.WARNING_MESSAGE).show(); 72 71 return; 73 72 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SymmetryAction.java
r29769 r30177 22 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 23 23 import org.openstreetmap.josm.data.osm.Way; 24 import org.openstreetmap.josm.gui.Notification; 25 24 26 import org.openstreetmap.josm.tools.Shortcut; 25 27 … … 60 62 61 63 if (p1==null || p2==null || nodes.size() < 1) { 62 JOptionPane.showMessageDialog( 63 Main.parent, 64 tr("Please select at least two nodes for symmetry axis and something else to mirror."), 65 tr("Information"), 66 JOptionPane.INFORMATION_MESSAGE 67 ); 64 new Notification( 65 tr("Please select at least two nodes for symmetry axis and something else to mirror.") 66 ).setIcon(JOptionPane.WARNING_MESSAGE).show(); 68 67 return; 69 68 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryAction.java
r28335 r30177 10 10 import org.openstreetmap.josm.actions.JosmAction; 11 11 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 import org.openstreetmap.josm.gui.Notification; 12 13 import static org.openstreetmap.josm.tools.I18n.tr; 13 14 import org.openstreetmap.josm.tools.Shortcut; … … 36 37 List<OsmPrimitive> selection = new ArrayList<OsmPrimitive>(getCurrentDataSet().getSelected()); 37 38 if (selection.size() != 2) { 38 JOptionPane.showMessageDialog(Main.parent,39 tr("This tool replaces geometry of one object with another, and so requires exactly two objects to be selected.") ,40 TITLE, JOptionPane.INFORMATION_MESSAGE);39 new Notification( 40 tr("This tool replaces geometry of one object with another, and so requires exactly two objects to be selected.") 41 ).setIcon(JOptionPane.WARNING_MESSAGE).show(); 41 42 return; 42 43 } … … 55 56 Main.main.undoRedo.add(replaceCommand); 56 57 } catch (IllegalArgumentException ex) { 57 JOptionPane.showMessageDialog(Main.parent, 58 ex.getMessage(), TITLE, JOptionPane.INFORMATION_MESSAGE); 58 new Notification( 59 ex.getMessage() 60 ).setIcon(JOptionPane.WARNING_MESSAGE).show(); 59 61 } catch (ReplaceGeometryException ex) { 60 JOptionPane.showMessageDialog(Main.parent, 61 ex.getMessage(), TITLE, JOptionPane.INFORMATION_MESSAGE); 62 new Notification( 63 ex.getMessage() 64 ).setIcon(JOptionPane.WARNING_MESSAGE).show(); 62 65 } 63 66 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryUtils.java
r29854 r30177 37 37 38 38 import edu.princeton.cs.algs4.AssignmentProblem; 39 import org.openstreetmap.josm.gui.Notification; 40 import static org.openstreetmap.josm.tools.I18n.tr; 39 41 40 42 /** … … 317 319 catch (Exception e) { 318 320 useRobust = false; 319 JOptionPane.showMessageDialog(Main.parent,320 tr("Exceeded iteration limit for robust method, using simpler method."),321 TITLE, JOptionPane.WARNING_MESSAGE);321 new Notification( 322 tr("Exceeded iteration limit for robust method, using simpler method.") 323 ).setIcon(JOptionPane.WARNING_MESSAGE).show(); 322 324 nodeAssoc = new HashMap<Node, Node>(); 323 325 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/IntersectedWaysAction.java
r29769 r30177 14 14 import org.openstreetmap.josm.actions.JosmAction; 15 15 import org.openstreetmap.josm.data.osm.*; 16 import org.openstreetmap.josm.gui.Notification; 16 17 17 18 import org.openstreetmap.josm.tools.Shortcut; … … 42 43 return; 43 44 } else { 44 JOptionPane.showMessageDialog(Main.parent,45 tr("Please select some ways to find connected and intersecting ways!") ,46 tr("Warning"), JOptionPane.WARNING_MESSAGE);45 new Notification( 46 tr("Please select some ways to find connected and intersecting ways!") 47 ).setIcon(JOptionPane.WARNING_MESSAGE).show(); 47 48 } 48 49 -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/IntersectedWaysRecursiveAction.java
r29769 r30177 14 14 import org.openstreetmap.josm.actions.JosmAction; 15 15 import org.openstreetmap.josm.data.osm.*; 16 import org.openstreetmap.josm.gui.Notification; 17 import static org.openstreetmap.josm.tools.I18n.tr; 16 18 17 19 import org.openstreetmap.josm.tools.Shortcut; … … 42 44 getCurrentDataSet().addSelected(newWays); 43 45 } else { 44 JOptionPane.showMessageDialog(Main.parent,45 tr("Please select some ways to find all connected and intersecting ways!"),46 tr("Warning"), JOptionPane.WARNING_MESSAGE);46 new Notification( 47 tr("Please select some ways to find all connected and intersecting ways!") 48 ).setIcon(JOptionPane.WARNING_MESSAGE).show(); 47 49 } 48 50 -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/MiddleNodesAction.java
r30002 r30177 14 14 import org.openstreetmap.josm.actions.JosmAction; 15 15 import org.openstreetmap.josm.data.osm.*; 16 import org.openstreetmap.josm.gui.Notification; 16 17 17 18 import org.openstreetmap.josm.tools.Shortcut; … … 38 39 // if no 2 nodes and no ways are selected, do nothing 39 40 if (selectedNodes.size() != 2) { 40 JOptionPane.showMessageDialog(Main.parent, 41 tr("Please select two nodes connected by way!"), 42 tr("Warning"), 43 JOptionPane.WARNING_MESSAGE); 41 new Notification( 42 tr("Please select two nodes connected by way!") 43 ).setIcon(JOptionPane.WARNING_MESSAGE).show(); 44 44 return; 45 45 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/NodeWayUtils.java
r30002 r30177 18 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 19 import org.openstreetmap.josm.data.osm.Way; 20 import org.openstreetmap.josm.gui.Notification; 20 21 import org.openstreetmap.josm.tools.Geometry; 22 import static org.openstreetmap.josm.tools.I18n.tr; 21 23 import org.openstreetmap.josm.tools.Pair; 22 24 23 import static org.openstreetmap.josm.tools.I18n.tr;24 25 25 26 … … 199 200 // System.out.printf("%d: %d ways added to selection intersectiong\n",level,c); 200 201 if (c>maxWays1) { 201 JOptionPane.showMessageDialog(Main.parent, 202 tr("Too many ways are added: {0}!",c), 203 tr("Warning"), 204 JOptionPane.WARNING_MESSAGE); 202 new Notification( 203 tr("Too many ways are added: {0}!",c) 204 ).setIcon(JOptionPane.WARNING_MESSAGE).show(); 205 205 return; 206 206 } … … 224 224 // System.out.printf("%d: %d ways added to selection\n",level,c); 225 225 if (c>maxWays) { 226 JOptionPane.showMessageDialog(Main.parent, 227 tr("Too many ways are added: {0}!",c), 228 tr("Warning"), 229 JOptionPane.WARNING_MESSAGE); 226 new Notification( 227 tr("Too many ways are added: {0}!",c) 228 ).setIcon(JOptionPane.WARNING_MESSAGE).show(); 230 229 return; 231 230 } … … 267 266 } 268 267 if (newNodes.isEmpty()) { 269 JOptionPane.showMessageDialog(Main.parent, 270 tr("Please select two nodes connected by way!"), 271 tr("Warning"), 272 JOptionPane.WARNING_MESSAGE); 268 new Notification( 269 tr("Please select two nodes connected by way!") 270 ).setIcon(JOptionPane.WARNING_MESSAGE).show(); 273 271 } 274 272 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectAllInsideAction.java
r30002 r30177 14 14 import org.openstreetmap.josm.actions.JosmAction; 15 15 import org.openstreetmap.josm.data.osm.*; 16 import org.openstreetmap.josm.gui.Notification; 17 16 18 import org.openstreetmap.josm.tools.Shortcut; 17 19 … … 35 37 getCurrentDataSet().addSelected(insideSelected); 36 38 } else{ 37 JOptionPane.showMessageDialog(Main.parent, 38 tr("Nothing found. Please select some closed ways or multipolygons to find all primitives inside them!"), 39 tr("Warning"), JOptionPane.WARNING_MESSAGE); 39 new Notification( 40 tr("Nothing found. Please select some closed ways or multipolygons to find all primitives inside them!")) 41 .setIcon(JOptionPane.WARNING_MESSAGE) 42 .show(); 40 43 } 41 44 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectBoundaryAction.java
r30015 r30177 22 22 import org.openstreetmap.josm.data.osm.Relation; 23 23 import org.openstreetmap.josm.data.osm.Way; 24 import org.openstreetmap.josm.gui.Notification; 25 24 26 import org.openstreetmap.josm.tools.Shortcut; 25 27 … … 42 44 Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class); 43 45 Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Node.class); 44 Set<Relation> selectedRelations = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Relation.class);45 46 46 47 Set<Way> newWays = new HashSet<Way>(); 47 48 48 49 Way w=null; 49 Relation selectedRelation=null;50 50 51 if (selectedRelations.size()==1) { 52 selectedRelation = selectedRelations.iterator().next(); 53 if (selectedRelation.getMemberPrimitives().contains(lastUsedStartingWay)) { 54 w=lastUsedStartingWay; 55 // repeated call for selected relation 56 } 57 } else if (selectedWays.isEmpty()) { 51 if (selectedWays.isEmpty()) { 58 52 if (selectedNodes.size()==1 ) { 59 53 for (OsmPrimitive p : selectedNodes.iterator().next().getReferrers()) { … … 81 75 lastUsedStartingWay = w; 82 76 83 List<Relation> rels=new ArrayList<Relation>(); 84 for (OsmPrimitive p : w.getReferrers()) { 85 if (p instanceof Relation && p.isSelectable()) { 86 rels.add((Relation) p); 87 } 88 } 89 if (selectedRelation!=null) { 90 int idx = rels.indexOf(selectedRelation); 91 // selectedRelation has number idx in active relation list 92 if (idx>=0) { 93 // select next relation 94 if (idx+1<rels.size()) 95 getCurrentDataSet().setSelected(Arrays.asList(rels.get(idx+1))); 96 else 97 getCurrentDataSet().setSelected(Arrays.asList(rels.get(0))); 98 return; 99 } 100 } else if (rels.size()>0) { 101 getCurrentDataSet().setSelected(Arrays.asList(rels.get(0))); 102 return; 103 } 104 77 105 78 // try going left at each turn 106 79 if (! NodeWayUtils.addAreaBoundary(w, newWays, lastUsedLeft) ) { … … 111 84 getCurrentDataSet().setSelected(newWays); 112 85 } else{ 113 JOptionPane.showMessageDialog(Main.parent,114 tr("Nothing found. Please select way that is a part of some polygon formed by connected ways"),115 tr("Warning"), JOptionPane.WARNING_MESSAGE);116 86 new Notification( 87 tr("Nothing found. Please select way that is a part of some polygon formed by connected ways") 88 ).setIcon(JOptionPane.WARNING_MESSAGE).show(); 89 } 117 90 } 118 91 -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectHighwayAction.java
r30002 r30177 11 11 import org.openstreetmap.josm.actions.JosmAction; 12 12 import org.openstreetmap.josm.data.osm.*; 13 import org.openstreetmap.josm.gui.Notification; 14 import static org.openstreetmap.josm.tools.I18n.tr; 13 15 import org.openstreetmap.josm.tools.Shortcut; 14 16 … … 36 38 getCurrentDataSet().setSelected(selectHighwayBetween(selectedWays.get(0), selectedWays.get(1))); 37 39 } else { 38 JOptionPane.showMessageDialog(Main.parent, tr("Please select one or two ways for this action"), "Select Highway", JOptionPane.ERROR_MESSAGE); 40 new Notification( 41 tr("Please select one or two ways for this action") 42 ).setIcon(JOptionPane.WARNING_MESSAGE).show(); 39 43 } 40 44 }
Note:
See TracChangeset
for help on using the changeset viewer.