jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1795015 - /jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderInBrowser.java
Date Fri, 12 May 2017 19:36:49 GMT
Author: fschumacher
Date: Fri May 12 19:36:49 2017
New Revision: 1795015

URL: http://svn.apache.org/viewvc?rev=1795015&view=rev
Log:
Use lambdas.

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderInBrowser.java

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderInBrowser.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderInBrowser.java?rev=1795015&r1=1795014&r2=1795015&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderInBrowser.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderInBrowser.java Fri May
12 19:36:49 2017
@@ -27,10 +27,8 @@ import javafx.beans.value.ChangeListener
 import javafx.beans.value.ObservableValue;
 import javafx.concurrent.Worker.State;
 import javafx.embed.swing.JFXPanel;
-import javafx.event.EventHandler;
 import javafx.scene.Scene;
 import javafx.scene.web.WebEngine;
-import javafx.scene.web.WebEvent;
 import javafx.scene.web.WebView;
 
 import javax.swing.BorderFactory;
@@ -90,12 +88,7 @@ public class RenderInBrowser extends Sam
         } 
         browserPanel.setVisible(true);
         resultsScrollPane.setViewportView(browserPanel);
-        Platform.runLater(new Runnable() {
-            @Override
-            public void run() {
-                engine.loadContent(html);
-            }
-        });
+        Platform.runLater(() -> engine.loadContent(html));
     }
 
     private JPanel initComponents(String htmlContent) {
@@ -126,33 +119,11 @@ public class RenderInBrowser extends Sam
                 WebView view = new WebView();
                 engine = view.getEngine();
 
-                engine.setOnStatusChanged(new EventHandler<WebEvent<String>>()
{
-                    @Override
-                    public void handle(final WebEvent<String> event) {
-                        SwingUtilities.invokeLater(new Runnable() {
-                            @Override
-                            public void run() {
-                                lblStatus.setText(event.getData());
-                            }
-                        });
-                    }
-                });
+                engine.setOnStatusChanged(event -> SwingUtilities.invokeLater(() ->
lblStatus.setText(event.getData())));
 
                 engine.getLoadWorker().workDoneProperty()
-                        .addListener(new ChangeListener<Number>() {
-                            @Override
-                            public void changed(
-                                    ObservableValue<? extends Number> observableValue,
-                                    Number oldValue, final Number newValue) {
-                                SwingUtilities.invokeLater(new Runnable() {
-                                    @Override
-                                    public void run() {
-                                        progressBar.setValue(newValue
-                                                .intValue());
-                                    }
-                                });
-                            }
-                        });
+                        .addListener((ChangeListener<Number>) (observableValue, oldValue,
newValue) -> SwingUtilities
+                                .invokeLater(() -> progressBar.setValue(newValue.intValue())));
 
                 engine.getLoadWorker().exceptionProperty()
                         .addListener(new ChangeListener<Throwable>() {
@@ -162,22 +133,17 @@ public class RenderInBrowser extends Sam
                                     ObservableValue<? extends Throwable> o,
                                     Throwable old, final Throwable value) {
                                 if (engine.getLoadWorker().getState() == State.FAILED) {
-                                    SwingUtilities.invokeLater(new Runnable() {
-                                        @Override
-                                        public void run() {
-                                            JOptionPane
-                                                    .showMessageDialog(
-                                                            resultsScrollPane,
-                                                            (value != null) ? engine
-                                                                    .getLocation()
-                                                                    + "\n"
-                                                                    + value.getMessage()
-                                                                    : engine.getLocation()
-                                                                            + "\nUnexpected
error.",
-                                                            "Loading error...",
-                                                            JOptionPane.ERROR_MESSAGE);
-                                        }
-                                    });
+                                    SwingUtilities.invokeLater(() -> JOptionPane
+                                            .showMessageDialog(
+                                                    resultsScrollPane,
+                                                    (value != null) ? engine
+                                                            .getLocation()
+                                                            + "\n"
+                                                            + value.getMessage()
+                                                            : engine.getLocation()
+                                                                    + "\nUnexpected error.",
+                                                    "Loading error...",
+                                                    JOptionPane.ERROR_MESSAGE));
                                 }
                             }
                         });
@@ -201,11 +167,6 @@ public class RenderInBrowser extends Sam
         if (browserPanel == null) {
             browserPanel = initComponents("");
         }
-        Platform.runLater(new Runnable() {
-            @Override
-            public void run() {
-                engine.loadContent("");
-            }
-        });
+        Platform.runLater(() -> engine.loadContent(""));
     }
 }



Mime
View raw message