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:org.kitodo.selenium.testframework.helper.WebDriverProvider.java
/** * Downloads chrome driver, extracts archive file and set system property * "webdriver.chrome.driver". On Linux the method also sets executable * permission./*from w w w . j av a2s .com*/ * * @param chromeDriverVersion * The chrome driver version. * @param downloadFolder * The folder in which the downloaded files will be put in. * @param extractFolder * The folder in which the extracted files will be put in. */ public static void provideChromeDriver(String chromeDriverVersion, String downloadFolder, String extractFolder) throws IOException { String chromeDriverUrl = "https://chromedriver.storage.googleapis.com/" + chromeDriverVersion + "/"; String chromeDriverFileName; if (SystemUtils.IS_OS_WINDOWS) { chromeDriverFileName = "chromedriver.exe"; File chromeDriverZipFile = new File(downloadFolder + "chromedriver.zip"); FileUtils.copyURLToFile(new URL(chromeDriverUrl + "chromedriver_win32.zip"), chromeDriverZipFile); extractZipFileToFolder(chromeDriverZipFile, new File(extractFolder)); } else if (SystemUtils.IS_OS_MAC_OSX) { chromeDriverFileName = "chromedriver"; File chromeDriverZipFile = new File(downloadFolder + "chromedriver.zip"); FileUtils.copyURLToFile(new URL(chromeDriverUrl + "chromedriver_mac64.zip"), chromeDriverZipFile); File theDir = new File(extractFolder); if (!theDir.exists()) { theDir.mkdir(); } extractZipFileToFolder(chromeDriverZipFile, new File(extractFolder)); } else { chromeDriverFileName = "chromedriver"; File chromeDriverZipFile = new File(downloadFolder + "chromedriver.zip"); FileUtils.copyURLToFile(new URL(chromeDriverUrl + "chromedriver_linux64.zip"), chromeDriverZipFile); extractZipFileToFolder(chromeDriverZipFile, new File(extractFolder)); } File chromeDriverFile = new File(extractFolder, chromeDriverFileName); if (chromeDriverFile.exists()) { if (!SystemUtils.IS_OS_WINDOWS) { ExecutionPermission.setExecutePermission(chromeDriverFile); } if (chromeDriverFile.canExecute()) { System.setProperty("webdriver.chrome.driver", chromeDriverFile.getPath()); } else { logger.error("Chromedriver not executeable"); } } else { logger.error("Chromedriver file not found"); } }
From source file:org.lnicholls.galleon.apps.iTunes.iTunesOptionsPanel.java
public iTunesOptionsPanel(AppConfiguration appConfiguration) { super(appConfiguration); setLayout(new GridLayout(0, 1)); iTunesConfiguration iTunesConfiguration = (iTunesConfiguration) appConfiguration; mTitleField = new JTextField(iTunesConfiguration.getName()); mSharedField = new JCheckBox("Share"); mSharedField.setSelected(iTunesConfiguration.isShared()); mSharedField.setToolTipText("Share this app"); String playlistPath = iTunesConfiguration.getPlaylistPath(); if (playlistPath == null) { if (SystemUtils.IS_OS_MAC_OSX) playlistPath = "/Users/" + System.getProperty("user.name") + "/Music/iTunes/iTunes Music Library.xml"; else/*from w w w .j ava 2 s .co m*/ playlistPath = "C:\\Documents and Settings\\" + System.getProperty("user.name") + "\\My Documents\\My Music\\iTunes\\iTunes Music Library.xml"; } mPlaylistPathField = new JTextField(playlistPath); FormLayout layout = new FormLayout("right:pref, 3dlu, 50dlu:g, 3dlu, pref, right:pref:grow", "pref, " + // general "9dlu, " + "pref, " + // title "3dlu, " + "pref, " + // share "3dlu, " + "pref, " // username ); PanelBuilder builder = new PanelBuilder(layout); //DefaultFormBuilder builder = new DefaultFormBuilder(new FormDebugPanel(), layout); builder.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); builder.addSeparator("General", cc.xyw(1, 1, 4)); builder.addLabel("Title", cc.xy(1, 3)); builder.add(mTitleField, cc.xyw(3, 3, 1)); builder.add(mSharedField, cc.xyw(3, 5, 1)); builder.addLabel("Playlist Path", cc.xy(1, 7)); builder.add(mPlaylistPathField, cc.xyw(3, 7, 1)); JButton button = new JButton("..."); button.setActionCommand("pick"); button.addActionListener(this); builder.add(button, cc.xyw(5, 7, 1)); JPanel panel = builder.getPanel(); //FormDebugUtils.dumpAll(panel); add(panel); }
From source file:org.lnicholls.galleon.database.NetworkServerManager.java
public static void initialize() throws Exception { mHibernateProperties = new Properties(); File file = new File(System.getProperty("conf") + "/" + "hibernate.properties"); if (!file.exists()) { InstantiationException exception = new InstantiationException("hibernate.properties not found"); log.error("Creating Derby Network Server failed", exception); throw exception; }//from w w w .ja v a 2 s . co m mHibernateProperties.load(new FileInputStream(file)); if (mHibernateProperties.getProperty("hibernate.dialect").equals("net.sf.hibernate.dialect.DerbyDialect")) { Properties derbyProperties = new Properties(); file = new File(System.getProperty("conf") + "/" + "derby.properties"); if (!file.exists()) { InstantiationException exception = new InstantiationException("derby.properties not found"); log.error("Creating Derby Network Server failed", exception); throw exception; } derbyProperties.load(new FileInputStream(file)); mPort = DEFAULT_PORT; if (derbyProperties.getProperty("derby.drda.portNumber") != null) { try { mPort = Integer.parseInt(derbyProperties.getProperty("derby.drda.portNumber")); } catch (NumberFormatException ex) { log.error("Invalid derby.drda.portNumber: " + derbyProperties.getProperty("derby.drda.portNumber"), ex); } } int port = Tools.findAvailablePort(mPort); if (port != mPort) { mPort = port; log.info("Changed port to " + mPort); } try { // Only use the network server for Derby database log.info("Creating Database Network Server"); if (derbyProperties.getProperty("derby.system.home") == null) System.setProperty("derby.system.home", System.getProperty("data")); if (derbyProperties.getProperty("derby.stream.error.file") == null) System.setProperty("derby.stream.error.file", System.getProperty("logs") + "/" + "derby.log"); mNetworkServerControl = new NetworkServerControl(InetAddress.getByName("127.0.0.1"), mPort); mNetworkServerControl.start(null); if (SystemUtils.IS_OS_MAC_OSX) System.setProperty("derby.storage.fileSyncTransactionLog", "true"); // OSX bug testDatabase(); log.info("Created Database Network Server"); } catch (Exception ex) { log.error("Derby Network server could not be created", ex); throw ex; } } else log.info("Alternate Hibernate database: " + mHibernateProperties.getProperty("hibernate.dialect")); }
From source file:org.lnicholls.galleon.util.Tools.java
public static Toolkit getDefaultToolkit() { // return Toolkit.getDefaultToolkit(); try {// w w w . j a v a 2 s . c o m String headless = System.getProperty("java.awt.headless"); if (headless == null || !headless.equals("true")) try { if (SystemUtils.IS_OS_WINDOWS) return (Toolkit) Class.forName("sun.awt.windows.WToolkit").newInstance(); else if (SystemUtils.IS_OS_LINUX) return (Toolkit) Class.forName("sun.awt.motif.MToolkit").newInstance(); else if (SystemUtils.IS_OS_MAC_OSX) return (Toolkit) Class.forName("apple.awt.CToolkit").newInstance(); } catch (Throwable ex) { } return Toolkit.getDefaultToolkit(); } catch (Throwable ex) { try { return (Toolkit) Class.forName("com.eteks.awt.PJAToolkit").newInstance(); } catch (Exception ex2) { } } return null; }
From source file:org.objectstyle.woproject.maven2.wobootstrap.AbstractBootstrapMojo.java
void initializeLocator() throws MojoExecutionException { if (locator != null) { return;/*w w w . j a v a 2 s . c o m*/ } if (webObjectsLibFolder != null && webObjectsVersion != null) { locator = new CustomWebObjectsLocator(webObjectsLibFolder); } else if (illegalSetOfParameters()) { throw new MojoExecutionException( "You must provide both webObjectsLibFolder and webObjectsVersion to use a custom locator for WebObjects libraries"); } else if (SystemUtils.IS_OS_MAC_OSX) { locator = new MacOsWebObjectsLocator(); } else if (SystemUtils.IS_OS_WINDOWS) { locator = new WindowsWebObjectsLocator(); } else if (SystemUtils.IS_OS_UNIX) { locator = new UnixWebObjectsLocator(); } else { throw new MojoExecutionException("Unsupported OS platform."); } }
From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java
/** * Returns <code>true</code> if the OS is MAC, <code>false</code> * otherwise.//www .ja va2s . c om * * @return See above. */ public static boolean isMacOS() { //String osName = System.getProperty("os.name").toLowerCase(); //return osName.startsWith("mac os"); return (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX); }
From source file:org.pentaho.di.core.ConstTest.java
@Test public void testIsOSX() { assertEquals(SystemUtils.IS_OS_MAC_OSX, Const.isOSX()); }
From source file:org.rapidcontext.app.ui.AppUtils.java
/** * Opens the specified URL in the user's default browser. * * @param url the URL to open * * @throws Exception if the URL failed to open or if no browser was found *///from w w w. j a v a2 s.c o m public static void openURL(String url) throws Exception { if (SystemUtils.IS_OS_MAC_OSX) { Runtime.getRuntime().exec("open " + url); } else if (SystemUtils.IS_OS_WINDOWS) { Runtime.getRuntime().exec("cmd.exe /C start " + url); } else if (hasCommand("xdg-open")) { Runtime.getRuntime().exec("xdg-open " + url); } else if (hasCommand("gnome-open")) { Runtime.getRuntime().exec("gnome-open " + url); } else if (hasCommand("kde-open")) { Runtime.getRuntime().exec("kde-open " + url); } else { for (int i = 0; i < BROWSERS.length; i++) { if (hasCommand(BROWSERS[i])) { Runtime.getRuntime().exec(BROWSERS[i] + " " + url); return; } } throw new Exception("No browser found."); } }
From source file:org.rapidcontext.app.ui.ControlPanel.java
/** * Initializes the panel UI./*from ww w . j ava2 s .c o m*/ */ private void initialize() { Rectangle bounds = new Rectangle(); GridBagConstraints c; JLabel label; Font font; Properties info; String str; // Set system UI looks if (SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_WINDOWS) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ignore) { // Ah well... at least we tried. } } // Set title, menu & layout setDefaultCloseOperation(EXIT_ON_CLOSE); setTitle("RapidContext Server"); setMenuBar(menuBar); initializeMenu(); getContentPane().setLayout(new GridBagLayout()); try { logotype = ImageIO.read(getClass().getResource("logotype.png")); Image img = ImageIO.read(getClass().getResource("logotype-icon-256x256.png")); setIconImage(img); if (SystemUtils.IS_OS_MAC_OSX) { MacApplication.get().setDockIconImage(img); } } catch (Exception ignore) { // Again, we only do our best effort here } // Add logotype c = new GridBagConstraints(); c.gridheight = 5; c.insets = new Insets(6, 15, 10, 10); c.anchor = GridBagConstraints.NORTHWEST; Image small = logotype.getScaledInstance(128, 128, Image.SCALE_SMOOTH); getContentPane().add(new JLabel(new ImageIcon(small)), c); // Add link label c = new GridBagConstraints(); c.gridx = 1; c.insets = new Insets(10, 10, 2, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(new JLabel("Server URL:"), c); serverLink.setText("http://localhost:" + server.port + "/"); serverLink.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { AppUtils.openURL(serverLink.getText()); } catch (Exception e) { error(e.getMessage()); } } }); c = new GridBagConstraints(); c.gridx = 2; c.weightx = 1.0; c.insets = new Insets(10, 0, 2, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(serverLink, c); // Add login info label label = new JLabel("Login as 'admin' on a new server."); font = label.getFont(); font = font.deriveFont(Font.ITALIC, font.getSize() - 2); label.setFont(font); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 1; c.gridwidth = 2; c.insets = new Insets(0, 0, 6, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(label, c); // Add status label c = new GridBagConstraints(); c.gridx = 1; c.gridy = 2; c.insets = new Insets(0, 10, 6, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(new JLabel("Status:"), c); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 2; c.insets = new Insets(0, 0, 6, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(statusLabel, c); // Add version label c = new GridBagConstraints(); c.gridx = 1; c.gridy = 3; c.insets = new Insets(0, 10, 6, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(new JLabel("Version:"), c); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 3; c.insets = new Insets(0, 0, 6, 10); c.anchor = GridBagConstraints.WEST; info = Main.buildInfo(); str = info.getProperty("build.version") + " (built " + info.getProperty("build.date") + ")"; getContentPane().add(new JLabel(str), c); // Add buttons startButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { start(); } }); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 4; c.weighty = 1.0; c.insets = new Insets(0, 10, 10, 10); c.anchor = GridBagConstraints.SOUTH; getContentPane().add(startButton, c); stopButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { stop(); } }); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 4; c.weighty = 1.0; c.insets = new Insets(0, 0, 10, 0); c.anchor = GridBagConstraints.SOUTHWEST; getContentPane().add(stopButton, c); // Set size & position pack(); bounds = this.getBounds(); bounds.width = 470; bounds.x = 100; bounds.y = 100; setBounds(bounds); }
From source file:org.rapidcontext.app.ui.ControlPanel.java
/** * Initializes the frame menu./*w w w.j a v a2 s . c o m*/ */ private void initializeMenu() { Menu menu; MenuItem item; // Create file menu if (!SystemUtils.IS_OS_MAC_OSX) { menu = new Menu("File"); item = new MenuItem("Exit", new MenuShortcut(KeyEvent.VK_Q)); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { quit(); } }); menu.add(item); menuBar.add(menu); menu = new Menu("Help"); item = new MenuItem("About"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { about(); } }); menu.add(item); menuBar.add(menu); } // Fix Mac OS specific menus if (SystemUtils.IS_OS_MAC_OSX) { try { MacApplication.get().setAboutHandler(new ActionListener() { public void actionPerformed(ActionEvent evt) { about(); } }); MacApplication.get().setPreferencesHandler(null); } catch (Exception ignore) { // Errors are ignored } } }