changeset 7971:f34fb0e93340

[SCENEBUILDER] Fix for DTL-6771 : Add support for DialogPane component to the Hierarchy Panel.
author slions
date Thu, 04 Sep 2014 10:15:30 +0200
parents 618aab68827f
children 9900c7afd0c6
files apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/images/nodeicons/DialogPane-content.png apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/images/nodeicons/DialogPane-expandable_content.png apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/images/nodeicons/DialogPane-graphic.png apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/images/nodeicons/DialogPane-header.png apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapJobUtils.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/hierarchy/AbstractHierarchyPanelController.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/hierarchy/HierarchyDNDController.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/hierarchy/HierarchyItemDialogPane.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/metadata/klass/ComponentClassMetadata.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/metadata/util/DesignHierarchyMask.java
diffstat 10 files changed, 257 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
Binary file apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/images/nodeicons/DialogPane-content.png has changed
Binary file apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/images/nodeicons/DialogPane-expandable_content.png has changed
Binary file apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/images/nodeicons/DialogPane-graphic.png has changed
Binary file apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/images/nodeicons/DialogPane-header.png has changed
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapJobUtils.java	Thu Sep 04 10:11:48 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/job/wrap/WrapJobUtils.java	Thu Sep 04 10:15:30 2014 +0200
@@ -49,6 +49,7 @@
 import javafx.scene.Node;
 import javafx.scene.chart.Axis;
 import javafx.scene.control.Accordion;
+import javafx.scene.control.DialogPane;
 import javafx.scene.control.TabPane;
 import javafx.scene.layout.BorderPane;
 import javafx.scene.text.TextFlow;
@@ -127,9 +128,10 @@
         if (TabPane.class.isAssignableFrom(containerInstance.getDeclaredClass())) {
             return false;
         }
-        // Cannot unwrap all Pane subclasses (ex : BorderPane and TextFlow)
+        // Cannot unwrap all Pane subclasses (ex : BorderPane, TextFlow and DialogPane)
         if (BorderPane.class.isAssignableFrom(containerInstance.getDeclaredClass())
-                || TextFlow.class.isAssignableFrom(containerInstance.getDeclaredClass())) {
+                || TextFlow.class.isAssignableFrom(containerInstance.getDeclaredClass())
+                || DialogPane.class.isAssignableFrom(containerInstance.getDeclaredClass())) {
             return false;
         }
         // Can unwrap classes supporting wrapping except TabPane + some Pane subclasses (see above)
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/hierarchy/AbstractHierarchyPanelController.java	Thu Sep 04 10:11:48 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/hierarchy/AbstractHierarchyPanelController.java	Thu Sep 04 10:15:30 2014 +0200
@@ -667,6 +667,25 @@
         return treeItem;
     }
 
+    private TreeItem<HierarchyItem> makeTreeItemDialogPane(
+            final DesignHierarchyMask owner,
+            final FXOMObject fxomObject,
+            final Accessory accessory) {
+        final HierarchyItemDialogPane item
+                = new HierarchyItemDialogPane(owner, fxomObject, accessory);
+        final TreeItem<HierarchyItem> treeItem = new TreeItem<>(item);
+        // Set back the TreeItem expanded property if any
+        Boolean expanded = treeItemsExpandedMapProperty.get(fxomObject);
+        if (expanded != null) {
+            treeItem.setExpanded(expanded);
+        }
+        // Mask may be null for empty place holder
+        if (item.getMask() != null) {
+            updateTreeItem(treeItem);
+        }
+        return treeItem;
+    }
+
     /**
      * @param owner the mask owner
      * @param fxomObject the FXOMObject
@@ -840,6 +859,19 @@
             }
         }
 
+        // DialogPane
+        //---------------------------------
+        for (Accessory accessory : new Accessory[]{
+            Accessory.HEADER,
+            Accessory.DP_GRAPHIC,
+            Accessory.DP_CONTENT,
+            Accessory.EXPANDABLE_CONTENT}) {
+            if (mask.isAcceptingAccessory(accessory)) {
+                final FXOMObject value = mask.getAccessory(accessory);
+                treeItem.getChildren().add(makeTreeItemDialogPane(mask, value, accessory));
+            }
+        }
+
         // Sub components
         //---------------------------------
         if (mask.isAcceptingSubComponent()) {
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/hierarchy/HierarchyDNDController.java	Thu Sep 04 10:11:48 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/hierarchy/HierarchyDNDController.java	Thu Sep 04 10:15:30 2014 +0200
@@ -270,7 +270,8 @@
 
                 assert treeItem != rootTreeItem;
                 assert item instanceof HierarchyItemBorderPane
-                        || item instanceof HierarchyItemGraphic;
+                        || item instanceof HierarchyItemGraphic
+                        || item instanceof HierarchyItemDialogPane;
 
                 if (item.isEmpty()) {
                     // Set the drop target
@@ -280,6 +281,8 @@
                     // Set the accessory
                     if (item instanceof HierarchyItemBorderPane) {
                         accessory = ((HierarchyItemBorderPane) item).getPosition();
+                    } else if (item instanceof HierarchyItemDialogPane) {
+                        accessory = ((HierarchyItemDialogPane) item).getAccessory();
                     } else {
                         accessory = Accessory.GRAPHIC;
                     }
@@ -435,7 +438,12 @@
                         Accessory.CONTENT,
                         Accessory.CONTEXT_MENU,
                         Accessory.GRAPHIC,
-                        Accessory.TOOLTIP};
+                        Accessory.TOOLTIP,
+                        Accessory.HEADER,
+                        Accessory.DP_GRAPHIC,
+                        Accessory.DP_CONTENT,
+                        Accessory.EXPANDABLE_CONTENT
+                    };
                     for (Accessory a : accessories) {
                         final AccessoryDropTarget dropTarget
                                 = new AccessoryDropTarget(dropTargetInstance, a);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/hierarchy/HierarchyItemDialogPane.java	Thu Sep 04 10:15:30 2014 +0200
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 014, 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.kit.editor.panel.hierarchy;
+
+import com.oracle.javafx.scenebuilder.kit.editor.i18n.I18N;
+import com.oracle.javafx.scenebuilder.kit.editor.images.ImageUtils;
+import com.oracle.javafx.scenebuilder.kit.fxom.FXOMObject;
+import com.oracle.javafx.scenebuilder.kit.metadata.util.DesignHierarchyMask;
+import com.oracle.javafx.scenebuilder.kit.metadata.util.DesignHierarchyMask.Accessory;
+import java.net.URL;
+import java.util.Locale;
+import java.util.Objects;
+import javafx.scene.image.Image;
+
+/**
+ * Object representing the data contained within the hierarchy TreeItems for the
+ * DialogPane content/expandableContent/graphic/header properties.
+ *
+ * @treatAsPrivate
+ */
+public class HierarchyItemDialogPane extends HierarchyItem {
+
+    private final Accessory accessory;
+    // The accessory owner. Used for the equals method.
+    private final DesignHierarchyMask owner;
+
+    /**
+     * Creates a hierarchy item.
+     *
+     * @param owner The accessory owner
+     * @param fxomObject The FX object represented by this item
+     * @param accessory The accessory of the FX object within the DialogPane
+     */
+    public HierarchyItemDialogPane(
+            final DesignHierarchyMask owner,
+            final FXOMObject fxomObject,
+            final Accessory accessory) {
+        assert owner != null;
+        this.owner = owner;
+        // fxomObject can be null for place holder items
+        this.mask = fxomObject == null ? null : new DesignHierarchyMask(fxomObject);
+        this.accessory = accessory;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final HierarchyItemDialogPane item = (HierarchyItemDialogPane) obj;
+        if (!isEmpty()) {
+            // If the place holder is not empty, we compare the fxom object
+            assert getFxomObject() != null;
+            return getFxomObject().equals(item.getFxomObject());
+        } else {
+            // If the place holder is empty, we compare the position + owner
+            return getOwner().equals(item.getOwner())
+                    && getAccessory().equals(item.getAccessory());
+        }
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 7;
+        hash = 37 * hash + Objects.hashCode(this.mask);
+        hash = 37 * hash + Objects.hashCode(this.owner);
+        hash = 37 * hash + Objects.hashCode(this.accessory);
+        return hash;
+    }
+
+    @Override
+    public boolean isPlaceHolder() {
+        return true;
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return mask == null;
+    }
+
+    /**
+     * Returns the DesignHierarchyMask owner of this accessory. Cannot be null.
+     *
+     * @return the DesignHierarchyMask owner
+     */
+    public DesignHierarchyMask getOwner() {
+        return owner;
+    }
+
+    /**
+     * Returns the DialogPane accessory represented by this item.
+     *
+     * @return the DialogPane accessory represented by this item.
+     */
+    public Accessory getAccessory() {
+        return this.accessory;
+    }
+
+    @Override
+    public Image getPlaceHolderImage() {
+        return ImageUtils.getNodeIcon("DialogPane-" + accessory.toString().toLowerCase(Locale.ROOT) + ".png"); //NOI18N
+    }
+
+    @Override
+    public String getPlaceHolderInfo() {
+        return (mask != null ? null : I18N.getString("hierarchy.placeholder.insert") + accessory.toString().toUpperCase(Locale.getDefault()));
+    }
+
+    @Override
+    public Image getClassNameIcon() {
+        return (mask == null ? null : mask.getClassNameIcon());
+    }
+
+    @Override
+    public URL getClassNameIconURL() {
+        return (mask == null ? null : mask.getClassNameIconURL());
+    }
+
+    @Override
+    public String getClassNameInfo() {
+        return (mask == null ? null : mask.getClassNameInfo());
+    }
+}
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/metadata/klass/ComponentClassMetadata.java	Thu Sep 04 10:11:48 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/metadata/klass/ComponentClassMetadata.java	Thu Sep 04 10:15:30 2014 +0200
@@ -65,6 +65,10 @@
             // We consider that BorderPane has no subcomponents.
             // left, right, bottom and top components are treated as "accessories".
             result = null;
+        } else if (componentClass == javafx.scene.control.DialogPane.class) {
+            // We consider that DialogPane has no subcomponents.
+            // content, expanded content, header and graphic components are treated as "accessories".
+            result = null;
         } else {
             while ((result == null) && (componentClass != null)) {
                 result = getSubComponentProperty(componentClass);
@@ -121,7 +125,8 @@
     private static PropertyName getSubComponentProperty(Class<?> componentClass) {
         final PropertyName result;
         
-        assert componentClass != javafx.scene.layout.BorderPane.class;
+        assert componentClass != javafx.scene.layout.BorderPane.class
+                && componentClass != javafx.scene.control.DialogPane.class;
         
         /*
          * Component Class -> Sub Component Property
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/metadata/util/DesignHierarchyMask.java	Thu Sep 04 10:11:48 2014 +0200
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/metadata/util/DesignHierarchyMask.java	Thu Sep 04 10:15:30 2014 +0200
@@ -54,6 +54,7 @@
 import javafx.scene.Group;
 import javafx.scene.Node;
 import javafx.scene.control.ComboBox;
+import javafx.scene.control.DialogPane;
 import javafx.scene.control.Labeled;
 import javafx.scene.control.Menu;
 import javafx.scene.control.MenuBar;
@@ -99,10 +100,26 @@
         CENTER,
         XAXIS,
         YAXIS,
-        TREE_COLUMN
+        TREE_COLUMN,
+        EXPANDABLE_CONTENT,
+        HEADER,
+        DP_CONTENT {
+                    @Override
+                    public String toString() {
+                        return "CONTENT"; // NOI18N
+                    }
+                },
+        DP_GRAPHIC {
+                    @Override
+                    public String toString() {
+                        return "GRAPHIC"; // NOI18N
+                    }
+                }
     }
     private static final PropertyName graphicName = new PropertyName("graphic");
     private static final PropertyName contentName = new PropertyName("content");
+    private static final PropertyName expandableContentName = new PropertyName("expandableContent");
+    private static final PropertyName headerName = new PropertyName("header");
     private static final PropertyName topName = new PropertyName("top");
     private static final PropertyName bottomName = new PropertyName("bottom");
     private static final PropertyName leftName = new PropertyName("left");
@@ -379,6 +396,24 @@
     public boolean isAcceptingAccessory(Accessory accessory) {
         final PropertyName propertyName = getPropertyNameForAccessory(accessory);
         final Class<?> valueClass = getClassForAccessory(accessory);
+
+        final Object sceneGraphObject = fxomObject.getSceneGraphObject();
+        switch (accessory) {
+            case CONTENT:
+            case GRAPHIC:
+                if (sceneGraphObject instanceof DialogPane == true) {
+                    return false;
+                }
+                break;
+            case DP_CONTENT:
+            case DP_GRAPHIC:
+                if (sceneGraphObject instanceof DialogPane == false) {
+                    return false;
+                }
+                break;
+            default:
+                break;
+        }
         return isAcceptingProperty(propertyName, valueClass);
     }
 
@@ -429,6 +464,12 @@
             case TREE_COLUMN:
                 result = javafx.scene.control.TreeTableColumn.class;
                 break;
+            case DP_CONTENT:
+            case EXPANDABLE_CONTENT:
+            case DP_GRAPHIC:
+            case HEADER:
+                result = javafx.scene.Node.class;
+                break;
             default: // Bug
                 throw new IllegalStateException("Unexpected accessory " + accessory);
         }
@@ -607,11 +648,19 @@
 
         switch (accessory) {
             case GRAPHIC:
+            case DP_GRAPHIC:
                 result = graphicName;
                 break;
             case CONTENT:
+            case DP_CONTENT:
                 result = contentName;
                 break;
+            case EXPANDABLE_CONTENT:
+                result = expandableContentName;
+                break;
+            case HEADER:
+                result = headerName;
+                break;
             case TOP:
                 result = topName;
                 break;