incubator-wookie-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scot...@apache.org
Subject svn commit: r1069948 - in /incubator/wookie/trunk: etc/ddl-schema/ parser/java/src/org/apache/wookie/w3c/ parser/java/src/org/apache/wookie/w3c/impl/ parser/java/src/org/apache/wookie/w3c/util/ src/org/apache/wookie/beans/ src/org/apache/wookie/beans/j...
Date Fri, 11 Feb 2011 20:36:10 GMT
Author: scottbw
Date: Fri Feb 11 20:36:10 2011
New Revision: 1069948

URL: http://svn.apache.org/viewvc?rev=1069948&view=rev
Log:
Added localisation properties (lang,dir) to the Widget object, both in the Parser and when
it is stored in the the Wookie Server, and updated FormattingUtils to use this information
when formatting the Widget Version. This addresses issue WOOKIE-175.

Modified:
    incubator/wookie/trunk/etc/ddl-schema/wookie-schema.xml
    incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidget.java
    incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/WidgetManifestModel.java
    incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/util/FormattingUtils.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/IWidget.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/WidgetImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/wookie-schema.cnd
    incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/impl/WidgetImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/util/WidgetFormattingUtils.java
    incubator/wookie/trunk/src/org/apache/wookie/util/gadgets/GadgetAdapter.java

Modified: incubator/wookie/trunk/etc/ddl-schema/wookie-schema.xml
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/etc/ddl-schema/wookie-schema.xml?rev=1069948&r1=1069947&r2=1069948&view=diff
==============================================================================
--- incubator/wookie/trunk/etc/ddl-schema/wookie-schema.xml (original)
+++ incubator/wookie/trunk/etc/ddl-schema/wookie-schema.xml Fri Feb 11 20:36:10 2011
@@ -30,6 +30,8 @@
     <column name="widget_author_email" size="320" type="VARCHAR"/>
     <column name="widget_author_href" type="LONGVARCHAR"/>
     <column name="widget_version" size="255" type="VARCHAR"/>
+    <column name="dir" size="255" type="VARCHAR"/>
+    <column name="lang" size="255" type="VARCHAR"/>
     <unique name="UNWidget1">
       <unique-column name="guid"/>
     </unique>

Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidget.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidget.java?rev=1069948&r1=1069947&r2=1069948&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidget.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidget.java Fri Feb 11
20:36:10 2011
@@ -22,7 +22,7 @@ import java.util.List;
  * This represents the information model for a W3C widget that has been
  * unpacked using the W3CWidgetFactory.
  */
-public interface W3CWidget extends IElement{
+public interface W3CWidget extends ILocalizedEntity{
 
 	/**
 	 * Get the list of access request entities for the widget

Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/WidgetManifestModel.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/WidgetManifestModel.java?rev=1069948&r1=1069947&r2=1069948&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/WidgetManifestModel.java
(original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/impl/WidgetManifestModel.java
Fri Feb 11 20:36:10 2011
@@ -45,14 +45,13 @@ import org.apache.wookie.w3c.util.Unicod
 import org.apache.wookie.w3c.util.WidgetPackageUtils;
 import org.jdom.Element;
 import org.jdom.JDOMException;
-import org.jdom.Namespace;
 import org.jdom.input.SAXBuilder;
 /**
  * Processes a config.xml document to create a model
  * for a widget, including all sub-objects
  * @author Paul Sharples
  */
-public class WidgetManifestModel implements W3CWidget {
+public class WidgetManifestModel extends AbstractLocalizedEntity implements W3CWidget {
 	
 	static Logger fLogger = Logger.getLogger(WidgetManifestModel.class.getName());
 	
@@ -61,7 +60,6 @@ public class WidgetManifestModel impleme
 	private Integer fHeight;
 	private Integer fWidth;
 	private String fViewModes;
-	private String fLang;
 	private String[] features;
 	private List<INameEntity> fNamesList;
 	private List<IDescriptionEntity> fDescriptionsList;
@@ -207,9 +205,13 @@ public class WidgetManifestModel impleme
 		return fUpdate;
 	}
 	
-	public void fromXML(Element element) throws BadManifestException{
+	public void fromXML(Element element){
 		fLogger.warn("WidgetManifestModel.fromXML() called with no locales");
-		fromXML(element, new String[]{"en"});
+		try {
+			fromXML(element, new String[]{"en"});
+		} catch (BadManifestException e) {
+			fLogger.error("WidgetManifestModel.fromXML() called with no locales and Bad Manifest",e);
+		}
 	}
 
 	public String getLocalName(String locale){
@@ -284,11 +286,9 @@ public class WidgetManifestModel impleme
 			}
 			fViewModes = modes.trim();
 		}
-		// xml:lang optional
-		fLang = element.getAttributeValue(IW3CXMLConfiguration.LANG_ATTRIBUTE, Namespace.XML_NAMESPACE);
-		if(fLang == null){
-			fLang = IW3CXMLConfiguration.DEFAULT_LANG;
-		}
+		// DIR and XML:LANG ARE OPTIONAL
+		super.fromXML(element);
+		
 
 		
 		// parse the children

Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/util/FormattingUtils.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/util/FormattingUtils.java?rev=1069948&r1=1069947&r2=1069948&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/util/FormattingUtils.java
(original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/util/FormattingUtils.java
Fri Feb 11 20:36:10 2011
@@ -51,7 +51,7 @@ public class FormattingUtils {
 	 * @return a CSS-formatted i18n string
 	 */
 	public static String getFormattedWidgetVersion(W3CWidget widget){
-		return getFormatted(widget.getVersion());
+		return getFormatted(widget.getDir(), widget.getVersion());
 	}
 	/**
 	 * Returns the CSS formatted i18n string for the widget description
@@ -100,6 +100,10 @@ public class FormattingUtils {
 	 * @return a CSS i18n string
 	 */
 	protected static String getFormatted(String dir, String value){
+		
+		// If the string has no embedded spans with dir attributes, and no set dir, just return
the string
+		//if (dir == null && !value.contains("dir=")) return value;
+		
 		String mode = "embed";
 		if (dir == null) dir = "ltr";
 		// Reformat embedded SPAN tags

Modified: incubator/wookie/trunk/src/org/apache/wookie/beans/IWidget.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/beans/IWidget.java?rev=1069948&r1=1069947&r2=1069948&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/beans/IWidget.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/beans/IWidget.java Fri Feb 11 20:36:10 2011
@@ -29,7 +29,7 @@ import org.apache.wookie.w3c.util.Locali
  * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
  * @version $Id$
  */
-public interface IWidget extends IBean
+public interface IWidget extends ILocalizedBean, IBean
 {
     /**
      * Get widget height.

Modified: incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/WidgetImpl.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/WidgetImpl.java?rev=1069948&r1=1069947&r2=1069948&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/WidgetImpl.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/impl/WidgetImpl.java Fri Feb 11
20:36:10 2011
@@ -42,7 +42,7 @@ import org.apache.wookie.beans.jcr.JCRPe
  * @version $Id$
  */
 @Node(jcrType="wookie:widget", jcrMixinTypes="mix:referenceable", discriminator=false)
-public class WidgetImpl implements IWidget, IPathBean, IUuidBean
+public class WidgetImpl extends LocalizedBeanImpl implements IWidget, IPathBean, IUuidBean
 {
     @Field(path=true)
     private String path;

Modified: incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/wookie-schema.cnd
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/wookie-schema.cnd?rev=1069948&r1=1069947&r2=1069948&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/wookie-schema.cnd (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/beans/jcr/wookie-schema.cnd Fri Feb 11 20:36:10
2011
@@ -85,6 +85,8 @@
 - wookie:widgetAuthorEmail (string)
 - wookie:widgetAuthorHref (string)
 - wookie:widgetVersion (string)
+- wookie:dir (string)
+- wookie:lang (string)
 + wookie:widgetTypes (nt:unstructured) = nt:unstructured
 + wookie:accessRequests (nt:unstructured) = nt:unstructured
 + wookie:features (nt:unstructured) = nt:unstructured

Modified: incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/impl/WidgetImpl.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/impl/WidgetImpl.java?rev=1069948&r1=1069947&r2=1069948&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/impl/WidgetImpl.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/beans/jpa/impl/WidgetImpl.java Fri Feb 11
20:36:10 2011
@@ -56,7 +56,7 @@ import org.apache.wookie.beans.jpa.Inver
 @NamedQueries({@NamedQuery(name="WIDGET", query="SELECT w FROM Widget w WHERE w.guid = :guid"),
                @NamedQuery(name="DEFAULT_WIDGET", query="SELECT w FROM WidgetDefault wd JOIN
wd.widget w WHERE wd.widgetContext = :widgetContext"),
                @NamedQuery(name="WIDGETS", query="SELECT w FROM Widget w JOIN w.widgetTypes
wt WHERE wt.widgetContext = :widgetContext")})
-public class WidgetImpl implements IWidget
+public class WidgetImpl extends LocalizedBeanImpl implements IWidget
 {
     @Id
     @GeneratedValue(strategy=GenerationType.AUTO)

Modified: incubator/wookie/trunk/src/org/apache/wookie/util/WidgetFormattingUtils.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/util/WidgetFormattingUtils.java?rev=1069948&r1=1069947&r2=1069948&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/util/WidgetFormattingUtils.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/util/WidgetFormattingUtils.java Fri Feb 11
20:36:10 2011
@@ -51,7 +51,7 @@ public class WidgetFormattingUtils exten
 	 * @return a CSS-formatted i18n string
 	 */
 	public static String getFormattedWidgetVersion(IWidget widget){
-		return getFormatted(widget.getVersion());
+		return getFormatted(widget.getDir(), widget.getVersion());
 	}
 	/**
 	 * Returns the CSS formatted i18n string for the widget description

Modified: incubator/wookie/trunk/src/org/apache/wookie/util/gadgets/GadgetAdapter.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/util/gadgets/GadgetAdapter.java?rev=1069948&r1=1069947&r2=1069948&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/util/gadgets/GadgetAdapter.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/util/gadgets/GadgetAdapter.java Fri Feb 11
20:36:10 2011
@@ -208,6 +208,21 @@ public class GadgetAdapter implements W3
 		// TODO Auto-generated method stub
 		return null;
 	}
+
+	public String getDir() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public boolean isValid() {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	public String getLang() {
+		// TODO Auto-generated method stub
+		return null;
+	}
 	
 	
 



Mime
View raw message