TreeView with mixed cell types

I would like to create a TreeView when some cells are CheckBoxTreeCells and
Some are not. My scope is a medical search engine where we
to have the investigator question a dataset by selecting one or more values. Here is one
simple example:
public class CheckBoxTreeSample extends Application {
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("CheckBoxTree Attempt");
        TreeItem<String> rootItem = new TreeItem<>("Dataset root");
        rootItem.setExpanded(true);

        final TreeView tree = new TreeView(rootItem);
        final TreeItem<String> testResultsItem = new TreeItem<>("Test Results");
        rootItem.getChildren().add(testResultsItem);
        testResultsItem.setExpanded(true);

        final CheckBoxTreeItem<String> normalTreeItem = new CheckBoxTreeItem<>("Normal");
        testResultsItem.getChildren().add(normalTreeItem);
        final CheckBoxTreeItem<String> abnormalTreeItem = new CheckBoxTreeItem<>("Abnormal");
        testResultsItem.getChildren().add(abnormalTreeItem);
        final CheckBoxTreeItem<String> preTreeItem = new CheckBoxTreeItem<>("PreCancer");
        testResultsItem.getChildren().add(preTreeItem);
        final CheckBoxTreeItem<String> cancerTreeItem = new CheckBoxTreeItem<>("Cancer");
        testResultsItem.getChildren().add(cancerTreeItem);

        tree.setCellFactory(CheckBoxTreeCell.<String>forTreeView()); 
                       
        tree.setRoot(rootItem);
        tree.setShowRoot(true);

        StackPane root = new StackPane();
        root.getChildren().add(tree);
        primaryStage.setScene(new Scene(root, 300, 250));
        primaryStage.show();
    }
}
So I would like to have the testResultsItem and the rootItem NOT have check boxes (which is why they are elements a treeitem), but have end-nodes be independent
CheckBoxTreeItems. I tried this plant replacement, but that seems only to control the Boolean property:
        tree.setCellFactory(CheckBoxTreeCell.<String>forTreeView(new Callback<TreeItem<String>, ObservableValue<Boolean>>() {
          @Override
          public ObservableValue<Boolean> call (TreeItem<String> item) {
            if (item instanceof CheckBoxTreeItem) {
              return new ReadOnlyBooleanWrapper(Boolean.TRUE);
            } else {
              return null; //Don't display an CheckBox - obviously doesn't work...
            }
          }
        }));
Recently, I saw this ad by Jonathan Giles:
http://fxexperience.com/2012/05/ListView-custom-cell-factories-and-context-menus/
but I don't know how that could apply to the present case.

All help to determine how to remove or disable the checkboxes of the nonleaf node at least, would be greatly
appreciated!

BOPF wrote:
Hi James,
Thanks for your solution - it seems to work pretty well, but it takes a little time for me to integrate it in my 'real' code Unsurprisingly, I have more complex than the strings in the tree objects. I hope that it is not a conflict between the local box and the box private inside the CheckBoxTreeCell. Links should handle this, however.

I have use a CheckBoxTreeCell, so no :).

>

I wonder why the "CheckBoxCells" (Table, tree, ListCheckBoxCells) do not expose the box as part of the API. Alternatively, they could make the box protected to allow its extension. Here again, this is the first for these classes, and I have not created a large number of public APIs. :)

I think that the use of a CheckBoxTreeCell case is for the trees for which all elements treeitem is CheckBoxTreeItems. I think something like the import wizards in Eclipse. In this case, you don't need to access the box; This option is selected and indeterminate properties are directly related to the properties of the CheckBoxTreeItem. Your use case is a little more complex because you have mixed types of cells in your tree.

Of course, there may be something that I am missing, but it seems to work.

Tags: Java

Similar Questions

  • Reading of the text files with mixed data types.

    I was able to read a text file ASCII with different types of numbers (whole, real) and the chains are associated.  However, I can't read a timestamp that is in the calendar and the clock for carpet (dd/mm/yy HH).  In view of the line

    34 03/26/12/11 01:23:45 56 78 90

    I want to read the time directly, but so far all I can do is read the date and time as a string.  If the reading string is the best I can do, how to convert a value of internal time?

    No need to separate the date/time string in two different things.  Do it in one fell swoop.

  • I get what looks like a type of lines of scanning through my photos printed in Photoshop. They have been taken with a cell phone camera.

    I get what looks like a type of lines of scanning through my photos printed in Photoshop. They have been taken with a cell phone camera.

    You might be low on ink.

  • TreeView with icons displayed incorrectly after expansion (8 JavaFX)

    I have a TreeView with classes CellFactory and TreeCell custom, which has been implemented in JavaFX 2.2 and works perfectly. However, after I upgraded to 8 JavaFX. This tree is completely messed up. If I develop a nodes, there will be duplicate tree nodes in the tree. Here is a simplified version of the source code. If not use a method setGraphic() in class TreeCell, it works fine.

    package test;
    
    
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.control.TreeCell;
    import javafx.scene.control.TreeItem;
    import javafx.scene.control.TreeView;
    import javafx.scene.image.Image;
    import javafx.scene.image.ImageView;
    import javafx.scene.layout.BorderPane;
    import javafx.stage.Stage;
    import javafx.util.Callback;
    
    
    public class TreeViewTest extends Application {
        private static final Image image = new Image(TreeViewTest.class.getResourceAsStream("icon_datasource.png"));
        
        public TreeViewTest() {
        }
    
    
        @Override
        public void start(Stage primaryStage) {
            BorderPane rootPane = new BorderPane();
    
    
            TreeItem<String> root = new TreeItem<String>("Root");
            
            for (int i = 0; i < 5; i++) {
                TreeItem<String> ds = new TreeItem<String>("Datasource " + i);
                
                for (int t = 0; t < 5; t++) {
            TreeItem<String> tb = new TreeItem<String>("Table " + t);
            ds.getChildren().add(tb);
                }
                
                root.getChildren().add(ds);
            }
            
            TreeView<String> tree = new TreeView<String>();
            tree.setCellFactory(new Callback<TreeView<String>, TreeCell<String>>() {
         
         public TreeCell<String> call(TreeView<String> param) {
      return new TreeCell<String>() {
         @Override
         protected void updateItem(String item, boolean empty) {
             super.updateItem(item, empty);
             
             if (!empty) {
                 ImageView imageView = new ImageView(image);
                 setText(item);
                 setGraphic(imageView);
             }
         }
      };
         }
      });
            tree.setRoot(root);
            tree.setShowRoot(false);
            
            rootPane.setLeft(tree);
            
            Scene scene = new Scene(rootPane, 1024, 800);
    
    
            primaryStage.setTitle("Test");
            primaryStage.setScene(scene);
            primaryStage.show();
        }
        
        public static void main(String[] args) {
            launch(args);
        }
    }
    

    In general, cells are reused as items in TreeView (and some make, and ListViews) as soon as they become visible and invisible. It is perfectly possible for a cell to have an element that is not empty and then it change to empty, as the cell is reused for an empty cell.

    If you have a bug in your code: you need

    tree.setCellFactory(new Callback, TreeCell>() {
    
                public TreeCell call(TreeView param) {
                    return new TreeCell() {
                        @Override
                        protected void updateItem(String item, boolean empty) {
                            super.updateItem(item, empty);
    
                            if (!empty) {
                                ImageView imageView = new ImageView(image);
                                setText(item);
                                setGraphic(imageView);
                            } else {
                                setText(null);
                                setGraphic(null);
                            }
                        }
                    };
                }
            });
    

    You lucky in JavaFX2.2 that the re-use of cell does not seem to affect your bug. improving the effectiveness of the re-use of the cell in JavaFX 8 has exposed the problem.

    Furthermore, it is generally a bit pointless to re - create the nodes each time than updateItem (...) is called (frequently), rather than create them once when the cell is created (much less often). So consider

    tree.setCellFactory(new Callback, TreeCell>() {
    
                public TreeCell call(TreeView param) {
                    return new TreeCell() {
                        private ImageView imageView = new ImageView(image);
                        @Override
                        protected void updateItem(String item, boolean empty) {
                            super.updateItem(item, empty);
    
                            if (!empty) {
                                setText(item);
                                setGraphic(imageView);
                            } else {
                                setText(null);
                                setGraphic(null);
                            }
                        }
                    };
                }
            });
    

    Instead

  • Impossible to analyze your diet. Invalid XML: error on line 190: name of the "disabled" attribute associated with an element type "button" should be followed by the "=" character.

    Hello I am trying to download an episode of my Podcast podcast connect and get this error?

    Impossible to analyze your diet. Invalid XML: error on line 190: name of the "disabled" attribute associated with an element type "button" should be followed by the "=" character.

    my diet is validated? http://beprovidedhealthradio.libsyn.com/RSS

    It worked for my first episode? I don't know why it doesn't work for the second episode. I also use Libsyn if that helps.

    Your show is already in iTunes.

    https://iTunes.Apple.com/podcast/id1151562400?MT=2 & ls = 1

    And everything seems fine with it and your diet.  You ONLY SUBMIT YOUR FEED ONCE.

    That's it - better to stay outside of your podcast connect account - only bad things happen to go there and play with things.  Once again, your show is very well and is in iTunes and your flow is good with it.

    Both episodes show when you subscribe - and your most recent episode appears on the page of the iTunes, general store with in 24 hours from when you posted it.

    Rob W

    https://iTunes.Apple.com/us/podcast/beprovided-health-radio/id1151562400?MT=2 https://iTunes.Apple.com/us/podcast/beprovided-health-radio/id1151562400?MT=2

  • Formula that multiplies the value in each cell in a column with another cell

    Hello

    is it possible to do a simple way?

    I need a formula that will multiply each cell in a column, one by one, with another cell. And then a way to fill the 32 raws and 12 columns.

    That's how I explain what I need simplified.

    G1 = ((chaque cellule de B1:B32, un par un) * E1) + (( B1:B32each cell, one by one) * E2) +...

    and then that again and again for coulumn 12.

    G1 to G12.

    G2 would be = ((chaque cellule de C1:C32, un par un) * E1) + ((each cell c1:C32, one by one) * E2) +... and so on...

    It would take weeks to do this manually.

    It is, for me, very complicated and my brain can not understand.

    very grateful for the help with this one.

    Thank you

    /Joakim

    Hello

    I can't imagine the structure of your table according to your descriptions, but formulas would be very simple if you calculate:

    G1 = (B1*E1 + B2*E1 + ... + B32*E1) + (B1*E2 + B2*E2 + ... + B32*E2) + ...
       = (B1 + B2 + ... + B32) * (E1 + E2 + ...)
    

    For example,.

    Table 1 (excerpt)
    
    A1 
    A2 
    A3 
    A4 
       
    B1  =RANDBETWEEN(0,5)
    B2  =RANDBETWEEN(0,5)
    B3  =RANDBETWEEN(0,5)
    B4  =RANDBETWEEN(0,5)
       
    C1  =RANDBETWEEN(0,5)
    C2  =RANDBETWEEN(0,5)
    C3  =RANDBETWEEN(0,5)
    C4  =RANDBETWEEN(0,5)
       
    D1 
    D2 
    D3 
    D4 
       
    E1  =RANDBETWEEN(0,5)
    E2  =RANDBETWEEN(0,5)
    E3  =RANDBETWEEN(0,5)
    E4  =RANDBETWEEN(0,5)
       
    F1 
    F2 
    F3 
    F4 
       
    G1  =SUM(B1:B32)*SUM(E)
    G2  =SUM(C1:C32)*SUM(E)
    G3 
    G4 
    

    * Table is designed with numbers v2.

    Kind regards

    H

  • Video taken with a cell phone. It can be rotated?

    I know how to rotate photos, but adjustable videos? It was taken with a cell phone, side lanes.

    Hello

    1. what operating system do you use?

    2. what applications do you use?

    You can use Windows Live to movie maker do, for more information I suggest you send your query to the Windows Live support:

    http://www.windowslivehelp.com/product.aspx?ProductID=5

    http://www.windowslivehelp.com/

    I would also like you to Windows live movie maker, if you use Windows 7 free download

    http://Windows.Microsoft.com/en-us/Windows7/products/features/Movie-Maker

  • The default value for a property with data of type boolean

    Hi all

    Is it a system preference setting, where the default value for a property with data of type boolean can be a Virgin? I want to keep the value by default in a vacuum, but every time I save the property even after empty selection, the default value changes to FALSE.

    Capture.JPG

    In this case Boolean doesn't help you, you mayneed to create a chain of ownership and have true/false / "" as your list of values

  • Problem with Illustrator CC Type Vertical

    I'm trying to change the orientation of type in Illustrator CC, but it doesn't seem to work

    .

    Normally I select type > Type Orientation > Vertical and direction changes so that the letters are separate.

    Lately, however, when I select this option simply turns the whole line of text 90 degrees. The same thing happens with the vertical type tool, instead of typing one letter under the other, that he hit just as if I have my line turned.

    I tried the rotation of characters, but it does not work with the vertical type but it works very well with the horizontal type.

    Normal type

    Horizontal.jpg

    Vertical type

    Vertical.jpg

    Uh, using the version 2015.3 as well.

    I understand the problem anyway. In the paragraph Panel, I clicked on the drop down menu (Options) on the upper right corner, and I changed the setting to the instead of Middle Eastern single-line composer Adobe single-line composer.

    Maybe the problem has to do with the fact that um using Adobe ME.

    Thanks for your help.

  • After installing Acrobat or Reader on Windows 7 or Vista, icons of applications and file types change in Acrobat/Reader icon. Double click on a file or icon launches Acrobat or Reader. (The native application associated with the file type is not ope

    After installing Acrobat or Reader on Windows 7 or Vista, icons of applications and file types change in Acrobat/Reader icon. Double click on a file or icon launches Acrobat or Reader. (The native application associated with the file type is not open.)

    Hi peterb53490660,

    Try the steps of troubleshooting mentioned in this KB doc. https://helpx.Adobe.com/Acrobat/KB/application-file-icons-change-Acrobat.html

    Kind regards
    Nicos

  • How to make a list of question field with the data type DATE?

    I have a column with the DATE data type. Using forms 6i I want to generate a poplist field of list item with this column while the value of the items in the list of names of days like SATURDAY, SUNDAY, MONDAY. If we change the date to a char data type, it won't work properly, but now with the data type DATE behind him, it gives the following error message

    "FRM-32082: invalid value for given the type of element."
    List WEEKREST
    Article: WEEKREST
    Block: EMPRESTS
    Form: module 3
    FRM-30085: unable to adapt to the shape for the release. »


    Using forms 6i how a list item field type DATE data which may contain names of days?

    Set your date as a hidden field (not shown) column. Create your item list with the names of day of varchar2. Create the list item as a base table field that accepts the values of text in the names of the days. On this area, create a when-validate-item trigger that translated the text into an actual date that it then uses to set the value of the real object of the base table.

  • Value set with the table type

    Hi all
    I use R12.1.3 EBS. I want to create a value set with the posting type "Table". But I must specify what application will be set and the table to use. I want to refer to an another diet/no apps. Is this possible? I have the link of database between this regime to receivables / via SQL Developer, I'm able to query or manipulate the data.

    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    PL/SQL Release 11.1.0.7.0 - Production
    "CORE     11.1.0.7.0     Production"
    TNS for Linux: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    Thanks in advance,
    Bahchevanov.

    Create a custom view in the schema of APPS that points to the table in the remote database, and you should be able to create a validated set of values from table based on the custom view. This will require you to create a link of database on the remote database (or a private database link in the APPS schema)

    HTH
    Srini

  • problem with the CLOB type

    Hello, I am a beginner, I have a problem with the CLOB type, please help me
    I want to write the input file is filename and string base64, then output decoded base64 content in dicrectory location (for example C:\),my code was executed but if entry with base64 long string, it displays error)
    ORA-29285: file write error
    ORA-06512: at "SYS.UTL_FILE", line 136
    ORA-06512: at "SYS.UTL_FILE", line 813
    ORA-06512: at "SYSTEM.WRITED", line 9
    ORA-06512: at line 1
    29285. 00000 -  "file write error"
    *Cause:    Failed to write to, flush, or close a file.
    *Action:   Verify that the file exists, that it is accessible, and that
               it is open in write or append mode.
    And this is my code
    create or replace directory dir_temp as 'C:\';
    /
    create or replace procedure writed(filename varchar2,code  clob)
    as
      f utl_file.file_type;
      v_lob          BLOB;  
    
    begin
      v_lob :=  UTL_ENCODE.BASE64_DECODE( UTL_RAW.CAST_TO_RAW(to_char(code)) ); 
      f := utl_file.fopen('DIR_TEMP', filename, 'w');
      utl_file.put_line(f,to_clob(utl_raw.cast_to_varchar2(v_lob)));  
      utl_file.fclose(f); 
    end;
    Thank you
    DBMS_XSLPROCESSOR.clob2file(
      cl => l_clob
    , flocation => 'XML_LOG'
    , fname => myfile_name
    );
    

    for example

    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2    type t_emps is table of emp%ROWTYPE;
      3    v_emps    t_emps;
      4    --
      5    v_clob    clob;
      6    v_newline varchar2(2) := chr(13)||chr(10);
      7  begin
      8    -- get the rows into a PL/SQL collection of records
      9    select *
     10    bulk collect into v_emps
     11    from emp;
     12    -- build up the CLOB
     13    v_clob := 'EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO';
     14    for i in 1..v_emps.count
     15    loop
     16      v_clob := v_clob||v_newline||
     17                to_char(v_emps(i).empno,'fm9999')||','||
     18                v_emps(i).ename||','||
     19                v_emps(i).job||','||
     20                to_char(v_emps(i).mgr,'fm9999')||','||
     21                to_char(v_emps(i).hiredate,'YYYYMMDD')||','||
     22                to_char(v_emps(i).sal,'fm99999')||','||
     23                to_char(v_emps(i).comm,'fm99999')||','||
     24                to_char(v_emps(i).deptno,'fm99');
     25    end loop;
     26    -- write the CLOB to a file
     27    DBMS_XSLPROCESSOR.clob2file(cl => v_clob, flocation => 'TEST_DIR', fname => 'myfile.csv');
     28* end;
    SQL> / 
    
    PL/SQL procedure successfully completed.
    
  • the selection of all colomns_names of a table, with their data types...

    HI :)

    I would like to know, how to select in SQL for all the names of columns in a table with their data types so that I get something like this:

    Table 1: table_name

    the ID of the column has the NUMBER data type
    the name of the column has Datatype Varchar2
    *....*

    --------------------------------------------------------------

    Table 2: table_name

    the check in the column has the NUMBER data type
    the air of the column has Datatype Varchar2
    *....*


    and it must be for all the tables that I own!...

    P. S: I'm trying to do this with java, so it s would be enough if you just tell me how to select all tables_names with all their colums_names and all their data types!...

    Thanks :)



    I've heard this can be done with USER_TABLES... but I have no idea how: (...)

    Edited by: user8865125 the 17.05.2011 12:22

    Hello

    USER_TAB_COLUMNS data dictionary view has a row for each column of each table in your schema. The columns TABLE_NAME, COLUMN_NAME and DATA_TYPE contains all the information you need.
    Another view of data, USER_TABLES dictionary, can be useful, too. He has a line of table pre.

  • Problem with the DATA types, in a UNION

    Hello
    I m trying to disply a custom message when no data found using the structure below. Unfortunately I ve you have a problem with the data types I im trying to union
    I tried different types of data in the 2nd SELECTION tool but the rest of the problem. Help, please.

    SELECT HOSP_NAME 'HOSPITAL' DOC_SUR 'NAME', 'NAME' DOC_NAME, d.DOC_ID ID, diagnosis
    H., DOCTOR d, (SELECT d.DOC_ID, COUNT (d.DIAGN_ID) diagnosis
    OF PATIENT_DIAGNOSIS d
    GROUP BY d.DOC_ID)
    WHERE diagnosis > 1

    UNION ALL

    SELECT TO_CHAR ('test'), TO_CHAR ('test'), TO_CHAR ('test'), TO_CHAR ('test'), 0
    OF THE DOUBLE
    If NOT EXISTS (HOSP_NAME 'HOSPITAL' 'NAME' 'NAME' DOC_NAME DOC_SUR, d.DOC_ID ID, diagnosis
    OF ΝΟΣΟΚΟΜΕΙΟ h, ΙΑΤΡΟΣ d, (SELECT d.DOC_ID, COUNT (d.DIAGN_ID) diagnosis
    OF PATIENT_DIAGNOSIS d
    GROUP BY d.DOC_ID)
    WHERE diagnosis > 1);


    ORA-01790: expression must have same type of data, matching expression
    01790 00000 - "expression must have the same type of data, matching expression.

    DOC_SUR 'NAME' DOC_NAME 'NAME', ID d.DOC_ID, HOSP_NAME "HOSPITAL", diagnosis

    What is the data type for these columns

    To_char('test'), to_char ('test'), to_char ('test'), to_char ('test'), 0

    What you're doing here 'test' is already a character. Why do you use TO_CHAR?

Maybe you are looking for