Changeset 5396 in josm
- Timestamp:
- 2012-08-05T20:55:08+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/GpxExporter.java
r5361 r5396 69 69 JPanel p = new JPanel(new GridBagLayout()); 70 70 71 GpxData gpxData; 72 // At this moment, we only need to know the attributes of the GpxData, 73 // conversion of OsmDataLayer (if needed) will be done after the dialog 74 // is closed. 75 if (layer instanceof GpxLayer) { 76 gpxData = ((GpxLayer) layer).data; 77 } else { 78 gpxData = new GpxData(); 79 } 80 71 81 p.add(new JLabel(tr("GPS track description")), GBC.eol()); 72 82 JTextArea desc = new JTextArea(3, 40); 73 83 desc.setWrapStyleWord(true); 74 84 desc.setLineWrap(true); 85 desc.setText((String) gpxData.attr.get(GpxData.META_DESC)); 75 86 p.add(new JScrollPane(desc), GBC.eop().fill(GBC.BOTH)); 76 87 77 88 JCheckBox author = new JCheckBox(tr("Add author information"), Main.pref.getBoolean("lastAddAuthor", true)); 78 author.setSelected(true);79 89 p.add(author, GBC.eol()); 80 90 JLabel nameLabel = new JLabel(tr("Real name")); 81 91 p.add(nameLabel, GBC.std().insets(10, 0, 5, 0)); 82 JTextField authorName = new JTextField( Main.pref.get("lastAuthorName"));92 JTextField authorName = new JTextField(); 83 93 p.add(authorName, GBC.eol().fill(GBC.HORIZONTAL)); 84 94 JLabel emailLabel = new JLabel(tr("E-Mail")); 85 95 p.add(emailLabel, GBC.std().insets(10, 0, 5, 0)); 86 String user = CredentialsManager.getInstance().getUsername(); 87 JTextField email = new JTextField(user == null ? "" : user); 96 JTextField email = new JTextField(); 88 97 p.add(email, GBC.eol().fill(GBC.HORIZONTAL)); 89 98 JLabel copyrightLabel = new JLabel(tr("Copyright (URL)")); … … 99 108 JLabel warning = new JLabel("<html><font size='-2'> </html"); 100 109 p.add(warning, GBC.eol().fill(GBC.HORIZONTAL).insets(15, 0, 0, 0)); 101 addDependencies( author, authorName, email, copyright, predefined, copyrightYear, nameLabel, emailLabel,110 addDependencies(gpxData, author, authorName, email, copyright, predefined, copyrightYear, nameLabel, emailLabel, 102 111 copyrightLabel, copyrightYearLabel, warning); 103 104 // if the user name is not the email address, but the osm user name105 // move it from the email textfield to the author textfield106 if (!email.getText().contains("@")) {107 authorName.setText(email.getText());108 email.setText("");109 }110 112 111 113 p.add(new JLabel(tr("Keywords")), GBC.eol()); 112 114 JTextField keywords = new JTextField(); 115 keywords.setText((String) gpxData.attr.get(GpxData.META_KEYWORDS)); 113 116 p.add(keywords, GBC.eop().fill(GBC.HORIZONTAL)); 114 117 … … 131 134 } 132 135 133 GpxData gpxData;134 136 if (layer instanceof OsmDataLayer) { 135 137 gpxData = ((OsmDataLayer) layer).toGpxData(); … … 180 182 } 181 183 182 private static void enableCopyright(final JTextField copyright, final JButton predefined,184 private static void enableCopyright(final GpxData data, final JTextField copyright, final JButton predefined, 183 185 final JTextField copyrightYear, final JLabel copyrightLabel, final JLabel copyrightYearLabel, 184 186 final JLabel warning, boolean enable) { … … 190 192 warning.setText(enable ? warningGpl : "<html><font size='-2'> </html"); 191 193 192 if (enable && copyrightYear.getText().length()==0) { 193 copyrightYear.setText(enable ? Integer.toString(Calendar.getInstance().get(Calendar.YEAR)) : ""); 194 } else if (!enable) { 194 if (enable) { 195 if (copyrightYear.getText().length()==0) { 196 String sCopyrightYear = (String) data.attr.get(GpxData.META_COPYRIGHT_YEAR); 197 if (sCopyrightYear == null) { 198 sCopyrightYear = Integer.toString(Calendar.getInstance().get(Calendar.YEAR)); 199 } 200 copyrightYear.setText(sCopyrightYear); 201 } 202 if (copyright.getText().length()==0) { 203 String sCopyright = (String) data.attr.get(GpxData.META_COPYRIGHT_LICENSE); 204 if (sCopyright == null) { 205 sCopyright = Main.pref.get("lastCopyright", "http://creativecommons.org/licenses/by-sa/2.5"); 206 } 207 copyright.setText(sCopyright); 208 copyright.setCaretPosition(0); 209 } 210 } else { 195 211 copyrightYear.setText(""); 196 }197 198 if (enable && copyright.getText().length()==0) {199 copyright.setText(enable ? Main.pref.get("lastCopyright", "http://creativecommons.org/licenses/by-sa/2.5") : "");200 copyright.setCaretPosition(0);201 } else if (!enable) {202 212 copyright.setText(""); 203 213 } … … 213 223 */ 214 224 private static void addDependencies( 225 final GpxData data, 215 226 final JCheckBox author, 216 227 final JTextField authorName, … … 232 243 nameLabel.setEnabled(b); 233 244 emailLabel.setEnabled(b); 234 authorName.setText(b ? Main.pref.get("lastAuthorName") : ""); 235 String user = CredentialsManager.getInstance().getUsername(); 236 email.setText(b ? (user == null ? "" : user) : ""); 237 238 boolean authorSet = authorName.getText().length() != 0; 239 GpxExporter.enableCopyright(copyright, predefined, copyrightYear, copyrightLabel, copyrightYearLabel, warning, b && authorSet); 245 if (b) { 246 String sAuthorName = (String) data.attr.get(GpxData.META_AUTHOR_NAME); 247 if (sAuthorName == null) { 248 sAuthorName = Main.pref.get("lastAuthorName"); 249 } 250 authorName.setText(sAuthorName); 251 String sEmail = (String) data.attr.get(GpxData.META_AUTHOR_EMAIL); 252 if (sEmail == null) { 253 sEmail = Main.pref.get("lastAuthorEmail"); 254 } 255 email.setText(sEmail); 256 } else { 257 authorName.setText(""); 258 email.setText(""); 259 } 260 boolean isAuthorSet = authorName.getText().length() != 0; 261 GpxExporter.enableCopyright(data, copyright, predefined, copyrightYear, copyrightLabel, copyrightYearLabel, warning, b && isAuthorSet); 240 262 } 241 263 }; … … 245 267 @Override public void keyReleased(KeyEvent e) { 246 268 boolean b = authorName.getText().length()!=0 && author.isSelected(); 247 GpxExporter.enableCopyright( copyright, predefined, copyrightYear, copyrightLabel, copyrightYearLabel, warning, b);269 GpxExporter.enableCopyright(data, copyright, predefined, copyrightYear, copyrightLabel, copyrightYearLabel, warning, b); 248 270 } 249 271 };
Note:
See TracChangeset
for help on using the changeset viewer.