List of usage examples for org.apache.commons.lang SystemUtils IS_OS_WINDOWS
boolean IS_OS_WINDOWS
To view the source code for org.apache.commons.lang SystemUtils IS_OS_WINDOWS.
Click Source Link
Is true
if this is Windows.
The field will return false
if OS_NAME
is null
.
From source file:org.sonarqube.tests.serverSystem.RestartTest.java
@Test public void restart_in_prod_mode_requires_sysadmin_permission_and_restarts() throws Exception { // server classloader locks Jar files on Windows if (!SystemUtils.IS_OS_WINDOWS) { orchestrator = Orchestrator.builderEnv().setOrchestratorProperty("orchestrator.keepWorkspace", "true") .build();//from w ww . j av a 2s .co m orchestrator.start(); verifyFailWith403(() -> newWsClient(orchestrator).system().restart()); createNonSystemAdministrator("john", "doe"); verifyFailWith403(() -> ItUtils.newUserWsClient(orchestrator, "john", "doe").system().restart()); createSystemAdministrator("big", "boss"); ItUtils.newUserWsClient(orchestrator, "big", "boss").system().restart(); assertThat(newAdminWsClient(orchestrator).system().status().getStatus()) .isEqualTo(System.Status.RESTARTING); // we just wait five seconds, for a lack of a better approach to waiting for the restart process to start in SQ Thread.sleep(5000); assertThat(FileUtils.readFileToString(orchestrator.getServer().getWebLogs())) .contains("SonarQube restart requested by big"); } }
From source file:org.sonarsource.scanner.jenkins.pipeline.WaitForQualityGateStepTest.java
private void declarativePipelineOneProject(int id, String reportTaskContent, StringBuilder pipeline) { pipeline.append(" stage(\"Scan " + id + "\") {\n"); pipeline.append(" agent any\n"); pipeline.append(" steps {\n"); pipeline.append(" dir(path: 'project" + id + "') {\n"); pipeline.append(" withSonarQubeEnv('" + SONAR_INSTALLATION_NAME + "') {\n"); pipeline.append(" writeFile file: 'foo/"); pipeline.append(SonarUtils.REPORT_TASK_FILE_NAME); pipeline.append("', text: '"); pipeline.append(reportTaskContent);/*from w w w . ja v a2 s . c o m*/ pipeline.append("', encoding: 'utf-8'\n"); pipeline.append(" "); pipeline.append((SystemUtils.IS_OS_WINDOWS ? "bat" : "sh")); pipeline.append(" 'mvn -version'\n"); pipeline.append(" }\n"); pipeline.append(" }\n"); pipeline.append(" }\n"); pipeline.append(" }\n"); pipeline.append(" stage(\"Quality Gate " + id + "\") {\n"); pipeline.append(" steps {\n"); pipeline.append(" waitForQualityGate abortPipeline: true\n"); pipeline.append(" }\n"); pipeline.append(" }\n"); }
From source file:org.sonarsource.scanner.jenkins.pipeline.WaitForQualityGateStepTest.java
private void scriptedPipelineOneProject(int id, String reportTaskContent, boolean specifyServer, StringBuilder pipeline) { pipeline.append("node {\n"); pipeline.append(" dir(path: 'project" + id + "') {\n"); if (specifyServer) { pipeline.append(" withSonarQubeEnv('" + SONAR_INSTALLATION_NAME + "') {\n"); } else {// w ww . j ava2s . com pipeline.append(" withSonarQubeEnv {\n"); } pipeline.append(" writeFile file: 'foo/"); pipeline.append(SonarUtils.REPORT_TASK_FILE_NAME); pipeline.append("', text: '"); pipeline.append(reportTaskContent); pipeline.append("', encoding: 'utf-8'\n"); pipeline.append(" "); pipeline.append((SystemUtils.IS_OS_WINDOWS ? "bat" : "sh")); pipeline.append(" 'mvn -version'\n"); pipeline.append(" }\n"); pipeline.append(" }\n"); pipeline.append("}\n"); pipeline.append("def qg" + id + " = waitForQualityGate();\n"); pipeline.append("if (qg" + id + ".status != 'OK') {\n"); pipeline.append(" error 'QG" + id + " failure'\n"); pipeline.append("}\n"); }
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 av a2s . c om*/ 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;//from w w w . ja v a 2s .c om } 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 .ja v a2 s. co m 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.PhexColors.java
/** * Colors get usually update when a UI update is performed. *///w w w. j a v a 2 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"; }//from ww w. j av a 2s. 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 w w .j av 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); }
From source file:phex.gui.tabs.library.LibraryTab.java
private JPanel createTreePanel(MouseHandler mouseHandler) { JPanel panel = new JPanel(); CellConstraints cc = new CellConstraints(); FormLayout layout = new FormLayout("fill:d:grow", // columns "fill:d:grow, 1dlu, p"); //rows PanelBuilder tabBuilder = new PanelBuilder(layout, panel); sharingTreeModel = new SharingTreeModel(); mainTree = new JTree(sharingTreeModel); mainTree.setMinimumSize(new Dimension(0, 0)); mainTree.setRowHeight(0);/*w w w . j av a2s. co m*/ mainTree.setCellRenderer(new SharingTreeRenderer()); mainTree.addMouseListener(mouseHandler); mainTree.getSelectionModel().addTreeSelectionListener(new SelectionHandler()); ToolTipManager.sharedInstance().registerComponent(mainTree); // open up first level of nodes TreeNode root = (TreeNode) sharingTreeModel.getRoot(); int count = root.getChildCount(); for (int i = 0; i < count; i++) { mainTree.expandPath(new TreePath(new Object[] { root, root.getChildAt(i) })); } JScrollPane treeScrollPane = new JScrollPane(mainTree); tabBuilder.add(treeScrollPane, cc.xywh(1, 1, 1, 1)); FWToolBar shareToolbar = new FWToolBar(FWToolBar.HORIZONTAL); shareToolbar.setBorderPainted(false); shareToolbar.setFloatable(false); tabBuilder.add(shareToolbar, cc.xy(1, 3)); FWAction action = new AddShareFolderAction(); addTabAction(ADD_SHARE_FOLDER_ACTION_KEY, action); shareToolbar.addAction(action); action = new RemoveShareFolderAction(); addTabAction(REMOVE_SHARE_FOLDER_ACTION_KEY, action); shareToolbar.addAction(action); if (SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_MAC_OSX) { action = new ExploreFolderAction(); addTabAction(EXPLORE_FOLDER_ACTION_KEY, action); } return panel; }