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 test.css.controls;
  26 
  27 import javafx.scene.control.Button;
  28 import javafx.scene.control.ToolBar;
  29 import javafx.scene.layout.Pane;
  30 import test.javaclient.shared.BasicButtonChooserApp;
  31 import test.javaclient.shared.PageWithSlots;
  32 import test.javaclient.shared.ScrollablePageWithSlots;
  33 import test.javaclient.shared.TestNode;
  34 import test.javaclient.shared.TestNodeLeaf;
  35 import test.javaclient.shared.Utils;
  36 
  37 /**
  38  *
  39  * @author sergey.lugovoy@oracle.com
  40  */
  41 public class ComplexButtonCssTests extends BasicButtonChooserApp {
  42 
  43     private static String stylesheets = "/test/css/resources/Buttons.css";
  44     private static int WIDTH = 400;
  45     private static int HEIGHT = 400;
  46 
  47     public ComplexButtonCssTests() {
  48         super(WIDTH, HEIGHT, "ComplexCssTests", false);
  49     }
  50 
  51     public static enum Pages {
  52         GREEN, ROUND_RED, BEVEL_GREY, GLASS_GREY, SHINY_ORANGE, DARK_BLUE, RECORD_SALES,
  53         RICH_BLUE, BIG_YELLOW, IPHONE_TOOLBAR, IPHONE, IPAD_DARK_GREY, IPAD_GREY,
  54         LION_DEFAULT, LION, WINDOWS7_DEFAULT, WINDOWS7;
  55     }
  56 
  57     @Override
  58     protected TestNode setup() {
  59         ScrollablePageWithSlots node = new ScrollablePageWithSlots("Complex Css Tests", WIDTH, HEIGHT);
  60         combinedTestChooserPresenter.getScene().getStylesheets().add(getClass().getResource(stylesheets).toExternalForm());
  61         for (Pages page : Pages.values()) {
  62             node.add(getPageSlot(page));
  63         }
  64         return node;
  65     }
  66 
  67     private PageWithSlots getPageSlot(Pages page) {
  68         PageWithSlots pageWithSlot = new PageWithSlots(page.name(), WIDTH, HEIGHT);
  69         Pane slot = new Pane();
  70         slot.setPrefSize(200, 200);
  71         if (page == Pages.IPHONE_TOOLBAR) {
  72             Button b = new Button("iPhone");
  73             b.setId("iphone");
  74             ToolBar temp = new ToolBar(b);
  75             temp.setId(page.name().toLowerCase());
  76             slot.getChildren().add(temp);
  77         } else {
  78             Button temp = new Button("Button");
  79             temp.setId(page.name().toLowerCase());
  80             temp.setMinWidth(100);
  81             slot.getChildren().add(temp);
  82         }
  83         pageWithSlot.add(new TestNodeLeaf(page.name(), slot));
  84         return pageWithSlot;
  85     }
  86 
  87     public static void main(String[] args) {
  88         Utils.launch(ComplexButtonCssTests.class, args);
  89     }
  90 }