You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2016/12/31 19:02:37 UTC

svn commit: r1776813 - in /jmeter/trunk/src/core/org/apache/jmeter/gui/action: AboutCommand.java Help.java

Author: pmouawad
Date: Sat Dec 31 19:02:37 2016
New Revision: 1776813

URL: http://svn.apache.org/viewvc?rev=1776813&view=rev
Log:
sonar : fix squid:S2696 Make the enclosing method "static" or remove this set

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/AboutCommand.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/Help.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/AboutCommand.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/AboutCommand.java?rev=1776813&r1=1776812&r2=1776813&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/AboutCommand.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/AboutCommand.java Sat Dec 31 19:02:37 2016
@@ -85,6 +85,22 @@ public class AboutCommand extends Abstra
      */
     void about() {
         JFrame mainFrame = GuiPackage.getInstance().getMainFrame();
+        JDialog dialog = initDialog(mainFrame);
+
+        // NOTE: these lines center the about dialog in the current window. 
+        Point p = mainFrame.getLocationOnScreen();
+        Dimension d1 = mainFrame.getSize();
+        Dimension d2 = dialog.getSize();
+        dialog.setLocation(p.x + (d1.width - d2.width) / 2, p.y + (d1.height - d2.height) / 2);
+        dialog.pack();
+        dialog.setVisible(true);
+    }
+
+    /**
+     * @param mainFrame {@link JFrame}
+     * @return {@link JDialog} initializing it if necessary
+     */
+    private static final JDialog initDialog(JFrame mainFrame) {
         if (about == null) {
             about = new EscapeDialog(mainFrame, "About Apache JMeter...", false);
             about.addMouseListener(new MouseAdapter() {
@@ -111,13 +127,6 @@ public class AboutCommand extends Abstra
             panel.add(jmeter, BorderLayout.NORTH);
             panel.add(infos, BorderLayout.SOUTH);
         }
-
-        // NOTE: these lines center the about dialog in the current window. 
-        Point p = mainFrame.getLocationOnScreen();
-        Dimension d1 = mainFrame.getSize();
-        Dimension d2 = about.getSize();
-        about.setLocation(p.x + (d1.width - d2.width) / 2, p.y + (d1.height - d2.height) / 2);
-        about.pack();
-        about.setVisible(true);
+        return about;
     }
 }

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/Help.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/Help.java?rev=1776813&r1=1776812&r2=1776813&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/Help.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/Help.java Sat Dec 31 19:02:37 2016
@@ -70,18 +70,9 @@ public class Help extends AbstractAction
      */
     @Override
     public void doAction(ActionEvent e) {
-        if (helpWindow == null) {
-            helpWindow = new EscapeDialog(new Frame(),// independent frame to
-                                                    // allow it to be overlaid
-                                                    // by the main frame
-                    JMeterUtils.getResString("help"),//$NON-NLS-1$
-                    false);
-            helpWindow.getContentPane().setLayout(new GridLayout(1, 1));
-            helpWindow.getContentPane().removeAll();
-            helpWindow.getContentPane().add(scroller);
-            ComponentUtil.centerComponentInWindow(helpWindow, 60);
-        }
-        helpWindow.setVisible(true); // set the window visible immediately
+        JDialog dialog = initHelpWindow();
+        dialog.setVisible(true); // set the window visible immediately
+
         /*
          * This means that a new page will be shown before rendering is complete,
          * however the correct location will be displayed.
@@ -114,6 +105,24 @@ public class Help extends AbstractAction
     }
 
     /**
+     * @return {@link JDialog} Help window and initializes it if necessary
+     */
+    private static JDialog initHelpWindow() {
+        if (helpWindow == null) {
+            helpWindow = new EscapeDialog(new Frame(),// independent frame to
+                                                    // allow it to be overlaid
+                                                    // by the main frame
+                    JMeterUtils.getResString("help"),//$NON-NLS-1$
+                    false);
+            helpWindow.getContentPane().setLayout(new GridLayout(1, 1));
+            helpWindow.getContentPane().removeAll();
+            helpWindow.getContentPane().add(scroller);
+            ComponentUtil.centerComponentInWindow(helpWindow, 60);
+        }
+        return helpWindow;
+    }
+
+    /**
      * @see org.apache.jmeter.gui.action.Command#getActionNames()
      */
     @Override