myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r918472 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/component/ core/src/main/java/org/apache/myfaces/tobago/taglib/component/ theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/...
Date Wed, 03 Mar 2010 13:51:22 GMT
Author: lofwyr
Date: Wed Mar  3 13:51:22 2010
New Revision: 918472

URL: http://svn.apache.org/viewvc?rev=918472&view=rev
Log:
TOBAGO-176: Addition: showNavigationBar implemented in Tobago 1.5.x

Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TabGroupTagDeclaration.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java?rev=918472&r1=918471&r2=918472&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
(original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
Wed Mar  3 13:51:22 2010
@@ -153,6 +153,7 @@
   public static final String SHOW_HEADER = "showHeader";
   public static final String SHOW_ICONS = "showIcons";
   public static final String SHOW_JUNCTIONS = "showJunctions";
+  public static final String SHOW_NAVIGATION_BAR = "showNavigationBar";
   public static final String SHOW_PAGE_RANGE = "showPageRange";
   public static final String SHOW_ROOT = "showRoot";
   public static final String SHOW_ROOT_JUNCTION = "showRootJunction";

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TabGroupTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TabGroupTagDeclaration.java?rev=918472&r1=918471&r2=918472&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TabGroupTagDeclaration.java
(original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TabGroupTagDeclaration.java
Wed Mar  3 13:51:22 2010
@@ -34,7 +34,7 @@
 import org.apache.myfaces.tobago.taglib.decl.IsImmediateCommand;
 
 /**
- * Renders a tabpanel.
+ * Renders a tab group which contains tab panels.
  */
 @Tag(name = "tabGroup")
 @BodyContentDescription(anyTagOf = "(<tc:tab>* ")
@@ -49,15 +49,13 @@
 public interface TabGroupTagDeclaration
     extends HasIdBindingAndRendered, IsImmediateCommand, HasAction, HasActionListener, HasMarkup,
     IsGridLayoutComponent, IsGridLayoutContainer {
+
   /**
-   * Deprecated! Use 'switchType' instead.
-   * Flag indicating that tab switching is done by server request.
-   * @deprecated
+   * Flag indicating that the tab navigation bar is rendered.
    */
   @TagAttribute
-  @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "Boolean.FALSE")
-  @Deprecated
-  void setServerside(String serverside);
+  @UIComponentTagAttribute(type = "boolean", defaultValue = "true")
+  void setShowNavigationBar(String showNavigationBar);
 
   /**
    * Indicating how tab switching should be done.

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java?rev=918472&r1=918471&r2=918472&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
(original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
Wed Mar  3 13:51:22 2010
@@ -287,8 +287,10 @@
     if (currentWidth.greaterThan(width)) {
       map.setWidth(currentWidth);
       map.setLeft(width.subtract(toolbarWidth).subtract(currentWidth));
-    } else {
+    } else if (tabGroup.isShowNavigationBar()) {
       map.setWidth(width.subtract(toolbarWidth));
+    } else {
+      map.setWidth(width);
     }
     map.setOverflow(Overflow.HIDDEN);
     map.setPosition(Position.ABSOLUTE);
@@ -312,55 +314,6 @@
     writer.startElement(HtmlConstants.TR, tabGroup);
     writer.writeAttribute(HtmlAttributes.VALIGN, "bottom", false);
 
-    Application application = facesContext.getApplication();
-
-    // tool bar
-
-    UICommand scrollLeft = (UICommand) application.createComponent(UICommand.COMPONENT_TYPE);
-    scrollLeft.setId(tabGroup.getId() + "__" + virtualTab + "__" + "previous");
-    //scrollLeft.setId(facesContext.getViewRoot().createUniqueId());
-    scrollLeft.setRendererType(null);
-    scrollLeft.getAttributes().put(Attributes.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(Attributes.ONCLICK, "tobago_previousTab('" + switchType
+ "','" + clientId + "',"
-          + tabGroup.getChildCount() + ')');
-    } else {
-      scrollLeft.getAttributes().put(Attributes.ONCLICK, "javascript:false");
-    }
-    UICommand scrollRight = (UICommand) application.createComponent(UICommand.COMPONENT_TYPE);
-    scrollRight.setId(tabGroup.getId() + "__" + virtualTab + "__" + "next");
-    scrollRight.setRendererType(null);
-    scrollRight.getAttributes().put(Attributes.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(Attributes.ONCLICK, "tobago_nextTab('" + switchType
+ "','" + clientId + "',"
-          + tabGroup.getChildCount() + ')');
-    } else {
-      scrollRight.getAttributes().put(Attributes.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(Facets.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(AbstractUIToolBar.ICON_OFF);
-    toolBar.getChildren().add(scrollLeft);
-    toolBar.getChildren().add(scrollRight);
-    //toolBar.getChildren().add(commandList);
-    tabGroup.getFacets().put(Facets.TOOL_BAR, toolBar);
-
     UITab activeTab = null;
 
     int index = 0;
@@ -481,8 +434,10 @@
     writer.endElement(HtmlConstants.TR);
     writer.endElement(HtmlConstants.TABLE);
     writer.endElement(HtmlConstants.DIV);
-    if (toolBar != null) { // todo: configurable later
-      renderToolbar(facesContext, writer, toolBar, width.subtract(toolbarWidth), toolbarWidth);
+    
+    if (tabGroup.isShowNavigationBar()) {
+      UIToolBar toolBar = createToolBar(facesContext, tabGroup, virtualTab, switchType, tabList);
+      renderToolBar(facesContext, writer, toolBar, width.subtract(toolbarWidth), toolbarWidth);
     }
     writer.endElement(HtmlConstants.DIV);
     writer.endElement(HtmlConstants.TD);
@@ -497,8 +452,59 @@
     writer.endElement(HtmlConstants.TABLE);
   }
 
+  private UIToolBar createToolBar(
+      FacesContext facesContext, UITabGroup tabGroup, int virtualTab, String switchType,
TabList tabList) {
+    final String clientId = tabGroup.getClientId(facesContext);
+    Application application = facesContext.getApplication();
+    UICommand scrollLeft = (UICommand) application.createComponent(UICommand.COMPONENT_TYPE);
+    scrollLeft.setId(tabGroup.getId() + "__" + virtualTab + "__" + "previous");
+    //scrollLeft.setId(facesContext.getViewRoot().createUniqueId());
+    scrollLeft.setRendererType(null);
+    scrollLeft.getAttributes().put(Attributes.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(Attributes.ONCLICK, "tobago_previousTab('" + switchType
+ "','" + clientId + "',"
+          + tabGroup.getChildCount() + ')');
+    } else {
+      scrollLeft.getAttributes().put(Attributes.ONCLICK, "javascript:false");
+    }
+    UICommand scrollRight = (UICommand) application.createComponent(UICommand.COMPONENT_TYPE);
+    scrollRight.setId(tabGroup.getId() + "__" + virtualTab + "__" + "next");
+    scrollRight.setRendererType(null);
+    scrollRight.getAttributes().put(Attributes.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(Attributes.ONCLICK, "tobago_nextTab('" + switchType
+ "','" + clientId + "',"
+          + tabGroup.getChildCount() + ')');
+    } else {
+      scrollRight.getAttributes().put(Attributes.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(Facets.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(AbstractUIToolBar.ICON_OFF);
+    toolBar.getChildren().add(scrollLeft);
+    toolBar.getChildren().add(scrollRight);
+    //toolBar.getChildren().add(commandList);
+    tabGroup.getFacets().put(Facets.TOOL_BAR, toolBar);
+    return toolBar;
+  }
+  
   // todo: this is quite the same as in ButtonRenderer
-  private void renderToolbar(FacesContext facesContext, TobagoResponseWriter writer, UIPanel
toolbar, Measure width,
+  private void renderToolBar(FacesContext facesContext, TobagoResponseWriter writer, UIPanel
toolbar, Measure width,
       Measure navigationBarWidth) throws IOException {
     writer.startElement(HtmlConstants.DIV, null);
     Style map = new Style();
@@ -512,8 +518,7 @@
     writer.endElement(HtmlConstants.DIV);
   }
 
-  protected void encodeContent(
-      TobagoResponseWriter writer, FacesContext facesContext, UITab activeTab, Style body)
+  protected void encodeContent(TobagoResponseWriter writer, FacesContext facesContext, UITab
activeTab, Style body)
       throws IOException {
 
     writer.startElement(HtmlConstants.TR, activeTab);



Mime
View raw message