Changeset 2358 in josm
- Timestamp:
- 2009-10-31T13:15:29+01:00 (15 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/build.xml
r2274 r2358 10 10 </fileset> 11 11 </path> 12 13 <!-- 14 ** Creates the REVISION file to be included in the distribution 15 --> 16 <target name="create-revision"> 17 <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false"> 18 <env key="LANG" value="C"/> 19 <arg value="info"/> 20 <arg value="--xml"/> 21 <arg value="."/> 22 </exec> 23 <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/> 24 <delete file="REVISION"/> 25 <tstamp> 26 <format property="build.tstamp" pattern="yyyy-MM-dd HH:mm:ss"/> 27 </tstamp> 12 28 13 <target name="dist" depends="compile"> 29 <echo file="${build.dir}/REVISION"> 30 # automatically generated JOSM build.xml - do not edit 31 Revision: ${version.entry.commit.revision} 32 Is-Local-Build: true 33 Build-Date: ${build.tstamp} 34 </echo> 35 </target> 36 37 38 <target name="dist" depends="compile,create-revision"> 14 39 15 40 <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false"> … … 28 53 <copy file="LICENSE" todir="build"/> 29 54 30 55 <!-- styles --> 31 56 <copy file="styles/standard/elemstyles.xml" todir="build/styles/standard"/> 32 57 -
trunk/src/org/openstreetmap/josm/actions/AboutAction.java
r2308 r2358 9 9 import java.awt.event.ActionEvent; 10 10 import java.awt.event.KeyEvent; 11 import java.io.BufferedReader;12 import java.io.IOException;13 import java.io.InputStream;14 import java.io.InputStreamReader;15 import java.net.MalformedURLException;16 import java.net.URL;17 import java.util.Properties;18 import java.util.regex.Matcher;19 import java.util.regex.Pattern;20 11 21 12 import javax.swing.BorderFactory; … … 28 19 29 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.data.Version; 30 22 import org.openstreetmap.josm.plugins.PluginHandler; 31 23 import org.openstreetmap.josm.tools.GBC; 32 24 import org.openstreetmap.josm.tools.ImageProvider; 33 import org.openstreetmap.josm.tools.LanguageInfo;34 25 import org.openstreetmap.josm.tools.Shortcut; 35 26 import org.openstreetmap.josm.tools.UrlLabel; … … 43 34 * @author imi 44 35 */ 45 /**46 * @author Stephan47 *48 */49 36 public class AboutAction extends JosmAction { 50 51 private static final String version; 52 53 private final static JTextArea revision; 54 private static String time; 55 56 static { 57 boolean manifest = false; 58 URL u = Main.class.getResource("/REVISION"); 59 if(u == null) { 60 try { 61 manifest = true; 62 u = new URL("jar:" + Main.class.getProtectionDomain().getCodeSource().getLocation().toString() 63 + "!/META-INF/MANIFEST.MF"); 64 } catch (MalformedURLException e) { 65 e.printStackTrace(); 66 } 67 } 68 revision = loadFile(u, manifest); 69 System.out.println("Revision: " + revision.getText()); 70 71 Pattern versionPattern = Pattern.compile(".*?(?:Revision|Main-Version): ([0-9]*(?: SVN)?).*", Pattern.CASE_INSENSITIVE|Pattern.DOTALL); 72 Matcher match = versionPattern.matcher(revision.getText()); 73 version = match.matches() ? match.group(1) : tr("UNKNOWN"); 74 75 Pattern timePattern = Pattern.compile(".*?(?:Last Changed Date|Main-Date): ([^\n]*).*", Pattern.CASE_INSENSITIVE|Pattern.DOTALL); 76 match = timePattern.matcher(revision.getText()); 77 time = match.matches() ? match.group(1) : tr("UNKNOWN"); 78 } 79 80 /** 81 * Return string describing version. 82 * Note that the strinc contains the version number plus an optional suffix of " SVN" to indicate an unofficial development build. 83 * @return version string 84 */ 85 static public String getVersionString() { 86 return version; 87 } 88 89 static public String getTextBlock() { 90 return revision.getText(); 91 } 92 93 static public void setUserAgent() { 94 Properties sysProp = System.getProperties(); 95 sysProp.put("http.agent", "JOSM/1.5 ("+(version.equals(tr("UNKNOWN"))?"UNKNOWN":version)+" "+LanguageInfo.getJOSMLocaleCode()+")"); 96 System.setProperties(sysProp); 97 } 98 99 /** 100 * Return the number part of the version string. 101 * @return integer part of version number or Integer.MAX_VALUE if not available 102 */ 103 public static int getVersionNumber() { 104 int myVersion=Integer.MAX_VALUE; 105 try { 106 myVersion = Integer.parseInt(version.split(" ")[0]); 107 } catch (NumberFormatException e) { 108 // e.printStackTrace(); 109 } 110 return myVersion; 111 } 112 113 /** 114 * check whether the version is a development build out of SVN. 115 * @return true if it is a SVN unofficial build 116 */ 117 public static boolean isDevelopmentVersion() { 118 return version.endsWith(" SVN") || version.equals(tr("UNKNOWN")); 119 } 120 37 121 38 public AboutAction() { 122 39 super(tr("About"), "about", tr("Display the about screen."), Shortcut.registerShortcut("system:about", tr("About"), KeyEvent.VK_F1, Shortcut.GROUP_DIRECT, Shortcut.SHIFT_DEFAULT), true); … … 125 42 public void actionPerformed(ActionEvent e) { 126 43 JTabbedPane about = new JTabbedPane(); 44 45 JTextArea readme = new JTextArea(); 46 readme.setEditable(false); 47 readme.setText(Version.loadResourceFile(Main.class.getResource("/README"))); 127 48 128 JTextArea readme = loadFile(Main.class.getResource("/README"), false); 129 JTextArea contribution = loadFile(Main.class.getResource("/CONTRIBUTION"), false); 130 JTextArea license = loadFile(Main.class.getResource("/LICENSE"), false); 49 JTextArea contribution = new JTextArea(); 50 contribution.setEditable(false); 51 contribution.setText(Version.loadResourceFile(Main.class.getResource("/CONTRIBUTION"))); 52 53 JTextArea license = new JTextArea(); 54 license.setEditable(false); 55 license.setText(Version.loadResourceFile(Main.class.getResource("/LICENSE"))); 56 57 Version version = Version.getInstance(); 131 58 132 59 JPanel info = new JPanel(new GridBagLayout()); … … 135 62 info.add(caption, GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0)); 136 63 info.add(GBC.glue(0,10), GBC.eol()); 137 info.add(new JLabel(tr("Version {0}", version)), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));64 info.add(new JLabel(tr("Version {0}", version.getVersionString())), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0)); 138 65 info.add(GBC.glue(0,5), GBC.eol()); 139 info.add(new JLabel(tr("Last change at {0}", time)), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0));66 info.add(new JLabel(tr("Last change at {0}",version.getTime())), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0)); 140 67 info.add(GBC.glue(0,5), GBC.eol()); 141 68 info.add(new JLabel(tr("Java Version {0}",System.getProperty("java.version"))), GBC.eol().fill(GBC.HORIZONTAL).insets(10,0,0,0)); … … 146 73 info.add(new UrlLabel("http://josm.openstreetmap.de/newticket"), GBC.eol().fill(GBC.HORIZONTAL)); 147 74 75 JTextArea revision = new JTextArea(); 76 revision.setEditable(false); 77 revision.setText(version.getRevision()); 148 78 about.addTab(tr("Info"), info); 149 79 about.addTab(tr("Readme"), createScrollPane(readme)); … … 167 97 return sp; 168 98 } 169 170 /**171 * Retrieve the latest JOSM version from the JOSM homepage.172 * @return An string with the latest version or "UNKNOWN" in case173 * of problems (e.g. no internet connection).174 */175 public static String checkLatestVersion() {176 String latest;177 try {178 InputStream s = new URL("http://josm.openstreetmap.de/current").openStream();179 latest = new BufferedReader(new InputStreamReader(s)).readLine();180 s.close();181 } catch (IOException x) {182 x.printStackTrace();183 return tr("UNKNOWN");184 }185 return latest;186 }187 188 /**189 * Load the specified resource into an TextArea and return it.190 * @param resource The resource url to load191 * @return An read-only text area with the content of "resource"192 */193 private static JTextArea loadFile(URL resource, boolean manifest) {194 JTextArea area = new JTextArea(tr("File could not be found."));195 area.setEditable(false);196 Font font = Font.getFont("monospaced");197 if (font != null) {198 area.setFont(font);199 }200 if (resource == null)201 return area;202 BufferedReader in;203 try {204 in = new BufferedReader(new InputStreamReader(resource.openStream()));205 String s = "";206 for (String line = in.readLine(); line != null; line = in.readLine()) {207 s += line + "\n";208 }209 if (manifest) {210 s = Pattern.compile("\n ", Pattern.DOTALL).matcher(s).replaceAll("");211 s = Pattern.compile("^(SHA1-Digest|Name): .*?$", Pattern.DOTALL|Pattern.MULTILINE).matcher(s).replaceAll("");212 s = Pattern.compile("\n+$", Pattern.DOTALL).matcher(s).replaceAll("");213 }214 area.setText(s);215 area.setCaretPosition(0);216 } catch (IOException e) {217 System.err.println("Cannot load resource " + resource + ": " + e.getMessage());218 //e.printStackTrace();219 }220 return area;221 }222 99 } -
trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
r2323 r2358 21 21 22 22 import org.openstreetmap.josm.Main; 23 import org.openstreetmap.josm.data.Version; 23 24 import org.openstreetmap.josm.gui.ExtendedDialog; 24 25 import org.openstreetmap.josm.plugins.PluginHandler; … … 46 47 { 47 48 StringBuilder text = new StringBuilder(); 48 text.append( AboutAction.getTextBlock());49 text.append(Version.getInstance().getRevision()); 49 50 text.append("\n"); 50 51 text.append("Memory Usage: "); -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r2334 r2358 30 30 31 31 import org.openstreetmap.josm.Main; 32 import org.openstreetmap.josm.actions.AboutAction;33 32 import org.openstreetmap.josm.gui.preferences.ProxyPreferences; 34 33 import org.openstreetmap.josm.tools.ColorHelper; 34 import org.openstreetmap.josm.tools.LanguageInfo; 35 35 36 36 /** … … 324 324 public void save() throws IOException { 325 325 /* currently unused, but may help to fix configuration issues in future */ 326 properties.put("josm.version", AboutAction.getVersionString());327 328 setSystemProperties();326 properties.put("josm.version", Version.getInstance().getVersionString()); 327 328 updateSystemProperties(); 329 329 File prefFile = new File(getPreferencesDirFile(), "preferences"); 330 330 … … 394 394 if (!errLines.isEmpty()) 395 395 throw new IOException(tr("Malformed config file at lines {0}", errLines)); 396 setSystemProperties();396 updateSystemProperties(); 397 397 } 398 398 … … 679 679 } 680 680 } 681 682 681 return put(key, s); 683 682 } 684 685 private void setSystemProperties() { 683 684 /** 685 * Updates system properties with the current values in the preferences. 686 * 687 */ 688 public void updateSystemProperties() { 689 Properties sysProp = System.getProperties(); 686 690 if (getBoolean(ProxyPreferences.PROXY_ENABLE)) { 687 Properties sysProp = System.getProperties();688 691 sysProp.put("proxySet", "true"); 689 692 sysProp.put("http.proxyHost", get(ProxyPreferences.PROXY_HOST)); … … 693 696 sysProp.put("proxyPassword", get(ProxyPreferences.PROXY_PASS)); 694 697 } 695 System.setProperties(sysProp); 696 } 697 AboutAction.setUserAgent(); 698 699 } 700 int v = Version.getInstance().getVersion(); 701 String s = ( v == Version.JOSM_UNKNOWN_VERSION) ? "UNKNOWN" : Integer.toString(v); 702 sysProp.put("http.agent", "JOSM/1.5 ("+ s+" "+LanguageInfo.getJOSMLocaleCode()+")"); 703 System.setProperties(sysProp); 698 704 } 699 705 } -
trunk/src/org/openstreetmap/josm/gui/GettingStarted.java
r2308 r2358 16 16 17 17 import org.openstreetmap.josm.Main; 18 import org.openstreetmap.josm. actions.AboutAction;18 import org.openstreetmap.josm.data.Version; 19 19 import org.openstreetmap.josm.io.CacheCustomContent; 20 20 import org.openstreetmap.josm.tools.LanguageInfo; … … 51 51 } 52 52 53 final private int myVersion = AboutAction.getVersionNumber();53 final private int myVersion = Version.getInstance().getVersion(); 54 54 final private String myLang = LanguageInfo.getWikiLanguagePrefix(); 55 55 -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r2274 r2358 96 96 I18n.set(Main.pref.get("language", null)); 97 97 } 98 Main.pref.updateSystemProperties(); 98 99 99 100 if (argList.contains("--help") || argList.contains("-?") || argList.contains("-h")) { -
trunk/src/org/openstreetmap/josm/gui/SplashScreen.java
r1212 r2358 26 26 27 27 import org.openstreetmap.josm.actions.AboutAction; 28 import org.openstreetmap.josm.data.Version; 28 29 import org.openstreetmap.josm.tools.ImageProvider; 29 30 … … 73 74 74 75 // Add the version number 75 JLabel version = new JLabel(tr("Version {0}", AboutAction.getVersionString()));76 JLabel version = new JLabel(tr("Version {0}", Version.getInstance().getVersionString())); 76 77 gbc.gridy = 1; 77 78 gbc.insets = new Insets(0, 0, 0, 0); -
trunk/src/org/openstreetmap/josm/gui/help/HelpApplication.java
r2308 r2358 92 92 I18n.set(Main.pref.get("language", null)); 93 93 } 94 95 94 MainApplication.preConstructorInit(args); 96 95 Thread.setDefaultUncaughtExceptionHandler( -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r2308 r2358 119 119 pnlLists = new JPanel(); 120 120 pnlLists.setLayout(new GridBagLayout()); 121 // we don't add the lists yet, see setUploadPrimi vies()121 // we don't add the lists yet, see setUploadPrimitives() 122 122 // 123 123 return pnlLists; … … 278 278 y++; 279 279 gcLabel.gridy = y; 280 lblUpdate.setText(trn("{0} object to modif iy:", "{0} objects to modify:", update.size(),update.size()));280 lblUpdate.setText(trn("{0} object to modify:", "{0} objects to modify:", update.size(),update.size())); 281 281 pnlLists.add(lblUpdate, gcLabel); 282 282 y++; -
trunk/src/org/openstreetmap/josm/plugins/PluginDownloader.java
r2070 r2358 27 27 import org.openstreetmap.josm.Main; 28 28 import org.openstreetmap.josm.actions.AboutAction; 29 import org.openstreetmap.josm.data.Version; 29 30 import org.openstreetmap.josm.gui.ExtendedDialog; 30 31 import org.openstreetmap.josm.gui.PleaseWaitRunnable; … … 120 121 121 122 private static boolean download(PluginInformation pd, File file) { 122 if(pd.mainversion > AboutAction.getVersionNumber())123 if(pd.mainversion > Version.getInstance().getVersion()) 123 124 { 124 125 ExtendedDialog dialog = new ExtendedDialog( -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r2297 r2358 34 34 import org.openstreetmap.josm.Main; 35 35 import org.openstreetmap.josm.actions.AboutAction; 36 import org.openstreetmap.josm.data.Version; 36 37 import org.openstreetmap.josm.gui.ExtendedDialog; 37 38 import org.openstreetmap.josm.gui.MapFrame; … … 101 102 continue; 102 103 } 103 if (info.mainversion > AboutAction.getVersionNumber()) { 104 int josmVersion = Version.getInstance().getVersion(); 105 if (info.mainversion > josmVersion && josmVersion != Version.JOSM_UNKNOWN_VERSION) { 104 106 JOptionPane.showMessageDialog( 105 107 Main.parent, -
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r1860 r2358 22 22 import org.openstreetmap.josm.Main; 23 23 import org.openstreetmap.josm.actions.AboutAction; 24 import org.openstreetmap.josm.data.Version; 24 25 import org.openstreetmap.josm.tools.LanguageInfo; 25 26 … … 121 122 catch(NumberFormatException e) {} 122 123 author = attr.getValue("Author"); 123 if(oldcheck && mainversion > AboutAction.getVersionNumber())124 if(oldcheck && mainversion > Version.getInstance().getVersion()) 124 125 { 125 int myv = AboutAction.getVersionNumber();126 int myv = Version.getInstance().getVersion(); 126 127 for(Map.Entry entry : attr.entrySet()) 127 128 { -
trunk/src/org/openstreetmap/josm/tools/I18n.java
r2225 r2358 132 132 } 133 133 134 public static void set(String localeName) 135 { 134 /** 135 * Sets the default locale (see {@see Locale#setDefault(Locale)} to the local 136 * given by <code>localName</code>. 137 * 138 * Ignored if localName is null. If the locale with name <code>localName</code> 139 * isn't found the default local is set to <tt>en</tt> (english). 140 * 141 * @param localeName the locale name. Ignored if null. 142 */ 143 public static void set(String localeName){ 136 144 if (localeName != null) { 137 145 Locale l;
Note:
See TracChangeset
for help on using the changeset viewer.