[gatein-commits] gatein SVN: r2498 - in portal/branches/EPP_5_0_Branch: portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Apr 6 10:37:29 EDT 2010


Author: mpodolin
Date: 2010-04-06 10:37:28 -0400 (Tue, 06 Apr 2010)
New Revision: 2498

Modified:
   portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetEditor.java
   portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java
   portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties
   portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/EmailAddressValidator.java
   portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ExpressionValidator.java
   portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/IdentifierValidator.java
   portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/MandatoryValidator.java
   portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NameValidator.java
   portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NullFieldValidator.java
   portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NumberFormatValidator.java
   portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/PositiveNumberFormatValidator.java
   portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ResourceValidator.java
   portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/SpecialCharacterValidator.java
Log:
JBEPP-285: GTNPORTAL-1018 ported to the branch

Modified: portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetEditor.java
===================================================================
--- portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetEditor.java	2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetEditor.java	2010-04-06 14:37:28 UTC (rev 2498)
@@ -42,7 +42,10 @@
 import org.exoplatform.webui.exception.MessageException;
 import org.exoplatform.webui.form.UIForm;
 import org.exoplatform.webui.form.UIFormInput;
+import org.exoplatform.webui.form.UIFormStringInput;
 import org.exoplatform.webui.form.UIFormTextAreaInput;
+import org.exoplatform.webui.form.validator.ExpressionValidator;
+import org.exoplatform.webui.form.validator.IdentifierValidator;
 import org.exoplatform.webui.form.validator.MandatoryValidator;
 import org.exoplatform.webui.form.validator.Validator;
 
@@ -61,19 +64,24 @@
 {
 
    final static public String FIELD_SOURCE = "source";
+   final static public String FIELD_NAME = "name";
 
    private Source source_;
 
    private String fullName_;
 
    private String dirPath;
+   
+   private String gadgetName_;
 
    public UIGadgetEditor(InitParams initParams) throws Exception
    {
       Param param = initParams.getParam("SampleGadget");
       WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
       String sample = (String)param.getMapGroovyObject(context);
-      addUIFormInput(new UIFormTextAreaInput(FIELD_SOURCE, null, sample).addValidator(MandatoryValidator.class)
+      addUIFormInput(new UIFormStringInput(FIELD_NAME, null, null).addValidator(MandatoryValidator.class).addValidator(ExpressionValidator.class, "^[\\p{L}][\\p{ASCII}]+$",
+      "UIGadgetEditor.msg.Invalid"));
+      addUIFormInput(new UIFormTextAreaInput(FIELD_SOURCE, FIELD_SOURCE, sample).addValidator(MandatoryValidator.class)
          .addValidator(GadgetSpecValidator.class));
    }
 
@@ -89,6 +97,11 @@
       UIFormTextAreaInput uiInputSource = getUIFormTextAreaInput(FIELD_SOURCE);
       uiInputSource.setValue(source_.getTextContent());
    }
+   
+   public void setGadgetName(String name) {
+	   UIFormStringInput uiInputName = getUIStringInput(FIELD_NAME);
+	   uiInputName.setValue(name);
+   }
 
    public String getSourceFullName()
    {
@@ -103,8 +116,13 @@
    public void processRender(WebuiRequestContext context) throws Exception
    {
       UIFormTextAreaInput uiInputSource = getUIFormTextAreaInput(FIELD_SOURCE);
+      UIFormStringInput uiInputName = getUIStringInput(FIELD_NAME);
       String encoded = StringEscapeUtils.escapeHtml(StringEscapeUtils.unescapeHtml(uiInputSource.getValue()));
       uiInputSource.setValue(encoded);
+      if(this.isEdit()) {
+    	  uiInputName.setEditable(false);
+      }
+      
       super.processRender(context);
    }
 
@@ -137,56 +155,57 @@
       {
          UIGadgetEditor uiForm = event.getSource();
          UIGadgetManagement uiManagement = uiForm.getParent();
-         String name, fileName, dirPath;
+         String gadgetName;
          String text = uiForm.getUIFormTextAreaInput(UIGadgetEditor.FIELD_SOURCE).getValue();
          GadgetRegistryService service = uiForm.getApplicationComponent(GadgetRegistryService.class);
          SourceStorage sourceStorage = uiForm.getApplicationComponent(SourceStorage.class);
-         boolean isEdit = uiForm.getSource() != null;
+         boolean isEdit = uiForm.isEdit();
          if (isEdit)
          {
-            fileName = uiForm.getSourceFullName();
-            name = uiForm.getSourceName();
-            dirPath = uiForm.getDirPath();
+        	 gadgetName = uiForm.getSourceFullName();
          }
          else
          {
-            name = "gadget" + Calendar.getInstance().hashCode();
-            fileName = name + ".xml";
-            dirPath = name;
+        	 gadgetName = uiForm.getUIStringInput(UIGadgetEditor.FIELD_NAME).getValue();
          }
 
          //
-         Gadget gadget = service.getGadget(name);
-         if (isEdit)
-         {
-            if (gadget == null)
-            {
-               UIApplication uiApp = event.getRequestContext().getUIApplication();
-               uiApp.addMessage(new ApplicationMessage("gadget.msg.changeNotExist", null));
-               uiManagement.reload();
-               return;
-            }
+         Gadget gadget = service.getGadget(gadgetName);
+         
+         if(isEdit) {
+        	 if (gadget == null)
+             {
+                UIApplication uiApp = event.getRequestContext().getUIApplication();
+                uiApp.addMessage(new ApplicationMessage("gadget.msg.changeNotExist", null, ApplicationMessage.WARNING));
+                uiManagement.reload();
+                return;
+             }
          }
+         else {
+        	// If gadget is null we need to create it first
+             if (gadget == null)
+             {
+                gadget = new Gadget();
+                gadget.setName(gadgetName);
 
-         // If gadget is null we need to create it first
-         if (gadget == null)
-         {
-            gadget = new Gadget();
-            gadget.setName("CHANGME");
+                // Those data will be taken from the gadget XML anyway
+                gadget.setDescription("");
+                gadget.setThumbnail("");
+                gadget.setLocal(true);
+                gadget.setTitle("");
+                gadget.setReferenceUrl("");
 
-            // Those data will be taken from the gadget XML anyway
-            gadget.setDescription("");
-            gadget.setThumbnail("");
-            gadget.setLocal(true);
-            gadget.setTitle("");
-            gadget.setReferenceUrl("");
-
-            // Save gadget with empty data first
-            service.saveGadget(gadget);
+                // Save gadget with empty data first
+                service.saveGadget(gadget);
+             }
+             else {
+        		 UIApplication uiApp = event.getRequestContext().getUIApplication();
+                 uiApp.addMessage(new ApplicationMessage("UIGadgetEditor.gadget.msg.gadgetIsExist", null, ApplicationMessage.WARNING));
+                 return;
+        	 }
          }
-
          //
-         Source source = new Source(fileName, "application/xml");
+         Source source = new Source(gadgetName, "application/xml");
          source.setTextContent(text);
          source.setLastModified(Calendar.getInstance());
 
@@ -202,6 +221,10 @@
       }
 
    }
+   
+   private boolean isEdit() {
+	   return (this.getSource() != null);
+   }
 
    public static class CancelActionListener extends EventListener<UIGadgetEditor>
    {

Modified: portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java
===================================================================
--- portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java	2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java	2010-04-06 14:37:28 UTC (rev 2498)
@@ -160,6 +160,7 @@
          // get gadget's source: path = dir path + file name
          Source source = sourceStorage.getSource(gadget);
          uiEditor.setSource(source);
+         uiEditor.setGadgetName(gadget.getName());
          uiEditor.setDirPath(dirPath);
          uiManagement.getChildren().clear();
          uiManagement.addChild(uiEditor);

Modified: portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties
===================================================================
--- portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties	2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties	2010-04-06 14:37:28 UTC (rev 2498)
@@ -139,10 +139,13 @@
 UIAddGadget.label.urlError=Data in url: '{0}' is not valid
 
 ##	org.exoplatform.applicationregistry.webui.component.UIGadgetEditor
-UIGadgetEditor.label.source=Source: 
+UIGadgetEditor.label.source=Source:
+UIGadgetEditor.label.name=Name:
 UIGadgetEditor.action.Save=#{word.save}
 UIGadgetEditor.action.Cancel=#{word.cancel}
 UIGadgetEditor.msg.invalidSpec=This source is invalid gadget specification.
+UIGadgetEditor.gadget.msg.gadgetIsExist=This name already exists, please enter a different name.
+UIGadgetEditor.msg.Invalid=The "{0}" field must not contains special characters.
 ##package org.exoplatform.organization.webui.component.UIListPermissionSelector
 UIListPermissionSelector.header.groupId=Group
 UIListPermissionSelector.header.membership=Membership

Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/EmailAddressValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/EmailAddressValidator.java	2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/EmailAddressValidator.java	2010-04-06 14:37:28 UTC (rev 2498)
@@ -59,7 +59,7 @@
       String s = (String)uiInput.getValue();
       if (s.matches(EMAIL_REGEX))
          return;
-      Object[] args = {label, uiInput.getBindingField()};
+      Object[] args = {label};
       throw new MessageException(new ApplicationMessage("EmailAddressValidator.msg.Invalid-input", args,
          ApplicationMessage.WARNING));
    }

Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ExpressionValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ExpressionValidator.java	2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ExpressionValidator.java	2010-04-06 14:37:28 UTC (rev 2498)
@@ -85,7 +85,7 @@
       {
          label = uiInput.getName();
       }
-      Object[] args = {label,};
+      Object[] args = {label};
       throw new MessageException(new ApplicationMessage(key_, args, ApplicationMessage.WARNING));
    }
 }

Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/IdentifierValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/IdentifierValidator.java	2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/IdentifierValidator.java	2010-04-06 14:37:28 UTC (rev 2498)
@@ -68,7 +68,7 @@
          {
             continue;
          }
-         Object[] args = {label, uiInput.getBindingField()};
+         Object[] args = {label};
          throw new MessageException(new ApplicationMessage("IdentifierValidator.msg.Invalid-char", args,
             ApplicationMessage.WARNING));
       }

Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/MandatoryValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/MandatoryValidator.java	2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/MandatoryValidator.java	2010-04-06 14:37:28 UTC (rev 2498)
@@ -61,7 +61,7 @@
          label = uiInput.getName();
       }
       label = label.trim();
-      Object[] args = {label, uiInput.getBindingField()};
+      Object[] args = {label};
       throw new MessageException(new ApplicationMessage("EmptyFieldValidator.msg.empty-input", args,
          ApplicationMessage.WARNING));
    }

Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NameValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NameValidator.java	2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NameValidator.java	2010-04-06 14:37:28 UTC (rev 2498)
@@ -62,7 +62,7 @@
          {
             continue;
          }
-         Object[] args = {label, uiInput.getBindingField()};
+         Object[] args = {label};
          throw new MessageException(new ApplicationMessage("NameValidator.msg.Invalid-char", args));
       }
    }

Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NullFieldValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NullFieldValidator.java	2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NullFieldValidator.java	2010-04-06 14:37:28 UTC (rev 2498)
@@ -52,7 +52,7 @@
       {
          label = uiInput.getName();
       }
-      Object[] args = {label, uiInput.getBindingField()};
+      Object[] args = {label};
       throw new MessageException(new ApplicationMessage("EmptyFieldValidator.msg.empty-input", args));
    }
 }

Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NumberFormatValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NumberFormatValidator.java	2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NumberFormatValidator.java	2010-04-06 14:37:28 UTC (rev 2498)
@@ -61,7 +61,7 @@
          {
             continue;
          }
-         Object[] args = {label, uiInput.getBindingField()};
+         Object[] args = {label};
          throw new MessageException(new ApplicationMessage("NumberFormatValidator.msg.Invalid-number", args));
       }
    }

Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/PositiveNumberFormatValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/PositiveNumberFormatValidator.java	2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/PositiveNumberFormatValidator.java	2010-04-06 14:37:28 UTC (rev 2498)
@@ -69,7 +69,7 @@
       }
       if (error == true && s.charAt(0) == '-')
       {
-         Object[] args = {label, uiInput.getBindingField()};
+         Object[] args = {label};
          throw new MessageException(new ApplicationMessage("PositiveNumberFormatValidator.msg.Invalid-number", args));
       }
    }

Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ResourceValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ResourceValidator.java	2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ResourceValidator.java	2010-04-06 14:37:28 UTC (rev 2498)
@@ -68,7 +68,7 @@
          {
             continue;
          }
-         Object[] args = {label, uiInput.getBindingField()};
+         Object[] args = {label};
          throw new MessageException(new ApplicationMessage("ResourceValidator.msg.Invalid-char", args,
             ApplicationMessage.WARNING));
       }

Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/SpecialCharacterValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/SpecialCharacterValidator.java	2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/SpecialCharacterValidator.java	2010-04-06 14:37:28 UTC (rev 2498)
@@ -60,7 +60,7 @@
          {
             continue;
          }
-         Object[] args = {label, uiInput.getBindingField()};
+         Object[] args = {label};
          throw new MessageException(new ApplicationMessage("SpecialCharacterValidator.msg.Invalid-char", args,
             ApplicationMessage.WARNING));
       }



More information about the gatein-commits mailing list