Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8095945

[Tab, TableColumnBase] Missing @IDProperty annotation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 8u20
    • 8
    • javafx
    • None
    • jdk 1.8.0 release
      Java(TM) SE Runtime Environment (build 1.8.0-b132)
      linux amd64

      JavaFX Scene Builder 2.0 (Developer Preview)
      Version: 2.0-b14, Changeset: 733a17ce9d73
      Date: 2014-02-13 06:53

      The FXML loader assigns the fx:id element from the .fxml file only when the @IDProperty annotation is given on the class.
      This is not the case for TableColumnBase which defines
      {code}
       private StringProperty id;
      {code}
      But is not annotated with the @IDProperty annotation.

      In the Scenebuilder I can give the TableColumn's of a TableView an fx:id which I will not be able to read again from the loaded TableColumn.

      https://javafx-jira.kenai.com/browse/RT-17657 <-- base task that changed the behaviour to reading the id based on the annotation.


      {code}
      public class TableColumnIdTest {
        private ExecutorService executorService;

        public static class TestApp extends Application {
          @Override
          public void start(Stage primaryStage) throws Exception {

          }
        }

        @Before
        public void setUp() throws Exception {
          executorService = Executors.newSingleThreadExecutor();
          executorService.submit(() -> Application.launch(TestApp.class));
        }

        @After
        public void tearDown() throws Exception {
          Platform.exit();
          executorService.shutdownNow();
        }

        @Test
        public void testName() throws Exception {
          URL url = TableColumnIdTest.class.getResource("TableColumnIdTest.fxml");
          StackPane pane = FXMLLoader.load(url);
          TableView tableView = (TableView) pane.getChildren().get(0);
          TableColumn column = (TableColumn) tableView.getColumns().get(0);
          assertNotNull("Table column id should be set to \"" + readColumnIdFromUrl(url) + "\"", column.getId());
        }

        private String readColumnIdFromUrl(URL url) throws URISyntaxException {
          try (FileInputStream stream = new FileInputStream(new File(url.toURI()))) {
            LineNumberReader reader = new LineNumberReader(new InputStreamReader(stream));
            for (String line = reader.readLine(); line != null; line = reader.readLine()) {
              String lookup = "fx:id=\"";
              int index = line.indexOf(lookup);
              if (index > 0) {
                int start = index + lookup.length();
                return line.substring(start, start + 6);
              }
            }
          } catch (FileNotFoundException e) {
            e.printStackTrace();
          } catch (IOException e) {
            e.printStackTrace();
          }

          return null;
        }
      }
      {code}

      {code}
      <?xml version="1.0" encoding="UTF-8"?>

      <?import java.lang.*?>
      <?import javafx.scene.control.*?>
      <?import javafx.scene.layout.*?>

      <StackPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
      <children><TableView prefHeight="200.0" prefWidth="200.0">
        <columns>
          <TableColumn fx:id="myId42" prefWidth="599.0" text="C1" />
        </columns>
      </TableView>
      </children></StackPane>
      {code}

            jgiles Jonathan Giles
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: