< prev index next >

functional/ControlsTests/src/javafx/scene/control/test/pagination/PaginationApp.java

Print this page




  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.pagination;
  26 
  27 import javafx.event.ActionEvent;
  28 import javafx.event.EventHandler;
  29 import javafx.scene.Node;
  30 import javafx.scene.Scene;
  31 import javafx.scene.control.Button;
  32 import javafx.scene.control.ButtonBuilder;
  33 import javafx.scene.control.Label;
  34 import javafx.scene.control.Pagination;
  35 import javafx.scene.control.test.utils.*;
  36 import javafx.scene.control.test.utils.ptables.PropertiesTable;
  37 import javafx.scene.control.test.utils.ptables.PropertyTablesFactory;
  38 import javafx.scene.control.test.utils.ptables.SpecialTablePropertiesProvider;
  39 import javafx.scene.layout.HBox;
  40 import javafx.scene.layout.VBox;
  41 import javafx.util.Callback;
  42 import static org.junit.Assert.assertFalse;
  43 import static org.junit.Assert.assertTrue;
  44 import test.javaclient.shared.InteroperabilityApp;
  45 import test.javaclient.shared.Utils;
  46 
  47 /**
  48  * @author Alexander Kirov
  49  */
  50 public class PaginationApp extends InteroperabilityApp {
  51 
  52     public final static String TESTED_PAGINATION_ID = "TESTED_PAGINATION_ID";


  93             for (int i = 0; i < MAX_CONTENT; i++) {
  94                 content[i] = "some text " + i;
  95             }
  96 
  97             testedPagination = new Pagination(i);
  98             testedPagination.setId(TESTED_PAGINATION_ID);
  99 
 100             testedPagination.setPageFactory(new Callback<Integer, Node>() {
 101                 @Override
 102                 public Node call(Integer pageIndex) {
 103                     return createPage(pageIndex);
 104                 }
 105             });
 106 
 107             tb = new PropertiesTable(testedPagination);
 108             PropertyTablesFactory.explorePropertiesList(testedPagination, tb);
 109             SpecialTablePropertiesProvider.provideForControl(testedPagination, tb);
 110             tb.addDoublePropertyLine(testedPagination.minHeightProperty(), -100, 300, 50, testedPagination);
 111             tb.addDoublePropertyLine(testedPagination.minWidthProperty(), -100, 300, 50, testedPagination);
 112 
 113             Button hardResetButton = ButtonBuilder.create().id(HARD_RESET_BUTTON_ID).text("Hard reset").build();

 114             hardResetButton.setOnAction(new EventHandler<ActionEvent>() {
 115                 public void handle(ActionEvent t) {
 116                     HBox hb = (HBox) getRoot();
 117                     hb.getChildren().clear();
 118                     prepareMainSceneStructure();
 119                     prepareScene();
 120                 }
 121             });
 122 
 123             Button setBulletPageIndicatorButton = ButtonBuilder.create().id(SET_BULLET_PAGE_INDICATOR_BUTTON_ID).text("Set bullet").build();

 124             setBulletPageIndicatorButton.setOnAction(new EventHandler<ActionEvent>() {
 125                 public void handle(ActionEvent t) {
 126                     //testedPagination.setStyle(Pagination.STYLE_CLASS_BULLET);
 127                     testedPagination.getStyleClass().add(Pagination.STYLE_CLASS_BULLET);
 128                 }
 129             });
 130 
 131             Button setPageCountToIndeterminateButton = ButtonBuilder.create().id(SET_PAGE_COUNT_TO_INDETERMINATE_BUTTON_ID).text("Set indeterminate\n page count").build();

 132             setPageCountToIndeterminateButton.setOnAction(new EventHandler<ActionEvent>() {
 133                 public void handle(ActionEvent t) {
 134                     testedPagination.setPageCount(Pagination.INDETERMINATE);
 135                 }
 136             });
 137 
 138             Button softResetButton = ButtonBuilder.create().id(SOFT_RESET_BUTTON_ID).text("Soft reset").build();

 139             softResetButton.setOnAction(new EventHandler<ActionEvent>() {
 140                 @Override
 141                 public void handle(ActionEvent t) {
 142                     tb.refresh();
 143                     Pagination newOne = new Pagination(i);
 144                     testedPagination.setCurrentPageIndex(newOne.getCurrentPageIndex());
 145                     testedPagination.setPageCount(newOne.getPageCount());
 146                     testedPagination.setPageFactory(newOne.getPageFactory());
 147                     testedPagination.setMaxPageIndicatorCount(newOne.maxPageIndicatorCountProperty().get());
 148                 }
 149             });
 150 
 151             Button setNewPageFactory = ButtonBuilder.create().id(SET_NEW_PAGE_FACTORY_BUTTON_ID).text("Set new page factory").build();

 152             setNewPageFactory.setOnAction(new EventHandler<ActionEvent>() {
 153                 @Override
 154                 public void handle(ActionEvent t) {
 155                     Callback<Integer, Node> newOne = new Callback<Integer, Node>() {
 156                         @Override
 157                         public Node call(Integer pageIndex) {
 158                             return createPage2(pageIndex);
 159                         }
 160                     };
 161 
 162                     Callback<Integer, Node> oldOne = testedPagination.getPageFactory();
 163 
 164                     testedPagination.setPageFactory(newOne);
 165 
 166                     assertTrue(testedPagination.pageFactoryProperty().getValue().equals(newOne));
 167                     assertTrue(testedPagination.getPageFactory().equals(newOne));
 168                     assertFalse(testedPagination.pageFactoryProperty().getValue().equals(oldOne));
 169                     assertFalse(testedPagination.getPageFactory().equals(oldOne));
 170                 }
 171             });
 172 
 173             Button setOldPageFactory = ButtonBuilder.create().id(SET_OLD_PAGE_FACTORY_BUTTON_ID).text("Set old page factory").build();

 174             setOldPageFactory.setOnAction(new EventHandler<ActionEvent>() {
 175                 @Override
 176                 public void handle(ActionEvent t) {
 177                     Callback<Integer, Node> newOne = new Callback<Integer, Node>() {
 178                         @Override
 179                         public Node call(Integer pageIndex) {
 180                             return createPage(pageIndex);
 181                         }
 182                     };
 183 
 184                     Callback<Integer, Node> oldOne = testedPagination.getPageFactory();
 185 
 186                     testedPagination.setPageFactory(newOne);
 187 
 188                     assertTrue(testedPagination.pageFactoryProperty().getValue().equals(newOne));
 189                     assertTrue(testedPagination.getPageFactory().equals(newOne));
 190                     assertFalse(testedPagination.pageFactoryProperty().getValue().equals(oldOne));
 191                     assertFalse(testedPagination.getPageFactory().equals(oldOne));
 192                 }
 193             });




  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.pagination;
  26 
  27 import javafx.event.ActionEvent;
  28 import javafx.event.EventHandler;
  29 import javafx.scene.Node;
  30 import javafx.scene.Scene;
  31 import javafx.scene.control.Button;

  32 import javafx.scene.control.Label;
  33 import javafx.scene.control.Pagination;
  34 import javafx.scene.control.test.utils.*;
  35 import javafx.scene.control.test.utils.ptables.PropertiesTable;
  36 import javafx.scene.control.test.utils.ptables.PropertyTablesFactory;
  37 import javafx.scene.control.test.utils.ptables.SpecialTablePropertiesProvider;
  38 import javafx.scene.layout.HBox;
  39 import javafx.scene.layout.VBox;
  40 import javafx.util.Callback;
  41 import static org.junit.Assert.assertFalse;
  42 import static org.junit.Assert.assertTrue;
  43 import test.javaclient.shared.InteroperabilityApp;
  44 import test.javaclient.shared.Utils;
  45 
  46 /**
  47  * @author Alexander Kirov
  48  */
  49 public class PaginationApp extends InteroperabilityApp {
  50 
  51     public final static String TESTED_PAGINATION_ID = "TESTED_PAGINATION_ID";


  92             for (int i = 0; i < MAX_CONTENT; i++) {
  93                 content[i] = "some text " + i;
  94             }
  95 
  96             testedPagination = new Pagination(i);
  97             testedPagination.setId(TESTED_PAGINATION_ID);
  98 
  99             testedPagination.setPageFactory(new Callback<Integer, Node>() {
 100                 @Override
 101                 public Node call(Integer pageIndex) {
 102                     return createPage(pageIndex);
 103                 }
 104             });
 105 
 106             tb = new PropertiesTable(testedPagination);
 107             PropertyTablesFactory.explorePropertiesList(testedPagination, tb);
 108             SpecialTablePropertiesProvider.provideForControl(testedPagination, tb);
 109             tb.addDoublePropertyLine(testedPagination.minHeightProperty(), -100, 300, 50, testedPagination);
 110             tb.addDoublePropertyLine(testedPagination.minWidthProperty(), -100, 300, 50, testedPagination);
 111 
 112             Button hardResetButton = new Button("Hard reset");
 113             hardResetButton.setId(HARD_RESET_BUTTON_ID);
 114             hardResetButton.setOnAction(new EventHandler<ActionEvent>() {
 115                 public void handle(ActionEvent t) {
 116                     HBox hb = (HBox) getRoot();
 117                     hb.getChildren().clear();
 118                     prepareMainSceneStructure();
 119                     prepareScene();
 120                 }
 121             });
 122 
 123             Button setBulletPageIndicatorButton = new Button("Set bullet");
 124             setBulletPageIndicatorButton.setId(SET_BULLET_PAGE_INDICATOR_BUTTON_ID);
 125             setBulletPageIndicatorButton.setOnAction(new EventHandler<ActionEvent>() {
 126                 public void handle(ActionEvent t) {
 127                     //testedPagination.setStyle(Pagination.STYLE_CLASS_BULLET);
 128                     testedPagination.getStyleClass().add(Pagination.STYLE_CLASS_BULLET);
 129                 }
 130             });
 131 
 132             Button setPageCountToIndeterminateButton = new Button("Set indeterminate\n page count");
 133             setPageCountToIndeterminateButton.setId(SET_PAGE_COUNT_TO_INDETERMINATE_BUTTON_ID);
 134             setPageCountToIndeterminateButton.setOnAction(new EventHandler<ActionEvent>() {
 135                 public void handle(ActionEvent t) {
 136                     testedPagination.setPageCount(Pagination.INDETERMINATE);
 137                 }
 138             });
 139 
 140             Button softResetButton = new Button("Soft reset");
 141             softResetButton.setId(SOFT_RESET_BUTTON_ID);
 142             softResetButton.setOnAction(new EventHandler<ActionEvent>() {
 143                 @Override
 144                 public void handle(ActionEvent t) {
 145                     tb.refresh();
 146                     Pagination newOne = new Pagination(i);
 147                     testedPagination.setCurrentPageIndex(newOne.getCurrentPageIndex());
 148                     testedPagination.setPageCount(newOne.getPageCount());
 149                     testedPagination.setPageFactory(newOne.getPageFactory());
 150                     testedPagination.setMaxPageIndicatorCount(newOne.maxPageIndicatorCountProperty().get());
 151                 }
 152             });
 153 
 154             Button setNewPageFactory = new Button("Set new page factory");
 155             setNewPageFactory.setId(SET_NEW_PAGE_FACTORY_BUTTON_ID);
 156             setNewPageFactory.setOnAction(new EventHandler<ActionEvent>() {
 157                 @Override
 158                 public void handle(ActionEvent t) {
 159                     Callback<Integer, Node> newOne = new Callback<Integer, Node>() {
 160                         @Override
 161                         public Node call(Integer pageIndex) {
 162                             return createPage2(pageIndex);
 163                         }
 164                     };
 165 
 166                     Callback<Integer, Node> oldOne = testedPagination.getPageFactory();
 167 
 168                     testedPagination.setPageFactory(newOne);
 169 
 170                     assertTrue(testedPagination.pageFactoryProperty().getValue().equals(newOne));
 171                     assertTrue(testedPagination.getPageFactory().equals(newOne));
 172                     assertFalse(testedPagination.pageFactoryProperty().getValue().equals(oldOne));
 173                     assertFalse(testedPagination.getPageFactory().equals(oldOne));
 174                 }
 175             });
 176 
 177             Button setOldPageFactory = new Button("Set old page factory");
 178             setOldPageFactory.setId(SET_OLD_PAGE_FACTORY_BUTTON_ID);
 179             setOldPageFactory.setOnAction(new EventHandler<ActionEvent>() {
 180                 @Override
 181                 public void handle(ActionEvent t) {
 182                     Callback<Integer, Node> newOne = new Callback<Integer, Node>() {
 183                         @Override
 184                         public Node call(Integer pageIndex) {
 185                             return createPage(pageIndex);
 186                         }
 187                     };
 188 
 189                     Callback<Integer, Node> oldOne = testedPagination.getPageFactory();
 190 
 191                     testedPagination.setPageFactory(newOne);
 192 
 193                     assertTrue(testedPagination.pageFactoryProperty().getValue().equals(newOne));
 194                     assertTrue(testedPagination.getPageFactory().equals(newOne));
 195                     assertFalse(testedPagination.pageFactoryProperty().getValue().equals(oldOne));
 196                     assertFalse(testedPagination.getPageFactory().equals(oldOne));
 197                 }
 198             });


< prev index next >