Changeset 17663 in josm
- Timestamp:
- 2021-03-25T01:56:53+01:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AboutAction.java
r17188 r17663 2 2 package org.openstreetmap.josm.actions; 3 3 4 import static java.awt.GridBagConstraints.HORIZONTAL; 5 import static javax.swing.SwingConstants.CENTER; 4 6 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 5 7 import static org.openstreetmap.josm.tools.I18n.tr; … … 105 107 "<p style='font-size:50%'></p>" + 106 108 "</html>"); 107 info.add(label, GBC.eol().fill( GBC.HORIZONTAL).insets(10, 0, 0, 10));109 info.add(label, GBC.eol().fill(HORIZONTAL).insets(10, 0, 0, 10)); 108 110 info.add(new JLabel(tr("Homepage")), GBC.std().insets(10, 0, 10, 0)); 109 111 info.add(new UrlLabel(Config.getUrls().getJOSMWebsite(), 2), GBC.eol()); … … 121 123 122 124 JPanel inst = new JPanel(new GridBagLayout()); 123 final String pathToPreferences = ShowStatusReportAction 124 .paramCleanup(Preferences.main().getPreferenceFile().getAbsolutePath()); 125 inst.add(new JLabel(tr("Preferences are stored in {0}", pathToPreferences)), GBC.eol().insets(0, 0, 0, 10)); 125 inst.add(new JLabel(tr("Preferences are stored in {0}", getPathToPreferences())), GBC.eol().insets(0, 0, 0, 10)); 126 126 inst.add(new JLabel(tr("Symbolic names for directories and the actual paths:")), 127 127 GBC.eol().insets(0, 0, 0, 10)); … … 147 147 JPanel panel = new JPanel(new GridBagLayout()); 148 148 panel.setPreferredSize(new Dimension(890, 300)); 149 panel.add(new JLabel("", ImageProvider.get("logo.svg", ImageProvider.ImageSizes.ABOUT_LOGO), 150 JLabel.CENTER), GBC.std().insets(0, 5, 0, 0)); 149 panel.add(new JLabel("", ImageProvider.get("logo.svg", ImageSizes.ABOUT_LOGO), CENTER), GBC.std().insets(0, 5, 0, 0)); 151 150 panel.add(about, GBC.std().fill()); 152 151 return panel; 152 } 153 154 private static String getPathToPreferences() { 155 File preferenceFile = Preferences.main().getPreferenceFile(); 156 try { 157 return ShowStatusReportAction.paramCleanup(preferenceFile.getAbsolutePath()); 158 } catch (SecurityException e) { 159 Logging.warn(e); 160 return ShowStatusReportAction.paramCleanup(preferenceFile.getPath()); 161 } 153 162 } 154 163 … … 176 185 putValue(Action.NAME, "..."); 177 186 this.dir = dir; 178 setEnabled(dir != null && new File(dir).isDirectory()); 187 try { 188 setEnabled(dir != null && new File(dir).isDirectory()); 189 } catch (SecurityException e) { 190 setEnabled(false); 191 Logging.warn(e); 192 } 179 193 } 180 194 … … 209 223 dirLabel.setFont(GuiHelper.getMonospacedFont(dirLabel)); 210 224 dirLabel.setOpaque(false); 211 inst.add(dirLabel, GBC.std().fill( GBC.HORIZONTAL));225 inst.add(dirLabel, GBC.std().fill(HORIZONTAL)); 212 226 JButton btn = new JButton(new OpenDirAction(dir)); 213 227 btn.setToolTipText(tr("Open directory")); -
trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java
r17369 r17663 42 42 */ 43 43 public final class JCSCacheManager { 44 private static final long maxObjectTTL = -1;44 private static final long MAX_OBJECT_TTL = -1; 45 45 private static final String PREFERENCE_PREFIX = "jcs.cache"; 46 47 /** 48 * Property that determines the disk cache implementation 49 */ 46 50 public static final BooleanProperty USE_BLOCK_CACHE = new BooleanProperty(PREFERENCE_PREFIX + ".use_block_cache", true); 47 51 48 private static final AuxiliaryCacheFactory DISK_CACHE_FACTORY = 49 USE_BLOCK_CACHE.get() ? new BlockDiskCacheFactory() : new IndexedDiskCacheFactory(); 52 private static final AuxiliaryCacheFactory DISK_CACHE_FACTORY = getDiskCacheFactory(); 50 53 private static FileLock cacheDirLock; 51 54 … … 139 142 props.setProperty("jcs.default.elementattributes", CacheEntryAttributes.class.getCanonicalName()); 140 143 props.setProperty("jcs.default.elementattributes.IsEternal", "false"); 141 props.setProperty("jcs.default.elementattributes.MaxLife", Long.toString( maxObjectTTL));142 props.setProperty("jcs.default.elementattributes.IdleTime", Long.toString( maxObjectTTL));144 props.setProperty("jcs.default.elementattributes.MaxLife", Long.toString(MAX_OBJECT_TTL)); 145 props.setProperty("jcs.default.elementattributes.IdleTime", Long.toString(MAX_OBJECT_TTL)); 143 146 props.setProperty("jcs.default.elementattributes.IsSpool", "true"); 144 147 // CHECKSTYLE.ON: SingleSpaceSeparator … … 148 151 Logging.log(Logging.LEVEL_WARN, "Unable to initialize JCS", e); 149 152 } 153 } 154 155 private static AuxiliaryCacheFactory getDiskCacheFactory() { 156 try { 157 return useBlockCache() ? new BlockDiskCacheFactory() : new IndexedDiskCacheFactory(); 158 } catch (SecurityException | LinkageError e) { 159 Logging.error(e); 160 return null; 161 } 162 } 163 164 private static boolean useBlockCache() { 165 return USE_BLOCK_CACHE.get() == Boolean.TRUE; 150 166 } 151 167 … … 173 189 @SuppressWarnings("unchecked") 174 190 public static <K, V> CacheAccess<K, V> getCache(String cacheName, int maxMemoryObjects, int maxDiskObjects, String cachePath) { 175 CacheAccess<K, V> cacheAccess = JCS.getInstance(cacheName, getCacheAttributes(maxMemoryObjects)); 176 CompositeCache<K, V> cc = cacheAccess.getCacheControl(); 177 178 if (cachePath != null && cacheDirLock != null) { 179 IDiskCacheAttributes diskAttributes = getDiskCacheAttributes(maxDiskObjects, cachePath, cacheName); 191 CacheAccess<K, V> cacheAccess = getCacheAccess(cacheName, getCacheAttributes(maxMemoryObjects)); 192 193 if (cachePath != null && cacheDirLock != null && cacheAccess != null && DISK_CACHE_FACTORY != null) { 194 CompositeCache<K, V> cc = cacheAccess.getCacheControl(); 180 195 try { 196 IDiskCacheAttributes diskAttributes = getDiskCacheAttributes(maxDiskObjects, cachePath, cacheName); 181 197 if (cc.getAuxCaches().length == 0) { 182 198 cc.setAuxCaches(new AuxiliaryCache[]{DISK_CACHE_FACTORY.createCache( … … 192 208 } 193 209 210 private static <K, V> CacheAccess<K, V> getCacheAccess(String cacheName, CompositeCacheAttributes cacheAttributes) { 211 try { 212 return JCS.getInstance(cacheName, cacheAttributes); 213 } catch (SecurityException | LinkageError e) { 214 Logging.error(e); 215 return null; 216 } 217 } 218 194 219 /** 195 220 * Close all files to ensure, that all indexes and data are properly written … … 201 226 private static IDiskCacheAttributes getDiskCacheAttributes(int maxDiskObjects, String cachePath, String cacheName) { 202 227 IDiskCacheAttributes ret; 203 removeStaleFiles(cachePath + File.separator + cacheName, USE_BLOCK_CACHE.get() ? "_INDEX_v2" : "_BLOCK_v2");204 String newCacheName = cacheName + ( USE_BLOCK_CACHE.get() ? "_BLOCK_v2" : "_INDEX_v2");205 206 if ( USE_BLOCK_CACHE.get()) {228 removeStaleFiles(cachePath + File.separator + cacheName, useBlockCache() ? "_INDEX_v2" : "_BLOCK_v2"); 229 String newCacheName = cacheName + (useBlockCache() ? "_BLOCK_v2" : "_INDEX_v2"); 230 231 if (useBlockCache()) { 207 232 BlockDiskCacheAttributes blockAttr = new BlockDiskCacheAttributes(); 208 233 /* -
trunk/src/org/openstreetmap/josm/spi/lifecycle/Lifecycle.java
r16995 r17663 79 79 } 80 80 // asynchronous initializations to be completed eventually 81 initSequence.asynchronousRunnableTasks().forEach(service::submit); 82 initSequence.asynchronousCallableTasks().forEach(service::submit); 81 initSequence.asynchronousRunnableTasks().forEach(x -> { 82 if (x != null) service.submit(x); 83 }); 84 initSequence.asynchronousCallableTasks().forEach(x -> { 85 if (x != null) service.submit(x); 86 }); 83 87 try { 84 88 service.shutdown();
Note:
See TracChangeset
for help on using the changeset viewer.