kopia lustrzana https://github.com/JOSM/MapWithAI
Have a somewhat intuitive fallback for adding data (alt+c) since shift+a is taken by a JOSM core command (changes the active data layer)
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
4216672381
commit
c3fba444fa
|
@ -4,9 +4,11 @@ import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
|
||||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.InputEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
@ -31,14 +33,28 @@ public class MapWithAIMoveAction extends JosmAction {
|
||||||
|
|
||||||
public MapWithAIMoveAction() {
|
public MapWithAIMoveAction() {
|
||||||
super(tr("{0}: Add selected data", MapWithAIPlugin.NAME), null, tr("Add data from {0}", MapWithAIPlugin.NAME),
|
super(tr("{0}: Add selected data", MapWithAIPlugin.NAME), null, tr("Add data from {0}", MapWithAIPlugin.NAME),
|
||||||
Shortcut.registerShortcut(
|
obtainShortcut(), true);
|
||||||
"data:mapwithaiadd", tr("{0}: {1}", MapWithAIPlugin.NAME, tr("Add selected data")),
|
|
||||||
KeyEvent.VK_A,
|
|
||||||
Shortcut.SHIFT),
|
|
||||||
true);
|
|
||||||
setHelpId(ht("Plugin/MapWithAI#BasicUsage"));
|
setHelpId(ht("Plugin/MapWithAI#BasicUsage"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The default shortcut, if available, or an alternate shortcut that
|
||||||
|
* makes sense otherwise
|
||||||
|
*/
|
||||||
|
private static Shortcut obtainShortcut() {
|
||||||
|
int key = KeyEvent.VK_A;
|
||||||
|
int modifier = Shortcut.SHIFT;
|
||||||
|
String shortText = "data:mapwithaiadd";
|
||||||
|
Optional<Shortcut> shortCut = Shortcut.findShortcut(key, InputEvent.SHIFT_DOWN_MASK); // Shortcut.SHIFT maps to
|
||||||
|
// KeyEvent.SHIFT_DOWN_MASK
|
||||||
|
if (shortCut.isPresent() && !shortText.equals(shortCut.get().getShortText())) {
|
||||||
|
key = KeyEvent.VK_C;
|
||||||
|
modifier = Shortcut.ALT;
|
||||||
|
}
|
||||||
|
return Shortcut.registerShortcut(shortText, tr("{0}: {1}", MapWithAIPlugin.NAME, tr("Add selected data")), key,
|
||||||
|
modifier);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
for (final MapWithAILayer mapWithAI : MainApplication.getLayerManager().getLayersOfType(MapWithAILayer.class)) {
|
for (final MapWithAILayer mapWithAI : MainApplication.getLayerManager().getLayersOfType(MapWithAILayer.class)) {
|
||||||
|
|
Ładowanie…
Reference in New Issue