Changeset 3327 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2010-06-09T22:14:06+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r3317 r3327 301 301 Object existing = inputMap.get(keyStroke); 302 302 if (existing != null && !existing.equals(action)) { 303 System.out.println(String.format("Keystroke is already assigned to %s, will be overridden by %s", existing, action)); 303 System.out.println(String.format("Keystroke %s is already assigned to %s, will be overridden by %s", keyStroke, existing, action)); 304 304 } 305 305 inputMap.put(keyStroke, action); … … 309 309 310 310 public static void unregisterActionShortcut(Shortcut shortcut) { 311 contentPanePrivate.getInputMap().remove(shortcut.getKeyStroke()); 311 contentPanePrivate.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).remove(shortcut.getKeyStroke()); 312 312 } 313 313 -
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r3251 r3327 72 72 } 73 73 74 public static void autoScale(String mode) { 75 new AutoScaleAction(mode, false).autoScale(); 76 } 77 74 78 private final String mode; 75 79 … … 101 105 return shortcut; 102 106 } 107 108 /** 109 * 110 * @param mode 111 * @param marker Used only to differentiate from default constructor 112 */ 113 private AutoScaleAction(String mode, boolean marker) { 114 super(false); 115 this.mode = mode; 116 } 117 103 118 104 119 public AutoScaleAction(String mode) { -
trunk/src/org/openstreetmap/josm/actions/JosmAction.java
r3252 r3327 82 82 83 83 public JosmAction() { 84 this(true); 85 } 86 87 public JosmAction(boolean installAdapters) { 84 88 setHelpId(); 85 installAdapters(); 89 if (installAdapters) { 90 installAdapters(); 91 } 86 92 } 87 93 -
trunk/src/org/openstreetmap/josm/actions/MoveAction.java
r3262 r3327 2 2 package org.openstreetmap.josm.actions; 3 3 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;6 6 7 7 import java.awt.event.ActionEvent; … … 28 28 29 29 public enum Direction { UP, LEFT, RIGHT, DOWN } 30 30 31 private Direction myDirection; 31 32 … … 63 64 public void actionPerformed(ActionEvent event) { 64 65 66 if (!Main.isDisplayingMapView()) 67 return; 68 65 69 // find out how many "real" units the objects have to be moved in order to 66 70 // achive an 1-pixel movement … … 73 77 74 78 switch (myDirection) { 75 76 77 78 79 80 81 82 83 84 85 86 87 79 case UP: 80 distx = 0; 81 disty = -disty; 82 break; 83 case DOWN: 84 distx = 0; 85 break; 86 case LEFT: 87 disty = 0; 88 distx = -distx; 89 break; 90 default: 91 disty = 0; 88 92 } 89 93 -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r3320 r3327 88 88 private EastNorth currentMouseEastNorth; 89 89 90 private Shortcut extraShortcut; 91 90 92 public DrawAction(MapFrame mapFrame) { 91 93 super(tr("Draw"), "node/autonode", tr("Draw nodes"), … … 94 96 95 97 // Add extra shortcut N 96 Main.registerActionShortcut(this, Shortcut.registerShortcut("mapmode:drawfocus", tr("Mode: Draw Focus"), KeyEvent.VK_N, Shortcut.GROUP_EDIT)); 98 extraShortcut = Shortcut.registerShortcut("mapmode:drawfocus", tr("Mode: Draw Focus"), KeyEvent.VK_N, Shortcut.GROUP_EDIT); 99 Main.registerActionShortcut(this, extraShortcut); 97 100 98 101 cursorCrosshair = getCursor(); … … 241 244 // 242 245 DataSet ds = getCurrentDataSet(); 243 if(ds != null) 246 if(ds != null) { 244 247 ds.fireSelectionChanged(); 248 } 245 249 } 246 250 … … 994 998 setEnabled(getEditLayer() != null); 995 999 } 1000 1001 @Override 1002 public void destroy() { 1003 super.destroy(); 1004 Main.unregisterActionShortcut(extraShortcut); 1005 } 996 1006 } -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r3266 r3327 41 41 import org.openstreetmap.josm.actions.JoinNodeWayAction; 42 42 import org.openstreetmap.josm.actions.JosmAction; 43 import org.openstreetmap.josm.actions.JumpToAction; 43 44 import org.openstreetmap.josm.actions.MergeLayerAction; 44 45 import org.openstreetmap.josm.actions.MergeNodesAction; 45 46 import org.openstreetmap.josm.actions.MergeSelectionAction; 46 47 import org.openstreetmap.josm.actions.MirrorAction; 48 import org.openstreetmap.josm.actions.MoveAction; 47 49 import org.openstreetmap.josm.actions.MoveNodeAction; 48 50 import org.openstreetmap.josm.actions.NewAction; … … 175 177 public final int defaultMenuPos = 5; 176 178 179 public final JosmAction moveUpAction = new MoveAction(MoveAction.Direction.UP); 180 public final JosmAction moveDownAction = new MoveAction(MoveAction.Direction.DOWN); 181 public final JosmAction moveLeftAction = new MoveAction(MoveAction.Direction.LEFT); 182 public final JosmAction moveRightAction = new MoveAction(MoveAction.Direction.RIGHT); 183 public final JumpToAction jumpToAct = new JumpToAction(); 184 185 177 186 /** 178 187 * Add a JosmAction to a menu. -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r3177 r3327 17 17 import java.awt.Toolkit; 18 18 import java.awt.event.AWTEventListener; 19 import java.awt.event.ComponentEvent;20 19 import java.awt.event.InputEvent; 21 20 import java.awt.event.KeyAdapter; … … 39 38 40 39 import org.openstreetmap.josm.Main; 41 import org.openstreetmap.josm.actions.JumpToAction;42 40 import org.openstreetmap.josm.data.coor.CoordinateFormat; 43 41 import org.openstreetmap.josm.data.coor.LatLon; … … 504 502 private AWTEventListener awtListener = new AWTEventListener() { 505 503 public void eventDispatched(AWTEvent event) { 506 if (event instanceof ComponentEvent &&507 (( ComponentEvent)event).getComponent() == mv) {504 if (event instanceof InputEvent && 505 ((InputEvent)event).getComponent() == mv) { 508 506 synchronized (collector) { 509 507 mouseState.modifiers = ((InputEvent)event).getModifiersEx(); … … 575 573 this.collector = new Collector(mapFrame); 576 574 577 JumpToAction JumpToAct = new JumpToAction(); 578 lonText.addMouseListener(JumpToAct); 579 latText.addMouseListener(JumpToAct); 575 lonText.addMouseListener(Main.main.menu.jumpToAct); 576 latText.addMouseListener(Main.main.menu.jumpToAct); 580 577 581 578 // Listen for mouse movements and set the position text field -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r3252 r3327 34 34 import org.openstreetmap.josm.Main; 35 35 import org.openstreetmap.josm.actions.AutoScaleAction; 36 import org.openstreetmap.josm.actions.MoveAction;37 36 import org.openstreetmap.josm.actions.mapmode.MapMode; 38 37 import org.openstreetmap.josm.data.Bounds; … … 190 189 public MapView(final JPanel contentPane) { 191 190 Main.pref.addPreferenceChangeListener(this); 191 192 // new MoveAction(MoveAction.Direction.UP); 193 // new MoveAction(MoveAction.Direction.DOWN); 194 // new MoveAction(MoveAction.Direction.LEFT); 195 // new MoveAction(MoveAction.Direction.RIGHT); 196 192 197 addComponentListener(new ComponentAdapter(){ 193 198 @Override public void componentResized(ComponentEvent e) { … … 206 211 if (!zoomToDataSetBoundingBox(layer.data)) { 207 212 // no bounding box defined 208 newAutoScaleAction("data").actionPerformed(null);213 AutoScaleAction.autoScale("data"); 209 214 } 210 215 } else { 211 newAutoScaleAction("layer").actionPerformed(null);216 AutoScaleAction.autoScale("layer"); 212 217 } 213 218 214 219 new MapMover(MapView.this, contentPane); 215 new MoveAction(MoveAction.Direction.UP);216 new MoveAction(MoveAction.Direction.DOWN);217 new MoveAction(MoveAction.Direction.LEFT);218 new MoveAction(MoveAction.Direction.RIGHT);219 220 } 220 221 }); -
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r3290 r3327 294 294 * Launches the search dialog 295 295 */ 296 class SearchAction extends AbstractAction implements EditLayerChangeListener { 296 static class SearchAction extends AbstractAction implements EditLayerChangeListener { 297 297 public SearchAction() { 298 298 putValue(NAME, tr("Search")); … … 358 358 359 359 public void actionPerformed(ActionEvent e) { 360 newAutoScaleAction("selection").autoScale();360 AutoScaleAction.autoScale("selection"); 361 361 } 362 362 … … 423 423 } 424 424 425 @Override 425 426 public void actionPerformed(ActionEvent e) { 426 427 Relation relation = (Relation)model.getSelected().toArray()[0]; … … 428 429 Collection<OsmPrimitive> selection = model.getAllElements(); 429 430 for (RelationMember member: relation.getMembers()) { 430 if (selection.contains(member.getMember())) 431 if (selection.contains(member.getMember())) { 431 432 members.add(member); 433 } 432 434 } 433 435 Main.map.relationListDialog.selectRelation(relation); 434 436 RelationEditor.getEditor(Main.map.mapView.getEditLayer(), relation, 435 members).setVisible(true); 437 members).setVisible(true); 436 438 } 437 439 } … … 801 803 { 802 804 text.append(": "); 803 for(OsmPrimitive o : sel) 804 text.append(o.getDisplayName(df)); 805 for(OsmPrimitive o : sel) { 806 text.append(o.getDisplayName(df)); 807 } 805 808 setText(text.toString()); 806 } 807 else 809 } else { 808 810 setText(tr("Selection: {0}", text)); 811 } 809 812 addActionListener(this); 810 813 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r3306 r3327 51 51 import javax.swing.table.DefaultTableCellRenderer; 52 52 import javax.swing.table.DefaultTableModel; 53 import javax.swing.table.TableColumnModel; 53 54 import javax.swing.table.TableModel; 54 import javax.swing.table.TableColumnModel;55 55 import javax.swing.text.JTextComponent; 56 56 … … 157 157 158 158 private DataSetListenerAdapter dataChangedAdapter = new DataSetListenerAdapter(this); 159 private AddAction addAction = new AddAction(); 160 private Shortcut addActionShortcut = Shortcut.registerShortcut("properties:add", tr("Add Properties"), KeyEvent.VK_B, 161 Shortcut.GROUP_MNEMONIC); 159 162 160 163 @Override … … 164 167 MapView.addEditLayerChangeListener(this); 165 168 updateSelection(); 169 Main.registerActionShortcut(addAction, addActionShortcut); 166 170 } 167 171 … … 171 175 SelectionEventManager.getInstance().removeSelectionListener(this); 172 176 MapView.removeEditLayerChangeListener(this); 177 Main.unregisterActionShortcut(addActionShortcut); 173 178 } 174 179 … … 331 336 * @param row 332 337 */ 333 @SuppressWarnings("unchecked")334 338 void membershipEdit(int row) { 335 339 Relation relation = (Relation)membershipData.getValueAt(row, 0); … … 474 478 + tr("Please select the objects you want to change properties for.") + "</p></html>"); 475 479 476 class MemberInfo { 480 static class MemberInfo { 477 481 List<RelationMember> role = new ArrayList<RelationMember>(); 478 482 List<Integer> position = new ArrayList<Integer>(); … … 480 484 void add(RelationMember r, Integer p) 481 485 { 482 role.add(r); 483 position.add(p); 486 role.add(r); 487 position.add(p); 484 488 } 485 489 String getPositionString() … … 496 500 ++cnt; 497 501 } else { 498 if(cnt == 1) 502 if(cnt == 1) { 499 503 positionString += ","+String.valueOf(last); 500 else if(cnt > 1) 504 } else if(cnt > 1) { 501 505 positionString += "-"+String.valueOf(last); 506 } 502 507 positionString += "-"+String.valueOf(cur); 503 508 cnt = 0; … … 505 510 last = cur; 506 511 } 507 if(cnt == 1) 512 if(cnt == 1) { 508 513 positionString += ","+String.valueOf(last); 509 else if(cnt > 1) 514 } else if(cnt > 1) { 510 515 positionString += "-"+String.valueOf(last); 511 } 512 if(positionString.length() > 20) 513 positionString = positionString.substring(0,17)+"..."; 516 } 517 } 518 if(positionString.length() > 20) { 519 positionString = positionString.substring(0,17)+"..."; 520 } 514 521 return positionString; 515 522 } … … 589 596 590 597 mod.getColumn(1).setCellRenderer(new DefaultTableCellRenderer() { 591 @SuppressWarnings("unchecked")592 598 @Override public Component getTableCellRendererComponent(JTable table, Object value, 593 599 boolean isSelected, boolean hasFocus, int row, int column) { … … 619 625 620 626 mod.getColumn(2).setCellRenderer(new DefaultTableCellRenderer() { 621 @SuppressWarnings("unchecked")622 627 @Override public Component getTableCellRendererComponent(JTable table, Object value, 623 628 boolean isSelected, boolean hasFocus, int row, int column) { … … 667 672 668 673 // -- add action and shortcut 669 AddAction addAction = new AddAction();670 674 this.btnAdd = new SideButton(addAction); 671 675 btnAdd.setFocusable(true); … … 673 677 btnAdd.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "onEnter"); 674 678 btnAdd.getActionMap().put("onEnter", addAction); 675 676 Main.registerActionShortcut(addAction, Shortcut.registerShortcut("properties:add", tr("Add Properties"), KeyEvent.VK_B,677 Shortcut.GROUP_MNEMONIC));678 679 679 680 // -- edit action … … 873 874 Relation r = (Relation) ref; 874 875 MemberInfo mi = roles.get(r); 875 if(mi == null) 876 if(mi == null) { 876 877 mi = new MemberInfo(); 878 } 877 879 roles.put(r, mi); 878 880 int i = 1; -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java
r3210 r3327 203 203 OsmPrimitive primitive = getMemberTableModel().getReferredPrimitive(row); 204 204 layer.data.setSelected(primitive); 205 AutoScaleAction action = new AutoScaleAction("selection"); 206 action.autoScale(); 205 AutoScaleAction.autoScale("selection"); 207 206 } 208 207 -
trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java
r3083 r3327 203 203 if (p!= null) { 204 204 getEditLayer().data.setSelected(p.getPrimitiveId()); 205 newAutoScaleAction("selection").autoScale();205 AutoScaleAction.autoScale("selection"); 206 206 } 207 207 } -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r3321 r3327 829 829 if (data == null) 830 830 return null; 831 OsmDataLayer layer = Main.main.getEditLayer();832 831 PresetPanel p = new PresetPanel(); 833 832 LinkedList<Item> l = new LinkedList<Item>();
Note:
See TracChangeset
for help on using the changeset viewer.