Changeset 5954 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2013-05-10T20:09:24+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r5933 r5954 243 243 public final ImageryPreference getImageryPreference() { 244 244 return getSetting(ImageryPreference.class); 245 } 246 247 public final ShortcutPreference getShortcutPreference() { 248 return getSetting(ShortcutPreference.class); 245 249 } 246 250 -
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r5151 r5954 17 17 import java.awt.event.ActionListener; 18 18 import java.awt.event.InputEvent; 19 import java.awt.event.KeyEvent; 19 20 import java.beans.PropertyChangeEvent; 20 21 import java.beans.PropertyChangeListener; … … 61 62 import org.openstreetmap.josm.actions.ActionParameter; 62 63 import org.openstreetmap.josm.actions.AdaptableAction; 64 import org.openstreetmap.josm.actions.JosmAction; 63 65 import org.openstreetmap.josm.actions.ParameterizedAction; 64 66 import org.openstreetmap.josm.actions.ParameterizedActionDecorator; … … 67 69 import org.openstreetmap.josm.tools.GBC; 68 70 import org.openstreetmap.josm.tools.ImageProvider; 71 import org.openstreetmap.josm.tools.Shortcut; 69 72 70 73 public class ToolbarPreferences implements PreferenceSettingFactory { … … 141 144 public static ActionDefinition getSeparator() { 142 145 return new ActionDefinition(null); 146 } 147 148 public boolean hasParameters() { 149 if (!(getAction() instanceof ParameterizedAction)) return false; 150 for (Object o: parameters.values()) { 151 if (o!=null) return true; 152 } 153 return false; 143 154 } 144 155 } … … 295 306 private ActionDefinition currentAction = ActionDefinition.getSeparator(); 296 307 308 @Override 297 309 public int getColumnCount() { 298 310 return 2; 299 311 } 300 312 313 @Override 301 314 public int getRowCount() { 302 315 int adaptable = ((currentAction.getAction() instanceof AdaptableAction) ? 2 : 0); … … 313 326 } 314 327 328 @Override 315 329 public Object getValueAt(int rowIndex, int columnIndex) { 316 330 if(currentAction.getAction() instanceof AdaptableAction) … … 375 389 add(tr("Remove from toolbar",action.getDisplayName())) 376 390 .addActionListener(new ActionListener() { 377 public void actionPerformed(ActionEvent e) {391 @Override public void actionPerformed(ActionEvent e) { 378 392 Collection<String> t = new LinkedList<String>(getToolString()); 379 393 ActionParser parser = new ActionParser(null); … … 389 403 390 404 add(tr("Configure toolbar")).addActionListener(new ActionListener() { 391 public void actionPerformed(ActionEvent e) {405 @Override public void actionPerformed(ActionEvent e) { 392 406 final PreferenceDialog p =new PreferenceDialog(Main.parent); 393 407 p.selectPreferencesTabByName("toolbar"); … … 395 409 } 396 410 }); 397 411 412 add(tr("Edit shortcut")).addActionListener(new ActionListener() { 413 @Override public void actionPerformed(ActionEvent e) { 414 final PreferenceDialog p =new PreferenceDialog(Main.parent); 415 p.getTabbedPane().getShortcutPreference().setDefaultFilter(action.getDisplayName()); 416 p.selectPreferencesTabByName("shortcuts"); 417 p.setVisible(true); 418 // refresh toolbar to accept changes of shortcuts without restart 419 Main.toolbar.refreshToolbarControl(); 420 } 421 }); 398 422 } 399 423 } … … 410 434 public JToolBar control = new JToolBar(); 411 435 436 @Override 412 437 public PreferenceSetting createPreferenceSetting() { 413 438 return new Settings(rootActionsNode); … … 417 442 418 443 private final class Move implements ActionListener { 444 @Override 419 445 public void actionPerformed(ActionEvent e) { 420 446 if (e.getActionCommand().equals("<") && actionsTree.getSelectionCount() > 0) { … … 468 494 } 469 495 496 @Override 470 497 public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { 471 498 return actions; 472 499 } 473 500 501 @Override 474 502 public DataFlavor[] getTransferDataFlavors() { 475 503 return flavors; 476 504 } 477 505 506 @Override 478 507 public boolean isDataFlavorSupported(DataFlavor flavor) { 479 508 return flavors[0] == flavor; … … 528 557 } 529 558 559 @Override 530 560 public void addGui(PreferenceTabbedPane gui) { 531 561 actionsTree.setCellRenderer(new DefaultTreeCellRenderer() { … … 568 598 selectedList.setCellRenderer(renderer); 569 599 selectedList.addListSelectionListener(new ListSelectionListener(){ 600 @Override 570 601 public void valueChanged(ListSelectionEvent e) { 571 602 boolean sel = selectedList.getSelectedIndex() != -1; … … 715 746 actionsTree.setDragEnabled(true); 716 747 actionsTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { 717 public void valueChanged(TreeSelectionEvent e) {748 @Override public void valueChanged(TreeSelectionEvent e) { 718 749 updateEnabledState(); 719 750 } … … 737 768 final JPanel p = new JPanel(); 738 769 p.setLayout(new LayoutManager(){ 770 @Override 739 771 public void addLayoutComponent(String name, Component comp) {} 772 @Override 740 773 public void removeLayoutComponent(Component comp) {} 774 @Override 741 775 public Dimension minimumLayoutSize(Container parent) { 742 776 Dimension l = left.getMinimumSize(); … … 745 779 return new Dimension(l.width+b.width+10+r.width,l.height+b.height+10+r.height); 746 780 } 781 @Override 747 782 public Dimension preferredLayoutSize(Container parent) { 748 783 Dimension l = new Dimension(200, 200); //left.getPreferredSize(); … … 750 785 return new Dimension(l.width+r.width+10+buttons.getPreferredSize().width,Math.max(l.height, r.height)); 751 786 } 787 @Override 752 788 public void layoutContainer(Container parent) { 753 789 Dimension d = p.getSize(); … … 780 816 } 781 817 818 @Override 782 819 public boolean ok() { 783 820 Collection<String> t = new LinkedList<String>(); … … 884 921 885 922 Collection<String> toolStr = Main.pref.getCollection("toolbar", Arrays.asList(deftoolbar)); 886 if (toolStr == null || toolStr. size() == 0) {923 if (toolStr == null || toolStr.isEmpty()) { 887 924 toolStr = Arrays.asList(deftoolbar); 888 925 } … … 947 984 control.addSeparator(); 948 985 } else { 949 final JButton b = control.add(action.getParametrizedAction()); 950 String tt = action.getDisplayTooltip(); 951 if (tt != null && !tt.isEmpty()) 952 b.setToolTipText(tt); 986 final JButton b = addButtonAndShortcut(action); 987 953 988 Icon i = action.getDisplayIcon(); 954 989 if (i != null) { … … 971 1006 control.setVisible(control.getComponentCount() != 0); 972 1007 } 1008 1009 private JButton addButtonAndShortcut(ActionDefinition action) { 1010 Action act = action.getParametrizedAction(); 1011 JButton b = control.add(act); 1012 1013 Shortcut sc = null; 1014 if (action.getAction() instanceof JosmAction) { 1015 sc = ((JosmAction) action.getAction()).getShortcut(); 1016 if (sc.getAssignedKey() == KeyEvent.CHAR_UNDEFINED) sc = null; 1017 } 1018 1019 long paramCode = 0; 1020 if (action.hasParameters()) { 1021 paramCode = action.parameters.hashCode(); 1022 } 1023 1024 String tt = action.getDisplayTooltip(); 1025 if (tt==null) tt=""; 1026 1027 if (sc == null || paramCode != 0) { 1028 String name = (String) action.getAction().getValue("toolbar"); 1029 if (name==null) name=action.getDisplayName(); 1030 if (paramCode!=0) name = name+paramCode; 1031 String desc = action.getDisplayName() + ((paramCode==0)?"":action.parameters.toString()); 1032 sc = Shortcut.registerShortcut("toolbar:"+name, tr("Toolbar: {0}", desc), 1033 KeyEvent.CHAR_UNDEFINED, Shortcut.NONE); 1034 Main.unregisterShortcut(sc); 1035 Main.registerActionShortcut(act, sc); 1036 1037 // add shortcut info to the tooltip if needed 1038 if (sc.getAssignedUser()) { 1039 if (tt.startsWith("<html>") && tt.endsWith("</html>")) { 1040 tt = tt.substring(6,tt.length()-6); 1041 } 1042 tt = Main.platform.makeTooltip(tt, sc); 1043 } 1044 } 1045 1046 if (!tt.isEmpty()) b.setToolTipText(tt); 1047 return b; 1048 } 973 1049 974 1050 private static DataFlavor ACTION_FLAVOR = new DataFlavor( -
trunk/src/org/openstreetmap/josm/gui/preferences/shortcut/PrefJPanel.java
r5886 r5954 147 147 } 148 148 149 /** 150 * Show only shortcuts with descriptions coontaing given substring 151 */ 152 public void filter(String substring) { 153 filterField.setText(substring); 154 } 155 149 156 private class ShortcutTableCellRenderer extends DefaultTableCellRenderer { 150 157 … … 284 291 this.panel = panel; 285 292 } 293 @Override 286 294 public void valueChanged(ListSelectionEvent e) { 287 295 ListSelectionModel lsm = panel.shortcutTable.getSelectionModel(); // can't use e here … … 313 321 } 314 322 } 323 @Override 315 324 public void actionPerformed(java.awt.event.ActionEvent e) { 316 325 ListSelectionModel lsm = panel.shortcutTable.getSelectionModel(); … … 378 387 } 379 388 389 @Override 380 390 public void changedUpdate(DocumentEvent arg0) { filter(); } 391 @Override 381 392 public void insertUpdate(DocumentEvent arg0) { filter(); } 393 @Override 382 394 public void removeUpdate(DocumentEvent arg0) { filter(); } 383 395 } -
trunk/src/org/openstreetmap/josm/gui/preferences/shortcut/ShortcutPreference.java
r5070 r5954 18 18 public class ShortcutPreference extends DefaultTabPreferenceSetting { 19 19 20 private String defaultFilter; 21 20 22 public static class Factory implements PreferenceSettingFactory { 21 23 public PreferenceSetting createPreferenceSetting() { … … 33 35 super("shortcuts", tr("Keyboard Shortcuts"), tr("Changing keyboard shortcuts manually.")); 34 36 } 35 37 38 @Override 36 39 public void addGui(PreferenceTabbedPane gui) { 37 40 JPanel p = gui.createPreferenceTab(this); … … 39 42 PrefJPanel prefpanel = new PrefJPanel(new scListModel()); 40 43 p.add(prefpanel, GBC.eol().fill(GBC.BOTH)); 41 44 if (defaultFilter!=null) prefpanel.filter(defaultFilter); 42 45 } 43 46 47 @Override 44 48 public boolean ok() { 45 49 return Shortcut.savePrefs(); 50 } 51 52 public void setDefaultFilter(String substring) { 53 defaultFilter = substring; 46 54 } 47 55 … … 54 62 data = Shortcut.listAll(); 55 63 } 64 @Override 56 65 public int getColumnCount() { 57 66 return columnNames.length; 58 67 } 68 @Override 59 69 public int getRowCount() { 60 70 return data.size(); … … 64 74 return columnNames[col]; 65 75 } 76 @Override 66 77 public Object getValueAt(int row, int col) { 67 78 return (col==0)? data.get(row).getLongText() : data.get(row); -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetMenu.java
r3710 r5954 5 5 6 6 import java.awt.Component; 7 import java.awt.MouseInfo; 8 import java.awt.Point; 7 9 import java.awt.event.ActionEvent; 8 10 import java.util.ArrayList; … … 14 16 import javax.swing.JPopupMenu; 15 17 import javax.swing.JSeparator; 18 import org.openstreetmap.josm.Main; 16 19 17 20 import org.openstreetmap.josm.tools.PresetTextComparator; … … 57 60 { 58 61 Component co = (Component)s; 62 59 63 JPopupMenu pm = new JPopupMenu(getName()); 60 64 for (Component c : menu.getMenuComponents()) { 61 65 pm.add(copyMenuComponent(c)); 62 66 } 63 pm.show(co, co.getWidth()/2, co.getHeight()/2); 67 Point p = MouseInfo.getPointerInfo().getLocation(); 68 pm.show(Main.parent, p.x-Main.parent.getX(), p.y-Main.parent.getY()); 64 69 } 65 70 }
Note:
See TracChangeset
for help on using the changeset viewer.