changeset 7638:9f11f4d07448

[SCENEBUILDER] Fix for DTL-6807 Preview/JavaFX Theme throws NPE when no document window is opened
author yjoan
date Fri, 08 Aug 2014 10:22:24 +0200
parents 17cc94866e88
children ad91cef63a6f
files apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/menubar/MenuBarController.java
diffstat 1 files changed, 24 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/menubar/MenuBarController.java	Fri Aug 08 10:00:35 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/menubar/MenuBarController.java	Fri Aug 08 10:22:24 2014 +0200
@@ -1775,28 +1775,30 @@
         @Override
         public boolean canPerform() {
             boolean res = documentWindowController != null;
-            final EditorPlatform.Theme currentTheme
-                    = documentWindowController.getEditorController().getTheme();
-            // CASPIAN_HIGH_CONTRAST can be selected only if another CASPIAN
-            // theme is active.
-            // MODENA_HIGH_CONTRAST_<*> can be selected only if another MODENA
-            // theme is active.
-            if (theme == EditorPlatform.Theme.CASPIAN_HIGH_CONTRAST
-                    && EditorPlatform.isModena(currentTheme)) {
-                res = false;
-                caspianHighContrastThemeMenuItem.setSelected(false);
-            } else if (theme == EditorPlatform.Theme.MODENA_HIGH_CONTRAST_BLACK_ON_WHITE
-                    && EditorPlatform.isCaspian(currentTheme)) {
-                res = false;
-                modenaHighContrastBlackonwhiteThemeMenuItem.setSelected(false);
-            } else if (theme == EditorPlatform.Theme.MODENA_HIGH_CONTRAST_WHITE_ON_BLACK
-                    && EditorPlatform.isCaspian(currentTheme)) {
-                res = false;
-                modenaHighContrastWhiteonblackThemeMenuItem.setSelected(false);
-            } else if (theme == EditorPlatform.Theme.MODENA_HIGH_CONTRAST_YELLOW_ON_BLACK
-                    && EditorPlatform.isCaspian(currentTheme)) {
-                res = false;
-                modenaHighContrastYellowonblackThemeMenuItem.setSelected(false);
+            if (res) {
+                final EditorPlatform.Theme currentTheme
+                        = documentWindowController.getEditorController().getTheme();
+                // CASPIAN_HIGH_CONTRAST can be selected only if another CASPIAN
+                // theme is active.
+                // MODENA_HIGH_CONTRAST_<*> can be selected only if another MODENA
+                // theme is active.
+                if (theme == EditorPlatform.Theme.CASPIAN_HIGH_CONTRAST
+                        && EditorPlatform.isModena(currentTheme)) {
+                    res = false;
+                    caspianHighContrastThemeMenuItem.setSelected(false);
+                } else if (theme == EditorPlatform.Theme.MODENA_HIGH_CONTRAST_BLACK_ON_WHITE
+                        && EditorPlatform.isCaspian(currentTheme)) {
+                    res = false;
+                    modenaHighContrastBlackonwhiteThemeMenuItem.setSelected(false);
+                } else if (theme == EditorPlatform.Theme.MODENA_HIGH_CONTRAST_WHITE_ON_BLACK
+                        && EditorPlatform.isCaspian(currentTheme)) {
+                    res = false;
+                    modenaHighContrastWhiteonblackThemeMenuItem.setSelected(false);
+                } else if (theme == EditorPlatform.Theme.MODENA_HIGH_CONTRAST_YELLOW_ON_BLACK
+                        && EditorPlatform.isCaspian(currentTheme)) {
+                    res = false;
+                    modenaHighContrastYellowonblackThemeMenuItem.setSelected(false);
+                }
             }
             
             return res;