Ignore:
Timestamp:
2017-11-13T06:31:02+01:00 (7 years ago)
Author:
nyuriks
Message:

renamed Wikosm to Sophox, updated URLs

Location:
applications/editors/josm/plugins/wikipedia/src/org/wikipedia
Files:
1 edited
3 moved

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaPlugin.java

    r33635 r33808  
    2828        MainMenu.add(dataMenu, new WikidataItemSearchDialog.Action());
    2929
    30         DownloadDialog.addDownloadSource(new WikosmDownloadSource());
     30        DownloadDialog.addDownloadSource(new SophoxDownloadReader());
    3131    }
    3232
     
    4242    public PreferenceSetting getPreferenceSetting() {
    4343        if (preferences == null) {
    44             preferences = (new WikosmServerPreference.Factory()).createPreferenceSetting();
     44            preferences = (new SophoxServerPreference.Factory()).createPreferenceSetting();
    4545        }
    4646        return preferences;
  • applications/editors/josm/plugins/wikipedia/src/org/wikipedia/gui/SophoxDownloadReader.java

    r33807 r33808  
    3737import org.openstreetmap.josm.tools.ImageProvider;
    3838import org.openstreetmap.josm.tools.OpenBrowser;
    39 import org.wikipedia.io.WikosmDownloadReader;
    4039
    4140/**
    42  * Class defines the way data is fetched from Wikosm API.
     41 * Class defines the way data is fetched from Sophox API.
    4342 */
    44 public class WikosmDownloadSource implements DownloadSource<WikosmDownloadSource.WikosmDownloadData> {
     43public class SophoxDownloadReader implements DownloadSource<SophoxDownloadReader.SophoxDownloadData> {
    4544
    4645    @Override
    47     public AbstractDownloadSourcePanel<WikosmDownloadData> createPanel(DownloadDialog dialog) {
    48         return new WikosmDownloadSourcePanel(this);
     46    public AbstractDownloadSourcePanel<SophoxDownloadData> createPanel(DownloadDialog dialog) {
     47        return new SophoxDownloadSourcePanel(this);
    4948    }
    5049
    5150    @Override
    52     public void doDownload(WikosmDownloadData data, DownloadSettings settings) {
     51    public void doDownload(SophoxDownloadData data, DownloadSettings settings) {
    5352        Bounds area = settings.getDownloadBounds().orElse(new Bounds(0, 0, 0, 0));
    5453        DownloadOsmTask task = new DownloadOsmTask();
    5554        task.setZoomAfterDownload(settings.zoomToData());
    5655        Future<?> future = task.download(
    57                 new WikosmDownloadReader(area, WikosmDownloadReader.WIKOSM_SERVER.get(), data.getQuery(),
     56                new org.wikipedia.io.SophoxDownloadReader(area, org.wikipedia.io.SophoxDownloadReader.SOPHOX_SERVER.get(), data.getQuery(),
    5857                        settings.asNewLayer(), data.getDownloadReferrers(), data.getDownloadFull()),
    5958
     
    6463    @Override
    6564    public String getLabel() {
    66         return tr("Download from Wikosm API");
     65        return tr("Download from Sophox API");
    6766    }
    6867
     
    7372
    7473    /**
    75      * The GUI representation of the Wikosm download source.
     74     * The GUI representation of the Sophox download source.
    7675     */
    77     public static class WikosmDownloadSourcePanel extends AbstractDownloadSourcePanel<WikosmDownloadData> {
     76    public static class SophoxDownloadSourcePanel extends AbstractDownloadSourcePanel<SophoxDownloadData> {
    7877
    7978        private static final String HELP_PAGE = "https://wiki.openstreetmap.org/wiki/Wikidata%2BOSM_SPARQL_query_service";
    80         private static final String SIMPLE_NAME = "wikosmdownloadpanel";
     79        private static final String SIMPLE_NAME = "sophoxdownloadpanel";
    8180        private static final AbstractProperty<Integer> PANEL_SIZE_PROPERTY =
    8281                new IntegerProperty(TAB_SPLIT_NAMESPACE + SIMPLE_NAME, 150).cached();
    83         private static final BooleanProperty WIKOSM_QUERY_LIST_OPENED =
    84                 new BooleanProperty("download.wikosm.query-list.opened", false);
     82        private static final BooleanProperty SOPHOX_QUERY_LIST_OPENED =
     83                new BooleanProperty("download.sophox.query-list.opened", false);
    8584        private static final String ACTION_IMG_SUBDIR = "dialogs";
    8685
    87         private final JosmTextArea wikosmQuery;
    88         private final UserQueryList wikosmQueryList;
     86        private final JosmTextArea sophoxQuery;
     87        private final UserQueryList sophoxQueryList;
    8988        private final JCheckBox referrers;
    9089        private final JCheckBox fullRel;
    9190
    9291        /**
    93          * Create a new {@code WikosmDownloadSourcePanel}
     92         * Create a new {@code SophoxDownloadSourcePanel}
    9493         * @param ds The download source to create the panel for
    9594         */
    96         public WikosmDownloadSourcePanel(WikosmDownloadSource ds) {
     95        public SophoxDownloadSourcePanel(SophoxDownloadReader ds) {
    9796            super(ds);
    9897            setLayout(new BorderLayout());
     
    109108                    "}";
    110109
    111             this.wikosmQuery = new JosmTextArea(queryText, 8, 80);
    112 
    113             this.wikosmQuery.setFont(GuiHelper.getMonospacedFont(wikosmQuery));
    114             this.wikosmQuery.addFocusListener(new FocusListener() {
     110            this.sophoxQuery = new JosmTextArea(queryText, 8, 80);
     111
     112            this.sophoxQuery.setFont(GuiHelper.getMonospacedFont(sophoxQuery));
     113            this.sophoxQuery.addFocusListener(new FocusListener() {
    115114                @Override
    116115                public void focusGained(FocusEvent e) {
    117                     wikosmQuery.selectAll();
     116                    sophoxQuery.selectAll();
    118117                }
    119118
     
    125124
    126125
    127             this.wikosmQueryList = new UserQueryList(this, this.wikosmQuery, "download.wikosm.query");
    128             this.wikosmQueryList.setPreferredSize(new Dimension(350, 300));
     126            this.sophoxQueryList = new UserQueryList(this, this.sophoxQuery, "download.sophox.query");
     127            this.sophoxQueryList.setPreferredSize(new Dimension(350, 300));
    129128
    130129            EditSnippetAction edit = new EditSnippetAction();
    131130            RemoveSnippetAction remove = new RemoveSnippetAction();
    132             this.wikosmQueryList.addSelectionListener(edit);
    133             this.wikosmQueryList.addSelectionListener(remove);
     131            this.sophoxQueryList.addSelectionListener(edit);
     132            this.sophoxQueryList.addSelectionListener(remove);
    134133
    135134            JPanel listPanel = new JPanel(new GridBagLayout());
    136135            listPanel.add(new JLabel(tr("Your saved queries:")), GBC.eol().insets(2).anchor(GBC.CENTER));
    137             listPanel.add(this.wikosmQueryList, GBC.eol().fill(GBC.BOTH));
     136            listPanel.add(this.sophoxQueryList, GBC.eol().fill(GBC.BOTH));
    138137            listPanel.add(new JButton(new AddSnippetAction()), GBC.std().fill(GBC.HORIZONTAL));
    139138            listPanel.add(new JButton(edit), GBC.std().fill(GBC.HORIZONTAL));
    140139            listPanel.add(new JButton(remove), GBC.std().fill(GBC.HORIZONTAL));
    141             listPanel.setVisible(WIKOSM_QUERY_LIST_OPENED.get());
    142 
    143             JScrollPane scrollPane = new JScrollPane(wikosmQuery);
     140            listPanel.setVisible(SOPHOX_QUERY_LIST_OPENED.get());
     141
     142            JScrollPane scrollPane = new JScrollPane(sophoxQuery);
    144143            BasicArrowButton arrowButton = new BasicArrowButton(listPanel.isVisible()
    145144                    ? BasicArrowButton.EAST
    146145                    : BasicArrowButton.WEST);
    147             arrowButton.setToolTipText(tr("Show/hide Wikosm snippet list"));
     146            arrowButton.setToolTipText(tr("Show/hide Sophox snippet list"));
    148147            arrowButton.addActionListener(e -> {
    149148                if (listPanel.isVisible()) {
    150149                    listPanel.setVisible(false);
    151150                    arrowButton.setDirection(BasicArrowButton.WEST);
    152                     WIKOSM_QUERY_LIST_OPENED.put(Boolean.FALSE);
     151                    SOPHOX_QUERY_LIST_OPENED.put(Boolean.FALSE);
    153152                } else {
    154153                    listPanel.setVisible(true);
    155154                    arrowButton.setDirection(BasicArrowButton.EAST);
    156                     WIKOSM_QUERY_LIST_OPENED.put(Boolean.TRUE);
     155                    SOPHOX_QUERY_LIST_OPENED.put(Boolean.TRUE);
    157156                }
    158157            });
     
    165164            referrers.setToolTipText(tr("Select if the referrers of the object should be downloaded as well, i.e.,"
    166165                    + "parent relations and for nodes, additionally, parent ways"));
    167             referrers.setSelected(Main.pref.getBoolean("wikosm.downloadprimitive.referrers", true));
    168             referrers.addActionListener(e -> Main.pref.putBoolean("wikosm.downloadprimitive.referrers", referrers.isSelected()));
     166            referrers.setSelected(Main.pref.getBoolean("sophox.downloadprimitive.referrers", true));
     167            referrers.addActionListener(e -> Main.pref.putBoolean("sophox.downloadprimitive.referrers", referrers.isSelected()));
    169168
    170169            fullRel = new JCheckBox(tr("Download relation members"));
    171170            fullRel.setToolTipText(tr("Select if the members of a relation should be downloaded as well"));
    172             fullRel.setSelected(Main.pref.getBoolean("wikosm.downloadprimitive.full", true));
    173             fullRel.addActionListener(e -> Main.pref.putBoolean("wikosm.downloadprimitive.full", fullRel.isSelected()));
     171            fullRel.setSelected(Main.pref.getBoolean("sophox.downloadprimitive.full", true));
     172            fullRel.addActionListener(e -> Main.pref.putBoolean("sophox.downloadprimitive.full", fullRel.isSelected()));
    174173
    175174            // https://stackoverflow.com/questions/527719/how-to-add-hyperlink-in-jlabel
     
    201200
    202201        @Override
    203         public WikosmDownloadData getData() {
    204             String query = wikosmQuery.getText();
     202        public SophoxDownloadData getData() {
     203            String query = sophoxQuery.getText();
    205204            /*
    206205             * A callback that is passed to PostDownloadReporter that is called once the download task
    207206             * has finished. According to the number of errors happened, their type we decide whether we
    208              * want to save the last query in WikosmQueryList.
     207             * want to save the last query in SophoxQueryList.
    209208             */
    210209            Consumer<Collection<Object>> errorReporter = errors -> {
     
    214213
    215214                if (errors.isEmpty() || onlyNoDataError) {
    216                     wikosmQueryList.saveHistoricItem(query);
     215                    sophoxQueryList.saveHistoricItem(query);
    217216                }
    218217            };
    219218
    220             return new WikosmDownloadData(query, referrers.isSelected(), fullRel.isSelected(), errorReporter);
     219            return new SophoxDownloadData(query, referrers.isSelected(), fullRel.isSelected(), errorReporter);
    221220        }
    222221
     
    236235
    237236            /*
    238              * Absence of the selected area can be justified only if the Wikosm query
     237             * Absence of the selected area can be justified only if the Sophox query
    239238             * is not restricted to bbox.
    240239             */
     
    257256        @Override
    258257        public Icon getIcon() {
    259             return ImageProvider.get(ACTION_IMG_SUBDIR, "wikosm");
     258            return ImageProvider.get(ACTION_IMG_SUBDIR, "sophox");
    260259        }
    261260
     
    286285            @Override
    287286            public void actionPerformed(ActionEvent e) {
    288                 wikosmQueryList.createNewItem();
     287                sophoxQueryList.createNewItem();
    289288            }
    290289        }
     
    307306            @Override
    308307            public void actionPerformed(ActionEvent e) {
    309                 wikosmQueryList.removeSelectedItem();
     308                sophoxQueryList.removeSelectedItem();
    310309            }
    311310
     
    314313             */
    315314            void checkEnabled() {
    316                 setEnabled(wikosmQueryList.getSelectedItem().isPresent());
     315                setEnabled(sophoxQueryList.getSelectedItem().isPresent());
    317316            }
    318317
     
    340339            @Override
    341340            public void actionPerformed(ActionEvent e) {
    342                 wikosmQueryList.editSelectedItem();
     341                sophoxQueryList.editSelectedItem();
    343342            }
    344343
     
    347346             */
    348347            void checkEnabled() {
    349                 setEnabled(wikosmQueryList.getSelectedItem().isPresent());
     348                setEnabled(sophoxQueryList.getSelectedItem().isPresent());
    350349            }
    351350
     
    358357
    359358    /**
    360      * Encapsulates data that is required to preform download from Wikosm API.
     359     * Encapsulates data that is required to preform download from Sophox API.
    361360     */
    362     static class WikosmDownloadData {
     361    static class SophoxDownloadData {
    363362        private final String query;
    364363        private final boolean downloadReferrers;
     
    366365        private final Consumer<Collection<Object>> errorReporter;
    367366
    368         WikosmDownloadData(String query, boolean downloadReferrers, boolean downloadFull, Consumer<Collection<Object>> errorReporter) {
     367        SophoxDownloadData(String query, boolean downloadReferrers, boolean downloadFull, Consumer<Collection<Object>> errorReporter) {
    369368            this.query = query;
    370369            this.downloadReferrers = downloadReferrers;
  • applications/editors/josm/plugins/wikipedia/src/org/wikipedia/gui/SophoxServerPreference.java

    r33807 r33808  
    1818import org.openstreetmap.josm.gui.widgets.HistoryComboBox;
    1919import org.openstreetmap.josm.tools.GBC;
    20 import org.wikipedia.io.WikosmDownloadReader;
     20import org.wikipedia.io.SophoxDownloadReader;
    2121
    2222/**
    23  * Preferences related to Wikosm API servers.
     23 * Preferences related to Sophox API servers.
    2424 */
    25 public class WikosmServerPreference implements SubPreferenceSetting {
     25public class SophoxServerPreference implements SubPreferenceSetting {
    2626
    27     private final HistoryComboBox wikosmServer = new HistoryComboBox();
     27    private final HistoryComboBox SophoxServer = new HistoryComboBox();
    2828
    2929    /**
    30      * Factory used to create a new {@link WikosmServerPreference}.
     30     * Factory used to create a new {@link SophoxServerPreference}.
    3131     */
    3232    public static class Factory implements PreferenceSettingFactory {
    3333        @Override
    3434        public PreferenceSetting createPreferenceSetting() {
    35             return new WikosmServerPreference();
     35            return new SophoxServerPreference();
    3636        }
    3737    }
     
    4848        panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    4949        panel.add(new JLabel(tr("Server: ")), GBC.std().insets(5, 5, 5, 5));
    50         panel.add(wikosmServer, GBC.eop().fill(GBC.HORIZONTAL));
    51         wikosmServer.setPossibleItems(WikosmDownloadReader.WIKOSM_SERVER_HISTORY.get());
    52         wikosmServer.setText(WikosmDownloadReader.WIKOSM_SERVER.get());
     50        panel.add(SophoxServer, GBC.eop().fill(GBC.HORIZONTAL));
     51        SophoxServer.setPossibleItems(SophoxDownloadReader.SOPHOX_SERVER_HISTORY.get());
     52        SophoxServer.setText(SophoxDownloadReader.SOPHOX_SERVER.get());
    5353
    5454        panel.add(Box.createVerticalGlue(), GBC.eol().fill());
     
    5959    @Override
    6060    public boolean ok() {
    61         WikosmDownloadReader.WIKOSM_SERVER.put(wikosmServer.getText());
    62         WikosmDownloadReader.WIKOSM_SERVER_HISTORY.put(wikosmServer.getHistory());
     61        SophoxDownloadReader.SOPHOX_SERVER.put(SophoxServer.getText());
     62        SophoxDownloadReader.SOPHOX_SERVER_HISTORY.put(SophoxServer.getHistory());
    6363        return false;
    6464    }
  • applications/editors/josm/plugins/wikipedia/src/org/wikipedia/io/SophoxDownloadReader.java

    r33807 r33808  
    3636
    3737/**
    38  * Read content from an Wikosm server.
     38 * Read content from an Sophox server.
    3939 */
    40 public class WikosmDownloadReader extends BoundingBoxDownloader {
     40public class SophoxDownloadReader extends BoundingBoxDownloader {
    4141
    4242    /**
    43      * Property for current Wikosm server.
     43     * Property for current Sophox server.
    4444     */
    45     public static final StringProperty WIKOSM_SERVER = new StringProperty("download.wikosm.server",
    46             "http://88.99.164.208/bigdata/namespace/wdq/sparql");
     45    public static final StringProperty SOPHOX_SERVER = new StringProperty("download.sophox.server",
     46            "https://sophox.org/bigdata/namespace/wdq/sparql");
    4747    /**
    48      * Property for list of known Wikosm servers.
     48     * Property for list of known Sophox servers.
    4949     */
    5050// TODO: Core dependency:
    51 //    public static final ListProperty WIKOSM_SERVER_HISTORY = new ListProperty("download.wikosm.servers",
    52 //            Arrays.asList("http://88.99.164.208/bigdata/namespace/wdq/sparql"));
    53     public static final ListProperty WIKOSM_SERVER_HISTORY = new ListProperty("download.wikosm.servers",
    54             Arrays.asList("http://88.99.164.208/bigdata/namespace/wdq/sparql"));
     51//    public static final ListProperty SOPHOX_SERVER_HISTORY = new ListProperty("download.sophox.servers",
     52//            Arrays.asList("https://sophox.org/bigdata/namespace/wdq/sparql"));
     53    public static final ListProperty SOPHOX_SERVER_HISTORY = new ListProperty("download.sophox.servers",
     54            Arrays.asList("https://sophox.org/bigdata/namespace/wdq/sparql"));
    5555
    5656    private static final String DATA_PREFIX = "?query=";
    5757
    58     private final String wikosmServer;
    59     private final String wikosmQuery;
     58    private final String sophoxServer;
     59    private final String sophoxQuery;
    6060    private final boolean asNewLayer;
    6161    private final boolean downloadReferrers;
     
    6363
    6464    /**
    65      * Constructs a new {@code WikosmDownloadReader}.
     65     * Constructs a new {@code SophoxDownloadReader}.
    6666     *
    6767     * @param downloadArea The area to download
    68      * @param wikosmServer The Wikosm server to use
    69      * @param wikosmQuery  The Wikosm query
     68     * @param sophoxServer The Sophox server to use
     69     * @param sophoxQuery  The Sophox query
    7070     */
    71     public WikosmDownloadReader(Bounds downloadArea, String wikosmServer, String wikosmQuery,
     71    public SophoxDownloadReader(Bounds downloadArea, String sophoxServer, String sophoxQuery,
    7272                                boolean asNewLayer, boolean downloadReferrers, boolean downloadFull) {
    7373        super(downloadArea);
    7474        setDoAuthenticate(false);
    75         this.wikosmServer = wikosmServer;
    76         this.wikosmQuery = wikosmQuery.trim();
     75        this.sophoxServer = sophoxServer;
     76        this.sophoxQuery = sophoxQuery.trim();
    7777        this.asNewLayer = asNewLayer;
    7878        this.downloadReferrers = downloadReferrers;
     
    8282    @Override
    8383    protected String getBaseUrl() {
    84         return wikosmServer;
     84        return sophoxServer;
    8585    }
    8686
    8787    @Override
    8888    protected String getRequestForBbox(double lon1, double lat1, double lon2, double lat2) {
    89         final String query = this.wikosmQuery
     89        final String query = this.sophoxQuery
    9090                .replace("{{boxParams}}", boxParams(lon1, lat1, lon2, lat2))
    9191                .replace("{{center}}", center(lon1, lat1, lon2, lat2));
     
    204204    protected void adaptRequest(HttpClient request) {
    205205        // see https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#timeout
    206         final Matcher timeoutMatcher = Pattern.compile("#timeout:(\\d+)").matcher(wikosmQuery);
     206        final Matcher timeoutMatcher = Pattern.compile("#timeout:(\\d+)").matcher(sophoxQuery);
    207207        final int timeout;
    208208        if (timeoutMatcher.find()) {
     
    265265        DataSet ds = super.parseOsm(progressMonitor);
    266266
    267         // add bounds if necessary (note that Wikosm API does not return bounds in the response XML)
    268         if (ds != null && ds.getDataSources().isEmpty() && wikosmQuery.contains("{{boxParams}}")) {
     267        // add bounds if necessary (note that Sophox API does not return bounds in the response XML)
     268        if (ds != null && ds.getDataSources().isEmpty() && sophoxQuery.contains("{{boxParams}}")) {
    269269            if (crosses180th) {
    270270                Bounds bounds = new Bounds(lat1, lon1, lat2, 180.0);
Note: See TracChangeset for help on using the changeset viewer.