Peter Centgraf pushed to branch master at cms-community / hippo-cms

Commits:
4710a897 by Peter Centgraf at 2017-12-29T17:40:10+01:00
CMS-11027 Refactor to match API cleanup in HCM-242

- - - - -
0b05416e by Peter Centgraf at 2018-01-29T17:32:12+01:00
CMS-11027 Refactor to match API cleanup in HCM-242

- - - - -
d612e640 by Peter Centgraf at 2018-02-08T11:53:07+01:00
CMS-11027 Update copyright year

- - - - -
f1a9baa4 by Peter Centgraf at 2018-02-08T13:01:48+01:00
CMS-11027 Relax static types for HCM to avoid annoying wildcards in API

- - - - -
f4c2c08b by Peter Centgraf at 2018-02-08T17:58:47+01:00
CMS-11027 merge master

- - - - -
4ea5bf35 by Peter Centgraf at 2018-02-08T18:08:14+01:00
CMS-11027 reintegrate feature/CMS-11027

- - - - -


1 changed file:

- 
console/frontend/src/main/java/org/hippoecm/frontend/plugins/console/editor/PropertiesEditor.java


Changes:

=====================================
console/frontend/src/main/java/org/hippoecm/frontend/plugins/console/editor/PropertiesEditor.java
=====================================
--- 
a/console/frontend/src/main/java/org/hippoecm/frontend/plugins/console/editor/PropertiesEditor.java
+++ 
b/console/frontend/src/main/java/org/hippoecm/frontend/plugins/console/editor/PropertiesEditor.java
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2008-2017 Hippo B.V. (http://www.onehippo.com)
+ *  Copyright 2008-2018 Hippo B.V. (http://www.onehippo.com)
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -43,6 +43,8 @@ import org.hippoecm.frontend.session.UserSession;
 import org.onehippo.cm.ConfigurationService;
 import org.onehippo.cm.model.ConfigurationModel;
 import org.onehippo.cm.model.definition.ContentDefinition;
+import org.onehippo.cm.model.path.JcrPath;
+import org.onehippo.cm.model.path.JcrPaths;
 import org.onehippo.cm.model.tree.ConfigurationItemCategory;
 import org.onehippo.cm.model.tree.ConfigurationNode;
 import org.onehippo.cm.model.tree.ConfigurationProperty;
@@ -147,7 +149,8 @@ public class PropertiesEditor extends DataView<Property> {
         final String nodeOrigin = getNodeOrigin(nodePath, cfgModel);
 
         final ConfigurationItemCategory propCat = 
getCategoryForProperty(propertyPath, cfgModel);
-        final ConfigurationProperty<? extends DefinitionProperty> cfgProperty 
= cfgModel.resolveProperty(propertyPath);
+        final JcrPath propertyJcrPath = JcrPaths.getPath(propertyPath);
+        final ConfigurationProperty cfgProperty = 
cfgModel.resolveProperty(propertyJcrPath);
         String origin = "";
         if ((propCat.equals(ConfigurationItemCategory.CONFIG) || 
propCat.equals(ConfigurationItemCategory.SYSTEM))
                 && cfgProperty != null) {
@@ -156,7 +159,7 @@ public class PropertiesEditor extends DataView<Property> {
             // TODO: mark system-with-initial-value in a special way?
         }
         else if (propCat.equals(ConfigurationItemCategory.CONTENT)) {
-            final ContentDefinition def = getNearestContentDef(propertyPath, 
cfgModel);
+            final ContentDefinition def = 
cfgModel.getNearestContentDefinition(propertyJcrPath);
             origin = (def==null)
                     ? "<content>"
                     : def.getOrigin();
@@ -176,14 +179,15 @@ public class PropertiesEditor extends DataView<Property> {
     public static String getNodeOrigin(final String nodePath, final 
ConfigurationModel cfgModel) {
         final ConfigurationItemCategory nodeCat = getCategoryForNode(nodePath, 
cfgModel);
         String nodeOrigin = "";
+        final JcrPath jcrPath = JcrPaths.getPath(nodePath);
         if (nodeCat.equals(ConfigurationItemCategory.CONFIG)) {
-            final ConfigurationNode<? extends DefinitionNode> cfgNode = 
cfgModel.resolveNode(nodePath);
+            final ConfigurationNode cfgNode = cfgModel.resolveNode(jcrPath);
             nodeOrigin = (cfgNode==null)
                     ? "<config>"
                     : 
cfgNode.getDefinitions().stream().map(ModelItem::getOrigin).collect(joining("\n"));
         }
         else if (nodeCat.equals(ConfigurationItemCategory.CONTENT)) {
-            final ContentDefinition def = getNearestContentDef(nodePath, 
cfgModel);
+            final ContentDefinition def = 
cfgModel.getNearestContentDefinition(jcrPath);
             nodeOrigin = (def==null)
                     ? "<content>"
                     : def.getOrigin();
@@ -194,18 +198,6 @@ public class PropertiesEditor extends DataView<Property> {
         return nodeOrigin;
     }
 
-    public static ContentDefinition getNearestContentDef(final String path, 
final ConfigurationModel cfgModel) {
-        String originPath = "";
-        ContentDefinition defValue = null;
-        for (ContentDefinition def : cfgModel.getContentDefinitions()) {
-            if (path.startsWith(def.getRootPath()) && 
(def.getRootPath().length() > originPath.length())) {
-                originPath = def.getRootPath();
-                defValue = def;
-            }
-        }
-        return defValue;
-    }
-
     /**
      * Creates {@link PropertyValueEditor} for a property. If name equals 
'hst:script' and parent node is of type
      * 'hst:template' a FreemarkerCodeMirrorPropertyValueEditor is returned 
instead.



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-cms/compare/76d775c500edf9768fc7f63432a7ddcd56047330...4ea5bf350dfb14e99682847e0d6a69f8d35003e7

---
View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-cms/compare/76d775c500edf9768fc7f63432a7ddcd56047330...4ea5bf350dfb14e99682847e0d6a69f8d35003e7
You're receiving this email because of your account on code.onehippo.org.
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to