functional/ControlsTests/src/javafx/scene/control/test/tabpane/NewTabPaneApp.java

Print this page




  74         //VBox which contain tested TabPane.
  75         Pane pane;
  76         //TabPane to be tested.
  77         TabPane testedTabPane;
  78         TabPaneWithControl tabPane;
  79         private PropertiesTable tb;
  80 
  81         public TabPaneScene() {
  82             super("Tab pane tests", 800, 600);
  83 
  84             prepareScene();
  85         }
  86 
  87         @Override
  88         public final void prepareScene() {
  89             pane = new Pane();
  90             pane.setMinSize(220, 220);
  91             pane.setPrefSize(220, 220);
  92             pane.setStyle("-fx-border-color : red;");
  93 
  94             testedTabPane = TabPaneBuilder.create().id(TESTED_TABPANE_ID).build();

  95             pane.getChildren().add(testedTabPane);
  96 
  97             tb = new PropertiesTable(testedTabPane);
  98             PropertyTablesFactory.explorePropertiesList(testedTabPane, tb);
  99 
 100             Button btnResetHardly = ButtonBuilder.create().id(RESET_BUTTON_ID).text("Reset").build();

 101             btnResetHardly.setOnAction(new EventHandler<ActionEvent>() {
 102                 public void handle(ActionEvent t) {
 103                     HBox hb = (HBox) getRoot();
 104                     hb.getChildren().clear();
 105                     prepareMainSceneStructure();
 106                     prepareScene();
 107                 }
 108             });
 109 
 110             Button btnResetSoftly = ButtonBuilder.create().id(RESET_SOFTLY_BUTTON_ID).text("Reset softly").build();

 111             btnResetSoftly.setOnAction(new EventHandler<ActionEvent>() {
 112                 public void handle(ActionEvent t) {
 113 
 114                     tb.refresh();
 115 
 116                     TabPane newInstance = new TabPane();
 117                     while (testedTabPane.getTabs().size() != 0) {
 118                         testedTabPane.getTabs().remove(0);
 119                     }
 120 
 121                     testedTabPane.setSide(newInstance.getSide());
 122                     testedTabPane.setPrefHeight(newInstance.getPrefHeight());
 123                     testedTabPane.setMinHeight(newInstance.getMinHeight());
 124                     testedTabPane.setMaxHeight(newInstance.getMaxHeight());
 125                     testedTabPane.setPrefWidth(newInstance.getPrefWidth());
 126                     testedTabPane.setMinWidth(newInstance.getMinWidth());
 127                     testedTabPane.setMaxWidth(newInstance.getMaxWidth());
 128                     testedTabPane.setVisible(newInstance.isVisible());
 129                     testedTabPane.setDisable(newInstance.isDisable());
 130                     testedTabPane.setContextMenu(newInstance.getContextMenu());


 159         /**
 160          *
 161          * @return controls which set parameters and create the new tab
 162          */
 163         private Pane getControlsForTabCreation(final TabPaneWithControl tabPane) {
 164 
 165             GridPane grid = new GridPane();
 166 
 167             grid.setStyle("-fx-border-color:DARKBLUE");
 168             grid.setHgap(5);
 169             grid.setVgap(5);
 170 
 171             ColumnConstraints column1 = new ColumnConstraints();
 172             column1.setPercentWidth(40);
 173             ColumnConstraints column2 = new ColumnConstraints();
 174             column2.setPercentWidth(60);
 175 
 176             grid.getColumnConstraints().addAll(column1, column2);
 177             //row #1
 178             grid.add(new Label("Tab ID"), 0, 0);
 179             final TextField newTabId = TextFieldBuilder.create()
 180                     .id(NEW_TAB_ID_TEXT_FIELD_ID)
 181                     .text("ID")
 182                     .prefWidth(40d)
 183                     .build();
 184             grid.add(newTabId, 1, 0);
 185 
 186             //row #2
 187             grid.add(new Label("Index"), 0, 1);
 188             final TextField newTabIndex = TextFieldBuilder.create()
 189                     .id(TABPANE_ADD_INDEX_TEXT_FIELD_ID)
 190                     .text("0")
 191                     .prefWidth(40)
 192                     .build();
 193             grid.add(newTabIndex, 1, 1);
 194 
 195             //row #3
 196             grid.add(new Label("Content"), 0, 2);
 197             final ChoiceBox<NodeFactory> cb = new ChoiceBox<NodeFactory>();
 198             cb.setId(NODE_CHOSER_CHOICE_BOX_ID);
 199             cb.getItems().addAll(ControlsFactory.filteredValues());
 200             cb.getItems().addAll(Shapes.values());
 201             cb.getItems().addAll(Panes.values());
 202             grid.add(cb, 1, 2);
 203 
 204             //row #4
 205             /*
 206              * If true then there will be created a properties pane
 207              * for tab content each time a tab is added
 208              */
 209             final CheckBox createPropsTab = CheckBoxBuilder
 210                     .create()
 211                     .text("Create additional panes\n with content properties")
 212                     .build();
 213             grid.add(createPropsTab, 0, 3, 2, 1);
 214 
 215             //row #5
 216             /*
 217              * If true then there will be created a properties pane
 218              * for tab content each time a tab is added
 219              */
 220             final CheckBox vetoOnClose = CheckBoxBuilder
 221                     .create()
 222                     .text("Veto tab request on close.")
 223                     .id(VETO_CHECKBOX_ID)
 224                     .build();
 225             grid.add(vetoOnClose, 0, 4, 2, 1);
 226 
 227             //row #6
 228             Button actionButton = new Button("Create new tab");
 229             actionButton.setId(NODE_CHOOSER_ACTION_BUTTON_ID);
 230 
 231             final NodesChoserFactory.NodeAction<Node> handler = new NodesChoserFactory.NodeAction<Node>() {
 232                 @Override
 233                 public void execute(Node node) {
 234                     Tab tab = new Tab();
 235 
 236                     tab.setId(newTabId.getText());
 237                     tab.setText(newTabId.getText());
 238                     tab.setContent(node);
 239 
 240                     final NodesStorage fullController = NodeControllerFactory.createFullController(tab, tabPane);
 241                     fullController.pt.addCounter(TAB_CLOSE_REQUEST_EVENT);
 242 
 243                     tab.setOnCloseRequest(new EventHandler<Event>() {
 244                         private boolean useVeto = vetoOnClose.isSelected();




  74         //VBox which contain tested TabPane.
  75         Pane pane;
  76         //TabPane to be tested.
  77         TabPane testedTabPane;
  78         TabPaneWithControl tabPane;
  79         private PropertiesTable tb;
  80 
  81         public TabPaneScene() {
  82             super("Tab pane tests", 800, 600);
  83 
  84             prepareScene();
  85         }
  86 
  87         @Override
  88         public final void prepareScene() {
  89             pane = new Pane();
  90             pane.setMinSize(220, 220);
  91             pane.setPrefSize(220, 220);
  92             pane.setStyle("-fx-border-color : red;");
  93 
  94             testedTabPane = new TabPane();

  95             testedTabPane.setId(TESTED_TABPANE_ID);

  96             pane.getChildren().add(testedTabPane);
  97 
  98             tb = new PropertiesTable(testedTabPane);
  99             PropertyTablesFactory.explorePropertiesList(testedTabPane, tb);
 100 
 101             Button btnResetHardly = new Button("Reset");

 102             btnResetHardly.setId(RESET_BUTTON_ID);

 103             btnResetHardly.setOnAction(new EventHandler<ActionEvent>() {
 104                 public void handle(ActionEvent t) {
 105                     HBox hb = (HBox) getRoot();
 106                     hb.getChildren().clear();
 107                     prepareMainSceneStructure();
 108                     prepareScene();
 109                 }
 110             });
 111 
 112             Button btnResetSoftly = new Button("Reset softly");

 113             btnResetSoftly.setId(RESET_SOFTLY_BUTTON_ID);

 114             btnResetSoftly.setOnAction(new EventHandler<ActionEvent>() {
 115                 public void handle(ActionEvent t) {
 116 
 117                     tb.refresh();
 118 
 119                     TabPane newInstance = new TabPane();
 120                     while (testedTabPane.getTabs().size() != 0) {
 121                         testedTabPane.getTabs().remove(0);
 122                     }
 123 
 124                     testedTabPane.setSide(newInstance.getSide());
 125                     testedTabPane.setPrefHeight(newInstance.getPrefHeight());
 126                     testedTabPane.setMinHeight(newInstance.getMinHeight());
 127                     testedTabPane.setMaxHeight(newInstance.getMaxHeight());
 128                     testedTabPane.setPrefWidth(newInstance.getPrefWidth());
 129                     testedTabPane.setMinWidth(newInstance.getMinWidth());
 130                     testedTabPane.setMaxWidth(newInstance.getMaxWidth());
 131                     testedTabPane.setVisible(newInstance.isVisible());
 132                     testedTabPane.setDisable(newInstance.isDisable());
 133                     testedTabPane.setContextMenu(newInstance.getContextMenu());


 162         /**
 163          *
 164          * @return controls which set parameters and create the new tab
 165          */
 166         private Pane getControlsForTabCreation(final TabPaneWithControl tabPane) {
 167 
 168             GridPane grid = new GridPane();
 169 
 170             grid.setStyle("-fx-border-color:DARKBLUE");
 171             grid.setHgap(5);
 172             grid.setVgap(5);
 173 
 174             ColumnConstraints column1 = new ColumnConstraints();
 175             column1.setPercentWidth(40);
 176             ColumnConstraints column2 = new ColumnConstraints();
 177             column2.setPercentWidth(60);
 178 
 179             grid.getColumnConstraints().addAll(column1, column2);
 180             //row #1
 181             grid.add(new Label("Tab ID"), 0, 0);
 182             final TextField newTabId = new TextField("ID");

 183             newTabId.setPrefWidth(40d);

 184             newTabId.setId(NEW_TAB_ID_TEXT_FIELD_ID);



 185             grid.add(newTabId, 1, 0);
 186 
 187             //row #2
 188             grid.add(new Label("Index"), 0, 1);
 189             final TextField newTabIndex = new TextField("0");

 190             newTabIndex.setId(TABPANE_ADD_INDEX_TEXT_FIELD_ID);

 191             newTabIndex.setPrefWidth(40);



 192             grid.add(newTabIndex, 1, 1);
 193 
 194             //row #3
 195             grid.add(new Label("Content"), 0, 2);
 196             final ChoiceBox<NodeFactory> cb = new ChoiceBox<NodeFactory>();
 197             cb.setId(NODE_CHOSER_CHOICE_BOX_ID);
 198             cb.getItems().addAll(ControlsFactory.filteredValues());
 199             cb.getItems().addAll(Shapes.values());
 200             cb.getItems().addAll(Panes.values());
 201             grid.add(cb, 1, 2);
 202 
 203             //row #4
 204             /*
 205              * If true then there will be created a properties pane
 206              * for tab content each time a tab is added
 207              */
 208             final CheckBox createPropsTab = new CheckBox("Create additional panes\n with content properties");




 209             grid.add(createPropsTab, 0, 3, 2, 1);
 210 
 211             //row #5
 212             /*
 213              * If true then there will be created a properties pane
 214              * for tab content each time a tab is added
 215              */
 216             final CheckBox vetoOnClose = new CheckBox("Veto tab request on close.");

 217             vetoOnClose.setId(VETO_CHECKBOX_ID);




 218             grid.add(vetoOnClose, 0, 4, 2, 1);
 219 
 220             //row #6
 221             Button actionButton = new Button("Create new tab");
 222             actionButton.setId(NODE_CHOOSER_ACTION_BUTTON_ID);
 223 
 224             final NodesChoserFactory.NodeAction<Node> handler = new NodesChoserFactory.NodeAction<Node>() {
 225                 @Override
 226                 public void execute(Node node) {
 227                     Tab tab = new Tab();
 228 
 229                     tab.setId(newTabId.getText());
 230                     tab.setText(newTabId.getText());
 231                     tab.setContent(node);
 232 
 233                     final NodesStorage fullController = NodeControllerFactory.createFullController(tab, tabPane);
 234                     fullController.pt.addCounter(TAB_CLOSE_REQUEST_EVENT);
 235                     
 236                     tab.setOnCloseRequest(new EventHandler<Event>() {
 237                         private boolean useVeto = vetoOnClose.isSelected();