Changeset 20622 in osm for applications/editors/josm
- Timestamp:
- 2010-03-23T13:35:14+01:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditor.java
r20586 r20622 48 48 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 49 49 import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction; 50 import org.openstreetmap.josm.gui.help.HelpUtil; 50 51 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 51 52 import org.openstreetmap.josm.plugins.turnrestrictions.qa.IssuesView; … … 380 381 * to the dataset. 381 382 */ 382 abstract class SavingAction extends AbstractAction { 383 abstract class SavingAction extends AbstractAction { 384 protected boolean confirmSaveDespiteOfErrorsAndWarnings(){ 385 int numErrors = editorModel.getIssuesModel().getNumErrors(); 386 int numWarnings = editorModel.getIssuesModel().getNumWarnings(); 387 if (numErrors + numWarnings == 0) return true; 388 389 StringBuffer sb = new StringBuffer(); 390 sb.append("<html>"); 391 sb.append(trn( 392 "There is still an unresolved error or warning identified for this turn restriction. " 393 + "You are recommended to resolve this issue first.", 394 "There are still {0} errors and/or warnings identified for this turn restriction. " 395 + "You are recommended to resolve these issues first.", 396 numErrors + numWarnings, 397 numErrors + numWarnings 398 )); 399 sb.append("<br>"); 400 sb.append(tr("Do you want to save anyway?")); 401 ButtonSpec[] options = new ButtonSpec[] { 402 new ButtonSpec( 403 tr("Yes, save anyway"), 404 ImageProvider.get("ok"), 405 tr("Save the turn restriction despite of errors and/or warnings"), 406 null // no specific help topic 407 ), 408 new ButtonSpec( 409 tr("No, resolve issues first"), 410 ImageProvider.get("cancel"), 411 tr("Cancel saving and start resolving pending issues first"), 412 null // no specific help topic 413 ) 414 }; 415 416 int ret = HelpAwareOptionPane.showOptionDialog( 417 JOptionPane.getFrameForComponent(TurnRestrictionEditor.this), 418 sb.toString(), 419 tr("Pending errors and warnings"), 420 JOptionPane.WARNING_MESSAGE, 421 null, // no special icon 422 options, 423 options[1], // cancel is default operation 424 HelpUtil.ht("/Plugins/turnrestrictions#PendingErrorsAndWarnings") 425 ); 426 return ret == 0 /* OK */; 427 } 383 428 384 429 /** … … 595 640 596 641 public void run() { 642 if (!confirmSaveDespiteOfErrorsAndWarnings()){ 643 tpEditors.setSelectedIndex(2); // show the errors and warnings 644 return; 645 } 597 646 if (getTurnRestriction() == null) { 598 647 applyNewTurnRestriction(); … … 634 683 635 684 public void run() { 685 if (!confirmSaveDespiteOfErrorsAndWarnings()){ 686 tpEditors.setSelectedIndex(2); // show the errors and warnings 687 return; 688 } 636 689 if (getTurnRestriction() == null) { 637 690 // it's a new turn restriction. Try to save it and close the dialog -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegRole.java
r20489 r20622 5 5 */ 6 6 public enum TurnRestrictionLegRole { 7 FROM, 8 TO 7 FROM("from"), 8 TO("to"); 9 10 private String osmRoleName; 11 12 private TurnRestrictionLegRole(String osmRoleName) { 13 this.osmRoleName = osmRoleName; 14 } 15 16 public String getOsmRole() { 17 return osmRoleName; 18 } 9 19 } -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/IdenticalTurnRestrictionLegsError.java
r20586 r20622 15 15 */ 16 16 public class IdenticalTurnRestrictionLegsError extends Issue{ 17 private String value;18 17 private OsmPrimitive leg; 19 18 … … 28 27 @Override 29 28 public String getText() { 30 return tr("This turn restriction uses the OSM way < em>{0}</em> with role ''from'' <strong>and</strong> with role ''to''. "29 return tr("This turn restriction uses the OSM way <span class=\"object-name\">{0}</span> with role ''from'' <strong>and</strong> with role ''to''. " 31 30 + "In a turn restriction, the way with role ''from'' should be different from the way with role ''to'', though.", 32 31 leg.getDisplayName(DefaultNameFormatter.getInstance()) -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/IllegalRestrictionTypeError.java
r20586 r20622 25 25 @Override 26 26 public String getText() { 27 return tr("This turn restriction uses a non-standard restriction type <tt>{0}</tt> for the tag key <tt>restriction<tt>. " 27 return tr("This turn restriction uses a non-standard restriction type <tt>{0}</tt> for the tag key <tt>restriction</tt>. " 28 28 + "It is recommended to use standard values only. Please select one in the Basic editor.", 29 29 value -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/Issue.java
r20586 r20622 19 19 abstract public class Issue { 20 20 /** the parent model for this issue */ 21 pr ivateIssuesModel parent;22 pr ivateSeverity severity;21 protected IssuesModel parent; 22 protected Severity severity; 23 23 protected final ArrayList<Action> actions = new ArrayList<Action>(); 24 24 -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/IssueView.java
r20586 r20622 14 14 import javax.swing.JPanel; 15 15 import javax.swing.SwingConstants; 16 import javax.swing.text.html.HTMLEditorKit; 17 import javax.swing.text.html.StyleSheet; 16 18 17 19 import org.openstreetmap.josm.gui.widgets.HtmlPanel; … … 28 30 private Issue issue; 29 31 private JLabel lblIcon; 32 private StyleSheet styleSheet; 33 34 /** 35 * Builds the style sheet used in the internal help browser 36 * 37 * @return the style sheet 38 */ 39 protected void initStyleSheet(HtmlPanel view) { 40 StyleSheet ss = ((HTMLEditorKit)view.getEditorPane().getEditorKit()).getStyleSheet(); 41 ss.addRule("em {font-style: italic}"); 42 ss.addRule("tt {font-family: Courier New}"); 43 ss.addRule(".object-name {background-color:rgb(240,240,240); color: blue;}"); 44 } 30 45 31 46 protected void build() { … … 59 74 gc.weighty = 1.0; 60 75 add(pnlMessage = new HtmlPanel(), gc); 76 initStyleSheet(pnlMessage); 61 77 pnlMessage.setBackground(Color.white); 62 78 pnlMessage.setText("<html><body>" + issue.getText() + "</html></bod>"); 79 63 80 64 81 // if there are any actions available to resolve the issue, add a panel with action buttons … … 98 115 CheckParameterUtil.ensureParameterNotNull(issue, "issue"); 99 116 this.issue = issue; 100 build(); 117 build(); 101 118 } 102 119 -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/IssuesModel.java
r20606 r20622 3 3 import java.util.ArrayList; 4 4 import java.util.Collections; 5 import java.util.HashSet; 5 6 import java.util.List; 6 7 import java.util.Observable; … … 8 9 import java.util.Set; 9 10 11 import org.openstreetmap.josm.data.osm.Node; 10 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 11 13 import org.openstreetmap.josm.data.osm.Way; … … 95 97 checkToLeg(editorModel); 96 98 checkFromAndToEquals(editorModel); 99 checkVias(editorModel); 97 100 } 98 101 setChanged(); … … 188 191 } 189 192 193 protected Node getNodeAtIntersection(Way from, Way to){ 194 Set<Node> fromNodes = new HashSet<Node>(from.getNodes()); 195 fromNodes.retainAll(to.getNodes()); 196 if (fromNodes.size() == 1){ 197 return fromNodes.iterator().next(); 198 } else { 199 return null; 200 } 201 } 202 203 /** 204 * Checks the 'via' members in the turn restriction 205 * 206 * @param editorModel the editor model 207 */ 208 protected void checkVias(TurnRestrictionEditorModel editorModel){ 209 Set<OsmPrimitive> toLegs = editorModel.getTurnRestrictionLeg(TurnRestrictionLegRole.TO); 210 Set<OsmPrimitive> fromLegs = editorModel.getTurnRestrictionLeg(TurnRestrictionLegRole.FROM); 211 // we only check vias if 'to' and 'from' are already OK 212 if (toLegs.size() != 1 || fromLegs.size() != 1) return; 213 if (! (toLegs.iterator().next() instanceof Way)) return; 214 if (! (fromLegs.iterator().next() instanceof Way)) return; 215 216 Way from = (Way)fromLegs.iterator().next(); 217 Way to = (Way)toLegs.iterator().next(); 218 Node intersect = getNodeAtIntersection(from, to); 219 if (intersect != null){ 220 if (!editorModel.getVias().contains(intersect)) { 221 issues.add(new IntersectionMissingAsViaError(this, from, to, intersect)); 222 } 223 } 224 225 // 'from' intersects with 'to' - should be split 226 if (intersect != null && from.getNode(0) != intersect && from.getNode(from.getNodesCount()-1) != intersect){ 227 issues.add(new TurnRestrictionLegSplitRequiredError(this, TurnRestrictionLegRole.FROM, from, to, intersect)); 228 } 229 // 'to' intersects with 'from' - should be split 230 if (intersect != null && to.getNode(0) != intersect && to.getNode(to.getNodesCount()-1) != intersect){ 231 issues.add(new TurnRestrictionLegSplitRequiredError(this, TurnRestrictionLegRole.TO, from, to, intersect)); 232 } 233 } 234 190 235 public NavigationControler getNavigationControler() { 191 236 return editorModel.getNavigationControler(); -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/MissingTurnRestrictionLegError.java
r20586 r20622 34 34 switch(role){ 35 35 case FROM: 36 msg = tr("An OSM way with role < em>from</em> is required in a turn restriction.");36 msg = tr("An OSM way with role <tt>from</t> is required in a turn restriction."); 37 37 break; 38 38 case TO: 39 msg = tr("An OSM way with role < em>to</em> is required in a turn restriction.");39 msg = tr("An OSM way with role <tt>to</tt> is required in a turn restriction."); 40 40 break; 41 41 } -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/MultipleTurnRestrictionLegError.java
r20586 r20622 35 35 switch(role){ 36 36 case FROM: return 37 tr("A turn restriction requires exactly one way with role < em>from</em>. "37 tr("A turn restriction requires exactly one way with role <tt>from</tt>. " 38 38 + "This turn restriction has {0} ways in this role. Please remove " 39 39 + "{1} of them.", … … 42 42 ); 43 43 case TO: 44 tr("A turn restriction requires exactly one way with role < em>from</em>. "44 tr("A turn restriction requires exactly one way with role <tt>from</tt>. " 45 45 + "This turn restriction has {0} ways in this role. Please remove " 46 46 + "{1} of them.", -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/WrongTurnRestrictionLegTypeError.java
r20586 r20622 43 43 case NODE: 44 44 msg = tr( 45 "This turn restriction uses the OSM node ''{0}''as member with role''{1}''.",45 "This turn restriction uses the OSM node <span class=\"object-name\">{0}</span> as member with role <tt>{1}</tt>.", 46 46 leg.getDisplayName(DefaultNameFormatter.getInstance()), 47 47 role.toString() … … 49 49 break; 50 50 case RELATION: 51 msg = tr("This turn restriction uses the OSM relation ''{0}''as member with role''{1}''.",51 msg = tr("This turn restriction uses the OSM relation <span class=\"object-name\">{0}</span> as member with role <tt>{1}</tt>.", 52 52 leg.getDisplayName(DefaultNameFormatter.getInstance()), 53 53 role.toString()
Note:
See TracChangeset
for help on using the changeset viewer.