Changeset 28114 in osm for applications/editors/josm/plugins/opendata/src/org
- Timestamp:
- 2012-03-19T00:45:17+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/AskLicenseAgreementDialog.java
r28113 r28114 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.awt.Dimension;6 import java.awt.event.ActionEvent;7 5 import java.io.IOException; 8 6 9 import javax.swing.Icon; 10 import javax.swing.JEditorPane; 11 import javax.swing.JOptionPane; 12 import javax.swing.JScrollPane; 7 import org.openstreetmap.josm.Main; 8 import org.openstreetmap.josm.plugins.opendata.core.licenses.License; 13 9 14 import org.openstreetmap.josm.Main; 15 import org.openstreetmap.josm.gui.ExtendedDialog; 16 import org.openstreetmap.josm.plugins.opendata.core.licenses.License; 17 import org.openstreetmap.josm.tools.ImageProvider; 18 19 public class AskLicenseAgreementDialog extends ExtendedDialog { 20 21 private final License license; 22 private final JEditorPane htmlPane; 23 private boolean summary; 10 public class AskLicenseAgreementDialog extends ViewLicenseDialog { 24 11 25 12 public AskLicenseAgreementDialog(License license) throws IOException { 26 super( Main.parent, tr("License Agreement"), new String[] {tr("Accept"), "", tr("Refuse")});13 super(license, Main.parent, tr("License Agreement"), new String[] {tr("Accept"), "", tr("Refuse")}); 27 14 28 this.license = license;29 this.htmlPane = new JEditorPane();30 //htmlPane.setEditorKitForContentType(pdfEditorKit.getContentType(), pdfEditorKit);31 htmlPane.setEditable(false);32 if (license.getSummaryURL() != null) {33 htmlPane.setPage(license.getSummaryURL());34 summary = true;35 } else {36 htmlPane.setPage(license.getURL());37 summary = false;38 }39 JScrollPane scrollPane = new JScrollPane(htmlPane);40 scrollPane.setPreferredSize(new Dimension(800, 600));41 42 setButtonIcons(new Icon[] {43 ImageProvider.get("ok"),44 ImageProvider.get("agreement24"),45 ImageProvider.get("cancel"),46 });47 15 setToolTipTexts(new String[] { 48 16 tr("I understand and accept these terms and conditions"), 49 17 tr("View the full text of this license"), 50 18 tr("I refuse these terms and conditions. Cancel download.")}); 51 if (license.getIcon() != null) {52 setIcon(license.getIcon());53 } else {54 setIcon(JOptionPane.INFORMATION_MESSAGE);55 }56 setCancelButton(3);57 setMinimumSize(new Dimension(300, 200));58 setContent(scrollPane, false);59 }60 61 @Override62 protected void buttonAction(int buttonIndex, ActionEvent evt) {63 if (buttonIndex == 1) {64 try {65 if (summary) {66 buttons.get(1).setText(tr("View summary"));67 htmlPane.setPage(license.getURL());68 } else {69 buttons.get(1).setText(tr("View full text"));70 htmlPane.setPage(license.getSummaryURL());71 }72 } catch (IOException e) {73 e.printStackTrace();74 }75 summary = !summary;76 } else {77 super.buttonAction(buttonIndex, evt);78 }79 }80 81 @Override82 public void setupDialog() {83 super.setupDialog();84 buttons.get(1).setEnabled(license.getSummaryURL() != null && license.getURL() != null);85 if (summary) {86 buttons.get(1).setText(tr("View full text"));87 } else {88 buttons.get(1).setText(tr("View summary"));89 }90 19 } 91 20 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/layers/OdDataLayer.java
r28113 r28114 36 36 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 37 37 import org.openstreetmap.josm.plugins.opendata.core.actions.OpenLinkAction; 38 import org.openstreetmap.josm.plugins.opendata.core.actions.ViewLicenseAction; 38 39 import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler; 39 40 import org.openstreetmap.josm.plugins.opendata.core.io.OsmDownloader; … … 161 162 result.add(new OpenLinkAction(lic.getURL(), ICON_AGREEMENT_24, 162 163 tr("View License"), tr("Launch browser to the license page of the selected data set"))); 163 } else {164 // TODO: view embedded licenses165 164 } 166 165 if (lic.getSummaryURL() != null && lic.getSummaryURL().getProtocol().startsWith("http")) { 167 166 result.add(new OpenLinkAction(lic.getSummaryURL(), ICON_AGREEMENT_24, 168 167 tr("View License (summary)"), tr("Launch browser to the summary license page of the selected data set"))); 169 } else { 170 // TODO: view embedded licenses 168 } 169 if ((lic.getURL() != null && !lic.getURL().getProtocol().startsWith("http")) || (lic.getSummaryURL() != null && !lic.getSummaryURL().getProtocol().startsWith("http"))) { 170 result.add(new ViewLicenseAction(lic, tr("View License"), tr("View the license of the selected data set"))); 171 171 } 172 172 }
Note:
See TracChangeset
for help on using the changeset viewer.