Changeset 20701 in osm for applications/editors/josm/plugins/turnrestrictions/src/org
- Timestamp:
- 2010-03-27T16:51:44+01:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/CreateOrEditTurnRestrictionAction.java
r20556 r20701 4 4 5 5 import java.awt.event.ActionEvent; 6 import java.awt.event.KeyEvent;7 6 import java.util.Collection; 8 7 import java.util.logging.Logger; 8 9 import javax.swing.ActionMap; 10 import javax.swing.InputMap; 11 import javax.swing.JComponent; 12 import javax.swing.KeyStroke; 9 13 10 14 import org.openstreetmap.josm.Main; … … 15 19 import org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionEditorManager; 16 20 import org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionSelectionPopupPanel; 17 import org.openstreetmap.josm. tools.Shortcut;21 import org.openstreetmap.josm.plugins.turnrestrictions.preferences.PreferenceKeys; 18 22 19 23 /** … … 26 30 public class CreateOrEditTurnRestrictionAction extends JosmAction { 27 31 static private final Logger logger = Logger.getLogger(CreateOrEditTurnRestrictionAction.class.getName()); 28 public CreateOrEditTurnRestrictionAction() { 32 33 /** 34 * Installs the global key stroke with which creating/editing a turn restriction 35 * is triggered. 36 * 37 * @param keyStroke the key stroke 38 */ 39 static public void install(KeyStroke keyStroke){ 40 InputMap im = Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); 41 Object actionMapKey = im.get(keyStroke); 42 if (actionMapKey != null && !actionMapKey.toString().equals("turnrestrictions:create-or-edit")) { 43 System.out.println(tr("Warning: turnrestrictions plugin replaces already existing action ''{0}'' behind shortcut ''{1}'' by action ''{2}''", actionMapKey.toString(), keyStroke.toString(), "turnrestrictions:create-or-edit")); 44 } 45 KeyStroke[] keys = im.keys(); 46 if (keys != null){ 47 for(KeyStroke ks: im.keys()){ 48 if (im.get(ks).equals("turnrestrictions:create-or-edit")) { 49 im.remove(ks); 50 } 51 } 52 } 53 im.put(keyStroke, "turnrestrictions:create-or-edit"); 54 ActionMap am = Main.contentPane.getActionMap(); 55 am.put("turnrestrictions:create-or-edit", getInstance()); 56 } 57 58 /** 59 * Installs global key stroke configured in the preferences. 60 * 61 * @param keyStroke the key stroke 62 */ 63 static public void install(){ 64 String value = Main.pref.get(PreferenceKeys.EDIT_SHORTCUT, "shift ctrl T"); 65 KeyStroke key = KeyStroke.getKeyStroke(value); 66 if (key == null){ 67 System.out.println(tr("Warning: illegal value ''{0}'' for preference key ''{1}''. Falling back to default value ''shift ctrl T''.", value, PreferenceKeys.EDIT_SHORTCUT)); 68 key = KeyStroke.getKeyStroke("shift ctrl T"); 69 } 70 install(key); 71 } 72 73 /** the singleton instance of this action */ 74 private static CreateOrEditTurnRestrictionAction instance; 75 76 /** 77 * Replies the unique instance of this action 78 * 79 * @return 80 */ 81 public static CreateOrEditTurnRestrictionAction getInstance() { 82 if (instance == null){ 83 instance = new CreateOrEditTurnRestrictionAction(); 84 } 85 return instance; 86 } 87 88 protected CreateOrEditTurnRestrictionAction() { 29 89 super( 30 90 tr("Create/Edit turn restriction..."), 31 91 null, 32 92 tr("Create or edit a turn restriction."), 33 Shortcut.registerShortcut( 34 "turnrestrictions:create-or-edit", 35 tr("Turnrestrictions: Create or Edit"), 36 // results in Shift-Ctrl-T on windows 37 KeyEvent.VK_T, 38 Shortcut.GROUPS_ALT1+Shortcut.GROUP_HOTKEY, 39 Shortcut.SHIFT_DEFAULT 40 ), 41 true /* register action */ 93 null, // shortcut is going to be registered later 94 false 42 95 ); 43 96 } -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/TurnRestrictionsPlugin.java
r20556 r20701 9 9 10 10 /** 11 * This is the main class for the turnrestriction plugin.11 * This is the main class for the turnrestrictions plugin. 12 12 * 13 13 */ 14 14 public class TurnRestrictionsPlugin extends Plugin{ 15 15 16 private CreateOrEditTurnRestrictionAction actCreateOrEditTurnRestriction;17 18 16 public TurnRestrictionsPlugin(PluginInformation info) { 19 super(info); 20 actCreateOrEditTurnRestriction = new CreateOrEditTurnRestrictionAction(); 17 super(info); 21 18 } 22 19 … … 30 27 // add the dialog 31 28 newFrame.addToggleDialog(dialog); 29 CreateOrEditTurnRestrictionAction.install(); 32 30 } 33 31 } -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegEditor.java
r20586 r20701 156 156 lblOsmObject.setFont(UIManager.getFont("Label.font").deriveFont(Font.ITALIC)); 157 157 lblOsmObject.setIcon(null); 158 lblOsmObject.setText(tr("multiple objects with role ''{0}''",this.role. toString()));158 lblOsmObject.setText(tr("multiple objects with role ''{0}''",this.role.getOsmRole())); 159 159 lblOsmObject.setToolTipText(null); 160 160 } -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionCellRenderer.java
r20666 r20701 96 96 */ 97 97 protected ImageIcon getIcon(String restrictionType) { 98 if (!isValidRestrictionType(restrictionType)) return null; 98 if (!isValidRestrictionType(restrictionType)) { 99 return ImageProvider.get("types", "non-standard-type"); 100 } 99 101 return ImageProvider.get(buildImageName(restrictionType)); 100 102 } … … 146 148 protected void renderIcon(Relation tr) { 147 149 String restrictionType = tr.get("restriction"); 148 if (!isValidRestrictionType(restrictionType)) {149 icon.setIcon(null);150 return;151 }152 150 icon.setIcon(getIcon(restrictionType)); 153 151 } -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/preferences/PreferenceKeys.java
r20675 r20701 1 1 package org.openstreetmap.josm.plugins.turnrestrictions.preferences; 2 3 import javax.swing.KeyStroke; 2 4 3 5 /** … … 29 31 */ 30 32 String SHOW_VIAS_IN_BASIC_EDITOR = "turnrestrictions.show-vias-in-basic-editor"; 33 34 /** 35 * The shortcut which triggers creating a new or editing and existing turn 36 * restriction. The value must be parseable by {@see KeyStroke#getKeyStroke(String)}. 37 * If missing, the default value "ctrl shift T" is assumed. 38 */ 39 String EDIT_SHORTCUT= "turnrestrictions.edit-shortcut"; 31 40 } -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/preferences/PreferencesPanel.java
r20675 r20701 16 16 import javax.swing.JPanel; 17 17 import javax.swing.JRadioButton; 18 import javax.swing.JSeparator; 18 19 19 20 import org.openstreetmap.josm.data.Preferences; … … 34 35 private ButtonGroup bgIconSet; 35 36 private JCheckBox cbShowViaListInBasicEditor; 37 private ShortcutPreferencePanel pnlShortcutPreference; 36 38 37 39 protected JPanel buildShowViaListInBasicEditorPanel() { … … 47 49 msg.setText("<html><body>" 48 50 + tr("The Basic Editor can optionally display the list of via-objects " 49 + "of a turn restriction s. If enabled, one can alsoedit them "50 + "in the Basic editor . If disabled, editing of via-objects is only"51 + "possible in the Advanced Editor ."51 + "of a turn restriction. If enabled, one can edit them " 52 + "in the Basic editor too. If disabled, editing of via-objects is " 53 + "possible in the Advanced Editor only." 52 54 ) 53 55 + "</body></html>" … … 153 155 add(buildSetBPanel(), gc); 154 156 gc.gridy++; 157 add(new JSeparator(), gc); 158 gc.gridy++; 155 159 add(buildShowViaListInBasicEditorPanel(), gc); 160 gc.gridy++; 161 add(new JSeparator(), gc); 162 gc.gridy++; 163 add(pnlShortcutPreference = new ShortcutPreferencePanel(), gc); 156 164 157 165 // filler - just grab remaining space … … 189 197 boolean b = prefs.getBoolean(PreferenceKeys.SHOW_VIAS_IN_BASIC_EDITOR, false); 190 198 cbShowViaListInBasicEditor.setSelected(b); 199 200 pnlShortcutPreference.initFromPreferences(prefs); 191 201 } 192 202 … … 213 223 prefs.put(PreferenceKeys.SHOW_VIAS_IN_BASIC_EDITOR, newValue); 214 224 } 225 226 pnlShortcutPreference.saveToPreferences(prefs); 215 227 } 216 228 -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/IdenticalTurnRestrictionLegsError.java
r20622 r20701 27 27 @Override 28 28 public String getText() { 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''. "30 + "In a turn restriction, the way with role ''from'' should be different from the way with role ''to'', though.",29 return tr("This turn restriction uses the OSM way <span class=\"object-name\">{0}</span> with role <tt>from</tt> <strong>and</strong> with role <tt>to</tt>. " 30 + "In a turn restriction, the way with role <tt>from</tt> should be different from the way with role <tt>to</tt>, though.", 31 31 leg.getDisplayName(DefaultNameFormatter.getInstance()) 32 32 ); -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/IntersectionMissingAsViaError.java
r20622 r20701 37 37 String msg = tr("The <strong>from</strong>-way <span class=\"object-name\">{0}</span> and the <strong>to</strong>-way <span class=\"object-name\">{1}</span> " 38 38 + "interesect at node <span class=\"object-name\">{2}</span> but <span class=\"object-name\">{2}</span> isn''t a <strong>via</strong>-object.<br> " 39 + "It is recommended to set <span class=\"object-name\">{2}</span> as only<strong>via</strong>-object.",39 + "It is recommended to set <span class=\"object-name\">{2}</span> as unique <strong>via</strong>-object.", 40 40 this.from.getDisplayName(DefaultNameFormatter.getInstance()), 41 41 this.to.getDisplayName(DefaultNameFormatter.getInstance()), -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/MultipleTurnRestrictionLegError.java
r20622 r20701 20 20 * Create the issue 21 21 * 22 * @param parent the par ant model22 * @param parent the parent model 23 23 * @param role the role of the turn restriction leg with multiple entries 24 24 * @param numLegs the number of legs … … 34 34 public String getText() { 35 35 switch(role){ 36 case FROM: return37 tr("A turn restriction requires exactly one way with role <tt>from</tt>. "36 case FROM: 37 return 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 <tt>from</tt>. "44 return tr("A turn restriction requires exactly one way with role <tt>to</tt>. " 45 45 + "This turn restriction has {0} ways in this role. Please remove " 46 46 + "{1} of them.",
Note:
See TracChangeset
for help on using the changeset viewer.