Changeset 6654 in josm
- Timestamp:
- 2014-01-06T21:46:07+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r6631 r6654 234 234 final HashMap<String, String> tags = new HashMap<String, String>(layer.data.getChangeSetTags()); 235 235 if (!tags.containsKey("source")) { 236 tags.put("source", Main.map.mapView.getLayerInformationForSourceTag());236 tags.put("source", dialog.getLastChangesetSourceFromHistory()); 237 237 } 238 238 if (!tags.containsKey("comment")) { -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r6567 r6654 45 45 import org.openstreetmap.josm.data.coor.EastNorth; 46 46 import org.openstreetmap.josm.data.coor.LatLon; 47 import org.openstreetmap.josm.data.imagery.ImageryInfo; 47 48 import org.openstreetmap.josm.data.osm.DataSet; 48 49 import org.openstreetmap.josm.data.osm.DataSource; … … 979 980 } 980 981 for (final ImageryLayer i : getLayersOfType(ImageryLayer.class)) { 981 layerInfo.add( i.getName());982 layerInfo.add(ImageryInfo.ImageryType.BING.equals(i.getInfo().getImageryType()) ? "Bing" : i.getName()); 982 983 } 983 984 return Utils.join("; ", layerInfo); -
trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java
r6631 r6654 21 21 import javax.swing.Action; 22 22 import javax.swing.BorderFactory; 23 import javax.swing.J Label;23 import javax.swing.JEditorPane; 24 24 import javax.swing.JPanel; 25 import javax.swing.event.HyperlinkEvent; 26 import javax.swing.event.HyperlinkListener; 25 27 26 28 import org.openstreetmap.josm.Main; 27 29 import org.openstreetmap.josm.data.osm.Changeset; 28 30 import org.openstreetmap.josm.gui.widgets.HistoryComboBox; 31 import org.openstreetmap.josm.gui.widgets.JosmEditorPane; 29 32 import org.openstreetmap.josm.tools.CheckParameterUtil; 30 33 import org.openstreetmap.josm.tools.GBC; … … 54 57 pnl.setLayout(new GridBagLayout()); 55 58 56 pnl.add(new JLabel(tr("Provide a brief comment for the changes you are uploading:")), GBC.eol().insets(0, 5, 10, 3)); 59 final JEditorPane commentLabel = JosmEditorPane.createJLabelLikePane(); 60 commentLabel.setText("<html><b>" + tr("Provide a brief comment for the changes you are uploading:")); 61 pnl.add(commentLabel, GBC.eol().insets(0, 5, 10, 3)); 57 62 hcbUploadComment.setToolTipText(tr("Enter an upload comment")); 58 63 hcbUploadComment.setMaxTextLength(Changeset.MAX_COMMENT_LENGTH); … … 65 70 pnl.add(hcbUploadComment, GBC.eol().fill(GBC.HORIZONTAL)); 66 71 67 pnl.add(new JLabel(tr("Specify the data source for the changes:")), GBC.eol().insets(0, 8, 10, 3)); 72 final JEditorPane sourceLabel = JosmEditorPane.createJLabelLikePane(); 73 sourceLabel.setText("<html><b>" + tr("Specify the data source for the changes") 74 + "</b> (<a href=\"urn:changeset-source\">" + tr("obtain from current layers") + "</a>)<b>:</b>"); 75 sourceLabel.addHyperlinkListener(new HyperlinkListener() { 76 @Override 77 public void hyperlinkUpdate(HyperlinkEvent e) { 78 if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { 79 hcbUploadSource.setText(Main.map.mapView.getLayerInformationForSourceTag()); 80 } 81 } 82 }); 83 pnl.add(sourceLabel, GBC.eol().insets(0, 8, 10, 3)); 84 68 85 hcbUploadSource.setToolTipText(tr("Enter a source")); 69 List<String> sourceHistory = new LinkedList<String>(Main.pref.getCollection(SOURCE_HISTORY_KEY, Arrays.asList("knowledge", "survey" )));86 List<String> sourceHistory = new LinkedList<String>(Main.pref.getCollection(SOURCE_HISTORY_KEY, Arrays.asList("knowledge", "survey", "Bing"))); 70 87 Collections.reverse(sourceHistory); // we have to reverse the history, because ComboBoxHistory will reverse it again in addElement() 71 88 hcbUploadSource.setPossibleItems(sourceHistory); -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r6631 r6654 590 590 } 591 591 592 p ublic String getLastChangesetCommentFromHistory() {593 Collection<String> history = Main.pref.getCollection( BasicUploadSettingsPanel.HISTORY_KEY, new ArrayList<String>());592 private String getLastChangesetTagFromHistory(String historyKey) { 593 Collection<String> history = Main.pref.getCollection(historyKey, new ArrayList<String>()); 594 594 int age = (int) (System.currentTimeMillis() / 1000 - Main.pref.getInteger(BasicUploadSettingsPanel.HISTORY_LAST_USED_KEY, 0)); 595 595 if (age < Main.pref.getInteger(BasicUploadSettingsPanel.HISTORY_MAX_AGE_KEY, 4 * 3600 * 1000) && history != null && !history.isEmpty()) { … … 599 599 } 600 600 } 601 602 public String getLastChangesetCommentFromHistory() { 603 return getLastChangesetTagFromHistory(BasicUploadSettingsPanel.HISTORY_KEY); 604 } 605 606 public String getLastChangesetSourceFromHistory() { 607 return getLastChangesetTagFromHistory(BasicUploadSettingsPanel.SOURCE_HISTORY_KEY); 608 } 601 609 } -
trunk/src/org/openstreetmap/josm/gui/io/UploadParameterSummaryPanel.java
r6084 r6654 6 6 7 7 import java.awt.BorderLayout; 8 import java.awt.Font;9 8 import java.beans.PropertyChangeEvent; 10 9 import java.beans.PropertyChangeListener; 11 import java.text.MessageFormat;12 10 13 11 import javax.swing.BorderFactory; 14 12 import javax.swing.JLabel; 15 13 import javax.swing.JPanel; 16 import javax.swing.UIManager;17 14 import javax.swing.event.HyperlinkEvent; 18 15 import javax.swing.event.HyperlinkListener; 19 import javax.swing.text.html.StyleSheet;20 16 21 17 import org.openstreetmap.josm.data.osm.Changeset; 22 18 import org.openstreetmap.josm.gui.widgets.JosmEditorPane; 23 import org.openstreetmap.josm.gui.widgets.JosmHTMLEditorKit;24 19 import org.openstreetmap.josm.io.OsmApi; 25 20 import org.openstreetmap.josm.tools.ImageProvider; … … 104 99 105 100 protected void build() { 106 jepMessage = new JosmEditorPane("text/html", ""); 107 jepMessage.setOpaque(false); 108 jepMessage.setEditable(false); 101 jepMessage = JosmEditorPane.createJLabelLikePane(); 109 102 jepMessage.addHyperlinkListener(this); 110 Font f = UIManager.getFont("Label.font");111 StyleSheet ss = new StyleSheet();112 String rule = MessageFormat.format(113 "font-family: ''{0}'';font-size: {1,number}pt; font-weight: {2}; font-style: {3}",114 f.getName(),115 f.getSize(),116 f.isBold() ? "bold" : "normal",117 f.isItalic() ? "italic" : "normal"118 );119 rule = "body {" + rule + "}";120 rule = MessageFormat.format(121 "font-family: ''{0}'';font-size: {1,number}pt; font-weight: {2}; font-style: {3}",122 f.getName(),123 f.getSize(),124 "bold",125 f.isItalic() ? "italic" : "normal"126 );127 rule = "strong {" + rule + "}";128 ss.addRule(rule);129 ss.addRule("a {text-decoration: underline; color: blue}");130 JosmHTMLEditorKit kit = new JosmHTMLEditorKit();131 kit.setStyleSheet(ss);132 jepMessage.setEditorKit(kit);133 103 134 104 setLayout(new BorderLayout()); -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmEditorPane.java
r5887 r6654 2 2 package org.openstreetmap.josm.gui.widgets; 3 3 4 import java.awt.Font; 4 5 import java.io.IOException; 5 6 import java.io.InputStream; 6 7 import java.net.URL; 7 8 import java.net.URLConnection; 9 import java.text.MessageFormat; 8 10 9 11 import javax.swing.JEditorPane; 12 import javax.swing.UIManager; 13 import javax.swing.text.html.StyleSheet; 10 14 11 15 import org.openstreetmap.josm.tools.Utils; … … 75 79 return result; 76 80 } 81 82 /** 83 * Creates a {@link JosmEditorPane} which is meant to be used as a powerful replacement of {@link javax.swing.JLabel}. 84 */ 85 public static JosmEditorPane createJLabelLikePane() { 86 final JosmEditorPane pane = new JosmEditorPane("text/html", ""); 87 pane.setOpaque(false); 88 pane.setEditable(false); 89 90 JosmHTMLEditorKit kit = new JosmHTMLEditorKit(); 91 final Font f = UIManager.getFont("Label.font"); 92 final StyleSheet ss = new StyleSheet(); 93 final String rule = MessageFormat.format( 94 "font-family: ''{0}'';font-size: {1,number}pt; font-weight: {2}; font-style: {3}", 95 f.getName(), 96 f.getSize(), 97 "bold", 98 f.isItalic() ? "italic" : "normal" 99 ); 100 ss.addRule("strong {" + rule + "}"); 101 ss.addRule("a {text-decoration: underline; color: blue}"); 102 kit.setStyleSheet(ss); 103 pane.setEditorKit(kit); 104 105 return pane; 106 } 77 107 }
Note:
See TracChangeset
for help on using the changeset viewer.