- Timestamp:
- 2013-11-02T16:36:10+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/Test.java
r6336 r6354 23 23 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 24 24 import org.openstreetmap.josm.tools.GBC; 25 import org.openstreetmap.josm.tools.Utils; 25 26 26 27 /** … … 64 65 /** the progress monitor to use */ 65 66 protected ProgressMonitor progressMonitor; 67 68 /** the start time to compute elapsed time when test finishes */ 69 protected long startTime; 70 66 71 /** 67 72 * Constructor … … 87 92 */ 88 93 public void initialize() throws Exception { 94 this.startTime = -1; 89 95 } 90 96 … … 100 106 this.progressMonitor = progressMonitor; 101 107 } 102 this.progressMonitor.beginTask(tr("Running test {0}", name)); 103 errors = new ArrayList<TestError>(30); 108 String startMessage = tr("Running test {0}", name); 109 this.progressMonitor.beginTask(startMessage); 110 Main.debug(startMessage); 111 this.errors = new ArrayList<TestError>(30); 112 this.startTime = System.currentTimeMillis(); 104 113 } 105 114 … … 130 139 progressMonitor.finishTask(); 131 140 progressMonitor = null; 141 if (startTime > 0) { 142 long elapsedTime = System.currentTimeMillis() - startTime; 143 Main.info(tr("Test ''{0}'' completed in {1}", getName(), Utils.getDurationString(elapsedTime))); 144 } 132 145 } 133 146 -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r6329 r6354 151 151 */ 152 152 public TagChecker() { 153 super(tr("Tag checker :"), tr("This test checks for errors in tag keys and values."));153 super(tr("Tag checker"), tr("This test checks for errors in tag keys and values.")); 154 154 } 155 155 … … 511 511 a.anchor = GridBagConstraints.EAST; 512 512 513 testPanel.add(new JLabel(name ), GBC.eol().insets(3,0,0,0));513 testPanel.add(new JLabel(name+" :"), GBC.eol().insets(3,0,0,0)); 514 514 515 515 prefCheckKeys = new JCheckBox(tr("Check property keys."), Main.pref.getBoolean(PREF_CHECK_KEYS, true)); -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r6313 r6354 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.tools; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.trn; 3 6 4 7 import java.awt.Color; … … 754 757 return josmTmpDir; 755 758 } 759 760 /** 761 * Returns a simple human readable (hours, minutes, seconds) string for a given duration in milliseconds. 762 * @param elapsedTime The duration in milliseconds 763 * @return A human redable string for the given duration 764 * @throws IllegalArgumentException if elapsedTime is < 0 765 * @since 6354 766 */ 767 public static String getDurationString(long elapsedTime) throws IllegalArgumentException { 768 if (elapsedTime < 0) { 769 throw new IllegalArgumentException("elapsedTime must be > 0"); 770 } 771 // Is it less than 1 second ? 772 if (elapsedTime < 1000) { 773 return String.format("%d %s", elapsedTime, tr("ms")); 774 } 775 // Is it less than 1 minute ? 776 if (elapsedTime < 60*1000) { 777 return String.format("%.1f %s", elapsedTime/1000f, tr("s")); 778 } 779 // Is it less than 1 hour ? 780 if (elapsedTime < 60*60*1000) { 781 return String.format("%d %s %d %s", elapsedTime/60000, tr("min"), elapsedTime/1000, tr("s")); 782 } 783 // Is it less than 1 day ? 784 if (elapsedTime < 24*60*60*1000) { 785 return String.format("%d %s %d %s", elapsedTime/3600000, tr("h"), elapsedTime/60000, tr("min")); 786 } 787 long days = elapsedTime/86400000; 788 return String.format("%d %s %d %s", days, trn("day", "days", days), elapsedTime/3600000, tr("h")); 789 } 756 790 }
Note:
See TracChangeset
for help on using the changeset viewer.