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
736 stars 219 forks source link

Cannot open multiple instances of Scene Builder (e.g. to compare SB11 vs. SB15 or SB16) #346

Open Oliver-Loeffler opened 3 years ago

Oliver-Loeffler commented 3 years ago

Starting multiple instances of SceneBuilder does not work.

Expected Behavior

Current Behavior

Steps to Reproduce

Running tests entirely from IDE helped me as follows:

Apr. 01, 2021 6:18:37 NACHM. com.oracle.javafx.scenebuilder.app.SceneBuilderApp$SceneBuilderUncaughtExceptionHandler uncaughtException
SEVERE: An exception was thrown:
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
    at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
    at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
    at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
    at java.base/java.util.Objects.checkIndex(Objects.java:372)
    at java.base/java.util.ArrayList.get(ArrayList.java:458)
    at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.handleOpenFilesAction(SceneBuilderApp.java:506)
    at com.oracle.javafx.scenebuilder.app.AppPlatform$MessageBoxDelegate.lambda$0(AppPlatform.java:186)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:447)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:446)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:834)

Environment

Screenshots

SceneBuilder2ndInstanceStackTraceAtLaunch

moacirrf commented 3 years ago

I had a look at code and apparently is intentional. Maybe a confirmation dialog may appear when try to open a new instance, what you think?

moacirrf commented 3 years ago

With a change on this method is possible to run two instances of scene builder if are different versions. Appending the current version of scene builder, it will create a folder like that. /home/my_user/.scenebuilder/16.0.0-SNAPSHOT/MB/

`public class AppPlatform {

private static String applicationDataFolder;
private static String userLibraryFolder;
private static String messageBoxFolder;
private static MessageBox<MessageBoxMessage> messageBox;

public static synchronized String getApplicationDataFolder() {

    if (applicationDataFolder == null) {
        final String version = getSceneBuilderVersion();
        final String appName = "Scene Builder"; //NOI18N

        if (IS_WINDOWS) {
            applicationDataFolder 
                    = System.getenv("APPDATA") + "\\" + appName+"\\"+version; //NOI18N
        } else if (IS_MAC) {
            applicationDataFolder 
                    = System.getProperty("user.home") //NOI18N
                    + "/Library/Application Support/" //NOI18N
                    + appName+"/"+version;
        } else if (IS_LINUX) {
            applicationDataFolder
                    = System.getProperty("user.home") + "/.scenebuilder/"+version; //NOI18N
        }
    }

    assert applicationDataFolder != null;
    return applicationDataFolder;
}

...`

This is an easy approach, at least for linux, what you think?

Oliver-Loeffler commented 3 years ago

Souns like a very good idea. Asking the user is alwas good. @abhinayagarwal , what do you think? Would this fit with the way Scene Builder is supposed to be used?

abhinayagarwal commented 3 years ago

In my experience, Scene Builder stores its data in various locations, including and not limited to the ApplicationDataFolder. There are a few instances where Scene Builder depends on Java preferences (https://github.com/gluonhq/scenebuilder/issues/369)

If we want to pursue this further, we need to make sure that all the data for the 2 instances is stored separately to avoid any unnecessary complications.

moacirrf commented 3 years ago

In my experience, Scene Builder stores its data in various locations, including and not limited to the ApplicationDataFolder. There are a few instances where Scene Builder depends on Java preferences (#369)

If we want to pursue this further, we need to make sure that all the data for the 2 instances is stored separately to avoid any unnecessary complications.

Yes you are right, i believe that is more easy deal with different folders for different versions than change the code that avoid open new instances.

Maybe this cannot be deal like a bug but a new feature to be discussed. thanks

Oliver-Loeffler commented 3 years ago

A similar topic raised with issue #369. Therefore I would opt-in with having separate settings and storages for individual installations of SceneBuilder. This also implies, that it should be first of all possible to have multiple versions installed. This is not possible yet but a requirement for #346 und #369.

Oliver-Loeffler commented 5 days ago

Related to #579.