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.zeroturnaround.exec.test.InputRedirectTest.java
@Test public void testRedirectInput() throws Exception { String binTrue;//w w w.j a v a 2 s . com if (SystemUtils.IS_OS_LINUX) { binTrue = "/bin/true"; } else if (SystemUtils.IS_OS_MAC_OSX) { binTrue = "/usr/bin/true"; } else { Assume.assumeTrue("Unsupported OS " + SystemUtils.OS_NAME, false); return; // Skip this test } // We need to put something in the buffer ByteArrayInputStream bais = new ByteArrayInputStream("foo".getBytes()); ProcessExecutor exec = new ProcessExecutor().command(binTrue); // Test that we don't get IOException: Stream closed int exit = exec.redirectInput(bais).readOutput(true).execute().getExitValue(); log.debug("Exit: {}", exit); }
From source file:phex.gui.common.FileDialogHandler.java
public static File openSingleDirectoryChooser(Component parent, String title, String approveBtnText, char approveBtnMnemonic, File currentDirectory) { if (SystemUtils.IS_OS_MAC_OSX) { return openMacDirectoryChooser(title, null, null); } else {// ww w . ja v a2s . c om return openDefaultSingleChooser(parent, initDefaultChooser(title, approveBtnText, approveBtnMnemonic, new DirectoryOnlyFileFilter(), JFileChooser.DIRECTORIES_ONLY, currentDirectory, null, null)); } }
From source file:phex.gui.common.FileDialogHandler.java
public static File[] openMultipleDirectoryChooser(Component parent, String title, String approveBtnText, char approveBtnMnemonic, File currentDirectory, String notifyPopupTitle, String notifyPopupShortMessage) { if (SystemUtils.IS_OS_MAC_OSX) { return new File[] { openMacDirectoryChooser(title, notifyPopupTitle, notifyPopupShortMessage) }; } else {/*from www .j a v a2 s . c o m*/ return openDefaultMultiChooser(parent, initDefaultChooser(title, approveBtnText, approveBtnMnemonic, new DirectoryOnlyFileFilter(), JFileChooser.DIRECTORIES_ONLY, currentDirectory, notifyPopupTitle, notifyPopupShortMessage)); } }
From source file:phex.gui.common.GUIRegistry.java
public void initialize(Servent servent) { this.servent = servent; // make sure you never need to keep a reference of DGuiSettings // by a class attributes... DGuiSettings guiSettings = loadGUISettings(); initializeGUISettings(guiSettings);/* w w w . j a va2 s . c o m*/ systemIconPack = new IconPack(SYSTEM_ICON_PACK_RESOURCE); countryIconPack = new CountryFlagIconPack(); // only systray support on windows... if (SystemUtils.IS_OS_WINDOWS) { try { desktopIndicator = new DesktopIndicator(); } catch (UnsupportedOperationException x) { desktopIndicator = null; } } if (SystemUtils.IS_OS_MAC_OSX) { MacOsxGUIUtils.installEventHandlers(); } guiUpdateTimer = new GuiUpdateTimer(InterfacePrefs.GuiUpdateInterval); initializeGlobalActions(); chatFrameManager = new ChatFrameManager(); try { mainFrame = new MainFrame(null, guiSettings); NLogger.debug(GUIRegistry.class, "GUIRegistry initialized."); } catch (java.awt.HeadlessException ex) { } globalEventListeners = new GlobalGuiEventListeners(servent.getEventService()); Environment environment = Environment.getInstance(); // before we set of the update check we will wait 1 minute... // this will help manager to initialize (file scan) and reduce // update checks on short Phex session lifetimes... environment.scheduleTimerTask(new TimerTask() { @Override public void run() { UpdateCheckRunner.triggerAutoBackgroundCheck(new GUIUpdateNotificationListener(), InterfacePrefs.ShowBetaUpdateNotification.get().booleanValue()); } }, DateUtils.MILLIS_PER_MINUTE); environment.setUserMessageListener(new GUIUserMessageListener()); }
From source file:phex.gui.common.GUIRegistry.java
private void initializeGUISettings(DGuiSettings guiSettings) { // set default values... if (SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_WINDOWS) { showTableHorizontalLines = false; showTableVerticalLines = false;/* w w w . j a v a2 s . c o m*/ } else { showTableHorizontalLines = true; showTableVerticalLines = true; } useLogBandwidthSlider = false; showRespectCopyrightNotice = true; // sets old values from old cfg... ToolTipManager.sharedInstance().setEnabled(InterfacePrefs.DisplayTooltip.get().booleanValue()); String userLafClass; String iconPackName; // load values from gui new settings if available. if (guiSettings != null) { if (guiSettings.isSetLogBandwidthSliderUsed()) { useLogBandwidthSlider = guiSettings.isLogBandwidthSliderUsed(); } if (guiSettings.isSetShowRespectCopyrightNotice()) { showRespectCopyrightNotice = guiSettings.isShowRespectCopyrightNotice(); } DTableList tableList = guiSettings.getTableList(); if (tableList != null && tableList.isSetShowHorizontalLines()) { showTableHorizontalLines = tableList.isShowHorizontalLines(); } if (tableList != null && tableList.isSetShowVerticalLines()) { showTableVerticalLines = tableList.isShowVerticalLines(); } iconPackName = guiSettings.getIconPackName(); userLafClass = guiSettings.getLookAndFeelClass(); } else { userLafClass = null; iconPackName = null; } if (iconPackName != null) { plafIconPack = IconPack.createIconPack(iconPackName); } if (plafIconPack == null) { plafIconPack = IconPack.createDefaultIconPack(); } LookAndFeel laf = LookAndFeelUtils.determineLAF(userLafClass); String phexLafClass = laf.getClass().getName(); if (userLafClass != null && !phexLafClass.equals(userLafClass)) {// in case we had to switch LAF show error. JOptionPane.showMessageDialog(GUIRegistry.getInstance().getMainFrame(), Localizer.getString("LAF_ErrorLoadingSwitchToDefault"), Localizer.getString("Error"), JOptionPane.ERROR_MESSAGE); } if (phexLafClass.equals(UIManager.getLookAndFeel().getClass().getName())) { // in case correct laf is already set just update UI! // this must be done to get colors correctly initialized! GUIUtils.updateComponentsUI(); } else { try { LookAndFeelUtils.setLookAndFeel(laf); } catch (ExceptionInInitializerError ex) { // headless mode } catch (LookAndFeelFailedException e) {// this is supposed to never happen.. since the LAF // should already be tested to function. assert (false); } } }
From source file:phex.gui.common.LookAndFeelUtils.java
public static UIManager.LookAndFeelInfo[] getAvailableLAFs() { List<UIManager.LookAndFeelInfo> list = new ArrayList<UIManager.LookAndFeelInfo>(); if (SystemUtils.IS_OS_MAC_OSX) { list.add(new UIManager.LookAndFeelInfo("Macintosh", UIManager.getSystemLookAndFeelClassName())); }/*from w w w.j a v a2 s.c om*/ list.add(new UIManager.LookAndFeelInfo("PlasticXP (default)", Options.PLASTICXP_NAME)); list.add(new UIManager.LookAndFeelInfo("Metal", "javax.swing.plaf.metal.MetalLookAndFeel")); //list.add( new UIManager.LookAndFeelInfo( // "CDE/Motif", Options.EXT_MOTIF_NAME ) ); if (SystemUtils.IS_OS_WINDOWS) { // This LAF will use the Java 1.4.2 avaiable XP look on XP systems list.add( new UIManager.LookAndFeelInfo("Windows", "com.sun.java.swing.plaf.windows.WindowsLookAndFeel")); } // The Java 1.4.2 available GTK+ LAF seems to be buggy and is not working // correctly together with the Swing UIDefault constants. Therefore we need // to wait with support of it Class gtkLAFClass; try { gtkLAFClass = Class.forName("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); } catch (ClassNotFoundException e) { gtkLAFClass = null; } if (gtkLAFClass != null) { list.add(new UIManager.LookAndFeelInfo("GTK", "com.sun.java.swing.plaf.gtk.GTKLookAndFeel")); } UIManager.LookAndFeelInfo[] lafs = new UIManager.LookAndFeelInfo[list.size()]; list.toArray(lafs); return lafs; }
From source file:phex.gui.common.LookAndFeelUtils.java
/** * Returns the default LAF class name of the system. */// ww w.j a v a 2s. co m private static String getDefaultLAFClassName() { if (SystemUtils.IS_OS_MAC_OSX) { // set the look and feel to System return UIManager.getSystemLookAndFeelClassName(); } else { // set the look and feel to Metal //lafClass = UIManager.getCrossPlatformLookAndFeelClassName(); return Options.PLASTICXP_NAME; } }
From source file:phex.gui.common.PhexColors.java
/** * Colors get usually update when a UI update is performed. *///from w w w. jav a2 s . c o m public static void updateColors() { Color activeCaptionBorderColor = UIManager.getColor("activeCaptionBorder"); Color infoColor = UIManager.getColor("info"); if ((SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_WINDOWS) && UIManager.getLookAndFeel().isNativeLookAndFeel()) { // in case this is native LAF we use our special orange color set // this is done because the standard ui colors we use for other LAF // just look so bad and ugly on Mac OSX. activatePhexColors(); } else if (infoColor == null || activeCaptionBorderColor == null) { // to prevent errors on LAF with some missing UI Colors we use // the Phex color set on this LAF. // (occures on Linux with GTK LAF) activatePhexColors(); } else { boxPanelBorderColor = GUIUtils.darkerColor(activeCaptionBorderColor, 0.8); boxPanelBackground = new Color(infoColor.getRGB()); boxHeaderBackground = GUIUtils.darkerColor(activeCaptionBorderColor, 0.9); boxHeaderGradientFrom = new Color(activeCaptionBorderColor.getRGB()); boxHeaderGradientTo = GUIUtils.brighterColor(infoColor, 0.8); linkLabelRolloverForeground = GUIUtils.darkerColor(activeCaptionBorderColor, 0.8); scopeProgressBarBackground = UIManager.getColor("window"); scopeProgressBarForeground = UIManager.getColor("ProgressBar.foreground"); finishedScopeProgressBarForeground = scopeProgressBarForeground; // give it a touch of red and saturation unverifiedScopeProgressBarForeground = new Color(0xf04656); // use a lighter color blockedScopeProgressBarForeground = GUIUtils.brighterColor(infoColor, 0.7); } }
From source file:phex.gui.tabs.download.DownloadOverviewPanel.java
private JPanel buildInfo2Panel() { JPanel subPanel = new JPanel(); CellConstraints cc = new CellConstraints(); String systemExtraCols = ""; if (SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_MAC_OSX) { systemExtraCols = ", 4dlu, d"; }//w w w . jav a 2 s . c o m FormLayout layout = new FormLayout("d, 4dlu, 1dlu:grow" + systemExtraCols, // columns "p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p"); //rows PanelBuilder panelBuilder = new PanelBuilder(layout, subPanel); panelBuilder.addSeparator(Localizer.getString("DownloadOverview_Information"), cc.xywh(1, 1, layout.getColumnCount(), 1)); JLabel label = new JLabel(Localizer.getString("DownloadOverview_FileName")); panelBuilder.add(label, cc.xy(1, 3)); fileNameTxt = new JTextField(); fileNameTxt.setEditable(false); fileNameTxt.setFont(UIManager.getFont("Label.font")); fileNameTxt.setForeground(UIManager.getColor("Label.foreground")); fileNameTxt.setBackground(UIManager.getColor("Label.background")); fileNameTxt.setMinimumSize(new Dimension(0, 0)); panelBuilder.add(fileNameTxt, cc.xy(3, 3)); label = new JLabel(Localizer.getString("DownloadOverview_IncompleteFile")); panelBuilder.add(label, cc.xy(1, 5)); incompleteFileTxt = new JTextField(); incompleteFileTxt.setEditable(false); incompleteFileTxt.setFont(UIManager.getFont("Label.font")); incompleteFileTxt.setForeground(UIManager.getColor("Label.foreground")); incompleteFileTxt.setBackground(UIManager.getColor("Label.background")); panelBuilder.add(incompleteFileTxt, cc.xy(3, 5)); if (SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_MAC_OSX) { exploreFileBtn = new JButton(); exploreFileBtn.setToolTipText(Localizer.getString("DownloadOverview_Explore")); exploreFileBtn.setMargin(GUIUtils.EMPTY_INSETS); exploreFileBtn.addActionListener(new ExploreActionListener()); panelBuilder.add(exploreFileBtn, cc.xy(5, 5)); } return subPanel; }
From source file:phex.gui.tabs.library.LibraryTab.java
public void initComponent(XJBGUISettings guiSettings) { CellConstraints cc = new CellConstraints(); FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "2dlu, fill:p:grow, 2dlu"); //rows PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this); JPanel contentPanel = new JPanel(); FWElegantPanel elegantPanel = new FWElegantPanel(Localizer.getString("Library"), contentPanel); tabBuilder.add(elegantPanel, cc.xy(2, 2)); FormLayout contentLayout = new FormLayout("fill:d:grow", // columns "fill:d:grow"); //rows PanelBuilder contentBuilder = new PanelBuilder(contentLayout, contentPanel); MouseHandler mouseHandler = new MouseHandler(); JPanel treePanel = createTreePanel(mouseHandler); JPanel tablePanel = createTablePanel(guiSettings, mouseHandler); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePanel, tablePanel); splitPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); splitPane.setDividerSize(4);/*from w ww .j a v a 2 s . c om*/ splitPane.setOneTouchExpandable(false); contentBuilder.add(splitPane, cc.xy(1, 1)); sharedFilesLabel = new JLabel(" "); sharedFilesLabel.setHorizontalAlignment(JLabel.RIGHT); elegantPanel.addHeaderPanelComponent(sharedFilesLabel, BorderLayout.EAST); ShareManager.getInstance().getSharedFilesService() .addSharedFilesChangeListener(new SharedFilesChangeHandler()); fileTreePopup = new FWPopupMenu(); fileTablePopup = new FWPopupMenu(); FWAction action; action = getTabAction(ADD_SHARE_FOLDER_ACTION_KEY); fileTreePopup.addAction(action); action = getTabAction(REMOVE_SHARE_FOLDER_ACTION_KEY); fileTreePopup.addAction(action); if (SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_MAC_OSX) { action = getTabAction(EXPLORE_FOLDER_ACTION_KEY); fileTreePopup.addAction(action); } action = getTabAction(OPEN_FILE_ACTION_KEY); fileTablePopup.addAction(action); action = getTabAction(VIEW_BITZI_ACTION_KEY); fileTablePopup.addAction(action); fileTablePopup.addSeparator(); fileTreePopup.addSeparator(); action = getTabAction(RESCAN_ACTION_KEY); fileTablePopup.addAction(action); fileTreePopup.addAction(action); action = getTabAction(EXPORT_ACTION_KEY); fileTablePopup.addAction(action); fileTreePopup.addAction(action); action = getTabAction(FILTER_ACTION_KEY); fileTablePopup.addAction(action); fileTreePopup.addAction(action); }