JCheckBox author = new JCheckBox(tr("Add author information"), Main.pref.getBoolean("lastAddAuthor", true));
p.add(author, GBC.eol());
JLabel nameLabel = new JLabel(tr("Real name"));
p.add(nameLabel, GBC.std().insets(10, 0, 5, 0));
JosmTextField authorName = new JosmTextField();
p.add(authorName, GBC.eol().fill(GBC.HORIZONTAL));
JLabel emailLabel = new JLabel(tr("E-Mail"));
p.add(emailLabel, GBC.std().insets(10, 0, 5, 0));
JosmTextField email = new JosmTextField();
p.add(email, GBC.eol().fill(GBC.HORIZONTAL));
JLabel copyrightLabel = new JLabel(tr("Copyright (URL)"));
p.add(copyrightLabel, GBC.std().insets(10, 0, 5, 0));
JosmTextField copyright = new JosmTextField();
p.add(copyright, GBC.std().fill(GBC.HORIZONTAL));
JButton predefined = new JButton(tr("Predefined"));
p.add(predefined, GBC.eol().insets(5, 0, 0, 0));
JLabel copyrightYearLabel = new JLabel(tr("Copyright year"));
p.add(copyrightYearLabel, GBC.std().insets(10, 0, 5, 5));
JosmTextField copyrightYear = new JosmTextField("");
p.add(copyrightYear, GBC.eol().fill(GBC.HORIZONTAL));
JLabel warning = new JLabel("<html><font size='-2'> </html");
p.add(warning, GBC.eol().fill(GBC.HORIZONTAL).insets(15, 0, 0, 0));
addDependencies(gpxData, author, authorName, email, copyright, predefined, copyrightYear, nameLabel, emailLabel,
copyrightLabel, copyrightYearLabel, warning);
p.add(new JLabel(tr("Keywords")), GBC.eol());
JosmTextField keywords = new JosmTextField();
keywords.setText((String) gpxData.attr.get(META_KEYWORDS));
p.add(keywords, GBC.eop().fill(GBC.HORIZONTAL));
ExtendedDialog ed = new ExtendedDialog(Main.parent,
tr("Export options"),
new String[] { tr("Export and Save"), tr("Cancel") });
ed.setButtonIcons(new String[] { "exportgpx.png", "cancel.png" });
ed.setContent(p);
ed.showDialog();
if (ed.getValue() != 1) {
setCanceled(true);
return;
}
setCanceled(false);
Main.pref.put("lastAddAuthor", author.isSelected());
if (authorName.getText().length() != 0) {
Main.pref.put("lastAuthorName", authorName.getText());
}
if (copyright.getText().length() != 0) {
Main.pref.put("lastCopyright", copyright.getText());
}
if (layer instanceof OsmDataLayer) {
gpxData = ((OsmDataLayer) layer).toGpxData();
} else if (layer instanceof GpxLayer) {
gpxData = ((GpxLayer) layer).data;
} else {
gpxData = OsmDataLayer.toGpxData(getCurrentDataSet(), file);
}
// add author and copyright details to the gpx data
if (author.isSelected()) {
if (authorName.getText().length() > 0) {
gpxData.attr.put(META_AUTHOR_NAME, authorName.getText());
gpxData.attr.put(META_COPYRIGHT_AUTHOR, authorName.getText());
}
if (email.getText().length() > 0) {
gpxData.attr.put(META_AUTHOR_EMAIL, email.getText());
}
if (copyright.getText().length() > 0) {
gpxData.attr.put(META_COPYRIGHT_LICENSE, copyright.getText());
}
if (copyrightYear.getText().length() > 0) {
gpxData.attr.put(META_COPYRIGHT_YEAR, copyrightYear.getText());
}
}
// add the description to the gpx data
if (desc.getText().length() > 0) {
gpxData.attr.put(META_DESC, desc.getText());
}
// add keywords to the gpx data
if (keywords.getText().length() > 0) {
gpxData.attr.put(META_KEYWORDS, keywords.getText());
}
try (OutputStream fo = Compression.getCompressedFileOutputStream(file)) {
new GpxWriter(fo).write(gpxData);