1.1 --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/fximpl/FXBrwsr.java Sun Apr 28 17:42:49 2013 +0200
1.2 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/fximpl/FXBrwsr.java Thu May 30 06:09:42 2013 +0200
1.3 @@ -34,8 +34,11 @@
1.4 import javafx.scene.Node;
1.5 import javafx.scene.Scene;
1.6 import javafx.scene.control.Button;
1.7 +import javafx.scene.control.ToolBar;
1.8 +import javafx.scene.layout.BorderPane;
1.9 import javafx.scene.layout.ColumnConstraints;
1.10 import javafx.scene.layout.GridPane;
1.11 +import javafx.scene.layout.HBox;
1.12 import javafx.scene.layout.Pane;
1.13 import javafx.scene.layout.Priority;
1.14 import javafx.scene.layout.VBox;
1.15 @@ -58,27 +61,42 @@
1.16
1.17 @Override
1.18 public void start(Stage primaryStage) throws Exception {
1.19 - Pane root = new WebViewPane(getParameters().getUnnamed());
1.20 - primaryStage.setScene(new Scene(root, 1024, 768));
1.21 - LOG.info("Showing the stage");
1.22 + WebView view = new WebView();
1.23 + WebController wc = new WebController(view, getParameters().getUnnamed());
1.24 +
1.25 + final VBox vbox = new VBox();
1.26 + vbox.setAlignment( Pos.CENTER );
1.27 + vbox.setStyle( "-fx-background-color: #808080;");
1.28 +
1.29 +
1.30 + HBox hbox = new HBox();
1.31 + hbox.setStyle( "-fx-background-color: #808080;");
1.32 + hbox.setAlignment(Pos.CENTER);
1.33 + hbox.getChildren().add(vbox);
1.34 + vbox.getChildren().add(view);
1.35 +
1.36 + BorderPane root = new BorderPane();
1.37 + if ("true".equals(this.getParameters().getNamed().get("toolbar"))) { // NOI18N
1.38 + final ToolBar toolbar = BrowserToolbar.create(view, vbox);
1.39 + root.setTop( toolbar );
1.40 + }
1.41 + root.setCenter(hbox);
1.42 +
1.43 + Scene scene = new Scene(root, 800, 600);
1.44 +
1.45 + primaryStage.setTitle( "Device Emulator" );
1.46 + primaryStage.setScene( scene );
1.47 primaryStage.show();
1.48 - LOG.log(Level.INFO, "State shown: {0}", primaryStage.isShowing());
1.49 }
1.50
1.51 /**
1.52 * Create a resizable WebView pane
1.53 */
1.54 - private class WebViewPane extends Pane {
1.55 + private static class WebController {
1.56 private final JVMBridge bridge = new JVMBridge();
1.57
1.58 - public WebViewPane(List<String> params) {
1.59 + public WebController(WebView view, List<String> params) {
1.60 LOG.log(Level.INFO, "Initializing WebView with {0}", params);
1.61 - VBox.setVgrow(this, Priority.ALWAYS);
1.62 - setMaxWidth(Double.MAX_VALUE);
1.63 - setMaxHeight(Double.MAX_VALUE);
1.64 - WebView view = new WebView();
1.65 - view.setMinSize(500, 400);
1.66 - view.setPrefSize(500, 400);
1.67 final WebEngine eng = view.getEngine();
1.68 try {
1.69 JVMBridge.addBck2BrwsrLoad(new InitBck2Brwsr(eng));
1.70 @@ -120,13 +138,6 @@
1.71 dialogStage.showAndWait();
1.72 }
1.73 });
1.74 - GridPane grid = new GridPane();
1.75 - grid.setVgap(5);
1.76 - grid.setHgap(5);
1.77 - GridPane.setConstraints(view, 0, 1, 2, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
1.78 - grid.getColumnConstraints().addAll(new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.ALWAYS, HPos.CENTER, true), new ColumnConstraints(40, 40, 40, Priority.NEVER, HPos.CENTER, true));
1.79 - grid.getChildren().addAll(view);
1.80 - getChildren().add(grid);
1.81 }
1.82
1.83 boolean initBck2Brwsr(WebEngine webEngine) {
1.84 @@ -141,21 +152,6 @@
1.85 return false;
1.86 }
1.87
1.88 - @Override
1.89 - protected void layoutChildren() {
1.90 - List<Node> managed = getManagedChildren();
1.91 - double width = getWidth();
1.92 - double height = getHeight();
1.93 - double top = getInsets().getTop();
1.94 - double right = getInsets().getRight();
1.95 - double left = getInsets().getLeft();
1.96 - double bottom = getInsets().getBottom();
1.97 - for (int i = 0; i < managed.size(); i++) {
1.98 - Node child = managed.get(i);
1.99 - layoutInArea(child, left, top, width - left - right, height - top - bottom, 0, Insets.EMPTY, true, true, HPos.CENTER, VPos.CENTER);
1.100 - }
1.101 - }
1.102 -
1.103 private class InitBck2Brwsr implements ChangeListener<Void>, Runnable {
1.104 private final WebEngine eng;
1.105