myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r619273 - in /myfaces/tomahawk/branches/1_2_0/core/src/main/java/org/apache/myfaces/custom/tabbedpane: AbstractHtmlPanelTab.java AbstractHtmlPanelTabbedPane.java
Date Thu, 07 Feb 2008 05:25:27 GMT
Author: lu4242
Date: Wed Feb  6 21:25:27 2008
New Revision: 619273

URL: http://svn.apache.org/viewvc?rev=619273&view=rev
Log:
Created Abstract base classes

Added:
    myfaces/tomahawk/branches/1_2_0/core/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTab.java
  (with props)
    myfaces/tomahawk/branches/1_2_0/core/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTabbedPane.java
  (with props)

Added: myfaces/tomahawk/branches/1_2_0/core/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTab.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/branches/1_2_0/core/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTab.java?rev=619273&view=auto
==============================================================================
--- myfaces/tomahawk/branches/1_2_0/core/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTab.java
(added)
+++ myfaces/tomahawk/branches/1_2_0/core/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTab.java
Wed Feb  6 21:25:27 2008
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+package org.apache.myfaces.custom.tabbedpane;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.html.HtmlPanelGroup;
+
+import org.apache.myfaces.component.UserRoleAware;
+import org.apache.myfaces.component.UserRoleUtils;
+
+/**
+ * Manage a stack of JSF components and allow for one child component to be choosen for rendering.
The behaviour
+ * is similar to the CardLayout of Java Swing. Property <code>selectedPanel</code>
defines the id of the child
+ * to be rendered. If no child panel is selected or if the selected panel can not be found
the first child is rendered.
+ *
+ * @author <a href="mailto:oliver@rossmueller.com">Oliver Rossmueller</a>
+ * @version $Revision$ $Date$
+ */
+abstract class AbstractHtmlPanelTab extends HtmlPanelGroup implements NamingContainer,UserRoleAware
+{
+    
+    public boolean isRendered()
+    {
+        if (!UserRoleUtils.isVisibleOnUserRole(this)) {
+            return false;
+        }
+        return super.isRendered();
+    }
+    
+}

Propchange: myfaces/tomahawk/branches/1_2_0/core/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTab.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/branches/1_2_0/core/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTab.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tomahawk/branches/1_2_0/core/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTabbedPane.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/branches/1_2_0/core/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTabbedPane.java?rev=619273&view=auto
==============================================================================
--- myfaces/tomahawk/branches/1_2_0/core/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTabbedPane.java
(added)
+++ myfaces/tomahawk/branches/1_2_0/core/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTabbedPane.java
Wed Feb  6 21:25:27 2008
@@ -0,0 +1,199 @@
+/*
+ * 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.
+ */
+package org.apache.myfaces.custom.tabbedpane;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UINamingContainer;
+import javax.faces.component.html.HtmlPanelGroup;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.MethodBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+
+/**
+ * @author Manfred Geiler (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public abstract class AbstractHtmlPanelTabbedPane extends HtmlPanelGroup
+{
+
+    //private static final Log log = LogFactory.getLog(HtmlPanelTabbedPane.class);
+    
+    private static final int DEFAULT_BORDER = Integer.MIN_VALUE;
+    
+
+    public void decode(FacesContext context)
+    {
+        super.decode(context);    //To change body of overridden methods use File | Settings
| File Templates.
+    }
+
+    public abstract int getSelectedIndex();
+    
+    public abstract void setSelectedIndex(int selectedIndex);
+    
+    public void processDecodes(javax.faces.context.FacesContext context)
+   {
+       if (context == null) throw new NullPointerException("context");
+       decode(context);
+
+       int tabIdx = 0;
+       int selectedIndex = getSelectedIndex();
+
+       Iterator it = getFacetsAndChildren();
+
+       while (it.hasNext())
+       {
+           UIComponent childOrFacet = getUIComponent((UIComponent) it.next());
+           if (childOrFacet instanceof HtmlPanelTab) {
+               if (isClientSide() || selectedIndex == tabIdx) {
+                   childOrFacet.processDecodes(context);
+               }
+               tabIdx++;
+           } else {
+               childOrFacet.processDecodes(context);
+           }
+       }
+   }
+
+    public void processValidators(FacesContext context)
+    {
+        if (context == null) throw new NullPointerException("context");
+        if (!isRendered()) return;
+
+        int tabIdx = 0;
+        int selectedIndex = getSelectedIndex();
+
+        Iterator it = getFacetsAndChildren();
+
+        while (it.hasNext())
+        {
+            UIComponent childOrFacet = getUIComponent((UIComponent) it.next());
+            if (childOrFacet instanceof HtmlPanelTab) {
+                if (isClientSide() || selectedIndex == tabIdx) {
+                    childOrFacet.processValidators(context);
+                }
+                tabIdx++;
+            } else {
+                childOrFacet.processValidators(context);
+            }
+        }
+    }
+
+    public void processUpdates(FacesContext context)
+    {
+        if (context == null) throw new NullPointerException("context");
+        if (!isRendered()) return;
+
+        int tabIdx = 0;
+        int selectedIndex = getSelectedIndex();
+
+        Iterator it = getFacetsAndChildren();
+
+        while (it.hasNext())
+        {
+            UIComponent childOrFacet = getUIComponent((UIComponent) it.next());
+            if (childOrFacet instanceof HtmlPanelTab) {
+                if (isClientSide() || selectedIndex == tabIdx) {
+                    childOrFacet.processUpdates(context);
+                }
+                tabIdx++;
+            } else {
+                childOrFacet.processUpdates(context);
+            }
+        }
+    }
+
+    private UIComponent getUIComponent(UIComponent uiComponent)
+    {
+        /*todo: checking for UIForm is not enough - Trinidad form, etc.*/
+        if (uiComponent instanceof UINamingContainer || uiComponent instanceof UIForm)
+        {
+            List children = uiComponent.getChildren();
+            for (int i = 0, len = children.size(); i < len; i++)
+            {
+                uiComponent = getUIComponent((UIComponent)children.get(i));
+            }
+        }
+        return uiComponent;
+    }
+
+    public void addTabChangeListener(TabChangeListener listener)
+    {
+        addFacesListener(listener);
+    }
+
+    public void removeTabChangeListener(TabChangeListener listener)
+    {
+        removeFacesListener(listener);
+    }
+    
+    public abstract MethodBinding getTabChangeListener();
+
+    public void broadcast(FacesEvent event) throws AbortProcessingException
+    {
+        if (event instanceof TabChangeEvent)
+        {
+            TabChangeEvent tabChangeEvent = (TabChangeEvent)event;
+            if (tabChangeEvent.getComponent() == this)
+            {
+                setSelectedIndex(tabChangeEvent.getNewTabIndex());
+                getFacesContext().renderResponse();
+            }
+        }
+        super.broadcast(event);
+
+        MethodBinding tabChangeListenerBinding = getTabChangeListener();
+        if (tabChangeListenerBinding != null)
+        {
+            try
+            {
+                tabChangeListenerBinding.invoke(getFacesContext(), new Object[]{event});
+            }
+            catch (EvaluationException e)
+            {
+                Throwable cause = e.getCause();
+                if (cause != null && cause instanceof AbortProcessingException)
+                {
+                    throw (AbortProcessingException)cause;
+                }
+                else
+                {
+                    throw e;
+                }
+            }
+        }
+    }
+    
+    /**
+     * Write out information about the toggling mode - the component might
+     * be toggled server side or client side.
+     */
+    public boolean isClientSide()
+    {
+        return !isServerSideTabSwitch(); 
+    }
+    
+    public abstract boolean isServerSideTabSwitch();   
+    
+}

Propchange: myfaces/tomahawk/branches/1_2_0/core/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTabbedPane.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/branches/1_2_0/core/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTabbedPane.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL



Mime
View raw message