Java Code Examples for org.openide.util.BaseUtilities#getOperatingSystem()
The following examples show how to use
org.openide.util.BaseUtilities#getOperatingSystem() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileUtil.java From netbeans with Apache License 2.0 | 6 votes |
private static File normalizeFileImpl(File file) { // XXX should use NIO in JDK 7; see #6358641 Parameters.notNull("file", file); //NOI18N File retFile; LOG.log(Level.FINE, "FileUtil.normalizeFile for {0}", file); // NOI18N long now = System.currentTimeMillis(); if ((BaseUtilities.isWindows() || (BaseUtilities.getOperatingSystem() == BaseUtilities.OS_OS2))) { retFile = normalizeFileOnWindows(file); } else if (BaseUtilities.isMac()) { retFile = normalizeFileOnMac(file); } else { retFile = normalizeFileOnUnixAlike(file); } File ret = (file.getPath().equals(retFile.getPath())) ? file : retFile; long took = System.currentTimeMillis() - now; if (took > 500) { LOG.log(Level.WARNING, "FileUtil.normalizeFile({0}) took {1} ms. Result is {2}", new Object[]{file, took, ret}); } return ret; }
Example 2
Source File: NbMutexEventProvider.java From netbeans with Apache License 2.0 | 5 votes |
/** @return true iff current thread is EventDispatchThread */ private static boolean isDispatchThread() { boolean dispatch = EventQueue.isDispatchThread(); if (!dispatch && (BaseUtilities.getOperatingSystem() == BaseUtilities.OS_SOLARIS)) { // on solaris the event queue is not always recognized correctly // => try to guess by name dispatch = (Thread.currentThread().getClass().getName().indexOf("EventDispatchThread") >= 0); // NOI18N } return dispatch; }
Example 3
Source File: CoreBridge.java From netbeans with Apache License 2.0 | 5 votes |
/** * Define {@code org.openide.modules.os.*} tokens according to the current platform. * @param provides a collection that may be added to */ public static void defineOsTokens(Collection<? super String> provides) { if (BaseUtilities.isUnix()) { provides.add("org.openide.modules.os.Unix"); // NOI18N if (!BaseUtilities.isMac()) { provides.add("org.openide.modules.os.PlainUnix"); // NOI18N } } if (BaseUtilities.isWindows()) { provides.add("org.openide.modules.os.Windows"); // NOI18N } if (BaseUtilities.isMac()) { provides.add("org.openide.modules.os.MacOSX"); // NOI18N } if ((BaseUtilities.getOperatingSystem() & BaseUtilities.OS_OS2) != 0) { provides.add("org.openide.modules.os.OS2"); // NOI18N } if ((BaseUtilities.getOperatingSystem() & BaseUtilities.OS_LINUX) != 0) { provides.add("org.openide.modules.os.Linux"); // NOI18N } if ((BaseUtilities.getOperatingSystem() & BaseUtilities.OS_SOLARIS) != 0) { provides.add("org.openide.modules.os.Solaris"); // NOI18N } if (isJavaFX(new File(System.getProperty("java.home")))) { provides.add("org.openide.modules.jre.JavaFX"); // NOI18N } }
Example 4
Source File: AbstractFolder.java From netbeans with Apache License 2.0 | 5 votes |
private final AbstractFolder getChild(String name, boolean onlyValid) { Reference<AbstractFolder> r = map.get(name); if (r == null) { //On OpenVMS, see if the name is stored in a different case //to work around a JVM bug. // if (BaseUtilities.getOperatingSystem() == BaseUtilities.OS_VMS) { if (Character.isLowerCase(name.charAt(0))) { r = map.get(name.toUpperCase()); } else { r = map.get(name.toLowerCase()); } if (r == null) { return null; } } else { return null; } } AbstractFolder fo = r.get(); if (fo == null) { // object does not exist => have to recreate it fo = createFile(name); if ((fo != null) && fo.isValid()) { map.put(name, (fo != null) ? createReference(fo) : null); } else { if (onlyValid) { fo = null; } } } return fo; }
Example 5
Source File: SettingsType.java From netbeans with Apache License 2.0 | 5 votes |
private boolean isApplicableForThisTargetOs(Object targetOs) throws NoSuchFieldException, IllegalAccessException { if (targetOs instanceof Boolean) { return ((Boolean) targetOs).booleanValue(); } else if (targetOs instanceof String) { // XXX FIXME - reflective access to Utilities Field field = BaseUtilities.class.getDeclaredField((String) targetOs); int targetOsMask = field.getInt(null); int currentOsId = BaseUtilities.getOperatingSystem(); return (currentOsId & targetOsMask) != 0; } else { return false; } }
Example 6
Source File: DockerSupport.java From netbeans with Apache License 2.0 | 5 votes |
public boolean isSocketSupported() { if (BaseUtilities.getOperatingSystem() != BaseUtilities.OS_LINUX && BaseUtilities.getOperatingSystem() != BaseUtilities.OS_MAC) { return false; } String arch = System.getProperty("os.arch"); // NOI18N return arch != null && (arch.contains("x86") || arch.contains("amd64")); // NOI18N }
Example 7
Source File: Attributes.java From netbeans with Apache License 2.0 | 4 votes |
private String preparePrefix(File fileSystemRoot) { fileSystemRoot = FileUtil.normalizeFile(fileSystemRoot); String rootPath = fileSystemRoot.getAbsolutePath().replace('\\', '/'); return ((BaseUtilities.isWindows () || (BaseUtilities.getOperatingSystem () == BaseUtilities.OS_OS2))) ? rootPath.toLowerCase() : rootPath; }
Example 8
Source File: FileUtil.java From netbeans with Apache License 2.0 | 4 votes |
/** Test if given name is free in given folder. * @param fo folder to check in * @param name name of the file or folder to check * @param ext extension of the file (null for folders) * @return true, if such name does not exists */ private static boolean checkFreeName(FileObject fo, String name, String ext) { if ((BaseUtilities.isWindows() || (BaseUtilities.getOperatingSystem() == BaseUtilities.OS_OS2)) || BaseUtilities.isMac()) { // case-insensitive, do some special check Enumeration<? extends FileObject> en = fo.getChildren(false); while (en.hasMoreElements()) { fo = en.nextElement(); String n = fo.getName(); String e = fo.getExt(); // different names => check others if (!n.equalsIgnoreCase(name)) { continue; } // same name + without extension => no if (((ext == null) || (ext.trim().length() == 0)) && ((e == null) || (e.trim().length() == 0))) { return fo.isVirtual(); } // one of there is witout extension => check next if ((ext == null) || (e == null)) { continue; } if (ext.equalsIgnoreCase(e)) { // same name + same extension => no return fo.isVirtual(); } } // no of the files has similar name and extension return true; } else { if (ext == null) { fo = fo.getFileObject(name); if (fo == null) { return true; } return fo.isVirtual(); } else { fo = fo.getFileObject(name, ext); if (fo == null) { return true; } return fo.isVirtual(); } } }
Example 9
Source File: LocalFileSystem.java From netbeans with Apache License 2.0 | 3 votes |
/** Compute the system name of this filesystem for a given root directory. * <P> * The default implementation simply returns the filename separated by slashes. * @see FileSystem#setSystemName * @param rootFile root directory for the filesystem * @return system name for the filesystem */ protected String computeSystemName(File rootFile) { String retVal = rootFile.getAbsolutePath().replace(File.separatorChar, '/'); return ((BaseUtilities.isWindows() || (BaseUtilities.getOperatingSystem() == BaseUtilities.OS_OS2))) ? retVal.toLowerCase() : retVal; }