kopia lustrzana https://github.com/JOSM/MapWithAI
Add setting for automatically switching layers
Signed-off-by: Taylor Smock <smocktaylor@gmail.com>pull/1/head
rodzic
8b60962984
commit
108b784900
|
@ -6,6 +6,7 @@ import java.awt.GridBagConstraints;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
@ -20,6 +21,9 @@ public class RapiDPreferences implements SubPreferenceSetting {
|
||||||
private final JLabel rapidApiUrl = new JLabel(tr("RapiD API URL"));
|
private final JLabel rapidApiUrl = new JLabel(tr("RapiD API URL"));
|
||||||
private final JComboBox<String> possibleRapidApiUrl = new JComboBox<>();
|
private final JComboBox<String> possibleRapidApiUrl = new JComboBox<>();
|
||||||
|
|
||||||
|
private final JLabel switchLayer = new JLabel(tr("Automatically switch layers"));
|
||||||
|
private final JCheckBox switchLayerCheckBox = new JCheckBox();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addGui(PreferenceTabbedPane gui) {
|
public void addGui(PreferenceTabbedPane gui) {
|
||||||
final JPanel container = new JPanel(new GridBagLayout());
|
final JPanel container = new JPanel(new GridBagLayout());
|
||||||
|
@ -34,6 +38,8 @@ public class RapiDPreferences implements SubPreferenceSetting {
|
||||||
possibleRapidApiUrl.setPrototypeDisplayValue("https://example.url/some/end/point");
|
possibleRapidApiUrl.setPrototypeDisplayValue("https://example.url/some/end/point");
|
||||||
possibleRapidApiUrl.setSelectedItem(RapiDDataUtils.getRapiDURL());
|
possibleRapidApiUrl.setSelectedItem(RapiDDataUtils.getRapiDURL());
|
||||||
|
|
||||||
|
switchLayerCheckBox.setSelected(RapiDDataUtils.getSwitchLayers());
|
||||||
|
|
||||||
constraints.gridx = 0;
|
constraints.gridx = 0;
|
||||||
constraints.gridy = 0;
|
constraints.gridy = 0;
|
||||||
constraints.weightx = .1;
|
constraints.weightx = .1;
|
||||||
|
@ -46,7 +52,13 @@ public class RapiDPreferences implements SubPreferenceSetting {
|
||||||
constraints.gridx++;
|
constraints.gridx++;
|
||||||
constraints.weightx = 1;
|
constraints.weightx = 1;
|
||||||
container.add(possibleRapidApiUrl, constraints);
|
container.add(possibleRapidApiUrl, constraints);
|
||||||
gui.getMaximumSize().getWidth();
|
|
||||||
|
constraints.gridx--;
|
||||||
|
constraints.gridy++;
|
||||||
|
container.add(switchLayer, constraints);
|
||||||
|
|
||||||
|
constraints.gridx++;
|
||||||
|
container.add(switchLayerCheckBox, constraints);
|
||||||
|
|
||||||
getTabPreferenceSetting(gui).addSubTab(this, "RapiD", container);
|
getTabPreferenceSetting(gui).addSubTab(this, "RapiD", container);
|
||||||
}
|
}
|
||||||
|
@ -54,6 +66,7 @@ public class RapiDPreferences implements SubPreferenceSetting {
|
||||||
@Override
|
@Override
|
||||||
public boolean ok() {
|
public boolean ok() {
|
||||||
RapiDDataUtils.setRapiDUrl((String) possibleRapidApiUrl.getSelectedItem());
|
RapiDDataUtils.setRapiDUrl((String) possibleRapidApiUrl.getSelectedItem());
|
||||||
|
RapiDDataUtils.setSwitchLayers(switchLayerCheckBox.isSelected());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class RapiDAddCommand extends Command {
|
||||||
RapiDDataUtils.removePrimitivesFromDataSet(primitives);
|
RapiDDataUtils.removePrimitivesFromDataSet(primitives);
|
||||||
rapid.lock();
|
rapid.lock();
|
||||||
}
|
}
|
||||||
if (editLayer != null) {
|
if (editLayer != null && RapiDDataUtils.getSwitchLayers()) {
|
||||||
MainApplication.getLayerManager().setActiveLayer(editLayer);
|
MainApplication.getLayerManager().setActiveLayer(editLayer);
|
||||||
editable.setSelected(
|
editable.setSelected(
|
||||||
editable.getSelected().stream().filter(OsmPrimitive::isTagged).collect(Collectors.toSet()));
|
editable.getSelected().stream().filter(OsmPrimitive::isTagged).collect(Collectors.toSet()));
|
||||||
|
|
|
@ -174,6 +174,9 @@ public final class RapiDDataUtils {
|
||||||
new ArrayList<>(Arrays.asList(DEFAULT_RAPID_API)));
|
new ArrayList<>(Arrays.asList(DEFAULT_RAPID_API)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a paintstyle from the jar (TODO)
|
||||||
|
*/
|
||||||
public static void addRapiDPaintStyles() {
|
public static void addRapiDPaintStyles() {
|
||||||
// TODO figure out how to use the one in the jar file
|
// TODO figure out how to use the one in the jar file
|
||||||
ExtendedSourceEntry rapid = new ExtendedSourceEntry(SourceType.MAP_PAINT_STYLE, "rapid.mapcss",
|
ExtendedSourceEntry rapid = new ExtendedSourceEntry(SourceType.MAP_PAINT_STYLE, "rapid.mapcss",
|
||||||
|
@ -186,4 +189,20 @@ public final class RapiDDataUtils {
|
||||||
paintStyles.add(rapid);
|
paintStyles.add(rapid);
|
||||||
MapPaintPrefHelper.INSTANCE.put(paintStyles);
|
MapPaintPrefHelper.INSTANCE.put(paintStyles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether or not a we switch from the RapiD layer to an OSM data layer
|
||||||
|
*
|
||||||
|
* @param selected true if we are going to switch layers
|
||||||
|
*/
|
||||||
|
public static void setSwitchLayers(boolean selected) {
|
||||||
|
Config.getPref().putBoolean(RapiDPlugin.NAME.concat(".autoswitchlayers"), selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@code true} if we want to automatically switch layers
|
||||||
|
*/
|
||||||
|
public static boolean getSwitchLayers() {
|
||||||
|
return Config.getPref().getBoolean(RapiDPlugin.NAME.concat(".autoswitchlayers"), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue