myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bom...@apache.org
Subject svn commit: r697172 [1/2] - in /myfaces/tobago/branches/tobago-1.0.x/theme: scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough...
Date Fri, 19 Sep 2008 18:17:00 GMT
Author: bommel
Date: Fri Sep 19 11:17:00 2008
New Revision: 697172

URL: http://svn.apache.org/viewvc?rev=697172&view=rev
Log:
(TOBAGO-176) Starting with a tabNavigationBar

Added:
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxToolBarRenderer.java   (with props)
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java   (with props)
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tabNext.gif   (with props)
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tabNextDisabled.gif   (with props)
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tabPrev.gif   (with props)
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tabPrevDisabled.gif   (with props)
    myfaces/tobago/branches/tobago-1.0.x/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/tabNext.gif   (with props)
    myfaces/tobago/branches/tobago-1.0.x/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/tabNextDisabled.gif   (with props)
    myfaces/tobago/branches/tobago-1.0.x/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/tabPrev.gif   (with props)
    myfaces/tobago/branches/tobago-1.0.x/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/image/tabPrevDisabled.gif   (with props)
Modified:
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxRenderer.java
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.java
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/mozilla/style/style.css
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/msie/style/style.css
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tab.js
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css
    myfaces/tobago/branches/tobago-1.0.x/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java
    myfaces/tobago/branches/tobago-1.0.x/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/style/style.css
    myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tabgroup.js
    myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxRenderer.java?rev=697172&r1=697171&r2=697172&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxRenderer.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxRenderer.java Fri Sep 19 11:17:00 2008
@@ -23,11 +23,8 @@
  */
 
 
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ICON_SIZE;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL_POSITION;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SUPPPRESS_TOOLBAR_CONTAINER;
 import static org.apache.myfaces.tobago.TobagoConstants.FACET_LABEL;
 import static org.apache.myfaces.tobago.TobagoConstants.FACET_TOOL_BAR;
 import org.apache.myfaces.tobago.context.ClientProperties;
@@ -37,7 +34,6 @@
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
 import org.apache.myfaces.tobago.renderkit.html.HtmlStyleMap;
-import org.apache.myfaces.tobago.taglib.component.ToolBarTag;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
 import javax.faces.component.UIComponent;
@@ -45,7 +41,6 @@
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 import java.io.IOException;
-import java.util.Map;
 
 public class BoxRenderer extends BoxRendererBase {
 
@@ -87,15 +82,7 @@
       writer.writeClassAttribute("tobago-box-toolbar-div");
       writer.startElement(HtmlConstants.DIV, null);
       writer.writeClassAttribute("tobago-box-toolbar-span");
-      final Map attributes = toolbar.getAttributes();
-      attributes.put(
-          ATTR_SUPPPRESS_TOOLBAR_CONTAINER, Boolean.TRUE);
-      if (ToolBarTag.LABEL_BOTTOM.equals(attributes.get(ATTR_LABEL_POSITION))) {
-        attributes.put(ATTR_LABEL_POSITION, ToolBarTag.LABEL_RIGHT);
-      }
-      if (ToolBarTag.ICON_BIG.equals(attributes.get(ATTR_ICON_SIZE))) {
-        attributes.put(ATTR_ICON_SIZE, ToolBarTag.ICON_SMALL);
-      }
+      toolbar.setRendererType("BoxToolBar");
       RenderUtil.encode(facesContext, toolbar);
       writer.endElement(HtmlConstants.DIV);
       writer.endElement(HtmlConstants.DIV);
@@ -135,6 +122,6 @@
 
   private int getExtraPadding(FacesContext facesContext, UIComponent component) {
     return getConfiguredValue(facesContext, component,
-              "extraPaddingHeightWhenToolbar");
+        "extraPaddingHeightWhenToolbar");
   }
 }

Added: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxToolBarRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxToolBarRenderer.java?rev=697172&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxToolBarRenderer.java (added)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxToolBarRenderer.java Fri Sep 19 11:17:00 2008
@@ -0,0 +1,66 @@
+package org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ICON_SIZE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL_POSITION;
+import org.apache.myfaces.tobago.component.UIToolBar;
+
+import javax.faces.component.UIComponent;
+
+
+public class BoxToolBarRenderer extends ToolBarRendererBase {
+
+  @Override
+  protected String getLabelPosition(UIComponent component) {
+    final String attribute = (String) component.getAttributes().get(ATTR_LABEL_POSITION);
+    if (UIToolBar.LABEL_BOTTOM.equals(attribute)) {
+      return UIToolBar.LABEL_RIGHT;
+    } else {
+      return attribute;
+    }
+
+  }
+
+  @Override
+  protected String getIconSize(UIComponent component) {
+    final String attribute = (String) component.getAttributes().get(ATTR_ICON_SIZE);
+    if (UIToolBar.ICON_BIG.equals(attribute)) {
+      return UIToolBar.ICON_SMALL;
+    } else {
+      return attribute;
+    }
+  }
+
+
+  protected String getHoverClasses(boolean first, boolean last) {
+    return "tobago-toolBar-button-hover tobago-toolBar-button-box-facet-hover"
+        + (last ? " tobago-box-toolBar-button-hover-last" : "");
+  }
+
+  protected String getTableClasses(boolean selected, boolean disabled) {
+    return
+        "tobago-toolbar-button-table tobago-boxToolbar-button-table-box-facet tobago-toolbar-button-table-box-facet-"
+            + (selected ? "selected-" : "") + (disabled ? "disabled" : "enabled");
+  }
+
+  protected String getDivClasses(boolean selected, boolean disabled) {
+    return "tobago-toolbar-button tobago-toolbar-button-box-facet tobago-toolbar-button-box-facet-"
+        + (selected ? "selected-" : "") + (disabled ? "disabled" : "enabled");
+  }
+}

Propchange: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxToolBarRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxToolBarRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java?rev=697172&r1=697171&r2=697172&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java Fri Sep 19 11:17:00 2008
@@ -456,6 +456,7 @@
 
     writer.startElement(HtmlConstants.A, null);
     writer.writeClassAttribute(spanClass);
+    writer.writeIdAttribute(command.getClientId(facesContext));
     if (label.getAccessKey() != null) {
       if (LOG.isInfoEnabled()
           && !AccessKeyMap.addAccessKey(facesContext, label.getAccessKey())) {
@@ -463,7 +464,6 @@
       }
 
       if (!disabled) {
-        writer.writeIdAttribute(command.getClientId(facesContext));
         addAcceleratorKey(facesContext, accKeyFunctions, command, label.getAccessKey());
       }
     }

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java?rev=697172&r1=697171&r2=697172&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java Fri Sep 19 11:17:00 2008
@@ -24,17 +24,21 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.tobago.TobagoConstants;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_HEIGHT;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_IMAGE;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LAYOUT_HEIGHT;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LAYOUT_WIDTH;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ONCLICK;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SELECTED_INDEX;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE_BODY;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE_CLASS;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE_HEADER;
-import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
 import org.apache.myfaces.tobago.ajax.api.AjaxRenderer;
 import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
 import org.apache.myfaces.tobago.component.ComponentUtil;
+import org.apache.myfaces.tobago.component.UICommand;
 import org.apache.myfaces.tobago.component.UIPage;
 import org.apache.myfaces.tobago.component.UIPanelBase;
 import org.apache.myfaces.tobago.component.UITab;
@@ -42,6 +46,7 @@
 import static org.apache.myfaces.tobago.component.UITabGroup.SWITCH_TYPE_CLIENT;
 import static org.apache.myfaces.tobago.component.UITabGroup.SWITCH_TYPE_RELOAD_PAGE;
 import static org.apache.myfaces.tobago.component.UITabGroup.SWITCH_TYPE_RELOAD_TAB;
+import org.apache.myfaces.tobago.component.UIToolBar;
 import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
 import org.apache.myfaces.tobago.event.TabChangeEvent;
@@ -57,10 +62,13 @@
 import org.apache.myfaces.tobago.util.AccessKeyMap;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
+import javax.faces.application.Application;
 import javax.faces.component.UIComponent;
+import javax.faces.component.UIPanel;
 import javax.faces.context.FacesContext;
 import javax.faces.el.ValueBinding;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -69,7 +77,8 @@
 
   private static final Log LOG = LogFactory.getLog(TabGroupRenderer.class);
 
-  public static final String ACTIVE_INDEX_POSTFIX = SUBCOMPONENT_SEP + "activeIndex";
+  public static final String ACTIVE_INDEX_POSTFIX = "__activeIndex";
+  private static final int TOOLBAR_WIDTH = 60;
 
   public void decode(FacesContext facesContext, UIComponent component) {
     if (ComponentUtil.isOutputOnly(component)) {
@@ -90,6 +99,7 @@
     } catch (NumberFormatException e) {
       LOG.error("Can't parse activeIndex: '" + newValue + "'");
     }
+    HtmlRendererUtil.createHeaderAndBodyStyles(facesContext, component);
   }
 
   public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
@@ -105,21 +115,16 @@
 
     final String clientId = component.getClientId(facesContext);
     final String hiddenId = clientId + TabGroupRenderer.ACTIVE_INDEX_POSTFIX;
-
     final String switchType = component.getSwitchType();
 
     UIPage page = ComponentUtil.findPage(facesContext, component);
-    final String[] scripts = new String[]{
-        "script/tab.js",
-        "script/tabgroup.js"
-    };
+    final String[] scripts = new String[]{"script/tab.js", "script/tabgroup.js", "script/tobago-menu.js"};
     page.getScriptFiles().addAll(Arrays.asList(scripts));
 
     if (TobagoConfig.getInstance(facesContext).isAjaxEnabled()) {
       HtmlRendererUtil.writeScriptLoader(facesContext, scripts, new String[0]);
     }
 
-
     TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
     writer.startElement(HtmlConstants.INPUT, null);
     writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
@@ -130,46 +135,93 @@
 
     String image1x1 = ResourceManagerUtil.getImageWithPath(facesContext, "image/1x1.gif");
 
+    TabList tabList = getTabList(facesContext, component);
+
     // if a outer uiPage is presend, the virtual tab will go over all
     // tabs and render it as they are selected, and it will
     // selected with stylesheet.
     int virtualTab = 0;
-    //UIPanelBase[] tabs = component.getTabs();
-    for (UIComponent tab: (List<UIComponent>) component.getChildren()) {
+    int currentWidth = 0;
+    for (UIComponent tab : (List<UIComponent>) component.getChildren()) {
       if (tab instanceof UIPanelBase) {
-        if (tab.isRendered() && (SWITCH_TYPE_CLIENT.equals(switchType) || virtualTab == activeIndex)) {
+        if (tab.isRendered()) {
+          currentWidth += tabList.getWidthList().get(virtualTab);
+          if (SWITCH_TYPE_CLIENT.equals(switchType) || virtualTab == activeIndex) {
 
-          if (virtualTab != activeIndex) {
-            HtmlRendererUtil.replaceStyleAttribute(component, "display", "none");
-          } else {
-            HtmlRendererUtil.removeStyleAttribute(component, "display");
+            if (virtualTab != activeIndex) {
+              HtmlRendererUtil.replaceStyleAttribute(component, "display", "none");
+            } else {
+              HtmlRendererUtil.removeStyleAttribute(component, "display");
+            }
+
+            writer.startElement(HtmlConstants.DIV, null);
+            writer.writeComment("empty div fix problem with mozilla and fieldset");
+            writer.endElement(HtmlConstants.DIV);
+
+            writer.startElement(HtmlConstants.DIV, null);
+            writer.writeIdAttribute(clientId);
+            StyleClasses classes = (StyleClasses) component.getAttributes().get(ATTR_STYLE_CLASS);
+            writer.writeClassAttribute(classes);
+            renderTabGroupView(facesContext, writer, component, virtualTab,
+                (HtmlStyleMap) component.getAttributes().get(ATTR_STYLE),
+                switchType, image1x1, TOOLBAR_WIDTH, currentWidth, tabList);
+            writer.endElement(HtmlConstants.DIV);
+
+            if (TobagoConfig.getInstance(facesContext).isAjaxEnabled()
+                && SWITCH_TYPE_RELOAD_TAB.equals(switchType)) {
+              final String[] cmds = {
+                  "new Tobago.TabGroup(",
+                  "    '" + clientId + "', ",
+                  "    '" + activeIndex + "', ",
+                  "    '" + component.getChildCount() + "');"
+              };
+              HtmlRendererUtil.writeScriptLoader(facesContext, new String[0], cmds);
+            }
           }
+        }
+        virtualTab++;
+      }
+    }
+  }
 
-          writer.startElement(HtmlConstants.DIV, null);
-          writer.writeComment("empty div fix problem with mozilla and fieldset");
-          writer.endElement(HtmlConstants.DIV);
+  private Integer getCurrentWidth(TabList tabs, int tabIndex) {
+    int currentWidth = 0;
+    for (int i = 0; i <= tabIndex; i++) {
+      currentWidth += tabs.getWidthList().get(i);
+    }
+    return currentWidth;
+  }
 
-          writer.startElement(HtmlConstants.DIV, null);
-          writer.writeIdAttribute(clientId);
-          renderTabGroupView(facesContext, writer, component, virtualTab,
-              (HtmlStyleMap) component.getAttributes().get(ATTR_STYLE),
-              switchType, image1x1);
-          writer.endElement(HtmlConstants.DIV);
 
-          if (TobagoConfig.getInstance(facesContext).isAjaxEnabled()
-              && SWITCH_TYPE_RELOAD_TAB.equals(switchType)) {
-            final String[] cmds = {
-                "new Tobago.TabGroup(",
-                "    '" + clientId + "', ",
-                "    '" + activeIndex + "', ",
-                "    '" + component.getChildCount() + "');"
-            };
-            HtmlRendererUtil.writeScriptLoader(facesContext, new String[0], cmds);
+  private TabList getTabList(FacesContext facesContext, UITabGroup component) {
+    TabList tabs = new TabList();
+    int index = 0;
+    int tabLabelExtraWidth = 15;
+    boolean first = true;
+    for (UIComponent child : (List<UIComponent>) component.getChildren()) {
+      if (child instanceof UITab) {
+        UITab tab = (UITab) child;
+        if (tab.isRendered()) {
+          LabelWithAccessKey label = new LabelWithAccessKey(tab);
+          if (label.getText() != null) {
+            tabs.getWidthList().add(RenderUtil.calculateStringWidth(facesContext, component, label.getText())
+                + tabLabelExtraWidth);
+          } else {
+            tabs.getWidthList().add(RenderUtil.calculateStringWidth(facesContext, component, Integer.toString(index + 1))
+                + tabLabelExtraWidth);
+          }
+          if (first) {
+            tabs.firstIndex = index;
+            first = false;
           }
+          tabs.lastIndex = index;
+        } else {
+          tabs.getWidthList().add(0);
         }
-        virtualTab++;
+        index++;
       }
     }
+    return tabs;
   }
 
   private int ensureRenderedActiveIndex(FacesContext context, UITabGroup tabGroup) {
@@ -177,13 +229,13 @@
     // ensure to select a rendered tab
     int index = -1;
     int closestRenderedTabIndex = -1;
-    for (UIComponent tab: (List<UIComponent>) tabGroup.getChildren()) {
+    for (UIComponent tab : (List<UIComponent>) tabGroup.getChildren()) {
       index++;
       if (tab instanceof UIPanelBase) {
         if (index == activeIndex) {
           if (tab.isRendered()) {
             return index;
-          } else if (closestRenderedTabIndex > -1)  {
+          } else if (closestRenderedTabIndex > -1) {
             break;
           }
         }
@@ -208,17 +260,16 @@
     return closestRenderedTabIndex;
   }
 
-  private void renderTabGroupView(
-      FacesContext facesContext, TobagoResponseWriter writer, UITabGroup component,
-      int virtualTab, HtmlStyleMap oStyle, String switchType, String image1x1)
-      throws IOException {
+  private void renderTabGroupView(FacesContext facesContext, TobagoResponseWriter writer, UITabGroup component,
+      int virtualTab, HtmlStyleMap oStyle, String switchType, String image1x1, int toolbarWidth,
+      int currentWidth, TabList tabList) throws IOException {
     writer.startElement(HtmlConstants.TABLE, null);
     writer.writeAttribute(HtmlAttributes.BORDER, 0);
     writer.writeAttribute(HtmlAttributes.CELLPADDING, 0);
     writer.writeAttribute(HtmlAttributes.CELLSPACING, 0);
     writer.writeAttribute(HtmlAttributes.SUMMARY, "", false);
     final String clientId = component.getClientId(facesContext);
-    writer.writeIdAttribute(clientId + '.' + virtualTab);
+    writer.writeIdAttribute(clientId + "__" + virtualTab);
     writer.writeStyleAttribute(oStyle);
 
 
@@ -226,22 +277,97 @@
     writer.writeAttribute(HtmlAttributes.VALIGN, "bottom", false);
 
     writer.startElement(HtmlConstants.TD, null);
+    HtmlStyleMap headerStyle = (HtmlStyleMap) component.getAttributes().get(ATTR_STYLE_HEADER);
+    headerStyle.put("position", "relative");
+    headerStyle.put("width", headerStyle.getInt("width"));
+    int width = headerStyle.getInt("width");
+    writer.writeStyleAttribute(headerStyle);
+    writer.startElement(HtmlConstants.DIV, null);
+    writer.writeStyleAttribute(headerStyle);
 
+    writer.startElement(HtmlConstants.DIV, null);
+    HtmlStyleMap map = new HtmlStyleMap();
+    if (currentWidth > width) {
+      map.put("width", currentWidth);
+      map.put("left", width - toolbarWidth - currentWidth);
+    } else {
+      map.put("width", width - toolbarWidth);
+    }
+    map.put("overflow", "hidden");
+    map.put("position", "absolute");
+    writer.writeStyleAttribute(map);
     writer.startElement(HtmlConstants.TABLE, component);
     writer.writeAttribute(HtmlAttributes.BORDER, 0);
     writer.writeAttribute(HtmlAttributes.CELLPADDING, 0);
     writer.writeAttribute(HtmlAttributes.CELLSPACING, 0);
     writer.writeAttribute(HtmlAttributes.SUMMARY, "", false);
-    HtmlStyleMap headerStyle = (HtmlStyleMap) component.getAttributes().get(ATTR_STYLE_HEADER);
+    headerStyle = (HtmlStyleMap) component.getAttributes().get(ATTR_STYLE_HEADER);
     writer.writeStyleAttribute(headerStyle);
 
+    writer.startElement(HtmlConstants.COLGROUP, null);
+    for (Integer colWidth : tabList.getWidthList()) {
+      writer.startElement(HtmlConstants.COL, null);
+      writer.writeAttribute(HtmlAttributes.WIDTH, colWidth);
+      writer.endElement(HtmlConstants.COL);
+    }
+    writer.endElement(HtmlConstants.COLGROUP);
+
     writer.startElement(HtmlConstants.TR, null);
     writer.writeAttribute(HtmlAttributes.VALIGN, "bottom", false);
 
+    Application application = facesContext.getApplication();
+
+    // tool bar
+
+    UICommand scrollLeft = (UICommand) application.createComponent(UICommand.COMPONENT_TYPE);
+    scrollLeft.setId(component.getId() + "__" + virtualTab + "__" + "previous");
+    //scrollLeft.setId(facesContext.getViewRoot().createUniqueId());
+    scrollLeft.setRendererType(null);
+    scrollLeft.getAttributes().put(ATTR_IMAGE, "image/tabPrev.gif");
+    if (tabList.isFirst(virtualTab)) {
+      scrollLeft.setDisabled(true);
+    }
+    if (!(TobagoConfig.getInstance(facesContext).isAjaxEnabled() && SWITCH_TYPE_RELOAD_TAB.equals(switchType))) {
+      scrollLeft.getAttributes().put(ATTR_ONCLICK, "tobago_previousTab('" + switchType + "','" + clientId + "',"
+          + component.getChildCount() + ')');
+    } else {
+      scrollLeft.getAttributes().put(ATTR_ONCLICK, "javascript:false");
+    }
+    UICommand scrollRight = (UICommand) application.createComponent(UICommand.COMPONENT_TYPE);
+    scrollRight.setId(component.getId() + "__" + virtualTab + "__" + "next");
+    scrollRight.setRendererType(null);
+    scrollRight.getAttributes().put(ATTR_IMAGE, "image/tabNext.gif");
+    if (tabList.isLast(virtualTab)) {
+      scrollRight.setDisabled(true);
+    }
+    if (!(TobagoConfig.getInstance(facesContext).isAjaxEnabled() && SWITCH_TYPE_RELOAD_TAB.equals(switchType))) {
+      scrollRight.getAttributes().put(ATTR_ONCLICK, "tobago_nextTab('" + switchType + "','" + clientId + "',"
+          + component.getChildCount() + ')');
+    } else {
+      scrollRight.getAttributes().put(ATTR_ONCLICK, "javascript:false");
+    }
+    /*UICommand commandList = (UICommand) application.createComponent(UICommand.COMPONENT_TYPE);
+    commandList.setId(facesContext.getViewRoot().createUniqueId());
+    commandList.setRendererType(null);
+    UIMenu menu = (UIMenu) application.createComponent(UIMenu.COMPONENT_TYPE);
+    menu.setId(facesContext.getViewRoot().createUniqueId());
+    menu.setRendererType(null);
+    commandList.getFacets().put(FACET_MENUPOPUP, menu);*/
+    UIToolBar toolBar = (UIToolBar) application.createComponent(UIToolBar.COMPONENT_TYPE);
+    toolBar.setId(facesContext.getViewRoot().createUniqueId());
+    //toolBar.setLabelPosition(UIToolBar.LABEL_OFF);
+    toolBar.setRendererType("BoxToolBar");
+    toolBar.setTransient(true);
+    //toolBar.setIconSize();
+    toolBar.getChildren().add(scrollLeft);
+    toolBar.getChildren().add(scrollRight);
+    //toolBar.getChildren().add(commandList);
+    component.getFacets().put(TobagoConstants.FACET_TOOL_BAR, toolBar);
+
     UITab activeTab = null;
 
     int index = 0;
-    for (UIComponent child: (List<UIComponent>) component.getChildren()) {
+    for (UIComponent child : (List<UIComponent>) component.getChildren()) {
       if (child instanceof UITab) {
         UITab tab = (UITab) child;
         if (tab.isRendered()) {
@@ -261,7 +387,6 @@
           }
 
           LabelWithAccessKey label = new LabelWithAccessKey(tab);
-
           StyleClasses outerClass = new StyleClasses();
           StyleClasses innerClass = new StyleClasses();
           if (virtualTab == index) {
@@ -275,17 +400,24 @@
           outerClass.addMarkupClass(tab, "tab", "outer");
           innerClass.addMarkupClass(tab, "tab", "outer");
           writer.startElement(HtmlConstants.TD, tab);
+          map = new HtmlStyleMap();
+          map.put("width", tabList.getWidthList().get(index));
+
+          writer.writeStyleAttribute(map);
           writer.writeIdAttribute(tab.getClientId(facesContext));
-          HtmlRendererUtil.renderTip(tab, writer);
 
+          HtmlRendererUtil.renderTip(tab, writer);
+          writer.startElement(HtmlConstants.DIV, null);
+          writer.writeStyleAttribute(map);
           writer.startElement(HtmlConstants.DIV, null);
           writer.writeClassAttribute(outerClass);
-
+          //writer.writeStyleAttribute(map);
           writer.startElement(HtmlConstants.DIV, null);
+          //writer.writeStyleAttribute(map);
           writer.writeClassAttribute(innerClass);
 
           writer.startElement(HtmlConstants.SPAN, null);
-          String tabId = clientId + "." + virtualTab + SUBCOMPONENT_SEP + index;
+          String tabId = clientId + "__" + virtualTab + "__" + index;
           writer.writeIdAttribute(tabId);
 
           if (tab.isDisabled()) {
@@ -299,7 +431,7 @@
           if (label.getText() != null) {
             HtmlRendererUtil.writeLabelWithAccessKey(writer, label);
           } else {
-            writer.writeText(Integer.toString(index+1));
+            writer.writeText(Integer.toString(index + 1));
           }
           writer.endElement(HtmlConstants.SPAN);
 
@@ -313,15 +445,35 @@
           }
           writer.endElement(HtmlConstants.DIV);
           writer.endElement(HtmlConstants.DIV);
+          writer.endElement(HtmlConstants.DIV);
           writer.endElement(HtmlConstants.TD);
+
+          // tool bar
+          /*UIMenuCommand menuItem = (UIMenuCommand) application.createComponent(UIMenuCommand.COMPONENT_TYPE);
+          menuItem.setId(component.getId() + "__" + virtualTab + "__" + index + "__" + "menu");
+          menuItem.setRendererType("MenuCommand");
+          if (onclick != null) {
+            menuItem.getAttributes().put(ATTR_ONCLICK, onclick);
+          } else {
+            menuItem.getAttributes().put(ATTR_ONCLICK, "javascript:false");
+          }
+          Object label2 = tab.getAttributes().get(ATTR_LABEL);
+          if (label2 != null) {
+            menuItem.getAttributes().put(ATTR_LABEL, label2);
+          }
+          menu.getChildren().add(menuItem);*/
+
         }
       }
       index++;
     }
 
     writer.startElement(HtmlConstants.TD, null);
-    writer.writeAttribute(HtmlAttributes.WIDTH, "100%", false);
-
+    if (currentWidth > width) {
+      writer.writeAttribute(HtmlAttributes.WIDTH, toolbarWidth);
+    } else {
+      writer.writeAttribute(HtmlAttributes.WIDTH, Integer.toString((width - currentWidth)) + "px", false);
+    }
     writer.startElement(HtmlConstants.DIV, null);
     writer.writeClassAttribute("tobago-tab-fulfill");
 
@@ -334,7 +486,11 @@
     writer.endElement(HtmlConstants.TD);
     writer.endElement(HtmlConstants.TR);
     writer.endElement(HtmlConstants.TABLE);
-
+    writer.endElement(HtmlConstants.DIV);
+    if (toolBar != null) { // todo: configurable later
+      renderToolbar(facesContext, writer, toolBar, width - toolbarWidth);
+    }
+    writer.endElement(HtmlConstants.DIV);
     writer.endElement(HtmlConstants.TD);
     writer.endElement(HtmlConstants.TR);
 
@@ -343,6 +499,21 @@
     writer.endElement(HtmlConstants.TABLE);
   }
 
+  private void renderToolbar(FacesContext facesContext, TobagoResponseWriter writer, UIPanel toolbar, int width)
+      throws IOException {
+    writer.startElement(HtmlConstants.DIV, null);
+    HtmlStyleMap map = new HtmlStyleMap();
+    map.put("width", TOOLBAR_WIDTH);
+    map.put("left", width);
+    writer.writeStyleAttribute(map);
+    writer.writeClassAttribute("tobago-tabnavigationbar");
+    toolbar.setRendererType("BoxToolBar");
+
+    RenderUtil.encode(facesContext, toolbar);
+    writer.endElement(HtmlConstants.DIV);
+  }
+
+
   protected void encodeContent(TobagoResponseWriter writer, FacesContext facesContext, UITab activeTab)
       throws IOException {
 
@@ -363,17 +534,16 @@
 
   public void encodeAjax(FacesContext context, UIComponent component) throws IOException {
     AjaxUtils.checkParamValidity(context, component, UITabGroup.class);
-
-    renderTabGroupView(context,
-        HtmlRendererUtil.getTobagoResponseWriter(context),
-        (UITabGroup) component,
-        ensureRenderedActiveIndex(context, (UITabGroup) component),
-        (HtmlStyleMap) component.getAttributes().get(ATTR_STYLE),
-        SWITCH_TYPE_RELOAD_TAB,
-        ResourceManagerUtil.getImageWithPath(context, "image/1x1.gif"));
-    context.responseComplete();
+    TabList tabList = getTabList(context, (UITabGroup) component);
+    int index = ensureRenderedActiveIndex(context, (UITabGroup) component);
+    int currentWidth = getCurrentWidth(tabList, index);
+    renderTabGroupView(context, HtmlRendererUtil.getTobagoResponseWriter(context),
+        (UITabGroup) component, index,
+        (HtmlStyleMap) component.getAttributes().get(ATTR_STYLE), SWITCH_TYPE_RELOAD_TAB,
+        ResourceManagerUtil.getImageWithPath(context, "image/1x1.gif"), TOOLBAR_WIDTH, currentWidth, tabList);
   }
 
+
   public int getFixedHeight(FacesContext facesContext, UIComponent uiComponent) {
     UITabGroup component = (UITabGroup) uiComponent;
     int height =
@@ -384,7 +554,7 @@
       fixedHeight = height;
     } else {
       fixedHeight = 0;
-      for (UIComponent tab: (List<UIComponent>) component.getChildren()) {
+      for (UIComponent tab : (List<UIComponent>) component.getChildren()) {
         if (tab instanceof UIPanelBase && tab.isRendered()) {
           LayoutInformationProvider renderer = ComponentUtil.getRenderer(facesContext, tab);
           fixedHeight
@@ -403,8 +573,8 @@
     Object layoutHeight =
         component.getAttributes().get(ATTR_LAYOUT_HEIGHT);
 
-    for (UIComponent tab: (List<UIComponent>) component.getChildren()) {
-      if (tab instanceof UIPanelBase && tab.isRendered())  {
+    for (UIComponent tab : (List<UIComponent>) component.getChildren()) {
+      if (tab instanceof UIPanelBase && tab.isRendered()) {
         if (layoutWidth != null) {
           HtmlRendererUtil.layoutSpace(facesContext, tab, true);
         }
@@ -414,5 +584,23 @@
       }
     }
   }
+
+  private static class TabList {
+    private List<Integer> widthList = new ArrayList<Integer>();
+    private int firstIndex;
+    private int lastIndex;
+
+    public List<Integer> getWidthList() {
+      return widthList;
+    }
+
+    public boolean isFirst(int index) {
+      return firstIndex == index;
+    }
+
+    public boolean isLast(int index) {
+      return lastIndex == index;
+    }
+  }
 }
 

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.java?rev=697172&r1=697171&r2=697172&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.java Fri Sep 19 11:17:00 2008
@@ -24,520 +24,61 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DISABLED;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ICON_SIZE;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_IMAGE;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL_POSITION;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MENU_POPUP;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MENU_POPUP_TYPE;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SUPPPRESS_TOOLBAR_CONTAINER;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_VALUE;
-import static org.apache.myfaces.tobago.TobagoConstants.FACET_ITEMS;
-import static org.apache.myfaces.tobago.TobagoConstants.FACET_MENUPOPUP;
-import static org.apache.myfaces.tobago.TobagoConstants.FACET_TOOL_BAR;
-import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_BOX;
-import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_MENUBAR;
-import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
-import org.apache.myfaces.tobago.component.ComponentUtil;
-import org.apache.myfaces.tobago.component.UIMenuSelectOne;
-import org.apache.myfaces.tobago.component.UISelectBooleanCommand;
-import org.apache.myfaces.tobago.component.UISelectOneCommand;
 import org.apache.myfaces.tobago.component.UIToolBar;
-import org.apache.myfaces.tobago.context.ResourceManager;
-import org.apache.myfaces.tobago.context.ResourceManagerFactory;
-import org.apache.myfaces.tobago.context.ResourceManagerUtil;
-import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
-import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
-import org.apache.myfaces.tobago.renderkit.RenderUtil;
-import org.apache.myfaces.tobago.renderkit.html.CommandRendererHelper;
-import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
-import org.apache.myfaces.tobago.taglib.component.ToolBarTag;
-import org.apache.myfaces.tobago.util.AccessKeyMap;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
-import javax.faces.component.UICommand;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIPanel;
-import javax.faces.component.UISelectBoolean;
-import javax.faces.component.UISelectOne;
-import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
-import javax.faces.model.SelectItem;
 import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
 
-public class ToolBarRenderer extends LayoutableRendererBase {
+public class ToolBarRenderer extends ToolBarRendererBase {
 
   private static final Log LOG = LogFactory.getLog(ToolBarRenderer.class);
 
-
-  public void encodeEnd(FacesContext facesContext,
-      UIComponent uiComponent) throws IOException {
+  public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
     UIPanel toolbar = (UIPanel) uiComponent;
 
     TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
-    boolean suppressContainer = ComponentUtil.getBooleanAttribute(toolbar, ATTR_SUPPPRESS_TOOLBAR_CONTAINER);
-
-    if (!suppressContainer) {
-      setToolBarHeight(facesContext, uiComponent);
-
-      writer.startElement(HtmlConstants.DIV, toolbar);
-      writer.writeIdAttribute(toolbar.getClientId(facesContext));
-      writer.writeClassAttribute();
-      writer.writeStyleAttribute();
-      writer.startElement(HtmlConstants.DIV, toolbar);
-      boolean right = false;
-      if (toolbar instanceof UIToolBar) {
-        right = UIToolBar.ORIENTATION_RIGHT.equals(((UIToolBar) toolbar).getOrientation());
-      }
-      // TODO use StyleClasses
-      writer.writeClassAttribute("tobago-toolbar-div-inner" + (right ? " tobago-toolbar-orientation-right" : ""));
-
-    }
-
-    boolean boxFacet = isBoxFacet(toolbar);
-
-    List children = toolbar.getChildren();
-
-    int index = 0;
-    for (Iterator iter = children.iterator(); iter.hasNext();) {
-      UIComponent component = (UIComponent) iter.next();
-      if (component instanceof UICommand) {
-        boolean addExtraClass = boxFacet ? !iter.hasNext() : index++ == 0;
-        renderToolbarCommand(facesContext, (UICommand) component, writer,
-            boxFacet, addExtraClass);
-      } else {
-        LOG.error("Illegal UIComponent class in toolbar :"
-            + component.getClass().getName());
-      }
-    }
-
-    if (!suppressContainer) {
-      writer.endElement(HtmlConstants.DIV);
-      writer.endElement(HtmlConstants.DIV);
-    }
-  }
-
-// ----------------------------------------------------------- business methods
-
-  public void encodeChildren(FacesContext facesContext, UIComponent component)
-      throws IOException {
-  }
-
-  public boolean getRendersChildren() {
-    return true;
-  }
-
-  private boolean isBoxFacet(UIComponent component) {
-    return (RENDERER_TYPE_BOX.equals(component.getParent().getRendererType())
-        && component.getParent().getFacet(FACET_TOOL_BAR) == component);
-  }
-
-  private void renderToolbarCommand(FacesContext facesContext,
-      final UICommand command, TobagoResponseWriter writer, boolean boxFacet,
-      boolean addExtraHoverClass)
-      throws IOException {
-    if (command instanceof UISelectBooleanCommand) {
-      renderSelectBoolean(facesContext, command, writer, boxFacet, addExtraHoverClass);
-    } else if (command instanceof UISelectOneCommand) {
-      renderSelectOne(facesContext, command, writer, boxFacet, addExtraHoverClass);
-    } else {
-      if (command.getFacet(FACET_ITEMS) != null) {
-        UIComponent facet = command.getFacet(FACET_ITEMS);
-        if (facet instanceof UISelectBoolean) {
-          renderSelectBoolean(facesContext, command, writer, boxFacet, addExtraHoverClass);
-        } else if (facet instanceof UISelectOne) {
-          renderSelectOne(facesContext, command, writer, boxFacet, addExtraHoverClass);
-        }
-      } else {
-        String onClick = createOnClick(facesContext, command);
-        renderToolbarButton(facesContext, command, writer, boxFacet, addExtraHoverClass, false, onClick);
-      }
-    }
-  }
-
-  private void renderSelectOne(FacesContext facesContext, UICommand command,
-      TobagoResponseWriter writer, boolean boxFacet, boolean addExtraHoverClass)
-      throws IOException {
-
-    String onclick = createOnClick(facesContext, command);
-
-    List<SelectItem> items;
-
-    UIMenuSelectOne radio = (UIMenuSelectOne) command.getFacet(FACET_ITEMS);
-    if (radio == null) {
-      items = ComponentUtil.getSelectItems(command);
-      radio = ComponentUtil.createUIMenuSelectOneFacet(facesContext, command);
-      radio.setId(facesContext.getViewRoot().createUniqueId());
-    } else {
-      items = ComponentUtil.getSelectItems(radio);
-    }
-
-
-    if (radio != null) {
-      Object value = radio.getValue();
-
-      boolean markFirst = !ComponentUtil.hasSelectedValue(items, value);
-      String radioId = radio.getClientId(facesContext);
-      String onClickPrefix = "menuSetRadioValue('" + radioId + "', '";
-      String onClickPostfix = onclick != null ? "') ; " + onclick : "";
-      for (SelectItem item : items) {
-        final String labelText = item.getLabel();
-        if (labelText != null) {
-          command.getAttributes().put(ATTR_LABEL, labelText);
-        } else {
-          LOG.warn("Menu item has label=null. UICommand.getClientId()="
-              + command.getClientId(facesContext));
-        }
-
-        String image = null;
-        if (item instanceof org.apache.myfaces.tobago.model.SelectItem) {
-          image = ((org.apache.myfaces.tobago.model.SelectItem) item).getImage();
-        } else if (LOG.isDebugEnabled()) {
-          LOG.debug("select item is not " + org.apache.myfaces.tobago.model.SelectItem.class.getName());
-        }
-        if (image == null) {
-          image = "image/1x1.gif";
-        }
-        command.getAttributes().put(ATTR_IMAGE, image);
-
-        if (item.getDescription() != null) {
-          command.getAttributes().put(ATTR_TIP, item.getDescription());
-        }
-
-
-        String formattedValue
-            = RenderUtil.getFormattedValue(facesContext, radio, item.getValue());
-        onclick = onClickPrefix + formattedValue + onClickPostfix;
-        final boolean checked;
-        if (item.getValue().equals(value) || markFirst) {
-          checked = true;
-          markFirst = false;
-          writer.writeJavascript("    " + onClickPrefix + formattedValue + "');");
-        } else {
-          checked = false;
-        }
-
-        renderToolbarButton(facesContext, command, writer, boxFacet, addExtraHoverClass, checked, onclick);
-
-      }
-    }
-
-  }
-
-  private void renderSelectBoolean(FacesContext facesContext, UICommand command,
-      TobagoResponseWriter writer, boolean boxFacet, boolean addExtraHoverClass)
-      throws IOException {
-
-    UIComponent checkbox = command.getFacet(FACET_ITEMS);
-    if (checkbox == null) {
-      checkbox = ComponentUtil.createUISelectBooleanFacet(facesContext, command);
-      checkbox.setId(facesContext.getViewRoot().createUniqueId());
-    }
-
-    final boolean checked = ComponentUtil.getBooleanAttribute(checkbox, ATTR_VALUE);
-
-    String onClick = createOnClick(facesContext, command);
-
-    String clientId = checkbox.getClientId(facesContext);
-    onClick = RenderUtil.addMenuCheckToggle(clientId, onClick);
-    if (checked) {
-      writer.writeJavascript("    menuCheckToggle('" + clientId + "');\n");
-    }
-
-    renderToolbarButton(facesContext, command, writer, boxFacet, addExtraHoverClass, checked, onClick);
-  }
-
-  private void renderToolbarButton(
-      FacesContext facesContext, final UICommand command, TobagoResponseWriter writer, boolean boxFacet,
-      boolean addExtraHoverClass, boolean selected, String onClick)
-      throws IOException {
-    if (!command.isRendered()) {
-      return;
-    }
-
-    final String clientId = command.getClientId(facesContext);
-    final boolean disabled = ComponentUtil.getBooleanAttribute(command, ATTR_DISABLED);
-    final LabelWithAccessKey label = new LabelWithAccessKey(command);
-    final UIComponent popupMenu = command.getFacet(FACET_MENUPOPUP);
-
-    Map parentAttributes = command.getParent().getAttributes();
-    String labelPosition = (String) parentAttributes.get(ATTR_LABEL_POSITION);
-    String iconSize = (String) parentAttributes.get(ATTR_ICON_SIZE);
-
-    String divClasses = "tobago-toolbar-button"
-        + " tobago-toolbar-button-"  + (boxFacet ? "box-facet-" : "")
-        + (selected ? "selected-" : "") + (disabled ? "disabled" : "enabled")
-        + (boxFacet ? " tobago-toolbar-button-box-facet" : "");
-
-    String tableClasses = "tobago-toolbar-button-table"
-        + (boxFacet ? " tobago-toolbar-button-table-box-facet" : "")
-        + " tobago-toolbar-button-table-" + (boxFacet ? "box-facet-" : "")
-        + (selected ? "selected-" : "") + (disabled ? "disabled" : "enabled");
-
-
-    String iconName = (String) command.getAttributes().get(ATTR_IMAGE);
-    String image = getImage(facesContext, iconName, iconSize, disabled, selected);
-    String graphicId = clientId + SUBCOMPONENT_SEP + "icon";
-
-    String extraHoverClass = "";
-    if (addExtraHoverClass) {
-      if (!boxFacet) {
-        extraHoverClass = " tobago-toolBar-button-hover-first";
-      } else {
-        extraHoverClass = " tobago-box-toolBar-button-hover-last";
-      }
-    }
-    final String args = "this, 'tobago-toolBar-button-hover"
-        + (boxFacet ? " tobago-toolBar-button-box-facet-hover" : "")
-        + extraHoverClass + "', '" + graphicId + "'";
-    final String mouseOverScript = "Tobago.toolbarMousesover(" + args + ");";
-    final String mouseOutScript = "Tobago.toolbarMousesout(" + args + ");";
-
-    writer.startElement(HtmlConstants.DIV, null);
-    writer.writeClassAttribute(divClasses);
-    if (!disabled) {
-      writer.writeAttribute(HtmlAttributes.ONMOUSEOVER, mouseOverScript, null);
-      writer.writeAttribute(HtmlAttributes.ONMOUSEOUT, mouseOutScript, null);
-      writer.writeAttribute(HtmlAttributes.ONCLICK, onClick, null);
-    }
-    writer.startElement(HtmlConstants.TABLE, null);
-    writer.writeAttribute(HtmlAttributes.CELLPADDING, 0);
-    writer.writeAttribute(HtmlAttributes.CELLSPACING, 0);
-    writer.writeAttribute(HtmlAttributes.SUMMARY, "", false);
-    writer.writeAttribute(HtmlAttributes.BORDER, 0);
-    writer.writeClassAttribute(tableClasses);
-    writer.startElement(HtmlConstants.TR, null);
-
-    boolean anchorOnLabel = label.getText() != null && !ToolBarTag.LABEL_OFF.equals(labelPosition);
-
-    if (!ToolBarTag.ICON_OFF.equals(iconSize)) {
-      HtmlRendererUtil.addImageSources(facesContext, writer,
-          iconName != null ? iconName : "image/1x1.gif", graphicId);
-
-      writer.startElement(HtmlConstants.TD, command);
-      writer.writeAttribute(HtmlAttributes.ALIGN, "center", false);
-      HtmlRendererUtil.renderTip(command, writer);
-
-      boolean render1pxImage = (iconName == null
-          && (!ToolBarTag.LABEL_BOTTOM.equals(labelPosition)
-          && label.getText() != null));
-
-      if (((!ToolBarTag.LABEL_OFF.equals(labelPosition)
-          && label.getText() != null)
-          || popupMenu != null)
-          && !render1pxImage) {
-        writer.writeStyleAttribute("padding-right: 3px;");
-        // TODO: make this '3px' configurable
-      }
-
-      String className = "tobago-image-default tobago-toolBar-button-image"
-          + " tobago-toolBar-button-image-" + iconSize;
-
-      if (!anchorOnLabel) {
-        renderAnchorBegin(facesContext, writer, command, label, disabled);
-      }
-      writer.startElement(HtmlConstants.IMG, command);
-      writer.writeIdAttribute(graphicId);
-      writer.writeAttribute(HtmlAttributes.SRC, image, false);
-      writer.writeAttribute(HtmlAttributes.ALT, "", false);
-      HtmlRendererUtil.renderTip(command, writer);
-      writer.writeAttribute(HtmlAttributes.BORDER, 0);
-      writer.writeClassAttribute(className);
-      if (render1pxImage) {
-        writer.writeStyleAttribute("width: 1px;");
-      }
-
-      writer.endElement(HtmlConstants.IMG);
-      if (!anchorOnLabel) {
-        writer.endElement(HtmlConstants.A);
-      }
-      writer.endElement(HtmlConstants.TD);
-    }
+    setToolBarHeight(facesContext, uiComponent);
 
-    boolean popupOn2 = ToolBarTag.LABEL_BOTTOM.equals(labelPosition)
-        && !ToolBarTag.ICON_OFF.equals(iconSize);
-    if (popupOn2) {
-      if (popupMenu != null) {
-        renderPopupTd(facesContext, writer, command, popupMenu,
-            true);
-      }
-      writer.endElement(HtmlConstants.TR);
-      writer.startElement(HtmlConstants.TR, null);
+    writer.startElement(HtmlConstants.DIV, toolbar);
+    writer.writeIdAttribute(toolbar.getClientId(facesContext));
+    writer.writeClassAttribute();
+    writer.writeStyleAttribute();
+    writer.startElement(HtmlConstants.DIV, toolbar);
+    boolean right = false;
+    if (toolbar instanceof UIToolBar) {
+      right = UIToolBar.ORIENTATION_RIGHT.equals(((UIToolBar) toolbar).getOrientation());
     }
+    // TODO use StyleClasses
+    writer.writeClassAttribute("tobago-toolbar-div-inner" + (right ? " tobago-toolbar-orientation-right" : ""));
 
-    if (!ToolBarTag.LABEL_OFF.equals(labelPosition)) {
-      writer.startElement(HtmlConstants.TD, null);
-      writer.writeClassAttribute("tobago-toolbar-label-td");
-      writer.writeAttribute(HtmlAttributes.ALIGN, "center", false);
-      if (popupMenu != null) {
-        writer.writeAttribute(HtmlAttributes.STYLE, "padding-right: 3px;", false);
-        // TODO: make this '3px' configurable
-      }
-      if (label.getText() != null) {
-        renderAnchorBegin(facesContext, writer, command, label, disabled);
-        HtmlRendererUtil.writeLabelWithAccessKey(writer, label);
-        writer.endElement(HtmlConstants.A);
-      }
-      writer.endElement(HtmlConstants.TD);
-    }
-    if (!popupOn2 && popupMenu != null) {
-      renderPopupTd(facesContext, writer, command, popupMenu,
-          false);
-    }
+    super.encodeEnd(facesContext, uiComponent);
 
-    writer.endElement(HtmlConstants.TR);
-    writer.endElement(HtmlConstants.TABLE);
+    writer.endElement(HtmlConstants.DIV);
     writer.endElement(HtmlConstants.DIV);
   }
 
-  private String createOnClick(FacesContext facesContext,
-      UIComponent component) {
-    if (component.getFacet(FACET_MENUPOPUP) != null
-        && ((UICommand) component).getAction() == null
-        && ((UICommand) component).getActionListener() == null
-        && ((UICommand) component).getActionListeners().length == 0) {
-      String searchId = component.getClientId(facesContext)
-          + MenuBarRenderer.SEARCH_ID_POSTFIX;
-      return "tobagoButtonOpenMenu(this, '" + searchId + "')";
-    } else {
-      CommandRendererHelper helper
-          = new CommandRendererHelper(facesContext, (UICommand) component);
-      return helper.getOnclick();
-    }
-  }
-
-  private String getImage(FacesContext facesContext, String name,
-      String iconSize, boolean disabled, boolean selected) {
-    if (name == null) {
-      return ResourceManagerUtil.getImageWithPath(facesContext, "image/1x1.gif");
-    }
-    int pos = name.lastIndexOf('.');
-    if (pos == -1) {
-      pos = name.length(); // avoid exception if no '.' in name
-    }
-    String key = name.substring(0, pos);
-    String ext = name.substring(pos);
-
-    String size = "";
-    if (ToolBarTag.ICON_SMALL.equals(iconSize)) {
-      size = "16";
-    } else if (ToolBarTag.ICON_BIG.equals(iconSize)) {
-      size = "32";
-    }
-    String image = null;
-    ResourceManager resourceManager = ResourceManagerFactory.getResourceManager(facesContext);
-    UIViewRoot viewRoot = facesContext.getViewRoot();
-    if (disabled && selected) {
-      image = resourceManager.getImage(
-          viewRoot, key + "SelectedDisabled" + size + ext, true);
-      if (image == null) {
-        image = resourceManager.getImage(
-            viewRoot, key + "SelectedDisabled" + ext, true);
-      }
-    }
-    if (image == null && disabled) {
-      image = resourceManager.getImage(
-          viewRoot, key + "Disabled" + size + ext, true);
-      if (image == null) {
-        image = resourceManager.getImage(
-            viewRoot, key + "Disabled" + ext, true);
-      }
-    }
-    if (image == null && selected) {
-      image = resourceManager.getImage(
-          viewRoot, key + "Selected" + size + ext, true);
-      if (image == null) {
-        image = resourceManager.getImage(
-            viewRoot, key + "Selected" + ext, true);
-      }
-    }
-    if (image == null) {
-      image
-          = resourceManager.getImage(viewRoot, key + size + ext, true);
-      if (image == null) {
-        image = resourceManager.getImage(viewRoot, key + ext, true);
-      }
-    }
-    String contextPath = facesContext.getExternalContext().getRequestContextPath();
-//    LOG.info("getImage for " + name + ", " + iconSize + ", " + disabled + ", " + selected + " = " + image);
-    return contextPath + image;
+  private void setToolBarHeight(FacesContext facesContext, UIComponent component) {
+    final int height = getFixedHeight(facesContext, component);
+    HtmlRendererUtil.replaceStyleAttribute(component, "height", height);
   }
 
-  private void renderAnchorBegin(
-      FacesContext facesContext, TobagoResponseWriter writer, final UICommand command,
-      final LabelWithAccessKey label, final boolean disabled)
-      throws IOException {
-    writer.startElement(HtmlConstants.A, command);
-    // TODO use StyleClasses
-    writer.writeClassAttribute("tobago-toolBar-button-link" + (disabled ? " tobago-toolBar-button-link-disabled" : ""));
-    HtmlRendererUtil.renderTip(command, writer);
-    if (!disabled) {
-      writer.writeAttribute(HtmlAttributes.HREF, "#", false);
-      writer.writeAttribute(HtmlAttributes.ONFOCUS, "Tobago.toolbarFocus(this, event)", false);
-      String id = command.getClientId(facesContext) + SUBCOMPONENT_SEP + "link";
-      writer.writeIdAttribute(id);
-      if (label.getAccessKey() != null) {
-        if (LOG.isInfoEnabled()
-            && !AccessKeyMap.addAccessKey(facesContext, label.getAccessKey())) {
-          LOG.info("dublicated accessKey : " + label.getAccessKey());
-        }
-        HtmlRendererUtil.addClickAcceleratorKey(
-            facesContext, id, label.getAccessKey());
-      }
-    }
+  protected String getHoverClasses(boolean first, boolean last) {
+    return "tobago-toolBar-button-hover" + (first ? " tobago-toolBar-button-hover-first" : "");
   }
 
-  private void renderPopupTd(FacesContext facesContext,
-      TobagoResponseWriter writer, UIComponent command, UIComponent popupMenu,
-      boolean labelBottom)
-      throws IOException {
-    writer.startElement(HtmlConstants.TD, null);
-    if (labelBottom) {
-      writer.writeAttribute(HtmlAttributes.ROWSPAN, 2);
-    }
-
-    if (popupMenu != null) {
-      String backgroundImage = ResourceManagerUtil.getImageWithPath(facesContext,
-          "image/1x1.gif");
-      writer.startElement(HtmlConstants.DIV, null);
-      writer.writeIdAttribute(
-          command.getClientId(facesContext) + SUBCOMPONENT_SEP + "popup");
-      writer.writeClassAttribute("tobago-toolBar-button-menu");
-      writer.startElement(HtmlConstants.IMG, null);
-      writer.writeAttribute(HtmlAttributes.SRC, backgroundImage, false);
-      writer.writeClassAttribute("tobago-toolBar-button-menu-background-image");
-      writer.endElement(HtmlConstants.IMG);
-      writer.endElement(HtmlConstants.DIV);
-      popupMenu.getAttributes().put(ATTR_MENU_POPUP, Boolean.TRUE);
-      popupMenu.getAttributes().put(ATTR_MENU_POPUP_TYPE, "ToolBarButton");
-      popupMenu.setRendererType(RENDERER_TYPE_MENUBAR);
-      popupMenu.getAttributes().remove(ATTR_LABEL);
-      popupMenu.getAttributes().put(ATTR_IMAGE, "image/toolbarButtonMenu.gif");
-      RenderUtil.encode(facesContext, popupMenu);
-    }
-
-    writer.endElement(HtmlConstants.TD);
+  protected String getTableClasses(boolean selected, boolean disabled) {
+    return "tobago-toolbar-button-table tobago-toolbar-button-table-"
+        + (selected ? "selected-" : "") + (disabled ? "disabled" : "enabled");
   }
 
-  private void setToolBarHeight(FacesContext facesContext,
-      UIComponent component) {
-    final int height = getFixedHeight(facesContext, component);
-    HtmlRendererUtil.replaceStyleAttribute(component, "height", height);
+  protected String getDivClasses(boolean selected, boolean disabled) {
+    return "tobago-toolbar-button tobago-toolbar-button-"
+        + (selected ? "selected-" : "") + (disabled ? "disabled" : "enabled");
   }
 
-  public int getFixedHeight(FacesContext facesContext, UIComponent component) {
-    final Map attributes = component.getAttributes();
-    final String labelPosition = (String) attributes.get(ATTR_LABEL_POSITION);
-    final String iconSize = (String) attributes.get(ATTR_ICON_SIZE);
-
-    final String key = iconSize + "_" + labelPosition + "_Height";
-    return getConfiguredValue(facesContext, component, key);
-  }
 }

Added: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java?rev=697172&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java (added)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java Fri Sep 19 11:17:00 2008
@@ -0,0 +1,490 @@
+package org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DISABLED;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ICON_SIZE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_IMAGE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL_POSITION;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MENU_POPUP;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MENU_POPUP_TYPE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_VALUE;
+import static org.apache.myfaces.tobago.TobagoConstants.FACET_ITEMS;
+import static org.apache.myfaces.tobago.TobagoConstants.FACET_MENUPOPUP;
+import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_MENUBAR;
+import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
+import org.apache.myfaces.tobago.component.ComponentUtil;
+import org.apache.myfaces.tobago.component.UIMenuSelectOne;
+import org.apache.myfaces.tobago.component.UISelectBooleanCommand;
+import org.apache.myfaces.tobago.component.UISelectOneCommand;
+import org.apache.myfaces.tobago.context.ResourceManager;
+import org.apache.myfaces.tobago.context.ResourceManagerFactory;
+import org.apache.myfaces.tobago.context.ResourceManagerUtil;
+import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
+import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
+import org.apache.myfaces.tobago.renderkit.RenderUtil;
+import org.apache.myfaces.tobago.renderkit.html.CommandRendererHelper;
+import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
+import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
+import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
+import org.apache.myfaces.tobago.taglib.component.ToolBarTag;
+import org.apache.myfaces.tobago.util.AccessKeyMap;
+import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
+
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIPanel;
+import javax.faces.component.UISelectBoolean;
+import javax.faces.component.UISelectOne;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.model.SelectItem;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+public abstract class ToolBarRendererBase extends LayoutableRendererBase {
+
+  protected String getLabelPosition(UIComponent component) {
+    return (String) component.getAttributes().get(ATTR_LABEL_POSITION);
+  }
+
+  protected String getIconSize(UIComponent component) {
+    return (String) component.getAttributes().get(ATTR_ICON_SIZE);
+  }
+
+  public void encodeEnd(FacesContext context, UIComponent uiComponent) throws IOException {
+    UIPanel toolbar = (UIPanel) uiComponent;
+
+    TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(context);
+    List children = toolbar.getChildren();
+
+    boolean first = true;
+    for (Iterator iter = children.iterator(); iter.hasNext();) {
+      UIComponent component = (UIComponent) iter.next();
+      if (component instanceof UICommand) {
+        boolean last = !iter.hasNext();
+        renderToolbarCommand(context, (UICommand) component, writer, first, last);
+        first = false;
+      } else {
+        LOG.error("Illegal UIComponent class in toolbar :" + component.getClass().getName());
+      }
+    }
+  }
+
+  private void renderToolbarCommand(FacesContext facesContext,
+      final UICommand command, TobagoResponseWriter writer, boolean first, boolean last)
+      throws IOException {
+    if (command instanceof UISelectBooleanCommand) {
+      renderSelectBoolean(facesContext, command, writer, first, last);
+    } else if (command instanceof UISelectOneCommand) {
+      renderSelectOne(facesContext, command, writer, first, last);
+    } else {
+      if (command.getFacet(FACET_ITEMS) != null) {
+        UIComponent facet = command.getFacet(FACET_ITEMS);
+        if (facet instanceof UISelectBoolean) {
+          renderSelectBoolean(facesContext, command, writer, first, last);
+        } else if (facet instanceof UISelectOne) {
+          renderSelectOne(facesContext, command, writer, first, last);
+        }
+      } else {
+        String onClick = createOnClick(facesContext, command);
+        renderToolbarButton(facesContext, command, writer, first, last, false, onClick);
+      }
+    }
+  }
+
+  private void renderSelectOne(FacesContext facesContext, UICommand command,
+      TobagoResponseWriter writer, boolean first, boolean last)
+      throws IOException {
+
+    String onclick = createOnClick(facesContext, command);
+
+    List<SelectItem> items;
+
+    UIMenuSelectOne radio = (UIMenuSelectOne) command.getFacet(FACET_ITEMS);
+    if (radio == null) {
+      items = ComponentUtil.getSelectItems(command);
+      radio = ComponentUtil.createUIMenuSelectOneFacet(facesContext, command);
+      radio.setId(facesContext.getViewRoot().createUniqueId());
+    } else {
+      items = ComponentUtil.getSelectItems(radio);
+    }
+
+
+    if (radio != null) {
+      Object value = radio.getValue();
+
+      boolean markFirst = !ComponentUtil.hasSelectedValue(items, value);
+      String radioId = radio.getClientId(facesContext);
+      String onClickPrefix = "menuSetRadioValue('" + radioId + "', '";
+      String onClickPostfix = onclick != null ? "') ; " + onclick : "";
+      for (SelectItem item : items) {
+        final String labelText = item.getLabel();
+        if (labelText != null) {
+          command.getAttributes().put(ATTR_LABEL, labelText);
+        } else {
+          LOG.warn("Menu item has label=null. UICommand.getClientId()="
+              + command.getClientId(facesContext));
+        }
+
+        String image = null;
+        if (item instanceof org.apache.myfaces.tobago.model.SelectItem) {
+          image = ((org.apache.myfaces.tobago.model.SelectItem) item).getImage();
+        } else if (LOG.isDebugEnabled()) {
+          LOG.debug("select item is not " + org.apache.myfaces.tobago.model.SelectItem.class.getName());
+        }
+        if (image == null) {
+          image = "image/1x1.gif";
+        }
+        command.getAttributes().put(ATTR_IMAGE, image);
+
+        if (item.getDescription() != null) {
+          command.getAttributes().put(ATTR_TIP, item.getDescription());
+        }
+
+
+        String formattedValue
+            = RenderUtil.getFormattedValue(facesContext, radio, item.getValue());
+        onclick = onClickPrefix + formattedValue + onClickPostfix;
+        final boolean checked;
+        if (item.getValue().equals(value) || markFirst) {
+          checked = true;
+          markFirst = false;
+          writer.writeJavascript("    " + onClickPrefix + formattedValue + "');");
+        } else {
+          checked = false;
+        }
+
+        renderToolbarButton(facesContext, command, writer, first, last, checked, onclick);
+
+      }
+    }
+
+  }
+
+  private void renderSelectBoolean(FacesContext facesContext, UICommand command,
+      TobagoResponseWriter writer, boolean first, boolean last)
+      throws IOException {
+
+    UIComponent checkbox = command.getFacet(FACET_ITEMS);
+    if (checkbox == null) {
+      checkbox = ComponentUtil.createUISelectBooleanFacet(facesContext, command);
+      checkbox.setId(facesContext.getViewRoot().createUniqueId());
+    }
+
+    final boolean checked = ComponentUtil.getBooleanAttribute(checkbox, ATTR_VALUE);
+
+    String onClick = createOnClick(facesContext, command);
+
+    String clientId = checkbox.getClientId(facesContext);
+    onClick = RenderUtil.addMenuCheckToggle(clientId, onClick);
+    if (checked) {
+      writer.writeJavascript("    menuCheckToggle('" + clientId + "');\n");
+    }
+
+    renderToolbarButton(facesContext, command, writer, first, last, checked, onClick);
+  }
+
+  private void renderToolbarButton(
+      FacesContext facesContext, final UICommand command, TobagoResponseWriter writer,
+      boolean first, boolean last, boolean selected, String onClick)
+      throws IOException {
+    if (!command.isRendered()) {
+      return;
+    }
+
+    final String clientId = command.getClientId(facesContext);
+    final boolean disabled = ComponentUtil.getBooleanAttribute(command, ATTR_DISABLED);
+    final LabelWithAccessKey label = new LabelWithAccessKey(command);
+    final UIComponent popupMenu = command.getFacet(FACET_MENUPOPUP);
+
+    String labelPosition = getLabelPosition(command.getParent());
+    String iconSize = getIconSize(command.getParent());
+
+
+    String iconName = (String) command.getAttributes().get(ATTR_IMAGE);
+    String image = getImage(facesContext, iconName, iconSize, disabled, selected);
+    String graphicId = clientId + SUBCOMPONENT_SEP + "icon";
+
+    final String hover = getHoverClasses(first, last);
+    final String mouseOverScript = "Tobago.toolbarMousesover(this, '" + hover + "', '" + graphicId + "');";
+    final String mouseOutScript = "Tobago.toolbarMousesout(this, '" + hover + "', '" + graphicId + "');";
+
+    writer.startElement(HtmlConstants.DIV, null);
+    writer.writeIdAttribute(command.getClientId(facesContext));
+    String divClasses = getDivClasses(selected, disabled);
+
+    writer.writeClassAttribute(divClasses);
+    if (!disabled) {
+      writer.writeAttribute(HtmlAttributes.ONMOUSEOVER, mouseOverScript, null);
+      writer.writeAttribute(HtmlAttributes.ONMOUSEOUT, mouseOutScript, null);
+      writer.writeAttribute(HtmlAttributes.ONCLICK, onClick, null);
+    }
+    writer.startElement(HtmlConstants.TABLE, null);
+    writer.writeAttribute(HtmlAttributes.CELLPADDING, 0);
+    writer.writeAttribute(HtmlAttributes.CELLSPACING, 0);
+    writer.writeAttribute(HtmlAttributes.SUMMARY, "", false);
+    writer.writeAttribute(HtmlAttributes.BORDER, 0);
+    String tableClasses = getTableClasses(selected, disabled);
+    writer.writeClassAttribute(tableClasses);
+    writer.startElement(HtmlConstants.TR, null);
+
+    boolean anchorOnLabel = label.getText() != null && !ToolBarTag.LABEL_OFF.equals(labelPosition);
+
+    if (!ToolBarTag.ICON_OFF.equals(iconSize)) {
+      HtmlRendererUtil.addImageSources(facesContext, writer,
+          iconName != null ? iconName : "image/1x1.gif", graphicId);
+
+      writer.startElement(HtmlConstants.TD, command);
+      writer.writeAttribute(HtmlAttributes.ALIGN, "center", false);
+      HtmlRendererUtil.renderTip(command, writer);
+
+      boolean render1pxImage = (iconName == null
+          && (!ToolBarTag.LABEL_BOTTOM.equals(labelPosition)
+          && label.getText() != null));
+
+      if (((!ToolBarTag.LABEL_OFF.equals(labelPosition)
+          && label.getText() != null)
+          || popupMenu != null)
+          && !render1pxImage) {
+        writer.writeStyleAttribute("padding-right: 3px;");
+        // TODO: make this '3px' configurable
+      }
+
+      String className = getIconClass(iconSize);
+
+      if (!anchorOnLabel) {
+        renderAnchorBegin(facesContext, writer, command, label, disabled);
+      }
+      writer.startElement(HtmlConstants.IMG, command);
+      writer.writeIdAttribute(graphicId);
+      writer.writeAttribute(HtmlAttributes.SRC, image, false);
+      writer.writeAttribute(HtmlAttributes.ALT, "", false);
+      HtmlRendererUtil.renderTip(command, writer);
+      writer.writeAttribute(HtmlAttributes.BORDER, 0);
+      writer.writeClassAttribute(className);
+      if (render1pxImage) {
+        writer.writeStyleAttribute("width: 1px;");
+      }
+
+      writer.endElement(HtmlConstants.IMG);
+      if (!anchorOnLabel) {
+        writer.endElement(HtmlConstants.A);
+      }
+      writer.endElement(HtmlConstants.TD);
+    }
+
+    boolean popupOn2 = ToolBarTag.LABEL_BOTTOM.equals(labelPosition)
+        && !ToolBarTag.ICON_OFF.equals(iconSize);
+    if (popupOn2) {
+      if (popupMenu != null) {
+        renderPopupTd(facesContext, writer, command, popupMenu,
+            true);
+      }
+      writer.endElement(HtmlConstants.TR);
+      writer.startElement(HtmlConstants.TR, null);
+    }
+
+    if (!ToolBarTag.LABEL_OFF.equals(labelPosition)) {
+      writer.startElement(HtmlConstants.TD, null);
+      writer.writeClassAttribute("tobago-toolbar-label-td");
+      writer.writeAttribute(HtmlAttributes.ALIGN, "center", false);
+      if (popupMenu != null) {
+        writer.writeAttribute(HtmlAttributes.STYLE, "padding-right: 3px;", false);
+        // TODO: make this '3px' configurable
+      }
+      if (label.getText() != null) {
+        renderAnchorBegin(facesContext, writer, command, label, disabled);
+        HtmlRendererUtil.writeLabelWithAccessKey(writer, label);
+        writer.endElement(HtmlConstants.A);
+      }
+      writer.endElement(HtmlConstants.TD);
+    }
+    if (!popupOn2 && popupMenu != null) {
+      renderPopupTd(facesContext, writer, command, popupMenu,
+          false);
+    }
+
+    writer.endElement(HtmlConstants.TR);
+    writer.endElement(HtmlConstants.TABLE);
+    writer.endElement(HtmlConstants.DIV);
+  }
+
+  protected String getIconClass(String iconSize) {
+    return "tobago-image-default tobago-toolBar-button-image tobago-toolBar-button-image-" + iconSize;
+  }
+
+  protected abstract String getHoverClasses(boolean first, boolean last);
+
+  protected abstract String getTableClasses(boolean selected, boolean disabled);
+
+  protected abstract String getDivClasses(boolean selected, boolean disabled);
+
+  private String createOnClick(FacesContext facesContext, UIComponent component) {
+    if (component.getFacet(FACET_MENUPOPUP) != null
+        && ((UICommand) component).getAction() == null
+        && ((UICommand) component).getActionListener() == null
+        && ((UICommand) component).getActionListeners().length == 0) {
+      String searchId = component.getClientId(facesContext)
+          + MenuBarRenderer.SEARCH_ID_POSTFIX;
+      return "tobagoButtonOpenMenu(this, '" + searchId + "')";
+    } else {
+      CommandRendererHelper helper
+          = new CommandRendererHelper(facesContext, (UICommand) component);
+      return helper.getOnclick();
+    }
+  }
+
+  private String getImage(FacesContext facesContext, String name,
+      String iconSize, boolean disabled, boolean selected) {
+    if (name == null) {
+      return ResourceManagerUtil.getImageWithPath(facesContext, "image/1x1.gif");
+    }
+    int pos = name.lastIndexOf('.');
+    if (pos == -1) {
+      pos = name.length(); // avoid exception if no '.' in name
+    }
+    String key = name.substring(0, pos);
+    String ext = name.substring(pos);
+
+    String size = "";
+    if (ToolBarTag.ICON_SMALL.equals(iconSize)) {
+      size = "16";
+    } else if (ToolBarTag.ICON_BIG.equals(iconSize)) {
+      size = "32";
+    }
+    String image = null;
+    ResourceManager resourceManager = ResourceManagerFactory.getResourceManager(facesContext);
+    UIViewRoot viewRoot = facesContext.getViewRoot();
+    if (disabled && selected) {
+      image = resourceManager.getImage(
+          viewRoot, key + "SelectedDisabled" + size + ext, true);
+      if (image == null) {
+        image = resourceManager.getImage(
+            viewRoot, key + "SelectedDisabled" + ext, true);
+      }
+    }
+    if (image == null && disabled) {
+      image = resourceManager.getImage(
+          viewRoot, key + "Disabled" + size + ext, true);
+      if (image == null) {
+        image = resourceManager.getImage(
+            viewRoot, key + "Disabled" + ext, true);
+      }
+    }
+    if (image == null && selected) {
+      image = resourceManager.getImage(
+          viewRoot, key + "Selected" + size + ext, true);
+      if (image == null) {
+        image = resourceManager.getImage(
+            viewRoot, key + "Selected" + ext, true);
+      }
+    }
+    if (image == null) {
+      image
+          = resourceManager.getImage(viewRoot, key + size + ext, true);
+      if (image == null) {
+        image = resourceManager.getImage(viewRoot, key + ext, true);
+      }
+    }
+    String contextPath = facesContext.getExternalContext().getRequestContextPath();
+//    LOG.info("getImage for " + name + ", " + iconSize + ", " + disabled + ", " + selected + " = " + image);
+    return contextPath + image;
+  }
+
+  private void renderAnchorBegin(
+      FacesContext facesContext, TobagoResponseWriter writer, final UICommand command,
+      final LabelWithAccessKey label, final boolean disabled)
+      throws IOException {
+    writer.startElement(HtmlConstants.A, command);
+    // TODO use StyleClasses
+    writer.writeClassAttribute(getAnchorClass(disabled));
+    HtmlRendererUtil.renderTip(command, writer);
+    if (!disabled) {
+      writer.writeAttribute(HtmlAttributes.HREF, "#", false);
+      writer.writeAttribute(HtmlAttributes.ONFOCUS, "Tobago.toolbarFocus(this, event)", false);
+      String id = command.getClientId(facesContext) + SUBCOMPONENT_SEP + "link";
+      writer.writeIdAttribute(id);
+      if (label.getAccessKey() != null) {
+        if (LOG.isInfoEnabled()
+            && !AccessKeyMap.addAccessKey(facesContext, label.getAccessKey())) {
+          LOG.info("dublicated accessKey : " + label.getAccessKey());
+        }
+        HtmlRendererUtil.addClickAcceleratorKey(
+            facesContext, id, label.getAccessKey());
+      }
+    }
+  }
+
+  protected String getAnchorClass(boolean disabled) {
+    return "tobago-toolBar-button-link" + (disabled ? " tobago-toolBar-button-link-disabled" : "");
+  }
+
+  private void renderPopupTd(FacesContext facesContext,
+      TobagoResponseWriter writer, UIComponent command, UIComponent popupMenu,
+      boolean labelBottom)
+      throws IOException {
+    writer.startElement(HtmlConstants.TD, null);
+    if (labelBottom) {
+      writer.writeAttribute(HtmlAttributes.ROWSPAN, 2);
+    }
+
+    if (popupMenu != null) {
+      String backgroundImage = ResourceManagerUtil.getImageWithPath(facesContext,
+          "image/1x1.gif");
+      writer.startElement(HtmlConstants.DIV, null);
+      writer.writeIdAttribute(
+          command.getClientId(facesContext) + SUBCOMPONENT_SEP + "popup");
+      writer.writeClassAttribute("tobago-toolBar-button-menu");
+      writer.startElement(HtmlConstants.IMG, null);
+      writer.writeAttribute(HtmlAttributes.SRC, backgroundImage, false);
+      writer.writeClassAttribute("tobago-toolBar-button-menu-background-image");
+      writer.endElement(HtmlConstants.IMG);
+      writer.endElement(HtmlConstants.DIV);
+      popupMenu.getAttributes().put(ATTR_MENU_POPUP, Boolean.TRUE);
+      popupMenu.getAttributes().put(ATTR_MENU_POPUP_TYPE, "ToolBarButton");
+      popupMenu.setRendererType(RENDERER_TYPE_MENUBAR);
+      popupMenu.getAttributes().remove(ATTR_LABEL);
+      popupMenu.getAttributes().put(ATTR_IMAGE, "image/toolbarButtonMenu.gif");
+      RenderUtil.encode(facesContext, popupMenu);
+    }
+
+    writer.endElement(HtmlConstants.TD);
+  }
+
+  public int getFixedHeight(FacesContext facesContext, UIComponent component) {
+    final Map attributes = component.getAttributes();
+    final String labelPosition = getLabelPosition(component);
+    final String iconSize = getIconSize(component);
+    final String key = iconSize + "_" + labelPosition + "_Height";
+    return getConfiguredValue(facesContext, component, key);
+  }
+
+  public void encodeChildren(FacesContext facesContext, UIComponent component)
+      throws IOException {
+  }
+
+  public boolean getRendersChildren() {
+    return true;
+  }
+
+}

Propchange: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/mozilla/style/style.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/mozilla/style/style.css?rev=697172&r1=697171&r2=697172&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/mozilla/style/style.css (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/mozilla/style/style.css Fri Sep 19 11:17:00 2008
@@ -45,4 +45,8 @@
 .tobago-toolBar-button-menu-background-image {
   width: 20px;
   height: 17px;
+}
+
+div.tobago-tabnavigationbar {
+  top: -2px;
 }
\ No newline at end of file

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/msie/style/style.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/msie/style/style.css?rev=697172&r1=697171&r2=697172&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/msie/style/style.css (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/msie/style/style.css Fri Sep 19 11:17:00 2008
@@ -27,8 +27,7 @@
 .tobago-box-toolbar-div {
   top: -15px;
   right: -2px;
-  height: 31px;
-/*  padding-top: 1px;*/
+  height: 31px; /*  padding-top: 1px;*/
 }
 
 .tobago-box-toolbar-span {
@@ -36,23 +35,23 @@
 }
 
 .tobago-date-default {
-  margin-top: -1 px;
-  margin-bottom: -1 px;
+  margin-top: -1px;
+  margin-bottom: -1px;
 }
 
 .tobago-textArea-default {
-  margin-top: -1 px;
-  margin-bottom: -1 px;
+  margin-top: -1px;
+  margin-bottom: -1px;
 }
 
 .tobago-in-default {
-  margin-top: -1 px;
-  margin-bottom: -1 px;
+  margin-top: -1px;
+  margin-bottom: -1px;
 }
 
 textarea.tobago-richTextEditor-body {
-  margin-top: -1 px;
-  margin-bottom: -1 px;
+  margin-top: -1px;
+  margin-bottom: -1px;
 }
 
 .tobago-label-default {
@@ -64,23 +63,25 @@
 }
 
 .tobago-time-input {
- margin-top: -1px;
- margin-bottom: -1px;
+  margin-top: -1px;
+  margin-bottom: -1px;
 }
 
 .tobago-toolBar-default {
   height: 31px;
 }
+
 /*
 .tobago-toolBar-div-inner {
  height: 27px;
 }*/
 
 .tobago-toolBar-button-hover-first {
- padding-left: 6px;
+  padding-left: 6px;
 }
+
 .tobago-box-toolBar-button-hover-last {
- padding-right: 6px;
+  padding-right: 6px;
 }
 
 .tobago-toolBar-button-image {
@@ -89,6 +90,10 @@
   top: -1px;
 }
 
+div.tobago-tabnavigationbar {
+  margin-right: 6px;
+  top: -1px;
+}
 
 .tobago-toolBar-button-popup-span {
   padding-right: 10px;
@@ -98,5 +103,5 @@
 }
 
 a:link.tobago-toolBar-button-link, a:visited.tobago-toolBar-button-link, a:active.tobago-toolBar-button-link {
-   color: #000000;
+  color: #000000;
 }
\ No newline at end of file

Added: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tabNext.gif
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tabNext.gif?rev=697172&view=auto
==============================================================================
Binary file - no diff available.

Propchange: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tabNext.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tabNextDisabled.gif
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tabNextDisabled.gif?rev=697172&view=auto
==============================================================================
Binary file - no diff available.

Propchange: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tabNextDisabled.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tabPrev.gif
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tabPrev.gif?rev=697172&view=auto
==============================================================================
Binary file - no diff available.

Propchange: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tabPrev.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tabPrevDisabled.gif
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tabPrevDisabled.gif?rev=697172&view=auto
==============================================================================
Binary file - no diff available.

Propchange: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/image/tabPrevDisabled.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message