functional/FXCssTests/src/test/css/controls/ComplexButtonCssTests.java

Print this page




   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.ButtonBuilder;
  28 import javafx.scene.control.ToolBarBuilder;
  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);


  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             slot.getChildren().add(ToolBarBuilder.create()
  73                     .id(page.name().toLowerCase())
  74                     .items(
  75                     ButtonBuilder.create().text("iPhone").id("iphone").build())
  76                     .build());
  77         } else {
  78             slot.getChildren().add(ButtonBuilder.create()
  79                     .text("Button")
  80                     .id(page.name().toLowerCase())
  81                     .minWidth(100)
  82                     .build());
  83         }
  84         pageWithSlot.add(new TestNodeLeaf(page.name(), slot));
  85         return pageWithSlot;
  86     }
  87 
  88     public static void main(String[] args) {
  89         Utils.launch(ComplexButtonCssTests.class, args);
  90     }
  91 }


   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);


  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 }