cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r446974 [3/3] - in /cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel: ./ library/ tree/ tree/builder/
Date Sat, 16 Sep 2006 23:39:10 GMT
Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java
(original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java
Sat Sep 16 16:39:08 2006
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2005 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,7 @@
 import org.apache.avalon.framework.CascadingException;
 import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.component.Component;
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -27,11 +28,13 @@
 import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+
 import org.apache.cocoon.forms.CacheManager;
 import org.apache.cocoon.forms.formmodel.WidgetDefinitionBuilder;
 import org.apache.cocoon.forms.util.DomHelper;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceResolver;
+
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
 
@@ -39,158 +42,164 @@
  * @version $Id$
  *
  */
-public class LibraryManagerImpl extends AbstractLogEnabled implements LibraryManager, ThreadSafe,
Serviceable,
-Configurable, Initializable, Disposable {
+public class LibraryManagerImpl extends AbstractLogEnabled
+                                implements LibraryManager, Serviceable, Configurable,
+                                           Initializable, Disposable, ThreadSafe, Component
{
 
-	protected static final String PREFIX = "CocoonFormLibrary:";
-	
-	private ServiceManager serviceManager;
-    private Configuration configuration;
+    protected static final String PREFIX = "CocoonFormLibrary:";
+
+    private ServiceManager serviceManager;
     private CacheManager cacheManager;
-    
+
     private ServiceSelector widgetDefinitionBuilderSelector;
 
+
     public void configure(Configuration configuration) throws ConfigurationException {
-        this.configuration = configuration;
-        getLogger().debug("Gotten a config: top level element: "+this.configuration);
+        // TODO Read config to "preload" libraries
     }
 
     public void service(ServiceManager serviceManager) throws ServiceException {
         this.serviceManager = serviceManager;
         this.cacheManager = (CacheManager)serviceManager.lookup(CacheManager.ROLE);
     }
-    
+
     public void initialize() throws Exception {
-    	this.widgetDefinitionBuilderSelector = (ServiceSelector) serviceManager.lookup(WidgetDefinitionBuilder.class.getName()
+ "Selector");
-    	
-        // read config to "preload" libraries
-    }
-    
-    public boolean libraryInCache(String librarysource) throws Exception {
-    	return libraryInCache(librarysource,null);
-    }
-    
-    public boolean libraryInCache(String librarysource, String relative) throws Exception
{
-    	SourceResolver sourceResolver = null;
+        this.widgetDefinitionBuilderSelector = (ServiceSelector) serviceManager.lookup(WidgetDefinitionBuilder.class.getName()
+ "Selector");
+    }
+
+    public boolean libraryInCache(String sourceURI) throws Exception {
+        return libraryInCache(sourceURI, null);
+    }
+
+    public boolean libraryInCache(String sourceURI, String baseURI) throws Exception {
+        SourceResolver sourceResolver = null;
         Source source = null;
-        
-        if(getLogger().isDebugEnabled())
-        	getLogger().debug("Checking if library is in cache: '"+librarysource+"' relative
to '"+relative+"'");
 
-        Library lib = null;
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Checking if library is in cache: '" + sourceURI + "' relative
to '" + baseURI + "'");
+        }
+
+        Library lib;
         boolean result = false;
-        
         try {
             sourceResolver = (SourceResolver)serviceManager.lookup(SourceResolver.ROLE);
-            source = sourceResolver.resolveURI(librarysource, relative, null);
-            
-            lib = (Library)this.cacheManager.get(source, PREFIX);
-            
-            if( lib != null && lib.dependenciesHaveChanged() ) {
-            	result = false;
-            	this.cacheManager.set(null,source,PREFIX); //evict?
-            }
-            else if( lib == null )
-            	result = false;
-            else
-            	result = true;
+            source = sourceResolver.resolveURI(sourceURI, baseURI, null);
+
+            lib = (Library) this.cacheManager.get(source, PREFIX);
+
+            if (lib != null && lib.dependenciesHaveChanged()) {
+                result = false;
+                this.cacheManager.remove(source, PREFIX); // evict?
+            } else if (lib == null) {
+                result = false;
+            } else {
+                result = true;
+            }
         } catch(Exception e) {
-        	if(getLogger().isErrorEnabled())
-            	getLogger().error("Problem getting library '"+librarysource+"' relative to '"+relative+"'!",e);
-        	throw e;
+            if (getLogger().isErrorEnabled()) {
+                getLogger().error("Problem getting library '" + sourceURI + "' relative to
'" + baseURI + "'!", e);
+            }
+            throw e;
         } finally {
-            if (source != null)
+            if (source != null) {
                 sourceResolver.release(source);
-            if (sourceResolver != null)
-            	serviceManager.release(sourceResolver);
+            }
+            if (sourceResolver != null) {
+                serviceManager.release(sourceResolver);
+            }
         }
 
-        if(getLogger().isDebugEnabled()) {
-        	if(result)
-        		getLogger().debug("Library IS in cache : '"+librarysource+"' relative to '"+relative+"'");
-        	else
-        		getLogger().debug("Library IS NOT in cache : '"+librarysource+"' relative to '"+relative+"'");
+        if (getLogger().isDebugEnabled()) {
+            if (result) {
+                getLogger().debug("Library IS in cache : '" + sourceURI + "' relative to
'" + baseURI + "'");
+            } else {
+                getLogger().debug("Library IS NOT in cache : '" + sourceURI + "' relative
to '" + baseURI + "'");
+            }
         }
-        
+
         return result;
     }
-    
+
     public Library getLibrary(String librarysource) throws Exception {
-    	return getLibrary(librarysource,null);
+        return getLibrary(librarysource,null);
     }
-    
-	public Library getLibrary(String librarysource, String relative) throws Exception {
-		SourceResolver sourceResolver = null;
+
+    public Library getLibrary(String librarysource, String relative)
+    throws Exception {
+        SourceResolver sourceResolver = null;
         Source source = null;
-        Document libraryDocument = null;
+        Document libraryDocument;
 
         Library lib = null;
-        
-        if(getLogger().isDebugEnabled())
-        	getLogger().debug("Getting library instance: '"+librarysource+"' relative to '"+relative+"'");
-        
+
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Getting library instance: '" + librarysource + "' relative
to '" + relative + "'");
+        }
+
         try {
-            sourceResolver = (SourceResolver)serviceManager.lookup(SourceResolver.ROLE);
+            sourceResolver = (SourceResolver) serviceManager.lookup(SourceResolver.ROLE);
             source = sourceResolver.resolveURI(librarysource, relative, null);
-            
-            lib = (Library)this.cacheManager.get(source, PREFIX);
-            
-            if( lib != null && lib.dependenciesHaveChanged() ) {
-            	if(getLogger().isDebugEnabled())
-                	getLogger().debug("Library dependencies changed, invalidating!");
-            	
-            	lib = null;
-            }
-            
-            if( lib == null ) {
-            	if(getLogger().isDebugEnabled())
-                	getLogger().debug("Library not in cache, creating!");
-            	
-            	try {
+
+            lib = (Library) this.cacheManager.get(source, PREFIX);
+
+            if (lib != null && lib.dependenciesHaveChanged()) {
+                if (getLogger().isDebugEnabled()) {
+                    getLogger().debug("Library dependencies changed, invalidating!");
+                }
+                lib = null;
+            }
+
+            if (lib == null) {
+                if (getLogger().isDebugEnabled()) {
+                    getLogger().debug("Library not in cache, creating!");
+                }
+
+                try {
                     InputSource inputSource = new InputSource(source.getInputStream());
                     inputSource.setSystemId(source.getURI());
                     libraryDocument = DomHelper.parse(inputSource, this.serviceManager);
-                    
+
                     lib = getNewLibrary();
                     lib.buildLibrary(libraryDocument.getDocumentElement());
-                    
-                    this.cacheManager.set(lib,source,PREFIX);
-                    
+
+                    this.cacheManager.set(lib, source, PREFIX);
                 } catch (Exception e) {
                     throw new CascadingException("Could not parse form definition from "
+
                                                  source.getURI(), e);
                 }
             }
         } finally {
-            if (source != null)
+            if (source != null) {
                 sourceResolver.release(source);
-            if (sourceResolver != null)
-            	serviceManager.release(sourceResolver);
+            }
+            if (sourceResolver != null) {
+                serviceManager.release(sourceResolver);
+            }
         }
 
         return lib;
-	}
-	
-	public Library getNewLibrary() {
-		Library lib = new Library(this);
+    }
+
+    public Library getNewLibrary() {
+        Library lib = new Library(this);
         lib.setWidgetDefinitionBuilderSelector(this.widgetDefinitionBuilderSelector);
-        
-        if(getLogger().isDebugEnabled())
-        	getLogger().debug("Created new library! "+lib);
-        
+
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Created new library! " + lib);
+        }
+
         return lib;
-	}
+    }
 
-	public void dispose() {
-		this.serviceManager.release(this.cacheManager);
-	    this.cacheManager = null;
-	    this.serviceManager = null;
-	}
-	
-	public void debug(String msg) {
-		if(getLogger().isDebugEnabled()) {
-			getLogger().debug(msg);
-		}
-	}
-	
+    public void dispose() {
+        this.serviceManager.release(this.cacheManager);
+        this.cacheManager = null;
+        this.serviceManager = null;
+    }
+
+    public void debug(String msg) {
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug(msg);
+        }
+    }
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/JavaTreeModelDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/JavaTreeModelDefinition.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/JavaTreeModelDefinition.java
(original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/JavaTreeModelDefinition.java
Sat Sep 16 16:39:08 2006
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2005 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,17 +28,17 @@
 /**
  * A {@link org.apache.cocoon.forms.formmodel.tree.TreeModelDefinition} based on an Java
class
  * implementing {@link org.apache.cocoon.forms.formmodel.tree.TreeModel}.
- * 
+ *
  * @version $Id$
  */
 public class JavaTreeModelDefinition extends AbstractLogEnabled
-    implements TreeModelDefinition, Contextualizable, Serviceable {
-    
+                                     implements TreeModelDefinition, Contextualizable, Serviceable
{
+
     private Class modelClass;
 
     Context ctx;
     ServiceManager manager;
-    
+
     public void contextualize(Context context) throws ContextException {
         this.ctx = context;
     }
@@ -59,7 +59,7 @@
         } catch (Exception e) {
             throw new CascadingRuntimeException("Cannot instanciate class " + modelClass.getName(),
e);
         }
-        
+
         return model;
     }
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/Tree.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/Tree.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/Tree.java
(original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/Tree.java
Sat Sep 16 16:39:08 2006
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2005 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,38 +32,38 @@
 
 /**
  * A tree widget, heavily inspired by Swing's <code>JTree</code>.
- * 
+ *
  * @version $Id$
  */
 public class Tree extends AbstractWidget {
-    
+
     public static final int SINGLE_SELECTION = 0;
     public static final int MULTIPLE_SELECTION = 1;
-    
+
     public interface ActionHandler {
         public void act(Tree tree, FormContext context);
     }
-    
+
     private TreeDefinition treeDef;
 
     private TreeModel treeModel;
-    
+
     private Set expandedPaths = new HashSet();
-    
+
     private Set selectedPaths = new HashSet();
-    
+
     private Set changedPaths = new HashSet();
-    
+
     private HashMap pathWidgets = new HashMap();
-    
+
     private boolean rootVisible = true;
 
     private boolean expandSelectedPath = false;
-    
+
     private TreeSelectionListener selectionListener;
-    
+
     private int selectionModel = MULTIPLE_SELECTION;
-    
+
     private TreeModelListener modelListener = new TreeModelListener() {
         public void treeStructureChanged(TreeModelEvent event) {
             markForRefresh(event.getPath());
@@ -93,15 +93,15 @@
     }
 
     protected void generateItemSaxFragment(ContentHandler contentHandler, Locale locale)
throws SAXException {
-	    	throw new UnsupportedOperationException(this + " cannot be rendered using <ft:widget>.
Please use <ft:tree>.");
+        throw new UnsupportedOperationException(this + " cannot be rendered using <ft:widget>.
Please use <ft:tree>.");
     }
 
     public void readFromRequest(FormContext formContext) {
         //TODO: crawl open nodes, calling their widget's readFromRequest
-        
+
         Request req = formContext.getRequest();
         String paramName = getRequestParameterName();
-        
+
         //---------------------------------------------------------------------
         // Handle node selection using checkboxes named <id>$select
         //---------------------------------------------------------------------
@@ -112,7 +112,7 @@
             for (int i = 0; i < selectValues.length; i++) {
                 newSelection.add(TreePath.valueOf(selectValues[i]));
             }
-            
+
             // Check if all visible selections are in the new selection
             TreePath[] currentSelection = (TreePath[])this.selectedPaths.toArray(new TreePath[this.selectedPaths.size()]);
             for (int i = 0; i < currentSelection.length; i++) {
@@ -128,30 +128,30 @@
                 addSelectionPath((TreePath)iter.next());
             }
         }
-        
+
         //---------------------------------------------------------------------
         // Handle tree actions:
         // - action is in <name>$action
         // - path is in <name>$path
         //---------------------------------------------------------------------
         String action = req.getParameter(paramName + ":action");
-        
+
         if (action == null || action.length() == 0) {
             // Nothing more to do here
             return;
         }
-        
+
         getForm().setSubmitWidget(this);
         String pathValue = req.getParameter(paramName + ":path");
-        
+
         if (pathValue == null || pathValue.length() == 0) {
             //this.treeDef.getLogger().warn("No tree path given");
             return;
         }
-        
+
         // Parse the path
         TreePath path = TreePath.valueOf(pathValue);
-        
+
         if ("expand".equals(action)) {
             this.expandPath(path);
         } else if ("collapse".equals(action)) {
@@ -181,7 +181,7 @@
     public TreeModel getModel() {
         return this.treeModel;
     }
-    
+
     public void setModel(TreeModel model) {
         if (model == null) {
             model = DefaultTreeModel.UNSPECIFIED_MODEL;
@@ -190,31 +190,31 @@
         this.treeModel = model;
         model.addTreeModelListener(this.modelListener);
     }
-    
+
     private void markForRefresh(TreePath path) {
         this.changedPaths.add(path);
         getForm().addWidgetUpdate(this);
     }
-    
+
     //---------------------------------------------------------------------------------------------
     // Selection
     //---------------------------------------------------------------------------------------------
-    
+
     public void setSelectionModel(int model) {
         if (model < 0 || model > MULTIPLE_SELECTION) {
             throw new IllegalArgumentException("Illegal selection model " + model);
         }
-        
+
         if (model == this.selectionModel) {
             return;
         }
-        
+
         this.selectionModel = model;
         if (model == SINGLE_SELECTION && getSelectionCount() > 1) {
             clearSelection();
         }
     }
-    
+
     public int getSelectionCount() {
         return this.selectedPaths.size();
     }
@@ -226,29 +226,29 @@
             return (TreePath)this.selectedPaths.iterator().next();
         }
     }
-    
+
     public TreePath[] getSelectionPaths() {
         return (TreePath[])this.selectedPaths.toArray(new TreePath[this.selectedPaths.size()]);
     }
-    
+
     public boolean isPathSelected(TreePath path) {
         return this.selectedPaths.contains(path);
     }
-    
+
     public boolean isSelectionEmpty() {
         return this.selectedPaths.isEmpty();
     }
-    
+
     public void setSelectionPath(TreePath path) {
         clearSelection();
         addSelectionPath(path);
     }
-    
+
     public void setSelectionPaths(TreePath paths[]) {
         clearSelection();
         addSelectionPaths(paths);
     }
-    
+
     public void addSelectionPath(TreePath path) {
         if (this.selectionModel == SINGLE_SELECTION) {
             clearSelection();
@@ -264,7 +264,7 @@
             }
         }
     }
-    
+
     public void addSelectionPaths(TreePath paths[]) {
         if (this.selectionModel == SINGLE_SELECTION) {
             setSelectionPath(paths[0]);
@@ -285,14 +285,14 @@
             }
         }
     }
-    
+
     public void removeSelectionPaths(TreePath paths[]) {
         for (int i = 0; i < paths.length; i++) {
             removeSelectionPath(paths[i]);
             // FIXME: use array-based constructors of TreeSelectionEvent
         }
     }
-    
+
     public void clearSelection() {
         if (this.isSelectionEmpty()) {
             return;
@@ -308,23 +308,23 @@
             this.selectionListener.selectionChanged(new TreeSelectionEvent(this, paths, false));
         }
     }
-    
+
     public void addTreeSelectionListener(TreeSelectionListener listener) {
         this.selectionListener = WidgetEventMulticaster.add(this.selectionListener, listener);
     }
-    
+
     public void removeTreeSelectionListener(TreeSelectionListener listener) {
         this.selectionListener = WidgetEventMulticaster.remove(this.selectionListener, listener);
     }
-    
+
     //---------------------------------------------------------------------------------------------
     // Visibility, expand & collapse
     //---------------------------------------------------------------------------------------------
-    
+
     public boolean isCollapsed(TreePath path) {
         return !isExpanded(path);
     }
-    
+
     public boolean isExpanded(TreePath path) {
         if (this.expandedPaths.contains(path)) {
             // Ensure all parents are expanded
@@ -334,11 +334,11 @@
             return false;
         }
     }
-    
+
     /**
      * Returns true if the value identified by path is currently viewable,
      * which means it is either the root or all of its parents are expanded.
-     * Otherwise, this method returns false. 
+     * Otherwise, this method returns false.
      *
      * @return true if the node is viewable, otherwise false
      */
@@ -358,7 +358,7 @@
             return false;
         }
     }
-    
+
     public void makeVisible(TreePath path) {
         if (path != null) {
             TreePath parent = path.getParentPath();
@@ -367,11 +367,11 @@
             }
         }
     }
-    
+
     public boolean isRootVisible() {
         return this.rootVisible;
     }
-    
+
     public void setRootVisible(boolean visible) {
         if (this.rootVisible != visible) {
             this.markForRefresh(TreePath.ROOT_PATH);
@@ -382,7 +382,7 @@
             }
         }
     }
-    
+
     public void collapsePath(TreePath path) {
         if (path != null) {
             if (this.expandedPaths.remove(path)) {
@@ -398,15 +398,15 @@
             }
         }
     }
-    
+
     public void setExpandsSelectedPath(boolean value) {
         this.expandSelectedPath  = value;
     }
-    
+
     //---------------------------------------------------------------------------------------------
     // Widget management
     //---------------------------------------------------------------------------------------------
-    
+
     public Widget getWidgetForPath(TreePath path) {
         Widget result = (Widget)this.pathWidgets.get(path);
         if (result == null && !this.pathWidgets.containsKey(path)) {
@@ -416,15 +416,15 @@
             }
             this.pathWidgets.put(path, result);
         }
-        
+
         return result;
     }
-    
+
     private Widget createWidgetForPath(TreePath path) {
         //TODO
         return null;
     }
-    
+
     //---------------------------------------------------------------------------------------------
     // TreeNode widget, which is the actual parent of widgets contained in a node
     //---------------------------------------------------------------------------------------------

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/JavaTreeModelDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/JavaTreeModelDefinitionBuilder.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/JavaTreeModelDefinitionBuilder.java
(original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/JavaTreeModelDefinitionBuilder.java
Sat Sep 16 16:39:08 2006
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2005 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -33,7 +33,7 @@
 /**
  * Builds a {@link TreeModelDefinition} based on an arbitrary Java class.
  * Avalon lifecycle will be run on the target class when instanciated.
- * 
+ *
  * @version $Id$
  */
 public class JavaTreeModelDefinitionBuilder extends AbstractLogEnabled
@@ -41,7 +41,7 @@
 
     Context ctx;
     ServiceManager manager;
-    
+
     public void contextualize(Context context) throws ContextException {
         this.ctx = context;
     }
@@ -52,26 +52,26 @@
 
     public TreeModelDefinition build(Element treeModelElement) throws Exception {
         String className = DomHelper.getAttribute(treeModelElement, "class");
-        
+
         Class modelClass;
         try {
             modelClass = Thread.currentThread().getContextClassLoader().loadClass(className);
         } catch(Exception e) {
             throw new CascadingException("Cannot load class '" + className + "', at " +
-                    DomHelper.getLocation(treeModelElement), e);
+                                         DomHelper.getLocation(treeModelElement), e);
         }
-        
+
         if (!TreeModel.class.isAssignableFrom(modelClass)) {
             throw new Exception("Class '" + className + "' doesn't implement TreeModel, at
" +
-                    DomHelper.getLocation(treeModelElement));
+                                DomHelper.getLocation(treeModelElement));
         }
-        
+
         JavaTreeModelDefinition definition = new JavaTreeModelDefinition();
-        
+
         LifecycleHelper.setupComponent(definition, getLogger(), ctx, manager, null);
-        
+
         definition.setModelClass(modelClass);
-        
+
         return definition;
     }
 

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/TreeDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/TreeDefinitionBuilder.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/TreeDefinitionBuilder.java
(original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/TreeDefinitionBuilder.java
Sat Sep 16 16:39:08 2006
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2005 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,7 +29,7 @@
 
 /**
  * Builds a {@link org.apache.cocoon.forms.formmodel.tree.Tree}.
- * 
+ *
  * @version $Id$
  */
 public class TreeDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
@@ -40,13 +40,13 @@
         definition.makeImmutable();
         return definition;
     }
-    
+
     protected void setupDefinition(Element widgetElement, TreeDefinition definition) throws
Exception {
         super.setupDefinition(widgetElement, definition);
-        
+
         // Get the optional "root-visible" attribute
         definition.setRootVisible(DomHelper.getAttributeAsBoolean(widgetElement, "root-visible",
true));
-        
+
         // Get the optional "selection" attribute
         String selection = DomHelper.getAttribute(widgetElement, "selection", null);
         if (selection == null) {
@@ -57,16 +57,16 @@
             definition.setSelectionModel(Tree.SINGLE_SELECTION);
         } else {
             throw new Exception("Invalid value selection value '" + selection + "' at " +
-                    DomHelper.getLocation(widgetElement));
+                                DomHelper.getLocation(widgetElement));
         }
-        
+
         // Get the model optional element
         Element modelElt = DomHelper.getChildElement(widgetElement, FormsConstants.DEFINITION_NS,
"tree-model", false);
         if (modelElt != null) {
             String type = DomHelper.getAttribute(modelElt, "type");
             ServiceSelector selector =
                 (ServiceSelector)this.serviceManager.lookup(TreeModelDefinitionBuilder.ROLE
+ "Selector");
-            
+
             TreeModelDefinitionBuilder builder = (TreeModelDefinitionBuilder)selector.select(type);
             try {
                 definition.setModelDefinition(builder.build(modelElt));
@@ -75,7 +75,7 @@
                 serviceManager.release(selector);
             }
         }
-        
+
         // parse "on-selection-changed"
         Iterator iter = buildEventListeners(widgetElement, "on-selection-changed", TreeSelectionListener.class).iterator();
         while (iter.hasNext()) {



Mime
View raw message