Changeset 3461 in josm
- Timestamp:
- 2010-08-24T10:32:50+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/AutosaveTask.java
r3435 r3461 25 25 import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter; 26 26 import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter.Listener; 27 import org.openstreetmap.josm.data.preferences.BooleanProperty; 27 28 import org.openstreetmap.josm.data.preferences.IntegerProperty; 28 29 import org.openstreetmap.josm.gui.MapView; … … 41 42 private static final String DELETED_LAYERS_DIR = "autosave/deleted_layers"; 42 43 43 44 public static final BooleanProperty PROP_AUTOSAVE_ENABLED = new BooleanProperty("autosave.enabled", true); 44 45 public static final IntegerProperty PROP_FILES_PER_LAYER = new IntegerProperty("autosave.filesPerLayer", 1); 45 46 public static final IntegerProperty PROP_DELETED_LAYERS = new IntegerProperty("autosave.deletedLayersBackupCount", 5); 46 47 public static final IntegerProperty PROP_INTERVAL = new IntegerProperty("autosave.interval", 5 * 60); 48 public static final IntegerProperty PROP_INDEX_LIMIT = new IntegerProperty("autosave.index-limit", 1000); 47 49 48 50 private static class AutosaveLayerInfo { … … 59 61 private final List<AutosaveLayerInfo> layersInfo = new ArrayList<AutosaveLayerInfo>(); 60 62 private Timer timer; 61 private Object layersLock = new Object(); 63 private final Object layersLock = new Object(); 62 64 private final Deque<File> deletedLayers = new LinkedList<File>(); 63 65 … … 136 138 else { 137 139 System.out.println(tr("Unable to create file {0}, other filename will be used", result.getAbsolutePath())); 140 if (index > PROP_INDEX_LIMIT.get()) 141 throw new IOException("index limit exceeded"); 138 142 } 139 143 } catch (IOException e) { … … 278 282 } 279 283 284 public void dicardUnsavedLayers() { 285 for (File f: getUnsavedLayersFiles()) { 286 f.renameTo(new File(deletedLayersDir, f.getName())); 287 } 288 } 280 289 281 290 } -
trunk/src/org/openstreetmap/josm/data/preferences/IntegerProperty.java
r3451 r3461 22 22 } 23 23 24 /** 25 * parses and saves an integer value 26 * @param value the value to be parsed 27 * @return true - preference value has changed 28 * false - parsing failed or preference value has not changed 29 */ 30 public boolean parseAndPut(String value) { 31 Integer intVal; 32 try { 33 intVal = Integer.parseInt(value); 34 } catch (NumberFormatException ex) { 35 return false; 36 } 37 return put(intVal); 38 } 39 24 40 public String getKey() { 25 41 return key; -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r3435 r3461 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.trn; 5 6 6 7 import java.awt.EventQueue; … … 247 248 } 248 249 249 AutosaveTask autosaveTask = new AutosaveTask(); 250 List<File> unsavedLayerFiles = autosaveTask.getUnsavedLayersFiles(); 251 if (!unsavedLayerFiles.isEmpty()) { 252 ExtendedDialog dialog = new ExtendedDialog( 253 Main.parent, 254 tr("Unsaved osm data"), 255 new String[] {tr("Restore"), tr("Cancel")} 256 ); 257 dialog.setContent(tr("JOSM found {0} unsaved osm data layers. It looks like JOSM crashed last time. Do you want to restore data?", 258 unsavedLayerFiles.size())); 259 dialog.setButtonIcons(new String[] {"ok.png", "cancel.png"}); 260 dialog.showDialog(); 261 if (dialog.getValue() == 1) { 262 for (OsmDataLayer layer: autosaveTask.getUnsavedLayers()) { 263 Main.main.addLayer(layer); 250 if (AutosaveTask.PROP_AUTOSAVE_ENABLED.get()) { 251 AutosaveTask autosaveTask = new AutosaveTask(); 252 List<File> unsavedLayerFiles = autosaveTask.getUnsavedLayersFiles(); 253 if (!unsavedLayerFiles.isEmpty()) { 254 ExtendedDialog dialog = new ExtendedDialog( 255 Main.parent, 256 tr("Unsaved osm data"), 257 new String[] {tr("Restore"), tr("Cancel"), tr("Discard")} 258 ); 259 dialog.setContent( 260 trn("JOSM found {0} unsaved osm data layer. ", 261 "JOSM found {0} unsaved osm data layers. ", unsavedLayerFiles.size(), unsavedLayerFiles.size()) + 262 tr("It looks like JOSM crashed last time. Do you like to restore the data?")); 263 dialog.setButtonIcons(new String[] {"ok", "cancel", "dialogs/remove"}); 264 int selection = dialog.showDialog().getValue(); 265 if (selection == 1) { 266 for (OsmDataLayer layer: autosaveTask.getUnsavedLayers()) { 267 Main.main.addLayer(layer); 268 } 269 AutoScaleAction.autoScale("data"); 270 } else if (selection == 3) { 271 autosaveTask.dicardUnsavedLayers(); 264 272 } 265 AutoScaleAction.autoScale("data"); 266 } 267 268 269 } 270 autosaveTask.schedule(); 273 } 274 autosaveTask.schedule(); 275 } 271 276 272 277 -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
r3321 r3461 78 78 WindowGeometry.centerInWindow( 79 79 getParent(), 80 new Dimension( 600,800)80 new Dimension(700,800) 81 81 ) 82 82 ).applySafe(this); -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r3321 r3461 268 268 settingsFactory.add(new MapPaintPreference.Factory()); 269 269 settingsFactory.add(new TaggingPresetPreference.Factory()); 270 settingsFactory.add(new BackupPreference.Factory()); 270 271 if(!Main.applet) { 271 272 settingsFactory.add(new PluginPreference.Factory()); -
trunk/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java
r3406 r3461 29 29 import org.openstreetmap.josm.data.projection.ProjectionSubPrefs; 30 30 import org.openstreetmap.josm.gui.NavigatableComponent; 31 import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel; 31 32 import org.openstreetmap.josm.tools.GBC; 32 33 … … 107 108 * This is the panel holding all projection preferences 108 109 */ 109 private JPanel projPanel = new JPanel();110 private JPanel projPanel = new VerticallyScrollablePanel(); 110 111 111 112 /** -
trunk/src/org/openstreetmap/josm/gui/preferences/ServerAccessPreference.java
r2801 r3461 36 36 private ProxyPreferencesPanel pnlProxyPreferences; 37 37 /** panel for backup preferences */ 38 private BackupPreferencesPanel pnlBackupPreferences;39 38 40 39 /** … … 63 62 pnlProxyPreferences = new ProxyPreferencesPanel(); 64 63 tpServerPreferences.add(wrapVerticallyScrollablePanel(pnlProxyPreferences)); 65 pnlBackupPreferences = new BackupPreferencesPanel();66 tpServerPreferences.add(wrapVerticallyScrollablePanel(pnlBackupPreferences));67 64 68 65 tpServerPreferences.setTitleAt(0, tr("Authentication")); 69 66 tpServerPreferences.setTitleAt(1, tr("Proxy settings")); 70 tpServerPreferences.setTitleAt(2, tr("File backup"));71 67 tpServerPreferences.setToolTipTextAt(0, tr("Configure your identity and how to authenticate at the OSM server")); 72 68 tpServerPreferences.setToolTipTextAt(1, tr("Configure whether to use a proxy server")); 73 tpServerPreferences.setToolTipTextAt(2, tr("Configure whether to create backup files"));74 69 75 70 pnl.add(tpServerPreferences, BorderLayout.CENTER); … … 127 122 pnlAuthPreferences.initFromPreferences(); 128 123 pnlProxyPreferences.initFromPreferences(); 129 pnlBackupPreferences.initFromPreferences();130 124 } 131 125 … … 137 131 pnlAuthPreferences.saveToPreferences(); 138 132 pnlProxyPreferences.saveToPreferences(); 139 pnlBackupPreferences.saveToPreferences();140 133 return false; 141 134 } -
trunk/src/org/openstreetmap/josm/gui/widgets/HtmlPanel.java
r3083 r3461 13 13 14 14 /** 15 * This panel can be used to display larger largersections of formatted text in15 * This panel can be used to display larger sections of formatted text in 16 16 * HTML. 17 17 * … … 61 61 } 62 62 63 public HtmlPanel(String text) { 64 this(); 65 setText(text); 66 } 67 63 68 /** 64 69 * Replies the editor pane used internally to render the HTML text. -
trunk/src/org/openstreetmap/josm/io/OsmExporter.java
r3378 r3461 79 79 } 80 80 // FIXME - how to close? 81 if (!Main.pref.getBoolean("save.keepbackup") && (tmpFile != null)) { 81 if (!Main.pref.getBoolean("save.keepbackup", false) && (tmpFile != null)) { 82 82 tmpFile.delete(); 83 83 } -
trunk/src/org/openstreetmap/josm/tools/I18n.java
r3433 r3461 118 118 119 119 /** 120 * Set by MainApplication. Changes here later will probably mess up everything, because 121 * many strings are already loaded. 120 * Translates some text for the current locale. 121 * These strings are collected by a script that runs on the source code files. 122 * After translation, the localizations are distributed with the main program. 123 * 124 * @param text the text to translate. 125 * Must be a string literal. (No constants or local vars.) 126 * Can be broken over multiple lines. 127 * An apostrophe ' must be quoted by another apostrophe. 128 * @param objects Parameters for the string. 129 * Mark occurrences in <code>text</code> with {0}, {1}, ... 130 * @return the translated string 131 * 132 * Example: tr("JOSM''s default value is ''{0}''.", val); 122 133 */ 123 134 public static final String tr(String text, Object... objects) { … … 131 142 } 132 143 133 public static final String trc(String ctx, String text) { 134 if (ctx == null) 144 /** 145 * Provide translation in a context. 146 * There can be different translations for the same text (but 147 * different context). 148 * 149 * @param context string that helps translators to find an appropriate 150 * translation for <code>text</code> 151 * @param text the text to translate 152 * @return the translated string 153 */ 154 public static final String trc(String context, String text) { 155 if (context == null) 135 156 return tr(text); 136 157 if (text == null) 137 158 return null; 138 return MessageFormat.format(gettext(text, ctx), (Object)null); 139 } 140 141 /* NOTE: marktr does NOT support context strings - use marktrc instead */ 159 return MessageFormat.format(gettext(text, context), (Object)null); 160 } 161 162 /** 163 * Marks a string for translation (such that a script can harvest 164 * the translatable strings from the source files). 165 * 166 * Example: 167 * String[] options = new String[] {marktr("up"), marktr("down")}; 168 * lbl.setText(tr(options[0])); 169 */ 142 170 public static final String marktr(String text) { 143 171 return text; … … 148 176 } 149 177 178 /** 179 * Example: trn("Found {0} error!", "Found {0} errors!", i, Integer.toString(i)); 180 */ 150 181 public static final String trn(String text, String pluralText, long n, Object... objects) { 151 182 return MessageFormat.format(gettextn(text, pluralText, null, n), objects); 152 183 } 153 184 185 /** 186 * Example: trn("There was an error!", "There were errors!", i); 187 */ 154 188 public static final String trn(String text, String pluralText, long n) { 155 189 return MessageFormat.format(gettextn(text, pluralText, null, n), (Object)null);
Note:
See TracChangeset
for help on using the changeset viewer.