changeset 7897:12525821c845

[SCENEBUILDER] Fix for DTL-6550: Authorizing multiline on TextField is confusing
author Jerome Cambon
date Thu, 28 Aug 2014 11:00:23 +0200
parents 71c7b518c853
children 33220c4b1e46
files apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/IncludeFileJob.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/inspector/InspectorPanelController.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/inspector/editors/I18nStringEditor.java
diffstat 3 files changed, 30 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/IncludeFileJob.java	Thu Aug 28 11:22:16 2014 +0400
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/IncludeFileJob.java	Thu Aug 28 11:00:23 2014 +0200
@@ -33,7 +33,6 @@
 
 import com.oracle.javafx.scenebuilder.kit.editor.EditorController;
 import com.oracle.javafx.scenebuilder.kit.editor.i18n.I18N;
-import com.oracle.javafx.scenebuilder.kit.editor.job.v2.UpdateSelectionJob;
 import com.oracle.javafx.scenebuilder.kit.editor.selection.AbstractSelectionGroup;
 import com.oracle.javafx.scenebuilder.kit.editor.selection.ObjectSelectionGroup;
 import com.oracle.javafx.scenebuilder.kit.editor.selection.Selection;
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/inspector/InspectorPanelController.java	Thu Aug 28 11:22:16 2014 +0400
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/inspector/InspectorPanelController.java	Thu Aug 28 11:00:23 2014 +0200
@@ -1539,6 +1539,23 @@
         }
         return 0;
     }
+    
+    private boolean isMultiLinesSupported(Set<Class<?>> selectedClasses, ValuePropertyMetadata propMeta) {
+        String propertyNameStr = propMeta.getName().getName();
+        if (selectedClasses.contains(TextField.class) || selectedClasses.contains(PasswordField.class)) {
+            if (propertyNameStr.equalsIgnoreCase("text")) {
+                return false;
+            }
+        }
+        if (propertyNameStr.equalsIgnoreCase("promptText")) {
+            return false;
+        }
+
+        if (propertyNameStr.equalsIgnoreCase("ellipsisString")) {
+            return false;
+        }
+        return true;
+    }
 
     private int getSpanPropertyMaxIndex(String propNameStr) {
         assert propNameStr.contains("columnSpan") || propNameStr.contains("rowSpan");
@@ -1704,9 +1721,9 @@
         Set<Class<?>> selectedClasses = getSelectedClasses();
         if (editorClass == I18nStringEditor.class) {
             if (propertyEditor != null) {
-                ((I18nStringEditor) propertyEditor).reset(propMeta, selectedClasses);
+                ((I18nStringEditor) propertyEditor).reset(propMeta, selectedClasses, isMultiLinesSupported(selectedClasses, propMeta));
             } else {
-                propertyEditor = new I18nStringEditor(propMeta, selectedClasses);
+                propertyEditor = new I18nStringEditor(propMeta, selectedClasses, isMultiLinesSupported(selectedClasses, propMeta));
             }
         } else if (editorClass == StringEditor.class) {
             if (propertyEditor != null) {
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/inspector/editors/I18nStringEditor.java	Thu Aug 28 11:22:16 2014 +0400
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/inspector/editors/I18nStringEditor.java	Thu Aug 28 11:00:23 2014 +0200
@@ -64,16 +64,18 @@
     private final MenuItem multilineMenuItem = new MenuItem();
     private final String MULTI_LINE = I18N.getString("inspector.i18n.multiline");
     private final String SINGLE_LINE = I18N.getString("inspector.i18n.singleline");
+    private boolean multiLineSupported = false;
     // Specific states
     private boolean i18nMode = false;
     private boolean multiLineMode = false;
 
-    public I18nStringEditor(ValuePropertyMetadata propMeta, Set<Class<?>> selectedClasses) {
+    public I18nStringEditor(ValuePropertyMetadata propMeta, Set<Class<?>> selectedClasses, boolean multiLineSupported) {
         super(propMeta, selectedClasses);
-        initialize();
+        initialize(multiLineSupported);
     }
     
-    private void initialize() {
+    private void initialize(boolean multiLineSupported) {
+        this.multiLineSupported = multiLineSupported;
         valueListener = event -> {
             userUpdateValueProperty(getValue());
             textNode.selectAll();
@@ -171,9 +173,9 @@
         updateMenuItems();
     }
 
-    @Override
-    public void reset(ValuePropertyMetadata propMeta, Set<Class<?>> selectedClasses) {
+    public void reset(ValuePropertyMetadata propMeta, Set<Class<?>> selectedClasses, boolean multiLineSupported) {
         super.reset(propMeta, selectedClasses);
+        this.multiLineSupported = multiLineSupported;
         textNode.setPromptText(null);
     }
 
@@ -271,5 +273,9 @@
             multilineMenuItem.setText(MULTI_LINE);
             i18nMenuItem.setDisable(false);
         }
+        
+        if (!multiLineSupported) {
+            multilineMenuItem.setDisable(true);
+        }
     }
 }