< prev index next >

modules/controls/src/test/java/test/javafx/scene/control/TreeTableViewTest.java

Print this page




   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 
  26 package test.javafx.scene.control;
  27 

  28 import static com.sun.xml.internal.fastinfoset.alphabet.BuiltInRestrictedAlphabets.table;
  29 import static test.com.sun.javafx.scene.control.infrastructure.ControlTestUtils.assertStyleClassContains;
  30 import static javafx.scene.control.TreeTableColumn.SortType.ASCENDING;
  31 import static javafx.scene.control.TreeTableColumn.SortType.DESCENDING;
  32 import static org.junit.Assert.*;
  33 import static org.junit.Assert.assertEquals;
  34 
  35 import java.util.ArrayList;
  36 import java.util.Comparator;
  37 import java.util.List;
  38 import java.util.Objects;
  39 import java.util.concurrent.atomic.AtomicInteger;
  40 import java.util.function.Supplier;
  41 import java.util.stream.Collectors;
  42 
  43 import com.sun.javafx.scene.control.behavior.TreeTableCellBehavior;
  44 import javafx.beans.property.ReadOnlyIntegerWrapper;
  45 import javafx.collections.transformation.FilteredList;
  46 import javafx.scene.control.TableColumn;
  47 import javafx.scene.control.TableView;


2705         root.setExpanded(true);
2706         table.setRoot(root);
2707         table.setShowRoot(false);
2708         root.getChildren().setAll(persons);
2709 
2710         TreeTableColumn first = new TreeTableColumn("First Name");
2711         first.setCellValueFactory(new TreeItemPropertyValueFactory<Person, String>("firstName"));
2712 
2713         TreeTableColumn last = new TreeTableColumn("Last Name");
2714         last.setCellValueFactory(new TreeItemPropertyValueFactory<Person, String>("lastName"));
2715 
2716         TreeTableColumn email = new TreeTableColumn("Email");
2717         email.setCellValueFactory(new TreeItemPropertyValueFactory<Person, String>("email"));
2718 
2719         table.getColumns().addAll(first, last, email);
2720 
2721         // load the table
2722         StageLoader sl = new StageLoader(table);
2723 
2724         // resize the last column
2725         last.impl_setWidth(400);
2726         assertEquals(400, last.getWidth(), 0.0);
2727 
2728         // hide the first column
2729         table.getColumns().remove(first);
2730         Toolkit.getToolkit().firePulse();
2731 
2732         // the last column should still be 400px, not the default width or any
2733         // other value (based on the width of the content in that column)
2734         assertEquals(400, last.getWidth(), 0.0);
2735 
2736         sl.dispose();
2737     }
2738 
2739     @Test public void test_rt26721_collapseParent_firstRootChild() {
2740         TreeTableView<String> table = new TreeTableView<>();
2741         table.setRoot(new TreeItem("Root"));
2742         table.getRoot().setExpanded(true);
2743 
2744         for (int i = 0; i < 4; i++) {
2745             TreeItem parent = new TreeItem("item - " + i);




   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 
  26 package test.javafx.scene.control;
  27 
  28 import com.sun.javafx.scene.control.TableColumnBaseHelper;
  29 import static com.sun.xml.internal.fastinfoset.alphabet.BuiltInRestrictedAlphabets.table;
  30 import static test.com.sun.javafx.scene.control.infrastructure.ControlTestUtils.assertStyleClassContains;
  31 import static javafx.scene.control.TreeTableColumn.SortType.ASCENDING;
  32 import static javafx.scene.control.TreeTableColumn.SortType.DESCENDING;
  33 import static org.junit.Assert.*;
  34 import static org.junit.Assert.assertEquals;
  35 
  36 import java.util.ArrayList;
  37 import java.util.Comparator;
  38 import java.util.List;
  39 import java.util.Objects;
  40 import java.util.concurrent.atomic.AtomicInteger;
  41 import java.util.function.Supplier;
  42 import java.util.stream.Collectors;
  43 
  44 import com.sun.javafx.scene.control.behavior.TreeTableCellBehavior;
  45 import javafx.beans.property.ReadOnlyIntegerWrapper;
  46 import javafx.collections.transformation.FilteredList;
  47 import javafx.scene.control.TableColumn;
  48 import javafx.scene.control.TableView;


2706         root.setExpanded(true);
2707         table.setRoot(root);
2708         table.setShowRoot(false);
2709         root.getChildren().setAll(persons);
2710 
2711         TreeTableColumn first = new TreeTableColumn("First Name");
2712         first.setCellValueFactory(new TreeItemPropertyValueFactory<Person, String>("firstName"));
2713 
2714         TreeTableColumn last = new TreeTableColumn("Last Name");
2715         last.setCellValueFactory(new TreeItemPropertyValueFactory<Person, String>("lastName"));
2716 
2717         TreeTableColumn email = new TreeTableColumn("Email");
2718         email.setCellValueFactory(new TreeItemPropertyValueFactory<Person, String>("email"));
2719 
2720         table.getColumns().addAll(first, last, email);
2721 
2722         // load the table
2723         StageLoader sl = new StageLoader(table);
2724 
2725         // resize the last column
2726         TableColumnBaseHelper.setWidth(last, 400);
2727         assertEquals(400, last.getWidth(), 0.0);
2728 
2729         // hide the first column
2730         table.getColumns().remove(first);
2731         Toolkit.getToolkit().firePulse();
2732 
2733         // the last column should still be 400px, not the default width or any
2734         // other value (based on the width of the content in that column)
2735         assertEquals(400, last.getWidth(), 0.0);
2736 
2737         sl.dispose();
2738     }
2739 
2740     @Test public void test_rt26721_collapseParent_firstRootChild() {
2741         TreeTableView<String> table = new TreeTableView<>();
2742         table.setRoot(new TreeItem("Root"));
2743         table.getRoot().setExpanded(true);
2744 
2745         for (int i = 0; i < 4; i++) {
2746             TreeItem parent = new TreeItem("item - " + i);


< prev index next >