[richfaces-svn-commits] JBoss Rich Faces SVN: r388 - in trunk/richfaces/tabPanel/src/main/java/org/richfaces: model and 2 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Thu Apr 12 12:24:47 EDT 2007
Author: A.Skokov
Date: 2007-04-12 12:24:47 -0400 (Thu, 12 Apr 2007)
New Revision: 388
Modified:
trunk/richfaces/tabPanel/src/main/java/org/richfaces/component/TabEncoder.java
trunk/richfaces/tabPanel/src/main/java/org/richfaces/component/TabsIterator.java
trunk/richfaces/tabPanel/src/main/java/org/richfaces/component/UITab.java
trunk/richfaces/tabPanel/src/main/java/org/richfaces/component/UITabPanel.java
trunk/richfaces/tabPanel/src/main/java/org/richfaces/model/TabModel.java
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabClassBuilder.java
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabInfoCollector.java
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabRendererBase.java
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/images/TabGradientA.java
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/images/TabGradientB.java
trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java
Log:
checkstyle
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/component/TabEncoder.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/component/TabEncoder.java 2007-04-12 16:23:41 UTC (rev 387)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/component/TabEncoder.java 2007-04-12 16:24:47 UTC (rev 388)
@@ -21,10 +21,9 @@
package org.richfaces.component;
+import javax.faces.context.FacesContext;
import java.io.IOException;
-import javax.faces.context.FacesContext;
-
public interface TabEncoder {
- public void encodeTab(FacesContext context, UITab tab, boolean active) throws IOException;
+ public void encodeTab(FacesContext context, UITab tab, boolean active) throws IOException;
}
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/component/TabsIterator.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/component/TabsIterator.java 2007-04-12 16:23:41 UTC (rev 387)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/component/TabsIterator.java 2007-04-12 16:24:47 UTC (rev 388)
@@ -26,91 +26,92 @@
/**
* "sublist" iterator for iterate over child components instantiate from {@link UITab}
+ *
* @author shura (latest modification by $Author$)
* @version $Revision$ $Date$
- *
*/
class TabsIterator implements Iterator {
- static interface FilterCondition {
- public boolean isSuitable(UITab tab);
- }
-
- private FilterCondition filterCondition;
-
- /**
- *
- */
- private final UITabPanel tabsIterator;
+ static interface FilterCondition {
+ public boolean isSuitable(UITab tab);
+ }
- /**
- * Original component iterator for children
- */
- private Iterator _childs;
-
- /**
- * Next UITab in children.
- */
- private Object _next=null;
+ private FilterCondition filterCondition;
- public TabsIterator(UITabPanel tabPanel, FilterCondition filterCondition) {
- super();
+ /**
+ *
+ */
+ private final UITabPanel tabsIterator;
- this.filterCondition = filterCondition;
-
- tabsIterator = tabPanel;
- _childs = tabsIterator.getChildren().iterator();
- _next = getNextTab();
- }
- /**
- * @param tabPanel TODO
- *
- */
- public TabsIterator(UITabPanel tabPanel) {
- this(tabPanel, null);
- }
+ /**
+ * Original component iterator for children
+ */
+ private Iterator _childs;
- /* (non-Javadoc)
- * @see java.util.Iterator#hasNext()
- */
- public boolean hasNext() {
- return _next != null;
- }
+ /**
+ * Next UITab in children.
+ */
+ private Object _next = null;
- /* (non-Javadoc)
- * @see java.util.Iterator#next()
- */
- public Object next() {
- if (null == _next) {
- throw new NoSuchElementException();
- }
- Object next = _next;
- _next = getNextTab();
- return next;
- }
+ public TabsIterator(UITabPanel tabPanel, FilterCondition filterCondition) {
+ super();
- /* (non-Javadoc)
- * @see java.util.Iterator#remove()
- */
- public void remove() {
- throw new UnsupportedOperationException("tabs Iterator not support remove operation");
-
- }
-
- /**
- * Find next {@link UITab} components in children
- * @return
- */
- private Object getNextTab() {
- while (_childs.hasNext()) {
- Object element = _childs.next();
- if(element instanceof UITab) {
- UITab tab = (UITab) element;
- if (filterCondition == null || filterCondition.isSuitable(tab)) {
- return tab;
- }
- }
- }
- return null;
- }
+ this.filterCondition = filterCondition;
+
+ tabsIterator = tabPanel;
+ _childs = tabsIterator.getChildren().iterator();
+ _next = getNextTab();
+ }
+
+ /**
+ * @param tabPanel TODO
+ */
+ public TabsIterator(UITabPanel tabPanel) {
+ this(tabPanel, null);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#hasNext()
+ */
+ public boolean hasNext() {
+ return _next != null;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#next()
+ */
+ public Object next() {
+ if (null == _next) {
+ throw new NoSuchElementException();
+ }
+ Object next = _next;
+ _next = getNextTab();
+ return next;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#remove()
+ */
+ public void remove() {
+ throw new UnsupportedOperationException("tabs Iterator not support remove operation");
+
+ }
+
+ /**
+ * Find next {@link UITab} components in children
+ * @return next tab
+ */
+ private Object getNextTab() {
+ while (_childs.hasNext()) {
+ Object element = _childs.next();
+ if (element instanceof UITab) {
+ UITab tab = (UITab) element;
+ if (filterCondition == null || filterCondition.isSuitable(tab))
+ {
+ return tab;
+ }
+ }
+ }
+ return null;
+ }
}
\ No newline at end of file
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/component/UITab.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/component/UITab.java 2007-04-12 16:23:41 UTC (rev 387)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/component/UITab.java 2007-04-12 16:24:47 UTC (rev 388)
@@ -21,7 +21,11 @@
package org.richfaces.component;
-import java.io.IOException;
+import org.ajax4jsf.framework.ajax.AjaxActionComponent;
+import org.ajax4jsf.framework.ajax.AjaxComponent;
+import org.ajax4jsf.framework.ajax.AjaxSource;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.richfaces.model.TabModel;
import javax.faces.FacesException;
import javax.faces.component.ActionSource;
@@ -29,160 +33,164 @@
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.render.Renderer;
+import java.io.IOException;
-import org.ajax4jsf.framework.ajax.AjaxActionComponent;
-import org.ajax4jsf.framework.ajax.AjaxComponent;
-import org.ajax4jsf.framework.ajax.AjaxSource;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.richfaces.model.TabModel;
-
/**
* Base class for panel tab.
+ *
* @author asmirnov at exadel.com (latest modification by $Author: ishabalov $)
* @version $Revision: 1.12 $ $Date: 2007/02/21 20:35:05 $
- *
*/
//TODO remove excess interfaces
public abstract class UITab extends AjaxActionComponent implements TabModel, AjaxComponent, AjaxSource, ActionSource {
-
- public static final String COMPONENT_TYPE = "org.richfaces.Tab";
-
- private transient boolean _active = false;
-
- private String switchType;
-
- /**
- * @param context
- * @param active
- * @throws IOException
- */
- public void encodeTab(FacesContext context, boolean active) throws IOException {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.Tab";
+
+ private transient boolean _active = false;
+
+ private String switchType;
+
+ /**
+ * @param context
+ * @param active
+ * @throws IOException
+ */
+ public void encodeTab(FacesContext context, boolean active) throws IOException {
if (context == null) {
throw new NullPointerException("No FacesContext");
}
-
+
if (!isRendered()) {
return;
}
Renderer renderer = getRenderer(context);
- if(null != renderer && renderer instanceof TabEncoder) {
- ((TabEncoder)renderer).encodeTab(context,this,active);
+ if (null != renderer && renderer instanceof TabEncoder) {
+ ((TabEncoder) renderer).encodeTab(context, this, active);
}
- }
-
- /**
- * Get enclosed {@link UITabPanelPane} tab panel for this component.
- * @return
- */
- public UITabPanel getPane() throws FacesException {
- UIComponent parent = this.getParent();
- if (parent instanceof UITabPanel) {
- return (UITabPanel) parent;
- }
-
- if (parent == null) {
- return null;
- }
+ }
- throw new FacesException("UITab "+this.getClientId(getFacesContext())+"component not inside in tab panel");
- }
+ /**
+ * Get enclosed {@link UITabPanel} tab panel for this component.
+ *
+ * @return {@link UITabPanel}
+ */
+ public UITabPanel getPane() throws FacesException {
+ UIComponent parent = this.getParent();
+ if (parent instanceof UITabPanel) {
+ return (UITabPanel) parent;
+ }
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.ajax.AjaxActionComponent#setupReRender()
- */
- protected void setupReRender() {
- super.setupReRender();
- AjaxRendererUtils.addRegionByName(getFacesContext(), this, this.getId());
- }
- /**
- * @return Returns the active.
- */
- public boolean isActive() {
- return _active;
- }
+ if (parent == null) {
+ return null;
+ }
- /**
- * @param active The active to set. This method should never be called from user code.
- */
- public void setActive(boolean active) {
- _active = active;
- }
+ throw new FacesException("UITab " + this.getClientId(getFacesContext()) + "component not inside in tab panel");
+ }
- /**
- * Get Model Value for this Tab.
- * @return
- */
- public abstract Object getValue();
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.ajax.AjaxActionComponent#setupReRender()
+ */
+ protected void setupReRender() {
+ super.setupReRender();
+ AjaxRendererUtils.addRegionByName(getFacesContext(), this, this.getId());
+ }
- /**
- * Set Model Value for this Tab.
- * @param newvalue
- */
- public abstract void setValue(Object newvalue);
-
- public abstract Object getName();
- public abstract void setName(Object newvalue);
-
- public abstract boolean isDisabled();
- public abstract void setDisabled(boolean disabled);
-
- public abstract String getLabel();
- public abstract void setLabel(String newvalue);
-
- public abstract String getLabelWidth();
- public abstract void setLabelWidth(String newvalue);
-
- public abstract String getTitle();
- public abstract void setTitle(String newvalue);
+ /**
+ * @return Returns the active.
+ */
+ public boolean isActive() {
+ return _active;
+ }
- /* public abstract String getDescription();
- public abstract void setDescription(String newvalue);*/
-
- public String getSwitchType() {
- if (this.switchType != null) {
- return this.switchType;
- }
+ /**
+ * @param active The active to set. This method should never be called from user code.
+ */
+ public void setActive(boolean active) {
+ _active = active;
+ }
- ValueBinding valueBinding = getValueBinding("switchType");
- if (valueBinding != null) {
- return (String) valueBinding.getValue(
- FacesContext.getCurrentInstance());
- }
-
- UITabPanel pane = getPane();
- if (pane != null) {
- return getPane().getSwitchType();
- }
+ /**
+ * Get Model Value for this Tab.
+ *
+ * @return value from local variable or value bindings
+ */
+ public abstract Object getValue();
- return UISwitchablePanel.DEFAULT_METHOD;
- }
+ /**
+ * Set Model Value for this Tab.
+ *
+ * @param newvalue
+ */
+ public abstract void setValue(Object newvalue);
- public void setSwitchType(String newvalue) {
- this.switchType = newvalue;
- }
-
- public Object saveState(FacesContext context) {
- Object[] state = new Object[2];
- state[0] = super.saveState(context);
-
- state[1] = switchType;
-
- return state;
- }
-
- public void restoreState(FacesContext context, Object object) {
- Object[] state = (Object[]) object;
- super.restoreState(context, state[0]);
-
- this.switchType = (String) state[1];
- }
-
- //TODO - nick - ?
+ public abstract Object getName();
+
+ public abstract void setName(Object newvalue);
+
+ public abstract boolean isDisabled();
+
+ public abstract void setDisabled(boolean disabled);
+
+ public abstract String getLabel();
+
+ public abstract void setLabel(String newvalue);
+
+ public abstract String getLabelWidth();
+
+ public abstract void setLabelWidth(String newvalue);
+
+ public abstract String getTitle();
+
+ public abstract void setTitle(String newvalue);
+
+ /* public abstract String getDescription();
+ public abstract void setDescription(String newvalue);*/
+
+ public String getSwitchType() {
+ if (this.switchType != null) {
+ return this.switchType;
+ }
+
+ ValueBinding valueBinding = getValueBinding("switchType");
+ if (valueBinding != null) {
+ return (String) valueBinding.getValue(
+ FacesContext.getCurrentInstance());
+ }
+
+ UITabPanel pane = getPane();
+ if (pane != null) {
+ return getPane().getSwitchType();
+ }
+
+ return UISwitchablePanel.DEFAULT_METHOD;
+ }
+
+ public void setSwitchType(String newvalue) {
+ this.switchType = newvalue;
+ }
+
+ public Object saveState(FacesContext context) {
+ Object[] state = new Object[2];
+ state[0] = super.saveState(context);
+
+ state[1] = switchType;
+
+ return state;
+ }
+
+ public void restoreState(FacesContext context, Object object) {
+ Object[] state = (Object[]) object;
+ super.restoreState(context, state[0]);
+
+ this.switchType = (String) state[1];
+ }
+
+ //TODO - nick - ?
// public void processDecodes(FacesContext context) {
-//
+//
// UITabPanel pane = getPane();
-//
+//
// if(getName().equals(pane.getSelectedTab().toString())) {
// super.processDecodes(context);
// } else {
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/component/UITabPanel.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/component/UITabPanel.java 2007-04-12 16:23:41 UTC (rev 387)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/component/UITabPanel.java 2007-04-12 16:24:47 UTC (rev 388)
@@ -21,98 +21,102 @@
package org.richfaces.component;
-import java.util.Iterator;
+import org.richfaces.model.Tab;
import javax.faces.component.UIComponent;
+import java.util.Iterator;
-import org.richfaces.model.Tab;
-
/**
* JSF component class
- *
*/
-public abstract class UITabPanel extends UISwitchablePanel
-{
+public abstract class UITabPanel extends UISwitchablePanel {
public static final String COMPONENT_TYPE = "org.richfaces.TabPanel";
public boolean getRendersChildren() {
- return true;
+ return true;
}
-
+
protected Iterator getSwitchedFacetsAndChildren() {
- final Object renderedValue = getRenderedValue();
-
- return new TabsIterator(this, new TabsIterator.FilterCondition() {
+ final Object renderedValue = getRenderedValue();
- public boolean isSuitable(UITab tab) {
- if (CLIENT_METHOD.equals(tab.getSwitchType())) {
-
- return true;
- }
-
- Object name = tab.getName();
-
- return name != null && name.equals(renderedValue);
- }
-
- });
+ return new TabsIterator(this, new TabsIterator.FilterCondition() {
+
+ public boolean isSuitable(UITab tab) {
+ if (CLIENT_METHOD.equals(tab.getSwitchType())) {
+
+ return true;
+ }
+
+ Object name = tab.getName();
+
+ return name != null && name.equals(renderedValue);
+ }
+
+ });
}
-
- public Object convertSwitchValue(UIComponent component, Object object) {
- if (object != null) {
- return object;
- }
-
- return ((UITab) component).getName();
- }
-
- /**
- * Get value for current selected tab. Possible classes - prefered {@link Integer} for tab number, or other Object for tab model value.
- * @return
- */
- public abstract Object getSelectedTab();
-
- /**
- * Set currently selected tab.
- * @param tab
- */
- public abstract void setSelectedTab(Object tab);
-
-
- /**
- * Create iterator for all tabs in this component ( in future, can be added special attribute for tabs collection.
- * {@link Iterator#next()} method will return tab model - {@link Tab}
- * @return
- */
- public Iterator getTabs() {
- return new TabsIterator(this);
- }
- /**
- * Get Tab selection behavior for panel - one of "client", "server", "ajax", "page".
- * @return
- */
- public abstract String getSwitchType();
+ public Object convertSwitchValue(UIComponent component, Object object) {
+ if (object != null) {
+ return object;
+ }
- /**
- * Set Tab selection behavior for panel - one of "client", "server", "ajax", "page".
- * @param newvalue
- */
- public abstract void setSwitchType(String newvalue);
-
- /**
- * Get headers alignment - one of "left", "center" and "right".
- * @return
- */
- public abstract String getHeaderAlignment();
-
- /**
- * Set headers alignment - one of "left", "center" and "right".
- * @param newAlignment
- */
- public abstract void setHeaderAlignment(String newAlignment);
+ return ((UITab) component).getName();
+ }
- public abstract String getHeaderSpacing();
+ /**
+ * Get value for current selected tab. Possible classes - prefered {@link Integer} for tab number, or other Object for tab model value.
+ *
+ * @return selectedTab value from local variable or value bindings
+ */
+ public abstract Object getSelectedTab();
- public abstract void setHeaderSpacing(String value);
+ /**
+ * Set currently selected tab.
+ *
+ * @param tab
+ */
+ public abstract void setSelectedTab(Object tab);
+
+
+ /**
+ * Create iterator for all tabs in this component ( in future, can be added special attribute for tabs collection.
+ * {@link Iterator#next()} method will return tab model - {@link Tab}
+ *
+ * @return Iterator
+ */
+ public Iterator getTabs() {
+ return new TabsIterator(this);
+ }
+
+ /**
+ * Get Tab selection behavior for panel - one of "client", "server", "ajax", "page".
+ *
+ * @return switchType value from local variable or value bindings
+ */
+ public abstract String getSwitchType();
+
+ /**
+ * Set Tab selection behavior for panel - one of "client", "server", "ajax", "page".
+ *
+ * @param newvalue
+ */
+ public abstract void setSwitchType(String newvalue);
+
+ /**
+ * Get headers alignment - one of "left", "center" and "right".
+ *
+ * @return headerAlignment value from local variable or value bindings
+ */
+ public abstract String getHeaderAlignment();
+
+ /**
+ * Set headers alignment - one of "left", "center" and "right".
+ *
+ * @param newAlignment
+ */
+ public abstract void setHeaderAlignment(String newAlignment);
+
+ public abstract String getHeaderSpacing();
+
+ public abstract void setHeaderSpacing(String value);
}
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/model/TabModel.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/model/TabModel.java 2007-04-12 16:23:41 UTC (rev 387)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/model/TabModel.java 2007-04-12 16:24:47 UTC (rev 388)
@@ -25,85 +25,80 @@
/**
* @author asmirnov at exadel.com (latest modification by $Author: ishabalov $)
* @version $Revision: 1.3 $ $Date: 2007/02/21 20:35:05 $
- *
*/
public interface TabModel {
- /**
- * Get Get internal value for this tab - to store in selectedTab attribute of {@link UITabPanelPane}.
- * by default, if no tabValue set, as it's value used ordered number of this tab in panel.
- * @return
- */
- public Object getName();
+ /**
+ * Get Get internal value for this tab - to store in selectedTab attribute of {@link org.richfaces.component.UITabPanel}.
+ * by default, if no tabValue set, as it's value used ordered number of this tab in panel.
+ *
+ * @return Returns the value.
+ */
+ public Object getName();
- /**
- * Set Get internal value for this tab - to store in selectedTab attribute of {@link UITabPanelPane}.
- * @param newvalue
- */
- public void setName(Object newvalue);
+ /**
+ * Set Get internal value for this tab - to store in selectedTab attribute of {@link org.richfaces.component.UITabPanel}.
+ *
+ * @param newvalue
+ */
+ public void setName(Object newvalue);
- public boolean isDisabled();
+ public boolean isDisabled();
- public void setDisabled(boolean disabled);
+ public void setDisabled(boolean disabled);
- /**
- * Get label for this tab.
- * @return
- */
- public String getLabel();
+ /**
+ * Get label for this tab.
+ *
+ * @return Returns the label.
+ */
+ public String getLabel();
- /**
- * Set label for this tab.
- * @param newvalue
- */
- public void setLabel(String newvalue);
+ /**
+ * Set label for this tab.
+ *
+ * @param newvalue
+ */
+ public void setLabel(String newvalue);
- /**
- * Get width of label for this tab.
- * @return
- */
- public String getLabelWidth();
+ /**
+ * Get width of label for this tab.
+ *
+ * @return Returns the labelWidth.
+ */
+ public String getLabelWidth();
- /**
- * Set width of label for this tab.
- * @param newvalue
- */
- public void setLabelWidth(String newvalue);
+ /**
+ * Set width of label for this tab.
+ *
+ * @param newvalue
+ */
+ public void setLabelWidth(String newvalue);
- /**
- * Get Tab description - for visual tools or pop-up message.
- * @return
- */
-// public String getDescription();
+ /**
+ * Get Tab title - for pop-up message.
+ *
+ * @return Returns the title.
+ */
+ public String getTitle();
- /**
- * Set Tab description - for visual tools or pop-up message.
- * @param newvalue
- */
-// public void setDescription(String newvalue);
+ /**
+ * Set Tab title - for pop-up message.
+ *
+ * @param newvalue
+ */
+ public void setTitle(String newvalue);
- /**
- * Get Tab title - for pop-up message.
- * @return
- */
- public String getTitle();
+ /**
+ * Get Tab selection behavior for panel - one of "client", "server", "ajax", "page".
+ *
+ * @return Returns the switchType.
+ */
+ public String getSwitchType();
- /**
- * Set Tab title - for pop-up message.
- * @param newvalue
- */
- public void setTitle(String newvalue);
-
- /**
- * Get Tab selection behavior for panel - one of "client", "server", "ajax", "page".
- * @return
- */
- public String getSwitchType();
-
- /**
- * Set Tab selection behavior for panel - one of "client", "server", "ajax", "page".
- * @param newvalue
- */
- public void setSwitchType(String newvalue);
-
+ /**
+ * Set Tab selection behavior for panel - one of "client", "server", "ajax", "page".
+ * @param newvalue
+ */
+ public void setSwitchType(String newvalue);
}
\ No newline at end of file
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabClassBuilder.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabClassBuilder.java 2007-04-12 16:23:41 UTC (rev 387)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabClassBuilder.java 2007-04-12 16:24:47 UTC (rev 388)
@@ -21,157 +21,160 @@
package org.richfaces.renderkit;
-import javax.faces.component.UIComponent;
-
import org.richfaces.component.UITab;
import org.richfaces.component.UITabPanel;
+import javax.faces.component.UIComponent;
+
/**
* Let's build tab style class of:
- * 'renderer-specific' classes
- *
+ * 'renderer-specific' classes
+ *
* @author Maksim Kaszynski
- *
*/
public class TabClassBuilder {
- public static final TabClassBuilder activeTabClassBuilder = new TabClassBuilder() {
+ public static final TabClassBuilder activeTabClassBuilder = new TabClassBuilder() {
- protected String getSpecificClassForAllTabs() {
- //dr-tb-act
- return "dr-tbpnl-tb-act rich-tab-active";
- }
+ protected String getSpecificClassForAllTabs() {
+ //dr-tb-act
+ return "dr-tbpnl-tb-act rich-tab-active";
+ }
- protected String getSpecificTabClassFromPane(UITab tab,
- UITabPanel pane) {
- return TabClassBuilder.getStringAttributeOrEmptyString(pane,
- "activeTabClass");
- }
+ protected String getSpecificTabClassFromPane(UITab tab,
+ UITabPanel pane) {
+ return TabClassBuilder.getStringAttributeOrEmptyString(pane,
+ "activeTabClass");
+ }
- };
+ };
- public static final TabClassBuilder disabledTabClassBuilder = new TabClassBuilder() {
+ public static final TabClassBuilder disabledTabClassBuilder = new TabClassBuilder() {
- protected String getSpecificClassForAllTabs() {
- //dr-tb-dsbld
- return "dr-tbpnl-tb-dsbl rich-tab-disabled";
- }
+ protected String getSpecificClassForAllTabs() {
+ //dr-tb-dsbld
+ return "dr-tbpnl-tb-dsbl rich-tab-disabled";
+ }
- protected String getSpecificTabClassFromPane(UITab tab,
- UITabPanel pane) {
- return TabClassBuilder.getStringAttributeOrEmptyString(pane,
- "disabledTabClass");
- }
+ protected String getSpecificTabClassFromPane(UITab tab,
+ UITabPanel pane) {
+ return TabClassBuilder.getStringAttributeOrEmptyString(pane,
+ "disabledTabClass");
+ }
- };
+ };
- public static final TabClassBuilder inactiveTabClassBuilder = new TabClassBuilder() {
+ public static final TabClassBuilder inactiveTabClassBuilder = new TabClassBuilder() {
- protected String getSpecificClassForAllTabs() {
- //dr-tb-inact
- return "dr-tbpnl-tb-inact rich-tab-inactive";
- }
+ protected String getSpecificClassForAllTabs() {
+ //dr-tb-inact
+ return "dr-tbpnl-tb-inact rich-tab-inactive";
+ }
- protected String getSpecificTabClassFromPane(UITab tab,
- UITabPanel pane) {
- return TabClassBuilder.getStringAttributeOrEmptyString(pane,
- "inactiveTabClass");
- }
+ protected String getSpecificTabClassFromPane(UITab tab,
+ UITabPanel pane) {
+ return TabClassBuilder.getStringAttributeOrEmptyString(pane,
+ "inactiveTabClass");
+ }
- };
+ };
- public static String getStringAttributeOrEmptyString(UIComponent component, String attributeName) {
- String attributeValue = (String) component.getAttributes().get(attributeName);
-
- if (null == attributeValue) {
- attributeValue = "";
- }
-
- return attributeValue;
- }
+ public static String getStringAttributeOrEmptyString(UIComponent component, String attributeName) {
+ String attributeValue = (String) component.getAttributes().get(attributeName);
-
- /**
- * gather cumulative class
- * @param tab
- * @param pane
- * @return
- */
- public String buildTabClass(UITab tab) {
- UITabPanel pane = tab.getPane();
- StringBuffer labelClass = new StringBuffer();
- labelClass
- .append(getCommonClassForAllTabs())
- .append(" ")
- .append(getSpecificClassForAllTabs())
- .append(" ")
- .append(getCommonTabClassFromPane(pane))
- .append(" ")
- .append(getSpecificTabClassFromPane(tab, pane))
- .append(" ")
- .append(getSpecificClassFromTab(tab))
- .append(" ")
- .append(getClassFromTab(tab));
-
- return labelClass.toString();
- }
-
- /**
- * common prefix for all tabs (renderer-specific)
- * @return
- */
- protected String getCommonClassForAllTabs() {
- //dr-tb-cntrl
- return "dr-tbpnl-tb rich-tab-header";
- }
-
- /**
- * class common class for different kinds of tabs (e.g. active, disabled, etc)
- * renderer-specific
- * @return
- */
- protected String getSpecificClassForAllTabs() {
- return "";
- }
-
- /**
- * usually styleClass attribute specified directly on tab
- * @param tab
- * @return
- */
- protected String getClassFromTab(UITab tab) {
- return getStringAttributeOrEmptyString(tab, "styleClass");
- }
-
- /**
- * no known implements
- * @param tab
- * @return
- */
-
- protected String getSpecificClassFromTab(UITab tab) {
- return "";
- }
+ if (null == attributeValue) {
+ attributeValue = "";
+ }
- /**
- * general class of all tabs specified on pane
- * @param pane
- * @return
- */
- protected String getCommonTabClassFromPane(UITabPanel pane) {
- return getStringAttributeOrEmptyString(pane, "tabClass");
- }
- /**
- * get class from pane depending on tab kind
- * @param tab
- * @param pane
- * @return
- */
- protected String getSpecificTabClassFromPane(UITab tab, UITabPanel pane) {
- return "";
- }
-
-
+ return attributeValue;
+ }
+
+
+ /**
+ * gather cumulative class
+ *
+ * @param tab
+ * @return
+ */
+ public String buildTabClass(UITab tab) {
+ UITabPanel pane = tab.getPane();
+ StringBuffer labelClass = new StringBuffer();
+ labelClass
+ .append(getCommonClassForAllTabs())
+ .append(" ")
+ .append(getSpecificClassForAllTabs())
+ .append(" ")
+ .append(getCommonTabClassFromPane(pane))
+ .append(" ")
+ .append(getSpecificTabClassFromPane(tab, pane))
+ .append(" ")
+ .append(getSpecificClassFromTab(tab))
+ .append(" ")
+ .append(getClassFromTab(tab));
+
+ return labelClass.toString();
+ }
+
+ /**
+ * common prefix for all tabs (renderer-specific)
+ *
+ * @return
+ */
+ protected String getCommonClassForAllTabs() {
+ //dr-tb-cntrl
+ return "dr-tbpnl-tb rich-tab-header";
+ }
+
+ /**
+ * class common class for different kinds of tabs (e.g. active, disabled, etc)
+ * renderer-specific
+ *
+ * @return
+ */
+ protected String getSpecificClassForAllTabs() {
+ return "";
+ }
+
+ /**
+ * usually styleClass attribute specified directly on tab
+ *
+ * @param tab
+ * @return
+ */
+ protected String getClassFromTab(UITab tab) {
+ return getStringAttributeOrEmptyString(tab, "styleClass");
+ }
+
+ /**
+ * no known implements
+ *
+ * @param tab
+ * @return
+ */
+
+ protected String getSpecificClassFromTab(UITab tab) {
+ return "";
+ }
+
+ /**
+ * general class of all tabs specified on pane
+ *
+ * @param pane
+ * @return
+ */
+ protected String getCommonTabClassFromPane(UITabPanel pane) {
+ return getStringAttributeOrEmptyString(pane, "tabClass");
+ }
+
+ /**
+ * get class from pane depending on tab kind
+ * @param tab
+ * @param pane
+ * @return
+ */
+ protected String getSpecificTabClassFromPane(UITab tab, UITabPanel pane) {
+ return "";
+ }
}
\ No newline at end of file
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java 2007-04-12 16:23:41 UTC (rev 387)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java 2007-04-12 16:24:47 UTC (rev 388)
@@ -21,13 +21,6 @@
package org.richfaces.renderkit;
-import java.io.IOException;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.framework.util.HtmlDimensions;
@@ -37,167 +30,172 @@
import org.richfaces.component.UITabPanel;
import org.richfaces.component.util.HtmlUtil;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+import java.util.Map;
+
/**
* @author Nick Belaevski - nbelaevski at exadel.com
- * created 12.01.2007
- *
+ * created 12.01.2007
*/
public class TabHeaderRendererBase extends org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase {
- private static final String LABEL_SUFFIX = "_lbl";
-
- protected Class getComponentClass() {
- return UITab.class;
- }
+ private static final String LABEL_SUFFIX = "_lbl";
- public void encodeTabLabel(FacesContext context, UITab tab) throws IOException{
- ResponseWriter writer = context.getResponseWriter();
+ protected Class getComponentClass() {
+ return UITab.class;
+ }
- boolean disabled = tab.isDisabled();
- UITabPanel pane = tab.getPane();
- String method = tab.getSwitchType();
- boolean ajax = UISwitchablePanel.AJAX_METHOD.equals(method);
- boolean clientSide = UISwitchablePanel.CLIENT_METHOD.equals(method);
- String label = tab.getLabel();
+ public void encodeTabLabel(FacesContext context, UITab tab) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
- if (label == null) {
- label = "";
- }
+ boolean disabled = tab.isDisabled();
+ UITabPanel pane = tab.getPane();
+ String method = tab.getSwitchType();
+ boolean ajax = UISwitchablePanel.AJAX_METHOD.equals(method);
+ boolean clientSide = UISwitchablePanel.CLIENT_METHOD.equals(method);
+ String label = tab.getLabel();
- String clientId = tab.getClientId(context) ;
+ if (label == null) {
+ label = "";
+ }
- String style = (String) tab.getAttributes().get("style");
+ String clientId = tab.getClientId(context);
- if (!disabled) {
- if(clientSide) {
- writer.writeAttribute(HTML.onclick_ATTRIBUTE,"RichFaces.switchTab('"+pane.getClientId(context)+"','"+clientId+"','"+getUtils().formatValue(context, pane, tab.getName())+"');","switchScript");
- } else {
- String activeCheck = "if (RichFaces.isTabActive('" + clientId + LABEL_SUFFIX + "')) return false;";
+ String style = (String) tab.getAttributes().get("style");
- if(ajax) {
- JSFunction function = AjaxRendererUtils.buildAjaxFunction(tab,
- context);
- Map eventOptions = AjaxRendererUtils.buildEventOptions(context,
- tab);
- function.addParameter(eventOptions);
+ if (!disabled) {
+ if (clientSide) {
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, "RichFaces.switchTab('" + pane.getClientId(context) + "','" + clientId + "','" + getUtils().formatValue(context, pane, tab.getName()) + "');", "switchScript");
+ } else {
+ String activeCheck = "if (RichFaces.isTabActive('" + clientId + LABEL_SUFFIX + "')) return false;";
- StringBuffer buffer = new StringBuffer();
- function.appendScript(buffer);
- buffer.append("; return false; this.onclick = null;");
- String script = buffer.toString();
- writer.writeAttribute(HTML.onclick_ATTRIBUTE, activeCheck + script, null);
- } else {
- StringBuffer script = new StringBuffer("var _formName = A4J.findForm(this).id; var _paramName = '" + clientId + "_server_submit'; var _params = new Object(); _params[_paramName] = _paramName; _JSFFormSubmit('");
- script.append(clientId);
- script.append("', _formName, null, _params);");
- script.append("this.onclick = null; _clearJSFFormParameters(_formName, null, [_paramName]);");
+ if (ajax) {
+ JSFunction function = AjaxRendererUtils.buildAjaxFunction(tab,
+ context);
+ Map eventOptions = AjaxRendererUtils.buildEventOptions(context,
+ tab);
+ function.addParameter(eventOptions);
- writer.writeAttribute(HTML.onclick_ATTRIBUTE, activeCheck + script.toString()
- /* "RichFaces.submitTab(this,'"+clientId + "_inp" +"','"+pane.getClientId(context)+"');"*/, null);
- }
- }
- }
+ StringBuffer buffer = new StringBuffer();
+ function.appendScript(buffer);
+ buffer.append("; return false; this.onclick = null;");
+ String script = buffer.toString();
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, activeCheck + script, null);
+ } else {
+ StringBuffer script = new StringBuffer("var _formName = A4J.findForm(this).id; var _paramName = '" + clientId + "_server_submit'; var _params = new Object(); _params[_paramName] = _paramName; _JSFFormSubmit('");
+ script.append(clientId);
+ script.append("', _formName, null, _params);");
+ script.append("this.onclick = null; _clearJSFFormParameters(_formName, null, [_paramName]);");
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, activeCheck + script.toString()
+ /* "RichFaces.submitTab(this,'"+clientId + "_inp" +"','"+pane.getClientId(context)+"');"*/, null);
+ }
+ }
+ }
- String width = tab.getLabelWidth();
- if (width != null) {
- style += ";width: " + getUtils().encodePctOrPx(width) + ";";
- }
+ String width = tab.getLabelWidth();
- if (style != null){
- writer.writeAttribute(HTML.style_ATTRIBUTE, style, "tabStyle");
- }
- }
+ if (width != null) {
+ style += ";width: " + getUtils().encodePctOrPx(width) + ";";
+ }
- public boolean getRendersChildren() {
- return true;
- }
+ if (style != null) {
+ writer.writeAttribute(HTML.style_ATTRIBUTE, style, "tabStyle");
+ }
+ }
- public void encodeCellClasses(FacesContext context, UITab tab) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
- String labelClass;
- if (tab.isDisabled()) {
- labelClass = TabPanelRendererBase.DISABLED_CELL_CLASSES;
- } else {
- if (tab.isActive()) {
- labelClass = TabPanelRendererBase.ACTIVE_CELL_CLASSES;
- } else {
- labelClass = TabPanelRendererBase.INACTIVE_CELL_CLASSES;
- }
- }
+ public boolean getRendersChildren() {
+ return true;
+ }
- writer.writeAttribute(HTML.class_ATTRIBUTE, labelClass, null);
- }
+ public void encodeCellClasses(FacesContext context, UITab tab) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ String labelClass;
+ if (tab.isDisabled()) {
+ labelClass = TabPanelRendererBase.DISABLED_CELL_CLASSES;
+ } else {
+ if (tab.isActive()) {
+ labelClass = TabPanelRendererBase.ACTIVE_CELL_CLASSES;
+ } else {
+ labelClass = TabPanelRendererBase.INACTIVE_CELL_CLASSES;
+ }
+ }
- /**
- * Hook method for create AJAX command script, in non-ajax state -simple write script attributes
- * @param writer
- * @param context
- * @param component
- * @throws IOException
- */
- protected void writeTabElementScript(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
- getUtils().encodeAttribute(context,component,HTML.onclick_ATTRIBUTE);
- getUtils().encodeAttribute(context,component,HTML.ondblclick_ATTRIBUTE);
- getUtils().encodeAttribute(context,component,HTML.onkeydown_ATTRIBUTE);
- getUtils().encodeAttribute(context,component,HTML.onkeyup_ATTRIBUTE);
- getUtils().encodeAttribute(context,component,HTML.onkeypress_ATTRIBUTE);
- }
+ writer.writeAttribute(HTML.class_ATTRIBUTE, labelClass, null);
+ }
- public void writeLabel(FacesContext context, UITab tab) throws IOException{
- ResponseWriter writer = context.getResponseWriter();
+ /**
+ * Hook method for create AJAX command script, in non-ajax state -simple write script attributes
+ *
+ * @param writer
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ protected void writeTabElementScript(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ getUtils().encodeAttribute(context, component, HTML.onclick_ATTRIBUTE);
+ getUtils().encodeAttribute(context, component, HTML.ondblclick_ATTRIBUTE);
+ getUtils().encodeAttribute(context, component, HTML.onkeydown_ATTRIBUTE);
+ getUtils().encodeAttribute(context, component, HTML.onkeyup_ATTRIBUTE);
+ getUtils().encodeAttribute(context, component, HTML.onkeypress_ATTRIBUTE);
+ }
- String labelClass = "";
- if (tab.isDisabled()) {
- labelClass = TabPanelRendererBase.getDisabledTabClass(tab);
- } else {
- if (tab.isActive()) {
- labelClass = TabPanelRendererBase.getActiveTabClass(tab);
- } else {
- labelClass = TabPanelRendererBase.getInactiveTabClass(tab);
- }
+ public void writeLabel(FacesContext context, UITab tab) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
- writer.writeAttribute(HTML.onmouseover_ATTRIBUTE, ONMOUSEOVER, "tabOnMouseOver");
- writer.writeAttribute(HTML.onmouseout_ATTRIBUTE, ONMOUSEOUT, "tabOnMouseOut");
- }
- writer.writeAttribute(HTML.class_ATTRIBUTE, labelClass, "tabClass");
- String title = tab.getTitle();
- if (title != null && title.length()!=0) {
- writer.writeAttribute(HTML.title_ATTRIBUTE, title, null);
- }
+ String labelClass = "";
+ if (tab.isDisabled()) {
+ labelClass = TabPanelRendererBase.getDisabledTabClass(tab);
+ } else {
+ if (tab.isActive()) {
+ labelClass = TabPanelRendererBase.getActiveTabClass(tab);
+ } else {
+ labelClass = TabPanelRendererBase.getInactiveTabClass(tab);
+ }
- String label = tab.getLabel();
+ writer.writeAttribute(HTML.onmouseover_ATTRIBUTE, ONMOUSEOVER, "tabOnMouseOver");
+ writer.writeAttribute(HTML.onmouseout_ATTRIBUTE, ONMOUSEOUT, "tabOnMouseOut");
+ }
+ writer.writeAttribute(HTML.class_ATTRIBUTE, labelClass, "tabClass");
+ String title = tab.getTitle();
+ if (title != null && title.length() != 0) {
+ writer.writeAttribute(HTML.title_ATTRIBUTE, title, null);
+ }
- if (label == null || label.length()==0) {
- label = " ";
- }
+ String label = tab.getLabel();
- context.getResponseWriter().write(label);
- }
+ if (label == null || label.length() == 0) {
+ label = " ";
+ }
- protected String encodeTabLabelWidth(FacesContext context, UITab tab) {
- String labelWidth = tab.getLabelWidth();
- if (labelWidth == null || labelWidth.trim().length() == 0) {
- return "";
- }
+ context.getResponseWriter().write(label);
+ }
- return "width: " + HtmlUtil.qualifySize(labelWidth) + ";";
- }
+ protected String encodeTabLabelWidth(FacesContext context, UITab tab) {
+ String labelWidth = tab.getLabelWidth();
+ if (labelWidth == null || labelWidth.trim().length() == 0) {
+ return "";
+ }
- public String encodeHeaderSpacing(FacesContext context, UITab tab) throws IOException {
- UITabPanel pane = tab.getPane();
- String headerSpacing = pane.getHeaderSpacing();
- Double decoded = HtmlDimensions.decode(headerSpacing);
- if (decoded.doubleValue() != 0) {
- return "width: " + HtmlUtil.qualifySize(headerSpacing);
- } else {
- return "";
- }
- }
+ return "width: " + HtmlUtil.qualifySize(labelWidth) + ";";
+ }
- private static final String ONMOUSEOVER = "RichFaces.overTab(this);";
- private static final String ONMOUSEOUT = "RichFaces.outTab(this);";
+ public String encodeHeaderSpacing(FacesContext context, UITab tab) throws IOException {
+ UITabPanel pane = tab.getPane();
+ String headerSpacing = pane.getHeaderSpacing();
+ Double decoded = HtmlDimensions.decode(headerSpacing);
+ if (decoded.doubleValue() != 0) {
+ return "width: " + HtmlUtil.qualifySize(headerSpacing);
+ } else {
+ return "";
+ }
+ }
+ private static final String ONMOUSEOVER = "RichFaces.overTab(this);";
+ private static final String ONMOUSEOUT = "RichFaces.outTab(this);";
}
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabInfoCollector.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabInfoCollector.java 2007-04-12 16:23:41 UTC (rev 387)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabInfoCollector.java 2007-04-12 16:24:47 UTC (rev 388)
@@ -21,15 +21,15 @@
package org.richfaces.renderkit;
+import org.richfaces.component.UITab;
+
import javax.faces.context.FacesContext;
-import org.richfaces.component.UITab;
-
/**
* @author Maksim Kaszynski
- *
*/
public interface TabInfoCollector {
- public Object collectTabInfo(FacesContext context, UITab tab);
+
+ public Object collectTabInfo(FacesContext context, UITab tab);
}
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-04-12 16:23:41 UTC (rev 387)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-04-12 16:24:47 UTC (rev 388)
@@ -21,16 +21,6 @@
package org.richfaces.renderkit;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.event.ActionEvent;
-
import org.ajax4jsf.framework.ajax.AjaxEvent;
import org.ajax4jsf.framework.renderer.ComponentVariables;
import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
@@ -43,254 +33,266 @@
import org.richfaces.component.util.HtmlUtil;
import org.richfaces.event.SwitchablePanelSwitchEvent;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
/**
* @author Nick Belaevski - nbelaevski at exadel.com
- * created 12.01.2007
- *
+ * created 12.01.2007
*/
public class TabPanelRendererBase extends org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase {
- public final static String ACTIVE_CELL_CLASSES = "dr-tbpnl-tbcell-act rich-tabhdr-cell-active";
- public final static String INACTIVE_CELL_CLASSES = "dr-tbpnl-tbcell-inact rich-tabhdr-cell-inactive";
- public final static String DISABLED_CELL_CLASSES = "dr-tbpnl-tbcell-dsbld rich-tabhdr-cell-disabled";
+ public final static String ACTIVE_CELL_CLASSES = "dr-tbpnl-tbcell-act rich-tabhdr-cell-active";
+ public final static String INACTIVE_CELL_CLASSES = "dr-tbpnl-tbcell-inact rich-tabhdr-cell-inactive";
+ public final static String DISABLED_CELL_CLASSES = "dr-tbpnl-tbcell-dsbld rich-tabhdr-cell-disabled";
- protected Class getComponentClass() {
- return UITabPanel.class;
- }
+ protected Class getComponentClass() {
+ return UITabPanel.class;
+ }
- protected void doDecode(FacesContext context, UIComponent component) {
- super.doDecode(context, component);
+ protected void doDecode(FacesContext context, UIComponent component) {
+ super.doDecode(context, component);
- UITabPanel panel = (UITabPanel) component;
+ UITabPanel panel = (UITabPanel) component;
- String clientId = component.getClientId(context);
- Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
+ String clientId = component.getClientId(context);
+ Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
- UITab eventTab = null;
+ UITab eventTab = null;
- for (Iterator tabsIterator = panel.getTabs();
- tabsIterator.hasNext() && eventTab == null;) {
+ for (Iterator tabsIterator = panel.getTabs();
+ tabsIterator.hasNext() && eventTab == null;) {
- UITab tab = (UITab) tabsIterator.next();
- if (!tab.isRendered() || tab.isDisabled()) {
- continue;
- }
+ UITab tab = (UITab) tabsIterator.next();
+ if (!tab.isRendered() || tab.isDisabled()) {
+ continue;
+ }
- String tabClientId = tab.getClientId(context);
- if (requestParameterMap.containsKey(tabClientId) ||
- requestParameterMap.containsKey(tabClientId + "_server_submit")) {
+ String tabClientId = tab.getClientId(context);
+ if (requestParameterMap.containsKey(tabClientId) ||
+ requestParameterMap.containsKey(tabClientId + "_server_submit"))
+ {
- eventTab = tab;
- }
- }
+ eventTab = tab;
+ }
+ }
- if (eventTab != null) {
- new SwitchablePanelSwitchEvent(panel, null, eventTab).queue();
- new ActionEvent(eventTab).queue();
+ if (eventTab != null) {
+ new SwitchablePanelSwitchEvent(panel, null, eventTab).queue();
+ new ActionEvent(eventTab).queue();
- if (UISwitchablePanel.AJAX_METHOD.equals(eventTab.getSwitchType())) {
- new AjaxEvent(eventTab).queue();
- }
- } else {
- String newValue = (String) requestParameterMap.get(clientId);
- if (null != newValue) {
- new SwitchablePanelSwitchEvent(panel, newValue, null).queue();
- }
- }
- }
+ if (UISwitchablePanel.AJAX_METHOD.equals(eventTab.getSwitchType()))
+ {
+ new AjaxEvent(eventTab).queue();
+ }
+ } else {
+ String newValue = (String) requestParameterMap.get(clientId);
+ if (null != newValue) {
+ new SwitchablePanelSwitchEvent(panel, newValue, null).queue();
+ }
+ }
+ }
- private static final TabInfoCollector collector = new TabInfoCollector() {
- private final JSReference JSR_ACTIVE_CLASS = new JSReference("activeClass");
- private final JSReference JSR_ID = new JSReference("id");
- private final JSReference JSR_INACTIVE_CLASS = new JSReference("inactiveClass");
+ private static final TabInfoCollector collector = new TabInfoCollector() {
+ private final JSReference JSR_ACTIVE_CLASS = new JSReference("activeClass");
+ private final JSReference JSR_ID = new JSReference("id");
+ private final JSReference JSR_INACTIVE_CLASS = new JSReference("inactiveClass");
- private final JSReference JSR_CELL_ACTIVE_CLASS = new JSReference("cellActiveClass");
- private final JSReference JSR_CELL_INACTIVE_CLASS = new JSReference("cellInactiveClass");
+ private final JSReference JSR_CELL_ACTIVE_CLASS = new JSReference("cellActiveClass");
+ private final JSReference JSR_CELL_INACTIVE_CLASS = new JSReference("cellInactiveClass");
- public Object collectTabInfo(FacesContext context, UITab tab) {
- Map info = new HashMap();
- info.put(JSR_ID, tab.getClientId(context));
- info.put(JSR_ACTIVE_CLASS, TabPanelRendererBase.getActiveTabClass(tab));
- info.put(JSR_INACTIVE_CLASS, TabPanelRendererBase.getInactiveTabClass(tab));
+ public Object collectTabInfo(FacesContext context, UITab tab) {
+ Map info = new HashMap();
+ info.put(JSR_ID, tab.getClientId(context));
+ info.put(JSR_ACTIVE_CLASS, TabPanelRendererBase.getActiveTabClass(tab));
+ info.put(JSR_INACTIVE_CLASS, TabPanelRendererBase.getInactiveTabClass(tab));
- info.put(JSR_CELL_ACTIVE_CLASS, ACTIVE_CELL_CLASSES);
- info.put(JSR_CELL_INACTIVE_CLASS, INACTIVE_CELL_CLASSES);
+ info.put(JSR_CELL_ACTIVE_CLASS, ACTIVE_CELL_CLASSES);
+ info.put(JSR_CELL_INACTIVE_CLASS, INACTIVE_CELL_CLASSES);
- return info;
- }
- };
+ return info;
+ }
+ };
- /**
- * @param context
- * @param component
- * @return
- * @throws IOException
- */
- public static String encodeStyles(FacesContext context, UIComponent component) throws IOException {
- String widthAttrValue = (String)component.getAttributes().get(HTML.width_ATTRIBUTE);
- String heightAttrValue = (String)component.getAttributes().get(HTML.height_ATTRIBUTE);
- String styleAttrValue = (String)component.getAttributes().get(HTML.style_ATTRIBUTE);
- String style = styleAttrValue != null ? styleAttrValue : "";
+ /**
+ * @param context
+ * @param component
+ * @return
+ * @throws IOException
+ */
+ public static String encodeStyles(FacesContext context, UIComponent component) throws IOException {
+ String widthAttrValue = (String) component.getAttributes().get(HTML.width_ATTRIBUTE);
+ String heightAttrValue = (String) component.getAttributes().get(HTML.height_ATTRIBUTE);
+ String styleAttrValue = (String) component.getAttributes().get(HTML.style_ATTRIBUTE);
+ String style = styleAttrValue != null ? styleAttrValue : "";
- if (!parameterPresent(styleAttrValue, HTML.width_ATTRIBUTE)) {
- String width = (widthAttrValue != null && widthAttrValue.length() > 0) ? HtmlUtil.qualifySize(widthAttrValue) : "100%";
- style = addParameter(style, HTML.width_ATTRIBUTE + ":" + width);
- }
+ if (!parameterPresent(styleAttrValue, HTML.width_ATTRIBUTE)) {
+ String width = (widthAttrValue != null && widthAttrValue.length() > 0) ? HtmlUtil.qualifySize(widthAttrValue) : "100%";
+ style = addParameter(style, HTML.width_ATTRIBUTE + ":" + width);
+ }
- if (!parameterPresent(styleAttrValue, HTML.height_ATTRIBUTE)) {
- String height = (heightAttrValue != null && heightAttrValue.length() > 0) ? HtmlUtil.qualifySize(heightAttrValue) : "";
- if (height.length() > 0) {
- style = addParameter(style, HTML.height_ATTRIBUTE + ":" + height);
- }
- }
+ if (!parameterPresent(styleAttrValue, HTML.height_ATTRIBUTE)) {
+ String height = (heightAttrValue != null && heightAttrValue.length() > 0) ? HtmlUtil.qualifySize(heightAttrValue) : "";
+ if (height.length() > 0) {
+ style = addParameter(style, HTML.height_ATTRIBUTE + ":" + height);
+ }
+ }
- return style;
- }
+ return style;
+ }
- /**
- * @param style
- * @param name
- * @return
- */
- protected static boolean parameterPresent(String style, String name) {
- if (style != null && style.length() > 0) {
- String[] styles = style.split(";");
- for (int i = 0; i < styles.length; i++) {
- String[] pair = styles[i].split(":");
- if (pair[0].trim().equals(name)) {
- return true;
- }
- }
- }
- return false;
- }
- private static String addParameter(String style, String element) {
- String s = style.trim();
- return style + (s.length() == 0 || s.endsWith(";") ? "" : ";") + element;
- }
+ /**
+ * @param style
+ * @param name
+ * @return
+ */
+ protected static boolean parameterPresent(String style, String name) {
+ if (style != null && style.length() > 0) {
+ String[] styles = style.split(";");
+ for (int i = 0; i < styles.length; i++) {
+ String[] pair = styles[i].split(":");
+ if (pair[0].trim().equals(name)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
- protected String getValueAsString(FacesContext context, UITabPanel tabPanel) {
- return getUtils().getValueAsString(context, tabPanel);
- }
+ private static String addParameter(String style, String element) {
+ String s = style.trim();
+ return style + (s.length() == 0 || s.endsWith(";") ? "" : ";") + element;
+ }
- public void encodeTabs(FacesContext context, UITabPanel tabPanel) throws IOException {
- ComponentVariables componentVariables = ComponentsVariableResolver.getVariables(this, tabPanel);
+ protected String getValueAsString(FacesContext context, UITabPanel tabPanel) {
+ return getUtils().getValueAsString(context, tabPanel);
+ }
- Object value = tabPanel.getValue();
- if (value instanceof String) {
- if (((String) value).length() == 0) {
- value = null;
- }
- }
- if (value == null){
- value=tabPanel.getSelectedTab();
- }
- boolean useFirstRenderedTab = value == null;
- UITabPanel pane = tabPanel;
- UITab firstRenderedTab = null;
- UITab activeTab = null;
+ public void encodeTabs(FacesContext context, UITabPanel tabPanel) throws IOException {
+ ComponentVariables componentVariables = ComponentsVariableResolver.getVariables(this, tabPanel);
- for (Iterator iter = pane.getTabs(); iter.hasNext() && activeTab == null;) {
- UITab tab = (UITab) iter.next();
+ Object value = tabPanel.getValue();
+ if (value instanceof String) {
+ if (((String) value).length() == 0) {
+ value = null;
+ }
+ }
+ if (value == null) {
+ value = tabPanel.getSelectedTab();
+ }
+ boolean useFirstRenderedTab = value == null;
+ UITabPanel pane = tabPanel;
+ UITab firstRenderedTab = null;
+ UITab activeTab = null;
- if (tab.isRendered()) {
- if (firstRenderedTab == null) {
- firstRenderedTab = tab;
- }
+ for (Iterator iter = pane.getTabs(); iter.hasNext() && activeTab == null;)
+ {
+ UITab tab = (UITab) iter.next();
- if (useFirstRenderedTab) {
- activeTab = firstRenderedTab;
- } else if (value.equals(tab.getName())) {
- activeTab = tab;
- }
+ if (tab.isRendered()) {
+ if (firstRenderedTab == null) {
+ firstRenderedTab = tab;
+ }
- } else {
- if (!useFirstRenderedTab) {
- if (value.equals(tab.getName())) {
- if (firstRenderedTab != null) {
- activeTab = firstRenderedTab;
- } else {
- useFirstRenderedTab = true;
- }
- }
- }
- }
- }
+ if (useFirstRenderedTab) {
+ activeTab = firstRenderedTab;
+ } else if (value.equals(tab.getName())) {
+ activeTab = tab;
+ }
- if (activeTab == null) {
- throw new IllegalStateException("No active tabs!");
- } else {
- tabPanel.setValue(activeTab.getName());
- }
+ } else {
+ if (!useFirstRenderedTab) {
+ if (value.equals(tab.getName())) {
+ if (firstRenderedTab != null) {
+ activeTab = firstRenderedTab;
+ } else {
+ useFirstRenderedTab = true;
+ }
+ }
+ }
+ }
+ }
- ArrayList tabs = new ArrayList();
- boolean clientSide = UISwitchablePanel.CLIENT_METHOD.equals(pane.getSwitchType());
+ if (activeTab == null) {
+ throw new IllegalStateException("No active tabs!");
+ } else {
+ tabPanel.setValue(activeTab.getName());
+ }
- TabInfoCollector tabInfoCollector = getTabInfoCollector();
+ ArrayList tabs = new ArrayList();
+ boolean clientSide = UISwitchablePanel.CLIENT_METHOD.equals(pane.getSwitchType());
- for (Iterator iter = pane.getTabs(); iter.hasNext();) {
- UITab tab = (UITab) iter.next();
- boolean active = activeTab == tab;
- tab.setActive(active);
+ TabInfoCollector tabInfoCollector = getTabInfoCollector();
- if (tab.isRendered()) {
- if (!clientSide) {
- clientSide = UISwitchablePanel.CLIENT_METHOD.equals(tab.getSwitchType());
- }
+ for (Iterator iter = pane.getTabs(); iter.hasNext();) {
+ UITab tab = (UITab) iter.next();
+ boolean active = activeTab == tab;
+ tab.setActive(active);
- tab.encodeTab(context, active);
+ if (tab.isRendered()) {
+ if (!clientSide) {
+ clientSide = UISwitchablePanel.CLIENT_METHOD.equals(tab.getSwitchType());
+ }
- if (!tab.isDisabled()) {
- tabs.add(tabInfoCollector.collectTabInfo(context, tab));
- }
- }
- }
+ tab.encodeTab(context, active);
- // Store flag for exist client-side tabs.
- componentVariables.setVariable("clientSide", new Boolean(clientSide));
- componentVariables.setVariable("tabs", tabs);
- }
+ if (!tab.isDisabled()) {
+ tabs.add(tabInfoCollector.collectTabInfo(context, tab));
+ }
+ }
+ }
- public static String getActiveTabCellClass(UITab tab) {
- return TabClassBuilder.activeTabClassBuilder.buildTabClass(tab);
- }
+ // Store flag for exist client-side tabs.
+ componentVariables.setVariable("clientSide", new Boolean(clientSide));
+ componentVariables.setVariable("tabs", tabs);
+ }
- public static String getDisabledTabCellClass(UITab tab) {
- return TabClassBuilder.disabledTabClassBuilder.buildTabClass(tab);
- }
+ public static String getActiveTabCellClass(UITab tab) {
+ return TabClassBuilder.activeTabClassBuilder.buildTabClass(tab);
+ }
- public static String getInactiveTabCellClass(UITab tab) {
- return TabClassBuilder.inactiveTabClassBuilder.buildTabClass(tab);
- }
+ public static String getDisabledTabCellClass(UITab tab) {
+ return TabClassBuilder.disabledTabClassBuilder.buildTabClass(tab);
+ }
+ public static String getInactiveTabCellClass(UITab tab) {
+ return TabClassBuilder.inactiveTabClassBuilder.buildTabClass(tab);
+ }
- public static String getActiveTabClass(UITab tab) {
- return TabClassBuilder.activeTabClassBuilder.buildTabClass(tab);
- }
- public static String getDisabledTabClass(UITab tab) {
- return TabClassBuilder.disabledTabClassBuilder.buildTabClass(tab);
- }
+ public static String getActiveTabClass(UITab tab) {
+ return TabClassBuilder.activeTabClassBuilder.buildTabClass(tab);
+ }
- public static String getInactiveTabClass(UITab tab) {
- return TabClassBuilder.inactiveTabClassBuilder.buildTabClass(tab);
- }
+ public static String getDisabledTabClass(UITab tab) {
+ return TabClassBuilder.disabledTabClassBuilder.buildTabClass(tab);
+ }
- /**
- * Encode JavaScript function for switch tabs.
- *
- * @param templateContext
- * @throws IOException
- */
- public void encodeTabsScript(FacesContext context, UITabPanel pane) throws IOException {
- ComponentVariables variables = ComponentsVariableResolver.getVariables(this, pane);
- ArrayList tabs = (ArrayList) variables.getVariable("tabs");
- // TODO - create tab control function.
- getUtils().writeScript(context,pane,"RichFaces.panelTabs['"+pane.getClientId(context)+"']="+ScriptUtils.toScript(tabs)+";");
- }
+ public static String getInactiveTabClass(UITab tab) {
+ return TabClassBuilder.inactiveTabClassBuilder.buildTabClass(tab);
+ }
+ /**
+ * Encode JavaScript function for switch tabs.
+ *
+ * @param context
+ * @throws IOException
+ */
+ public void encodeTabsScript(FacesContext context, UITabPanel pane) throws IOException {
+ ComponentVariables variables = ComponentsVariableResolver.getVariables(this, pane);
+ ArrayList tabs = (ArrayList) variables.getVariable("tabs");
+ // TODO - create tab control function.
+ getUtils().writeScript(context, pane, "RichFaces.panelTabs['" + pane.getClientId(context) + "']=" + ScriptUtils.toScript(tabs) + ";");
+ }
+
/* public String encodeHeaderSpacing(FacesContext context, UITabPanel pane) throws IOException {
String headerSpacing = pane.getHeaderSpacing();
Double decoded = HtmlDimensions.decode(headerSpacing);
@@ -301,9 +303,7 @@
}
} */
- protected TabInfoCollector getTabInfoCollector() {
- return collector;
- }
-
-
+ protected TabInfoCollector getTabInfoCollector() {
+ return collector;
+ }
}
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabRendererBase.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabRendererBase.java 2007-04-12 16:23:41 UTC (rev 387)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/TabRendererBase.java 2007-04-12 16:24:47 UTC (rev 388)
@@ -21,105 +21,102 @@
package org.richfaces.renderkit;
-import java.io.IOException;
+import org.ajax4jsf.framework.renderer.RendererBase;
+import org.richfaces.component.TabEncoder;
+import org.richfaces.component.UISwitchablePanel;
+import org.richfaces.component.UITab;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import java.io.IOException;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.richfaces.component.TabEncoder;
-import org.richfaces.component.UISwitchablePanel;
-import org.richfaces.component.UITab;
-
-
/**
* @author Nick Belaevski - nbelaevski at exadel.com
- * created 12.01.2007
- *
+ * created 12.01.2007
*/
public class TabRendererBase extends RendererBase implements TabEncoder {
- private RendererBase tabHeaderRenderer;
+ private RendererBase tabHeaderRenderer;
- public TabRendererBase() {
- super();
-
- Package pkg = this.getClass().getPackage();
- try {
- tabHeaderRenderer = (RendererBase) Class.forName(pkg.getName() + ".TabHeaderRenderer").newInstance();
- } catch (InstantiationException e) {
- throw new FacesException(e);
- } catch (IllegalAccessException e) {
- throw new FacesException(e);
- } catch (ClassNotFoundException e) {
- throw new FacesException(e);
- }
- }
-
- /**
- * Encode this tab header in Panel switch pane.
- * @param context
- * @param tab
- * @param active
- * @throws IOException
- */
- public void encodeTab(FacesContext context, UITab tab, boolean active) throws IOException {
- tabHeaderRenderer.encodeBegin(context, tab);
- tabHeaderRenderer.encodeEnd(context, tab);
- }
-
- public String getTabDisplay(FacesContext context, UITab tab) {
- if (!tab.isActive()) {
- return "display: none;";
- }
-
- return "";
- }
+ public TabRendererBase() {
+ super();
- protected boolean shouldRenderTab(UITab tab) {
- String method = tab.getSwitchType();
- return (tab.isActive() || UISwitchablePanel.CLIENT_METHOD.equals(method));
- }
-
- public void encodeBegin(FacesContext context, UIComponent component)
- throws IOException {
+ Package pkg = this.getClass().getPackage();
+ try {
+ tabHeaderRenderer = (RendererBase) Class.forName(pkg.getName() + ".TabHeaderRenderer").newInstance();
+ } catch (InstantiationException e) {
+ throw new FacesException(e);
+ } catch (IllegalAccessException e) {
+ throw new FacesException(e);
+ } catch (ClassNotFoundException e) {
+ throw new FacesException(e);
+ }
+ }
- UITab tab = (UITab) component;
- if (shouldRenderTab(tab)) {
- super.encodeBegin(context, component);
- }
- }
-
- public void encodeEnd(FacesContext context, UIComponent component)
- throws IOException {
+ /**
+ * Encode this tab header in Panel switch pane.
+ *
+ * @param context
+ * @param tab
+ * @param active
+ * @throws IOException
+ */
+ public void encodeTab(FacesContext context, UITab tab, boolean active) throws IOException {
+ tabHeaderRenderer.encodeBegin(context, tab);
+ tabHeaderRenderer.encodeEnd(context, tab);
+ }
- UITab tab = (UITab) component;
- if (shouldRenderTab(tab)) {
- super.encodeEnd(context, component);
- }
- }
-
- public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
+ public String getTabDisplay(FacesContext context, UITab tab) {
+ if (!tab.isActive()) {
+ return "display: none;";
+ }
- UITab tab = (UITab) component;
- if (shouldRenderTab(tab)) {
- if ((tab.getChildren()!=null) && (tab.getChildren().size()>0)){
- renderChildren(context,component);
- }
- else{
- ResponseWriter out = context.getResponseWriter();
- out.write(" ");
- }
- }
- }
+ return "";
+ }
- protected Class getComponentClass() {
- return UITab.class;
- }
+ protected boolean shouldRenderTab(UITab tab) {
+ String method = tab.getSwitchType();
+ return (tab.isActive() || UISwitchablePanel.CLIENT_METHOD.equals(method));
+ }
- public boolean getRendersChildren() {
- return true;
- }
+ public void encodeBegin(FacesContext context, UIComponent component)
+ throws IOException {
+
+ UITab tab = (UITab) component;
+ if (shouldRenderTab(tab)) {
+ super.encodeBegin(context, component);
+ }
+ }
+
+ public void encodeEnd(FacesContext context, UIComponent component)
+ throws IOException {
+
+ UITab tab = (UITab) component;
+ if (shouldRenderTab(tab)) {
+ super.encodeEnd(context, component);
+ }
+ }
+
+ public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
+
+ UITab tab = (UITab) component;
+ if (shouldRenderTab(tab)) {
+ if ((tab.getChildren() != null) && (tab.getChildren().size() > 0)) {
+ renderChildren(context, component);
+ } else {
+ ResponseWriter out = context.getResponseWriter();
+ out.write(" ");
+ }
+ }
+ }
+
+ protected Class getComponentClass() {
+ return UITab.class;
+ }
+
+ public boolean getRendersChildren() {
+ return true;
+ }
}
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/images/TabGradientA.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/images/TabGradientA.java 2007-04-12 16:23:41 UTC (rev 387)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/images/TabGradientA.java 2007-04-12 16:24:47 UTC (rev 388)
@@ -26,11 +26,10 @@
/**
* @author Nick Belaevski - nbelaevski at exadel.com
- * created 02.02.2007
- *
+ * created 02.02.2007
*/
public class TabGradientA extends BaseGradient {
- public TabGradientA() {
- super(10, 40, 14, "tabBackgroundColor", Skin.generalBackgroundColor);
- }
+ public TabGradientA() {
+ super(10, 40, 14, "tabBackgroundColor", Skin.generalBackgroundColor);
+ }
}
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/images/TabGradientB.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/images/TabGradientB.java 2007-04-12 16:23:41 UTC (rev 387)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/images/TabGradientB.java 2007-04-12 16:24:47 UTC (rev 388)
@@ -26,11 +26,10 @@
/**
* @author Nick Belaevski - nbelaevski at exadel.com
- * created 02.02.2007
- *
+ * created 02.02.2007
*/
public class TabGradientB extends BaseGradient {
- public TabGradientB() {
- super(10, 40, 12, Skin.generalBackgroundColor, "tabBackgroundColor");
- }
+ public TabGradientB() {
+ super(10, 40, 12, Skin.generalBackgroundColor, "tabBackgroundColor");
+ }
}
Modified: trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java
===================================================================
--- trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java 2007-04-12 16:23:41 UTC (rev 387)
+++ trunk/richfaces/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java 2007-04-12 16:24:47 UTC (rev 388)
@@ -21,15 +21,6 @@
package org.richfaces.renderkit.images;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.geom.Rectangle2D;
-import java.util.Date;
-
-import javax.faces.context.FacesContext;
-
import org.ajax4jsf.framework.resource.GifRenderer;
import org.ajax4jsf.framework.resource.InternetResourceBuilder;
import org.ajax4jsf.framework.resource.Java2Dresource;
@@ -38,56 +29,60 @@
import org.ajax4jsf.framework.skin.SkinFactory;
import org.ajax4jsf.framework.util.HtmlColor;
+import javax.faces.context.FacesContext;
+import java.awt.*;
+import java.awt.geom.Rectangle2D;
+import java.util.Date;
+
/**
* @author Nick - mailto:nbelaevski at exadel.com
- * created 02.02.2007
- *
+ * created 02.02.2007
*/
public class TabStripeImage extends Java2Dresource {
- private int width;
- private int height;
+ private int width;
+ private int height;
- public TabStripeImage() {
- super();
+ public TabStripeImage() {
+ super();
- this.width = 1;
- this.height = 200;
-
- setRenderer(new GifRenderer());
- setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
- }
-
- protected Object getDataToStore(FacesContext context, Object data) {
- Skin skin = SkinFactory.getInstance().getSkin(context);
-
- String color = (String) skin.getParameter(context, "panelBorderColor");
- return new Integer(HtmlColor.decode(color).getRGB());
- }
+ this.width = 1;
+ this.height = 200;
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return getDimensions(null, restoreData(resourceContext));
- }
+ setRenderer(new GifRenderer());
+ setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
+ }
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return new Dimension(width, height);
- }
+ protected Object getDataToStore(FacesContext context, Object data) {
+ Skin skin = SkinFactory.getInstance().getSkin(context);
- protected void paint(ResourceContext context, Graphics2D graphics2D) {
- super.paint(context, graphics2D);
+ String color = (String) skin.getParameter(context, "panelBorderColor");
+ return new Integer(HtmlColor.decode(color).getRGB());
+ }
- graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
- graphics2D.setRenderingHint(RenderingHints.KEY_DITHERING,
- RenderingHints.VALUE_DITHER_ENABLE);
- graphics2D.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
- RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ protected Dimension getDimensions(ResourceContext resourceContext) {
+ return getDimensions(null, restoreData(resourceContext));
+ }
- Integer tabData = (Integer) restoreData(context);
+ public Dimension getDimensions(FacesContext facesContext, Object data) {
+ return new Dimension(width, height);
+ }
- Dimension dimension = getDimensions(context);
- Rectangle2D region = new Rectangle2D.Double(0, 1, dimension.getWidth(), dimension.getHeight() - 1);
-
- graphics2D.setColor(new Color(tabData.intValue()));
- graphics2D.fill(region);
- }
+ protected void paint(ResourceContext context, Graphics2D graphics2D) {
+ super.paint(context, graphics2D);
+
+ graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ graphics2D.setRenderingHint(RenderingHints.KEY_DITHERING,
+ RenderingHints.VALUE_DITHER_ENABLE);
+ graphics2D.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
+ RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+
+ Integer tabData = (Integer) restoreData(context);
+
+ Dimension dimension = getDimensions(context);
+ Rectangle2D region = new Rectangle2D.Double(0, 1, dimension.getWidth(), dimension.getHeight() - 1);
+
+ graphics2D.setColor(new Color(tabData.intValue()));
+ graphics2D.fill(region);
+ }
}
More information about the richfaces-svn-commits
mailing list