Changeset 3502 in josm for trunk/src/org
- Timestamp:
- 2010-08-31T12:37:51+02:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r3470 r3502 24 24 import javax.swing.AbstractAction; 25 25 import javax.swing.BorderFactory; 26 import javax.swing.ComponentInputMap;27 26 import javax.swing.ImageIcon; 28 import javax.swing.InputMap;29 27 import javax.swing.JButton; 30 28 import javax.swing.JComponent; … … 33 31 import javax.swing.JOptionPane; 34 32 import javax.swing.JPanel; 35 import javax.swing.KeyStroke;36 33 37 34 import org.openstreetmap.josm.Main; … … 40 37 import org.openstreetmap.josm.gui.help.HelpUtil; 41 38 import org.openstreetmap.josm.gui.help.Helpful; 39 import org.openstreetmap.josm.gui.util.RedirectInputMap; 42 40 import org.openstreetmap.josm.tools.GBC; 43 41 import org.openstreetmap.josm.tools.ImageProvider; … … 49 47 */ 50 48 public class ToggleDialog extends JPanel implements Helpful { 51 52 // It's not possible to simply set component input map parent to be Main.contentPane.getInputMap because53 // there is check in setParent that InputMap is for the same component54 // Yes, this is a hack55 // Another possibility would be simply copy InputMap, but that would require to keep copies synchronized when some shortcut is56 // later57 private static class RedirectInputMap extends ComponentInputMap {58 59 private final InputMap target;60 61 public RedirectInputMap(JComponent component, InputMap target) {62 super(component);63 this.target = target;64 }65 66 @Override67 public Object get(KeyStroke keyStroke) {68 return target.get(keyStroke);69 }70 71 @Override72 public KeyStroke[] keys() {73 return target.keys();74 }75 76 @Override77 public int size() {78 return target.size();79 }80 81 @Override82 public KeyStroke[] allKeys() {83 return target.allKeys();84 }85 86 @Override87 public void put(KeyStroke keyStroke, Object actionMapKey) {88 throw new UnsupportedOperationException();89 }90 91 @Override92 public void remove(KeyStroke key) {93 throw new UnsupportedOperationException();94 }95 96 @Override97 public void clear() {98 throw new UnsupportedOperationException();99 }100 101 }102 49 103 50 /** The action to toggle this dialog */ … … 152 99 * @param defShow if the dialog should be shown by default, if there is no preference 153 100 */ 154 @SuppressWarnings("deprecation")155 101 public ToggleDialog(String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight, boolean defShow) { 156 102 super(new BorderLayout()); … … 180 126 isCollapsed = Main.pref.getBoolean(preferencePrefix+".minimized", false); 181 127 182 InputMap lastParent = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); 183 while (lastParent.getParent() != null) { 184 lastParent = lastParent.getParent(); 185 } 186 lastParent.setParent(new RedirectInputMap(this, Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW))); 187 getActionMap().setParent(Main.contentPane.getActionMap()); 128 RedirectInputMap.redirectToMainContentPane(this); 188 129 } 189 130 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r3440 r3502 72 72 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField; 73 73 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; 74 import org.openstreetmap.josm.gui.util.RedirectInputMap; 74 75 import org.openstreetmap.josm.tools.ImageProvider; 75 76 import org.openstreetmap.josm.tools.Shortcut; … … 185 186 memberTableModel.setSelectedMembers(selectedMembers); 186 187 HelpUtil.setHelpContext(getRootPane(),ht("/Dialog/RelationEditor")); 188 RedirectInputMap.redirectToMainContentPane(getRootPane()); 187 189 } 188 190
Note:
See TracChangeset
for help on using the changeset viewer.