Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading project from XML issue #24

Open
LaurentiuVasile opened this issue Feb 9, 2015 · 1 comment
Open

Loading project from XML issue #24

LaurentiuVasile opened this issue Feb 9, 2015 · 1 comment

Comments

@LaurentiuVasile
Copy link

Hello Michael,

Lawrence here... So... In order to make the issue better understood i've took your first tutorial and just added a "SAVE" button to call saveToXML(Path p, VFlowModel flow) method, then adeded a button "load" to call loadFromXML(Path p).

Steps to reproduce:

  1. Run the App class.
  2. Save the flow by clicking save button.
  3. Load the flow by clicking load button. (optional here close the nodes before).

Expected Result:
The flow is created.

Actual Result:
NullPointerException occurs.

Here is the code:

import java.io.IOException;
import java.nio.file.Paths;

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.stage.Stage;
import eu.mihosoft.vrl.workflow.FlowFactory;
import eu.mihosoft.vrl.workflow.VFlow;
import eu.mihosoft.vrl.workflow.VNode;
import eu.mihosoft.vrl.workflow.fx.FXSkinFactory;
import eu.mihosoft.vrl.workflow.io.WorkflowIO;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
import jfxtras.labs.scene.layout.ScalableContentPane;

/**
*

  • @author Michael Hoffer info@michaelhoffer.de
    */
    public class App extends Application {

    /**

    • The main() method is ignored in correctly deployed JavaFX application.
    • main() serves only as fallback in case the application can not be
    • launched through deployment artifacts, e.g., in IDEs with limited FX
    • support. NetBeans ignores main().
      *
    • @param args the command line arguments
      */
      public static void main(String[] args) {
      launch(args);
      }

    @OverRide
    public void start(Stage primaryStage) {

    // create scalable root pane
    ScalableContentPane canvas = new ScalableContentPane();
    
    // define background style
    canvas.setStyle("-fx-background-color: linear-gradient(to bottom, rgb(10,32,60), rgb(42,52,120));");
    
    // create a new flow object
    
    VFlow flow = FlowFactory.newFlow();
    
    // make it visible
    flow.setVisible(true);
    
    // add two nodes to the flow
    VNode n1 = flow.newNode();
    VNode n2 = flow.newNode();
    
    // specify input & output capabilities...
    
    // ... for node 1
    n1.addInput("data");
    n1.addOutput("data");
    
    // ... for node 2
    n2.addInput("data");
    n2.addOutput("data");
    
    // create skin factory for flow visualization
    FXSkinFactory fXSkinFactory = new FXSkinFactory(canvas.getContentPane());
    
    // generate the ui for the flow
    flow.setSkinFactories(fXSkinFactory);
    
    // added a button in order to save the flow 
    Button save = new Button();
    save.setText("save");
    save.setLayoutX(100);
    save.setLayoutY(100);
    
    // setting mouse action to save the flow
    save.setOnMouseClicked(new EventHandler<MouseEvent>() {
    
        @Override
        public void handle(MouseEvent event) {
            try {
                WorkflowIO.saveToXML(Paths.get("D://flow-01.xml"), flow.getModel());
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });
    
    // added load button in order to load the flow
    Button load = new Button();
    load.setText("load");
    load.setLayoutX(100);
    load.setLayoutY(200);
    
    // setting mouse action to load the flow
    load.setOnMouseClicked(new EventHandler<MouseEvent>() {
    
        @Override
        public void handle(MouseEvent event) {
            try {
                VFlow flow = WorkflowIO.loadFromXML(Paths.get("D://flow-01.xml"));
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });
    
    //adding the buttons
    canvas.getChildren().addAll(save, load);
    
    // the usual application setup
    Scene scene = new Scene(canvas, 800, 800);
    primaryStage.setTitle("VWorkflows Tutorial 01");
    primaryStage.setScene(scene);
    primaryStage.show();
    

    }
    }

I've also tried to load the flow direct from the xml from the beginning(loading the flow direct from the xml ), the same issue occurs

So i'm getting a NullPointerException

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at eu.mihosoft.vrl.workflow.io.WorkflowIO.toValueObject(WorkflowIO.java:389)
at eu.mihosoft.vrl.workflow.io.WorkflowIO.createFlowFromPersistent(WorkflowIO.java:273)
at eu.mihosoft.vrl.workflow.io.WorkflowIO.flowFromPersistentFlow(WorkflowIO.java:250)
at eu.mihosoft.vrl.workflow.io.WorkflowIO.loadFromXML(WorkflowIO.java:115)
at eu.mihosoft.vrl.workflow.io.WorkflowIO.loadFromXML(WorkflowIO.java:72)
at aa.bc.App$2.handle(App.java:105)
at aa.bc.App$2.handle(App.java:1)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Scene$ClickGenerator.postProcess(Unknown Source)
at javafx.scene.Scene$ClickGenerator.access$8300(Unknown Source)
at javafx.scene.Scene$MouseHandler.process(Unknown Source)
at javafx.scene.Scene$MouseHandler.access$1800(Unknown Source)
at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.notifyMouse(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$300(Unknown Source)
at com.sun.glass.ui.win.WinApplication$4$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

(WorkflowIO.java:389) goes here (witch has the TODO that i was talking about)

public static ValueObject toValueObject(VNode node, PersistentValueObject vObj) {
ValueObject result = new DefaultValueObject();

    result.setParent(node);
    // line 389
    result.setValue(vObj.getValue());
    // resulult. // .. TODO visualizationRequest isnot persistent! 11.01.2014

    return result;
}

If there is more information about this issue please do tell and thank you once again for the assistance.

Regards,
Lawrence.

@LaurentiuVasile
Copy link
Author

Hello Michael,

     Any updates on this issue ?

Regards,
Lawrence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant