1 /*
   2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation. Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package javafx.scene.control.test.splitpane;
  26 
  27 import javafx.scene.control.test.utils.ptables.TabPaneWithControl;
  28 import javafx.scene.control.test.utils.ptables.PropertyTablesFactory;
  29 import javafx.scene.control.test.utils.ptables.PropertiesTable;
  30 import javafx.scene.control.test.utils.ptables.NodesChoserFactory;
  31 import javafx.scene.control.test.utils.ptables.NodeControllerFactory;
  32 import javafx.event.ActionEvent;
  33 import javafx.event.EventHandler;
  34 import javafx.geometry.Insets;
  35 import javafx.scene.Node;
  36 import javafx.scene.Scene;
  37 import javafx.scene.control.*;
  38 import javafx.scene.control.test.utils.*;
  39 import javafx.scene.layout.HBox;
  40 import javafx.scene.layout.Pane;
  41 import javafx.scene.layout.VBox;
  42 import test.javaclient.shared.InteroperabilityApp;
  43 import test.javaclient.shared.Utils;
  44 
  45 /**
  46  * @author Alexander Kirov
  47  */
  48 public class SplitPaneApp extends InteroperabilityApp {
  49 
  50     public final static String TESTED_SPLIPANE_ID = "TESTED_SPLIPANE_ID";
  51     public final static String RESET_BUTTON_ID = "RESET_SPLIPANE_BUTTON_ID";
  52     public final static String SPLITPANE_ADD_INDEX_TEXT_FIELD_ID = "SPLITPANE_ADD_INDEX_TEXT_FIELD_ID";
  53 
  54     public static void main(String[] args) {
  55         Utils.launch(SplitPaneApp.class, args);
  56     }
  57 
  58     @Override
  59     protected Scene getScene() {
  60         Utils.setTitleToStage(stage, "SplitPaneTestApp");
  61         return new SplitPaneApp.SplitPaneScene();
  62     }
  63 
  64     class SplitPaneScene extends Scene {
  65 
  66         //VBox which contain tested split pane.
  67         Pane pane;
  68         //Splipane to be tested.
  69         SplitPane testedSplitPane;
  70 
  71         public SplitPaneScene() {
  72             super(new HBox(), 800, 600);
  73 
  74             prepareScene();
  75         }
  76 
  77         private void prepareScene() {
  78             pane = new Pane();
  79             testedSplitPane = new SplitPane();
  80             testedSplitPane.setId(TESTED_SPLIPANE_ID);
  81 
  82             PropertiesTable tb = new PropertiesTable(testedSplitPane);
  83             PropertyTablesFactory.explorePropertiesList(testedSplitPane, tb);
  84 
  85             final TabPaneWithControl tabPane = new TabPaneWithControl("Accordion", tb);
  86 
  87             final TextField tf = new TextField("0");
  88             tf.setId(SPLITPANE_ADD_INDEX_TEXT_FIELD_ID);
  89             tf.setPrefWidth(40);
  90 
  91             HBox nodeshb = new NodesChoserFactory("Add!", new NodesChoserFactory.NodeAction<Node>() {
  92 
  93                 @Override
  94                 public void execute(Node node) {
  95                     testedSplitPane.getItems().add(Integer.parseInt(tf.getText()), node);
  96                     tabPane.addPropertiesTable(node.getClass().getSimpleName(), NodeControllerFactory.createFullController(node, tabPane));
  97                 }
  98             }, tf);
  99 
 100             pane.setMinSize(220, 220);
 101             pane.setPrefSize(220, 220);
 102             pane.setStyle("-fx-border-color : red;");
 103             pane.getChildren().add(testedSplitPane);
 104 
 105             VBox vb = new VBox();
 106             vb.setSpacing(5);
 107 
 108             HBox hb = (HBox) getRoot();
 109             hb.setPadding(new Insets(5, 5, 5, 5));
 110             hb.setStyle("-fx-border-color : green;");
 111 
 112             Button resetButton = new Button("Reset");
 113             resetButton.setId(RESET_BUTTON_ID);
 114             resetButton.setOnAction(new EventHandler<ActionEvent>() {
 115 
 116                 public void handle(ActionEvent t) {
 117                     HBox hb = (HBox) getRoot();
 118                     hb.getChildren().clear();
 119                     prepareScene();
 120                 }
 121             });
 122 
 123             vb.getChildren().addAll(new Label("Pane with tested Accordion"), pane, resetButton, nodeshb);
 124 
 125             hb.getChildren().addAll(vb, tabPane);
 126         }
 127     }
 128 }
--- EOF ---