incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject svn commit: r427402 [1/2] - in /incubator/adffaces/branches/matzew-component-renaming/trinidad: trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/ trinidad-build/src/main/resources/META-INF/maven-faces-plugin/render...
Date Tue, 01 Aug 2006 01:42:44 GMT
Author: matzew
Date: Mon Jul 31 18:42:43 2006
New Revision: 427402

URL: http://svn.apache.org/viewvc?rev=427402&view=rev
Log:
ADFFACES-66

Added:
    incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/ProcessTrainRenderer.java   (with props)
    incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/pda/ProcessTrainRenderer.java   (with props)
Modified:
    incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreProcessTrain.xml
    incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/renderers/trinidad/ProcessTrain.xml
    incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/DesktopRenderKit.java
    incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/pda/PdaRenderKit.java
    incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ProcessUtils.java
    incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/ProcessTrainRenderer.java
    incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/pda/ProcessTrainRenderer.java
    incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/uinode/nav/ProcessTrainFacesBean.java
    incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/resources/META-INF/faces-bean.properties

Modified: incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreProcessTrain.xml
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreProcessTrain.xml?rev=427402&r1=427401&r2=427402&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreProcessTrain.xml (original)
+++ incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreProcessTrain.xml Mon Jul 31 18:42:43 2006
@@ -30,172 +30,56 @@
     </icon>
     <component-type>org.apache.myfaces.trinidad.CoreProcessTrain</component-type>
     <component-class>org.apache.myfaces.trinidad.component.core.nav.CoreProcessTrain</component-class>
-    <property>
-      <description><![CDATA[the short description of the bean.  This text
-         is commonly used by user agents to display tooltip help text.]]>
-      </description>
-      <property-name>shortDesc</property-name>
-      <property-class>java.lang.String</property-class>
-      <property-extension>
-        <mfp:property-metadata>
-          <mfp:group>${md:getTranslatedString("CORE_GROUP")}</mfp:group>
-        </mfp:property-metadata>
-      </property-extension>
-    </property>
-    <property>
-      <description><![CDATA[the IDs of the components that should trigger a partial update.
-         This component will listen on the trigger components. If one of the
-         trigger components receives an event that will cause it to update
-         in some way, this component will request to be updated too.]]>
-      </description>
-      <property-name>partialTriggers</property-name>
-      <property-class>java.lang.String[]</property-class>
-    </property>
-    <property>
-      <description><![CDATA[an onclick Javascript handler.]]></description>
-      <property-name>onclick</property-name>
-      <property-class>java.lang.String</property-class>
-      <property-extension>
-        <mfp:property-metadata>
-          <mfp:group>${md:getTranslatedString("EVENTS_GROUP")}</mfp:group>
-        </mfp:property-metadata>
-      </property-extension>
-    </property>
-    <property>
-      <description><![CDATA[an ondblclick Javascript handler.]]></description>
-      <property-name>ondblclick</property-name>
-      <property-class>java.lang.String</property-class>
-      <property-extension>
-        <mfp:property-metadata>
-          <mfp:group>${md:getTranslatedString("EVENTS_GROUP")}</mfp:group>
-        </mfp:property-metadata>
-      </property-extension>
-    </property>
-    <property>
-      <description><![CDATA[an onmousedown Javascript handler.]]></description>
-      <property-name>onmousedown</property-name>
-      <property-class>java.lang.String</property-class>
-      <property-extension>
-        <mfp:property-metadata>
-          <mfp:group>${md:getTranslatedString("EVENTS_GROUP")}</mfp:group>
-        </mfp:property-metadata>
-      </property-extension>
-    </property>
-    <property>
-      <description><![CDATA[an onmouseup Javascript handler.]]></description>
-      <property-name>onmouseup</property-name>
-      <property-class>java.lang.String</property-class>
-      <property-extension>
-        <mfp:property-metadata>
-          <mfp:group>${md:getTranslatedString("EVENTS_GROUP")}</mfp:group>
-        </mfp:property-metadata>
-      </property-extension>
-    </property>
-    <property>
-      <description><![CDATA[an onmouseover Javascript handler.]]></description>
-      <property-name>onmouseover</property-name>
-      <property-class>java.lang.String</property-class>
-      <property-extension>
-        <mfp:property-metadata>
-          <mfp:group>${md:getTranslatedString("EVENTS_GROUP")}</mfp:group>
-        </mfp:property-metadata>
-      </property-extension>
-    </property>
-    <property>
-      <description><![CDATA[an onmousemove Javascript handler.]]></description>
-      <property-name>onmousemove</property-name>
-      <property-class>java.lang.String</property-class>
-      <property-extension>
-        <mfp:property-metadata>
-          <mfp:group>${md:getTranslatedString("EVENTS_GROUP")}</mfp:group>
-        </mfp:property-metadata>
-      </property-extension>
-    </property>
-    <property>
-      <description><![CDATA[an onmouseout Javascript handler.]]></description>
-      <property-name>onmouseout</property-name>
-      <property-class>java.lang.String</property-class>
-      <property-extension>
-        <mfp:property-metadata>
-          <mfp:group>${md:getTranslatedString("EVENTS_GROUP")}</mfp:group>
-        </mfp:property-metadata>
-      </property-extension>
-    </property>
-    <property>
-      <description><![CDATA[an onkeypress Javascript handler.]]></description>
-      <property-name>onkeypress</property-name>
-      <property-class>java.lang.String</property-class>
-      <property-extension>
-        <mfp:property-metadata>
-          <mfp:group>${md:getTranslatedString("EVENTS_GROUP")}</mfp:group>
-        </mfp:property-metadata>
-      </property-extension>
-    </property>
-    <property>
-      <description><![CDATA[an onkeydown Javascript handler.]]></description>
-      <property-name>onkeydown</property-name>
-      <property-class>java.lang.String</property-class>
-      <property-extension>
-        <mfp:property-metadata>
-          <mfp:group>${md:getTranslatedString("EVENTS_GROUP")}</mfp:group>
-        </mfp:property-metadata>
-      </property-extension>
-    </property>
-    <property>
-      <description><![CDATA[an onkeyup Javascript handler.]]></description>
-      <property-name>onkeyup</property-name>
-      <property-class>java.lang.String</property-class>
-      <property-extension>
-        <mfp:property-metadata>
-          <mfp:group>${md:getTranslatedString("EVENTS_GROUP")}</mfp:group>
-        </mfp:property-metadata>
-      </property-extension>
-    </property>
-    <property>
-      <description><![CDATA[the CSS style class of the bean.]]></description>
-      <property-name>styleClass</property-name>
-      <property-class>java.lang.String</property-class>
-      <property-extension>
-        <mfp:property-metadata>
-          <mfp:group>${md:getTranslatedString("CORE_GROUP")}</mfp:group>
-        </mfp:property-metadata>
-      </property-extension>
-    </property>
-    <property>
-      <description><![CDATA[the inline CSS style for this element]]></description>
-      <property-name>inlineStyle</property-name>
-      <property-class>java.lang.String</property-class>
-      <property-extension>
-        <mfp:property-metadata>
-          <mfp:group>${md:getTranslatedString("CORE_GROUP")}</mfp:group>
-        </mfp:property-metadata>
-      </property-extension>
-    </property>
+
+    <xi:include href="includes/CommonAttrs.xml" xpointer="/faces-config/component/*"/>
+    <xi:include href="includes/CoreJSEvents.xml" xpointer="/faces-config/component/*"/>
+
     <component-extension>
       <mfp:component-supertype>org.apache.myfaces.trinidad.Process</mfp:component-supertype>
       <mfp:renderer-type>org.apache.myfaces.trinidad.Train</mfp:renderer-type>
       <mfp:tag-name>tr:processTrain</mfp:tag-name>
       <mfp:tag-class>org.apache.myfaces.trinidadinternal.taglib.core.nav.CoreProcessTrainTag</mfp:tag-class>
-      <mfp:long-description><![CDATA[ProcessTrain is a UIXProcess component that renders a train.
-          A processTrain is a horizontal series of train stations connected by
-          a horizontal line. Each train station
-          is an image and text describing the page in the multi-page process.
-          <section name="Model">
+      <mfp:long-description>
+        <![CDATA[ProcessTrain is a UIXProcess component 
+        that renders a train. A processTrain is a horizontal series of train 
+        stations connected by a horizontal line. Each train station is an 
+        image and text describing the page in the multi-page process.
+        
+        <section name="Model">
           The train takes a model of type 
-          <html:code>org.apache.myfaces.trinidad.model.MenuModel</html:code>. The last node along the focusPath and its siblings are rendered.         
+          <html:code>org.apache.myfaces.adf.model.MenuModel</html:code>. The 
+          last node along the focusPath and its siblings are rendered.         
           <html:p>
-          MenuModel extends TreeModel, but it also knows how to go from the current viewId to the focus path. Notice that the menuModel has no special knowledge of page navigation and places no requirements on the nodes that go into the tree. The nodes in the tree are stamped out with the 'nodeStamp' facet, which should contain a commandNavigationItem component, which allows the default actionListener mechanism to be used for page navigation. 
+          MenuModel extends TreeModel, but it also knows how to go from the 
+          current viewId to the focus path. Notice that the menuModel has no 
+          special knowledge of page navigation and places no requirements on 
+          the nodes that go into the tree. The nodes in the tree are stamped 
+          out with the 'nodeStamp' facet, which should contain a 
+          commandNavigationItem component, which allows the default 
+          actionListener mechanism to be used for page navigation. 
           </html:p>  
           <html:p>
-          There are two common scenarios for processes, &quot;Plus One&quot; and &quot;Max Visited&quot; which are explained below. 
+          There are two common scenarios for processes, &quot;Plus One&quot; 
+          and &quot;Max Visited&quot; which are explained below. 
             <html:ul>
-              <html:li>&quot;Plus One&quot; - from the current step the user can navigate to any previous page and the next page. If the user is on the 5th step of a process and goes back to step 2, then the user can only navigate from step 2 to step 1 and step 3.               
+              <html:li>&quot;Plus One&quot; - from the current step the user can 
+              navigate to any previous page and the next page. If the user is on
+              the 5th step of a process and goes back to step 2, then the user 
+              can only navigate from step 2 to step 1 and step 3.               
               </html:li>
-              <html:li>&quot;Max Visited&quot; - the user can navigate to the max visited page. If the user is currently on the max visited page then the user can also navigate to the next page. If the user is on the 5th step of a process and goes back to step 2, then the user can navigate from step 2 to steps 1, 2, 3, 4, and 5.
+              <html:li>&quot;Max Visited&quot; - the user can navigate to the max 
+              visited page. If the user is currently on the max visited page 
+              then the user can also navigate to the next page. If the user is 
+              on the 5th step of a process and goes back to step 2, then the 
+              user can navigate from step 2 to steps 1, 2, 3, 4, and 5.
               </html:li>
             </html:ul>
             
-            The class <html:code>org.apache.myfaces.trinidad.model.ProcessMenuModel</html:code> and <html:code>org.apache.myfaces.trinidad.model.ProcessUtils</html:code> were created to support the &quot;Plus One&quot; and &quot;Max Visited&quot; scenarios. Please see the javadoc for these classes for more information. 
+            The class <html:code>org.apache.myfaces.adf.model.ProcessMenuModel</html:code> 
+            and <html:code>org.apache.myfaces.adf.model.ProcessUtils</html:code> 
+            were created to support the &quot;Plus One&quot; and 
+            &quot;Max Visited&quot; scenarios. Please see the javadoc for these
+            classes for more information. 
             
             <html:p>
             When the focusPath is not focused on a top level node, 
@@ -204,20 +88,19 @@
             part of a sub-process
             </html:p>
           </html:p>
-          
-          
           </section>]]>
       </mfp:long-description>
       <mfp:example>
         <xhtml:p>This is an example of a processTrain.</xhtml:p>
-        <mfp:source-code><![CDATA[<tr:processTrain var="node" value="#{processMenuModel}">
-  <f:facet name="nodeStamp">
-    <tr:commandNavigationItem text="#{node.label}"
-                        action="#{node.getOutcome}"
-                        immediate="#{processMenuModel.immediate}"
-                        readOnly="#{processMenuModel.readOnly}"/>
-  </f:facet>
-</tr:processTrain>]]>
+        <mfp:source-code>
+          <![CDATA[<af:processTrain var="node" value="#{processMenuModel}">
+          <f:facet name="nodeStamp">
+            <af:commandNavigationItem text="#{node.label}"
+              action="#{node.getOutcome}"
+              immediate="#{processMenuModel.immediate}"
+              readOnly="#{processMenuModel.readOnly}"/>
+          </f:facet>
+        </af:processTrain>]]>
         </mfp:source-code>
       </mfp:example>
       <mfp:author>Jeanne Waldman</mfp:author>

Modified: incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/renderers/trinidad/ProcessTrain.xml
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/renderers/trinidad/ProcessTrain.xml?rev=427402&r1=427401&r2=427402&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/renderers/trinidad/ProcessTrain.xml (original)
+++ incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/renderers/trinidad/ProcessTrain.xml Mon Jul 31 18:42:43 2006
@@ -21,7 +21,7 @@
     <renderer>
       <component-family>org.apache.myfaces.trinidad.Process</component-family>
       <renderer-type>org.apache.myfaces.trinidad.Train</renderer-type>
-      <renderer-class>org.apache.myfaces.trinidadinternal.renderkit.uix.ProcessRenderer</renderer-class>
+      <renderer-class>org.apache.myfaces.trinidadinternal.renderkit.core.desktop.ProcessRenderer</renderer-class>
       <renderer-extension>
         <mfp:component-type>org.apache.myfaces.trinidad.CoreProcessTrain</mfp:component-type>
       </renderer-extension>

Modified: incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/DesktopRenderKit.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/DesktopRenderKit.java?rev=427402&r1=427401&r2=427402&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/DesktopRenderKit.java (original)
+++ incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/DesktopRenderKit.java Mon Jul 31 18:42:43 2006
@@ -25,6 +25,9 @@
     addRenderer("org.apache.myfaces.trinidad.Table",
 		"org.apache.myfaces.trinidad.Table",
                 new DesktopTableRenderer());
+    addRenderer("org.apache.myfaces.trinidad.Process",
+    "org.apache.myfaces.trinidad.Train",
+                new ProcessTrainRenderer());
   }
 
   protected String getDecoratedRenderKitId()

Added: incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/ProcessTrainRenderer.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/ProcessTrainRenderer.java?rev=427402&view=auto
==============================================================================
--- incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/ProcessTrainRenderer.java (added)
+++ incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/ProcessTrainRenderer.java Mon Jul 31 18:42:43 2006
@@ -0,0 +1,817 @@
+/*
+ * Copyright  2003-2006 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.myfaces.trinidadinternal.renderkit.core.desktop;
+
+
+import java.io.IOException;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.event.ActionEvent;
+
+import org.apache.myfaces.trinidad.bean.FacesBean;
+import org.apache.myfaces.trinidad.logging.TrinidadLogger;
+import org.apache.myfaces.trinidad.component.UIXProcess;
+
+import org.apache.myfaces.trinidad.component.core.nav.CoreProcessTrain;
+
+import org.apache.myfaces.trinidadinternal.renderkit.RenderingContext;
+import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.FormData;
+import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.OutputUtils;
+import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.ProcessUtils;
+import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlConstants;
+import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlRenderer;
+import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlUtils;
+
+/**
+ * Renderer for process train components
+ * * <p>
+ */
+public class ProcessTrainRenderer
+  extends XhtmlRenderer
+{
+  /**
+   * Constructor.
+   */
+  public ProcessTrainRenderer()
+  {
+    super(CoreProcessTrain.TYPE);
+  }
+  
+  /**
+   */
+  public void decode(FacesContext context, UIComponent component)
+  {
+    Map requestMap = context.getExternalContext().getRequestParameterMap();
+
+    Object event = requestMap.get(XhtmlConstants.EVENT_PARAM);
+
+    if ((event != null) && event.equals(XhtmlConstants.GOTO_EVENT))
+    {
+      Object source = requestMap.get(XhtmlConstants.SOURCE_PARAM);
+
+      if (source != null && source.equals(component.getClientId(context)))
+      {
+
+        Object valueObject = requestMap.get(XhtmlConstants.VALUE_PARAM);
+
+        // we piggyback on the size parameter.
+        // 0 means we are moving to a previous step, 1 means we are
+        // moving to the next step.
+        Object sizeObject = requestMap.get(XhtmlConstants.SIZE_PARAM);
+
+        if (valueObject != null)
+        {
+          int value = -1;
+
+          try
+          {
+            value = Integer.parseInt(valueObject.toString());
+          }
+          catch (NumberFormatException nfe)
+          {
+            _LOG.severe(nfe);
+          }
+
+          int size = 0;
+
+          try
+          {
+            size = Integer.parseInt(sizeObject.toString());
+          }
+          catch (NumberFormatException nfe)
+          {
+            _LOG.warning(nfe);
+          }
+
+          if (size < 0)
+            size = 0;
+
+          if (value >= 0)
+          {
+            UIXProcess process = (UIXProcess) component;
+            Object oldPath = process.getRowKey();
+            Object focusPath = process.getFocusRowKey();
+            process.setRowKey(focusPath);
+            UIComponent stamp = process.getNodeStamp();
+            int index = process.getRowIndex();
+
+            if (size == 0)
+            {
+              index = ProcessUtils.getBackIndex(process, stamp, index);
+            }
+            else
+            {
+              index = ProcessUtils.getNextIndex(process, stamp, index);
+            }
+
+            process.setRowIndex(index);
+            new ActionEvent(stamp).queue();
+            process.setRowKey(oldPath);
+          }
+        }
+      }
+    }
+  }
+  
+  /**
+   * @return
+   */
+  public boolean getRendersChildren()
+  {
+    return true;
+  }
+
+  protected void encodeAll(
+    FacesContext context, 
+    RenderingContext arc, 
+    UIComponent component, 
+    FacesBean bean)
+    throws IOException
+  {
+    UIXProcess process = (UIXProcess) component;
+    UIComponent stamp = process.getNodeStamp();
+
+    if (stamp != null)
+    {
+      Object oldPath = process.getRowKey();
+      Object newPath = null;
+      boolean isNewPath = _setNewPath(process);
+      if (isNewPath)
+      {
+        ResponseWriter writer = context.getResponseWriter();
+
+        ProcessTrainRenderer.TrainState trainState = 
+        _getTrainState(context, arc, process);
+        _renderHiddenFields(context, arc, trainState);
+
+        writer.startElement("table", component);
+        OutputUtils.renderLayoutTableAttributes(context, arc, "0", null);
+        writer.writeAttribute("align", "center", null);
+        newPath = process.getRowKey();
+        process.setRowKey(oldPath);
+        renderId(context, component);
+        process.setRowKey(newPath);
+        renderAllAttributes(context, arc, bean);
+
+        int length = process.getRowCount();
+
+        if (length == 0)
+          return;
+
+        _encodeChildren(context, arc, process, stamp, trainState, length);
+
+        writer.endElement("table");
+
+        process.setRowKey(oldPath);
+      }
+    }
+  }
+
+  /**
+   * This is how we can render both the user defined styleClass and our
+   * component style class
+   */
+  protected void renderStyleAttributes(
+    FacesContext context, 
+    RenderingContext arc, 
+    FacesBean bean)
+    throws IOException
+  {
+    renderStyleAttributes(context, arc, bean, 
+                          XhtmlConstants.AF_PROCESS_TRAIN_STYLE_CLASS);
+  }
+
+
+  /**
+  * Initialize the station state
+  */
+  private void _initializeStationState(
+    FacesContext context, 
+    RenderingContext arc, 
+    ProcessTrainRenderer.TrainState train, 
+    ProcessTrainRenderer.StationState station, 
+    int currVisChildIndex, 
+    int prevVisChildIndex, 
+    int nextVisChildIndex, 
+    boolean isCurrChildDisabled, 
+    boolean isPrevChildDisabled, 
+    boolean isNextChildDisabled)
+  {
+    station.isPreviousLink = false;
+    station.isMoreLink = false;
+    station.isDisabled = false;
+    station.isNextDisabled = false;
+    station.isPrevDisabled = false;
+    station.index = currVisChildIndex;
+
+    // train.startIndex is the index into the List that is the
+    // start of the train. The algorithm is dependent upon the BLAF spec.
+    if (currVisChildIndex == train.startIndex - 1)
+    {
+      station.isPreviousLink = true;
+    }
+    else if (currVisChildIndex == train.startIndex + _MAX_NUM_LINK_INDEX)
+    {
+      station.isMoreLink = true;
+    }
+
+    // selected nodes cannot be disabled,
+    // so don't bother getting disabled attribute for the selected node
+
+    if (currVisChildIndex != NO_CHILD_INDEX && 
+        currVisChildIndex != train.selectedIndex)
+    {
+      station.isDisabled = isCurrChildDisabled;
+    }
+
+    // get disabled information about the previous and the next child.
+    // selectedIndex cannot act disabled
+    //
+    if (prevVisChildIndex != NO_CHILD_INDEX && 
+        prevVisChildIndex != train.selectedIndex)
+    {
+      station.isPrevDisabled = isPrevChildDisabled;
+    }
+
+    if (nextVisChildIndex != NO_CHILD_INDEX && 
+        nextVisChildIndex != train.selectedIndex)
+    {
+      station.isNextDisabled = isNextChildDisabled;
+
+    }
+
+    //
+    // get the selected and visited flags for our node
+    //
+    station.isSelected = (currVisChildIndex == train.selectedIndex);
+    station.isVisited = (currVisChildIndex <= train.maxVisitedIndex);
+    station.isNextVisited = (currVisChildIndex < train.maxVisitedIndex);
+    station.isNext = (currVisChildIndex == (train.maxVisitedIndex + 1));
+    // if previous station is "next", and disabled, mark this as "next".
+    if ((currVisChildIndex - 1 == (train.maxVisitedIndex + 1)) && 
+        (station.isPrevDisabled))
+    {
+      station.isNext = true;
+    }
+  }
+
+  /**
+   * Returns the MAX_VISITED_ATTR
+   * @todo =-=jmw Hopefully the controller will tell us this someday.
+   */
+  private static Object _getMaxVisited(
+    RenderingContext arc, 
+    UIComponent component)
+  {
+    // return component.getAttributes().get("maxVisited");
+    return null;
+  }
+
+  /**
+   * Get the maxVisited attribute from the node and return it.
+   */
+  private int _getMaxVisitedIndex(
+    RenderingContext arc, 
+    UIComponent component)
+  {
+    int maxVisitedIndex = NO_CHILD_INDEX;
+    Integer maxVisited = (Integer) _getMaxVisited(arc, component);
+    if (maxVisited != null)
+    {
+      maxVisitedIndex = maxVisited.intValue();
+    }
+    return maxVisitedIndex;
+  }
+
+  /**
+   * Return what the starting index into the stations List.
+   */
+  private int _getStartIndex(int numPages, int originalSelectedIndex)
+  {
+    int currentMinIndex = 0;
+
+    if (numPages <= _MAX_NUM_LINK_INDEX)
+      return currentMinIndex;
+
+    int selectedIndex = originalSelectedIndex;
+    int currentMaxIndex = _MAX_NUM_LINK_INDEX - 1;
+
+    if (selectedIndex < currentMaxIndex)
+    {
+      return currentMinIndex; //0
+    }
+
+    // the algorithm below works, but I thought it was too cryptic
+    // return (selectedIndex -
+    //            (((selectedIndex-1)%(_MAX_NUM_LINK_INDEX-2))+1));
+
+    // loop until the selectedIndex range is found or
+    // we have gone past the number of nodes in the train.
+    // Then we'll know what index to start the visible portion of the train.
+    while (numPages > currentMaxIndex)
+    {
+      currentMinIndex = currentMaxIndex - 1;
+      currentMaxIndex += (_MAX_NUM_LINK_INDEX - 2);
+      if (selectedIndex > currentMinIndex && 
+          selectedIndex < currentMaxIndex)
+        return currentMinIndex;
+    }
+
+    return currentMinIndex;
+  }
+
+
+  /**
+   * Gather up the train state: selectedIndex, maxVisitedIndex, startIndex,
+   *  isSubTrain, formName, id,.
+   *  This way all the parameters we need to pass around to various methods
+   *  are all in one place, the TrainState
+   * @param arc RenderingContext
+   * @param context FacesContext
+   * @param process the UIXProcess component.
+   * @return
+   */
+  private TrainState _getTrainState(
+    FacesContext context, 
+    RenderingContext arc, 
+    UIXProcess process)
+  {
+    ProcessTrainRenderer.TrainState state = 
+      new ProcessTrainRenderer.TrainState();
+
+    state.selectedIndex = process.getRowIndex();
+
+    // get highest node in train visited
+    state.maxVisitedIndex = _getMaxVisitedIndex(arc, process);
+
+    // default to selectedIndex if it wasn't set
+    // or if it was set to be greater than selectedIndex
+    if (state.maxVisitedIndex == NO_CHILD_INDEX || 
+        state.maxVisitedIndex < state.selectedIndex)
+    {
+      state.maxVisitedIndex = state.selectedIndex;
+    }
+
+    int totalPages = process.getRowCount();
+    state.startIndex = _getStartIndex(totalPages, state.selectedIndex);
+
+    state.subTrain = _isSubTrain(process);
+
+    state.formName = arc.getFormData().getName();
+
+    String id = process.getClientId(context);
+    state.id = (id != null)? id: null;
+
+    return state;
+  }
+
+
+  /**
+   * Get the subTrain attribute from the node and return it.
+   */
+  private boolean _isSubTrain(UIXProcess component)
+  {
+    Object focusRowKey = component.getFocusRowKey();
+    if (focusRowKey != null && (component.getDepth(focusRowKey) > 0))
+      return true;
+
+    return false;
+  }
+
+
+  private void _encodeChildren(
+    FacesContext context, 
+    RenderingContext arc, 
+    UIXProcess process, 
+    UIComponent stamp, 
+    TrainState train, 
+    int length)
+    throws IOException
+  {
+
+    ResponseWriter writer = context.getResponseWriter();
+
+    // start FOR SUBTRAIN
+    // If subTrain, add a row and on the first and last cells, render
+    // a border which looks like a sub-train
+    if (train.subTrain)
+    {
+      _renderSubTrainRow(context, arc, train, length, writer);
+
+      writer.startElement("tr", null);
+      writer.startElement("td", null);
+      writer.endElement("td");
+    }
+    else
+    {
+      writer.startElement("tr", null);
+    }
+
+    // loop through each rendered station.
+    int lastTrainIndex = train.startIndex + _getMaxLinks(arc, process);
+
+    if (length <= lastTrainIndex)
+    {
+      lastTrainIndex = length;
+    }
+    else
+    {
+      lastTrainIndex++; // length of train is larger than the visible
+      // number of train stations, so make room for the more
+      // by adding one to the lastTrainIndex.
+    }
+    int currVisChildIndex = Math.max(0, train.startIndex - 1);
+    boolean isPrevVisChildDisabled = false;
+    boolean isCurrVisChildDisabled = false;
+    boolean isNextVisChildDisabled = false;
+
+    process.setRowIndex(currVisChildIndex);
+
+    isCurrVisChildDisabled = 
+        Boolean.TRUE.equals(stamp.getAttributes().get("disabled"));
+    // getBooleanAttributeValue(context, stamp, DISABLED_ATTR, false);
+
+    for (; currVisChildIndex < lastTrainIndex; currVisChildIndex++)
+    {
+      //
+      // get index of the child and
+      // determine if it is within the range in which it will be rendered.
+      //
+      int prevVisChildIndex = 
+        ((currVisChildIndex == 0)? NO_CHILD_INDEX: currVisChildIndex - 1);
+      int nextVisChildIndex = 
+        ((currVisChildIndex == length - 1)? NO_CHILD_INDEX: 
+         currVisChildIndex + 1);
+
+      process.setRowIndex(nextVisChildIndex);
+
+      isNextVisChildDisabled = 
+          Boolean.TRUE.equals(stamp.getAttributes().get("disabled"));
+
+      process.setRowIndex(currVisChildIndex);
+
+      // initialized state of the station
+      ProcessTrainRenderer.StationState station = train.station;
+      _initializeStationState(context, arc, train, station, 
+                             currVisChildIndex, prevVisChildIndex, 
+                             nextVisChildIndex, isCurrVisChildDisabled, 
+                             isPrevVisChildDisabled, 
+                             isNextVisChildDisabled);
+
+      // set up for next pass
+      isPrevVisChildDisabled = isCurrVisChildDisabled;
+      isCurrVisChildDisabled = isNextVisChildDisabled;
+
+      Object label = stamp.getAttributes().get("text");
+
+      String currVisChildText = null;
+
+      // Get text from link, or Previous or More text if appropriate
+      currVisChildText = _getTextForStation(arc, station, label);
+
+      String currVisChildID = null;
+
+      process.setRowIndex(currVisChildIndex);
+      _renderLink(context, arc, stamp, writer, train, currVisChildText, 
+                 currVisChildID, station);
+
+    }
+
+    if (train.subTrain)
+    {
+      writer.startElement("td", null);
+      writer.endElement("td");
+    }
+
+    writer.endElement("tr");
+  }
+
+  /**
+   * Renders the link under the train node
+   *
+   */
+  private void _renderLink(
+    FacesContext context, 
+    RenderingContext arc, 
+    UIComponent stamp, 
+    ResponseWriter writer, 
+    ProcessTrainRenderer.TrainState train, 
+    String currVisChildText, 
+    String currVisChildID, 
+    ProcessTrainRenderer.StationState station)
+    throws IOException
+  {
+    //
+    // Write the link under the train node.
+    //
+    writer.startElement("td", null);
+    writer.writeAttribute("colspan", "2", null);
+
+    String styleClass = 
+      (station.isSelected)? XhtmlConstants.AF_PROCESS_TRAIN_ACTIVE_STYLE_CLASS: 
+      (station.isDisabled && !station.isMoreLink)? 
+      XhtmlConstants.AF_PROCESS_TRAIN_DISABLED_STYLE_CLASS: 
+      (station.isVisited)? 
+      XhtmlConstants.AF_PROCESS_TRAIN_VISITED_STYLE_CLASS: 
+      XhtmlConstants.AF_PROCESS_TRAIN_UNVISITED_STYLE_CLASS;
+
+    renderStyleClass(context, arc, styleClass);
+
+    Map originalResourceKeyMap = arc.getSkinResourceKeyMap();
+    try
+    {
+      arc.setSkinResourceKeyMap(_RESOURCE_KEY_MAP);
+      _renderStamp(context, stamp);
+    }
+    finally
+    {
+      arc.setSkinResourceKeyMap(originalResourceKeyMap);
+    }
+    writer.endElement("td");
+  }
+
+  /**
+   * Called to render a child.  This method does not update the
+   * rendering context (by calling pushChild() and popChild()
+   * as needed);  subclasses need to use renderIndexedChild() or
+   * renderNamedChild() for that purpose.
+   * <p>
+   * @param context the faces context
+   * @param child the child under consideration
+   */
+  private void _renderStamp(FacesContext context, UIComponent child)
+    throws IOException
+  {
+    if (child != null)
+    {
+      encodeChild(context, child);
+      // child.render(context);
+    }
+  }
+
+  /**
+  * return the string to use for the text of the station
+  * it is the text of the link or "Previous" or "More"
+  */
+  private String _getTextForStation(
+    RenderingContext arc, 
+    ProcessTrainRenderer.StationState station, 
+    Object textObj)
+  {
+    String textValue = (textObj == null)? null: textObj.toString();
+    final String currText;
+
+    if (textValue != null && !station.isPreviousLink && 
+        !station.isMoreLink)
+    {
+      // if we are in screen reader mode, then we must render more descriptive
+      // text.
+      // see bug 1801348 REMOVE ONE SET OF TRAIN TEXT IN ACCESSIBLE MODE
+      if (isScreenReaderMode(arc))
+      {
+        currText = _getDisabledUserText(arc, station, textValue);
+      }
+      else
+      {
+        currText = textValue;
+      }
+    }
+    else if (station.isPreviousLink)
+    {
+      currText = arc.getTranslatedString(_PREVIOUS_KEY);
+    }
+    else if (station.isMoreLink)
+    {
+      currText = arc.getTranslatedString(_MORE_KEY);
+    }
+    else
+      currText = null;
+
+    return currText;
+  }
+
+  private String _getDisabledUserText(
+    RenderingContext arc, 
+    ProcessTrainRenderer.StationState station, 
+    String textString)
+  {
+    String altTextKey = 
+      station.isSelected? _ACTIVE_KEY: station.isVisited? _VISITED_KEY: 
+                                       _NEXT_KEY;
+
+    String[] parameters = new String[]
+      { textString };
+
+    String altText = 
+      XhtmlUtils.getFormattedString(arc.getTranslatedString(altTextKey), 
+                                    parameters);
+    return altText;
+  }
+
+  /**
+   * Returns the max number of links to show
+   */
+  private int _getMaxLinks(
+    RenderingContext arc, 
+    UIComponent component)
+  {
+    return _MAX_NUM_LINK_INDEX;
+  }
+
+  private void _renderSubTrainRow(
+    FacesContext context, 
+    RenderingContext arc, 
+    ProcessTrainRenderer.TrainState train, 
+    int length, 
+    ResponseWriter writer)
+    throws IOException
+  {
+    boolean isRTL = arc.getLocaleContext().isRightToLeft();
+
+    writer.startElement("tr", null);
+
+    if (isRTL)
+      _renderSubTrainCell(context, arc, 
+                          XhtmlConstants.TRAIN_SUB_RIGHT_STYLE_CLASS, 
+                          writer);
+    else
+      _renderSubTrainCell(context, arc, 
+                          XhtmlConstants.AF_PROCESS_TRAIN_SUB_START_STYLE_CLASS, 
+                          writer);
+
+    _renderSubTrainBlankCells(train, length, writer);
+
+    if (isRTL)
+      _renderSubTrainCell(context, arc, 
+                          XhtmlConstants.AF_PROCESS_TRAIN_SUB_START_STYLE_CLASS, 
+                          writer);
+    else
+      _renderSubTrainCell(context, arc, 
+                          XhtmlConstants.TRAIN_SUB_RIGHT_STYLE_CLASS, 
+                          writer);
+
+    writer.endElement("tr");
+  }
+
+  private void _renderSubTrainCell(
+    FacesContext context, 
+    RenderingContext arc, 
+    String style, 
+    ResponseWriter writer)
+    throws IOException
+  {
+    writer.startElement("td", null);
+    renderStyleClass(context, arc, style);
+    renderSpacer(context, arc, "14", "2");
+    writer.endElement("td");
+  }
+
+  /**
+   * renders a td with colSpan equal to the number of visible stations
+   * including the Previous and More if they are there.
+   * @param train
+   * @param length
+   * @param writer
+   * @throws IOException
+   */
+  private void _renderSubTrainBlankCells(ProcessTrainRenderer.TrainState train, 
+                                         int length, ResponseWriter writer)
+    throws IOException
+  {
+    writer.startElement("td", null);
+
+    // figure out the number of stations
+    int startIndex = Math.max(0, train.startIndex - 1);
+    int lastTrainIndex = train.startIndex + _MAX_NUM_LINK_INDEX;
+    if (length <= lastTrainIndex)
+      lastTrainIndex = length;
+    else
+    {
+      // when the length of train is larger than the visible
+      // number of train stations, we render a More link.
+      // so make room for the more
+      // by adding one to the lastTrainIndex.
+      lastTrainIndex++;
+    }
+    String numberOfStations = 
+      Integer.toString((lastTrainIndex - startIndex) * 2);
+    writer.writeAttribute("colspan", numberOfStations, null);
+    writer.endElement("td");
+  }
+
+
+  private void _renderHiddenFields(
+    FacesContext context, 
+    RenderingContext arc, 
+    TrainState train)
+    throws IOException
+  {
+    if ((train.formName != null) && supportsScripting(arc))
+    {
+      // render hidden fields to hold the form data
+      FormData fData = arc.getFormData();
+      if (fData != null)
+      {
+        fData.addNeededValue(XhtmlConstants.EVENT_PARAM);
+        fData.addNeededValue(XhtmlConstants.SOURCE_PARAM);
+        fData.addNeededValue(XhtmlConstants.VALUE_PARAM);
+        fData.addNeededValue(XhtmlConstants.SIZE_PARAM);
+      }
+
+      // Render script submission code.
+      ProcessUtils.renderNavSubmitScript(context, arc);
+    }
+  }
+
+
+  private boolean _setNewPath(UIXProcess component)
+  {
+    Object focusPath = component.getFocusRowKey();
+    component.setRowKey(focusPath);
+    return true;
+  }
+
+  protected static class TrainState
+  {
+    public TrainState()
+    {
+      station = new ProcessTrainRenderer.StationState();
+    }
+    public int startIndex;
+    public int maxVisitedIndex;
+    public int selectedIndex;
+    public boolean subTrain;
+    public String formName;
+    public String id;
+    public ProcessTrainRenderer.StationState station;
+  }
+
+  protected static class StationState
+  {
+
+    public boolean isSelected;
+    // is this the station that is right AFTER the selected station.
+    public boolean isNext;
+    public boolean isVisited; // has this station been visited already?
+    public boolean isPreviousLink; // is this the Previous link?
+    public boolean isMoreLink; // is this the More link?
+    public boolean isDisabled; // is this station disabled?
+    public boolean isNextDisabled; // is the next station disabled?
+    public boolean isPrevDisabled; // is the previous station disabled?
+    public boolean isNextVisited; // is the next station visited?
+    public int index; // the index of this node
+  } //end StationState
+
+  private static final int  _MAX_NUM_LINK_INDEX = 
+    6; //number of visible links
+
+  /**
+ * The following keys are used to get at the corresponding translated
+ * strings.
+ */
+  private static final String _VISITED_KEY = "af_processTrain.VISITED_TIP";
+  private static final String _ACTIVE_KEY = "af_processTrain.ACTIVE_TIP";
+  private static final String _NEXT_KEY = "af_processTrain.NEXT_TIP";
+  private static final String _MORE_KEY = "af_processTrain.MORE";
+  private static final String _PREVIOUS_KEY = "af_processTrain.PREVIOUS";
+
+  private static final TrinidadLogger _LOG = 
+    TrinidadLogger.createTrinidadLogger(ProcessTrainRenderer.class);
+
+  // for now keep the OraLink/OraDisabledLink styles on the 'a', and
+  // append train link style class.
+  private static final Map _RESOURCE_KEY_MAP = new HashMap();
+  private static final String _TRAIN_DISABLED_LINK = 
+    XhtmlConstants.LINK_DISABLED_STYLE_CLASS + " " + 
+    XhtmlConstants.AF_PROCESS_TRAIN_LINK_STYLE_CLASS;
+  private static final String _TRAIN_ENABLED_LINK = 
+    XhtmlConstants.LINK_STYLE_CLASS + " " + 
+    XhtmlConstants.AF_PROCESS_TRAIN_LINK_STYLE_CLASS;
+  
+  static {
+    _RESOURCE_KEY_MAP.put(XhtmlConstants.LINK_DISABLED_STYLE_CLASS, 
+                          _TRAIN_DISABLED_LINK);
+    _RESOURCE_KEY_MAP.put(XhtmlConstants.LINK_STYLE_CLASS, 
+                          _TRAIN_ENABLED_LINK);
+  }
+
+}

Propchange: incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/ProcessTrainRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/desktop/ProcessTrainRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/pda/PdaRenderKit.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/pda/PdaRenderKit.java?rev=427402&r1=427401&r2=427402&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/pda/PdaRenderKit.java (original)
+++ incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/pda/PdaRenderKit.java Mon Jul 31 18:42:43 2006
@@ -25,6 +25,9 @@
     addRenderer("org.apache.myfaces.trinidad.Table",
 		"org.apache.myfaces.trinidad.Table",
                 new PdaTableRenderer());
+    addRenderer("org.apache.myfaces.trinidad.Process",
+    "org.apache.myfaces.trinidad.Train",
+                new ProcessTrainRenderer());
   }
 
   protected String getDecoratedRenderKitId()

Added: incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/pda/ProcessTrainRenderer.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/pda/ProcessTrainRenderer.java?rev=427402&view=auto
==============================================================================
--- incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/pda/ProcessTrainRenderer.java (added)
+++ incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/pda/ProcessTrainRenderer.java Mon Jul 31 18:42:43 2006
@@ -0,0 +1,123 @@
+/*
+ * Copyright  2003-2006 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.myfaces.trinidadinternal.renderkit.core.pda;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import javax.faces.context.ResponseWriter;
+
+import org.apache.myfaces.trinidad.bean.FacesBean;
+import org.apache.myfaces.trinidad.component.UIXProcess;
+import org.apache.myfaces.trinidad.component.core.nav.CoreProcessTrain;
+import org.apache.myfaces.trinidadinternal.renderkit.RenderingContext;
+import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlConstants;
+import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlRenderer;
+import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlUtils;
+import org.apache.myfaces.trinidadinternal.util.IntegerUtils;
+
+public class ProcessTrainRenderer
+  extends XhtmlRenderer
+{
+
+  /**
+   * Constructor.
+   */
+  public ProcessTrainRenderer()
+  {
+    super(CoreProcessTrain.TYPE);
+  }
+
+  protected void encodeAll(
+    FacesContext        context,
+    RenderingContext    arc,
+    UIComponent         component,
+    FacesBean           bean) throws IOException
+  {
+    UIXProcess process = (UIXProcess) component;          
+    UIComponent stamp = process.getNodeStamp();
+    
+    if(stamp != null)
+    { 
+      Object oldPath = process.getRowKey();      
+      boolean isNewPath = _setNewPath(process);
+      if (isNewPath)
+      {
+        int selectedIndex = process.getRowIndex();
+        int length = process.getRowCount();      
+        String pattern;
+        String[] parameters;
+        
+        selectedIndex++; 
+        
+        if (length == XhtmlConstants.MAX_VALUE_UNKNOWN)
+        {
+          pattern = arc.getTranslatedString(
+            _SINGLE_RANGE_FORMAT_NO_TOTAL_STRING);
+    
+          parameters = new String[]
+          {
+            arc.getTranslatedString(_STEP_TEXT_KEY),
+            IntegerUtils.getString(selectedIndex)
+          };
+          
+        }
+        else
+        {
+          pattern = arc.getTranslatedString(_SINGLE_RANGE_FORMAT_TOTAL_STRING);
+    
+          parameters = new String[]
+          {
+            arc.getTranslatedString(_STEP_TEXT_KEY),
+            IntegerUtils.getString(selectedIndex),
+            IntegerUtils.getString(length)
+          };
+        }
+
+        ResponseWriter writer = context.getResponseWriter();
+        String outputText = XhtmlUtils.getFormattedString(pattern, parameters); 
+        writer.writeText(outputText, null);
+        
+        process.setRowKey(oldPath);
+      }
+    }
+  }
+
+
+  public boolean getRendersChildren()
+  {
+    return true;
+  }
+  
+  private boolean _setNewPath(
+    UIXProcess component)
+  {
+    Object focusPath = component.getFocusRowKey();
+    component.setRowKey(focusPath);
+    return true;
+  }
+  
+  static private final String _STEP_TEXT_KEY = 
+    "af_processTrain.STEP";
+  static private final String _SINGLE_RANGE_FORMAT_TOTAL_STRING =
+    "af_processTrain.FORMAT_TOTAL";
+  static private final String _SINGLE_RANGE_FORMAT_NO_TOTAL_STRING =
+    "af_processTrain.FORMAT_NO_TOTAL";
+
+}

Propchange: incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/pda/ProcessTrainRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/pda/ProcessTrainRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ProcessUtils.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ProcessUtils.java?rev=427402&r1=427401&r2=427402&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ProcessUtils.java (original)
+++ incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ProcessUtils.java Mon Jul 31 18:42:43 2006
@@ -17,9 +17,11 @@
 
 import java.io.IOException;
 
+import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 
+import org.apache.myfaces.trinidad.component.UIXProcess;
 import org.apache.myfaces.trinidadinternal.renderkit.RenderingContext;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.jsLibs.Scriptlet;
 import org.apache.myfaces.trinidadinternal.util.IntegerUtils;
@@ -34,8 +36,6 @@
  */
 public class ProcessUtils
 {
-
-
   /**
    * Returns a String with the javascript function call _navSubmit
    */
@@ -74,6 +74,43 @@
   }
 
   /**
+ * @param component
+ * @param stamp
+ * @param startIndex
+ * @return
+ */
+  public static int getBackIndex(
+    UIXProcess component,
+    UIComponent stamp,
+    int startIndex)
+  {
+    int i = startIndex - 1;
+    while (i >= 0)
+    {
+      component.setRowIndex(i);
+      boolean disabled = Boolean.TRUE.equals(
+        stamp.getAttributes().get("disabled"));
+      boolean readOnly = Boolean.TRUE.equals(
+        stamp.getAttributes().get("readOnly"));
+      boolean rendered = stamp.isRendered();
+
+      // if this node is rendered and not disabled and not readOnly
+      // then it can be used as the back button node.
+      if (!disabled && !readOnly && rendered)
+      {
+        component.setRowIndex(startIndex);
+        return i;
+      }
+
+      i--;
+    }
+
+    component.setRowIndex(startIndex);
+    return NO_INDEX;
+
+  }
+
+  /**
    */
   public static String getChoiceOnChangeFormSubmitted(
     String           form,
@@ -104,6 +141,43 @@
     return buffer.toString();
   }
 
+
+  /**
+   * @param component
+   * @param stamp
+   * @param startIndex
+   * @return
+   */
+  public static int getNextIndex(
+    UIXProcess component, 
+    UIComponent stamp,
+    int startIndex)
+  {
+    int i = startIndex + 1;
+    int rowCount = component.getRowCount();
+    while (i < rowCount)
+    {
+      component.setRowIndex(i);
+      boolean disabled = Boolean.TRUE.equals(
+        stamp.getAttributes().get("disabled"));
+      boolean readOnly = Boolean.TRUE.equals(
+        stamp.getAttributes().get("readOnly"));
+      boolean rendered = stamp.isRendered();
+
+      // if this node is rendered and not disabled and not readOnly
+      // then it can be used as the back button node.
+      if (!disabled && !readOnly && rendered)
+      {
+        component.setRowIndex(startIndex);
+        return i;
+      }
+
+      i++;
+    }
+
+    component.setRowIndex(startIndex);
+    return NO_INDEX;
+  }
 
   public static void renderNavSubmitScript(
     FacesContext        context,

Modified: incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/ProcessTrainRenderer.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/ProcessTrainRenderer.java?rev=427402&r1=427401&r2=427402&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/ProcessTrainRenderer.java (original)
+++ incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/desktop/ProcessTrainRenderer.java Mon Jul 31 18:42:43 2006
@@ -1,890 +0,0 @@
-/*
- * Copyright  2000-2006 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.myfaces.trinidadinternal.ui.laf.base.desktop;
-
-import java.io.IOException;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.context.ResponseWriter;
-
-import org.apache.myfaces.trinidad.logging.TrinidadLogger;
-import org.apache.myfaces.trinidad.component.UIXHierarchy;
-
-import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlConstants;
-import org.apache.myfaces.trinidadinternal.share.url.URLEncoder;
-import org.apache.myfaces.trinidadinternal.ui.UIXRenderingContext;
-import org.apache.myfaces.trinidadinternal.ui.UINode;
-import org.apache.myfaces.trinidadinternal.ui.laf.base.xhtml.FormValueRenderer;
-import org.apache.myfaces.trinidadinternal.ui.laf.base.xhtml.ProcessUtils;
-import org.apache.myfaces.trinidadinternal.ui.laf.base.xhtml.XhtmlLafUtils;
-
-/**
- * @version $Name:  $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/ui/laf/base/desktop/ProcessTrainRenderer.java#0 $) $Date: 10-nov-2005.18:56:11 $
- * @author The Oracle ADF Faces Team
-
- */
-public class ProcessTrainRenderer extends HtmlLafRenderer
-{
-
-  protected UIXHierarchy getHierarchyBase(
-    UIXRenderingContext context,
-    UINode           node
-  )
-  {
-    return (UIXHierarchy) node.getUIComponent();
-  }
-
-
-  protected UINode getStamp(
-    UIXRenderingContext context,
-    UINode           node
-    )
-  {
-    return node.getNamedChild(context, NODE_STAMP_CHILD);
-  }
-
-
-  protected boolean setNewPath(
-    UIXRenderingContext context,
-    UINode           node,
-    UIXHierarchy    component
-  )
-  {
-    Object focusPath = component.getFocusRowKey();
-    component.setRowKey(focusPath);
-    return true;
-
-
-  }
-
-
-  protected void renderAttributes(
-    UIXRenderingContext context,
-    UINode           node
-    ) throws IOException
-  {
-    super.renderAttributes(context, node);
-    renderLayoutTableAttributes(context, "0", null);
-    context.getResponseWriter().writeAttribute("align", "center", null);
-  }
-
-  /* this is how we can render both the user defined styleClass and our
-   * component style class
-   */
-  protected void renderStyleAttrs(
-    UIXRenderingContext context,
-    UINode           node
-  ) throws IOException
-  {
-    renderStyleAttrs(context, node, AF_PROCESS_TRAIN_STYLE_CLASS);
-  }
-
-  protected String getElementName(
-    UIXRenderingContext context,
-    UINode           node
-    )
-  {
-    return "table";
-  }
-
-  /**
-   * Overrride to render in two passes.  The first pass is the graphical
-   * elements.  The second pass is the text elements.
-   */
-  protected void renderContent(
-    UIXRenderingContext context,
-    UINode           node
-    ) throws IOException
-  {
-    UIXHierarchy component = getHierarchyBase(context, node);
-    UINode stamp = getStamp(context, node);
-
-    if(stamp != null)
-    {
-      Object oldPath = component.getRowKey();
-      boolean isNewPath = setNewPath(context, node, component);
-      if (isNewPath)
-      {
-
-        ProcessTrainRenderer.TrainState state =
-            getTrainState(context, node, component);
-
-
-        renderHiddenFields( context, node, state);
-
-        renderContent(context, node, component, stamp, state);
-
-        component.setRowKey(oldPath);
-      }
-    }
-  }
-
-  protected void logProcessTrainModelTypeError()
-  {
-    if (_LOG.isFine())
-      _LOG.fine("The value model type for process components " +
-                "must be a List of Page objects");
-  }
-
-  protected void renderHiddenFields(
-    UIXRenderingContext context,
-    UINode           node,
-    TrainState       state
-  )throws IOException
-  {
-
-    if ((state.formName != null) && supportsScripting(context))
-    {
-      // render hidden fields to hold the form data
-      FormValueRenderer.addNeededValue( context,
-                                        state.formName,
-                                        state.eventKey,
-                                        state.sourceKey,
-                                        state.valueKey,
-                                        state.sizeKey);
-
-      // Render script submission code.
-      ProcessUtils.renderNavSubmitScript(context);
-    }
-  }
-
-  /**
-   * Gather up the train state: selectedIndex, maxVisitedIndex, startIndex,
-   *  isSubTrain, readOnly, formName, id, eventKey, sourceKey, valueKey
-   *  This way all the parameters we need to pass around to various methods
-   *  are all in one place, the TrainState
-   * @param context RenderingContext
-   * @param node the processTrain node.
-   * @param pages a List of Page objects.
-   * @return
-   */
-  protected TrainState getTrainState(
-    UIXRenderingContext context,
-    UINode           node,
-    UIXHierarchy    component
-  )
-  {
-    ProcessTrainRenderer.TrainState state =
-      new ProcessTrainRenderer.TrainState();
-    state.selectedIndex = component.getRowIndex();
-
-    // get highest node in train visited
-    state.maxVisitedIndex = _getMaxVisitedIndex(context, node);
-    //
-    // default to selectedIndex if it wasn't set
-    // or if it was set to be greater than selectedIndex
-    if (state.maxVisitedIndex == NO_CHILD_INDEX ||
-        state.maxVisitedIndex < state.selectedIndex)
-    {
-      state.maxVisitedIndex = state.selectedIndex;
-    }
-
-    int totalPages = component.getRowCount();
-    state.startIndex = _getStartIndex(totalPages,
-                                      state.selectedIndex);
-
-    state.subTrain = _isSubTrain(context, node);
-
-    state.readOnly = _isReadOnly(context, node);
-
-    state.formName = XhtmlLafUtils.getSubmitFormName(context, node);
-    Object id = getID(context, node);
-    state.id = (id != null) ? id.toString() : null;
-
-    URLEncoder encoder = context.getURLEncoder();
-    state.eventKey  = encoder.encodeParameter(EVENT_PARAM);
-    state.sourceKey = encoder.encodeParameter(SOURCE_PARAM);
-    state.valueKey  = encoder.encodeParameter(VALUE_PARAM);
-    state.sizeKey  = encoder.encodeParameter(SIZE_PARAM);
-
-    return state;
-  }
-
-
-  /**
-   * return what the starting index into the stations List.
-   */
-  private int _getStartIndex(
-    int numPages,
-    int originalSelectedIndex)
-  {
-    int currentMinIndex = 0;
-
-    if (numPages <= _MAX_NUM_LINK_INDEX)
-      return currentMinIndex;
-
-    int selectedIndex = originalSelectedIndex;
-
-
-    int currentMaxIndex = _MAX_NUM_LINK_INDEX - 1;
-
-    if(selectedIndex < currentMaxIndex)
-    {
-      return currentMinIndex; //0
-    }
-    // the algorithm below works, but I thought it was too cryptic
-    // return (selectedIndex -
-    //            (((selectedIndex-1)%(_MAX_NUM_LINK_INDEX-2))+1));
-
-    // loop until the selectedIndex range is found or
-    // we have gone past the number of nodes in the train.
-    // Then we'll know what index to start the visible portion of the train.
-    while(numPages > currentMaxIndex)
-    {
-      currentMinIndex = currentMaxIndex-1;
-      currentMaxIndex += (_MAX_NUM_LINK_INDEX-2);
-      if(selectedIndex > currentMinIndex && selectedIndex < currentMaxIndex)
-        return currentMinIndex;
-    }
-
-    return currentMinIndex;
-
-  }
-
-
-  /**
-  * Get the subTrain attribute from the node and return it.
-  */
-  private boolean _isSubTrain(
-    UIXRenderingContext context,
-    UINode node)
-  {
-    UIXHierarchy component = getHierarchyBase(context, node);
-    Object focusRowKey = component.getFocusRowKey();
-    if ( focusRowKey != null && (component.getDepth(focusRowKey) > 0))
-      return true;
-
-    return false;
-  }
-
-  /**
-  * Returns true if READ_ONLY_ATTR is set to Boolean.TRUE
-  */
-  private static boolean _isReadOnly(
-    UIXRenderingContext context,
-    UINode           node
-    )
-  {
-    return
-      getBooleanAttributeValue(context, node, READ_ONLY_ATTR, Boolean.FALSE);
-  }
-
-  /**
-  * Returns the MAX_VISITED_ATTR
-  * @todo =-=jmw Hopefully the controller will tell us this someday.
-  */
-  protected static Object _getMaxVisited(
-    UIXRenderingContext context,
-    UINode           node
-    )
-  {
-   // return node.getAttributeValue(context, MAX_VISITED_ATTR);
-   return null;
-  }
-
-  /**
-  * Get the maxVisited attribute from the node and return it.
-  */
-  private int _getMaxVisitedIndex(
-    UIXRenderingContext context,
-    UINode node)
-  {
-    int maxVisitedIndex = NO_CHILD_INDEX;
-    Integer  maxVisited = (Integer)_getMaxVisited(context, node);
-    if (maxVisited != null)
-    {
-      maxVisitedIndex = maxVisited.intValue();
-    }
-    return maxVisitedIndex;
-  }
-
-
-
-
-
-  /**
-   *
-   *
-   */
-  protected void renderContent(
-    UIXRenderingContext context,
-    UINode           node,
-    UIXHierarchy    component,
-    UINode           stamp,
-    TrainState       train
-  ) throws IOException
-  {
-
-    int length = component.getRowCount();
-    if (length == 0)
-      return;
-
-    ResponseWriter writer = context.getResponseWriter();
-
-    // start FOR SUBTRAIN
-    // If subTrain, add a row and on the first and last cells, render
-    // a border which looks like a sub-train
-    if (train.subTrain)
-    {
-      _renderSubTrainRow(context, train, length, writer);
-
-      writer.startElement("tr", null);
-      writer.startElement("td", null);
-      writer.endElement("td");
-    }
-    else
-    {
-      writer.startElement("tr", null);
-    }
-
-    // loop through each rendered station.
-
-   int lastTrainIndex = train.startIndex + getMaxLinks(context, node);
-    if (length <= lastTrainIndex)
-      lastTrainIndex = length;
-    else
-      lastTrainIndex++; // length of train is larger than the visible
-                        // number of train stations, so make room for the more
-                        // by adding one to the lastTrainIndex.
-
-    int currVisChildIndex =  Math.max(0, train.startIndex - 1);
-    boolean isPrevVisChildDisabled = false;
-    boolean isCurrVisChildDisabled = false;
-    boolean isNextVisChildDisabled = false;
-
-    component.setRowIndex(currVisChildIndex);
-    isCurrVisChildDisabled = getBooleanAttributeValue(context,
-                                                    stamp,
-                                                    DISABLED_ATTR,
-                                                    false);
-    for (; currVisChildIndex < lastTrainIndex; currVisChildIndex++)
-    {
-      //
-      // get index of the child and
-      // determine if it is within the range in which it will be rendered.
-      //
-      int prevVisChildIndex = ((currVisChildIndex == 0)
-                               ? NO_CHILD_INDEX
-                               : currVisChildIndex  - 1);
-      int nextVisChildIndex = ((currVisChildIndex == length - 1)
-                               ? NO_CHILD_INDEX
-                               : currVisChildIndex  + 1);
-
-      component.setRowIndex(nextVisChildIndex);
-      isNextVisChildDisabled = getBooleanAttributeValue(context,
-                                                      stamp,
-                                                      DISABLED_ATTR,
-                                                      false);
-
-      component.setRowIndex(currVisChildIndex);
-
-      // initialized state of the station
-      ProcessTrainRenderer.StationState station = train.station;
-      initializeStationState(
-         context,
-         train,
-         station,
-         currVisChildIndex,
-         prevVisChildIndex,
-         nextVisChildIndex,
-         isCurrVisChildDisabled,
-         isPrevVisChildDisabled,
-         isNextVisChildDisabled
-         );
-
-      // set up for next pass
-      isPrevVisChildDisabled = isCurrVisChildDisabled;
-      isCurrVisChildDisabled = isNextVisChildDisabled;
-
-      Object label = stamp.getAttributeValue(context, TEXT_ATTR);
-
-      String currVisChildText = null;
-
-      // Get text from link, or Previous or More text if appropriate
-      currVisChildText = getTextForStation(context, station, label);
-
-      String currVisChildID = null;
-
-      component.setRowIndex(currVisChildIndex);
-      renderLink(context,
-                 stamp,
-                 writer,
-                 train,
-                 currVisChildText,
-                 currVisChildID,
-                 station);
-
-    }
-
-    if (train.subTrain)
-    {
-      writer.startElement("td", null);
-      writer.endElement("td");
-    }
-
-    writer.endElement("tr");
-  }
-
-
-
-  /**
-   * Renders the link under the train node
-   *
-   */
-  protected void renderLink(
-    UIXRenderingContext context,
-    UINode           stamp,
-    ResponseWriter   writer,
-    ProcessTrainRenderer.TrainState train,
-    String           currVisChildText,
-    String           currVisChildID,
-    ProcessTrainRenderer.StationState station
-    ) throws IOException
-  {
-
-
-    //
-    // Write the link under the train node.
-    //
-    writer.startElement("td", null);
-    writer.writeAttribute("colspan", "2", null);
-
-    String styleClass =  (station.isSelected)
-                          ? AF_PROCESS_TRAIN_ACTIVE_STYLE_CLASS
-                          : (station.isDisabled && !station.isMoreLink)
-                          ? AF_PROCESS_TRAIN_DISABLED_STYLE_CLASS
-                          : (station.isVisited)
-                          ? AF_PROCESS_TRAIN_VISITED_STYLE_CLASS
-                          : AF_PROCESS_TRAIN_UNVISITED_STYLE_CLASS;
-
-    renderStyleClassAttribute(context, styleClass);
-
-    Map originalResourceKeyMap = context.getSkinResourceKeyMap();
-    try
-    {
-      context.setSkinResourceKeyMap(_RESOURCE_KEY_MAP);
-      renderChild(context, stamp);
-    }
-    finally
-    {
-      context.setSkinResourceKeyMap(originalResourceKeyMap);
-    }
-/*
-    // if there should be a link, render it
-    // If the processTrain is read-only, then don't render the link, but
-    // still render the text.
-    if (!train.readOnly && (
-        station.isPreviousLink ||
-        (station.isMoreLink&&station.isVisited) ||
-        (!station.isSelected && !station.isDisabled &&
-        (station.isVisited || station.isNext) )))
-    {
-
-      UINode currLink = null;
-
-      // If we don't support navigation (e.g., printable pages),
-      // lie and claim we support scripting (even though we probably don't).
-      // This will give us the highest fidelity output - that is,
-      // we avoid creating submit buttons.
-
-      if (supportsScripting(context) ||
-          !supportsNavigation(context))
-      {
-
-        String destination =
-          ProcessUtils.getSubmitScriptCall(
-              context,
-              train.formName,
-              train.eventKey,
-              train.sourceKey,
-              train.id,
-              train.valueKey,
-              station.index,
-              train.sizeKey,
-              (station.index > train.selectedIndex)
-              ? 1 : 0,// 0 means back, 1 means next
-              false, null, null);
-
-        currLink = _createSingleItemLink(
-                      currVisChildText,
-                      currVisChildID,
-                      destination);
-      }
-      else
-      {
-        currLink= ProcessUtils.createSubmitButton(
-                                          context,
-                                          currVisChildText,
-                                          null,
-                                          currVisChildID,
-                                          train.formName,
-                                          false,
-                                          train.eventKey,
-                                          train.sourceKey,
-                                          train.id,
-                                          train.valueKey,
-                                          station.index,
-                                          train.sizeKey,
-                                          (station.index > train.selectedIndex)
-                                          ? 1 : 0);
-
-      }
-
-
-      currLink.render(context);
-    }
-    else
-    {
-      writer.startElement(SPAN_ELEMENT, null);
-      renderID(context, currVisChildID, false);
-      writer.writeText(currVisChildText, null);
-      writer.endElement(SPAN_ELEMENT);
-    }*/
-
-    writer.endElement("td");
-  }
-
-
-  /**
-  * return the string to use for the text of the station
-  * it is the text of the link or "Previous" or "More"
-  */
-  protected String getTextForStation(UIXRenderingContext context,
-                                    ProcessTrainRenderer.StationState station,
-                                    Object textObj)
-  {
-    String textValue = (textObj == null) ? null : textObj.toString();
-    final String currText;
-
-    if (textValue != null && !station.isPreviousLink && !station.isMoreLink)
-    {
-      // if we are in screen reader mode, then we must render more descriptive
-      // text.
-      // see bug 1801348 REMOVE ONE SET OF TRAIN TEXT IN ACCESSIBLE MODE
-      if (isScreenReaderMode(context))
-      {
-        currText = _getDisabledUserText(context, station, textValue);
-      }
-      else
-      {
-        currText = textValue;
-      }
-    }
-    else if(station.isPreviousLink)
-    {
-      currText = getTranslatedString(context, _PREVIOUS_KEY);
-    }
-    else if(station.isMoreLink)
-    {
-      currText = getTranslatedString(context, _MORE_KEY);
-    }
-    else
-      currText = null;
-
-    return currText;
-  }
-
-  /**
-  * return the string to use for the text of the station
-  * it is the text of the link or "Previous" or "More"
-  */
-  protected static String getIDForStation(
-    UIXRenderingContext context,
-    ProcessTrainRenderer.StationState station,
-    Object idValue)
-  {
-
-    if (idValue != null && !station.isPreviousLink && !station.isMoreLink)
-    {
-      return idValue.toString();
-    }
-
-    return null;
-  }
-
-  private String _getDisabledUserText(UIXRenderingContext context,
-                                      ProcessTrainRenderer.StationState station,
-                                      String textString)
-  {
-    String altTextKey = station.isSelected
-      ? _ACTIVE_KEY
-      : station.isVisited
-      ? _VISITED_KEY
-      : _NEXT_KEY;
-
-    String[] parameters = new String[]
-    {
-      textString
-    };
-
-    String altText = formatString(context,
-                                  getTranslatedString(context, altTextKey),
-                                  parameters);
-    return altText;
-  }
-
-  protected String getAltText(
-    UIXRenderingContext context,
-    ProcessTrainRenderer.StationState station,
-    String textString)
-  {
-    // if we are in screen reader mode, then we must not render any alt text
-    // on the image. However, we can't return null since OAC will
-    // complain, so return "":
-    // see bug 1801348 REMOVE ONE SET OF TRAIN TEXT IN ACCESSIBLE MODE
-
-    return isInaccessibleMode(context)
-      ? null
-      : isScreenReaderMode(context)
-      ? ""
-      : _getDisabledUserText(context, station, textString);
-  }
-
-  /**
-  * Returns the max number of links to show
-  */
-  protected int getMaxLinks(
-    UIXRenderingContext context,
-    UINode           node
-    )
-  {
-    return _MAX_NUM_LINK_INDEX;
-  }
-
-  /**
-  * Initialize the station state
-  */
-  protected void initializeStationState(
-    UIXRenderingContext context,
-    ProcessTrainRenderer.TrainState train,
-    ProcessTrainRenderer.StationState station,
-    int              currVisChildIndex,
-    int              prevVisChildIndex,
-    int              nextVisChildIndex,
-    boolean          isCurrChildDisabled,
-    boolean          isPrevChildDisabled,
-    boolean          isNextChildDisabled
-)
-  {
-
-
-    station.isPreviousLink = false;
-    station.isMoreLink = false;
-    station.isDisabled = false;
-    station.isNextDisabled = false;
-    station.isPrevDisabled = false;
-    station.index = currVisChildIndex;
-
-    // train.startIndex is the index into the List that is the
-    // start of the train. The algorithm is dependent upon the BLAF spec.
-    if( currVisChildIndex == train.startIndex-1)
-    {
-      station.isPreviousLink = true;
-    }
-    else if (currVisChildIndex == train.startIndex+_MAX_NUM_LINK_INDEX)
-    {
-      station.isMoreLink = true;
-    }
-
-    // selected nodes cannot be disabled,
-    // so don't bother getting disabled attribute for the selected node
-
-    if (currVisChildIndex != NO_CHILD_INDEX &&
-        currVisChildIndex != train.selectedIndex)
-    {
-      station.isDisabled = isCurrChildDisabled;
-    }
-
-
-    // get disabled information about the previous and the next child.
-    // selectedIndex cannot act disabled
-    //
-    if (prevVisChildIndex != NO_CHILD_INDEX &&
-        prevVisChildIndex != train.selectedIndex)
-    {
-      station.isPrevDisabled =  isPrevChildDisabled;
-    }
-
-    if (nextVisChildIndex != NO_CHILD_INDEX &&
-        nextVisChildIndex != train.selectedIndex)
-    {
-      station.isNextDisabled = isNextChildDisabled;
-
-    }
-
-    //
-    // get the selected and visited flags for our node
-    //
-    station.isSelected = (currVisChildIndex == train.selectedIndex);
-    station.isVisited  = (currVisChildIndex <= train.maxVisitedIndex);
-    station.isNextVisited = (currVisChildIndex < train.maxVisitedIndex);
-    station.isNext = (currVisChildIndex == (train.maxVisitedIndex+1));
-    // if previous station is "next", and disabled, mark this as "next".
-    if ((currVisChildIndex-1 == (train.maxVisitedIndex+1)) &&
-        (station.isPrevDisabled))
-    {
-      station.isNext = true;
-    }
-  }
-
-  protected static class TrainState
-  {
-    public TrainState()
-    {
-      station = new ProcessTrainRenderer.StationState();
-    }
-    public int startIndex;
-    public int maxVisitedIndex;
-    public int selectedIndex;
-    public boolean subTrain;
-    public boolean readOnly;
-    public String formName;
-    public String id;
-    public String eventKey;
-    public String sourceKey;
-    public String valueKey;
-    public String sizeKey;
-    public ProcessTrainRenderer.StationState station;
-  }
-
-  protected static class StationState
-  {
-
-    public boolean isSelected;
-    // is this the station that is right AFTER the selected station.
-    public boolean isNext;
-    public boolean isVisited;// has this station been visited already?
-    public boolean isPreviousLink; // is this the Previous link?
-    public boolean isMoreLink;  // is this the More link?
-    public boolean isDisabled; // is this station disabled?
-    public boolean isNextDisabled; // is the next station disabled?
-    public boolean isPrevDisabled;// is the previous station disabled?
-    public boolean isNextVisited; // is the next station visited?
-    public int index; // the index of this node
-  } //end StationState
-
-  private void _renderSubTrainRow(
-    UIXRenderingContext         context,
-    ProcessTrainRenderer.TrainState train,
-    int                      length,
-    ResponseWriter           writer
-    ) throws IOException
-  {
-    boolean isRTL = isRightToLeft(context);
-
-    writer.startElement("tr", null);
-
-    if (isRTL)
-      _renderSubTrainCell(context, TRAIN_SUB_RIGHT_STYLE_CLASS, writer);
-    else
-      _renderSubTrainCell(context, AF_PROCESS_TRAIN_SUB_START_STYLE_CLASS, writer);
-
-    _renderSubTrainBlankCells(train, length, writer);
-
-    if (isRTL)
-      _renderSubTrainCell(context, AF_PROCESS_TRAIN_SUB_START_STYLE_CLASS, writer);
-    else
-      _renderSubTrainCell(context, TRAIN_SUB_RIGHT_STYLE_CLASS, writer);
-
-    writer.endElement("tr");
-  }
-
-  private void _renderSubTrainCell(
-    UIXRenderingContext context,
-    String           style,
-    ResponseWriter   writer
-    ) throws IOException
-  {
-    writer.startElement("td", null);
-    renderStyleClassAttribute(context, style);
-    renderSpacer(context, "14", "2");
-    writer.endElement("td");
-  }
-  /**
-   * renders a td with colSpan equal to the number of visible stations
-   * including the Previous and More if they are there.
-   * @param context
-   * @param length
-   * @param output
-   * @param train
-   * @throws IOException
-   */
-  private void _renderSubTrainBlankCells(
-    ProcessTrainRenderer.TrainState train,
-    int                      length,
-    ResponseWriter           writer
-    ) throws IOException
-  {
-    writer.startElement("td", null);
-
-    // figure out the number of stations
-    int startIndex = Math.max(0, train.startIndex - 1);
-    int lastTrainIndex = train.startIndex + _MAX_NUM_LINK_INDEX;
-    if (length <= lastTrainIndex)
-      lastTrainIndex = length;
-    else
-    {
-      // when the length of train is larger than the visible
-      // number of train stations, we render a More link.
-      // so make room for the more
-      // by adding one to the lastTrainIndex.
-      lastTrainIndex++;
-    }
-    String numberOfStations = Integer.toString((lastTrainIndex - startIndex)*2);
-    writer.writeAttribute("colspan", numberOfStations, null);
-    writer.endElement("td");
-  }
-
-
-
-  private static final int _MAX_NUM_LINK_INDEX = 6; //number of visible links
-
-  /**
-   * The following keys are used to get at the corresponding translated
-   * strings.
-   */
-  private static final String _VISITED_KEY  = "af_processTrain.VISITED_TIP";
-  private static final String _ACTIVE_KEY   = "af_processTrain.ACTIVE_TIP";
-  private static final String _NEXT_KEY     = "af_processTrain.NEXT_TIP";
-  private static final String _MORE_KEY     = "af_processTrain.MORE";
-  private static final String _PREVIOUS_KEY = "af_processTrain.PREVIOUS";
-
-
-  static private final TrinidadLogger _LOG =
-    TrinidadLogger.createTrinidadLogger(ProcessTrainRenderer.class);
-
-  // for now keep the OraLink/OraDisabledLink styles on the 'a', and
-  // append train link style class.
-  private static final Map _RESOURCE_KEY_MAP  =  new HashMap();
-  private static final String _TRAIN_DISABLED_LINK =
-    XhtmlConstants.LINK_DISABLED_STYLE_CLASS +
-    " " + XhtmlConstants.AF_PROCESS_TRAIN_LINK_STYLE_CLASS;
-  private static final String _TRAIN_ENABLED_LINK =
-    XhtmlConstants.LINK_STYLE_CLASS +
-    " " + XhtmlConstants.AF_PROCESS_TRAIN_LINK_STYLE_CLASS;
-  static
-  {
-    _RESOURCE_KEY_MAP.put(
-      XhtmlConstants.LINK_DISABLED_STYLE_CLASS,
-      _TRAIN_DISABLED_LINK);
-    _RESOURCE_KEY_MAP.put(
-      XhtmlConstants.LINK_STYLE_CLASS,
-      _TRAIN_ENABLED_LINK);
-  }
-
-}

Modified: incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/pda/ProcessTrainRenderer.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/pda/ProcessTrainRenderer.java?rev=427402&r1=427401&r2=427402&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/pda/ProcessTrainRenderer.java (original)
+++ incubator/adffaces/branches/matzew-component-renaming/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/pda/ProcessTrainRenderer.java Mon Jul 31 18:42:43 2006
@@ -1,145 +0,0 @@
-/*
- * Copyright  2000-2006 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.myfaces.trinidadinternal.ui.laf.base.pda;
-
-import java.io.IOException;
-
-import javax.faces.context.ResponseWriter;
-
-import org.apache.myfaces.trinidad.component.UIXHierarchy;
-
-import org.apache.myfaces.trinidadinternal.ui.UIXRenderingContext;
-import org.apache.myfaces.trinidadinternal.ui.UINode;
-import org.apache.myfaces.trinidadinternal.ui.laf.base.xhtml.ModelRendererUtils;
-import org.apache.myfaces.trinidadinternal.ui.laf.base.xhtml.XhtmlLafRenderer;
-import org.apache.myfaces.trinidadinternal.util.IntegerUtils;
-
-
-/**
- * @version $Name:  $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/ui/laf/base/pda/ProcessTrainRenderer.java#0 $) $Date: 10-nov-2005.18:55:03 $
- * @author The Oracle ADF Faces Team
- */
-public class ProcessTrainRenderer extends XhtmlLafRenderer
-{
-
- protected UIXHierarchy getHierarchyBase(
-    UIXRenderingContext context,
-    UINode           node
-  )
-  {
-    return (UIXHierarchy) node.getUIComponent();  
-  }
-
-
-  protected UINode getStamp(
-    UIXRenderingContext context,
-    UINode           node
-    )
-  {
-    return node.getNamedChild(context, NODE_STAMP_CHILD);
-  }
-  
-
-  protected boolean setNewPath(
-    UIXRenderingContext context,
-    UINode           node,
-    UIXHierarchy    component
-  )
-  {
-    int startDepth = getIntAttributeValue(context, node, START_DEPTH_ATTR, 0);
-    return ModelRendererUtils.setNewPath(component, startDepth, 
-                                         component.getFocusRowKey(), false); 
-    
-   
-  }
-
-  /**
-   *  Render Step x of z for process Train components.
-   */
-  protected void renderContent(
-          UIXRenderingContext context,
-          UINode           node
-          ) throws IOException
-  {
-
-    UIXHierarchy component = getHierarchyBase(context, node);          
-    UINode stamp = getStamp(context, node);
-    
-    if(stamp != null)
-    { 
-      Object oldPath = component.getRowKey();      
-      boolean isNewPath = setNewPath(context, node, component);
-      if (isNewPath)
-      {
-
-        int selectedIndex = component.getRowIndex();
-        int length = component.getRowCount();      
-        String pattern;
-        String[] parameters;
-        
-        selectedIndex++; 
-        
-        if (length == MAX_VALUE_UNKNOWN)
-        {
-          pattern = getTranslatedString(context,
-                  _SINGLE_RANGE_FORMAT_NO_TOTAL_STRING);
-  
-          parameters = new String[]
-          {
-            getTranslatedString(context, _STEP_TEXT_KEY),
-            IntegerUtils.getString(selectedIndex)
-          };
-          
-        }
-        else
-        {
-          pattern = getTranslatedString(context,
-                  _SINGLE_RANGE_FORMAT_TOTAL_STRING);
-  
-          parameters = new String[]
-          {
-            getTranslatedString(context, _STEP_TEXT_KEY),
-            IntegerUtils.getString(selectedIndex),
-            IntegerUtils.getString(length)
-          };
-        }
-
-        ResponseWriter writer = context.getResponseWriter();
-
-        writer.writeText(formatString(context, pattern, parameters), null);
-        
-        component.setRowKey(oldPath);
-      }
-    }
-  }
-
-
-  protected String getElementName(
-          UIXRenderingContext context,
-          UINode           node
-          )
-  {
-    return null;
-  }
-
-
-  static private final String _STEP_TEXT_KEY = 
-    "af_processTrain.STEP";
-  static private final String _SINGLE_RANGE_FORMAT_TOTAL_STRING =
-    "af_processTrain.FORMAT_TOTAL";
-  static private final String _SINGLE_RANGE_FORMAT_NO_TOTAL_STRING =
-    "af_processTrain.FORMAT_NO_TOTAL";
-}



Mime
View raw message