kopia lustrzana https://github.com/JOSM/MapWithAI
Add TOS and Privacy policy for default servers
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
b043714ee5
commit
fc98ca9747
|
@ -3,6 +3,7 @@ package org.openstreetmap.josm.plugins.mapwithai;
|
||||||
|
|
||||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
@ -25,6 +26,7 @@ import javax.swing.JCheckBox;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JSeparator;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
import javax.swing.SpinnerNumberModel;
|
import javax.swing.SpinnerNumberModel;
|
||||||
|
|
||||||
|
@ -33,6 +35,8 @@ import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
|
||||||
import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
|
import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
|
||||||
import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
|
import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
|
||||||
import org.openstreetmap.josm.gui.preferences.advanced.PrefEntry;
|
import org.openstreetmap.josm.gui.preferences.advanced.PrefEntry;
|
||||||
|
import org.openstreetmap.josm.gui.widgets.JosmTextField;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.backend.DataAvailability;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIPreferenceHelper;
|
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIPreferenceHelper;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.backend.commands.conflation.DataUrl;
|
import org.openstreetmap.josm.plugins.mapwithai.backend.commands.conflation.DataUrl;
|
||||||
import org.openstreetmap.josm.spi.preferences.StringSetting;
|
import org.openstreetmap.josm.spi.preferences.StringSetting;
|
||||||
|
@ -201,6 +205,8 @@ public class MapWithAIPreferences implements SubPreferenceSetting {
|
||||||
|
|
||||||
pane.add(Box.createHorizontalGlue(), second);
|
pane.add(Box.createHorizontalGlue(), second);
|
||||||
|
|
||||||
|
legalInformation(pane);
|
||||||
|
|
||||||
JButton kaartLogo = new JButton(ImageProvider.getIfAvailable("kaart") == null ? null
|
JButton kaartLogo = new JButton(ImageProvider.getIfAvailable("kaart") == null ? null
|
||||||
: new ImageProvider("kaart").setHeight(ImageProvider.ImageSizes.SETTINGS_TAB.getAdjustedHeight())
|
: new ImageProvider("kaart").setHeight(ImageProvider.ImageSizes.SETTINGS_TAB.getAdjustedHeight())
|
||||||
.get());
|
.get());
|
||||||
|
@ -229,7 +235,7 @@ 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, new JScrollPane(pane),
|
||||||
tr("{0} preferences", MapWithAIPlugin.NAME));
|
tr("{0} preferences", MapWithAIPlugin.NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,4 +298,50 @@ public class MapWithAIPreferences implements SubPreferenceSetting {
|
||||||
public JSpinner getMaximumAdditionSpinner() {
|
public JSpinner getMaximumAdditionSpinner() {
|
||||||
return maximumAdditionSpinner;
|
return maximumAdditionSpinner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get legal information for sources with special handling
|
||||||
|
*
|
||||||
|
* @param pane A pane to directly add the terms of use/privacy panels to
|
||||||
|
* @return A scroll pane with sources
|
||||||
|
*/
|
||||||
|
public JScrollPane legalInformation(JPanel pane) {
|
||||||
|
GBC line = GBC.eol().fill(GBC.HORIZONTAL);
|
||||||
|
JPanel termsOfUse = new JPanel(new GridBagLayout());
|
||||||
|
termsOfUse.add(new JLabel(tr("Server Terms Of Use")), line);
|
||||||
|
DataAvailability.getTermsOfUse().stream().map(MapWithAIPreferences::convertUrlToTextWithAction)
|
||||||
|
.forEach(urlObj -> termsOfUse.add(urlObj, line));
|
||||||
|
JPanel privacy = new JPanel(new GridBagLayout());
|
||||||
|
privacy.add(new JLabel(tr("Server Privacy Policy")), line);
|
||||||
|
DataAvailability.getPrivacyPolicy().stream().map(MapWithAIPreferences::convertUrlToTextWithAction)
|
||||||
|
.forEach(urlObj -> privacy.add(urlObj, line));
|
||||||
|
|
||||||
|
JScrollPane scroll = new JScrollPane();
|
||||||
|
scroll.add(termsOfUse, line);
|
||||||
|
scroll.add(privacy, line);
|
||||||
|
scroll.setMinimumSize(new Dimension(0, 60));
|
||||||
|
if (pane != null) {
|
||||||
|
pane.add(new JSeparator(), line);
|
||||||
|
pane.add(new JLabel(tr("Default Provider Legal Information")), line);
|
||||||
|
pane.add(termsOfUse, line);
|
||||||
|
pane.add(privacy, line);
|
||||||
|
pane.add(new JSeparator(), line);
|
||||||
|
}
|
||||||
|
return scroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static JosmTextField convertUrlToTextWithAction(String url) {
|
||||||
|
JosmTextField field = new JosmTextField();
|
||||||
|
field.setEditable(false);
|
||||||
|
field.setText(url);
|
||||||
|
field.setForeground(Color.BLUE);
|
||||||
|
field.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||||
|
field.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
OpenBrowser.displayUrl(url);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return field;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -25,6 +26,7 @@ import org.openstreetmap.josm.io.CachedFile;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.backend.commands.conflation.DataUrl;
|
import org.openstreetmap.josm.plugins.mapwithai.backend.commands.conflation.DataUrl;
|
||||||
import org.openstreetmap.josm.tools.Logging;
|
import org.openstreetmap.josm.tools.Logging;
|
||||||
import org.openstreetmap.josm.tools.Territories;
|
import org.openstreetmap.josm.tools.Territories;
|
||||||
|
import org.openstreetmap.josm.tools.Utils;
|
||||||
|
|
||||||
public class DataAvailability {
|
public class DataAvailability {
|
||||||
/** This points to a list of default sources that can be used with MapWithAI */
|
/** This points to a list of default sources that can be used with MapWithAI */
|
||||||
|
@ -244,4 +246,56 @@ public class DataAvailability {
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Terms Of Use Url
|
||||||
|
*
|
||||||
|
* @return The url or ""
|
||||||
|
*/
|
||||||
|
public String getTermsOfUseUrl() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Terms Of Use Url
|
||||||
|
*
|
||||||
|
* @return The url or ""
|
||||||
|
*/
|
||||||
|
public String getPrivacyPolicyUrl() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the terms of use for all specially handled URL's
|
||||||
|
*
|
||||||
|
* @return List of terms of use urls
|
||||||
|
*/
|
||||||
|
public static final List<String> getTermsOfUse() {
|
||||||
|
return DATA_SOURCES.stream().map(clazz -> {
|
||||||
|
try {
|
||||||
|
return clazz.getConstructor().newInstance().getTermsOfUseUrl();
|
||||||
|
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
|
||||||
|
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||||
|
Logging.debug(e);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}).filter(Objects::nonNull).filter(str -> !Utils.removeWhiteSpaces(str).isEmpty()).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the privacy policy for all specially handled URL's
|
||||||
|
*
|
||||||
|
* @return List of privacy policy urls
|
||||||
|
*/
|
||||||
|
public static final List<String> getPrivacyPolicy() {
|
||||||
|
return DATA_SOURCES.stream().map(clazz -> {
|
||||||
|
try {
|
||||||
|
return clazz.getConstructor().newInstance().getPrivacyPolicyUrl();
|
||||||
|
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
|
||||||
|
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||||
|
Logging.debug(e);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}).filter(Objects::nonNull).filter(str -> !Utils.removeWhiteSpaces(str).isEmpty()).collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,4 +141,14 @@ public final class MapWithAIAvailability extends DataAvailability {
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return MapWithAIPreferenceHelper.DEFAULT_MAPWITHAI_API;
|
return MapWithAIPreferenceHelper.DEFAULT_MAPWITHAI_API;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTermsOfUseUrl() {
|
||||||
|
return "https://mapwith.ai/doc/license/MapWithAILicense.pdf";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrivacyPolicyUrl() {
|
||||||
|
return "https://mapwith.ai/doc/license/MapWithAIPrivacyPolicy.pdf#page=3";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue