1 /*
   2  * Copyright (c) 2009, 2012, 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  */
  24 package test.scenegraph.lcd.controls;
  25 
  26 import javafx.collections.FXCollections;
  27 import javafx.scene.Parent;
  28 import javafx.scene.control.*;
  29 import javafx.scene.control.cell.PropertyValueFactory;
  30 import javafx.scene.layout.StackPane;
  31 import org.jemmy.fx.NodeDock;
  32 
  33 /**
  34  *
  35  * @author Alexander Petrov
  36  */
  37 public enum Factories implements Factory{
  38 
  39     Button(new DefaultFactory() {
  40 
  41         @Override
  42         public Parent createControl() {
  43             return new Button("Test");
  44         }
  45     }),
  46     ToggleButton(new DefaultFactory() {
  47 
  48         @Override
  49         public Parent createControl() {
  50             return new ToggleButton("Test");
  51         }
  52     }),
  53     TextField(new DefaultFactory() {
  54 
  55         @Override
  56         public Parent createControl() {
  57                         TextField temp = new TextField("Test");
  58                         temp.setMaxHeight(25);
  59                         temp.setMaxWidth(50);
  60             return temp;
  61         }
  62     }),
  63     Radio(new DefaultFactory() {
  64 
  65         @Override
  66         public Parent createControl() {
  67             return new RadioButton("Test");
  68         }
  69     }),
  70     CheckBox(new DefaultFactory() {
  71 
  72         @Override
  73         public Parent createControl() {
  74             return new CheckBox("Test");
  75         }
  76     }),
  77     Label(new DefaultFactory() {
  78 
  79         @Override
  80         public Parent createControl() {
  81             StackPane value = new StackPane();
  82 
  83             Label label = new Label("Test");
  84             value.getChildren().add(label);
  85 
  86             return value;
  87         }
  88     }),
  89     TitledPane(new DefaultFactory() {
  90 
  91         @Override
  92         public Parent createControl() {
  93                         TitledPane temp = new TitledPane();
  94                         temp.setText("Test");
  95                         temp.setMaxWidth(200);
  96                         temp.setMaxHeight(200);
  97                         return temp;
  98         }
  99     }),
 100     ToolBar(new DefaultFactory() {
 101 
 102         @Override
 103         public Parent createControl() {
 104             return new ToolBar(new Button("Test"));
 105         }
 106     }),
 107     Menu(new DefaultFactory() {
 108 
 109         @Override
 110         public Parent createControl() {
 111             Menu m = new Menu("Text1");
 112                         m.getItems().addAll(new MenuItem("Text2"));
 113             return new MenuBar(m);
 114         }
 115     }), ListView(new DefaultFactory() {
 116 
 117         @Override
 118         public Parent createControl() {
 119             ListView listView = new ListView();
 120             listView.getItems().addAll(FXCollections.observableArrayList((Object)"Test"));
 121             listView.setMaxHeight(150);
 122             listView.setMaxWidth(150);
 123             return listView;
 124         }
 125     }), TableView(new DefaultFactory() {
 126 
 127         @Override
 128         public Parent createControl() {
 129             TableView tableView = new TableView();
 130 //            tableView.getColumns().addAll(TableColumnBuilder.create()
 131 //                        .minWidth(50)
 132 //                        .cellValueFactory(new PropertyValueFactory("test"))
 133 //                        .text("Test")
 134 //                        .build());
 135             TableColumn tableColumn = new TableColumn("Text");
 136             tableColumn.setMinWidth(50);
 137             tableColumn.setCellValueFactory(new PropertyValueFactory("test"));
 138             tableView.getColumns().add(tableColumn);
 139             System.err.println("TableColumnFactory is temporarily modifier. Please, review once http://javafx-jira.kenai.com/browse/RT-27027 is resolved.");
 140 
 141             tableView.getItems().addAll(FXCollections.observableArrayList((Object)new TestTableItem()));
 142             tableView.setMaxHeight(150);
 143             tableView.setMaxWidth(150);
 144             return tableView;
 145         }
 146     }),
 147 
 148     Accordion(new DefaultFactory() {
 149 
 150         @Override
 151         public Parent createControl() {
 152             TitledPane expandedPane = new TitledPane("Test1", new Button("Test3"));
 153                         TitledPane otherPane = new TitledPane();
 154                         otherPane.setText("Test2");
 155                         Accordion temp = new Accordion(expandedPane, otherPane);
 156                         temp.setMaxHeight(200);
 157                         temp.setMaxWidth(200);
 158                         temp.setExpandedPane(expandedPane);
 159                         return temp;
 160         }
 161     }),
 162     Slider(new DefaultFactory() {
 163 
 164         @Override
 165         public Parent createControl() {
 166             Parent value = new Slider();
 167                         ((Slider)value).setShowTickLabels(true);
 168                         ((Slider)value).setShowTickMarks(true);
 169                         ((Slider)value).setMaxWidth(150);
 170                         value.setId("TestSlider");
 171             return value;
 172         }
 173     }),
 174     ProgressIndicator(new DefaultFactory() {
 175 
 176         @Override
 177         public Parent createControl() {
 178             ProgressIndicator temp = new ProgressIndicator(0.02);
 179                         temp.setMaxHeight(50);
 180                         temp.setMaxWidth(50);
 181                         return temp;
 182         }
 183     })
 184     ;
 185 
 186     private Factory factory;
 187 
 188     private Factories(Factory factory) {
 189         this.factory = factory;
 190     }
 191 
 192     public Parent createControl(boolean lcd) {
 193         return factory.createControl(lcd);
 194     }
 195 
 196 }
 197