/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.almibe.multipage;

import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.Node;
import javafx.scene.image.ImageView;

public class Page {
    private final ObjectProperty<Node> content = new SimpleObjectProperty<>();
    private final StringProperty text = new SimpleStringProperty();
    private final EventHandler<Event> onCloseRequest;
    private final Node icon;

    public Page(String title, Node image, Node node) {
        text.setValue(title);
        content.setValue(node);
        icon = image;
        onCloseRequest = null;
    }

    public Page(String title, ImageView image, Node node, EventHandler<Event> onCloseRequest) {
        text.setValue(title);
        content.setValue(node);
        icon = image;
        this.onCloseRequest = onCloseRequest;
    }

    public Node getIcon() {
        return icon;
    }

    public Node getContent() {
        return content.get();
    }

    public ObjectProperty<Node> contentProperty() {
        return content;
    }

    public void setContent(Node node) {
        content.setValue(node);
    }

    public String getText() {
        return text.get();
    }

    public StringProperty textProperty() {
        return text;
    }

    public void setText(String newValue) {
        text.set(newValue);
    }

    public EventHandler<Event> getOnCloseRequest() {
        return onCloseRequest;
    }
}

@@ -512,45 +512,8 @@
 ode;
-%0Aimport javafx.scene.image.ImageView;
 %0A%0Apu
@@ -797,20 +797,19 @@
 , Node i
-mage
+con
 , Node n
@@ -815,32 +815,37 @@
 node) %7B%0A        
+this.
 text.setValue(ti
@@ -850,32 +850,37 @@
 title);%0A        
+this.
 content.setValue
@@ -891,32 +891,37 @@
 e);%0A        
+this.
 icon = i
 mage;%0A      
@@ -900,36 +900,35 @@
    this.icon = i
-mage
+con
 ;%0A        onClos
@@ -921,16 +921,21 @@
         
+this.
 onCloseR
@@ -990,23 +990,17 @@
 le, 
-ImageView image
+Node icon
 , No
@@ -1046,32 +1046,37 @@
 uest) %7B%0A        
+this.
 text.setValue(ti
@@ -1081,32 +1081,37 @@
 title);%0A        
+this.
 content.setValue
@@ -1126,24 +1126,29 @@
         
+this.
 icon = i
 mage;%0A  
@@ -1143,12 +1143,11 @@
  = i
-mage
+con
 ;%0A  

replace ImageView with Node for icons