Add setting for automatically switching layers

Signed-off-by: Taylor Smock <smocktaylor@gmail.com>
pull/1/head
Taylor Smock 2019-09-28 06:52:16 -06:00
rodzic 8b60962984
commit 108b784900
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 9FDE4FFEF1C4CCB7
3 zmienionych plików z 34 dodań i 2 usunięć

Wyświetl plik

@ -6,6 +6,7 @@ import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
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 JComboBox<String> possibleRapidApiUrl = new JComboBox<>();
private final JLabel switchLayer = new JLabel(tr("Automatically switch layers"));
private final JCheckBox switchLayerCheckBox = new JCheckBox();
@Override
public void addGui(PreferenceTabbedPane gui) {
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.setSelectedItem(RapiDDataUtils.getRapiDURL());
switchLayerCheckBox.setSelected(RapiDDataUtils.getSwitchLayers());
constraints.gridx = 0;
constraints.gridy = 0;
constraints.weightx = .1;
@ -46,7 +52,13 @@ public class RapiDPreferences implements SubPreferenceSetting {
constraints.gridx++;
constraints.weightx = 1;
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);
}
@ -54,6 +66,7 @@ public class RapiDPreferences implements SubPreferenceSetting {
@Override
public boolean ok() {
RapiDDataUtils.setRapiDUrl((String) possibleRapidApiUrl.getSelectedItem());
RapiDDataUtils.setSwitchLayers(switchLayerCheckBox.isSelected());
return false;
}

Wyświetl plik

@ -78,7 +78,7 @@ public class RapiDAddCommand extends Command {
RapiDDataUtils.removePrimitivesFromDataSet(primitives);
rapid.lock();
}
if (editLayer != null) {
if (editLayer != null && RapiDDataUtils.getSwitchLayers()) {
MainApplication.getLayerManager().setActiveLayer(editLayer);
editable.setSelected(
editable.getSelected().stream().filter(OsmPrimitive::isTagged).collect(Collectors.toSet()));

Wyświetl plik

@ -174,6 +174,9 @@ public final class RapiDDataUtils {
new ArrayList<>(Arrays.asList(DEFAULT_RAPID_API)));
}
/**
* Add a paintstyle from the jar (TODO)
*/
public static void addRapiDPaintStyles() {
// TODO figure out how to use the one in the jar file
ExtendedSourceEntry rapid = new ExtendedSourceEntry(SourceType.MAP_PAINT_STYLE, "rapid.mapcss",
@ -186,4 +189,20 @@ public final class RapiDDataUtils {
paintStyles.add(rapid);
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);
}
}