gluonhq / scenebuilder

Scene Builder is a visual, drag 'n' drop, layout tool for designing JavaFX application user interfaces.
https://gluonhq.com/products/scene-builder/
Other
748 stars 220 forks source link

SB won't load a file that contains <userData> #253

Open bendem opened 5 years ago

bendem commented 5 years ago

I have the file

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

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>

<VBox prefWidth="940.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.a2l.extenso.kitdev.controllers.MethodFilesController">
    <userData>
        <fx:reference source="controller"/>
    </userData>
   <children>
      <HBox spacing="7.0">
         <children>
            <Button fx:id="importButton" mnemonicParsing="false" onAction="#onImport" text="Import methods" />
            <Button fx:id="exportButton" mnemonicParsing="false" onAction="#onExport" text="Export selection" />
            <Button fx:id="analysisButton" mnemonicParsing="false" onAction="#onAnalysis" text="Use method for analysis" />
            <Button fx:id="deleteButton" mnemonicParsing="false" onAction="#onDelete" text="Delete selected methods" />
         </children>
         <opaqueInsets>
            <Insets />
         </opaqueInsets>
         <padding>
            <Insets bottom="7.0" left="7.0" right="7.0" top="7.0" />
         </padding>
      </HBox>
      <TableView fx:id="tableView" minWidth="700.0" VBox.vgrow="ALWAYS">
        <columns>
          <TableColumn fx:id="kitId" editable="false" prefWidth="178.0" text="Kit ID" />
          <TableColumn fx:id="methodId" editable="false" prefWidth="164.0" text="Method ID" />
          <TableColumn fx:id="revision" editable="false" prefWidth="148.0" text="Revision" />
        </columns>
      </TableView>
   </children>
</VBox>

I have to remove the <userData> tag, before opening the file, otherwise I get

Aug 19, 2019 5:14:43 PM com.oracle.javafx.scenebuilder.app.SceneBuilderApp$SceneBuilderUncaughtExceptionHandler uncaughtException
SEVERE: An exception was thrown:
java.lang.NullPointerException
        at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:98)
        at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:93)
        at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:110)
        at com.oracle.javafx.scenebuilder.kit.editor.EditorController.updateFxomDocument(EditorController.java:2560)
        at com.oracle.javafx.scenebuilder.kit.editor.EditorController.setFxmlTextAndLocation(EditorController.java:763)

adding the tag back after the file is opened causes the same exception but that doesn't prevent the editor from working.

Oliver-Loeffler commented 3 years ago

This is even worse. There should be an error dialog which is not shown. The exception is thrown by FXMLLoader as it fails to handle the <fx:reference source="controller"/>. Before making any step further, I need to find out, why the error dialog does not appear.

Oliver-Loeffler commented 3 years ago

@abhinayagarwal What is the way SceneBuilder should work? If the controller class as defined in fx:controller property does not exist in class path or module path, this is supposed to fail. Should there be a way for users to extend the class path for FXML loading?

Otherwise, one approach would be to ignore the user data elements on existing FXMLs for FXML loading. This would be possible by extending the functionality of PR #405 accordingly.

With #405, we could remove most likely not-working content from FXML before passing the FXML into the FXMLLoader but without removing the nodes from the FXOM so the data is not lost for the user.

Hello @bendem! Would it be okay to just ignore this kind of user data in your case?

bendem commented 3 years ago

Yes, that's the point of userData in my opinion, provide something dynamic to a static view. There is no way scenebuilder could ever resolve that symbol.

abhinayagarwal commented 3 years ago

Ignoring the user data elements sounds like the correct approach. I can't think of a scenario where Scene Builder would need to use the data and process something.

jaymehta-g commented 1 year ago

Still broken, any workarounds/fixes?

huayra07 commented 1 year ago

Still broken, any workarounds/fixes?

no

MetalOxidePeroxide commented 1 year ago

...

Oliver-Loeffler commented 1 year ago

@jaymehta-g I will look into this as. There are other FXML/FXOM related issues around and I had to learn how this works internally. There won't be a fix for Scene Builder 20 but I'll give you a ping as soon as there is something to test. Thanks for the reminder.

@AlmasB Could you please assign this one to me?

Oliver-Loeffler commented 1 year ago

Related issues:

512 (Can't open fxml that contains fx:include)

281 (ClassDefNotFoundError when importing custom component)