kopia lustrzana https://github.com/JOSM/MapWithAI
Add icons to everything that can have an icon
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head v0.2.0
rodzic
744490d0ed
commit
b72da6c6c3
|
@ -63,23 +63,22 @@ public class MapWithAIPreferences implements SubPreferenceSetting {
|
||||||
private static void fillReplacementTagDisplayData(List<PrefEntry> list) {
|
private static void fillReplacementTagDisplayData(List<PrefEntry> list) {
|
||||||
final Map<String, String> current = new TreeMap<>(MapWithAIPreferenceHelper.getReplacementTags());
|
final Map<String, String> current = new TreeMap<>(MapWithAIPreferenceHelper.getReplacementTags());
|
||||||
for (final Entry<String, String> entry : current.entrySet()) {
|
for (final Entry<String, String> entry : current.entrySet()) {
|
||||||
list.add(new PrefEntry(entry.getKey(), new StringSetting(entry.getValue()), new StringSetting(null), false));
|
list.add(
|
||||||
|
new PrefEntry(entry.getKey(), new StringSetting(entry.getValue()), new StringSetting(null), false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void fillMapWithAIURLTableDisplayData(List<DataUrl> list) {
|
private static void fillMapWithAIURLTableDisplayData(List<DataUrl> list) {
|
||||||
MapWithAIPreferenceHelper.getMapWithAIURLs()
|
MapWithAIPreferenceHelper.getMapWithAIURLs()
|
||||||
.forEach(
|
.forEach(entry -> list.add(new DataUrl(entry.get(SOURCE), entry.get("url"),
|
||||||
entry -> list
|
|
||||||
.add(new DataUrl(entry.get(SOURCE), entry.get("url"),
|
|
||||||
Boolean.valueOf(entry.getOrDefault("enabled", "false")),
|
Boolean.valueOf(entry.getOrDefault("enabled", "false")),
|
||||||
entry.getOrDefault("parameters", "[]"))));
|
entry.getOrDefault("parameters", "[]"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addGui(PreferenceTabbedPane gui) {
|
public void addGui(PreferenceTabbedPane gui) {
|
||||||
int width = 200;
|
final int width = 200;
|
||||||
int height = 200;
|
final int height = 200;
|
||||||
final JLabel mapWithAIApiUrl = new JLabel(tr("{0} API URLs", MapWithAIPlugin.NAME));
|
final JLabel mapWithAIApiUrl = new JLabel(tr("{0} API URLs", MapWithAIPlugin.NAME));
|
||||||
final JLabel switchLayer = new JLabel(tr("Automatically switch layers"));
|
final JLabel switchLayer = new JLabel(tr("Automatically switch layers"));
|
||||||
final JLabel maximumAddition = new JLabel(tr("Maximum features (add)"));
|
final JLabel maximumAddition = new JLabel(tr("Maximum features (add)"));
|
||||||
|
@ -104,9 +103,9 @@ public class MapWithAIPreferences implements SubPreferenceSetting {
|
||||||
pane.setAlignmentY(Component.TOP_ALIGNMENT);
|
pane.setAlignmentY(Component.TOP_ALIGNMENT);
|
||||||
pane.setAlignmentX(Component.LEFT_ALIGNMENT);
|
pane.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||||
|
|
||||||
GBC first = GBC.std().weight(0, 1).anchor(GridBagConstraints.WEST);
|
final GBC first = GBC.std().weight(0, 1).anchor(GridBagConstraints.WEST);
|
||||||
GBC second = GBC.eol().fill(GridBagConstraints.HORIZONTAL);
|
final GBC second = GBC.eol().fill(GridBagConstraints.HORIZONTAL);
|
||||||
GBC buttonInsets = GBC.std().insets(5, 5, 0, 0);
|
final GBC buttonInsets = GBC.std().insets(5, 5, 0, 0);
|
||||||
|
|
||||||
pane.add(mapWithAIApiUrl, first);
|
pane.add(mapWithAIApiUrl, first);
|
||||||
|
|
||||||
|
@ -116,7 +115,7 @@ public class MapWithAIPreferences implements SubPreferenceSetting {
|
||||||
scroll1.setPreferredSize(new Dimension(width, height));
|
scroll1.setPreferredSize(new Dimension(width, height));
|
||||||
|
|
||||||
pane.add(new JLabel(), first);
|
pane.add(new JLabel(), first);
|
||||||
JPanel replaceAddEditDeleteScroll1 = new JPanel(new GridBagLayout());
|
final JPanel replaceAddEditDeleteScroll1 = new JPanel(new GridBagLayout());
|
||||||
pane.add(replaceAddEditDeleteScroll1, second);
|
pane.add(replaceAddEditDeleteScroll1, second);
|
||||||
final JButton addScroll1 = new JButton(tr("Add"));
|
final JButton addScroll1 = new JButton(tr("Add"));
|
||||||
replaceAddEditDeleteScroll1.add(addScroll1, buttonInsets);
|
replaceAddEditDeleteScroll1.add(addScroll1, buttonInsets);
|
||||||
|
@ -135,7 +134,7 @@ public class MapWithAIPreferences implements SubPreferenceSetting {
|
||||||
final JButton deleteScroll1 = new JButton(tr("Delete"));
|
final JButton deleteScroll1 = new JButton(tr("Delete"));
|
||||||
replaceAddEditDeleteScroll1.add(deleteScroll1, buttonInsets);
|
replaceAddEditDeleteScroll1.add(deleteScroll1, buttonInsets);
|
||||||
deleteScroll1.addActionListener(e -> {
|
deleteScroll1.addActionListener(e -> {
|
||||||
List<DataUrl> toRemove = mapwithaiUrlPreferenceTable.getSelectedItems();
|
final List<DataUrl> toRemove = mapwithaiUrlPreferenceTable.getSelectedItems();
|
||||||
if (!toRemove.isEmpty()) {
|
if (!toRemove.isEmpty()) {
|
||||||
mapwithaiurlTableDisplayData.removeAll(toRemove);
|
mapwithaiurlTableDisplayData.removeAll(toRemove);
|
||||||
}
|
}
|
||||||
|
@ -163,13 +162,13 @@ public class MapWithAIPreferences implements SubPreferenceSetting {
|
||||||
scroll2.setPreferredSize(new Dimension(width, height));
|
scroll2.setPreferredSize(new Dimension(width, height));
|
||||||
|
|
||||||
pane.add(new JLabel(), first);
|
pane.add(new JLabel(), first);
|
||||||
JPanel replaceAddEditDeleteScroll2 = new JPanel(new GridBagLayout());
|
final JPanel replaceAddEditDeleteScroll2 = new JPanel(new GridBagLayout());
|
||||||
pane.add(replaceAddEditDeleteScroll2, second);
|
pane.add(replaceAddEditDeleteScroll2, second);
|
||||||
final JButton addScroll2 = new JButton(tr("Add"));
|
final JButton addScroll2 = new JButton(tr("Add"));
|
||||||
replaceAddEditDeleteScroll2.add(addScroll2, buttonInsets);
|
replaceAddEditDeleteScroll2.add(addScroll2, buttonInsets);
|
||||||
addScroll2.addActionListener(e -> {
|
addScroll2.addActionListener(e -> {
|
||||||
final PrefEntry pe = replacementPreferenceTable.addPreference(gui);
|
final PrefEntry pe = replacementPreferenceTable.addPreference(gui);
|
||||||
if (pe != null && pe.getValue() instanceof StringSetting) {
|
if ((pe != null) && (pe.getValue() instanceof StringSetting)) {
|
||||||
replacementTableDisplayData.add(pe);
|
replacementTableDisplayData.add(pe);
|
||||||
Collections.sort(replacementTableDisplayData);
|
Collections.sort(replacementTableDisplayData);
|
||||||
replacementPreferenceTable.fireDataChanged();
|
replacementPreferenceTable.fireDataChanged();
|
||||||
|
@ -196,18 +195,19 @@ public class MapWithAIPreferences implements SubPreferenceSetting {
|
||||||
});
|
});
|
||||||
|
|
||||||
Arrays.asList(replaceAddEditDeleteScroll2, scroll2, expertHorizontalGlue, replacementTags)
|
Arrays.asList(replaceAddEditDeleteScroll2, scroll2, expertHorizontalGlue, replacementTags)
|
||||||
.forEach(ExpertToggleAction::addVisibilitySwitcher);
|
.forEach(ExpertToggleAction::addVisibilitySwitcher);
|
||||||
|
|
||||||
getTabPreferenceSetting(gui).addSubTab(this, MapWithAIPlugin.NAME, pane);
|
getTabPreferenceSetting(gui).addSubTab(this, MapWithAIPlugin.NAME, pane,
|
||||||
|
tr("{0} preferences", MapWithAIPlugin.NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean ok() {
|
public boolean ok() {
|
||||||
ArrayList<DataUrl> tData = new ArrayList<>(
|
final ArrayList<DataUrl> tData = new ArrayList<>(
|
||||||
mapwithaiurlTableDisplayData.stream().distinct()
|
mapwithaiurlTableDisplayData.stream().distinct()
|
||||||
.filter(data -> !data.getMap().getOrDefault("url", "http://example.com")
|
.filter(data -> !data.getMap().getOrDefault("url", "http://example.com")
|
||||||
.equalsIgnoreCase(DataUrl.emptyData().getMap().get("url")))
|
.equalsIgnoreCase(DataUrl.emptyData().getMap().get("url")))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
mapwithaiurlTableDisplayData.clear();
|
mapwithaiurlTableDisplayData.clear();
|
||||||
mapwithaiurlTableDisplayData.addAll(tData);
|
mapwithaiurlTableDisplayData.addAll(tData);
|
||||||
MapWithAIPreferenceHelper.setMapWithAIURLs(convertUrlPrefToMap(mapwithaiurlTableDisplayData));
|
MapWithAIPreferenceHelper.setMapWithAIURLs(convertUrlPrefToMap(mapwithaiurlTableDisplayData));
|
||||||
|
|
|
@ -27,15 +27,14 @@ import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
||||||
import org.openstreetmap.josm.tools.Shortcut;
|
import org.openstreetmap.josm.tools.Shortcut;
|
||||||
|
|
||||||
|
|
||||||
public class MapWithAIAction extends JosmAction {
|
public class MapWithAIAction extends JosmAction {
|
||||||
/** UID */
|
/** UID */
|
||||||
private static final long serialVersionUID = 8886705479253246588L;
|
private static final long serialVersionUID = 8886705479253246588L;
|
||||||
|
|
||||||
public MapWithAIAction() {
|
public MapWithAIAction() {
|
||||||
super(tr("{0}: Download data", MapWithAIPlugin.NAME), null, tr("Get data from {0}", MapWithAIPlugin.NAME),
|
super(tr("{0}: Download data", MapWithAIPlugin.NAME), "mapwithai",
|
||||||
Shortcut.registerShortcut("data:mapWithAI", tr("Data: {0}", MapWithAIPlugin.NAME), KeyEvent.VK_R,
|
tr("Get data from {0}", MapWithAIPlugin.NAME), Shortcut.registerShortcut("data:mapWithAI",
|
||||||
Shortcut.CTRL),
|
tr("Data: {0}", MapWithAIPlugin.NAME), KeyEvent.VK_R, Shortcut.CTRL),
|
||||||
true);
|
true);
|
||||||
setHelpId(ht("Plugin/MapWithAI#BasicUsage"));
|
setHelpId(ht("Plugin/MapWithAI#BasicUsage"));
|
||||||
}
|
}
|
||||||
|
@ -48,12 +47,12 @@ public class MapWithAIAction extends JosmAction {
|
||||||
.stream().filter(layer -> !(layer instanceof MapWithAILayer)).filter(Layer::isVisible)
|
.stream().filter(layer -> !(layer instanceof MapWithAILayer)).filter(Layer::isVisible)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
final OsmDataLayer layer = getOsmLayer(osmLayers);
|
final OsmDataLayer layer = getOsmLayer(osmLayers);
|
||||||
if (layer != null && MapWithAIDataUtils.getMapWithAIData(MapWithAIDataUtils.getLayer(true), layer)) {
|
if ((layer != null) && MapWithAIDataUtils.getMapWithAIData(MapWithAIDataUtils.getLayer(true), layer)) {
|
||||||
Notification notification = createMessageDialog();
|
final Notification notification = createMessageDialog();
|
||||||
if (notification != null) {
|
if (notification != null) {
|
||||||
notification.show();
|
notification.show();
|
||||||
}
|
}
|
||||||
} else if (layer != null && hasLayer) {
|
} else if ((layer != null) && hasLayer) {
|
||||||
toggleLayer(layer);
|
toggleLayer(layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,9 +87,9 @@ public class MapWithAIAction extends JosmAction {
|
||||||
final OsmDataLayer mapwithai = MapWithAIDataUtils.getLayer(false);
|
final OsmDataLayer mapwithai = MapWithAIDataUtils.getLayer(false);
|
||||||
final Layer currentLayer = MainApplication.getLayerManager().getActiveLayer();
|
final Layer currentLayer = MainApplication.getLayerManager().getActiveLayer();
|
||||||
if (currentLayer != null) {
|
if (currentLayer != null) {
|
||||||
if (currentLayer.equals(mapwithai) && toLayer != null) {
|
if (currentLayer.equals(mapwithai) && (toLayer != null)) {
|
||||||
MainApplication.getLayerManager().setActiveLayer(toLayer);
|
MainApplication.getLayerManager().setActiveLayer(toLayer);
|
||||||
} else if (currentLayer.equals(toLayer) && mapwithai != null) {
|
} else if (currentLayer.equals(toLayer) && (mapwithai != null)) {
|
||||||
MainApplication.getLayerManager().setActiveLayer(mapwithai);
|
MainApplication.getLayerManager().setActiveLayer(mapwithai);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,8 +113,8 @@ public class MapWithAIAction extends JosmAction {
|
||||||
final List<Bounds> bounds = new ArrayList<>(layer.getDataSet().getDataSourceBounds());
|
final List<Bounds> bounds = new ArrayList<>(layer.getDataSet().getDataSourceBounds());
|
||||||
if (bounds.isEmpty()) {
|
if (bounds.isEmpty()) {
|
||||||
MainApplication.getLayerManager().getLayersOfType(OsmDataLayer.class).stream()
|
MainApplication.getLayerManager().getLayersOfType(OsmDataLayer.class).stream()
|
||||||
.map(OsmDataLayer::getDataSet).filter(Objects::nonNull).map(DataSet::getDataSourceBounds)
|
.map(OsmDataLayer::getDataSet).filter(Objects::nonNull).map(DataSet::getDataSourceBounds)
|
||||||
.forEach(bounds::addAll);
|
.forEach(bounds::addAll);
|
||||||
}
|
}
|
||||||
final StringBuilder message = new StringBuilder();
|
final StringBuilder message = new StringBuilder();
|
||||||
message.append(MapWithAIPlugin.NAME).append(": ");
|
message.append(MapWithAIPlugin.NAME).append(": ");
|
||||||
|
@ -123,7 +122,7 @@ public class MapWithAIAction extends JosmAction {
|
||||||
final Map<String, Boolean> availableTypes = new TreeMap<>();
|
final Map<String, Boolean> availableTypes = new TreeMap<>();
|
||||||
for (final Bounds bound : bounds) {
|
for (final Bounds bound : bounds) {
|
||||||
availability.getDataTypes(bound.getCenter())
|
availability.getDataTypes(bound.getCenter())
|
||||||
.forEach((type, available) -> availableTypes.merge(type, available, Boolean::logicalOr));
|
.forEach((type, available) -> availableTypes.merge(type, available, Boolean::logicalOr));
|
||||||
}
|
}
|
||||||
final List<String> types = availableTypes.entrySet().stream().filter(Entry::getValue)
|
final List<String> types = availableTypes.entrySet().stream().filter(Entry::getValue)
|
||||||
.map(entry -> MapWithAIAvailability.getPossibleDataTypesAndMessages().get(entry.getKey()))
|
.map(entry -> MapWithAIAvailability.getPossibleDataTypesAndMessages().get(entry.getKey()))
|
||||||
|
|
|
@ -48,10 +48,11 @@ public class MapWithAIArbitraryAction extends JosmAction {
|
||||||
private static final String ARBITRARY_DATA_STRING = tr("Get arbitrary data from {0}", MapWithAIPlugin.NAME);
|
private static final String ARBITRARY_DATA_STRING = tr("Get arbitrary data from {0}", MapWithAIPlugin.NAME);
|
||||||
|
|
||||||
public MapWithAIArbitraryAction() {
|
public MapWithAIArbitraryAction() {
|
||||||
super(tr("{0}: Download arbitrary data", MapWithAIPlugin.NAME), null, tr(ARBITRARY_DATA_STRING),
|
super(tr("{0}: Download arbitrary data", MapWithAIPlugin.NAME), "mapwithai", tr(ARBITRARY_DATA_STRING),
|
||||||
Shortcut.registerShortcut("data:arbitrarymapwithai",
|
Shortcut.registerShortcut("data:arbitrarymapwithai",
|
||||||
tr("Data: Arbitrary {0} Data", tr(ARBITRARY_DATA_STRING)), KeyEvent.VK_R,
|
tr("Data: Arbitrary {0} Data", tr(ARBITRARY_DATA_STRING)), KeyEvent.VK_R,
|
||||||
Shortcut.ALT_CTRL_SHIFT), true);
|
Shortcut.ALT_CTRL_SHIFT),
|
||||||
|
true);
|
||||||
setHelpId(ht("Plugin/MapWithAI#BasicUsage"));
|
setHelpId(ht("Plugin/MapWithAI#BasicUsage"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +118,7 @@ public class MapWithAIArbitraryAction extends JosmAction {
|
||||||
bbox = new BBox();
|
bbox = new BBox();
|
||||||
bbox.add(new LatLon(Double.parseDouble(lowerLat.getText()), Double.parseDouble(leftLon.getText())));
|
bbox.add(new LatLon(Double.parseDouble(lowerLat.getText()), Double.parseDouble(leftLon.getText())));
|
||||||
bbox.add(new LatLon(Double.parseDouble(upperLat.getText()), Double.parseDouble(rightLon.getText())));
|
bbox.add(new LatLon(Double.parseDouble(upperLat.getText()), Double.parseDouble(rightLon.getText())));
|
||||||
} catch (NumberFormatException e) {
|
} catch (final NumberFormatException e) {
|
||||||
JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
|
JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
|
||||||
tr("Could not parse Latitude or Longitude. Please check."), tr("Unable to parse Lon/Lat"),
|
tr("Could not parse Latitude or Longitude. Please check."), tr("Unable to parse Lon/Lat"),
|
||||||
JOptionPane.ERROR_MESSAGE);
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
@ -126,8 +127,9 @@ public class MapWithAIArbitraryAction extends JosmAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkbox.isSelected()) {
|
if (checkbox.isSelected()) {
|
||||||
MainApplication.getLayerManager().addLayer(new GpxLayer(
|
MainApplication.getLayerManager()
|
||||||
DetectTaskingManagerUtils.createTaskingManagerGpxData(bbox), DetectTaskingManagerUtils.MAPWITHAI_CROP_AREA));
|
.addLayer(new GpxLayer(DetectTaskingManagerUtils.createTaskingManagerGpxData(bbox),
|
||||||
|
DetectTaskingManagerUtils.MAPWITHAI_CROP_AREA));
|
||||||
}
|
}
|
||||||
|
|
||||||
MapWithAIDataUtils.getMapWithAIData(MapWithAIDataUtils.getLayer(true), bbox);
|
MapWithAIDataUtils.getMapWithAIData(MapWithAIDataUtils.getLayer(true), bbox);
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
|
@ -27,6 +28,7 @@ import org.openstreetmap.josm.gui.mappaint.StyleSource;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
||||||
import org.openstreetmap.josm.spi.preferences.Config;
|
import org.openstreetmap.josm.spi.preferences.Config;
|
||||||
import org.openstreetmap.josm.tools.GBC;
|
import org.openstreetmap.josm.tools.GBC;
|
||||||
|
import org.openstreetmap.josm.tools.ImageProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Taylor Smock
|
* @author Taylor Smock
|
||||||
|
@ -145,7 +147,7 @@ public class MapWithAILayer extends OsmDataLayer implements ActiveLayerChangeLis
|
||||||
@Override
|
@Override
|
||||||
public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
|
public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
|
||||||
if (checkIfToggleLayer()) {
|
if (checkIfToggleLayer()) {
|
||||||
StyleSource style = MapWithAIDataUtils.getMapWithAIPaintStyle();
|
final StyleSource style = MapWithAIDataUtils.getMapWithAIPaintStyle();
|
||||||
if (style.active != this.equals(MainApplication.getLayerManager().getActiveLayer())) {
|
if (style.active != this.equals(MainApplication.getLayerManager().getActiveLayer())) {
|
||||||
MapPaintStyles.toggleStyleActive(MapPaintStyles.getStyles().getStyleSources().indexOf(style));
|
MapPaintStyles.toggleStyleActive(MapPaintStyles.getStyles().getStyleSources().indexOf(style));
|
||||||
}
|
}
|
||||||
|
@ -153,7 +155,7 @@ public class MapWithAILayer extends OsmDataLayer implements ActiveLayerChangeLis
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean checkIfToggleLayer() {
|
private static boolean checkIfToggleLayer() {
|
||||||
List<String> keys = Config.getPref().getKeySet().parallelStream()
|
final List<String> keys = Config.getPref().getKeySet().parallelStream()
|
||||||
.filter(string -> string.contains(MapWithAIPlugin.NAME) && string.contains("boolean:toggle_with_layer"))
|
.filter(string -> string.contains(MapWithAIPlugin.NAME) && string.contains("boolean:toggle_with_layer"))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
boolean toggle = false;
|
boolean toggle = false;
|
||||||
|
@ -168,4 +170,9 @@ public class MapWithAILayer extends OsmDataLayer implements ActiveLayerChangeLis
|
||||||
super.destroy();
|
super.destroy();
|
||||||
MainApplication.getLayerManager().removeActiveLayerChangeListener(this);
|
MainApplication.getLayerManager().removeActiveLayerChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ImageIcon getIcon() {
|
||||||
|
return ImageProvider.get("mapwithai", ImageProvider.ImageSizes.LAYER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,8 @@ public class MapWithAIMoveAction extends JosmAction {
|
||||||
private transient Notification lastNotification;
|
private transient Notification lastNotification;
|
||||||
|
|
||||||
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), "mapwithai",
|
||||||
obtainShortcut(), true);
|
tr("Add data from {0}", MapWithAIPlugin.NAME), obtainShortcut(), true);
|
||||||
setHelpId(ht("Plugin/MapWithAI#BasicUsage"));
|
setHelpId(ht("Plugin/MapWithAI#BasicUsage"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,9 +44,10 @@ public class MapWithAIMoveAction extends JosmAction {
|
||||||
private static Shortcut obtainShortcut() {
|
private static Shortcut obtainShortcut() {
|
||||||
int key = KeyEvent.VK_A;
|
int key = KeyEvent.VK_A;
|
||||||
int modifier = Shortcut.SHIFT;
|
int modifier = Shortcut.SHIFT;
|
||||||
String shortText = "data:mapwithaiadd";
|
final String shortText = "data:mapwithaiadd";
|
||||||
Optional<Shortcut> shortCut = Shortcut.findShortcut(key, InputEvent.SHIFT_DOWN_MASK); // Shortcut.SHIFT maps to
|
final Optional<Shortcut> shortCut = Shortcut.findShortcut(key, InputEvent.SHIFT_DOWN_MASK); // Shortcut.SHIFT
|
||||||
// KeyEvent.SHIFT_DOWN_MASK
|
// maps to
|
||||||
|
// KeyEvent.SHIFT_DOWN_MASK
|
||||||
if (shortCut.isPresent() && !shortText.equals(shortCut.get().getShortText())) {
|
if (shortCut.isPresent() && !shortText.equals(shortCut.get().getShortText())) {
|
||||||
key = KeyEvent.VK_C;
|
key = KeyEvent.VK_C;
|
||||||
modifier = Shortcut.ALT;
|
modifier = Shortcut.ALT;
|
||||||
|
@ -94,7 +95,7 @@ public class MapWithAIMoveAction extends JosmAction {
|
||||||
final Notification notification = new Notification();
|
final Notification notification = new Notification();
|
||||||
final StringBuilder message = new StringBuilder();
|
final StringBuilder message = new StringBuilder();
|
||||||
message.append(MapWithAIPlugin.NAME).append(": ").append(tr("maximum additions per action are "))
|
message.append(MapWithAIPlugin.NAME).append(": ").append(tr("maximum additions per action are "))
|
||||||
.append(maxAddition).append(", ").append(tr("tried to add ")).append(triedToAdd).append('.');
|
.append(maxAddition).append(", ").append(tr("tried to add ")).append(triedToAdd).append('.');
|
||||||
notification.setContent(message.toString());
|
notification.setContent(message.toString());
|
||||||
notification.setDuration(Notification.TIME_DEFAULT);
|
notification.setDuration(Notification.TIME_DEFAULT);
|
||||||
notification.setIcon(JOptionPane.INFORMATION_MESSAGE);
|
notification.setIcon(JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
@ -112,7 +113,7 @@ public class MapWithAIMoveAction extends JosmAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
|
protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
|
||||||
if (selection == null || selection.isEmpty()) {
|
if ((selection == null) || selection.isEmpty()) {
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
setEnabled(checkIfActionEnabled());
|
setEnabled(checkIfActionEnabled());
|
||||||
|
@ -125,7 +126,7 @@ public class MapWithAIMoveAction extends JosmAction {
|
||||||
if (active instanceof MapWithAILayer) {
|
if (active instanceof MapWithAILayer) {
|
||||||
final MapWithAILayer mapWithAILayer = (MapWithAILayer) active;
|
final MapWithAILayer mapWithAILayer = (MapWithAILayer) active;
|
||||||
final Collection<OsmPrimitive> selection = mapWithAILayer.getDataSet().getAllSelected();
|
final Collection<OsmPrimitive> selection = mapWithAILayer.getDataSet().getAllSelected();
|
||||||
returnValue = selection != null && !selection.isEmpty();
|
returnValue = (selection != null) && !selection.isEmpty();
|
||||||
}
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,8 @@ public class MergeDuplicateWaysAction extends JosmAction {
|
||||||
private static final String DESCRIPTION = "Attempt to merge potential duplicate ways";
|
private static final String DESCRIPTION = "Attempt to merge potential duplicate ways";
|
||||||
|
|
||||||
public MergeDuplicateWaysAction() {
|
public MergeDuplicateWaysAction() {
|
||||||
super(tr("{0}: ".concat(DESCRIPTION), MapWithAIPlugin.NAME), null, tr(DESCRIPTION),
|
super(tr("{0}: ".concat(DESCRIPTION), MapWithAIPlugin.NAME), "mapwithai", tr(DESCRIPTION),
|
||||||
Shortcut.registerShortcut("data:attemptmergeway",
|
Shortcut.registerShortcut("data:attemptmergeway", tr(DESCRIPTION), KeyEvent.VK_EXCLAMATION_MARK,
|
||||||
tr(DESCRIPTION), KeyEvent.VK_EXCLAMATION_MARK,
|
|
||||||
Shortcut.ALT_CTRL_SHIFT),
|
Shortcut.ALT_CTRL_SHIFT),
|
||||||
true);
|
true);
|
||||||
setHelpId(ht("Plugin/MapWithAI"));
|
setHelpId(ht("Plugin/MapWithAI"));
|
||||||
|
@ -37,7 +36,8 @@ public class MergeDuplicateWaysAction extends JosmAction {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (MainApplication.getLayerManager().getActiveDataSet() != null) {
|
if (MainApplication.getLayerManager().getActiveDataSet() != null) {
|
||||||
final List<Way> ways = new ArrayList<>(MainApplication.getLayerManager().getActiveDataSet().getSelectedWays());
|
final List<Way> ways = new ArrayList<>(
|
||||||
|
MainApplication.getLayerManager().getActiveDataSet().getSelectedWays());
|
||||||
Command command = null;
|
Command command = null;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
do {
|
do {
|
||||||
|
@ -52,7 +52,7 @@ public class MergeDuplicateWaysAction extends JosmAction {
|
||||||
UndoRedoHandler.getInstance().add(command);
|
UndoRedoHandler.getInstance().add(command);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
} while (command != null && i < 1);
|
} while ((command != null) && (i < 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue