Ignore:
Timestamp:
2017-09-18T07:11:12+02:00 (7 years ago)
Author:
nyuriks
Message:

Better SPARQL example, added help link

File:
1 edited

Legend:

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

    r33626 r33628  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.awt.BorderLayout;
    7 import java.awt.Dimension;
    8 import java.awt.GridBagLayout;
     6import java.awt.*;
    97import java.awt.event.ActionEvent;
    108import java.awt.event.FocusEvent;
     
    3634import org.openstreetmap.josm.tools.GBC;
    3735import org.openstreetmap.josm.tools.ImageProvider;
     36import org.openstreetmap.josm.tools.OpenBrowser;
    3837import org.wikipedia.io.WikosmDownloadReader;
    3938
     
    7675    public static class WikosmDownloadSourcePanel extends AbstractDownloadSourcePanel<WikosmDownloadData> {
    7776
     77        private static final String HELP_PAGE = "https://wiki.openstreetmap.org/wiki/Wikidata%2BOSM_SPARQL_query_service";
    7878        private static final String SIMPLE_NAME = "wikosmdownloadpanel";
    7979        private static final AbstractProperty<Integer> PANEL_SIZE_PROPERTY =
     
    9696            setLayout(new BorderLayout());
    9797
    98             // CHECKSTYLE.OFF: LineLength
    99             this.wikosmQuery = new JosmTextArea(
    100                     "# " + tr("Enter your Wikosm SPARQL query below") + "\n"
    101                             + "SELECT ?osmId ?loc WHERE { BIND(osmnode:2681940767 as ?osmId). ?osmId osmm:loc ?loc . }",
    102                     8, 80);
    103             // CHECKSTYLE.ON: LineLength
     98            String queryText = "# " +
     99                    tr("Find places of education at least 2km, and at most 3km from the center of the selection") +
     100                    "\n" +
     101                    "SELECT ?osmid WHERE {\n" +
     102                    "  VALUES ?amenity { \"kindergarten\" \"school\" \"university\" \"college\" }\n" +
     103                    "  ?osmid osmt:amenity ?amenity ;\n" +
     104                    "         osmm:loc ?location .\n" +
     105                    "  BIND(geof:distance({{center}}, ?location) as ?distance)\n" +
     106                    "  FILTER(?distance > 2 && ?distance < 3)\n" +
     107                    "}";
     108
     109            this.wikosmQuery = new JosmTextArea(queryText, 8, 80);
     110
    104111            this.wikosmQuery.setFont(GuiHelper.getMonospacedFont(wikosmQuery));
    105112            this.wikosmQuery.addFocusListener(new FocusListener() {
     
    149156            });
    150157
     158            // TODO: Once new core is widely avialable, replace:
     159            //   Main.pref.getBoolean --> Config.getPref().getBoolean
     160            //   Main.pref.put --> Config.getPref().putBoolean
    151161
    152162            referrers = new JCheckBox(tr("Download referrers (parent relations)"));
    153163            referrers.setToolTipText(tr("Select if the referrers of the object should be downloaded as well, i.e.,"
    154164                    + "parent relations and for nodes, additionally, parent ways"));
    155 
    156             // TODO: Once new core is widely avialable, replace:
    157             //   Main.pref.getBoolean --> Config.getPref().getBoolean
    158             //   Main.pref.put --> Config.getPref().putBoolean
    159 
    160165            referrers.setSelected(Main.pref.getBoolean("wikosm.downloadprimitive.referrers", true));
    161166            referrers.addActionListener(e -> Main.pref.put("wikosm.downloadprimitive.referrers", referrers.isSelected()));
     
    166171            fullRel.addActionListener(e -> Main.pref.put("wikosm.downloadprimitive.full", fullRel.isSelected()));
    167172
     173            // https://stackoverflow.com/questions/527719/how-to-add-hyperlink-in-jlabel
     174            JButton helpLink = new JButton();
     175            helpLink.setText("<HTML><FONT color=\"#000099\"><U>"+tr("help")+"</U></FONT></HTML>");
     176            helpLink.setToolTipText(HELP_PAGE);
     177            helpLink.setHorizontalAlignment(SwingConstants.LEFT);
     178            helpLink.setBorderPainted(false);
     179            helpLink.setOpaque(false);
     180            helpLink.setBackground(Color.WHITE);
     181            helpLink.addActionListener(e -> OpenBrowser.displayUrl(HELP_PAGE));
     182
    168183            JPanel centerPanel = new JPanel(new GridBagLayout());
    169184            centerPanel.add(scrollPane, GBC.eol().fill(GBC.BOTH));
    170185            centerPanel.add(referrers, GBC.std().anchor(GBC.WEST).insets(5, 5, 5, 5));
    171186            centerPanel.add(fullRel, GBC.std().anchor(GBC.WEST).insets(15, 5, 5, 5));
     187            centerPanel.add(helpLink, GBC.std().anchor(GBC.WEST).insets(10, 5, 5, 5));
    172188
    173189
Note: See TracChangeset for help on using the changeset viewer.