# HG changeset patch # User kcr # Date 1542645178 28800 # Mon Nov 19 08:32:58 2018 -0800 # Node ID 77aad202e4c394da86606bc4467341c8e73eb4d6 # Parent 908599063479369e8ef913279892006e338fb3d9 8198961: Remove old version of SceneBuilder from OpenJFX Reviewed-by: diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -67,7 +67,6 @@ !default.mode1v3 !default.mode2v3 !default.perspectivev3 -apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/about/about.properties .git .gitattributes .gitignore diff --git a/.idea/AirportApp.iml b/.idea/AirportApp.iml deleted file mode 100644 --- a/.idea/AirportApp.iml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/.idea/HelloI18N.iml b/.idea/HelloI18N.iml deleted file mode 100644 --- a/.idea/HelloI18N.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/.idea/HelloSwingNode.iml b/.idea/HelloSwingNode.iml deleted file mode 100644 --- a/.idea/HelloSwingNode.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/.idea/IssueTrackingBiDi.iml b/.idea/IssueTrackingBiDi.iml deleted file mode 100644 --- a/.idea/IssueTrackingBiDi.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/.idea/IssueTrackingLite.iml b/.idea/IssueTrackingLite.iml deleted file mode 100644 --- a/.idea/IssueTrackingLite.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/.idea/Login.iml b/.idea/Login.iml deleted file mode 100644 --- a/.idea/Login.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/.idea/SceneBuilderApp.iml b/.idea/SceneBuilderApp.iml deleted file mode 100644 --- a/.idea/SceneBuilderApp.iml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/.idea/SceneBuilderKit.iml b/.idea/SceneBuilderKit.iml deleted file mode 100644 --- a/.idea/SceneBuilderKit.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/.idea/UnlockCustom.iml b/.idea/UnlockCustom.iml deleted file mode 100644 --- a/.idea/UnlockCustom.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/.idea/modules.xml b/.idea/modules.xml --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,24 +3,15 @@ - - - - - - - - - diff --git a/apps/build.xml b/apps/build.xml --- a/apps/build.xml +++ b/apps/build.xml @@ -6,39 +6,22 @@ Gradle namespace, so lets use long names... --> - + - + - - - - - - - - - - - - - - - - - - + diff --git a/apps/scenebuilder/.classpath b/apps/scenebuilder/.classpath deleted file mode 100644 --- a/apps/scenebuilder/.classpath +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/apps/scenebuilder/.project b/apps/scenebuilder/.project deleted file mode 100644 --- a/apps/scenebuilder/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - scenebuilder - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/apps/scenebuilder/SceneBuilderApp/.classpath b/apps/scenebuilder/SceneBuilderApp/.classpath deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/apps/scenebuilder/SceneBuilderApp/.project b/apps/scenebuilder/SceneBuilderApp/.project deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - SceneBuilderApp - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/apps/scenebuilder/SceneBuilderApp/build.xml b/apps/scenebuilder/SceneBuilderApp/build.xml deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/build.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - Builds, tests, and runs the project SceneBuilderApp. - - - - diff --git a/apps/scenebuilder/SceneBuilderApp/manifest.mf b/apps/scenebuilder/SceneBuilderApp/manifest.mf deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/apps/scenebuilder/SceneBuilderApp/nbproject/build-impl.xml b/apps/scenebuilder/SceneBuilderApp/nbproject/build-impl.xml deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/nbproject/build-impl.xml +++ /dev/null @@ -1,1447 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set platform.home - Must set platform.bootcp - Must set platform.java - Must set platform.javac - - The J2SE Platform is not correctly set up. - Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. - Either open the project in the IDE and setup the Platform with the same name or add it manually. - For example like this: - ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file) - or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - ${platform.java} -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/scenebuilder/SceneBuilderApp/nbproject/genfiles.properties b/apps/scenebuilder/SceneBuilderApp/nbproject/genfiles.properties deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=16ebd6b2 -build.xml.script.CRC32=5368385f -build.xml.stylesheet.CRC32=8064a381@1.68.1.46 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=16ebd6b2 -nbproject/build-impl.xml.script.CRC32=c1599104 -nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 diff --git a/apps/scenebuilder/SceneBuilderApp/nbproject/project.properties b/apps/scenebuilder/SceneBuilderApp/nbproject/project.properties deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/nbproject/project.properties +++ /dev/null @@ -1,82 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.desc=JavaFX Scene Builder application -application.homepage=http://www.oracle.com/technetwork/java/javafx/tools/index.html -application.title=SceneBuilderApp -application.vendor=Oracle -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# Files in build.classes.dir which should be excluded from distribution jar -dist.archive.excludes= -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/SceneBuilderApp.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= -excludes= -file.reference.SceneBuilderApp-src=src -includes=** -jar.compress=false -javac.classpath=\ - ${reference.SceneBuilderKit.jar} -# Space-separated list of extra javac options -compile.patch=@../../../build/compile.args -javac.compilerargs=${compile.patch} -javac.deprecation=false -javac.processorpath=\ - ${javac.classpath} -javac.source=1.9 -javac.target=1.9 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -main.class=com.oracle.javafx.scenebuilder.app.SceneBuilderApp -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=JDK_1.9 -project.SceneBuilderKit=../SceneBuilderKit -reference.SceneBuilderKit.jar=${project.SceneBuilderKit}/dist/SceneBuilderKit.jar -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project. -# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. -# To set system properties for unit tests define test-sys-prop.name=value: -run.patch=@../../../build/run.args -run.jvmargs=${run.patch} -ea -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=${file.reference.SceneBuilderApp-src} diff --git a/apps/scenebuilder/SceneBuilderApp/nbproject/project.xml b/apps/scenebuilder/SceneBuilderApp/nbproject/project.xml deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/nbproject/project.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - SceneBuilderApp - - - - - - - - - SceneBuilderKit - jar - - jar - clean - jar - - - - diff --git a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/AppPlatform.java b/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/AppPlatform.java deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/AppPlatform.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. - * All rights reserved. Use is subject to license terms. - * - * This file is available and licensed under the following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the distribution. - * - Neither the name of Oracle Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.oracle.javafx.scenebuilder.app; - -import com.oracle.javafx.scenebuilder.app.util.MessageBox; -import com.oracle.javafx.scenebuilder.kit.editor.EditorPlatform; -import static com.oracle.javafx.scenebuilder.kit.editor.EditorPlatform.IS_LINUX; -import static com.oracle.javafx.scenebuilder.kit.editor.EditorPlatform.IS_MAC; -import static com.oracle.javafx.scenebuilder.kit.editor.EditorPlatform.IS_WINDOWS; -import com.oracle.javafx.scenebuilder.kit.util.Deprecation; -import java.io.IOException; -import java.nio.file.FileAlreadyExistsException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import javafx.application.Application; -import javafx.application.Platform; - -/** - * - */ -public class AppPlatform { - - private static String applicationDataFolder; - private static String userLibraryFolder; - private static String messageBoxFolder; - private static MessageBox messageBox; - - public static synchronized String getApplicationDataFolder() { - - if (applicationDataFolder == null) { - final String appName = "Scene Builder"; //NOI18N - - if (IS_WINDOWS) { - applicationDataFolder - = System.getenv("APPDATA") + "\\" + appName; //NOI18N - } else if (IS_MAC) { - applicationDataFolder - = System.getProperty("user.home") //NOI18N - + "/Library/Application Support/" //NOI18N - + appName; - } else if (IS_LINUX) { - applicationDataFolder - = System.getProperty("user.home") + "/.scenebuilder"; //NOI18N - } - } - - assert applicationDataFolder != null; - - return applicationDataFolder; - } - - - public static synchronized String getUserLibraryFolder() { - - if (userLibraryFolder == null) { - userLibraryFolder = getApplicationDataFolder() + "/Library"; //NOI18N - } - - return userLibraryFolder; - } - - public static boolean requestStart( - AppNotificationHandler notificationHandler, Application.Parameters parameters) - throws IOException { - if (EditorPlatform.isAssertionEnabled()) { - // Development mode : we do not delegate to the existing instance - notificationHandler.handleLaunch(parameters.getUnnamed()); - return true; - } else { - return requestStartGeneric(notificationHandler, parameters); - } - } - - public interface AppNotificationHandler { - public void handleLaunch(List files); - public void handleOpenFilesAction(List files); - public void handleMessageBoxFailure(Exception x); - public void handleQuitAction(); - } - - - /* - * Private (requestStartGeneric) - */ - - private static synchronized boolean requestStartGeneric( - AppNotificationHandler notificationHandler, Application.Parameters parameters) - throws IOException { - assert notificationHandler != null; - assert parameters != null; - assert messageBox == null; - - try { - Files.createDirectories(Paths.get(getMessageBoxFolder())); - } catch(FileAlreadyExistsException x) { - // Fine - } - - final boolean result; - messageBox = new MessageBox<>(getMessageBoxFolder(), MessageBoxMessage.class, 1000 /* ms */); - if (messageBox.grab(new MessageBoxDelegate(notificationHandler))) { - notificationHandler.handleLaunch(parameters.getUnnamed()); - result = true; - } else { - result = false; - final MessageBoxMessage unamedParameters - = new MessageBoxMessage(parameters.getUnnamed()); - try { - messageBox.sendMessage(unamedParameters); - } catch(InterruptedException x) { - throw new IOException(x); - } - } - - return result; - } - - private static String getMessageBoxFolder() { - if (messageBoxFolder == null) { - messageBoxFolder = getApplicationDataFolder() + "/MB"; //NOI18N - } - - return messageBoxFolder; - } - - private static class MessageBoxMessage extends ArrayList { - static final long serialVersionUID = 10; - public MessageBoxMessage(List strings) { - super(strings); - }; - }; - - private static class MessageBoxDelegate implements MessageBox.Delegate { - - private final AppNotificationHandler eventHandler; - - public MessageBoxDelegate(AppNotificationHandler eventHandler) { - assert eventHandler != null; - this.eventHandler = eventHandler; - } - - /* - * MessageBox.Delegate - */ - - @Override - public void messageBoxDidGetMessage(MessageBoxMessage message) { - assert Platform.isFxApplicationThread() == false; - Platform.runLater(() -> eventHandler.handleOpenFilesAction(message)); - } - - @Override - public void messageBoxDidCatchException(Exception x) { - assert Platform.isFxApplicationThread() == false; - Platform.runLater(() -> eventHandler.handleMessageBoxFailure(x)); - } - - } -} diff --git a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/CssPanelDelegate.java b/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/CssPanelDelegate.java deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/CssPanelDelegate.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. - * All rights reserved. Use is subject to license terms. - * - * This file is available and licensed under the following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the distribution. - * - Neither the name of Oracle Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.oracle.javafx.scenebuilder.app; - -import com.oracle.javafx.scenebuilder.kit.editor.panel.css.CssPanelController; -import com.oracle.javafx.scenebuilder.kit.editor.panel.inspector.InspectorPanelController; -import com.oracle.javafx.scenebuilder.kit.editor.panel.inspector.InspectorPanelController.SectionId; -import com.oracle.javafx.scenebuilder.kit.metadata.property.ValuePropertyMetadata; -import javafx.application.Platform; - -/** - * Implements the interface with the css panel. - */ -public class CssPanelDelegate extends CssPanelController.Delegate { - - private final InspectorPanelController inspectorController; - private final DocumentWindowController documentWindowController; - - public CssPanelDelegate(InspectorPanelController inspectorController, DocumentWindowController documentWindowController) { - this.inspectorController = inspectorController; - this.documentWindowController = documentWindowController; - } - - @Override - public void revealInspectorEditor(ValuePropertyMetadata propMeta) { - if (inspectorController == null || documentWindowController == null - || propMeta == null) { - return; - } - - // Show the inspector if it is hidden - if (!documentWindowController.isRightPanelVisible()) { - documentWindowController.performControlAction(DocumentWindowController.DocumentControlAction.TOGGLE_RIGHT_PANEL); - } - // Expand the inspector section - String inspectorSection = propMeta.getInspectorPath().getSectionTag(); - if (inspectorSection.equalsIgnoreCase("properties")) { //NOI18N - inspectorController.setExpandedSection(SectionId.PROPERTIES); - } else if (inspectorSection.equalsIgnoreCase("layout")) {//NOI18N - inspectorController.setExpandedSection(SectionId.LAYOUT); - } else if (inspectorSection.equalsIgnoreCase("code")) {//NOI18N - inspectorController.setExpandedSection(SectionId.CODE); - } - - // Need to delay the focus to the editor, so that the section is actually expanded first. - Platform.runLater(() -> Platform.runLater(() -> inspectorController.setFocusToEditor(propMeta.getName()))); - } - -} diff --git a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/CssPanelMenuController.java b/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/CssPanelMenuController.java deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/CssPanelMenuController.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. - * All rights reserved. Use is subject to license terms. - * - * This file is available and licensed under the following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the distribution. - * - Neither the name of Oracle Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.oracle.javafx.scenebuilder.app; - -import com.oracle.javafx.scenebuilder.app.i18n.I18N; -import com.oracle.javafx.scenebuilder.kit.editor.panel.css.CssPanelController; -import javafx.scene.control.MenuItem; - - -/** - * - */ -class CssPanelMenuController { - private boolean showStyledOnly = false; - private boolean splitDefaults = false; - private final CssPanelController cssPanelController; - - public CssPanelMenuController(CssPanelController cssPanelController) { - this.cssPanelController = cssPanelController; - } - - public void viewRules() { - cssPanelController.changeView(CssPanelController.View.RULES); - } - - public void viewTable() { - cssPanelController.changeView(CssPanelController.View.TABLE); - } - - public void viewText() { - cssPanelController.changeView(CssPanelController.View.TEXT); - } - - public void copyStyleablePath() { - cssPanelController.copyStyleablePath(); - } - - public void splitDefaultsAction(MenuItem cssPanelSplitDefaultsMi) { - cssPanelController.splitDefaultsAction(); - splitDefaults = !splitDefaults; - if (splitDefaults) { - cssPanelSplitDefaultsMi.setText(I18N.getString("csspanel.defaults.join")); - } else { - cssPanelSplitDefaultsMi.setText(I18N.getString("csspanel.defaults.split")); - } - } - - public void showStyledOnly(MenuItem cssPanelShowStyledOnlyMi) { - cssPanelController.showStyledOnly(); - showStyledOnly = !showStyledOnly; - if (showStyledOnly) { - cssPanelShowStyledOnlyMi.setText(I18N.getString("csspanel.show.default.values")); - } else { - cssPanelShowStyledOnlyMi.setText(I18N.getString("csspanel.hide.default.values")); - } - } - -} diff --git a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/DocumentWatchingController.java b/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/DocumentWatchingController.java deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/DocumentWatchingController.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. - * All rights reserved. Use is subject to license terms. - * - * This file is available and licensed under the following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the distribution. - * - Neither the name of Oracle Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.oracle.javafx.scenebuilder.app; - -import com.oracle.javafx.scenebuilder.app.i18n.I18N; -import com.oracle.javafx.scenebuilder.kit.editor.EditorController; -import com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument; -import com.oracle.javafx.scenebuilder.kit.util.FileWatcher; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; - -import javafx.beans.value.ChangeListener; -import javafx.collections.ObservableList; - -/** - * - */ -public class DocumentWatchingController implements FileWatcher.Delegate { - - private final DocumentWindowController documentWindowController; - private final EditorController editorController; - private final ResourceController resourceController; - private final SceneStyleSheetMenuController sceneStyleSheetMenuController; - private final FileWatcher fileWatcher - = new FileWatcher(2000 /* ms */, this, DocumentWindowController.class.getSimpleName()); - - - public DocumentWatchingController(DocumentWindowController documentWindowController) { - this.documentWindowController = documentWindowController; - this.editorController = documentWindowController.getEditorController(); - this.resourceController = documentWindowController.getResourceController(); - this.sceneStyleSheetMenuController = documentWindowController.getSceneStyleSheetMenuController(); - - this.editorController.sceneStyleSheetProperty().addListener( - (ChangeListener>) (ov, t, - t1) -> update()); - } - - public void start() { - fileWatcher.start(); - } - - - public void stop() { - fileWatcher.stop(); - } - - - public void update() { - /* - * The file watcher associated to this document window controller watches: - * 1) the file holding the FXML document (if any) - * 2) the resource file set in the Preview menu (if any) - * 3) the style sheets files set in the Preview menu (if any) - */ - - final List targets = new ArrayList<>(); - - // 1) - final FXOMDocument fxomDocument = editorController.getFxomDocument(); - if ((fxomDocument != null) && (fxomDocument.getLocation() != null)) { - try { - final File fxmlFile = new File(fxomDocument.getLocation().toURI()); - targets.add(fxmlFile.toPath()); - } catch(URISyntaxException x) { - throw new IllegalStateException("Bug", x); //NOI18N - } - } - - // 2) - if (resourceController.getResourceFile() != null) { - targets.add(resourceController.getResourceFile().toPath()); - } - - // 3) - if (editorController.getSceneStyleSheets() != null) { - for (File sceneStyleSheet : editorController.getSceneStyleSheets()) { - targets.add(sceneStyleSheet.toPath()); - } - } - - fileWatcher.setTargets(targets); - } - - public void removeDocumentTarget() { - final FXOMDocument fxomDocument = editorController.getFxomDocument(); - assert fxomDocument != null; - assert fxomDocument.getLocation() != null; - - try { - final File fxmlFile = new File(fxomDocument.getLocation().toURI()); - assert fileWatcher.getTargets().contains(fxmlFile.toPath()); - fileWatcher.removeTarget(fxmlFile.toPath()); - } catch(URISyntaxException x) { - throw new IllegalStateException("Bug", x); //NOI18N - } - } - - /* - * FileWatcher.Delegate - */ - - @Override - public void fileWatcherDidWatchTargetCreation(Path target) { - // Ignored - } - - @Override - public void fileWatcherDidWatchTargetDeletion(Path target) { - if (isPathMatchingResourceLocation(target)) { - // Resource file has disappeared - resourceController.performRemoveResource(); - // Call above has invoked - // - FXOMDocument.refreshSceneGraph() - // - DocumentWatchingController.update() - editorController.getMessageLog().logInfoMessage("log.info.file.deleted", - I18N.getBundle(), target.getFileName()); - } else if (isPathMatchingSceneStyleSheet(target)) { - sceneStyleSheetMenuController.performRemoveSceneStyleSheet(target.toFile()); - // Call above has invoked - // - FXOMDocument.reapplyCSS() - // - DocumentWatchingController.update() - editorController.getMessageLog().logInfoMessage("log.info.file.deleted", - I18N.getBundle(), target.getFileName()); - } - /* - * Else it's the document file which has disappeared : - * We ignore this event : file will be recreated when user runs - * the save command. - */ - } - - @Override - public void fileWatcherDidWatchTargetModification(Path target) { - if (isPathMatchingResourceLocation(target)) { - // Resource file has been modified -> refresh the scene graph - resourceController.performReloadResource(); - // Call above has invoked FXOMDocument.refreshSceneGraph() - editorController.getMessageLog().logInfoMessage("log.info.reload", - I18N.getBundle(), target.getFileName()); - - } else if (isPathMatchingDocumentLocation(target)) { - if (documentWindowController.isDocumentDirty() == false) { - // Try to reload the fxml text on disk - try { - documentWindowController.reload(); - editorController.getMessageLog().logInfoMessage("log.info.reload", - I18N.getBundle(), target.getFileName()); - } catch(IOException x) { - // Here we silently ignore the failure : - // loadFromFile() has failed but left the document unchanged. - } - } - } else if (isPathMatchingSceneStyleSheet(target)) { - final FXOMDocument fxomDocument = editorController.getFxomDocument(); - if (fxomDocument != null) { - fxomDocument.reapplyCSS(target); - editorController.getMessageLog().logInfoMessage("log.info.reload", - I18N.getBundle(), target.getFileName()); - } - } - } - - - /* - * Private - */ - - private boolean isPathMatchingDocumentLocation(Path p) { - final boolean result; - - final FXOMDocument fxomDocument = editorController.getFxomDocument(); - if ((fxomDocument != null) && (fxomDocument.getLocation() != null)) { - try { - final File fxmlFile = new File(fxomDocument.getLocation().toURI()); - result = p.equals(fxmlFile.toPath()); - } catch(URISyntaxException x) { - throw new IllegalStateException("Bug", x); //NOI18N - } - } else { - result = false; - } - - return result; - } - - private boolean isPathMatchingResourceLocation(Path p) { - final boolean result; - - if (resourceController.getResourceFile() != null) { - result = p.equals(resourceController.getResourceFile().toPath()); - } else { - result = false; - } - - return result; - } - - - private boolean isPathMatchingSceneStyleSheet(Path p) { - final boolean result; - - if (editorController.getSceneStyleSheets() != null) { - result = editorController.getSceneStyleSheets().contains(p.toFile()); - } else { - result = false; - } - - return result; - } - -} diff --git a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/DocumentWindow.fxml b/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/DocumentWindow.fxml deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/DocumentWindow.fxml +++ /dev/null @@ -1,210 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/DocumentWindowController.java b/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/DocumentWindowController.java deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/DocumentWindowController.java +++ /dev/null @@ -1,2171 +0,0 @@ -/* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. - * All rights reserved. Use is subject to license terms. - * - * This file is available and licensed under the following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the distribution. - * - Neither the name of Oracle Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.oracle.javafx.scenebuilder.app; - -import com.oracle.javafx.scenebuilder.app.i18n.I18N; -import com.oracle.javafx.scenebuilder.app.info.InfoPanelController; -import com.oracle.javafx.scenebuilder.app.menubar.MenuBarController; -import com.oracle.javafx.scenebuilder.app.message.MessageBarController; -import com.oracle.javafx.scenebuilder.app.preferences.PreferencesController; -import com.oracle.javafx.scenebuilder.app.preferences.PreferencesRecordDocument; -import com.oracle.javafx.scenebuilder.app.preferences.PreferencesRecordGlobal; -import com.oracle.javafx.scenebuilder.app.preview.PreviewWindowController; -import com.oracle.javafx.scenebuilder.app.report.JarAnalysisReportController; -import com.oracle.javafx.scenebuilder.app.selectionbar.SelectionBarController; -import com.oracle.javafx.scenebuilder.app.skeleton.SkeletonWindowController; -import com.oracle.javafx.scenebuilder.kit.editor.EditorController; -import com.oracle.javafx.scenebuilder.kit.editor.EditorController.ControlAction; -import com.oracle.javafx.scenebuilder.kit.editor.EditorController.EditAction; -import com.oracle.javafx.scenebuilder.kit.editor.EditorPlatform; -import com.oracle.javafx.scenebuilder.kit.editor.job.Job; -import com.oracle.javafx.scenebuilder.kit.editor.panel.content.ContentPanelController; -import com.oracle.javafx.scenebuilder.kit.editor.panel.css.CssPanelController; -import com.oracle.javafx.scenebuilder.kit.editor.panel.hierarchy.AbstractHierarchyPanelController; -import com.oracle.javafx.scenebuilder.kit.editor.panel.hierarchy.AbstractHierarchyPanelController.DisplayOption; -import com.oracle.javafx.scenebuilder.kit.editor.panel.hierarchy.HierarchyPanelController; -import com.oracle.javafx.scenebuilder.kit.editor.panel.inspector.InspectorPanelController; -import com.oracle.javafx.scenebuilder.kit.editor.panel.inspector.InspectorPanelController.SectionId; -import com.oracle.javafx.scenebuilder.kit.editor.panel.library.LibraryPanelController; -import com.oracle.javafx.scenebuilder.kit.editor.panel.util.AbstractFxmlWindowController; -import com.oracle.javafx.scenebuilder.kit.editor.panel.util.dialog.AbstractModalDialog; -import com.oracle.javafx.scenebuilder.kit.editor.panel.util.dialog.AbstractModalDialog.ButtonID; -import com.oracle.javafx.scenebuilder.kit.editor.panel.util.dialog.AlertDialog; -import com.oracle.javafx.scenebuilder.kit.editor.panel.util.dialog.ErrorDialog; -import com.oracle.javafx.scenebuilder.kit.editor.search.SearchController; -import com.oracle.javafx.scenebuilder.kit.editor.selection.AbstractSelectionGroup; -import com.oracle.javafx.scenebuilder.kit.editor.selection.GridSelectionGroup; -import com.oracle.javafx.scenebuilder.kit.editor.selection.ObjectSelectionGroup; -import com.oracle.javafx.scenebuilder.kit.editor.selection.Selection; -import com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument; -import com.oracle.javafx.scenebuilder.kit.fxom.FXOMNodes; -import com.oracle.javafx.scenebuilder.kit.fxom.FXOMObject; -import com.oracle.javafx.scenebuilder.kit.library.Library; -import com.oracle.javafx.scenebuilder.kit.library.user.UserLibrary; - -import java.io.File; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.NoSuchFileException; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.attribute.FileTime; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javafx.beans.InvalidationListener; -import javafx.beans.value.ChangeListener; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; -import javafx.fxml.FXML; -import javafx.geometry.Insets; -import javafx.scene.Node; -import javafx.scene.control.Accordion; -import javafx.scene.control.ComboBox; -import javafx.scene.control.DialogPane; -import javafx.scene.control.Menu; -import javafx.scene.control.MenuButton; -import javafx.scene.control.MenuItem; -import javafx.scene.control.RadioMenuItem; -import javafx.scene.control.SplitPane; -import javafx.scene.control.TextInputControl; -import javafx.scene.input.Clipboard; -import javafx.scene.input.KeyCode; -import javafx.scene.input.KeyCombination; -import javafx.scene.input.KeyEvent; -import javafx.scene.layout.StackPane; -import javafx.scene.layout.VBox; -import javafx.stage.FileChooser; -import javafx.stage.FileChooser.ExtensionFilter; -import javafx.stage.WindowEvent; - -/** - * - */ -public class DocumentWindowController extends AbstractFxmlWindowController { - - - public enum DocumentControlAction { - COPY, - SELECT_ALL, - SELECT_NONE, - SAVE_FILE, - SAVE_AS_FILE, - REVERT_FILE, - CLOSE_FILE, - REVEAL_FILE, - GOTO_CONTENT, - GOTO_PROPERTIES, - GOTO_LAYOUT, - GOTO_CODE, - TOGGLE_LIBRARY_PANEL, - TOGGLE_DOCUMENT_PANEL, - TOGGLE_CSS_PANEL, - TOGGLE_LEFT_PANEL, - TOGGLE_RIGHT_PANEL, - TOGGLE_OUTLINES_VISIBILITY, - TOGGLE_GUIDES_VISIBILITY, - SHOW_PREVIEW_WINDOW, - SHOW_PREVIEW_DIALOG, - ADD_SCENE_STYLE_SHEET, - SET_RESOURCE, - REMOVE_RESOURCE, - REVEAL_RESOURCE, - HELP, - SHOW_SAMPLE_CONTROLLER - } - - public enum DocumentEditAction { - DELETE, - CUT, - PASTE, - IMPORT_FXML, - IMPORT_MEDIA, - INCLUDE_FXML - } - - public enum ActionStatus { - CANCELLED, - DONE - } - - private final EditorController editorController = new EditorController(); - private final MenuBarController menuBarController = new MenuBarController(this); - private final ContentPanelController contentPanelController = new ContentPanelController(editorController); - private final AbstractHierarchyPanelController hierarchyPanelController = new HierarchyPanelController(editorController); - private final InfoPanelController infoPanelController = new InfoPanelController(editorController); - private final InspectorPanelController inspectorPanelController = new InspectorPanelController(editorController); - private final CssPanelDelegate cssPanelDelegate = new CssPanelDelegate(inspectorPanelController, this); - private final CssPanelController cssPanelController = new CssPanelController(editorController, cssPanelDelegate); - private final LibraryPanelController libraryPanelController = new LibraryPanelController(editorController); - private final SelectionBarController selectionBarController = new SelectionBarController(editorController); - private final MessageBarController messageBarController = new MessageBarController(editorController); - private final SearchController librarySearchController = new SearchController(editorController); - private final SearchController inspectorSearchController = new SearchController(editorController); - private final SearchController cssPanelSearchController = new SearchController(editorController);; - private final SceneStyleSheetMenuController sceneStyleSheetMenuController = new SceneStyleSheetMenuController(this); - private final CssPanelMenuController cssPanelMenuController = new CssPanelMenuController(cssPanelController); - private final ResourceController resourceController = new ResourceController((this)); - private final DocumentWatchingController watchingController = new DocumentWatchingController(this); - - // The controller below are created lazily because they need an owner - // and computing them here would be too costly (impact on start-up time): - // - PreviewWindowController - // - SkeletonWindowController - // - JarAnalysisReportController - private PreviewWindowController previewWindowController = null; - private SkeletonWindowController skeletonWindowController = null; - private JarAnalysisReportController jarAnalysisReportController = null; - - @FXML private StackPane libraryPanelHost; - @FXML private StackPane librarySearchPanelHost; - @FXML private StackPane hierarchyPanelHost; - @FXML private StackPane infoPanelHost; - @FXML private StackPane contentPanelHost; - @FXML private StackPane inspectorPanelHost; - @FXML private StackPane inspectorSearchPanelHost; - @FXML private StackPane cssPanelHost; - @FXML private StackPane cssPanelSearchPanelHost; - @FXML private StackPane messageBarHost; - @FXML private Accordion documentAccordion; - @FXML private SplitPane mainSplitPane; - @FXML private SplitPane leftRightSplitPane; - @FXML private SplitPane libraryDocumentSplitPane; - - @FXML private MenuButton libraryMenuButton; - @FXML private MenuItem libraryImportSelection; - @FXML private RadioMenuItem libraryViewAsList; - @FXML private RadioMenuItem libraryViewAsSections; - @FXML private MenuItem libraryReveal; - @FXML private Menu customLibraryMenu; - - @FXML private MenuItem cssPanelShowStyledOnlyMi; - @FXML private MenuItem cssPanelSplitDefaultsMi; - - @FXML private RadioMenuItem showInfoMenuItem; - @FXML private RadioMenuItem showFxIdMenuItem; - @FXML private RadioMenuItem showNodeIdMenuItem; - - private SplitController bottomSplitController; - private SplitController leftSplitController; - private SplitController rightSplitController; - private SplitController librarySplitController; - private SplitController documentSplitController; - - private FileTime loadFileTime; - private Job saveJob; - - private static List imageExtensions; - private static List audioExtensions; - private static List videoExtensions; - private static List mediaExtensions; - - private final EventHandler mainKeyEventFilter = (KeyEvent event) -> { - //------------------------------------------------------------------ - // TEXT INPUT CONTROL - //------------------------------------------------------------------ - // Common editing actions handled natively and defined as application accelerators - // - // The platform support is not mature/stable enough to rely on. - // Indeed, the behavior may differ : - // - when using system menu bar vs not using it - // - when using accelerators vs using menu items - // - depending on the focused control (TextField vs ComboBox) - // - // On SB side, we decide for now to consume events that may be handled natively - // so ALL actions are defined in our ApplicationMenu class. - // - // This may be revisit when platform implementation will be more reliable. - // - final Node focusOwner = getScene().getFocusOwner(); - final KeyCombination accelerator = getAccelerator(event); - if (isTextInputControlEditing(focusOwner) == true - && accelerator != null) { - -// focusOwner.getInputMap() -// .lookupMapping(KeyBinding.toKeyBinding(event)) -// .ifPresent(mapping -> { -// // The event is handled natively -// if (mapping.getSpecificity(event) > 0) { -// // When using system menu bar, the event is handled natively -// // before the application receives it : we just consume the event -// // so the editing action is not performed a second time by the app. -// if (menuBarController.getMenuBar().isUseSystemMenuBar()) { -// event.consume(); -// } -// } -// }); - } - - //------------------------------------------------------------------ - // Hierarchy TreeView + select all - //------------------------------------------------------------------ - // Select all is handled natively by TreeView (= hierarchy panel control). - boolean modifierDown = (EditorPlatform.IS_MAC ? event.isMetaDown() : event.isControlDown()); - boolean isSelectAll = KeyCode.A.equals(event.getCode()) && modifierDown; - if (getHierarchyPanelController().getPanelControl().isFocused() && isSelectAll) { - // Consume the event so the control action is not performed natively. - event.consume(); - // When using system menu bar, the control action is performed by the app. - if (menuBarController.getMenuBar().isUseSystemMenuBar() == false) { - if (canPerformControlAction(DocumentControlAction.SELECT_ALL)) { - performControlAction(DocumentControlAction.SELECT_ALL); - } - } - } - - // MenuItems define a single accelerator. - // BACK_SPACE key must be handled same way as DELETE key. - boolean isBackspace = KeyCode.BACK_SPACE.equals(event.getCode()); - if (isTextInputControlEditing(focusOwner) == false && isBackspace) { - if (canPerformEditAction(DocumentEditAction.DELETE)) { - performEditAction(DocumentEditAction.DELETE); - } - event.consume(); - } - }; - - /* - * DocumentWindowController - */ - - public DocumentWindowController() { - super(DocumentWindowController.class.getResource("DocumentWindow.fxml"), //NOI18N - I18N.getBundle(), false); // sizeToScene = false because sizing is defined in preferences - editorController.setLibrary(SceneBuilderApp.getSingleton().getUserLibrary()); - } - - public EditorController getEditorController() { - return editorController; - } - - public MenuBarController getMenuBarController() { - return menuBarController; - } - - public ContentPanelController getContentPanelController() { - return contentPanelController; - } - - public InspectorPanelController getInspectorPanelController() { - return inspectorPanelController; - } - - public CssPanelController getCssPanelController() { - return cssPanelController; - } - - public AbstractHierarchyPanelController getHierarchyPanelController() { - return hierarchyPanelController; - } - - public InfoPanelController getInfoPanelController() { - return infoPanelController; - } - - public PreviewWindowController getPreviewWindowController() { - return previewWindowController; - } - - public SceneStyleSheetMenuController getSceneStyleSheetMenuController() { - return sceneStyleSheetMenuController; - } - - public ResourceController getResourceController() { - return resourceController; - } - - public DocumentWatchingController getWatchingController() { - return watchingController; - } - - public SplitController getBottomSplitController() { - return bottomSplitController; - } - - public SplitController getLeftSplitController() { - return leftSplitController; - } - - public SplitController getRightSplitController() { - return rightSplitController; - } - - public SplitController getLibrarySplitController() { - return librarySplitController; - } - - public SplitController getDocumentSplitController() { - return documentSplitController; - } - - public void loadFromFile(File fxmlFile) throws IOException { - final URL fxmlURL = fxmlFile.toURI().toURL(); - final String fxmlText = FXOMDocument.readContentFromURL(fxmlURL); - editorController.setFxmlTextAndLocation(fxmlText, fxmlURL); - updateLoadFileTime(); - updateStageTitle(); // No-op if fxml has not been loaded yet - updateFromDocumentPreferences(); - watchingController.update(); - } - - public void loadFromURL(URL fxmlURL) { - assert fxmlURL != null; - try { - final String fxmlText = FXOMDocument.readContentFromURL(fxmlURL); - editorController.setFxmlTextAndLocation(fxmlText, null); - updateLoadFileTime(); - updateStageTitle(); // No-op if fxml has not been loaded yet - updateFromDocumentPreferences(); - watchingController.update(); - } catch(IOException x) { - throw new IllegalStateException(x); - } - } - - public void loadWithDefaultContent() { - try { - editorController.setFxmlTextAndLocation("", null); //NOI18N - updateLoadFileTime(); - updateStageTitle(); // No-op if fxml has not been loaded yet - watchingController.update(); - } catch (IOException x) { - throw new IllegalStateException(x); - } - } - - public void reload() throws IOException { - final FXOMDocument fxomDocument = editorController.getFxomDocument(); - assert (fxomDocument != null) && (fxomDocument.getLocation() != null); - final URL fxmlURL = fxomDocument.getLocation(); - final String fxmlText = FXOMDocument.readContentFromURL(fxmlURL); - editorController.setFxmlTextAndLocation(fxmlText, fxmlURL); - updateLoadFileTime(); - // Here we do not invoke updateStageTitleAndPreferences() neither watchingController.update() - } - - public String getFxmlText() { - return editorController.getFxmlText(); - } - - public void refreshLibraryDisplayOption(LibraryPanelController.DISPLAY_MODE option) { - switch (option) { - case LIST: - libraryViewAsList.setSelected(true); - break; - case SECTIONS: - libraryViewAsSections.setSelected(true); - break; - default: - assert false; - break; - } - libraryPanelController.setDisplayMode(option); - } - - public void refreshHierarchyDisplayOption(DisplayOption option) { - switch(option) { - case INFO: - showInfoMenuItem.setSelected(true); - break; - case FXID: - showFxIdMenuItem.setSelected(true); - break; - case NODEID: - showNodeIdMenuItem.setSelected(true); - break; - default: - assert false; - break; - } - hierarchyPanelController.setDisplayOption(option); - } - - public void refreshCssTableColumnsOrderingReversed(boolean cssTableColumnsOrderingReversed) { - cssPanelController.setTableColumnsOrderingReversed(cssTableColumnsOrderingReversed); - } - - public static final String makeTitle(FXOMDocument fxomDocument) { - final String title; - - if (fxomDocument == null) { - title = I18N.getString("label.no.document"); - } else if (fxomDocument.getLocation() == null) { - title = I18N.getString("label.untitled"); - } else { - String name = ""; //NOI18N - try { - final File toto = new File(fxomDocument.getLocation().toURI()); - name = toto.getName(); - } catch (URISyntaxException ex) { - throw new RuntimeException("Bug", ex); //NOI18N - } - title = name; - } - - return title; - } - - public boolean canPerformControlAction(DocumentControlAction controlAction) { - final boolean result; - - switch(controlAction) { - case COPY: - result = canPerformCopy(); - break; - - case SELECT_ALL: - result = canPerformSelectAll(); - break; - - case SELECT_NONE: - result = canPerformSelectNone(); - break; - - case SHOW_SAMPLE_CONTROLLER: - result = editorController.getFxomDocument() != null; - break; - - case TOGGLE_LIBRARY_PANEL: - case TOGGLE_DOCUMENT_PANEL: - case TOGGLE_CSS_PANEL: - case TOGGLE_LEFT_PANEL: - case TOGGLE_RIGHT_PANEL: - case TOGGLE_OUTLINES_VISIBILITY: - case TOGGLE_GUIDES_VISIBILITY: - case SHOW_PREVIEW_WINDOW: - result = true; - break; - - case SHOW_PREVIEW_DIALOG: - final FXOMDocument fxomDocument = editorController.getFxomDocument(); - if (fxomDocument != null) { - Object sceneGraphRoot = fxomDocument.getSceneGraphRoot(); - return sceneGraphRoot instanceof DialogPane; - } - result = false; - break; - - case SAVE_FILE: - result = isDocumentDirty() - || editorController.getFxomDocument().getLocation() == null; // Save new empty document - break; - - case SAVE_AS_FILE: - case CLOSE_FILE: - result = true; - break; - - case REVERT_FILE: - result = isDocumentDirty() - && editorController.getFxomDocument().getLocation() != null; - break; - - case REVEAL_FILE: - result = (editorController.getFxomDocument() != null) - && (editorController.getFxomDocument().getLocation() != null); - break; - - case GOTO_CONTENT: - case GOTO_PROPERTIES: - case GOTO_LAYOUT: - case GOTO_CODE: - result = true; - break; - - case ADD_SCENE_STYLE_SHEET: - result = true; - break; - - case SET_RESOURCE: - result = true; - break; - - case REMOVE_RESOURCE: - case REVEAL_RESOURCE: - result = resourceController.getResourceFile() != null; - break; - - case HELP: - result = true; - break; - - default: - result = false; - assert false; - break; - } - - return result; - } - - public void performControlAction(DocumentControlAction controlAction) { - assert canPerformControlAction(controlAction); - - final PreferencesController pc = PreferencesController.getSingleton(); - final PreferencesRecordDocument recordDocument = pc.getRecordDocument(this); - - switch(controlAction) { - case COPY: - performCopy(); - break; - - case SELECT_ALL: - performSelectAll(); - break; - - case SELECT_NONE: - performSelectNone(); - break; - - case SHOW_PREVIEW_WINDOW: - if (previewWindowController == null) { - previewWindowController = new PreviewWindowController(editorController, getStage()); - previewWindowController.setToolStylesheet(getToolStylesheet()); - } - previewWindowController.openWindow(); - break; - - case SHOW_PREVIEW_DIALOG: - if (previewWindowController == null) { - previewWindowController = new PreviewWindowController(editorController, getStage()); - previewWindowController.setToolStylesheet(getToolStylesheet()); - } - previewWindowController.openDialog(); - break; - - case SAVE_FILE: - performSaveOrSaveAsAction(); - break; - - case SAVE_AS_FILE: - performSaveAsAction(); - break; - - case REVERT_FILE: - performRevertAction(); - break; - - case CLOSE_FILE: - performCloseAction(); - break; - - case REVEAL_FILE: - performRevealAction(); - break; - - case GOTO_CONTENT: - contentPanelController.getGlassLayer().requestFocus(); - break; - - case GOTO_PROPERTIES: - performGoToSection(SectionId.PROPERTIES); - break; - - case GOTO_LAYOUT: - performGoToSection(SectionId.LAYOUT); - break; - - case GOTO_CODE: - performGoToSection(SectionId.CODE); - break; - - case TOGGLE_LEFT_PANEL: - if (leftSplitController.isTargetVisible()) { - assert librarySplitController.isTargetVisible() - || documentSplitController.isTargetVisible(); - // Hide Left => hide both Library + Document - librarySplitController.hideTarget(); - documentSplitController.hideTarget(); - leftSplitController.hideTarget(); - } else { - assert librarySplitController.isTargetVisible() == false - && documentSplitController.isTargetVisible() == false; - // Show Left => show both Library + Document - librarySplitController.showTarget(); - documentSplitController.showTarget(); - leftSplitController.showTarget(); - - // This workarounds layout issues when showing Left - libraryDocumentSplitPane.layout(); - libraryDocumentSplitPane.setDividerPositions(0.5); - } - // Update preferences - recordDocument.setLibraryVisible(librarySplitController.isTargetVisible()); - recordDocument.setDocumentVisible(documentSplitController.isTargetVisible()); - recordDocument.setLeftVisible(leftSplitController.isTargetVisible()); - break; - - case TOGGLE_RIGHT_PANEL: - rightSplitController.toggleTarget(); - // Update preferences - recordDocument.setRightVisible(rightSplitController.isTargetVisible()); - break; - - case TOGGLE_CSS_PANEL: - // CSS panel is built lazely : initialize the CSS panel first - initializeCssPanel(); - bottomSplitController.toggleTarget(); - if (bottomSplitController.isTargetVisible()) { - // CSS panel is built lazely - // Need to update its table column ordering with preference value - final PreferencesRecordGlobal recordGlobal = pc.getRecordGlobal(); - refreshCssTableColumnsOrderingReversed(recordGlobal.isCssTableColumnsOrderingReversed()); - // Enable pick mode - editorController.setPickModeEnabled(true); - } else { - // Disable pick mode - editorController.setPickModeEnabled(false); - } - // Update preferences - recordDocument.setBottomVisible(bottomSplitController.isTargetVisible()); - break; - - case TOGGLE_LIBRARY_PANEL: - if (librarySplitController.isTargetVisible()) { - assert leftSplitController.isTargetVisible(); - librarySplitController.hideTarget(); - if (documentSplitController.isTargetVisible() == false) { - leftSplitController.hideTarget(); - } - } else { - if (leftSplitController.isTargetVisible() == false) { - leftSplitController.showTarget(); - } - librarySplitController.showTarget(); - } - // Update preferences - recordDocument.setLibraryVisible(librarySplitController.isTargetVisible()); - recordDocument.setLeftVisible(leftSplitController.isTargetVisible()); - break; - - case TOGGLE_DOCUMENT_PANEL: - if (documentSplitController.isTargetVisible()) { - assert leftSplitController.isTargetVisible(); - documentSplitController.hideTarget(); - if (librarySplitController.isTargetVisible() == false) { - leftSplitController.hideTarget(); - } - } else { - if (leftSplitController.isTargetVisible() == false) { - leftSplitController.showTarget(); - } - documentSplitController.showTarget(); - } - // Update preferences - recordDocument.setDocumentVisible(documentSplitController.isTargetVisible()); - recordDocument.setLeftVisible(leftSplitController.isTargetVisible()); - break; - - case TOGGLE_OUTLINES_VISIBILITY: - contentPanelController.setOutlinesVisible( - ! contentPanelController.isOutlinesVisible()); - break; - - case TOGGLE_GUIDES_VISIBILITY: - contentPanelController.setGuidesVisible( - ! contentPanelController.isGuidesVisible()); - break; - - case ADD_SCENE_STYLE_SHEET: - sceneStyleSheetMenuController.performAddSceneStyleSheet(); - break; - - case SET_RESOURCE: - resourceController.performSetResource(); - // Update preferences - recordDocument.setI18NResourceFile(getResourceFile()); - break; - - case REMOVE_RESOURCE: - resourceController.performRemoveResource(); - // Update preferences - recordDocument.setI18NResourceFile(getResourceFile()); - break; - - case REVEAL_RESOURCE: - resourceController.performRevealResource(); - break; - - case HELP: - performHelp(); - break; - - case SHOW_SAMPLE_CONTROLLER: - if (skeletonWindowController == null) { - skeletonWindowController = new SkeletonWindowController(editorController, getStage()); - skeletonWindowController.setToolStylesheet(getToolStylesheet()); - } - skeletonWindowController.openWindow(); - break; - - default: - assert false; - break; - } - } - - public boolean canPerformEditAction(DocumentEditAction editAction) { - final boolean result; - - switch(editAction) { - case DELETE: - result = canPerformDelete(); - break; - - case CUT: - result = canPerformCut(); - break; - - case IMPORT_FXML: - case IMPORT_MEDIA: - result = true; - break; - - case INCLUDE_FXML: - // Cannot include as root or if the document is not saved yet - final FXOMDocument fxomDocument = editorController.getFxomDocument(); - result = (fxomDocument != null) - && (fxomDocument.getFxomRoot() != null) - && (fxomDocument.getLocation() != null); - break; - - case PASTE: - result = canPerformPaste(); - break; - - default: - result = false; - assert false; - break; - } - - return result; - } - - public void performEditAction(DocumentEditAction editAction) { - assert canPerformEditAction(editAction); - - switch(editAction) { - case DELETE: - performDelete(); - break; - - case CUT: - performCut(); - break; - - case IMPORT_FXML: - performImportFxml(); - break; - - case IMPORT_MEDIA: - performImportMedia(); - break; - - case INCLUDE_FXML: - performIncludeFxml(); - break; - - case PASTE: - performPaste(); - break; - - default: - assert false; - break; - } - } - - public boolean isLeftPanelVisible() { - return leftSplitController.isTargetVisible(); - } - - - public boolean isRightPanelVisible() { - return rightSplitController.isTargetVisible(); - } - - - public boolean isBottomPanelVisible() { - return bottomSplitController.isTargetVisible(); - } - - - public boolean isHierarchyPanelVisible() { - return documentSplitController.isTargetVisible(); - } - - - public boolean isLibraryPanelVisible() { - return librarySplitController.isTargetVisible(); - } - - public File getResourceFile() { - return resourceController.getResourceFile(); - } - - public void setResourceFile(File file) { - resourceController.setResourceFile(file); - } - - public boolean isDocumentDirty() { - return getEditorController().getJobManager().getCurrentJob() != saveJob; - } - - public boolean isUnused() { - /* - * A document window controller is considered as "unused" if: //NOI18N - * 1) it has not fxml text - * 2) it is not dirty - * 3) it is unamed - */ - - final FXOMDocument fxomDocument = editorController.getFxomDocument(); - final boolean noFxmlText = (fxomDocument == null) || (fxomDocument.getFxomRoot() == null); - final boolean clean = isDocumentDirty() == false; - final boolean noName = (fxomDocument != null) && (fxomDocument.getLocation() == null); - - return noFxmlText && clean && noName; - } - - public static class TitleComparator implements Comparator { - - @Override - public int compare(DocumentWindowController d1, DocumentWindowController d2) { - final int result; - - assert d1 != null; - assert d2 != null; - - if (d1 == d2) { - result = 0; - } else { - final String t1 = d1.getStage().getTitle(); - final String t2 = d2.getStage().getTitle(); - assert t1 != null; - assert t2 != null; - result = t1.compareTo(t2); - } - - return result; - } - - } - - public void initializeCssPanel() { - assert cssPanelHost != null; - assert cssPanelSearchPanelHost != null; - if (cssPanelHost.getChildren().isEmpty()) { - cssPanelHost.getChildren().add(cssPanelController.getPanelRoot()); - } - if (cssPanelSearchPanelHost.getChildren().isEmpty()) { - cssPanelSearchPanelHost.getChildren().add(cssPanelSearchController.getPanelRoot()); - addCssPanelSearchListener(); - } - } - - public void updatePreferences() { - final PreferencesController pc = PreferencesController.getSingleton(); - final URL fxmlLocation = getEditorController().getFxmlLocation(); - if (fxmlLocation == null) { - // Document has not been saved => nothing to write - // This is the case with initial empty document - return; - } - // Update record document - final PreferencesRecordDocument recordDocument = pc.getRecordDocument(this); - recordDocument.writeToJavaPreferences(); - // Update record global - final PreferencesRecordGlobal recordGlobal = pc.getRecordGlobal(); - // recentItems may not contain the current document - // if the Open Recent -> Clear menu has been invoked - if (recordGlobal.containsRecentItem(fxmlLocation) == false) { - recordGlobal.addRecentItem(fxmlLocation); - } - } - - /* - * AbstractFxmlWindowController - */ - - @Override - protected void controllerDidLoadFxml() { - - assert libraryPanelHost != null; - assert librarySearchPanelHost != null; - assert hierarchyPanelHost != null; - assert infoPanelHost != null; - assert contentPanelHost != null; - assert inspectorPanelHost != null; - assert inspectorSearchPanelHost != null; - assert messageBarHost != null; - assert mainSplitPane != null; - assert mainSplitPane.getItems().size() == 2; - assert leftRightSplitPane != null; - assert leftRightSplitPane.getItems().size() == 3; - assert libraryDocumentSplitPane != null; - assert libraryDocumentSplitPane.getItems().size() == 2; - assert documentAccordion != null; - assert documentAccordion.getPanes().isEmpty() == false; - assert libraryViewAsList != null; - assert libraryViewAsSections != null; - assert libraryReveal != null; - assert libraryMenuButton != null; - assert libraryImportSelection != null; - assert customLibraryMenu != null; - - // Add a border to the Windows app, because of the specific window decoration on Windows. - if (EditorPlatform.IS_WINDOWS) { - getRoot().getStyleClass().add("windows-document-decoration");//NOI18N - } - - mainSplitPane.addEventFilter(KeyEvent.KEY_PRESSED, mainKeyEventFilter); - - // Insert the menu bar - assert getRoot() instanceof VBox; - final VBox rootVBox = (VBox) getRoot(); - rootVBox.getChildren().add(0, menuBarController.getMenuBar()); - - libraryPanelHost.getChildren().add(libraryPanelController.getPanelRoot()); - librarySearchPanelHost.getChildren().add(librarySearchController.getPanelRoot()); - hierarchyPanelHost.getChildren().add(hierarchyPanelController.getPanelRoot()); - infoPanelHost.getChildren().add(infoPanelController.getPanelRoot()); - contentPanelHost.getChildren().add(contentPanelController.getPanelRoot()); - inspectorPanelHost.getChildren().add(inspectorPanelController.getPanelRoot()); - inspectorSearchPanelHost.getChildren().add(inspectorSearchController.getPanelRoot()); - messageBarHost.getChildren().add(messageBarController.getPanelRoot()); - - messageBarController.getSelectionBarHost().getChildren().add( - selectionBarController.getPanelRoot()); - - inspectorSearchController.textProperty().addListener((ChangeListener) (ov, oldStr, newStr) -> inspectorPanelController.setSearchPattern(newStr)); - - librarySearchController.textProperty().addListener((ChangeListener) (ov, oldStr, newStr) -> libraryPanelController.setSearchPattern(newStr)); - - bottomSplitController = new SplitController(mainSplitPane, SplitController.Target.LAST); - leftSplitController = new SplitController(leftRightSplitPane, SplitController.Target.FIRST); - rightSplitController = new SplitController(leftRightSplitPane, SplitController.Target.LAST); - librarySplitController = new SplitController(libraryDocumentSplitPane, SplitController.Target.FIRST); - documentSplitController = new SplitController(libraryDocumentSplitPane, SplitController.Target.LAST); - - messageBarHost.heightProperty().addListener((InvalidationListener) o -> { - final double h = messageBarHost.getHeight(); - contentPanelHost.setPadding(new Insets(h, 0.0, 0.0, 0.0)); - }); - - documentAccordion.setExpandedPane(documentAccordion.getPanes().get(0)); - - // Monitor the status of the document to set status icon accordingly in message bar - getEditorController().getJobManager().revisionProperty().addListener((ChangeListener) (ov, t, t1) -> messageBarController.setDocumentDirty(isDocumentDirty())); - - // Setup title of the Library Reveal menu item according the underlying o/s. - final String revealMenuKey; - if (EditorPlatform.IS_MAC) { - revealMenuKey = "menu.title.reveal.mac"; - } else if (EditorPlatform.IS_WINDOWS) { - revealMenuKey = "menu.title.reveal.win"; - } else { - assert EditorPlatform.IS_LINUX; - revealMenuKey = "menu.title.reveal.linux"; - } - libraryReveal.setText(I18N.getString(revealMenuKey)); - - // We need to tune the content of the library menu according if there's - // or not a selection likely to be dropped onto Library panel. - libraryMenuButton.showingProperty().addListener((ChangeListener) (ov, t, t1) -> { - if (t1) { - AbstractSelectionGroup asg = getEditorController().getSelection().getGroup(); - libraryImportSelection.setDisable(true); - - if (asg instanceof ObjectSelectionGroup) { - if (((ObjectSelectionGroup)asg).getItems().size() >= 1) { - libraryImportSelection.setDisable(false); - } - } - - // DTL-6439. The custom library menu shall be enabled only - // in the case there is a user library directory on disk. - Library lib = getEditorController().getLibrary(); - if (lib instanceof UserLibrary) { - File userLibDir = new File(((UserLibrary)lib).getPath()); - if (userLibDir.canRead()) { - customLibraryMenu.setDisable(false); - } else { - customLibraryMenu.setDisable(true); - } - } - } - }); - } - - @Override - protected void controllerDidCreateStage() { - updateStageTitle(); - updateFromDocumentPreferences(); - } - - @Override - public void openWindow() { - - if (getStage().isShowing() == false) { - // Starts watching document: - // - editorController watches files referenced from the FXML text - // - watchingController watches the document file, i18n resources, - // preview stylesheets... - assert editorController.isFileWatchingStarted() == false; - editorController.startFileWatching(); - watchingController.start(); - } - - super.openWindow(); - - // Give focus to the library search TextField - assert librarySearchController != null; - librarySearchController.requestFocus(); - } - - @Override - public void closeWindow() { - - super.closeWindow(); - - // Stops watching - editorController.stopFileWatching(); - watchingController.stop(); - } - - @Override - public void onCloseRequest(WindowEvent event) { - performCloseAction(); - } - - public boolean isFrontDocumentWindow() { - return getStage().isFocused() - || (previewWindowController != null && previewWindowController.getStage().isFocused()) - || (skeletonWindowController != null && skeletonWindowController.getStage().isFocused()) - || (jarAnalysisReportController != null && jarAnalysisReportController.getStage().isFocused()); - } - - public void performCloseFrontDocumentWindow() { - if (getStage().isFocused()) { - performCloseAction(); - } else if (previewWindowController != null - && previewWindowController.getStage().isFocused()) { - previewWindowController.closeWindow(); - } else if (skeletonWindowController != null - && skeletonWindowController.getStage().isFocused()) { - skeletonWindowController.closeWindow(); - } else if (jarAnalysisReportController != null - && jarAnalysisReportController.getStage().isFocused()) { - jarAnalysisReportController.closeWindow(); - } - } - - - @Override - protected void toolStylesheetDidChange(String oldStylesheet) { - super.toolStylesheetDidChange(oldStylesheet); - editorController.setToolStylesheet(getToolStylesheet()); - // previewWindowController should not be affected by tool style sheet - if (skeletonWindowController != null) { - skeletonWindowController.setToolStylesheet(getToolStylesheet()); - } - if (jarAnalysisReportController != null) { - jarAnalysisReportController.setToolStylesheet(getToolStylesheet()); - } - } - - - // - // Inspector menu - // - @FXML - void onInspectorShowAllAction(ActionEvent event) { - inspectorPanelController.setShowMode(InspectorPanelController.ShowMode.ALL); - - } - - @FXML - void onInspectorShowEditedAction(ActionEvent event) { - inspectorPanelController.setShowMode(InspectorPanelController.ShowMode.EDITED); - } - - @FXML - void onInspectorViewSectionsAction(ActionEvent event) { - inspectorPanelController.setViewMode(InspectorPanelController.ViewMode.SECTION); - } - - @FXML - void onInspectorViewByPropertyNameAction(ActionEvent event) { - inspectorPanelController.setViewMode(InspectorPanelController.ViewMode.PROPERTY_NAME); - } - - @FXML - void onInspectorViewByPropertyTypeAction(ActionEvent event) { - inspectorPanelController.setViewMode(InspectorPanelController.ViewMode.PROPERTY_TYPE); - } - - // - // CSS menu - // - - @FXML - void onCssPanelViewRulesAction(ActionEvent event) { - cssPanelMenuController.viewRules(); - cssPanelSplitDefaultsMi.setDisable(true); - cssPanelShowStyledOnlyMi.setDisable(true); - } - - @FXML - void onCssPanelViewTableAction(ActionEvent event) { - cssPanelMenuController.viewTable(); - cssPanelSplitDefaultsMi.setDisable(false); - cssPanelShowStyledOnlyMi.setDisable(false); - } - - @FXML - void onCssPanelViewTextAction(ActionEvent event) { - cssPanelMenuController.viewText(); - cssPanelSplitDefaultsMi.setDisable(true); - cssPanelShowStyledOnlyMi.setDisable(true); - } - - @FXML - void onCssPanelCopyStyleablePathAction(ActionEvent event) { - cssPanelMenuController.copyStyleablePath(); - } - - @FXML - void onCssPanelSplitDefaultsAction(ActionEvent event) { - cssPanelMenuController.splitDefaultsAction(cssPanelSplitDefaultsMi); - } - - @FXML - void onCssPanelShowStyledOnlyAction(ActionEvent event) { - cssPanelMenuController.showStyledOnly(cssPanelShowStyledOnlyMi); - } - - // - // Hierarchy menu - // - @FXML - void onHierarchyShowInfo(ActionEvent event) { - hierarchyPanelController.setDisplayOption(AbstractHierarchyPanelController.DisplayOption.INFO); - documentAccordion.setExpandedPane(documentAccordion.getPanes().get(0)); - } - - @FXML - void onHierarchyShowFxId(ActionEvent event) { - hierarchyPanelController.setDisplayOption(AbstractHierarchyPanelController.DisplayOption.FXID); - documentAccordion.setExpandedPane(documentAccordion.getPanes().get(0)); - } - - @FXML - void onHierarchyShowNodeId(ActionEvent event) { - hierarchyPanelController.setDisplayOption(AbstractHierarchyPanelController.DisplayOption.NODEID); - documentAccordion.setExpandedPane(documentAccordion.getPanes().get(0)); - } - - // - // Library menu - // - @FXML - void onLibraryImportJarFxml(ActionEvent event) { - libraryPanelController.performImportJarFxml(); - } - - @FXML - void onLibraryViewAsList(ActionEvent event) { - if (libraryPanelController.getDisplayMode() != LibraryPanelController.DISPLAY_MODE.SEARCH) { - libraryPanelController.setDisplayMode(LibraryPanelController.DISPLAY_MODE.LIST); - } else { - libraryPanelController.setPreviousDisplayMode(LibraryPanelController.DISPLAY_MODE.LIST); - } - } - - @FXML - void onLibraryViewAsSections(ActionEvent event) { - if (libraryPanelController.getDisplayMode() != LibraryPanelController.DISPLAY_MODE.SEARCH) { - libraryPanelController.setDisplayMode(LibraryPanelController.DISPLAY_MODE.SECTIONS); - } else { - libraryPanelController.setPreviousDisplayMode(LibraryPanelController.DISPLAY_MODE.SECTIONS); - } - } - - // This method cannot be called if there is not a valid selection, a selection - // eligible for being dropped onto Library panel. - @FXML - void onLibraryImportSelection(ActionEvent event) { - AbstractSelectionGroup asg = getEditorController().getSelection().getGroup(); - - if (asg instanceof ObjectSelectionGroup) { - ObjectSelectionGroup osg = (ObjectSelectionGroup)asg; - assert osg.getItems().isEmpty() == false; - List selection = new ArrayList<>(osg.getItems()); - libraryPanelController.performImportSelection(selection); - } - } - - @FXML - void onLibraryRevealCustomFolder(ActionEvent event) { - String userLibraryPath = ((UserLibrary) getEditorController().getLibrary()).getPath(); - try { - EditorPlatform.revealInFileBrowser(new File(userLibraryPath)); - } catch(IOException x) { - final ErrorDialog errorDialog = new ErrorDialog(null); - errorDialog.setMessage(I18N.getString("alert.reveal.failure.message", getStage().getTitle())); - errorDialog.setDetails(I18N.getString("alert.reveal.failure.details")); - errorDialog.setDebugInfoWithThrowable(x); - errorDialog.showAndWait(); - } - } - - @FXML - void onLibraryShowJarAnalysisReport(ActionEvent event) { - if (jarAnalysisReportController == null) { - jarAnalysisReportController = new JarAnalysisReportController(getEditorController(), getStage()); - jarAnalysisReportController.setToolStylesheet(getToolStylesheet()); - } - - jarAnalysisReportController.openWindow(); - } - - /* - * Private - */ - - private boolean canPerformSelectAll() { - final boolean result; - final Node focusOwner = this.getScene().getFocusOwner(); - if (isPopupEditing(focusOwner)) { - return false; - } else if (isTextInputControlEditing(focusOwner)) { - final TextInputControl tic = getTextInputControl(focusOwner); - final String text = tic.getText(); - final String selectedText = tic.getSelectedText(); - if (text == null || text.isEmpty()) { - result = false; - } else { - // Check if the TextInputControl is not already ALL selected - result = selectedText == null - || selectedText.length() < tic.getText().length(); - } - } else { - result = getEditorController().canPerformControlAction(ControlAction.SELECT_ALL); - } - return result; - } - - private void performSelectAll() { - final Node focusOwner = this.getScene().getFocusOwner(); - if (isTextInputControlEditing(focusOwner)) { - final TextInputControl tic = getTextInputControl(focusOwner); - tic.selectAll(); - } else { - this.getEditorController().performControlAction(ControlAction.SELECT_ALL); - } - } - - private boolean canPerformSelectNone() { - boolean result; - final Node focusOwner = this.getScene().getFocusOwner(); - if (isPopupEditing(focusOwner)) { - return false; - } else if (isTextInputControlEditing(focusOwner)) { - final TextInputControl tic = getTextInputControl(focusOwner); - result = tic.getSelectedText() != null && tic.getSelectedText().isEmpty() == false; - } else { - result = getEditorController().canPerformControlAction(ControlAction.SELECT_NONE); - } - return result; - } - - private void performSelectNone() { - final Node focusOwner = this.getScene().getFocusOwner(); - if (isTextInputControlEditing(focusOwner)) { - final TextInputControl tic = getTextInputControl(focusOwner); - tic.deselect(); - } else { - this.getEditorController().performControlAction(ControlAction.SELECT_NONE); - } - } - - private boolean canPerformCopy() { - boolean result; - final Node focusOwner = this.getScene().getFocusOwner(); - if (isPopupEditing(focusOwner)) { - return false; - } else if (isTextInputControlEditing(focusOwner)) { - final TextInputControl tic = getTextInputControl(focusOwner); - result = tic.getSelectedText() != null && tic.getSelectedText().isEmpty() == false; - } else if (isCssRulesEditing(focusOwner) || isCssTextEditing(focusOwner)) { - result = true; - } else { - result = getEditorController().canPerformControlAction(ControlAction.COPY); - } - return result; - } - - private void performCopy() { - final Node focusOwner = this.getScene().getFocusOwner(); - if (isTextInputControlEditing(focusOwner)) { - final TextInputControl tic = getTextInputControl(focusOwner); - tic.copy(); - } else if (isCssRulesEditing(focusOwner)) { - cssPanelController.copyRules(); - } else if (isCssTextEditing(focusOwner)) { - // CSS text pane is a WebView - // Let the WebView handle the copy action natively - } else { - this.getEditorController().performControlAction(ControlAction.COPY); - } - } - - private boolean canPerformCut() { - boolean result; - final Node focusOwner = this.getScene().getFocusOwner(); - if (isPopupEditing(focusOwner)) { - return false; - } else if (isTextInputControlEditing(focusOwner)) { - final TextInputControl tic = getTextInputControl(focusOwner); - result = tic.getSelectedText() != null && tic.getSelectedText().isEmpty() == false; - } else { - result = getEditorController().canPerformEditAction(EditAction.CUT); - } - return result; - } - - private void performCut() { - final Node focusOwner = this.getScene().getFocusOwner(); - if (isTextInputControlEditing(focusOwner)) { - final TextInputControl tic = getTextInputControl(focusOwner); - tic.cut(); - } else { - this.getEditorController().performEditAction(EditAction.CUT); - } - } - - private boolean canPerformPaste() { - boolean result; - final Node focusOwner = this.getScene().getFocusOwner(); - // If there is FXML in the clipboard, we paste the FXML whatever the focus owner is - if (getEditorController().canPerformEditAction(EditAction.PASTE)) { - result = true; - } else if (isTextInputControlEditing(focusOwner)) { - result = Clipboard.getSystemClipboard().hasString(); - } else { - result = false; - } - return result; - } - - private void performPaste() { - final Node focusOwner = this.getScene().getFocusOwner(); - // If there is FXML in the clipboard, we paste the FXML whatever the focus owner is - if (getEditorController().canPerformEditAction(EditAction.PASTE)) { - this.getEditorController().performEditAction(EditAction.PASTE); - // Give focus to content panel - contentPanelController.getGlassLayer().requestFocus(); - } else { - assert isTextInputControlEditing(focusOwner); - final TextInputControl tic = getTextInputControl(focusOwner); - tic.paste(); - } - } - - private boolean canPerformDelete() { - boolean result; - final Node focusOwner = this.getScene().getFocusOwner(); - if (isTextInputControlEditing(focusOwner)) { - final TextInputControl tic = getTextInputControl(focusOwner); - result = tic.getCaretPosition() < tic.getLength(); - } else { - result = getEditorController().canPerformEditAction(EditAction.DELETE); - } - return result; - } - - private void performDelete() { - - final Node focusOwner = this.getScene().getFocusOwner(); - if (isTextInputControlEditing(focusOwner)) { - final TextInputControl tic = getTextInputControl(focusOwner); - tic.deleteNextChar(); - } else { - - // Collects all the selected objects - final List selectedObjects = new ArrayList<>(); - final Selection selection = editorController.getSelection(); - if (selection.getGroup() instanceof ObjectSelectionGroup) { - final ObjectSelectionGroup osg = (ObjectSelectionGroup) selection.getGroup(); - selectedObjects.addAll(osg.getItems()); - } else if (selection.getGroup() instanceof GridSelectionGroup) { - final GridSelectionGroup gsg = (GridSelectionGroup) selection.getGroup(); - selectedObjects.addAll(gsg.collectSelectedObjects()); - } else { - assert false; - } - - // Collects fx:ids in selected objects and their descendants. - // We filter out toggle groups because their fx:ids are managed automatically. - final Map fxIdMap = new HashMap<>(); - for (FXOMObject selectedObject : selectedObjects) { - fxIdMap.putAll(selectedObject.collectFxIds()); - } - FXOMNodes.removeToggleGroups(fxIdMap); - - // Checks if deleted objects have some fx:ids and ask for confirmation. - final boolean deleteConfirmed; - if (fxIdMap.isEmpty()) { - deleteConfirmed = true; - } else { - final String message; - - if (fxIdMap.size() == 1) { - if (selectedObjects.size() == 1) { - message = I18N.getString("alert.delete.fxid1of1.message"); - } else { - message = I18N.getString("alert.delete.fxid1ofN.message"); - } - } else { - if (selectedObjects.size() == fxIdMap.size()) { - message = I18N.getString("alert.delete.fxidNofN.message"); - } else { - message = I18N.getString("alert.delete.fxidKofN.message"); - } - } - - final AlertDialog d = new AlertDialog(getStage()); - d.setMessage(message); - d.setDetails(I18N.getString("alert.delete.fxid.details")); - d.setOKButtonTitle(I18N.getString("label.delete")); - - deleteConfirmed = (d.showAndWait() == AbstractModalDialog.ButtonID.OK); - } - - if (deleteConfirmed) { - editorController.performEditAction(EditAction.DELETE); - } - } - } - - private void performImportFxml() { - - final FileChooser fileChooser = new FileChooser(); - final ExtensionFilter f - = new ExtensionFilter(I18N.getString("file.filter.label.fxml"), - "*.fxml"); //NOI18N - fileChooser.getExtensionFilters().add(f); - fileChooser.setInitialDirectory(EditorController.getNextInitialDirectory()); - - File fxmlFile = fileChooser.showOpenDialog(getStage()); - if (fxmlFile != null) { - // See DTL-5948: on Linux we anticipate an extension less path. - final String path = fxmlFile.getPath(); - if (!path.endsWith(".fxml")) { //NOI18N - fxmlFile = new File(path + ".fxml"); //NOI18N - } - - // Keep track of the user choice for next time - EditorController.updateNextInitialDirectory(fxmlFile); - - this.getEditorController().performImportFxml(fxmlFile); - } - } - - private void performImportMedia() { - - final FileChooser fileChooser = new FileChooser(); - final ExtensionFilter imageFilter - = new ExtensionFilter(I18N.getString("file.filter.label.image"), - getImageExtensions()); - final ExtensionFilter audioFilter - = new ExtensionFilter(I18N.getString("file.filter.label.audio"), - getAudioExtensions()); - final ExtensionFilter videoFilter - = new ExtensionFilter(I18N.getString("file.filter.label.video"), - getVideoExtensions()); - final ExtensionFilter mediaFilter - = new ExtensionFilter(I18N.getString("file.filter.label.media"), - getMediaExtensions()); - - fileChooser.getExtensionFilters().add(mediaFilter); - fileChooser.getExtensionFilters().add(imageFilter); - fileChooser.getExtensionFilters().add(audioFilter); - fileChooser.getExtensionFilters().add(videoFilter); - - fileChooser.setInitialDirectory(EditorController.getNextInitialDirectory()); - - File mediaFile = fileChooser.showOpenDialog(getStage()); - if (mediaFile != null) { - - // Keep track of the user choice for next time - EditorController.updateNextInitialDirectory(mediaFile); - - this.getEditorController().performImportMedia(mediaFile); - } - } - - private static synchronized List getImageExtensions() { - if (imageExtensions == null) { - imageExtensions = new ArrayList<>(); - imageExtensions.add("*.jpg"); //NOI18N - imageExtensions.add("*.jpeg"); //NOI18N - imageExtensions.add("*.png"); //NOI18N - imageExtensions.add("*.gif"); //NOI18N - imageExtensions = Collections.unmodifiableList(imageExtensions); - } - return imageExtensions; - } - - private static synchronized List getAudioExtensions() { - if (audioExtensions == null) { - audioExtensions = new ArrayList<>(); - audioExtensions.add("*.aif"); //NOI18N - audioExtensions.add("*.aiff"); //NOI18N - audioExtensions.add("*.mp3"); //NOI18N - audioExtensions.add("*.m4a"); //NOI18N - audioExtensions.add("*.wav"); //NOI18N - audioExtensions.add("*.m3u"); //NOI18N - audioExtensions.add("*.m3u8"); //NOI18N - audioExtensions = Collections.unmodifiableList(audioExtensions); - } - return audioExtensions; - } - - private static synchronized List getVideoExtensions() { - if (videoExtensions == null) { - videoExtensions = new ArrayList<>(); - videoExtensions.add("*.flv"); //NOI18N - videoExtensions.add("*.fxm"); //NOI18N - videoExtensions.add("*.mp4"); //NOI18N - videoExtensions.add("*.m4v"); //NOI18N - videoExtensions = Collections.unmodifiableList(videoExtensions); - } - return videoExtensions; - } - - private static synchronized List getMediaExtensions() { - if (mediaExtensions == null) { - mediaExtensions = new ArrayList<>(); - mediaExtensions.addAll(getImageExtensions()); - mediaExtensions.addAll(getAudioExtensions()); - mediaExtensions.addAll(getVideoExtensions()); - mediaExtensions = Collections.unmodifiableList(mediaExtensions); - } - return mediaExtensions; - } - - private void performIncludeFxml() { - - final FileChooser fileChooser = new FileChooser(); - final ExtensionFilter f - = new ExtensionFilter(I18N.getString("file.filter.label.fxml"), - "*.fxml"); //NOI18N - fileChooser.getExtensionFilters().add(f); - fileChooser.setInitialDirectory(EditorController.getNextInitialDirectory()); - - File fxmlFile = fileChooser.showOpenDialog(getStage()); - if (fxmlFile != null) { - // See DTL-5948: on Linux we anticipate an extension less path. - final String path = fxmlFile.getPath(); - if (!path.endsWith(".fxml")) { //NOI18N - fxmlFile = new File(path + ".fxml"); //NOI18N - } - - // Keep track of the user choice for next time - EditorController.updateNextInitialDirectory(fxmlFile); - - this.getEditorController().performIncludeFxml(fxmlFile); - } - } - - /** - * Returns true if the specified node is part of the main scene and is - * either a TextInputControl or a ComboBox. - * - * @param node the focused node of the main scene - * @return - */ - private boolean isTextInputControlEditing(Node node) { - return (node instanceof TextInputControl - || node instanceof ComboBox); - } - - private TextInputControl getTextInputControl(Node node) { - assert isTextInputControlEditing(node); - final TextInputControl tic; - if (node instanceof TextInputControl) { - tic = (TextInputControl) node; - } else { - assert node instanceof ComboBox; - final ComboBox cb = (ComboBox) node; - tic = cb.getEditor(); - } - return tic; - } - - /** - * Returns true if we are editing within a popup window : - * either the specified node is showing a popup window - * or the inline editing popup is showing. - * - * @param node the focused node of the main scene - * @return - */ - private boolean isPopupEditing(Node node) { - return (node instanceof MenuButton && ((MenuButton) node).isShowing()) - || editorController.getInlineEditController().isWindowOpened(); - } - - private boolean isCssRulesEditing(Node node) { - final Node cssRules = cssPanelController.getRulesPane(); - if (cssRules != null) { - return isDescendantOf(cssRules, node); - } - return false; - } - - private boolean isCssTextEditing(Node node) { - final Node cssText = cssPanelController.getTextPane(); - if (cssText != null) { - return isDescendantOf(cssText, node); - } - return false; - } - - private boolean isDescendantOf(Node container, Node node) { - Node child = node; - while (child != null) { - if (child == container) { - return true; - } - child = child.getParent(); - } - return false; - } - - private KeyCombination getAccelerator(final KeyEvent event) { - KeyCombination result = null; - for (KeyCombination kc : menuBarController.getAccelerators()) { - if (kc.match(event)) { - result = kc; - break; - } - } - return result; - } - - private void updateStageTitle() { - if (libraryPanelHost != null) { - getStage().setTitle(makeTitle(editorController.getFxomDocument())); - } // else controllerDidLoadFxml() will invoke me again - } - - private void updateFromDocumentPreferences() { - if (libraryPanelHost != null) { // Layout is over - // Refresh UI with preferences - final PreferencesController pc = PreferencesController.getSingleton(); - // Preferences global to the application - final PreferencesRecordGlobal recordGlobal = pc.getRecordGlobal(); - recordGlobal.refresh(this); - // Preferences specific to the document - final PreferencesRecordDocument recordDocument = pc.getRecordDocument(this); - recordDocument.readFromJavaPreferences(); - // Update UI accordingly - recordDocument.refresh(); - } - } - - private void resetDocumentPreferences() { - final PreferencesController pc = PreferencesController.getSingleton(); - final PreferencesRecordDocument recordDocument = pc.getRecordDocument(this); - recordDocument.resetDocumentPreferences(); - } - - ActionStatus performSaveOrSaveAsAction() { - final ActionStatus result; - - if (editorController.getFxomDocument().getLocation() == null) { - result = performSaveAsAction(); - } else { - result = performSaveAction(); - } - - if (result.equals(ActionStatus.DONE)) { - messageBarController.setDocumentDirty(false); - saveJob = getEditorController().getJobManager().getCurrentJob(); - } - - return result; - } - - private void addCssPanelSearchListener() { - cssPanelSearchController.textProperty().addListener((ChangeListener) (ov, oldStr, newStr) -> cssPanelController.setSearchPattern(newStr)); - } - - private void performGoToSection(SectionId sectionId) { - // First make the right panel visible if not already the case - if (isRightPanelVisible() == false) { - performControlAction(DocumentControlAction.TOGGLE_RIGHT_PANEL); - } - inspectorPanelController.setExpandedSection(sectionId); - } - - private ActionStatus performSaveAction() { - final FXOMDocument fxomDocument = editorController.getFxomDocument(); - assert fxomDocument != null; - assert fxomDocument.getLocation() != null; - - ActionStatus result; - if (editorController.canGetFxmlText()) { - final Path fxmlPath; - try { - fxmlPath = Paths.get(fxomDocument.getLocation().toURI()); - } catch(URISyntaxException x) { - // Should not happen - throw new RuntimeException("Bug in " + getClass().getSimpleName(), x); //NOI18N - } - final String fileName = fxmlPath.getFileName().toString(); - - try { - final boolean saveConfirmed; - if (checkLoadFileTime()) { - saveConfirmed = true; - } else { - final AlertDialog d = new AlertDialog(getStage()); - d.setMessage(I18N.getString("alert.overwrite.message", fileName)); - d.setDetails(I18N.getString("alert.overwrite.details")); - d.setOKButtonVisible(true); - d.setOKButtonTitle(I18N.getString("label.overwrite")); - d.setDefaultButtonID(ButtonID.CANCEL); - d.setShowDefaultButton(true); - saveConfirmed = (d.showAndWait() == ButtonID.OK); - } - - if (saveConfirmed) { - try { - watchingController.removeDocumentTarget(); - final byte[] fxmlBytes = editorController.getFxmlText().getBytes("UTF-8"); //NOI18N - Files.write(fxmlPath, fxmlBytes); - updateLoadFileTime(); - watchingController.update(); - - editorController.getMessageLog().logInfoMessage( - "log.info.save.confirmation", I18N.getBundle(), fileName); - result = ActionStatus.DONE; - } catch(UnsupportedEncodingException x) { - // Should not happen - throw new RuntimeException("Bug", x); //NOI18N - } - } else { - result = ActionStatus.CANCELLED; - } - } catch(IOException x) { - final ErrorDialog d = new ErrorDialog(getStage()); - d.setMessage(I18N.getString("alert.save.failure.message", fileName)); - d.setDetails(I18N.getString("alert.save.failure.details")); - d.setDebugInfoWithThrowable(x); - d.showAndWait(); - result = ActionStatus.CANCELLED; - } - } else { - result = ActionStatus.CANCELLED; - } - - return result; - } - - - private ActionStatus performSaveAsAction() { - - final ActionStatus result; - if (editorController.canGetFxmlText()) { - final FileChooser fileChooser = new FileChooser(); - final FileChooser.ExtensionFilter f - = new FileChooser.ExtensionFilter(I18N.getString("file.filter.label.fxml"), - "*.fxml"); //NOI18N - fileChooser.getExtensionFilters().add(f); - fileChooser.setInitialDirectory(EditorController.getNextInitialDirectory()); - - File fxmlFile = fileChooser.showSaveDialog(getStage()); - if (fxmlFile == null) { - result = ActionStatus.CANCELLED; - } else { - boolean forgetSave = false; - // It is only on Linux where you can get the case the path doesn't - // end with the extension, thanks the behavior of the FX 8 FileChooser - // on this specific OS (see RT-31956). - // Below we ask the user if the extension shall be added or not. - // See DTL-5948. - final String path = fxmlFile.getPath(); - if (! path.endsWith(".fxml")) { //NOI18N - try { - URL alternateURL = new URL(fxmlFile.toURI().toURL().toExternalForm() + ".fxml"); //NOI18N - File alternateFxmlFile = new File(alternateURL.toURI()); - final AlertDialog d = new AlertDialog(getStage()); - d.setMessage(I18N.getString("alert.save.noextension.message", fxmlFile.getName())); - String details = I18N.getString("alert.save.noextension.details"); - - if (alternateFxmlFile.exists()) { - details += "\n" //NOI18N - + I18N.getString("alert.save.noextension.details.overwrite", alternateFxmlFile.getName()); - } - - d.setDetails(details); - d.setOKButtonVisible(true); - d.setOKButtonTitle(I18N.getString("alert.save.noextension.savewith")); - d.setDefaultButtonID(ButtonID.OK); - d.setShowDefaultButton(true); - d.setActionButtonDisable(false); - d.setActionButtonVisible(true); - d.setActionButtonTitle(I18N.getString("alert.save.noextension.savewithout")); - - switch (d.showAndWait()) { - case ACTION: - // Nothing to do, we save with the no extension name - break; - case CANCEL: - forgetSave = true; - break; - case OK: - fxmlFile = alternateFxmlFile; - break; - } - } catch (MalformedURLException | URISyntaxException ex) { - forgetSave = true; - } - } - - // Transform File into URL - final URL newLocation; - try { - newLocation = fxmlFile.toURI().toURL(); - } catch(MalformedURLException x) { - // Should not happen - throw new RuntimeException("Bug in " + getClass().getSimpleName(), x); //NOI18N - } - - // Checks if fxmlFile is the name of an already opened document - final DocumentWindowController dwc - = SceneBuilderApp.getSingleton().lookupDocumentWindowControllers(newLocation); - if (dwc != null && dwc != this) { - final Path fxmlPath = Paths.get(fxmlFile.toString()); - final String fileName = fxmlPath.getFileName().toString(); - final ErrorDialog d = new ErrorDialog(getStage()); - d.setMessage(I18N.getString("alert.save.conflict.message", fileName)); - d.setDetails(I18N.getString("alert.save.conflict.details")); - d.showAndWait(); - result = ActionStatus.CANCELLED; - } else if (forgetSave) { - result = ActionStatus.CANCELLED; - } else { - // Recalculates references if needed - // TODO(elp) - - // First change the location of the fxom document - editorController.setFxmlLocation(newLocation); - updateLoadFileTime(); - updateStageTitle(); - // We use same DocumentWindowController BUT we change its fxml : - // => reset document preferences - resetDocumentPreferences(); - - watchingController.update(); - - // Now performs a regular save action - result = performSaveAction(); - if (result.equals(ActionStatus.DONE)) { - messageBarController.setDocumentDirty(false); - saveJob = getEditorController().getJobManager().getCurrentJob(); - } - - // Keep track of the user choice for next time - EditorController.updateNextInitialDirectory(fxmlFile); - - // Update recent items with just saved file - final PreferencesController pc = PreferencesController.getSingleton(); - final PreferencesRecordGlobal recordGlobal = pc.getRecordGlobal(); - recordGlobal.addRecentItem(fxmlFile); - } - } - } else { - result = ActionStatus.CANCELLED; - } - - return result; - } - - - private void performRevertAction() { - assert editorController.getFxomDocument() != null; - assert editorController.getFxomDocument().getLocation() != null; - - final AlertDialog d = new AlertDialog(getStage()); - d.setMessage(I18N.getString("alert.revert.question.message", getStage().getTitle())); - d.setDetails(I18N.getString("alert.revert.question.details")); - d.setOKButtonTitle(I18N.getString("label.revert")); - - if (d.showAndWait() == AlertDialog.ButtonID.OK) { - try { - reload(); - } catch(IOException x) { - final ErrorDialog errorDialog = new ErrorDialog(null); - errorDialog.setMessage(I18N.getString("alert.open.failure1.message", getStage().getTitle())); - errorDialog.setDetails(I18N.getString("alert.open.failure1.details")); - errorDialog.setDebugInfoWithThrowable(x); - errorDialog.setTitle(I18N.getString("alert.title.open")); - errorDialog.showAndWait(); - SceneBuilderApp.getSingleton().documentWindowRequestClose(this); - } - } - } - - - ActionStatus performCloseAction() { - - // Makes sure that our window is front - getStage().toFront(); - - // Check if an editing session is on going - if (getEditorController().isTextEditingSessionOnGoing()) { - // Check if we can commit the editing session - if (getEditorController().canGetFxmlText() == false) { - // Commit failed - return ActionStatus.CANCELLED; - } - } - - // Checks if there are some pending changes - final boolean closeConfirmed; - if (isDocumentDirty()) { - - final AlertDialog d = new AlertDialog(getStage()); - d.setMessage(I18N.getString("alert.save.question.message", getStage().getTitle())); - d.setDetails(I18N.getString("alert.save.question.details")); - d.setOKButtonTitle(I18N.getString("label.save")); - d.setActionButtonTitle(I18N.getString("label.do.not.save")); - d.setActionButtonVisible(true); - - switch(d.showAndWait()) { - default: - case OK: - if (editorController.getFxomDocument().getLocation() == null) { - closeConfirmed = (performSaveAsAction() == ActionStatus.DONE); - } else { - closeConfirmed = (performSaveAction() == ActionStatus.DONE); - } - break; - case CANCEL: - closeConfirmed = false; - break; - case ACTION: // Do not save - closeConfirmed = true; - break; - } - - } else { - // No pending changes - closeConfirmed = true; - } - - // Closes if confirmed - if (closeConfirmed) { - SceneBuilderApp.getSingleton().documentWindowRequestClose(this); - - // Write java preferences at close time - updatePreferences(); - } - - return closeConfirmed ? ActionStatus.DONE : ActionStatus.CANCELLED; - } - - - private void performRevealAction() { - assert editorController.getFxomDocument() != null; - assert editorController.getFxomDocument().getLocation() != null; - - final URL location = editorController.getFxomDocument().getLocation(); - - try { - final File fxmlFile = new File(location.toURI()); - EditorPlatform.revealInFileBrowser(fxmlFile); - } catch(IOException | URISyntaxException x) { - final ErrorDialog errorDialog = new ErrorDialog(null); - errorDialog.setMessage(I18N.getString("alert.reveal.failure.message", getStage().getTitle())); - errorDialog.setDetails(I18N.getString("alert.reveal.failure.details")); - errorDialog.setDebugInfoWithThrowable(x); - errorDialog.showAndWait(); - } - } - - - private void updateLoadFileTime() { - - final URL fxmlURL = editorController.getFxmlLocation(); - if (fxmlURL == null) { - loadFileTime = null; - } else { - try { - final Path fxmlPath = Paths.get(fxmlURL.toURI()); - if (Files.exists(fxmlPath)) { - loadFileTime = Files.getLastModifiedTime(fxmlPath); - } else { - loadFileTime = null; - } - } catch(URISyntaxException x) { - throw new RuntimeException("Bug", x); //NOI18N - } catch(IOException x) { - loadFileTime = null; - } - } - } - - - private boolean checkLoadFileTime() throws IOException { - assert editorController.getFxmlLocation() != null; - - /* - * loadFileTime == null - * => fxml file does not exist - * => TRUE - * - * loadFileTime != null - * => fxml file does/did exist - * - * currentFileTime == null - * => fxml file no longer exists - * => TRUE - * - * currentFileTime != null - * => fxml file still exists - * => loadFileTime.compare(currentFileTime) == 0 - */ - - boolean result; - if (loadFileTime == null) { - // editorController.getFxmlLocation() does not exist yet - result = true; - } else { - try { - // editorController.getFxmlLocation() still exists - // Check if its file time matches loadFileTime - Path fxmlPath = Paths.get(editorController.getFxmlLocation().toURI()); - FileTime currentFileTime = Files.getLastModifiedTime(fxmlPath); - result = loadFileTime.compareTo(currentFileTime) == 0; - } catch(NoSuchFileException x) { - // editorController.getFxmlLocation() no longer exists - result = true; - } catch(URISyntaxException x) { - throw new RuntimeException("Bug", x); //NOI18N - } - } - - return result; - } - - - private void performHelp() { - try { - EditorPlatform.open(EditorPlatform.DOCUMENTATION_URL); - } catch (IOException ioe) { - final ErrorDialog errorDialog = new ErrorDialog(null); - errorDialog.setMessage(I18N.getString("alert.help.failure.message", EditorPlatform.DOCUMENTATION_URL)); - errorDialog.setDetails(I18N.getString("alert.messagebox.failure.details")); - errorDialog.setDebugInfoWithThrowable(ioe); - errorDialog.showAndWait(); - } - } -} - -///** -// * This class setup key bindings for the TextInputControl type classes and -// * provide a way to access the key binding list. -// */ -//class SBTextInputControlBindings extends TextInputControlBindings { -// -// private SBTextInputControlBindings() { -// assert false; -// } -// -// public static List getBindings() { -// return BINDINGS; -// } -//} diff --git a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/ResourceController.java b/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/ResourceController.java deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/ResourceController.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. - * All rights reserved. Use is subject to license terms. - * - * This file is available and licensed under the following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the distribution. - * - Neither the name of Oracle Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.oracle.javafx.scenebuilder.app; - -import com.oracle.javafx.scenebuilder.app.i18n.I18N; -import com.oracle.javafx.scenebuilder.kit.editor.EditorController; -import com.oracle.javafx.scenebuilder.kit.editor.EditorPlatform; -import com.oracle.javafx.scenebuilder.kit.editor.panel.util.dialog.ErrorDialog; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.charset.Charset; -import java.util.PropertyResourceBundle; -import java.util.ResourceBundle; - -import javafx.stage.FileChooser; - -/** - * - */ -class ResourceController { - - private final DocumentWindowController documentWindowController; - private File resourceFile; - - public ResourceController(DocumentWindowController dwc) { - this.documentWindowController = dwc; - } - - public File getResourceFile() { - return resourceFile; - } - - public void setResourceFile(File file) { - if (file != null) { - if (readPropertyResourceBundle(file) == null) { - // Property file syntax is probably incorrect - - } else { - resourceFile = file; - resourceFileDidChange(); - } - } - } - - public void performSetResource() { - // Open a file chooser for *.properties & *.bss - FileChooser fileChooser = new FileChooser(); - fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(I18N.getString("resource.filechooser.filter.msg"), - "*.properties")); //NOI18N - fileChooser.setInitialDirectory(EditorController.getNextInitialDirectory()); - File newResourceFile = fileChooser.showOpenDialog(documentWindowController.getStage()); - // Keep track of the user choice for next time - if (newResourceFile != null) { - EditorController.updateNextInitialDirectory(newResourceFile); - } - - setResourceFile(newResourceFile); - } - - public void performRemoveResource() { - assert resourceFile != null; - resourceFile = null; - resourceFileDidChange(); - } - - public void performRevealResource() { - assert resourceFile != null; - try { - EditorPlatform.revealInFileBrowser(resourceFile); - } catch (IOException ioe) { - final ErrorDialog errorDialog = new ErrorDialog(null); - errorDialog.setTitle(I18N.getString("error.file.reveal.title")); - errorDialog.setMessage(I18N.getString("error.file.reveal.message")); - errorDialog.setDetails(I18N.getString("error.filesystem.details")); - errorDialog.setDebugInfoWithThrowable(ioe); - errorDialog.showAndWait(); - } - } - - public void performReloadResource() { - assert resourceFile != null; - resourceFileDidChange(); - } - - /* - * Private - */ - - private void resourceFileDidChange() { - ResourceBundle resources; - - if (resourceFile != null) { - resources = readPropertyResourceBundle(resourceFile); - assert resources != null; - } else { - resources = null; - } - - documentWindowController.getEditorController().setResources(resources); - documentWindowController.getWatchingController().update(); - } - - - private static PropertyResourceBundle readPropertyResourceBundle(File f) { - PropertyResourceBundle result; - try { - result = new PropertyResourceBundle(new InputStreamReader(new FileInputStream(f), Charset.forName("UTF-8"))); //NOI18N - } catch (IOException ex) { - result = null; - } - return result; - } -} diff --git a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/SceneBuilderApp.java b/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/SceneBuilderApp.java deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/SceneBuilderApp.java +++ /dev/null @@ -1,844 +0,0 @@ -/* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. - * All rights reserved. Use is subject to license terms. - * - * This file is available and licensed under the following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the distribution. - * - Neither the name of Oracle Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.oracle.javafx.scenebuilder.app; - -import com.oracle.javafx.scenebuilder.app.DocumentWindowController.ActionStatus; -import com.oracle.javafx.scenebuilder.app.about.AboutWindowController; -import com.oracle.javafx.scenebuilder.app.i18n.I18N; -import com.oracle.javafx.scenebuilder.app.menubar.MenuBarController; -import com.oracle.javafx.scenebuilder.app.preferences.PreferencesController; -import com.oracle.javafx.scenebuilder.app.preferences.PreferencesRecordGlobal; -import com.oracle.javafx.scenebuilder.app.preferences.PreferencesWindowController; -import com.oracle.javafx.scenebuilder.app.template.FxmlTemplates; -import com.oracle.javafx.scenebuilder.app.template.TemplateDialogController; -import com.oracle.javafx.scenebuilder.kit.editor.EditorController; -import com.oracle.javafx.scenebuilder.kit.editor.EditorPlatform; -import com.oracle.javafx.scenebuilder.kit.editor.panel.util.dialog.AlertDialog; -import com.oracle.javafx.scenebuilder.kit.editor.panel.util.dialog.ErrorDialog; -import com.oracle.javafx.scenebuilder.kit.library.BuiltinLibrary; -import com.oracle.javafx.scenebuilder.kit.library.user.UserLibrary; -import com.oracle.javafx.scenebuilder.kit.metadata.Metadata; -import com.oracle.javafx.scenebuilder.kit.util.Deprecation; -import com.oracle.javafx.scenebuilder.kit.util.control.effectpicker.EffectPicker; - -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javafx.application.Application; -import javafx.application.Platform; -import javafx.beans.value.ChangeListener; -import javafx.stage.FileChooser; -import javafx.stage.Stage; - -/** - * - */ -public class SceneBuilderApp extends Application implements AppPlatform.AppNotificationHandler { - - public enum ApplicationControlAction { - - ABOUT, - NEW_FILE, - NEW_ALERT_DIALOG, - NEW_ALERT_DIALOG_CSS, - NEW_ALERT_DIALOG_I18N, - NEW_BASIC_APPLICATION, - NEW_BASIC_APPLICATION_CSS, - NEW_BASIC_APPLICATION_I18N, - NEW_COMPLEX_APPLICATION, - NEW_COMPLEX_APPLICATION_CSS, - NEW_COMPLEX_APPLICATION_I18N, - OPEN_FILE, - CLOSE_FRONT_WINDOW, - USE_DEFAULT_THEME, - USE_DARK_THEME, - SHOW_PREFERENCES, - EXIT - } - - public enum ToolTheme { - - DEFAULT { - @Override - public String toString() { - return I18N.getString("prefs.tool.theme.default"); - } - }, - DARK { - @Override - public String toString() { - return I18N.getString("prefs.tool.theme.dark"); - } - } - } - - private static SceneBuilderApp singleton; - private static String darkToolStylesheet; - private static final CountDownLatch launchLatch = new CountDownLatch(1); - - private final List windowList = new ArrayList<>(); - private final PreferencesWindowController preferencesWindowController - = new PreferencesWindowController(); - private final AboutWindowController aboutWindowController - = new AboutWindowController(); - private UserLibrary userLibrary; - private ToolTheme toolTheme = ToolTheme.DEFAULT; - - - /* - * Public - */ - public static SceneBuilderApp getSingleton() { - return singleton; - } - - public SceneBuilderApp() { - assert singleton == null; - singleton = this; - - /* - * We spawn our two threads for handling background startup. - */ - final Runnable p0 = () -> backgroundStartPhase0(); - final Runnable p1 = () -> { - try { - launchLatch.await(); - backgroundStartPhase2(); - } catch(InterruptedException x) { - // JavaFX thread has been interrupted. Simply exits. - } - }; - final Thread phase0 = new Thread(p0, "Phase 0"); //NOI18N - final Thread phase1 = new Thread(p1, "Phase 1"); //NOI18N - phase0.setDaemon(true); - phase1.setDaemon(true); - - // Note : if you suspect a race condition bug, comment the two next - // lines to make startup fully sequential. - phase0.start(); - phase1.start(); - } - - public void performControlAction(ApplicationControlAction a, DocumentWindowController source) { - switch (a) { - case ABOUT: - aboutWindowController.openWindow(); - break; - - case NEW_FILE: - final DocumentWindowController newWindow = makeNewWindow(); - newWindow.loadWithDefaultContent(); - newWindow.openWindow(); - break; - - case NEW_ALERT_DIALOG: - case NEW_BASIC_APPLICATION: - case NEW_COMPLEX_APPLICATION: - performNewTemplate(a); - break; - - case NEW_ALERT_DIALOG_CSS: - case NEW_ALERT_DIALOG_I18N: - case NEW_BASIC_APPLICATION_CSS: - case NEW_BASIC_APPLICATION_I18N: - case NEW_COMPLEX_APPLICATION_CSS: - case NEW_COMPLEX_APPLICATION_I18N: - performNewTemplateWithResources(a); - break; - - case OPEN_FILE: - performOpenFile(source); - break; - - case CLOSE_FRONT_WINDOW: - performCloseFrontWindow(); - break; - - case USE_DEFAULT_THEME: - performUseToolTheme(ToolTheme.DEFAULT); - break; - - case USE_DARK_THEME: - performUseToolTheme(ToolTheme.DARK); - break; - - case SHOW_PREFERENCES: - preferencesWindowController.openWindow(); - break; - - case EXIT: - performExit(); - break; - } - } - - - public boolean canPerformControlAction(ApplicationControlAction a, DocumentWindowController source) { - final boolean result; - switch (a) { - case ABOUT: - case NEW_FILE: - case NEW_ALERT_DIALOG: - case NEW_BASIC_APPLICATION: - case NEW_COMPLEX_APPLICATION: - case NEW_ALERT_DIALOG_CSS: - case NEW_ALERT_DIALOG_I18N: - case NEW_BASIC_APPLICATION_CSS: - case NEW_BASIC_APPLICATION_I18N: - case NEW_COMPLEX_APPLICATION_CSS: - case NEW_COMPLEX_APPLICATION_I18N: - case OPEN_FILE: - case SHOW_PREFERENCES: - case EXIT: - result = true; - break; - - case CLOSE_FRONT_WINDOW: - result = windowList.isEmpty() == false; - break; - - case USE_DEFAULT_THEME: - result = toolTheme != ToolTheme.DEFAULT; - break; - - case USE_DARK_THEME: - result = toolTheme != ToolTheme.DARK; - break; - - default: - result = false; - assert false; - break; - } - return result; - } - - public void performOpenRecent(DocumentWindowController source, final File fxmlFile) { - assert fxmlFile != null && fxmlFile.exists(); - - final List fxmlFiles = new ArrayList<>(); - fxmlFiles.add(fxmlFile); - performOpenFiles(fxmlFiles, source); - } - - public void documentWindowRequestClose(DocumentWindowController fromWindow) { - closeWindow(fromWindow); - } - - public UserLibrary getUserLibrary() { - return userLibrary; - } - - public List getDocumentWindowControllers() { - return Collections.unmodifiableList(windowList); - } - - public DocumentWindowController lookupDocumentWindowControllers(URL fxmlLocation) { - assert fxmlLocation != null; - - DocumentWindowController result = null; - try { - final URI fxmlURI = fxmlLocation.toURI(); - for (DocumentWindowController dwc : windowList) { - final URL docLocation = dwc.getEditorController().getFxmlLocation(); - if ((docLocation != null) && fxmlURI.equals(docLocation.toURI())) { - result = dwc; - break; - } - } - } catch (URISyntaxException x) { - // Should not happen - throw new RuntimeException("Bug in " + getClass().getSimpleName(), x); //NOI18N - } - - return result; - } - - public DocumentWindowController lookupUnusedDocumentWindowController() { - DocumentWindowController result = null; - - for (DocumentWindowController dwc : windowList) { - if (dwc.isUnused()) { - result = dwc; - break; - } - } - - return result; - } - - public void toggleDebugMenu() { - final boolean visible; - - if (windowList.isEmpty()) { - visible = false; - } else { - final DocumentWindowController dwc = windowList.get(0); - visible = dwc.getMenuBarController().isDebugMenuVisible(); - } - - for (DocumentWindowController dwc : windowList) { - dwc.getMenuBarController().setDebugMenuVisible(!visible); - } - - if (EditorPlatform.IS_MAC) { - MenuBarController.getSystemMenuBarController().setDebugMenuVisible(!visible); - } - } - - public static synchronized String getDarkToolStylesheet() { - if (darkToolStylesheet == null) { - final URL url = SceneBuilderApp.class.getResource("css/ThemeDark.css"); //NOI18N - assert url != null; - darkToolStylesheet = url.toExternalForm(); - } - return darkToolStylesheet; - } - - /* - * Application - */ - @Override - public void start(Stage stage) throws Exception { - launchLatch.countDown(); - setApplicationUncaughtExceptionHandler(); - - try { - if (AppPlatform.requestStart(this, getParameters()) == false) { - // Start has been denied because another instance is running. - Platform.exit(); - } - // else { - // No other Scene Builder instance is already running. - // AppPlatform.requestStart() has/will invoke(d) handleLaunch(). - // start() has now finished its job and should imply return. - // } - - } catch (IOException x) { - final ErrorDialog errorDialog = new ErrorDialog(null); - errorDialog.setTitle(I18N.getString("alert.title.start")); - errorDialog.setMessage(I18N.getString("alert.start.failure.message")); - errorDialog.setDetails(I18N.getString("alert.start.failure.details")); - errorDialog.setDebugInfoWithThrowable(x); - errorDialog.showAndWait(); - Platform.exit(); - } - - logTimestamp(ACTION.START); - } - - /* - * AppPlatform.AppNotificationHandler - */ - @Override - public void handleLaunch(List files) { - setApplicationUncaughtExceptionHandler(); - - // Creates the user library - userLibrary = new UserLibrary(AppPlatform.getUserLibraryFolder()); - - userLibrary.explorationCountProperty().addListener((ChangeListener) (ov, t, t1) -> userLibraryExplorationCountDidChange()); - - userLibrary.startWatching(); - - if (files.isEmpty()) { - // Creates an empty document - final DocumentWindowController newWindow = makeNewWindow(); - newWindow.loadWithDefaultContent(); - newWindow.openWindow(); - - // Show ScenicView Tool when the JVM is started with option -Dscenic. - // NetBeans: set it on [VM Options] line in [Run] category of project's Properties. - if (System.getProperty("scenic") != null) { //NOI18N - Platform.runLater(new ScenicViewStarter(newWindow.getScene())); - } - } else { - // Open files passed as arguments by the platform - handleOpenFilesAction(files); - } - - // On Mac, AppPlatform disables implicit exit. - // So we need to set a default system menu bar. - if (Platform.isImplicitExit() == false) { - Deprecation.setDefaultSystemMenuBar(MenuBarController.getSystemMenuBarController().getMenuBar()); - } - } - - @Override - public void handleOpenFilesAction(List files) { - assert files != null; - assert files.isEmpty() == false; - - final List fileObjs = new ArrayList<>(); - for (String file : files) { - fileObjs.add(new File(file)); - } - - performOpenFiles(fileObjs, null); - } - - @Override - public void handleMessageBoxFailure(Exception x) { - final ErrorDialog errorDialog = new ErrorDialog(null); - errorDialog.setTitle(I18N.getString("alert.title.messagebox")); - errorDialog.setMessage(I18N.getString("alert.messagebox.failure.message")); - errorDialog.setDetails(I18N.getString("alert.messagebox.failure.details")); - errorDialog.setDebugInfoWithThrowable(x); - errorDialog.showAndWait(); - } - - @Override - public void handleQuitAction() { - - /* - * Note : this callback is called on Mac OS X only when the user - * selects the 'Quit App' command in the Application menu. - * - * Before calling this callback, FX automatically sends a close event - * to each open window ie DocumentWindowController.performCloseAction() - * is invoked for each open window. - * - * When we arrive here, windowList is empty if the user has confirmed - * the close operation for each window : thus exit operation can - * be performed. If windowList is not empty, this means the user has - * cancelled at least one close operation : in that case, exit operation - * should be not be executed. - */ - if (windowList.isEmpty()) { - logTimestamp(ACTION.STOP); - Platform.exit(); - } - } - - /** - * Normally ignored in correctly deployed JavaFX application. - * But on Mac OS, this method seems to be called by the javafx launcher. - */ - public static void main(String[] args) { - launch(args); - } - - /* - * Private - */ - public DocumentWindowController makeNewWindow() { - final DocumentWindowController result = new DocumentWindowController(); - windowList.add(result); - return result; - } - - private void closeWindow(DocumentWindowController w) { - assert windowList.contains(w); - windowList.remove(w); - w.closeWindow(); - } - - private static String displayName(String pathString) { - return Paths.get(pathString).getFileName().toString(); - } - - /* - * Private (control actions) - */ - private void performOpenFile(DocumentWindowController fromWindow) { - final FileChooser fileChooser = new FileChooser(); - - fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(I18N.getString("file.filter.label.fxml"), - "*.fxml")); //NOI18N - fileChooser.setInitialDirectory(EditorController.getNextInitialDirectory()); - final List fxmlFiles = fileChooser.showOpenMultipleDialog(null); - if (fxmlFiles != null) { - assert fxmlFiles.isEmpty() == false; - EditorController.updateNextInitialDirectory(fxmlFiles.get(0)); - performOpenFiles(fxmlFiles, fromWindow); - } - } - - private void performNewTemplate(ApplicationControlAction action) { - final DocumentWindowController newTemplateWindow = makeNewWindow(); - final URL url = FxmlTemplates.getContentURL(action); - newTemplateWindow.loadFromURL(url); - newTemplateWindow.openWindow(); - } - - private void performNewTemplateWithResources(ApplicationControlAction action) { - final TemplateDialogController tdc = new TemplateDialogController(action); - tdc.setToolStylesheet(getToolStylesheet()); - tdc.openWindow(); - } - - private void performCloseFrontWindow() { - if (preferencesWindowController != null - && preferencesWindowController.getStage().isFocused()) { - preferencesWindowController.closeWindow(); - } else { - for (DocumentWindowController dwc : windowList) { - if (dwc.isFrontDocumentWindow()) { - dwc.performCloseFrontDocumentWindow(); - break; - } - } - } - } - - private void performOpenFiles(List fxmlFiles, - DocumentWindowController fromWindow) { - assert fxmlFiles != null; - assert fxmlFiles.isEmpty() == false; - - final Map exceptions = new HashMap<>(); - for (File fxmlFile : fxmlFiles) { - try { - final DocumentWindowController dwc - = lookupDocumentWindowControllers(fxmlFile.toURI().toURL()); - if (dwc != null) { - // fxmlFile is already opened - dwc.getStage().toFront(); - } else { - // Open fxmlFile - final DocumentWindowController hostWindow; - final DocumentWindowController unusedWindow - = lookupUnusedDocumentWindowController(); - if (unusedWindow != null) { - hostWindow = unusedWindow; - } else { - hostWindow = makeNewWindow(); - } - hostWindow.loadFromFile(fxmlFile); - hostWindow.openWindow(); - } - } catch (IOException xx) { - exceptions.put(fxmlFile, xx); - } - } - - switch (exceptions.size()) { - case 0: { // Good - // Update recent items with opened files - final PreferencesController pc = PreferencesController.getSingleton(); - final PreferencesRecordGlobal recordGlobal = pc.getRecordGlobal(); - recordGlobal.addRecentItems(fxmlFiles); - break; - } - case 1: { - final File fxmlFile = exceptions.keySet().iterator().next(); - final Exception x = exceptions.get(fxmlFile); - final ErrorDialog errorDialog = new ErrorDialog(null); - errorDialog.setMessage(I18N.getString("alert.open.failure1.message", displayName(fxmlFile.getPath()))); - errorDialog.setDetails(I18N.getString("alert.open.failure1.details")); - errorDialog.setDebugInfoWithThrowable(x); - errorDialog.setTitle(I18N.getString("alert.title.open")); - errorDialog.showAndWait(); - break; - } - default: { - final ErrorDialog errorDialog = new ErrorDialog(null); - if (exceptions.size() == fxmlFiles.size()) { - // Open operation has failed for all the files - errorDialog.setMessage(I18N.getString("alert.open.failureN.message")); - errorDialog.setDetails(I18N.getString("alert.open.failureN.details")); - } else { - // Open operation has failed for some files - errorDialog.setMessage(I18N.getString("alert.open.failureMofN.message", - exceptions.size(), fxmlFiles.size())); - errorDialog.setDetails(I18N.getString("alert.open.failureMofN.details")); - } - errorDialog.setTitle(I18N.getString("alert.title.open")); - errorDialog.showAndWait(); - break; - } - } - } - - private void performExit() { - - // Check if an editing session is on going - for (DocumentWindowController dwc : windowList) { - if (dwc.getEditorController().isTextEditingSessionOnGoing()) { - // Check if we can commit the editing session - if (dwc.getEditorController().canGetFxmlText() == false) { - // Commit failed - return; - } - } - } - - // Collects the documents with pending changes - final List pendingDocs = new ArrayList<>(); - for (DocumentWindowController dwc : windowList) { - if (dwc.isDocumentDirty()) { - pendingDocs.add(dwc); - } - } - - // Notifies the user if some documents are dirty - final boolean exitConfirmed; - switch (pendingDocs.size()) { - case 0: { - exitConfirmed = true; - break; - } - - case 1: { - final DocumentWindowController dwc0 = pendingDocs.get(0); - exitConfirmed = dwc0.performCloseAction() == ActionStatus.DONE; - break; - } - - default: { - assert pendingDocs.size() >= 2; - - final AlertDialog d = new AlertDialog(null); - d.setMessage(I18N.getString("alert.review.question.message", pendingDocs.size())); - d.setDetails(I18N.getString("alert.review.question.details")); - d.setOKButtonTitle(I18N.getString("label.review.changes")); - d.setActionButtonTitle(I18N.getString("label.discard.changes")); - d.setActionButtonVisible(true); - - switch (d.showAndWait()) { - default: - case OK: { // Review - int i = 0; - ActionStatus status; - do { - status = pendingDocs.get(i++).performCloseAction(); - } while ((status == ActionStatus.DONE) && (i < pendingDocs.size())); - exitConfirmed = (status == ActionStatus.DONE); - break; - } - case CANCEL: { - exitConfirmed = false; - break; - } - case ACTION: { // Do not review - exitConfirmed = true; - break; - } - } - break; - } - } - - // Exit if confirmed - if (exitConfirmed) { - for (DocumentWindowController dwc : new ArrayList<>(windowList)) { - // Write to java preferences before closing - dwc.updatePreferences(); - documentWindowRequestClose(dwc); - } - logTimestamp(ACTION.STOP); - // TODO (elp): something else here ? - Platform.exit(); - } - } - - private enum ACTION {START, STOP}; - - private void logTimestamp(ACTION type) { - switch (type) { - case START: - Logger.getLogger(this.getClass().getName()).info(I18N.getString("log.start")); - break; - case STOP: - Logger.getLogger(this.getClass().getName()).info(I18N.getString("log.stop")); - break; - default: - assert false; - } - } - - private void setApplicationUncaughtExceptionHandler() { - if (Thread.getDefaultUncaughtExceptionHandler() == null) { - // Register a Default Uncaught Exception Handler for the application - Thread.setDefaultUncaughtExceptionHandler(new SceneBuilderUncaughtExceptionHandler()); - } - } - - private static class SceneBuilderUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler{ - - @Override - public void uncaughtException(Thread t, Throwable e) { - // Print the details of the exception in SceneBuilder log file - Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "An exception was thrown:", e); //NOI18N - } - } - - - private void performUseToolTheme(ToolTheme toolTheme) { - this.toolTheme = toolTheme; - - final String toolStylesheet = getToolStylesheet(); - - for (DocumentWindowController dwc : windowList) { - dwc.setToolStylesheet(toolStylesheet); - } - preferencesWindowController.setToolStylesheet(toolStylesheet); - aboutWindowController.setToolStylesheet(toolStylesheet); - } - - - private String getToolStylesheet() { - final String result; - - switch(this.toolTheme) { - - default: - case DEFAULT: - result = EditorController.getBuiltinToolStylesheet(); - break; - - case DARK: - result = getDarkToolStylesheet(); - break; - } - - return result; - } - - - /* - * Background startup - * - * To speed SB startup, we create two threads which anticipate some - * initialization tasks and offload the JFX thread: - * - 'Phase 0' thread executes tasks that do not require JFX initialization - * - 'Phase 1' thread executes tasks that requires JFX initialization - * - * Tasks executed here must be carefully chosen: - * 1) they must be thread-safe - * 2) they should be order-safe : whether they are executed in background - * or by the JFX thread should make no difference. - * - * Currently we simply anticipate creation of big singleton instances - * (like Metadata, Preferences...) - */ - - private void backgroundStartPhase0() { - assert Platform.isFxApplicationThread() == false; // Warning - - PreferencesController.getSingleton(); - Metadata.getMetadata(); - } - - private void backgroundStartPhase2() { - assert Platform.isFxApplicationThread() == false; // Warning - assert launchLatch.getCount() == 0; // i.e JavaFX is initialized - - BuiltinLibrary.getLibrary(); - if (EditorPlatform.IS_MAC) { - MenuBarController.getSystemMenuBarController(); - } - EffectPicker.getEffectClasses(); - } - - private void userLibraryExplorationCountDidChange() { - // We can have 0, 1 or N FXML file, same for JAR one. - final int numOfFxmlFiles = userLibrary.getFxmlFileReports().size(); - final int numOfJarFiles = userLibrary.getJarReports().size(); - final int jarCount = userLibrary.getJarReports().size(); - final int fxmlCount = userLibrary.getFxmlFileReports().size(); - - switch (numOfFxmlFiles + numOfJarFiles) { - case 0: // Case 0-0 - final int previousNumOfJarFiles = userLibrary.getPreviousJarReports().size(); - final int previousNumOfFxmlFiles = userLibrary.getPreviousFxmlFileReports().size(); - if (previousNumOfFxmlFiles > 0 || previousNumOfJarFiles > 0) { - logInfoMessage("log.user.exploration.0"); - } - break; - case 1: - Path path; - if (numOfFxmlFiles == 1) { // Case 1-0 - path = userLibrary.getFxmlFileReports().get(0); - } else { // Case 0-1 - path = userLibrary.getJarReports().get(0).getJar(); - } - logInfoMessage("log.user.exploration.1", path.getFileName()); - break; - default: - switch (numOfFxmlFiles) { - case 0: // Case 0-N - logInfoMessage("log.user.jar.exploration.n", jarCount); - break; - case 1: - final Path fxmlName = userLibrary.getFxmlFileReports().get(0).getFileName(); - if (numOfFxmlFiles == numOfJarFiles) { // Case 1-1 - final Path jarName = userLibrary.getJarReports().get(0).getJar().getFileName(); - logInfoMessage("log.user.fxml.jar.exploration.1.1", fxmlName, jarName); - } else { // Case 1-N - logInfoMessage("log.user.fxml.jar.exploration.1.n", fxmlName, jarCount); - } - break; - default: - switch (numOfJarFiles) { - case 0: // Case N-0 - logInfoMessage("log.user.fxml.exploration.n", fxmlCount); - break; - case 1: // Case N-1 - final Path jarName = userLibrary.getJarReports().get(0).getJar().getFileName(); - logInfoMessage("log.user.fxml.jar.exploration.n.1", fxmlCount, jarName); - break; - default: // Case N-N - logInfoMessage("log.user.fxml.jar.exploration.n.n", fxmlCount, jarCount); - break; - } - break; - } - break; - } - } - - private void logInfoMessage(String key) { - for (DocumentWindowController dwc : windowList) { - dwc.getEditorController().getMessageLog().logInfoMessage(key, I18N.getBundle()); - } - } - - private void logInfoMessage(String key, Object... args) { - for (DocumentWindowController dwc : windowList) { - dwc.getEditorController().getMessageLog().logInfoMessage(key, I18N.getBundle(), args); - } - } -} diff --git a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/SceneBuilderTest.java b/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/SceneBuilderTest.java deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/SceneBuilderTest.java +++ /dev/null @@ -1,458 +0,0 @@ -/* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. - * All rights reserved. Use is subject to license terms. - * - * This file is available and licensed under the following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the distribution. - * - Neither the name of Oracle Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.oracle.javafx.scenebuilder.app; - -import com.oracle.javafx.scenebuilder.app.about.AboutWindowController; -import com.oracle.javafx.scenebuilder.kit.editor.EditorController; -import com.oracle.javafx.scenebuilder.kit.editor.panel.content.ContentPanelController; -import com.oracle.javafx.scenebuilder.kit.editor.panel.content.driver.handles.AbstractGenericHandles; -import com.oracle.javafx.scenebuilder.kit.editor.panel.content.driver.handles.AbstractHandles; -import com.oracle.javafx.scenebuilder.kit.editor.panel.content.util.CardinalPoint; -import com.oracle.javafx.scenebuilder.kit.editor.panel.hierarchy.AbstractHierarchyPanelController; -import com.oracle.javafx.scenebuilder.kit.editor.panel.hierarchy.HierarchyItem; -import com.oracle.javafx.scenebuilder.kit.editor.selection.ObjectSelectionGroup; -import com.oracle.javafx.scenebuilder.kit.editor.selection.Selection; -import com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument; -import com.oracle.javafx.scenebuilder.kit.fxom.FXOMObject; -import java.io.File; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import javafx.geometry.Bounds; -import javafx.geometry.Point2D; -import javafx.scene.Node; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.scene.control.Cell; -import javafx.scene.control.TreeItem; - -/** - * This class groups the entry points reserved to QE testing. - * - * Design consideration - * - * This class tries to hide SB internal architecture as much as possible; - * for example, an FXML document is represented by a DocumentWindowController - * instance in SB; however, in this class, the FXML document is - * identified by the Scene instance holding the document window contents.. - * - * However some internals must be disclosed: - * - * - FXOMObject : represents a design object ; it is paired with an object - * in the user scene graph ; FXOMObject.getSceneGraphObject() returns the - * matching scene graph object : sometimes it's a plain Node (eg Button), - * sometimes not (eg a Tab, a TableColumn...). - * - * - ... - * - */ -public class SceneBuilderTest { - - /** - * Performs [File/New] menu command and returns the Scene instance - * holding the new document window. - * - * @return the scene instance holding the new document window (never null). - */ - public static Scene newFxmlFile() { - final DocumentWindowController newWindow - = SceneBuilderApp.getSingleton().makeNewWindow(); - newWindow.openWindow(); - return newWindow.getScene(); - } - - /** - * Performs [File/Open] menu command with the file passed in argument. - * If an error happens, the method throws the corresponding exception - * (in place of displaying an alert dialog). - * - * @param fxmlFile fxml file to be opened (never null) - * @return the scene instance holding the new document window (never null). - * @throws IOException if the open operation has failed. - */ - public static Scene openFxmlFile(File fxmlFile) throws IOException { - assert fxmlFile != null; - - final DocumentWindowController newWindow - = SceneBuilderApp.getSingleton().makeNewWindow(); - newWindow.loadFromFile(fxmlFile); - newWindow.openWindow(); - return newWindow.getScene(); - } - - /** - * Returns the root of the [user scene graph] ie the scene graph - * constructed from the content of the FXML file. If documentScene does - * not match any document window, returns null. - * - * Note: the returned is an [Object] because an FXML file is not limited - * to javafx.scene.Node. - * - * @param documentScene a scene holding a document window - * - * @return the user scene graph root or null if documentScene does - * not hold a document window - */ - public static Object getUserSceneGraphRoot(Scene documentScene) { - assert documentScene != null; - - final Object result; - final FXOMDocument fxomDocument = lookupFxomDocument(documentScene); - if (fxomDocument == null) { - result = null; - } else { - result = fxomDocument.getSceneGraphRoot(); - } - - return result; - } - - - /** - * Returns the set of selected objects. Each selected object is represented - * by an FXOMObject instance. - * - * @param documentScene a scene holding a document window - * @return the set of selected objects or null if documentScene does - * not hold a document window - */ - public static Set findSelectedObjects(Scene documentScene) { - assert documentScene != null; - - final Set result; - final DocumentWindowController dwc = lookupWindowController(documentScene); - if (dwc == null) { - result = null; - } else { - final Selection selection = dwc.getEditorController().getSelection(); - if (selection.getGroup() instanceof ObjectSelectionGroup) { - final ObjectSelectionGroup osg = (ObjectSelectionGroup) selection.getGroup(); - result = Collections.unmodifiableSet(osg.getItems()); - } else { - // TODO(elp) : will implement later - result = Collections.emptySet(); - } - } - - return result; - } - - /** - * Returns the fxom object matching a given node in the content panel. - * Returns null if nothing is found. - * - * @param node a node part of the content panel (never null) - * @return null or the matching fxom object - */ - public static FXOMObject fxomObjectFromContentPanelNode(Node node) { - assert node != null; - assert node.getScene() != null; - - final FXOMObject result; - final DocumentWindowController dwc = lookupWindowController(node.getScene()); - if (dwc == null) { - result = null; - } else { - final Bounds b = node.getLayoutBounds(); - final double midX = (b.getMinX() + b.getMaxX()) / 2.0; - final double midY = (b.getMinY() + b.getMaxY()) / 2.0; - final Point2D nodeCenter = node.localToScene(midX, midY, true /* rootScene */); - - final ContentPanelController cpc = dwc.getContentPanelController(); - result = cpc.searchWithNode(node, nodeCenter.getX(), nodeCenter.getY()); - } - - return result; - } - - /** - * Returns the node in content panel matching a given fxom object. - * This method invokes FXOMObject.getSceneGraphObject() and checks if - * it is a Node. If it's not, it returns null. - * - * @param documentScene a scene holding a document window - * @param fxomObject an fxom object (never null) - * @return null or the matching node in content panel - */ - public static Node fxomObjectToContentPanelNode( - Scene documentScene, FXOMObject fxomObject) { - assert documentScene != null; - assert fxomObject != null; - - final Node result; - if (fxomObject.getSceneGraphObject() instanceof Node) { - result = (Node) fxomObject.getSceneGraphObject(); - } else { - result = null; - } - return result; - } - - /** - * Returns the fxom object matching a given node in the hierarchy panel. - * Returns null if nothing is found. - * This method lookups for a Cell object ancestor of the specified node parameter - * and returns the associated FXOMObject. - * If there is no Cell object ancestor, it returns null. - * - * @param node a node part of the hierarchy panel (never null) - * @return null or the matching fxom object - */ - public static FXOMObject fxomObjectFromHierarchyPanelNode(Node node) { - assert node != null; - assert node.getScene() != null; - - final FXOMObject result; - final DocumentWindowController dwc = lookupWindowController(node.getScene()); - if (dwc == null) { - result = null; - } else { - Parent parent = node.getParent(); - Cell cell = null; - while (parent != null) { - if (parent instanceof Cell) { - cell = (Cell) parent; - break; - } - } - // A cell has been found - if (cell != null) { - assert cell.isEmpty() == false; - if (cell.isVisible()) { - final Object item = cell.getItem(); - assert item instanceof HierarchyItem; - final HierarchyItem hierarchyItem = (HierarchyItem) item; - result = hierarchyItem.getFxomObject(); - } else { - result = null; - } - } else { - result = null; - } - } - - return result; - } - - /** - * Returns the node in hierarchy panel matching a given fxom object. - * Returns null if the FXOMObject is currently not displayed by hierarchy - * panel. - * The returned Node is a Cell object. - * - * @param documentScene a scene holding a document window - * @param fxomObject an fxom object (never null) - * @return null or the matching node in hierarchy panel - */ - public static Node fxomObjectToHierarchyPanelNode( - Scene documentScene, FXOMObject fxomObject) { - assert documentScene != null; - assert fxomObject != null; - - final Node result; - final DocumentWindowController dwc = lookupWindowController(documentScene); - if (dwc == null) { - result = null; - } else { - final EditorController ec = dwc.getEditorController(); - assert fxomObject.getFxomDocument() == ec.getFxomDocument(); - - final AbstractHierarchyPanelController hpc = dwc.getHierarchyPanelController(); - assert hpc != null; - assert hpc.getPanelControl() != null; - if (hpc.getPanelControl().isVisible()) { - final TreeItem treeItem = hpc.lookupTreeItem(fxomObject); - if (treeItem != null) { - result = hpc.getCell(treeItem); - } else { - result = null; - } - } else { - result = null; - } - } - - return result; - } - - /** - * Looks for the TreeItem corresponding to the specified FXOM object. - * If a TreeItem has been found, scroll to this TreeItem within the hierarchy panel. - * - * @param documentScene - * @param fxomObject - */ - public static void revealInHierarchyPanel( - Scene documentScene, FXOMObject fxomObject) { - assert documentScene != null; - assert fxomObject != null; - final DocumentWindowController dwc = lookupWindowController(documentScene); - if (dwc != null) { - final EditorController ec = dwc.getEditorController(); - assert fxomObject.getFxomDocument() == ec.getFxomDocument(); - - final AbstractHierarchyPanelController hpc - = dwc.getHierarchyPanelController(); - assert hpc != null; - assert hpc.getPanelControl() != null; - // First expand the hierarchy tree - expandAllTreeItems(hpc.getRoot()); - // Then look for the fxom object - if (hpc.getPanelControl().isVisible()) { - final TreeItem treeItem - = hpc.lookupTreeItem(fxomObject); - if (treeItem != null) { - hpc.scrollTo(treeItem); - } - } - } - } - - /** - * Returns the node representing a resize handle. - * - * @param documentScene a scene holding a document window - * @param fxomObject one of the selected fxom object - * @param cp the cardinal point of the target handle - * @return null or the node representing the handle - */ - public static Node lookupResizeHandle( - Scene documentScene, FXOMObject fxomObject, CardinalPoint cp) { - assert documentScene != null; - assert fxomObject != null; - - final Node result; - final DocumentWindowController dwc = lookupWindowController(documentScene); - if (dwc == null) { - result = null; - } else { - final EditorController ec = dwc.getEditorController(); - - assert fxomObject.getFxomDocument() == ec.getFxomDocument(); - assert ec.getSelection().isSelected(fxomObject); - - final ContentPanelController cpc = dwc.getContentPanelController(); - final AbstractHandles h = cpc.lookupHandles(fxomObject); - if (h instanceof AbstractGenericHandles) { - final AbstractGenericHandles gh = (AbstractGenericHandles) h; - result = gh.getHandleNode(cp); - } else { - result = null; - } - } - - return result; - } - - /** - * Returns the version string. - * It has the format 'Version: [major].[minor]-b[ii], Changeset: [someValue]'. - *
A typical value is 'Version: 2.0-b07, Changeset: 8a5ccd834b5f'. - * - * @return a version string. It is never null: in the case something weird - * would occur when constructing the proper value then what is returned is - * 'UNSET'. - */ - public static String getVersionString() { - AboutWindowController awc = new AboutWindowController(); - return awc.getBuildInfo(); - } - - - /** - * Closes the preview window associated to a document window. - * Performs nothing if documentScene is not a scene associated to a - * document window or if preview window is not opened. - * - * @param documentScene a scene holding a document window - */ - public static void closePreviewWindow(Scene documentScene) { - final DocumentWindowController dwc = lookupWindowController(documentScene); - if (dwc != null) { - dwc.getPreviewWindowController().closeWindow(); - } - } - - /** - * Starts the application in test mode. - * In this mode, no files are opened at application startup. - * - * @param args arguments to SceneBuilderApp.main() - */ - public static void startApplication(String[] args) { - SceneBuilderApp.main(args); - } - - /* - * Private - */ - - private static FXOMDocument lookupFxomDocument(Scene documentScene) { - final FXOMDocument result; - - final DocumentWindowController dwc = lookupWindowController(documentScene); - if (dwc == null) { - result = null; - } else { - result = dwc.getEditorController().getFxomDocument(); - } - - return result; - } - - private static DocumentWindowController lookupWindowController(Scene documentScene) { - DocumentWindowController result = null; - - final SceneBuilderApp app = SceneBuilderApp.getSingleton(); - for (DocumentWindowController c : app.getDocumentWindowControllers()) { - if (c.getScene() == documentScene) { - result = c; - break; - } - } - - return result; - } - - private static void expandAllTreeItems(final TreeItem parentTreeItem) { - if (parentTreeItem != null) { - parentTreeItem.setExpanded(true); - final List> children = parentTreeItem.getChildren(); - if (children != null) { - for (TreeItem child : children) { - expandAllTreeItems(child); - } - } - } - } -} diff --git a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/SceneStyleSheetMenuController.java b/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/SceneStyleSheetMenuController.java deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/SceneStyleSheetMenuController.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. - * All rights reserved. Use is subject to license terms. - * - * This file is available and licensed under the following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the distribution. - * - Neither the name of Oracle Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.oracle.javafx.scenebuilder.app; - -import com.oracle.javafx.scenebuilder.app.i18n.I18N; -import com.oracle.javafx.scenebuilder.kit.editor.EditorController; -import com.oracle.javafx.scenebuilder.kit.editor.EditorPlatform; -import com.oracle.javafx.scenebuilder.kit.editor.panel.util.dialog.ErrorDialog; - -import java.io.File; -import java.io.IOException; -import java.util.List; - -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import javafx.stage.FileChooser; - -/** - * - */ -public class SceneStyleSheetMenuController { - private final DocumentWindowController documentWindowController; - - public SceneStyleSheetMenuController(DocumentWindowController dwc) { - this.documentWindowController = dwc; - } - - void performAddSceneStyleSheet() { - boolean knownFilesModified = false; - ObservableList knownFiles = documentWindowController.getEditorController().getSceneStyleSheets(); - - if (knownFiles == null) { - knownFiles = FXCollections.observableArrayList(); - } - - // Open a file chooser for *.css & *.bss - FileChooser fileChooser = new FileChooser(); - fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(I18N.getString("scenestylesheet.filechooser.filter.msg"), - "*.css", "*.bss")); //NOI18N - fileChooser.setInitialDirectory(EditorController.getNextInitialDirectory()); - List selectedFiles = fileChooser.showOpenMultipleDialog(documentWindowController.getStage()); - - if (selectedFiles != null) { - assert selectedFiles.isEmpty() == false; - // Keep track of the user choice for next time - EditorController.updateNextInitialDirectory(selectedFiles.get(0)); - for (File f : selectedFiles) { - if (!knownFiles.contains(f)) { - knownFiles.add(f); - knownFilesModified = true; - } - } - } - - // Update sceneStyleSheet property so that listeners will react accordingly - if (knownFilesModified) { - documentWindowController.getEditorController().setSceneStyleSheets(knownFiles); - } - } - - public void performRemoveSceneStyleSheet(File toRemove) { - ObservableList knownFiles = documentWindowController.getEditorController().getSceneStyleSheets(); - assert knownFiles != null; - - if (knownFiles.contains(toRemove)) { - knownFiles.remove(toRemove); - documentWindowController.getEditorController().setSceneStyleSheets(knownFiles); - } - } - - public void performOpenSceneStyleSheet(File toOpen) { - try { - EditorPlatform.open(toOpen.getPath()); - } catch (IOException ioe) { - final ErrorDialog errorDialog = new ErrorDialog(null); - errorDialog.setTitle(I18N.getString("error.file.open.title")); - errorDialog.setMessage(I18N.getString("error.file.open.message")); - errorDialog.setDetails(I18N.getString("error.filesystem.details")); - errorDialog.setDebugInfoWithThrowable(ioe); - errorDialog.showAndWait(); - } - } - -} diff --git a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/ScenicViewStarter.java b/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/ScenicViewStarter.java deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/ScenicViewStarter.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. - * All rights reserved. Use is subject to license terms. - * - * This file is available and licensed under the following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the distribution. - * - Neither the name of Oracle Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.oracle.javafx.scenebuilder.app; - -import javafx.scene.Scene; - -/** - * @treatAsPrivate - */ -public class ScenicViewStarter implements Runnable { -// private final Scene targetScene; - - public ScenicViewStarter(Scene targetScene) { -// this.targetScene = targetScene; - } - - @Override - public void run() { -// org.scenicview.ScenicView.show(targetScene); - } -} diff --git a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/SplitController.java b/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/SplitController.java deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/SplitController.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. - * All rights reserved. Use is subject to license terms. - * - * This file is available and licensed under the following license: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the distribution. - * - Neither the name of Oracle Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.oracle.javafx.scenebuilder.app; - -import java.util.ArrayList; -import java.util.List; -import javafx.beans.property.DoubleProperty; -import javafx.scene.Node; -import javafx.scene.control.SplitPane; -import javafx.scene.control.SplitPane.Divider; - -/** - * - */ -public class SplitController { - - public enum Target { - - FIRST, LAST - }; - - private final SplitPane splitPane; - private final Target target; - private final Node targetNode; - private double dividerPosition = -1.0; - - public SplitController(SplitPane splitPane, Target target) { - assert splitPane != null; - assert splitPane.getItems().size() >= 1; - - this.splitPane = splitPane; - this.target = target; - - final List children = splitPane.getItems(); - final int targetIndex = (target == Target.FIRST) ? 0 : children.size() - 1; - this.targetNode = children.get(targetIndex); - } - - public DoubleProperty position() { - final Divider divider = getTargetDivider(); - return divider == null ? null : divider.positionProperty(); - } - - public double getPosition() { - final Divider divider = getTargetDivider(); - return divider == null ? -1.0 : divider.getPosition(); - } - - public void setPosition(double value) { - final Divider divider = getTargetDivider(); - if (divider != null) { - divider.setPosition(value); - } - dividerPosition = value; - } - - public void showTarget() { - if (isTargetVisible() == false) { - // Put the target node back in the split pane items - if (target == Target.FIRST) { - splitPane.getItems().add(0, targetNode); - } else { - splitPane.getItems().add(targetNode); - } - - // Restore the target divider position (if any) - final List dividers = splitPane.getDividers(); - if ((dividers.isEmpty() == false) && (dividerPosition != -1)) { // (1) - final Divider divider = getTargetDivider(); - assert divider != null; // Because of (1) - divider.setPosition(dividerPosition); - } - } - } - - public void hideTarget() { - - if (isTargetVisible()) { - - final List dividers = splitPane.getDividers(); - final List positionsList = asList(splitPane.getDividerPositions()); - - // Backup the target divider positions (if any) - // so we can restore it on showing - final Divider targetDivider = getTargetDivider(); - if (targetDivider != null) { - dividerPosition = targetDivider.getPosition(); - int targetDividerIndex = target == Target.FIRST ? 0 : dividers.size() - 1; - positionsList.remove(targetDividerIndex); - } - - // Removes the target node from the split pane items - splitPane.getItems().remove(targetNode); - - // Set back remaining dividers positions if any - if (positionsList.isEmpty() == false) { - double[] positionsArray = toArray(positionsList); - splitPane.setDividerPositions(positionsArray); - } - } - } - - public void toggleTarget() { - if (isTargetVisible()) { - hideTarget(); - } else { - showTarget(); - } - } - - public void setTargetVisible(boolean visible) { - if (visible) { - showTarget(); - } else { - hideTarget(); - } - } - - public boolean isTargetVisible() { - return splitPane.getItems().contains(targetNode); - } - - private Divider getTargetDivider() { - final Divider divider; - final List dividers = splitPane.getDividers(); - if (dividers.isEmpty() == false) { - if (target == Target.FIRST) { - divider = dividers.get(0); - } else { - divider = dividers.get(dividers.size() - 1); - } - } else { - divider = null; - } - return divider; - } - - // Arrays.asList does not work with primitive types - private static List asList(double[] array) { - final List list = new ArrayList<>(array.length); - for (double d : array) { - list.add(d); - } - return list; - } - - // List.toArray does not work with primitive types - private static double[] toArray(List list) { - final double[] array = new double[list.size()]; - for (int i = 0; i < list.size(); i++) { - array[i] = list.get(i); - } - return array; - } -} diff --git a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/about/About.fxml b/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/about/About.fxml deleted file mode 100644 --- a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/about/About.fxml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -