List of usage examples for org.apache.commons.lang SystemUtils IS_OS_MAC_OSX
boolean IS_OS_MAC_OSX
To view the source code for org.apache.commons.lang SystemUtils IS_OS_MAC_OSX.
Click Source Link
Is true
if this is Mac.
The field will return false
if OS_NAME
is null
.
From source file:results.report.java
/** * Return an HTML String with System information... * @return /*from w ww .jav a 2s.co m*/ */ public String printSystemInfo() { StringBuilder st = new StringBuilder(); st.append("<br>Compiler found: " + config.isCompilerFound() + "<br>"); st.append("Developper mode: " + config.isDevelopperMode() + "<br>"); st.append("Windows :" + SystemUtils.IS_OS_WINDOWS + "<br>"); st.append("MacOSX :" + SystemUtils.IS_OS_MAC_OSX + "<br>"); st.append("Linux :" + SystemUtils.IS_OS_LINUX + "<br>"); st.append("Memory: " + PrintMemory() + "<br >"); return st.toString(); }
From source file:sh.tak.appbundler.CreateApplicationBundleMojo.java
/** * Bundle project as a Mac OS X application bundle. * * @throws MojoExecutionException If an unexpected error occurs during * packaging of the bundle./*from www . j a va2 s .c om*/ */ public void execute() throws MojoExecutionException { // 1. Create and set up directories getLog().info("Creating and setting up the bundle directories"); buildDirectory.mkdirs(); File bundleDir = new File(buildDirectory, bundleName + ".app"); bundleDir.mkdirs(); File contentsDir = new File(bundleDir, "Contents"); contentsDir.mkdirs(); File resourcesDir = new File(contentsDir, "Resources"); resourcesDir.mkdirs(); File javaDirectory = new File(contentsDir, "Java"); javaDirectory.mkdirs(); File macOSDirectory = new File(contentsDir, "MacOS"); macOSDirectory.mkdirs(); // 2. Copy in the native java application stub getLog().info("Copying the native Java Application Stub"); File launcher = new File(macOSDirectory, javaLauncherName); launcher.setExecutable(true); FileOutputStream launcherStream = null; try { launcherStream = new FileOutputStream(launcher); } catch (FileNotFoundException ex) { throw new MojoExecutionException("Could not copy file to directory " + launcher, ex); } InputStream launcherResourceStream = this.getClass().getResourceAsStream(javaLauncherName); try { IOUtil.copy(launcherResourceStream, launcherStream); } catch (IOException ex) { throw new MojoExecutionException( "Could not copy file " + javaLauncherName + " to directory " + macOSDirectory, ex); } // 3.Copy icon file to the bundle if specified if (iconFile != null) { File f = searchFile(iconFile); if (f != null && f.exists() && f.isFile()) { getLog().info("Copying the Icon File"); try { FileUtils.copyFileToDirectory(f, resourcesDir); } catch (IOException ex) { throw new MojoExecutionException("Error copying file " + iconFile + " to " + resourcesDir, ex); } } } // 4. Resolve and copy in all dependencies from the pom getLog().info("Copying dependencies"); List<String> files = copyDependencies(javaDirectory); if (additionalBundledClasspathResources != null && !additionalBundledClasspathResources.isEmpty()) { files.addAll(copyAdditionalBundledClasspathResources(javaDirectory, "lib", additionalBundledClasspathResources)); } // 5. Check if JRE should be embedded. Check JRE path. Copy JRE if (jrePath != null) { File f = new File(jrePath); if (f.exists() && f.isDirectory()) { // Check if the source folder is a jdk-home File pluginsDirectory = new File(contentsDir, "PlugIns/JRE/Contents/Home/jre"); pluginsDirectory.mkdirs(); File sourceFolder = new File(jrePath, "Contents/Home"); if (new File(jrePath, "Contents/Home/jre").exists()) { sourceFolder = new File(jrePath, "Contents/Home/jre"); } try { getLog().info("Copying the JRE Folder from : [" + sourceFolder + "] to PlugIn folder: [" + pluginsDirectory + "]"); FileUtils.copyDirectoryStructure(sourceFolder, pluginsDirectory); File binFolder = new File(pluginsDirectory, "bin"); //Setting execute permissions on executables in JRE for (String filename : binFolder.list()) { new File(binFolder, filename).setExecutable(true, false); } new File(pluginsDirectory, "lib/jspawnhelper").setExecutable(true, false); embeddJre = true; } catch (IOException ex) { throw new MojoExecutionException("Error copying folder " + f + " to " + pluginsDirectory, ex); } } else { getLog().warn("JRE not found check jrePath setting in pom.xml"); } } // 6. Create and write the Info.plist file getLog().info("Writing the Info.plist file"); File infoPlist = new File(bundleDir, "Contents" + File.separator + "Info.plist"); this.writeInfoPlist(infoPlist, files); // 7. Copy specified additional resources into the top level directory getLog().info("Copying additional resources"); if (additionalResources != null && !additionalResources.isEmpty()) { this.copyResources(buildDirectory, additionalResources); } // 7. Make the stub executable if (!SystemUtils.IS_OS_WINDOWS) { getLog().info("Making stub executable"); Commandline chmod = new Commandline(); try { chmod.setExecutable("chmod"); chmod.createArgument().setValue("755"); chmod.createArgument().setValue(launcher.getAbsolutePath()); chmod.execute(); } catch (CommandLineException e) { throw new MojoExecutionException("Error executing " + chmod + " ", e); } } else { getLog().warn("The stub was created without executable file permissions for UNIX systems"); } // 8. Create the DMG file if (generateDiskImageFile) { if (SystemUtils.IS_OS_MAC_OSX) { getLog().info("Generating the Disk Image file"); Commandline dmg = new Commandline(); try { // user wants /Applications symlink in the resulting disk image if (includeApplicationsSymlink) { createApplicationsSymlink(); } dmg.setExecutable("hdiutil"); dmg.createArgument().setValue("create"); dmg.createArgument().setValue("-srcfolder"); dmg.createArgument().setValue(buildDirectory.getAbsolutePath()); dmg.createArgument().setValue(diskImageFile.getAbsolutePath()); try { dmg.execute().waitFor(); } catch (InterruptedException ex) { throw new MojoExecutionException( "Thread was interrupted while creating DMG " + diskImageFile, ex); } finally { if (includeApplicationsSymlink) { removeApplicationsSymlink(); } } } catch (CommandLineException ex) { throw new MojoExecutionException("Error creating disk image " + diskImageFile, ex); } if (diskImageInternetEnable) { getLog().info("Enabling the Disk Image file for internet"); try { Commandline internetEnableCommand = new Commandline(); internetEnableCommand.setExecutable("hdiutil"); internetEnableCommand.createArgument().setValue("internet-enable"); internetEnableCommand.createArgument().setValue("-yes"); internetEnableCommand.createArgument().setValue(diskImageFile.getAbsolutePath()); internetEnableCommand.execute(); } catch (CommandLineException ex) { throw new MojoExecutionException("Error internet enabling disk image: " + diskImageFile, ex); } } projectHelper.attachArtifact(project, "dmg", null, diskImageFile); } if (SystemUtils.IS_OS_LINUX) { getLog().info("Generating the Disk Image file"); Commandline linux_dmg = new Commandline(); try { linux_dmg.setExecutable("genisoimage"); linux_dmg.createArgument().setValue("-V"); linux_dmg.createArgument().setValue(bundleName); linux_dmg.createArgument().setValue("-D"); linux_dmg.createArgument().setValue("-R"); linux_dmg.createArgument().setValue("-apple"); linux_dmg.createArgument().setValue("-no-pad"); linux_dmg.createArgument().setValue("-o"); linux_dmg.createArgument().setValue(diskImageFile.getAbsolutePath()); linux_dmg.createArgument().setValue(buildDirectory.getAbsolutePath()); try { linux_dmg.execute().waitFor(); } catch (InterruptedException ex) { throw new MojoExecutionException( "Thread was interrupted while creating DMG " + diskImageFile, ex); } } catch (CommandLineException ex) { throw new MojoExecutionException( "Error creating disk image " + diskImageFile + " genisoimage probably missing", ex); } projectHelper.attachArtifact(project, "dmg", null, diskImageFile); } else { getLog().warn("Disk Image file cannot be generated in non Mac OS X and Linux environments"); } } getLog().info("App Bundle generation finished"); }
From source file:util.PosixComplianceUtil.java
private boolean isFullyPosixCompliant() { return SystemUtils.IS_OS_AIX || SystemUtils.IS_OS_HP_UX || SystemUtils.IS_OS_IRIX || SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_SOLARIS; }
From source file:VASSAL.Info.java
/** @depricated Use {@link SystemUtils.IS_OS_MAC_OSX} instead */ @Deprecated//from w ww .java 2s. c o m public static boolean isMacOSX() { return SystemUtils.IS_OS_MAC_OSX; }
From source file:VASSAL.Info.java
/** @depricated Use {@link SystemUtils.IS_OS_MAC_OSX} instead. */ @Deprecated/* ww w . j a va2s . co m*/ public static boolean isMacOsX() { return SystemUtils.IS_OS_MAC_OSX; }
From source file:VASSAL.Info.java
public static File getDocDir() { final String d = SystemUtils.IS_OS_MAC_OSX ? "Contents/Resources/doc" : "doc"; return new File(getBaseDir(), d); }
From source file:VASSAL.Info.java
public static File getHomeDir() { // FIXME: creation of VASSAL's home should be moved someplace else, possibly // to the new Application class when it's merged with the trunk. if (homeDir == null) { if (SystemUtils.IS_OS_MAC_OSX) { homeDir = new File(System.getProperty("user.home"), "Library/Application Support/VASSAL"); } else if (SystemUtils.IS_OS_WINDOWS) { homeDir = new File(System.getenv("APPDATA") + "/VASSAL"); } else {// ww w .j av a2 s. c o m homeDir = new File(System.getProperty("user.home"), ".VASSAL"); } if (!homeDir.exists()) { // FIXME: What if this fails? This should be done from someplace that // can signal failure properly. homeDir.mkdirs(); } } return homeDir; }
From source file:VASSAL.launch.Editor.java
protected MenuManager createMenuManager() { return SystemUtils.IS_OS_MAC_OSX ? new MacOSXMenuManager() : new EditorMenuManager(); }
From source file:VASSAL.launch.EditorWindow.java
protected EditorWindow() { setTitle("VASSAL " + getEditorType() + " Editor"); setLayout(new BorderLayout()); ApplicationIcons.setFor(this); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { close();/*from w w w .j a v a2s .co m*/ } }); toolBar.setFloatable(false); add(toolBar, BorderLayout.NORTH); // setup menubar and actions final MenuManager mm = MenuManager.getInstance(); final MenuBarProxy mb = mm.getMenuBarProxyFor(this); // file menu if (SystemUtils.IS_OS_MAC_OSX) { mm.addToSection("Editor.File", mm.addKey("Editor.save")); mm.addToSection("Editor.File", mm.addKey("Editor.save_as")); } else { final MenuProxy fileMenu = new MenuProxy(Resources.getString("General.file")); // FIMXE: setting nmemonic from first letter could cause collisions in // some languages fileMenu.setMnemonic(Resources.getString("General.file.shortcut").charAt(0)); fileMenu.add(mm.addKey("Editor.save")); fileMenu.add(mm.addKey("Editor.save_as")); fileMenu.addSeparator(); fileMenu.add(mm.addKey("General.quit")); mb.add(fileMenu); } // edit menu final MenuProxy editMenu = new MenuProxy(Resources.getString("General.edit")); editMenu.setMnemonic(Resources.getString("General.edit.shortcut").charAt(0)); editMenu.add(mm.addKey("Editor.cut")); editMenu.add(mm.addKey("Editor.copy")); editMenu.add(mm.addKey("Editor.paste")); editMenu.add(mm.addKey("Editor.move")); editMenu.addSeparator(); editMenu.add(mm.addKey("Editor.ModuleEditor.properties")); editMenu.add(mm.addKey("Editor.ModuleEditor.translate")); // tools menu final MenuProxy toolsMenu = new MenuProxy(Resources.getString("General.tools")); toolsMenu.setMnemonic(Resources.getString("General.tools.shortcut").charAt(0)); toolsMenu.add(mm.addKey("create_module_updater")); toolsMenu.add(mm.addKey("Editor.ModuleEditor.update_saved")); if (SystemUtils.IS_OS_MAC_OSX) { mm.addToSection("Editor.MenuBar", editMenu); mm.addToSection("Editor.MenuBar", toolsMenu); } else { mb.add(editMenu); mb.add(toolsMenu); } // help menu if (SystemUtils.IS_OS_MAC_OSX) { mm.addToSection("Documentation.VASSAL", mm.addKey("Editor.ModuleEditor.reference_manual")); } else { final MenuProxy helpMenu = new MenuProxy(Resources.getString("General.help")); // FIMXE: setting nmemonic from first letter could cause collisions in // some languages helpMenu.setMnemonic(Resources.getString("General.help.shortcut").charAt(0)); helpMenu.add(mm.addKey("General.help")); helpMenu.add(mm.addKey("Editor.ModuleEditor.reference_manual")); helpMenu.addSeparator(); helpMenu.add(mm.addKey("AboutScreen.about_vassal")); mb.add(helpMenu); } final int mask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); saveAction = new SaveAction() { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { save(); treeStateChanged(false); } }; saveAction.setEnabled(false); saveAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, mask)); mm.addAction("Editor.save", saveAction); toolBar.add(saveAction); saveAsAction = new SaveAsAction() { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { saveAs(); treeStateChanged(false); } }; saveAsAction.setEnabled(false); saveAsAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_A, mask)); mm.addAction("Editor.save_as", saveAsAction); toolBar.add(saveAsAction); mm.addAction("General.quit", new ShutDownAction()); // FXIME: mnemonics should be language-dependant // mm.getAction("General.quit").setMnemonic('Q'); createUpdater = new AbstractAction("Create " + getEditorType() + " updater") { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { new ModuleUpdaterDialog(EditorWindow.this).setVisible(true); } }; createUpdater.setEnabled(false); mm.addAction("create_module_updater", createUpdater); URL url = null; try { url = new File(Documentation.getDocumentationBaseDir(), "README.html").toURI().toURL(); } catch (MalformedURLException e) { ErrorDialog.bug(e); } mm.addAction("General.help", new ShowHelpAction(url, null)); url = null; try { File dir = VASSAL.build.module.Documentation.getDocumentationBaseDir(); dir = new File(dir, "ReferenceManual/index.htm"); //$NON-NLS-1$ url = URLUtils.toURL(dir); } catch (MalformedURLException e) { ErrorDialog.bug(e); } final Action helpAction = new ShowHelpAction(url, helpWindow.getClass().getResource("/images/Help16.gif")); //$NON-NLS-1$ helpAction.putValue(Action.SHORT_DESCRIPTION, Resources.getString("Editor.ModuleEditor.reference_manual")); //$NON-NLS-1$ mm.addAction("Editor.ModuleEditor.reference_manual", helpAction); toolBar.add(helpAction); mm.addAction("AboutScreen.about_vassal", new AboutVASSALAction(this)); setJMenuBar(mm.getMenuBarFor(this)); // the presence of the panel prevents a NullPointerException on packing final JPanel panel = new JPanel(); panel.setPreferredSize(new Dimension(250, 400)); scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); add(scrollPane, BorderLayout.CENTER); pack(); }
From source file:VASSAL.launch.Launcher.java
protected Launcher(String[] args) { if (instance != null) throw new IllegalStateException(); instance = this; LaunchRequest lreq = null;/*w w w . ja v a2 s . co m*/ try { lreq = LaunchRequest.parseArgs(args); } catch (LaunchRequestException e) { System.err.println("VASSAL: " + e.getMessage()); System.exit(1); } lr = lreq; // Note: We could do more sanity checking of the launch request // in standalone mode, but we don't bother because this is meant // only for debugging, not for normal use. If you pass nonsense // arguments (e.g., '-e' to the Player), don't expect it to work. final boolean standalone = lr.standalone; /* // parse the command line args now if we're standalone, since they // could be messed up and so we'll bail before setup LaunchRequest lr = null; if (standalone) { // Note: We could do more sanity checking of the launch request // in standalone mode, but we don't bother because this is meant // only for debugging, not for normal use. If you pass nonsense // arguments (e.g., '-e' to the Player), don't expect it to work. try { lr = LaunchRequest.parseArgs(args); } catch (LaunchRequestException e) { System.err.println("VASSAL: " + e.getMessage()); System.exit(1); } } */ // start the error log and setup system properties final StartUp start = SystemUtils.IS_OS_MAC_OSX ? new MacOSXStartUp() : new StartUp(); start.startErrorLog(); // log everything which comes across our stderr System.setErr(new PrintStream(new LoggedOutputStream(), true)); logger.info(getClass().getSimpleName()); Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler()); start.initSystemProperties(); // if we're not standalone, contact the module manager for instructions if (!standalone) { try { final int port = Integer.parseInt(System.getProperty("VASSAL.port")); final InetAddress lo = InetAddress.getByName(null); final Socket cs = new Socket(lo, port); ipc = new IPCMessenger(cs); ipc.addEventListener(CloseRequest.class, new CloseRequestListener()); ipc.start(); ipc.send(new StartedNotice(Info.getInstanceID())); } catch (IOException e) { // What we've got here is failure to communicate. ErrorDialog.show(e, "Error.communication_error", Resources.getString(getClass().getSimpleName() + ".app_name")); System.exit(1); } } createMenuManager(); SwingUtilities.invokeLater(new Runnable() { public void run() { try { launch(); } catch (ExtensionsLoader.LoadExtensionException e2) { warn(e2); } catch (IOException e1) { warn(e1); } } private void warn(Exception e1) { if (ipc == null) { // we are standalone, so warn the user directly ErrorDialog.showDetails(e1, ThrowableUtils.getStackTrace(e1), "Error.module_load_failed", e1.getMessage()); } else { // we have a manager, so pass the load failure back to it try { ipc.send(new AbstractLaunchAction.NotifyOpenModuleFailed(lr, e1)); } catch (IOException e2) { // warn the user directly as a last resort ErrorDialog.showDetails(e1, ThrowableUtils.getStackTrace(e1), "Error.module_load_failed", e1.getMessage()); ErrorDialog.show(e2, "Error.communication_error", Resources.getString(getClass().getSimpleName() + ".app_name")); } } System.exit(1); } }); }