Changeset 12776 in josm
- Timestamp:
- 2017-09-07T23:41:42+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r12755 r12776 54 54 import org.openstreetmap.josm.tools.JosmRuntimeException; 55 55 import org.openstreetmap.josm.tools.Logging; 56 import org.openstreetmap.josm.tools.Platform; 56 57 import org.openstreetmap.josm.tools.PlatformHook; 57 58 import org.openstreetmap.josm.tools.PlatformHookOsx; … … 772 773 */ 773 774 public static void determinePlatformHook() { 774 String os = System.getProperty("os.name"); 775 if (os == null) { 776 Logging.warn("Your operating system has no name, so I'm guessing its some kind of *nix."); 777 platform = new PlatformHookUnixoid(); 778 } else if (os.toLowerCase(Locale.ENGLISH).startsWith("windows")) { 779 platform = new PlatformHookWindows(); 780 } else if ("Linux".equals(os) || "Solaris".equals(os) || 781 "SunOS".equals(os) || "AIX".equals(os) || 782 "FreeBSD".equals(os) || "NetBSD".equals(os) || "OpenBSD".equals(os)) { 783 platform = new PlatformHookUnixoid(); 784 } else if (os.toLowerCase(Locale.ENGLISH).startsWith("mac os x")) { 785 platform = new PlatformHookOsx(); 786 } else { 787 Logging.warn("I don't know your operating system '"+os+"', so I'm guessing its some kind of *nix."); 788 platform = new PlatformHookUnixoid(); 789 } 775 platform = Platform.determinePlatform().accept(PlatformHook.CONSTRUCT_FROM_PLATFORM); 790 776 } 791 777 -
trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFileWrapper.java
r11642 r12776 5 5 import java.io.IOException; 6 6 import java.io.InputStream; 7 import java.util.Arrays; 8 import java.util.Collections; 9 import java.util.List; 7 10 8 11 import org.openstreetmap.josm.Main; 9 12 import org.openstreetmap.josm.io.CachedFile; 13 import org.openstreetmap.josm.tools.Platform; 14 import org.openstreetmap.josm.tools.PlatformVisitor; 10 15 11 16 /** … … 29 34 30 35 /** 36 * Lists default directories where the ntv2 shift files (NAD) for the proj4 37 * library would be located on different platforms. 38 */ 39 public static final PlatformVisitor<List<File>> DEFAULT_PROJ4_NTV2_SHIFT_DIRS = 40 new PlatformVisitor<List<File>>() { 41 @Override 42 public List<File> visitUnixoid() { 43 return Arrays.asList(new File("/usr/local/share/proj"), new File("/usr/share/proj")); 44 } 45 46 @Override 47 public List<File> visitWindows() { 48 return Arrays.asList(new File("C:\\PROJ\\NAD")); 49 } 50 51 @Override 52 public List<File> visitOsx() { 53 return Collections.emptyList(); 54 } 55 }; 56 57 /** 31 58 * Returns the actual {@link NTV2GridShiftFile} behind this wrapper. 32 59 * The grid file is only loaded once, when first accessed. … … 38 65 File grid = null; 39 66 // Check is the grid is installed in default PROJ.4 directories 40 for (File dir : Main.platform.getDefaultProj4NadshiftDirectories()) {67 for (File dir : Platform.determinePlatform().accept(DEFAULT_PROJ4_NTV2_SHIFT_DIRS)) { 41 68 File file = new File(dir, gridFileName); 42 69 if (file.exists() && file.isFile()) { -
trunk/src/org/openstreetmap/josm/tools/PlatformHook.java
r12748 r12776 20 20 21 21 import org.openstreetmap.josm.Main; 22 import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileWrapper; 22 23 import org.openstreetmap.josm.io.CertificateAmendment.CertAmend; 23 24 import org.openstreetmap.josm.tools.date.DateUtils; … … 29 30 */ 30 31 public interface PlatformHook { 32 33 /** 34 * Visitor to construct a PlatformHook from a given {@link Platform} object. 35 */ 36 public static final PlatformVisitor<PlatformHook> CONSTRUCT_FROM_PLATFORM = new PlatformVisitor<PlatformHook>() { 37 @Override 38 public PlatformHook visitUnixoid() { 39 return new PlatformHookUnixoid(); 40 } 41 42 @Override 43 public PlatformHook visitWindows() { 44 return new PlatformHookWindows(); 45 } 46 47 @Override 48 public PlatformHook visitOsx() { 49 return new PlatformHookUnixoid(); 50 } 51 }; 52 53 /** 54 * Get the platform corresponding to this platform hook. 55 * @return the platform corresponding to this platform hook 56 */ 57 Platform getPlatform(); 31 58 32 59 /** … … 231 258 * @since 11642 232 259 */ 233 List<File> getDefaultProj4NadshiftDirectories(); 260 default List<File> getDefaultProj4NadshiftDirectories() { 261 return getPlatform().accept(NTV2GridShiftFileWrapper.DEFAULT_PROJ4_NTV2_SHIFT_DIRS); 262 } 234 263 235 264 /** -
trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
r12748 r12776 15 15 import java.lang.reflect.Proxy; 16 16 import java.util.Arrays; 17 import java.util.Collections;18 17 import java.util.List; 19 18 import java.util.Objects; … … 32 31 33 32 private NativeOsCallback osCallback; 33 34 @Override 35 public Platform getPlatform() { 36 return Platform.OSX; 37 } 34 38 35 39 @Override … … 423 427 Main.pref.getJOSMDirectoryBaseName()); 424 428 } 425 426 @Override427 public List<File> getDefaultProj4NadshiftDirectories() {428 return Collections.emptyList();429 }430 429 } -
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r12620 r12776 22 22 import java.security.cert.X509Certificate; 23 23 import java.util.Arrays; 24 import java.util.List;25 24 import java.util.Locale; 26 25 … … 66 65 "尚未安裝" // zh_TW 67 66 }; 67 68 @Override 69 public Platform getPlatform() { 70 return Platform.UNIXOID; 71 } 68 72 69 73 @Override … … 422 426 423 427 @Override 424 public List<File> getDefaultProj4NadshiftDirectories() {425 return Arrays.asList(new File("/usr/local/share/proj"), new File("/usr/share/proj"));426 }427 428 @Override429 428 public X509Certificate getX509Certificate(CertAmend certAmend) 430 429 throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException { -
trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
r12744 r12776 58 58 import java.security.spec.X509EncodedKeySpec; 59 59 import java.util.ArrayList; 60 import java.util.Arrays;61 60 import java.util.Collection; 62 61 import java.util.Enumeration; … … 155 154 156 155 private String oSBuildNumber; 156 157 @Override 158 public Platform getPlatform() { 159 return Platform.WINDOWS; 160 } 157 161 158 162 @Override … … 673 677 return def; 674 678 } 675 676 @Override677 public List<File> getDefaultProj4NadshiftDirectories() {678 return Arrays.asList(new File("C:\\PROJ\\NAD"));679 }680 679 }
Note:
See TracChangeset
for help on using the changeset viewer.