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:VASSAL.launch.ModuleManager.java
public ModuleManager(ServerSocket serverSocket, long key, FileOutputStream lout, FileLock lock) throws IOException { if (instance != null) throw new IllegalStateException(); instance = this; this.serverSocket = serverSocket; this.key = key; // we hang on to these to prevent the lock from being lost this.lout = lout; this.lock = lock; // truncate the errorLog final File errorLog = new File(Info.getHomeDir(), "errorLog"); new FileOutputStream(errorLog).close(); final StartUp start = SystemUtils.IS_OS_MAC_OSX ? new ModuleManagerMacOSXStartUp() : new StartUp(); start.startErrorLog();//www . ja v a2 s. c o m // log everything which comes across our stderr System.setErr(new PrintStream(new LoggedOutputStream(), true)); Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler()); start.initSystemProperties(); // check whether we need to migrate pre-3.2 preferences final File oldprefs = new File(System.getProperty("user.home"), "VASSAL/Preferences"); if (oldprefs.exists()) { final File newprefs = new File(Info.getHomeDir(), "Preferences"); if (!newprefs.exists()) { FileUtils.copyFile(oldprefs, newprefs); } } if (SystemUtils.IS_OS_MAC_OSX) new MacOSXMenuManager(); else new ModuleManagerMenuManager(); SwingUtilities.invokeLater(new Runnable() { public void run() { launch(); } }); // ModuleManagerWindow.getInstance() != null now, so listen on the socket new Thread(new SocketListener(serverSocket), "socket listener").start(); final Prefs globalPrefs = Prefs.getGlobalPrefs(); // determine when we should next check on the current version of VASSAL final LongConfigurer nextVersionCheckConfig = new LongConfigurer(NEXT_VERSION_CHECK, null, -1L); globalPrefs.addOption(null, nextVersionCheckConfig); long nextVersionCheck = nextVersionCheckConfig.getLongValue(-1L); if (nextVersionCheck < System.currentTimeMillis()) { new UpdateCheckRequest().execute(); } // set the time for the next version check if (nextVersionCheck == -1L) { // this was our first check; randomly check after 0-10 days to // to spread version checks evenly over a 10-day period nextVersionCheck = System.currentTimeMillis() + (long) (Math.random() * 10 * 86400000); } else { // check again in 10 days nextVersionCheck += 10 * 86400000; } nextVersionCheckConfig.setValue(nextVersionCheck); // FIXME: the importer heap size configurers don't belong here // the initial heap size for the module importer final IntConfigurer initHeapConf = new IntConfigurer(INITIAL_HEAP, Resources.getString("GlobalOptions.initial_heap"), //$NON-NLS-1$ Integer.valueOf(256)); globalPrefs.addOption("Importer", initHeapConf); // the maximum heap size for the module importer final IntConfigurer maxHeapConf = new IntConfigurer(MAXIMUM_HEAP, Resources.getString("GlobalOptions.maximum_heap"), //$NON-NLS-1$ Integer.valueOf(512)); globalPrefs.addOption("Importer", maxHeapConf); /* final InetAddress lo = InetAddress.getByName(null); signalServerSocket = new ServerSocket(0, 0, lo); final MultiplexedSignalSource mss = new DefaultMultiplexedSignalSource(); final SignalDispatcher sd = new SignalDispatcher(mss); sd.addEventListener( AbstractLaunchAction.NotifyOpenModuleOk.class, new AbstractLaunchAction.NotifyOpenModuleOkListener() ); sd.addEventListener( AbstractLaunchAction.NotifyNewModuleOk.class, new AbstractLaunchAction.NotifyNewModuleOkListener() ); sd.addEventListener( AbstractLaunchAction.NotifyImportModuleOk.class, new AbstractLaunchAction.NotifyImportModuleOkListener() ); sd.addEventListener( AbstractLaunchAction.NotifyOpenModuleFailed.class, new AbstractLaunchAction.NotifyOpenModuleFailedListener() ); sd.addEventListener( AbstractLaunchAction.NotifySaveFileOk.class, new AbstractLaunchAction.NotifySaveFileOkListener() ); final SignalSender ss = new SignalSender(); signalServer = new SignalServer(signalServerSocket, mss, sd, ss); new Thread(signalServer, "comm server").start(); */ }
From source file:VASSAL.launch.ModuleManagerWindow.java
public ModuleManagerWindow() { setTitle("VASSAL"); setLayout(new BoxLayout(getContentPane(), BoxLayout.X_AXIS)); ApplicationIcons.setFor(this); final AbstractAction shutDownAction = new AbstractAction() { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { if (!AbstractLaunchAction.shutDown()) return; final Prefs gl = Prefs.getGlobalPrefs(); try { gl.write();/*from ww w. ja v a2 s.c o m*/ gl.close(); } catch (IOException ex) { WriteErrorDialog.error(ex, gl.getFile()); } finally { IOUtils.closeQuietly(gl); } logger.info("Exiting"); System.exit(0); } }; shutDownAction.putValue(Action.NAME, Resources.getString(Resources.QUIT)); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { shutDownAction.actionPerformed(null); } }); // setup menubar and actions final MenuManager mm = MenuManager.getInstance(); final MenuBarProxy mb = mm.getMenuBarProxyFor(this); // file menu final MenuProxy fileMenu = new MenuProxy(Resources.getString("General.file")); fileMenu.setMnemonic(Resources.getString("General.file.shortcut").charAt(0)); fileMenu.add(mm.addKey("Main.play_module")); fileMenu.add(mm.addKey("Main.edit_module")); fileMenu.add(mm.addKey("Main.new_module")); fileMenu.add(mm.addKey("Main.import_module")); fileMenu.addSeparator(); if (!SystemUtils.IS_OS_MAC_OSX) { fileMenu.add(mm.addKey("Prefs.edit_preferences")); fileMenu.addSeparator(); fileMenu.add(mm.addKey("General.quit")); } // tools menu final MenuProxy toolsMenu = new MenuProxy(Resources.getString("General.tools")); // Initialize Global Preferences Prefs.getGlobalPrefs().getEditor().initDialog(this); Prefs.initSharedGlobalPrefs(); final BooleanConfigurer serverStatusConfig = new BooleanConfigurer(SHOW_STATUS_KEY, null, Boolean.FALSE); Prefs.getGlobalPrefs().addOption(null, serverStatusConfig); dividerLocationConfig = new IntConfigurer(DIVIDER_LOCATION_KEY, null, -10); Prefs.getGlobalPrefs().addOption(null, dividerLocationConfig); toolsMenu.add(new CheckBoxMenuItemProxy(new AbstractAction(Resources.getString("Chat.server_status")) { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { serverStatusView.toggleVisibility(); serverStatusConfig.setValue(serverStatusConfig.booleanValue() ? Boolean.FALSE : Boolean.TRUE); if (serverStatusView.isVisible()) { setDividerLocation(getPreferredDividerLocation()); } } }, serverStatusConfig.booleanValue())); // help menu final MenuProxy helpMenu = new MenuProxy(Resources.getString("General.help")); helpMenu.setMnemonic(Resources.getString("General.help.shortcut").charAt(0)); helpMenu.add(mm.addKey("General.help")); helpMenu.add(mm.addKey("Main.tour")); helpMenu.addSeparator(); helpMenu.add(mm.addKey("UpdateCheckAction.update_check")); helpMenu.add(mm.addKey("Help.error_log")); if (!SystemUtils.IS_OS_MAC_OSX) { helpMenu.addSeparator(); helpMenu.add(mm.addKey("AboutScreen.about_vassal")); } mb.add(fileMenu); mb.add(toolsMenu); mb.add(helpMenu); // add actions mm.addAction("Main.play_module", new Player.PromptLaunchAction(this)); mm.addAction("Main.edit_module", new Editor.PromptLaunchAction(this)); mm.addAction("Main.new_module", new Editor.NewModuleLaunchAction(this)); mm.addAction("Main.import_module", new Editor.PromptImportLaunchAction(this)); mm.addAction("Prefs.edit_preferences", Prefs.getGlobalPrefs().getEditor().getEditAction()); mm.addAction("General.quit", shutDownAction); 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)); mm.addAction("Main.tour", new LaunchTourAction(this)); mm.addAction("AboutScreen.about_vassal", new AboutVASSALAction(this)); mm.addAction("UpdateCheckAction.update_check", new UpdateCheckAction(this)); mm.addAction("Help.error_log", new ShowErrorLogAction(this)); setJMenuBar(mm.getMenuBarFor(this)); // Load Icons moduleIcon = new ImageIcon(getClass().getResource("/images/mm-module.png")); activeExtensionIcon = new ImageIcon(getClass().getResource("/images/mm-extension-active.png")); inactiveExtensionIcon = new ImageIcon(getClass().getResource("/images/mm-extension-inactive.png")); openGameFolderIcon = new ImageIcon(getClass().getResource("/images/mm-gamefolder-open.png")); closedGameFolderIcon = new ImageIcon(getClass().getResource("/images/mm-gamefolder-closed.png")); fileIcon = new ImageIcon(getClass().getResource("/images/mm-file.png")); // build module controls final JPanel moduleControls = new JPanel(new BorderLayout()); modulePanelLayout = new CardLayout(); moduleView = new JPanel(modulePanelLayout); buildTree(); final JScrollPane scroll = new JScrollPane(tree); moduleView.add(scroll, "modules"); final JEditorPane l = new JEditorPane("text/html", Resources.getString("ModuleManager.quickstart")); l.setEditable(false); // Try to get background color and font from LookAndFeel; // otherwise, use dummy JLabel to get color and font. Color bg = UIManager.getColor("control"); Font font = UIManager.getFont("Label.font"); if (bg == null || font == null) { final JLabel dummy = new JLabel(); if (bg == null) bg = dummy.getBackground(); if (font == null) font = dummy.getFont(); } l.setBackground(bg); ((HTMLEditorKit) l.getEditorKit()).getStyleSheet() .addRule("body { font: " + font.getFamily() + " " + font.getSize() + "pt }"); l.addHyperlinkListener(BrowserSupport.getListener()); // FIXME: use MigLayout for this! // this is necessary to get proper vertical alignment final JPanel p = new JPanel(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.CENTER; p.add(l, c); moduleView.add(p, "quickStart"); modulePanelLayout.show(moduleView, getModuleCount() == 0 ? "quickStart" : "modules"); moduleControls.add(moduleView, BorderLayout.CENTER); moduleControls.setBorder(new TitledBorder(Resources.getString("ModuleManager.recent_modules"))); add(moduleControls); // build server status controls final ServerStatusView serverStatusControls = new ServerStatusView(new CgiServerStatus()); serverStatusControls.setBorder(new TitledBorder(Resources.getString("Chat.server_status"))); serverStatusView = new ComponentSplitter().splitRight(moduleControls, serverStatusControls, false); serverStatusView.revalidate(); // show the server status controls according to the prefs if (serverStatusConfig.booleanValue()) { serverStatusView.showComponent(); } setDividerLocation(getPreferredDividerLocation()); serverStatusView.addPropertyChangeListener("dividerLocation", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { setPreferredDividerLocation((Integer) e.getNewValue()); } }); final Rectangle r = Info.getScreenBounds(this); serverStatusControls.setPreferredSize(new Dimension((int) (r.width / 3.5), 0)); setSize(3 * r.width / 4, 3 * r.height / 4); // Save/load the window position and size in prefs final PositionOption option = new PositionOption(PositionOption.key + "ModuleManager", this); Prefs.getGlobalPrefs().addOption(option); }
From source file:VASSAL.launch.Player.java
protected MenuManager createMenuManager() { return SystemUtils.IS_OS_MAC_OSX ? new MacOSXMenuManager() : new PlayerMenuManager(); }
From source file:VASSAL.launch.PlayerWindow.java
public PlayerWindow() { setTitle("VASSAL"); setLayout(new BorderLayout()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ApplicationIcons.setFor(this); // setup menubar and actions final MenuManager mm = MenuManager.getInstance(); final MenuBarProxy mb = mm.getMenuBarProxyFor(this); // file menu//from ww w . j a va 2 s.com final MenuProxy fileMenu = new MenuProxy(Resources.getString("General.file")); fileMenu.setMnemonic(Resources.getString("General.file.shortcut").charAt(0)); fileMenu.add(mm.addMarker("PredefinedSetup.start")); fileMenu.add(mm.addMarker("PredefinedSetup.end")); fileMenu.add(mm.addKey("GameState.new_game")); fileMenu.add(mm.addKey("GameState.load_game")); fileMenu.add(mm.addKey("GameState.save_game")); fileMenu.add(mm.addKey("GameState.close_game")); fileMenu.addSeparator(); fileMenu.add(mm.addKey("BasicLogger.begin_logfile")); fileMenu.add(mm.addKey("BasicLogger.end_logfile")); if (SystemUtils.IS_OS_MAC_OSX) { fileMenu.add(mm.addMarker("Editor.File.start")); fileMenu.add(mm.addMarker("Editor.File.end")); } else { fileMenu.addSeparator(); fileMenu.add(mm.addKey("Prefs.edit_preferences")); fileMenu.addSeparator(); fileMenu.add(mm.addKey("General.quit")); } mm.addAction("General.quit", new ShutDownAction()); // help menu final MenuProxy helpMenu = new MenuProxy(Resources.getString("General.help")); // FIMXE: setting mnemonic from first letter could cause collisions in // some languages helpMenu.setMnemonic(Resources.getString("General.help.shortcut").charAt(0)); helpMenu.add(mm.addMarker("Documentation.VASSAL.start")); helpMenu.add(mm.addKey("General.help")); helpMenu.add(mm.addMarker("Documentation.VASSAL.end")); helpMenu.addSeparator(); helpMenu.add(mm.addMarker("Documentation.Module.start")); helpMenu.add(mm.addMarker("Documentation.Module.end")); helpMenu.add(mm.addKey("Documentation.about_module")); if (!SystemUtils.IS_OS_MAC_OSX) { helpMenu.add(mm.addKey("AboutScreen.about_vassal")); } // Tools menu final MenuProxy toolsMenu = new MenuProxy(Resources.getString("General.tools")); toolsMenu.setMnemonic(Resources.getString("General.tools.shortcut").charAt(0)); toolsMenu.add(mm.addKey("GameRefresher.refresh_counters")); 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)); mm.addAction("AboutScreen.about_vassal", new AboutVASSALAction(this)); mb.add(fileMenu); mb.add(toolsMenu); mb.add(mm.addMarker("Editor.MenuBar.start")); mb.add(mm.addMarker("Editor.MenuBar.end")); mb.add(helpMenu); setJMenuBar(mm.getMenuBarFor(this)); // build toolbar toolBar.setLayout(new WrapLayout(FlowLayout.LEFT, 0, 0)); toolBar.setAlignmentX(0.0f); toolBar.setFloatable(false); add(toolBar, BorderLayout.NORTH); // build central area controlPanel.setLayout(new BorderLayout()); controlPanel.setPreferredSize(new Dimension(800, 600)); add(controlPanel, BorderLayout.CENTER); pack(); }
From source file:VASSAL.tools.filechooser.FileChooser.java
/** * Creates a FileChooser appropriate for the user's OS. * * @param parent/*w w w . j a v a 2s.co m*/ * The Component over which the FileChooser should appear. * @param prefs * A FileConfigure that stores the preferred starting directory of the FileChooser in preferences */ public static FileChooser createFileChooser(Component parent, DirectoryConfigurer prefs, int mode) { FileChooser fc; if (SystemUtils.IS_OS_MAC_OSX) { // Mac has a good native file dialog fc = new NativeFileChooser(parent, prefs, mode); } else if (mode == FILES_ONLY && SystemUtils.IS_OS_WINDOWS) { // Window has a good native file dialog, but it doesn't support selecting directories fc = new NativeFileChooser(parent, prefs, mode); } else { // Linux's native dialog is inferior to Swing's fc = new SwingFileChooser(parent, prefs, mode); } return fc; }
From source file:VASSAL.tools.image.FallbackImageTypeConverter.java
private boolean tryConvertingInMemory(Reference<BufferedImage> ref) { /*/* w ww.j av a2s . c om*/ * Having an OutOfMemoryException while converting in memory is * apparently catastrophic on Apple's Java 6 JVM (and possibly also * on their Java 5 JVM as well). In-memory tiling also uses far more * memory than it should on Apple's Java 6 JVM due to * Graphics2D.drawImage making an intermediate copy of the image data. * Hence, we ensure that when using Java 5 or 6 on Mac OS X, we never * try in-memory conversion for images which can't comfortably have * three copies existing simultaneously in memory. */ return !SystemUtils.IS_OS_MAC_OSX || (!SystemUtils.IS_JAVA_1_6 && !SystemUtils.IS_JAVA_1_5) || 4 * ref.obj.getHeight() * ref.obj.getWidth() <= Runtime.getRuntime().maxMemory() / 4; }
From source file:VASSAL.tools.lang.MemoryUtilsTest.java
@Test public void testGetPhysicalMemoryUNIX() throws IOException { assumeTrue(SystemUtils.IS_OS_UNIX && !SystemUtils.IS_OS_MAC_OSX); // get the total RAM from the system, in kB final Process p = Runtime.getRuntime() .exec(new String[] { "sh", "-c", "grep '^MemTotal:' /proc/meminfo | sed 's/[^0-9]//g'" }); final BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream())); final int eRAM = Integer.parseInt(r.readLine()); r.close();/*w w w. j a v a2 s . com*/ // check that it's correct assertEquals(eRAM, MemoryUtils.getPhysicalMemory() >> 10); }
From source file:VASSAL.tools.lang.MemoryUtilsTest.java
@Ignore @Test public void testGetPhysicalMemoryMacOSX() { assumeTrue(SystemUtils.IS_OS_MAC_OSX); }