本文整理匯總了Java中org.openide.util.Utilities.isWindows方法的典型用法代碼示例。如果您正苦於以下問題:Java Utilities.isWindows方法的具體用法?Java Utilities.isWindows怎麽用?Java Utilities.isWindows使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openide.util.Utilities
的用法示例。
在下文中一共展示了Utilities.isWindows方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initialize
import org.openide.util.Utilities; //導入方法依賴的package包/類
public static void initialize(String prefix, Mode mode, Set<String> allowedFiles) {
System.setProperty("counting.security.disabled", "true");
if (System.getSecurityManager() instanceof CountingSecurityManager) {
// ok
} else {
System.setSecurityManager(new CountingSecurityManager());
}
setCnt(0);
msgs = new StringWriter();
pw = new PrintWriter(msgs);
if (prefix != null && Utilities.isWindows()) {
prefix = prefix.toUpperCase();
}
CountingSecurityManager.prefix = prefix;
CountingSecurityManager.mode = mode;
allowed = allowedFiles;
Logger.getLogger("org.netbeans.TopSecurityManager").setLevel(Level.OFF);
System.setProperty("org.netbeans.TopSecurityManager.level", "3000");
System.setProperty("counting.security.disabled", "false");
}
示例2: injectEventSpy
import org.openide.util.Utilities; //導入方法依賴的package包/類
private void injectEventSpy(final BeanRunConfig clonedConfig) {
//TEMP
String mavenPath = clonedConfig.getProperties().get(CosChecker.MAVENEXTCLASSPATH);
File jar = InstalledFileLocator.getDefault().locate("maven-nblib/netbeans-eventspy.jar", "org.netbeans.modules.maven", false);
if (mavenPath == null) {
mavenPath = "";
} else {
String delimiter = Utilities.isWindows() ? ";" : ":";
if(mavenPath.contains(jar + delimiter)) {
// invoked by output view > rerun? see also issue #249971
return;
}
mavenPath = delimiter + mavenPath;
}
//netbeans-eventspy.jar comes first on classpath
mavenPath = jar.getAbsolutePath() + mavenPath;
clonedConfig.setProperty(CosChecker.MAVENEXTCLASSPATH, mavenPath);
}
示例3: isDeviceAvailable
import org.openide.util.Utilities; //導入方法依賴的package包/類
@Override
public boolean isDeviceAvailable(String deviceName) {
String p = "";
if ( Utilities.isWindows() ) {
p = deviceName;
} else if ( Utilities.isMac() || Utilities.isUnix() ) {
p = deviceName.substring( DEV_PREFFIX.length() );
}
Enumeration<CommPortIdentifier> portIdentifiers = CommPortIdentifier.getPortIdentifiers();
while (portIdentifiers.hasMoreElements()) {
CommPortIdentifier cpi = portIdentifiers.nextElement();
if ( p.equals(cpi.getName()) ) {
return isPortAvailable(cpi);
}
}
return false;
}
示例4: testRenameFolderChangeCase_FO
import org.openide.util.Utilities; //導入方法依賴的package包/類
public void testRenameFolderChangeCase_FO () throws Exception {
// prepare
File fromFolder = createFolder("folder");
File fromFile = createFile(fromFolder, "file");
File toFolder = new File(getWorkTreeDir(), "FOLDER");
File toFile = new File(toFolder, fromFile.getName());
commit(fromFolder);
// move
renameFO(fromFolder, toFolder.getName());
// test
if (Utilities.isWindows() || Utilities.isMac()) {
assertTrue(Arrays.asList(toFolder.getParentFile().list()).contains(toFolder.getName()));
assertFalse(Arrays.asList(fromFolder.getParentFile().list()).contains(fromFolder.getName()));
} else {
assertFalse(fromFolder.exists());
assertTrue(toFolder.exists());
assertTrue(toFile.exists());
assertEquals(FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY, getCache().refresh(fromFile).getStatus());
assertEquals(FileInformation.STATUS_VERSIONED_ADDEDLOCALLY, getCache().refresh(toFile).getStatus());
}
}
示例5: findCommonPrefix
import org.openide.util.Utilities; //導入方法依賴的package包/類
static int findCommonPrefix(String s1, String s2) {
if (Utilities.isWindows() || Utilities.isMac()) {
s1 = s1.toUpperCase();
s2 = s2.toUpperCase();
}
int len = Math.min(s1.length(), s2.length());
int max = 0;
for (int i = 0; i < len; i++) {
final char ch = s1.charAt(i);
if (ch != s2.charAt(i)) {
return max;
}
if (ch == '/' || ch == File.separatorChar) {
max = i + 1;
}
}
return len;
}
示例6: run
import org.openide.util.Utilities; //導入方法依賴的package包/類
private void run(File workDir, String... args) throws Exception {
URL u = Lookup.class.getProtectionDomain().getCodeSource().getLocation();
File f = Utilities.toFile(u.toURI());
assertTrue("file found: " + f, f.exists());
File nbexec = Utilities.isWindows() ? new File(f.getParent(), "nbexec.exe") : new File(f.getParent(), "nbexec");
assertTrue("nbexec found: " + nbexec, nbexec.exists());
URL tu = MainCallback.class.getProtectionDomain().getCodeSource().getLocation();
File testf = Utilities.toFile(tu.toURI());
assertTrue("file found: " + testf, testf.exists());
LinkedList<String> allArgs = new LinkedList<String>(Arrays.asList(args));
allArgs.addFirst("-J-Dnetbeans.mainclass=" + MainCallback.class.getName());
allArgs.addFirst(System.getProperty("java.home"));
allArgs.addFirst("--jdkhome");
allArgs.addFirst(getWorkDirPath());
allArgs.addFirst("--userdir");
allArgs.addFirst(testf.getPath());
allArgs.addFirst("-cp:p");
if (!Utilities.isWindows()) {
allArgs.addFirst(nbexec.getPath());
allArgs.addFirst("-x");
allArgs.addFirst("/bin/sh");
} else {
allArgs.addFirst(nbexec.getPath());
}
StringBuffer sb = new StringBuffer();
Process p = Runtime.getRuntime().exec(allArgs.toArray(new String[allArgs.size()]), new String[0], workDir);
int res = readOutput(sb, p);
String output = sb.toString();
assertEquals("Execution is ok: " + output, 0, res);
}
示例7: getAPPDATA
import org.openide.util.Utilities; //導入方法依賴的package包/類
/**
* Returns the value for the %APPDATA% env variable on windows
*
*/
private static String getAPPDATA() {
String appdata = "";
if(Utilities.isWindows()) {
appdata = System.getenv("APPDATA");// NOI18N
}
return appdata!= null? appdata: "";
}
示例8: init
import org.openide.util.Utilities; //導入方法依賴的package包/類
/** initialize object */
private void init () {
if (err.isLoggable(Level.FINE)) {
err.log(Level.FINE, getClass().getName() + " " + System.currentTimeMillis() + "> init");
}
pcs = new PropertyChangeSupport(this);
if (Utilities.isWindows()) {
pcs.addPropertyChangeListener(this);
}
}
示例9: testCreatedDeleteBrokenLinkExternally
import org.openide.util.Utilities; //導入方法依賴的package包/類
public void testCreatedDeleteBrokenLinkExternally () throws Exception {
if (Utilities.isWindows()) {
log("Skipping test " + getName() + " on Windows");
return;
}
FileObject fo = FileUtil.toFileObject(getWorkDir());
FileObject[] children = fo.getChildren(); // scan folder
FileObject folder = fo.createFolder("folder");
iListener.clear();
assertEquals(0, iListener.implsCreatedExternallyCalls);
File f = new File(FileUtil.toFile(fo), "wlock");
ProcessBuilder pb = new ProcessBuilder().directory(f.getParentFile()).command(new String[] { "ln", "-s", "doesnotexist", f.getName() });
pb.start().waitFor();
assertEquals(0, iListener.implsCreatedExternallyCalls);
fo.refresh();
assertEquals(1, iListener.implsCreatedExternallyCalls);
iListener.clear();
f.delete();
assertEquals(0, iListener.implsDeletedExternallyCalls);
fo.refresh();
assertEquals(1, iListener.implsDeletedExternallyCalls);
// let's try once more, now it starts failing
pb = new ProcessBuilder().directory(f.getParentFile()).command(new String[] { "ln", "-s", "doesnotexist", f.getName() });
pb.start().waitFor();
iListener.clear();
assertEquals(0, iListener.implsCreatedExternallyCalls);
fo.refresh();
assertEquals(1, iListener.implsCreatedExternallyCalls);
iListener.clear();
f.delete();
assertEquals(0, iListener.implsDeletedExternallyCalls);
fo.refresh();
assertEquals(1, iListener.implsDeletedExternallyCalls);
}
示例10: createHtmlBrowserImpl
import org.openide.util.Utilities; //導入方法依賴的package包/類
/**
* Returns a new instance of BrowserImpl implementation.
* @throws UnsupportedOperationException when method is called and OS is not Windows.
* @return browserImpl implementation of browser.
*/
@Override
public HtmlBrowser.Impl createHtmlBrowserImpl() {
ExtBrowserImpl impl = null;
if (Utilities.isWindows()) {
impl = new NbDdeBrowserImpl(this);
} else if (Utilities.isUnix() && !Utilities.isMac()) {
impl = new UnixBrowserImpl(this);
} else {
throw new UnsupportedOperationException (NbBundle.getMessage (MozillaBrowser.class, "MSG_CannotUseBrowser"));
}
return impl;
}
示例11: init
import org.openide.util.Utilities; //導入方法依賴的package包/類
public void init(String searchDir) {
synchronized (initLock) {
if (!Utilities.isWindows()) {
return;
}
pathConverter = new SimpleConverter();
activeShell = findShell(searchDir);
initCharset();
initialized = true;
}
}
示例12: suite
import org.openide.util.Utilities; //導入方法依賴的package包/類
public static Test suite() {
NbTestSuite ts = new NbTestSuite();
if (Utilities.isWindows()) {
for (File root : File.listRoots()) {
ts.addTest(new CreateFileOnWindowsTest(root));
}
}
return ts;
}
示例13: testRelativizeLocation
import org.openide.util.Utilities; //導入方法依賴的package包/類
public void testRelativizeLocation() throws Exception {
File srcApp = Utilities.isWindows() ? new File("c:\\src\\app") : new File("/src/app");
File srcAppFooBar = new File(srcApp, "foo" + File.separatorChar + "bar");
File projApp = Utilities.isWindows() ? new File("c:\\proj\\app") : new File("/proj/app");
File otherFooBar = Utilities.isWindows() ? new File("c:\\other\\foo\\bar") : new File("/other/foo/bar");
assertEquals("foo/bar", Util.relativizeLocation(srcApp, srcApp, srcAppFooBar));
assertEquals("${project.dir}/foo/bar", Util.relativizeLocation(srcApp, projApp, srcAppFooBar));
assertEquals(otherFooBar.getAbsolutePath(), Util.relativizeLocation(srcApp, srcApp, otherFooBar));
assertEquals(otherFooBar.getAbsolutePath(), Util.relativizeLocation(srcApp, projApp, otherFooBar));
// Mentioned incidentally in #54428:
assertEquals(".", Util.relativizeLocation(srcApp, srcApp, srcApp));
assertEquals("${project.dir}", Util.relativizeLocation(srcApp, projApp, srcApp));
}
示例14: validateFields
import org.openide.util.Utilities; //導入方法依賴的package包/類
private boolean validateFields() {
getPanel().showError(null);
String username = panel.userNameTextField.getText();
if (!HgModuleConfig.getDefault().isUserNameValid(username)) {
getPanel().showError(NbBundle.getMessage(MercurialPanel.class, "MSG_WARN_USER_NAME_TEXT")); //NOI18N
return false;
}
String execpath = panel.executablePathTextField.getText();
String hgExecutableParent = null;
if (Utilities.isWindows()) {
hgExecutableParent = getHgWindowsExecutableParent(execpath);
}
if ((hgExecutableParent == null) && execpath.endsWith(HG_COMMAND)) {
hgExecutableParent = execpath.substring(0, execpath.length() - HG_COMMAND.length());
}
if (hgExecutableParent == null) {
hgExecutableParent = execpath;
}
if (!HgModuleConfig.getDefault().isExecPathValid(hgExecutableParent)) {
getPanel().showError(NbBundle.getMessage(MercurialPanel.class, "MSG_WARN_EXEC_PATH_TEXT")); //NOI18N
return false;
}
if (!HgUtils.isAnnotationFormatValid(HgUtils.createAnnotationFormat(panel.annotationTextField.getText()))) {
getPanel().showError(NbBundle.getMessage(MercurialPanel.class, "MSG_WARN_ANNOTATION_FORMAT_TEXT")); //NOI18N
return false;
}
return true;
}
示例15: isEJDK
import org.openide.util.Utilities; //導入方法依賴的package包/類
static boolean isEJDK(@NonNull final File folder) {
//XXX: Workaround of hard NFS mounts on Solaris.
final int osId = Utilities.getOperatingSystem();
if (osId == Utilities.OS_SOLARIS || osId == Utilities.OS_SUNOS) {
return false;
}
final String jrecreateName = Utilities.isWindows() ?
"jrecreate.bat" : //NOI18N
"jrecreate.sh"; //NOI18N
final File jrecreate = new File(
new File(folder, "bin"), //NOI18N
jrecreateName);
return jrecreate.exists();
}