Example usage for org.apache.commons.lang SystemUtils IS_OS_MAC_OSX

List of usage examples for org.apache.commons.lang SystemUtils IS_OS_MAC_OSX

Introduction

In this page you can find the example usage for org.apache.commons.lang SystemUtils IS_OS_MAC_OSX.

Prototype

boolean IS_OS_MAC_OSX

To view the source code for org.apache.commons.lang SystemUtils IS_OS_MAC_OSX.

Click Source Link

Document

Is true if this is Mac.

The field will return false if OS_NAME is null.

Usage

From source file:com.nsn.squirrel.tab.utils.PathUtils.java

/**
 * Default path can be different for various OS
 * // w w  w  . jav a2 s  . co  m
 * @return default path
 */
public static Path getDefaultPath() {

    Path defaultPath = Paths.get(""); //$NON-NLS-1$
    if (SystemUtils.IS_OS_WINDOWS) {
        defaultPath = Paths.get("C:\\"); //$NON-NLS-1$
    } else if (SystemUtils.IS_OS_MAC_OSX) {
        defaultPath = Paths.get(System.getenv().get("HOME")); //$NON-NLS-1$
    }
    return defaultPath;
}

From source file:cane.brothers.e4.commander.utils.PathUtils.java

/**
 * Default path can be different for various OS
 * //from w  ww . j ava 2 s.c o  m
 * @return default path
 */
public static Path getDefaultPath() {
    Path defaultPath = Paths.get(""); //$NON-NLS-1$

    if (SystemUtils.IS_OS_WINDOWS) {
        defaultPath = Paths.get("C:\\"); //$NON-NLS-1$
    } else if (SystemUtils.IS_OS_MAC_OSX) {
        defaultPath = Paths.get(System.getenv().get("HOME")); //$NON-NLS-1$
    }
    return defaultPath;
}

From source file:com.zilotti.utils.NetworkUtils.java

/**
 * Provides the full path to the hosts file of the current
 * operational system.//  ww  w .ja  v  a 2 s .c o m
 *  
 * @return
 */
public static File getSystemHostsFilePath() {
    if (SystemUtils.IS_OS_LINUX)
        return new File("/etc/hosts");

    if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX)
        return new File("/private/etc/hosts");

    if (SystemUtils.IS_OS_WINDOWS) {
        // TODO: Implement on Windows environment
        File[] roots = FileSystemView.getFileSystemView().getRoots();
        for (File root : roots)
            System.out.println(root.getPath());

        return new File("c:/Windows/system32/drivers/etc/hosts");
    }

    throw new RuntimeException("Operational System not supported: " + System.getProperty("os.name"));
}

From source file:freemarker.cache.FileTemplateLoaderTest.java

@Test
public void testCaseSensitivity() throws Exception {
    for (boolean emuCaseSensFS : new boolean[] { false, true }) {
        for (String nameWithBadCase : new String[] { "SUB1/sub2/t.ftl", "sub1/SUB2/t.ftl",
                "sub1/sub2/T.FTL" }) {
            ((FileTemplateLoader) cfg.getTemplateLoader()).setEmulateCaseSensitiveFileSystem(emuCaseSensFS);
            cfg.clearTemplateCache();/*from  www .  ja va2s  . co m*/

            if ((SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_MAC_OSX) && !emuCaseSensFS) {
                assertEquals("foo", cfg.getTemplate(nameWithBadCase).toString());
            } else {
                assertEquals("foo", cfg.getTemplate(nameWithBadCase.toLowerCase()).toString());
                try {
                    cfg.getTemplate(nameWithBadCase);
                    fail();
                } catch (TemplateNotFoundException e) {
                    assertThat(e.getMessage(), containsString(nameWithBadCase));
                    assertNull(e.getCause());
                }
            }
        }
    }
}

From source file:gov.nasa.jpf.symbc.tree.visualizer.DOTVisualizerListener.java

private void outputVisualization(String path) {
    File file = new File(path);
    try {//from w ww  .  jav  a  2 s.  c  o  m
        FileOutputStream fo = new FileOutputStream(file);
        graph.printGraph(fo);
        fo.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    if (format != OUTPUT_FORMAT.DOT) {
        if ((SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_MAC)) {
            try {
                convertDotFile(file, format);
                file.delete();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:com.jayway.maven.plugins.android.AndroidNdk.java

private File findStripper(String toolchain) {
    List<String> osDirectories = new ArrayList<String>();
    String extension = "";

    if (SystemUtils.IS_OS_LINUX) {
        osDirectories.add("linux-x86");
        osDirectories.add("linux-x86_64");
    } else if (SystemUtils.IS_OS_WINDOWS) {
        osDirectories.add("windows");
        osDirectories.add("windows-x86_64");
        extension = ".exe";
    } else if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX) {
        osDirectories.add("darwin-x86");
        osDirectories.add("darwin-x86_64");
    }/*from   w w  w. j av  a 2s  . co  m*/

    String fileName = "";
    if (toolchain.startsWith("arm")) {
        fileName = "arm-linux-androideabi-strip" + extension;
    } else if (toolchain.startsWith("x86")) {
        fileName = "i686-linux-android-strip" + extension;
    } else if (toolchain.startsWith("mips")) {
        fileName = "mipsel-linux-android-strip" + extension;
    }

    for (String osDirectory : osDirectories) {
        String stripperLocation = String.format("toolchains/%s/prebuilt/%s/bin/%s", toolchain, osDirectory,
                fileName);
        final File stripper = new File(ndkPath, stripperLocation);
        if (stripper.exists()) {
            return stripper;
        }
    }
    return null;
}

From source file:net.sf.housekeeper.swing.ApplicationPresenter.java

/**
 * Initializes the Look and Feel./*from  w  w  w. j  ava2s  .co  m*/
 */
private void initLookAndFeel() {

    if (SystemUtils.IS_OS_MAC_OSX) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            //Do nothing if setting the Look and Feel fails.
        }
    } else {
        try {
            UIManager.setLookAndFeel(new PlasticXPLookAndFeel());
        } catch (Exception e) {
            //Do nothing if setting the Look and Feel fails.
        }
    }

    LOG.debug("Using Look and Feel: " + UIManager.getLookAndFeel().getName());
}

From source file:com.ibm.ecm.extension.aspera.AsperaPlugin.java

private void copyResources() throws AsperaPluginException {
    resourcePaths.add(copyResource("", "asperaweb_id_dsa.openssh", ""));
    resourcePaths.add(copyResource(ETC, "aspera-license", ETC));
    resourcePaths.add(copyResource(ETC, "aspera.conf", ETC));
    if (SystemUtils.IS_OS_WINDOWS) {
        copyWindowsResources();//  w  ww.  j av a  2  s.  com
    } else if (SystemUtils.IS_OS_MAC_OSX) {
        resourcePaths.add(makeFileExecutable(copyResource(BIN_OSX, "ascp4", BIN)));
    } else if (SystemUtils.IS_OS_LINUX) {
        resourcePaths.add(makeFileExecutable(copyResource(BIN_LINUX, "ascp4", BIN)));
    } else {
        throw new AsperaPluginException("The operating system is not supported.");
    }
}

From source file:fr.jmmc.jmcs.logging.LogbackGui.java

/**
 * Initialize the Swing components//from  w  w w  . j av  a  2 s .  c om
 */
private void postInit() {

    if (SystemUtils.IS_OS_MAC_OSX) {
        jPanelConf.setOpaque(false);
    }

    // add log panel automatically:
    int tabIndex = 0;
    for (AppenderLogMapper mapper : LoggingService.getInstance().getLogMappers()) {
        jTabbedPane.insertTab(mapper.getDisplayName(), null, new LogPanel(mapper.getLoggerPath()), null,
                tabIndex++);
    }

    generateTree();

    // tree selection listener :
    jTreeLoggers.addTreeSelectionListener(this);

    // add property change listener to editable fields :
    // level (combo box) :
    jComboBoxLevel.addActionListener(this);

    // display root logger information:
    processLoggerSelection(_rootLogger);
}

From source file:dmh.kuebiko.view.NoteStackFrame.java

/**
 * Initialize the contents of the frame. The contents of this method was
 * generated by Window Builder Pro./*w  w w .  jav  a2s  .  co m*/
 */
private void initialize() {
    setTitle(buildTitle());
    setBounds(100, 100, 450, 300);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0 };
    gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0 };
    gridBagLayout.columnWeights = new double[] { 0.0, 0.0, 1.0, Double.MIN_VALUE };
    gridBagLayout.rowWeights = new double[] { 0.0, 1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE };
    getContentPane().setLayout(gridBagLayout);

    horizontalStrut = Box.createHorizontalStrut(20);
    horizontalStrut.setMinimumSize(new Dimension(3, 0));
    horizontalStrut.setPreferredSize(new Dimension(3, 0));
    horizontalStrut.setSize(new Dimension(3, 0));
    GridBagConstraints gbc_horizontalStrut = new GridBagConstraints();
    gbc_horizontalStrut.insets = new Insets(0, 0, 0, 0);
    gbc_horizontalStrut.gridx = 0;
    gbc_horizontalStrut.gridy = 0;
    getContentPane().add(horizontalStrut, gbc_horizontalStrut);

    GridBagConstraints gbc_stateImageLabel = new GridBagConstraints();
    gbc_stateImageLabel.insets = new Insets(0, 0, 0, 0);
    gbc_stateImageLabel.anchor = GridBagConstraints.EAST;
    gbc_stateImageLabel.gridx = 1;
    gbc_stateImageLabel.gridy = 0;
    stateImageLabel.setBorder(null);
    stateImageLabel.setHorizontalAlignment(SwingConstants.CENTER);
    getContentPane().add(stateImageLabel, gbc_stateImageLabel);

    searchText = new JTextField();
    GridBagConstraints gbc_searchText = new GridBagConstraints();
    gbc_searchText.insets = new Insets(0, 0, 0, 0);
    gbc_searchText.fill = GridBagConstraints.HORIZONTAL;
    gbc_searchText.gridx = 2;
    gbc_searchText.gridy = 0;
    getContentPane().add(searchText, gbc_searchText);
    searchText.setColumns(10);
    if (SystemUtils.IS_OS_MAC_OSX) {
        // Make the text field look like the standard Mac OS X search
        // box control.
        searchText.putClientProperty("JTextField.variant", "search");
    }

    splitPane = new JSplitPane();
    splitPane.setBorder(null);
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    GridBagConstraints gbc_splitPane = new GridBagConstraints();
    gbc_splitPane.gridwidth = 3;
    gbc_splitPane.gridheight = 4;
    gbc_splitPane.insets = new Insets(0, 0, 0, 0);
    gbc_splitPane.fill = GridBagConstraints.BOTH;
    gbc_splitPane.gridx = 0;
    gbc_splitPane.gridy = 1;
    getContentPane().add(splitPane, gbc_splitPane);

    notePanel = new NotePanel();
    notePanel.getHuxleyUiManager().setOnTextChangeCallback(new Callback<Boolean>() {
        @Override
        public void callback(Boolean input) {
            toggleUnsavedChangeIndicator(input);
        }
    });
    splitPane.setRightComponent(notePanel);

    noteTableScroll = new JScrollPane();
    noteTableScroll.setMinimumSize(new Dimension(23, 100));
    splitPane.setLeftComponent(noteTableScroll);
    noteTable = newNoteTable();
    noteTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    noteTableScroll.setViewportView(noteTable);

    ActionObserverUtil.registerEnMass(actionMngr, observable,
            notePanel.getHuxleyUiManager().getTextAction(TextAction.INSERT_DATE));

    insertDateMenuItem = new JMenuItem(actionMngr.getAction(InsertDynamicTextAction.class));
    insertDateMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T,
            InputEvent.SHIFT_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    textMenu.add(insertDateMenuItem);
}