// Path: widget-core/src/main/java/org/ewidgetfx/core/Widget.java
// public interface Widget {
// 
//     public static enum DECORATION {
// 
//         STAGED_OS_TITLE_BAR,
//         STAGED_CLOSE,
//         STAGED_CONFIG_CLOSE,
//         STAGED_CONFIG,
//         STAGED_UNDECORATED,
//         NON_STAGED_CLOSE,
//         NON_STAGED_CONFIG_CLOSE,
//         NON_STAGED_CONFIG,
//         NON_STAGED_UNDECORATED
//     };
// 
//     DECORATION getDecoration();
// 
//     void setDecoration(DECORATION decoration);
// 
//     String getName();
// 
//     void setName(String name);
// 
//     StringProperty nameProperty();
// 
//     String getVersion();
// 
//     void setVersion(String version);
// 
//     StringProperty versionProperty();
// 
//     String getDescription();
// 
//     void setDescription(String descr);
// 
//     String getVendor();
// 
//     void setVendor(String vendor);
// 
//     String getVendorUrl();
// 
//     void setVendorUrl(String vendorUrl);
// 
//     String getVendorEmail();
// 
//     void setVendorEmail(String vendorEmail);
// 
//     LaunchInfo getLaunchInfo();
// 
//     void setLaunchInfo(LaunchInfo launchInfo);
// 
//     WidgetIcon getWidgetIcon();
// 
//     void setWidgetIcon(WidgetIcon widgetIcon);
// 
//     ObjectProperty<WidgetIcon> widgetIconProperty();
// 
//     Pane getAsNode();
// 
//     Stage getParentStage();
// 
//     void setParentStage(Stage stage);
// 
//     WidgetState getWidgetState();
// 
//     /**
//      * Returns a created WidgetIcon for the app container to use. Called 1st.
//      *
//      * @return WidgetIcon containing a raw node representing the icon. App containers can resize.
//      */
//     WidgetIcon buildWidgetIcon();
// 
//     /**
//      * Called after buildWidgetIcon() method to allow background processes to occur. Called 2nd. Typically to collect
//      * data to update WidgetIcon's Icon overlay. An example would be an email widget periodically checking email to
//      * update Icon overlay the number of emails received.
//      */
//     void startBackground();
// 
//     /**
//      * Initialize the widget. If the developer calls this method the framework will not call it. Called 3rd.
//      */
//     void init();
// 
//     /**
//      * Start is meant to be called when the user clicks to the icon to launch window. Called 4th. Typically to start
//      * animations. This should not be confused with backgroundStart()
//      */
//     void start();
// 
//     /**
//      * Pause is typically used to pause animations. Or other developer defined resources.
//      */
//     void pause();
// 
//     /**
//      * Resume is typically used to resume a animations. Or other developer defined resources.
//      */
//     void resume();
// 
//     /**
//      * Stop is called when the widget is closed and not visible. Typically this is to stop animations, and minor
//      * cleanup. The framework will call stop and stopBackground() method when exiting the app container.
//      */
//     void stop();
// 
//     /**
//      * Stops any background processes. Called when widget is being closed by the framework when exiting app contain.
//      * Called last.
//      *
//      */
//     void stopBackground();
// 
// }


import javafx.collections.FXCollections;
import javafx.collections.MapChangeListener;
import javafx.collections.ObservableMap;
import javafx.event.EventHandler;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;
import org.ewidgetfx.core.Widget;
import org.ewidgetfx.core.WidgetStage;
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import org.apache.log4j.Logger;

    public static void update(String name, Widget widget) {
        widgetMap.put(name, widget);
    }

    public static void remove(String name) {
        widgetMap.remove(name);
    }

    public static void addListener(MapChangeListener<String, Widget> mapChangeListener) {
        widgetMap.addListener(mapChangeListener);
    }

    public static Collection<Widget> retrieveAll() {
        return widgetMap.values();
    }

    public static EventHandler<? super MouseEvent> createLaunchWidgetEventHandler(Stage primaryStage, Widget w) {
        return me -> {
            Widget.DECORATION decor = w.getDecoration();
            if (decor == null) {
                decor = Widget.DECORATION.STAGED_UNDECORATED;
                w.setDecoration(decor);
            }

            switch (decor) {
                case STAGED_UNDECORATED:
                case STAGED_CLOSE:
                case STAGED_CONFIG:
                case STAGED_CONFIG_CLOSE:
// Path: widget-core/src/main/java/org/ewidgetfx/core/Widget.java
// public interface Widget {
// 
//     public static enum DECORATION {
// 
//         STAGED_OS_TITLE_BAR,
//         STAGED_CLOSE,
//         STAGED_CONFIG_CLOSE,
//         STAGED_CONFIG,
//         STAGED_UNDECORATED,
//         NON_STAGED_CLOSE,
//         NON_STAGED_CONFIG_CLOSE,
//         NON_STAGED_CONFIG,
//         NON_STAGED_UNDECORATED
//     };
// 
//     DECORATION getDecoration();
// 
//     void setDecoration(DECORATION decoration);
// 
//     String getName();
// 
//     void setName(String name);
// 
//     StringProperty nameProperty();
// 
//     String getVersion();
// 
//     void setVersion(String version);
// 
//     StringProperty versionProperty();
// 
//     String getDescription();
// 
//     void setDescription(String descr);
// 
//     String getVendor();
// 
//     void setVendor(String vendor);
// 
//     String getVendorUrl();
// 
//     void setVendorUrl(String vendorUrl);
// 
//     String getVendorEmail();
// 
//     void setVendorEmail(String vendorEmail);
// 
//     LaunchInfo getLaunchInfo();
// 
//     void setLaunchInfo(LaunchInfo launchInfo);
// 
//     WidgetIcon getWidgetIcon();
// 
//     void setWidgetIcon(WidgetIcon widgetIcon);
// 
//     ObjectProperty<WidgetIcon> widgetIconProperty();
// 
//     Pane getAsNode();
// 
//     Stage getParentStage();
// 
//     void setParentStage(Stage stage);
// 
//     WidgetState getWidgetState();
// 
//     /**
//      * Returns a created WidgetIcon for the app container to use. Called 1st.
//      *
//      * @return WidgetIcon containing a raw node representing the icon. App containers can resize.
//      */
//     WidgetIcon buildWidgetIcon();
// 
//     /**
//      * Called after buildWidgetIcon() method to allow background processes to occur. Called 2nd. Typically to collect
//      * data to update WidgetIcon's Icon overlay. An example would be an email widget periodically checking email to
//      * update Icon overlay the number of emails received.
//      */
//     void startBackground();
// 
//     /**
//      * Initialize the widget. If the developer calls this method the framework will not call it. Called 3rd.
//      */
//     void init();
// 
//     /**
//      * Start is meant to be called when the user clicks to the icon to launch window. Called 4th. Typically to start
//      * animations. This should not be confused with backgroundStart()
//      */
//     void start();
// 
//     /**
//      * Pause is typically used to pause animations. Or other developer defined resources.
//      */
//     void pause();
// 
//     /**
//      * Resume is typically used to resume a animations. Or other developer defined resources.
//      */
//     void resume();
// 
//     /**
//      * Stop is called when the widget is closed and not visible. Typically this is to stop animations, and minor
//      * cleanup. The framework will call stop and stopBackground() method when exiting the app container.
//      */
//     void stop();
// 
//     /**
//      * Stops any background processes. Called when widget is being closed by the framework when exiting app contain.
//      * Called last.
//      *
//      */
//     void stopBackground();
// 
// }


// Path: widget-core/src/main/java/org/ewidgetfx/util/WidgetFactory.java
import javafx.collections.FXCollections;
import javafx.collections.MapChangeListener;
import javafx.collections.ObservableMap;
import javafx.event.EventHandler;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;
import org.ewidgetfx.core.Widget;
import org.ewidgetfx.core.WidgetStage;
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import org.apache.log4j.Logger;


    public static void update(String name, Widget widget) {
        widgetMap.put(name, widget);
    }

    public static void remove(String name) {
        widgetMap.remove(name);
    }

    public static void addListener(MapChangeListener<String, Widget> mapChangeListener) {
        widgetMap.addListener(mapChangeListener);
    }

    public static Collection<Widget> retrieveAll() {
        return widgetMap.values();
    }

    public static EventHandler<? super MouseEvent> createLaunchWidgetEventHandler(Stage primaryStage, Widget w) {
        return me -> {
            Widget.DECORATION decor = w.getDecoration();
            if (decor == null) {
                decor = Widget.DECORATION.STAGED_UNDECORATED;
                w.setDecoration(decor);
            }

            switch (decor) {
                case STAGED_UNDECORATED:
                case STAGED_CLOSE:
                case STAGED_CONFIG:
                case STAGED_CONFIG_CLOSE:
                case STAGED_OS_TITLE_BAR: