Java Code Examples for org.openide.util.BaseUtilities#isMac()

The following examples show how to use org.openide.util.BaseUtilities#isMac() . 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 vote down vote up
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: NbClipboardTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testDefaultOnJDK15AndLater() throws Exception {
    if (BaseUtilities.isMac()) {
        macCheck();
    } else {
        NbClipboard ec = new NbClipboard();
        assertTrue("By default we use slow hacks", ec.slowSystemClipboard);
    }
}
 
Example 3
Source File: CoreBridge.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * 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: LocalFileSystem.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected OutputStream outputStream(final String name) throws java.io.IOException {
    File f = getFile(name);
    if (!f.exists()) {
        f.getParentFile().mkdirs();
    }
    OutputStream retVal = new BufferedOutputStream(new FileOutputStream(f));

    // workaround for #42624
    if (BaseUtilities.isMac()) {
        retVal = getOutputStreamForMac42624(retVal, name);
    }

    return retVal;
}
 
Example 5
Source File: StandardModule.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Look up a native library as described in modules documentation.
 * @see http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/api.html#jni
 */
protected @Override String findLibrary(String libname) {
    InstalledFileLocator ifl = InstalledFileLocator.getDefault();
    String arch = System.getProperty("os.arch"); // NOI18N
    String system = System.getProperty("os.name").toLowerCase(Locale.ENGLISH); // NOI18N
    String mapped = System.mapLibraryName(libname);
    File lib;

    lib = ifl.locate("modules/lib/" + mapped, getCodeNameBase(), false); // NOI18N
    if (lib != null) {
        CL_LOG.log(Level.FINE, "found {0}", lib);
        return lib.getAbsolutePath();
    }

    lib = ifl.locate("modules/lib/" + arch + "/" + mapped, getCodeNameBase(), false); // NOI18N
    if (lib != null) {
        CL_LOG.log(Level.FINE, "found {0}", lib);
        return lib.getAbsolutePath();
    }

    lib = ifl.locate("modules/lib/" + arch + "/" + system + "/" + mapped, getCodeNameBase(), false); // NOI18N
    if (lib != null) {
        CL_LOG.log(Level.FINE, "found {0}", lib);
        return lib.getAbsolutePath();
    }
    
    if( BaseUtilities.isMac() ) {
        String jniMapped = mapped.replaceFirst("\\.dylib$",".jnilib");
        lib = ifl.locate("modules/lib/" + jniMapped, getCodeNameBase(), false); // NOI18N
        if (lib != null) {
            CL_LOG.log(Level.FINE, "found {0}", lib);
            return lib.getAbsolutePath();
        }

        lib = ifl.locate("modules/lib/" + arch + "/" + jniMapped, getCodeNameBase(), false); // NOI18N
        if (lib != null) {
            CL_LOG.log(Level.FINE, "found {0}", lib);
            return lib.getAbsolutePath();
        }

        lib = ifl.locate("modules/lib/" + arch + "/" + system + "/" + jniMapped, getCodeNameBase(), false); // NOI18N
        if (lib != null) {
            CL_LOG.log(Level.FINE, "found {0}", lib);
            return lib.getAbsolutePath();
        }
        CL_LOG.log(Level.FINE, "found nothing like modules/lib/{0}/{1}/{2}", new Object[] {arch, system, jniMapped});
    }

    CL_LOG.log(Level.FINE, "found nothing like modules/lib/{0}/{1}/{2}", new Object[] {arch, system, mapped});
    return null;
}
 
Example 6
Source File: FileObjectFactory.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public boolean isWarningEnabled() {
    return WARNINGS && !BaseUtilities.isMac();
}
 
Example 7
Source File: FileUtil.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** 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();
        }
    }
}