You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by co...@apache.org on 2013/02/11 11:32:32 UTC

svn commit: r1444727 - in /syncope/trunk/console/src/main: java/org/apache/syncope/console/pages/ java/org/apache/syncope/console/pages/panels/ resources/org/apache/syncope/console/pages/

Author: coheigea
Date: Mon Feb 11 10:32:31 2013
New Revision: 1444727

URL: http://svn.apache.org/r1444727
Log:
[SYNCOPE-215] - Committing Fabio's modified patch

Modified:
    syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/VirtualSchemaModalPage.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/VirtualAttributesPanel.java
    syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/VirtualSchemaModalPage.html
    syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/VirtualSchemaModalPage.properties
    syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/VirtualSchemaModalPage_it.properties

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/VirtualSchemaModalPage.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/VirtualSchemaModalPage.java?rev=1444727&r1=1444726&r2=1444727&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/VirtualSchemaModalPage.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/VirtualSchemaModalPage.java Mon Feb 11 10:32:31 2013
@@ -22,6 +22,7 @@ import org.apache.syncope.common.Abstrac
 import org.apache.syncope.common.to.VirtualSchemaTO;
 import org.apache.syncope.common.types.AttributableType;
 import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.console.wicket.markup.html.form.AjaxCheckBoxPanel;
 import org.apache.syncope.console.wicket.markup.html.form.AjaxTextFieldPanel;
 import org.apache.wicket.PageReference;
 import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -61,6 +62,9 @@ public class VirtualSchemaModalPage exte
         name.addRequiredLabel();
 
         name.setEnabled(createFlag);
+        
+        final AjaxCheckBoxPanel readonly = new AjaxCheckBoxPanel("readonly", getString("readonly"),
+                                                                 new PropertyModel<Boolean>(schema, "readonly"));
 
         final IndicatingAjaxButton submit = new IndicatingAjaxButton("apply", new ResourceModel("submit")) {
 
@@ -121,6 +125,7 @@ public class VirtualSchemaModalPage exte
         MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles);
 
         schemaForm.add(name);
+        schemaForm.add(readonly);
 
         schemaForm.add(submit);
         schemaForm.add(cancel);

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/VirtualAttributesPanel.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/VirtualAttributesPanel.java?rev=1444727&r1=1444726&r2=1444727&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/VirtualAttributesPanel.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/VirtualAttributesPanel.java Mon Feb 11 10:32:31 2013
@@ -18,12 +18,16 @@
  */
 package org.apache.syncope.console.pages.panels;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.syncope.common.to.AbstractAttributableTO;
 import org.apache.syncope.common.to.AttributeTO;
 import org.apache.syncope.common.to.RoleTO;
 import org.apache.syncope.common.to.UserTO;
+import org.apache.syncope.common.to.VirtualSchemaTO;
 import org.apache.syncope.common.types.AttributableType;
 import org.apache.syncope.console.rest.SchemaRestClient;
 import org.apache.syncope.console.wicket.markup.html.form.AjaxDecoratedCheckbox;
@@ -64,22 +68,33 @@ public class VirtualAttributesPanel exte
 
         setOutputMarkupId(true);
 
-        final IModel<List<String>> virtualSchemaNames = new LoadableDetachableModel<List<String>>() {
+        final IModel<Map<String, VirtualSchemaTO>> schemas = new LoadableDetachableModel<Map<String, VirtualSchemaTO>>() {
 
-            private static final long serialVersionUID = 5275935387613157437L;
+            private static final long serialVersionUID = -5489981430516587774L;
 
             @Override
-            protected List<String> load() {
+            protected Map<String, VirtualSchemaTO> load() {
+                final List<VirtualSchemaTO> schemaTOs;
                 if (entityTO instanceof RoleTO) {
-                    return schemaRestClient.getVirtualSchemaNames(AttributableType.ROLE);
+                    schemaTOs = schemaRestClient.getVirtualSchemas(AttributableType.ROLE);
                 } else if (entityTO instanceof UserTO) {
-                    return schemaRestClient.getVirtualSchemaNames(AttributableType.USER);
+                    schemaTOs = schemaRestClient.getVirtualSchemas(AttributableType.USER);
                 } else {
-                    return schemaRestClient.getVirtualSchemaNames(AttributableType.MEMBERSHIP);
+                    schemaTOs = schemaRestClient.getVirtualSchemas(AttributableType.MEMBERSHIP);
                 }
+
+                final Map<String, VirtualSchemaTO> schemas = new HashMap<String, VirtualSchemaTO>();
+
+                for (VirtualSchemaTO schemaTO : schemaTOs) {
+                    schemas.put(schemaTO.getName(), schemaTO);
+                }
+
+                return schemas;
             }
         };
 
+        final List<String> virtualSchemaNames = new ArrayList<String>(schemas.getObject().keySet());
+
         final WebMarkupContainer attributesContainer = new WebMarkupContainer("virAttrContainer");
 
         attributesContainer.setOutputMarkupId(true);
@@ -141,6 +156,30 @@ public class VirtualAttributesPanel exte
                     }
                 });
 
+                if (attributeTO.getValues().isEmpty()) {
+                    attributeTO.addValue("");
+                }
+
+                if (attributeTO.getSchema() != null) {
+                    VirtualSchemaTO attributeSchema = schemas.getObject().get(attributeTO.getSchema());
+                    if (attributeSchema != null) {
+                        attributeTO.setReadonly(attributeSchema.isReadonly());
+                    }
+                }
+
+                final AjaxTextFieldPanel panel;
+                final MultiValueSelectorPanel multiPanel;
+                if (templateMode) {
+                    panel = new AjaxTextFieldPanel("values", "values", new Model<String>());
+                    panel.setReadOnly(attributeTO.isReadonly());
+                    multiPanel = null;
+                } else {
+                    panel = new AjaxTextFieldPanel("panel", "values", new Model<String>(null));
+                    panel.setReadOnly(attributeTO.isReadonly());
+                    multiPanel = new MultiValueSelectorPanel("values", new PropertyModel<List<String>>(attributeTO,
+                            "values"), panel);
+                }
+
                 final DropDownChoice<String> schemaChoice = new DropDownChoice<String>("schema",
                         new PropertyModel<String>(attributeTO, "schema"), virtualSchemaNames,
                         new ChoiceRenderer<String>() {
@@ -162,9 +201,30 @@ public class VirtualAttributesPanel exte
                     private static final long serialVersionUID = -1107858522700306810L;
 
                     @Override
-                    protected void onUpdate(final AjaxRequestTarget art) {
+                    protected void onUpdate(final AjaxRequestTarget target) {
 
                         attributeTO.setSchema(schemaChoice.getModelObject());
+
+                        VirtualSchemaTO attributeSchema =
+                                schemas.getObject().get(attributeTO.getSchema());
+                        if (attributeSchema != null) {
+                            attributeTO.setReadonly(attributeSchema.isReadonly());
+                            panel.setReadOnly(attributeTO.isReadonly());
+                        }
+
+                        if (multiPanel != null) {
+                            multiPanel.getView().setEnabled(false);
+                        }
+                    }
+                });
+
+                schemaChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
+
+                    private static final long serialVersionUID = -1107858522700306810L;
+
+                    @Override
+                    protected void onUpdate(final AjaxRequestTarget target) {
+                        target.add(attributesContainer);
                     }
                 });
 
@@ -172,15 +232,10 @@ public class VirtualAttributesPanel exte
                 schemaChoice.setRequired(true);
                 item.add(schemaChoice);
 
-                if (attributeTO.getValues().isEmpty()) {
-                    attributeTO.addValue("");
-                }
-
                 if (templateMode) {
-                    item.add(new AjaxTextFieldPanel("values", "values", new Model<String>()));
+                    item.add(panel);
                 } else {
-                    item.add(new MultiValueSelectorPanel("values", new PropertyModel<List<String>>(attributeTO,
-                            "values"), new AjaxTextFieldPanel("panel", "values", new Model<String>(null))));
+                    item.add(multiPanel);
                 }
             }
         };

Modified: syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/VirtualSchemaModalPage.html
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/VirtualSchemaModalPage.html?rev=1444727&r1=1444726&r2=1444727&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/VirtualSchemaModalPage.html (original)
+++ syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/VirtualSchemaModalPage.html Mon Feb 11 10:32:31 2013
@@ -29,6 +29,14 @@ under the License.
                     <span wicket:id="name">[name]</span>
                 </div>
             </div>
+            <div class="tablerow">
+                <div class="tablecolumn_label short_dynamicsize">
+                    <label for="readonly" class="onerowlabel"><wicket:message key="readonly"/></label>
+                </div>
+                <div class="tablecolumn_field medium_dynamicsize">
+                    <span wicket:id="readonly">[readonly]</span>
+                </div>
+            </div>
         </div>
         <div style="margin: 10px 0px 0">
             <input type="submit"

Modified: syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/VirtualSchemaModalPage.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/VirtualSchemaModalPage.properties?rev=1444727&r1=1444726&r2=1444727&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/VirtualSchemaModalPage.properties (original)
+++ syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/VirtualSchemaModalPage.properties Mon Feb 11 10:32:31 2013
@@ -20,3 +20,4 @@ existing_schemas=Existing Schemas:
 edit_attribute=Edit attribute
 attributes=Virtual attributes
 title=Virtual Schema
+readonly=Read-only

Modified: syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/VirtualSchemaModalPage_it.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/VirtualSchemaModalPage_it.properties?rev=1444727&r1=1444726&r2=1444727&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/VirtualSchemaModalPage_it.properties (original)
+++ syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/VirtualSchemaModalPage_it.properties Mon Feb 11 10:32:31 2013
@@ -20,3 +20,4 @@ existing_schemas=Schemi presenti:
 edit_attribute=Modifica attributo
 attributes=Attributi virtuali
 title=Schema Virtuale
+readonly=Read-only