You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by to...@apache.org on 2006/10/16 13:56:02 UTC
svn commit: r464453 - in /myfaces/tomahawk/trunk: core/
sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/
sandbox/core/src/main/resources-facesconfig/META-INF/
sandbox/core/src/main/tld/ sandbox/core/src/main/tld/entities/
sandbox/examples/...
Author: tomsp
Date: Mon Oct 16 04:55:58 2006
New Revision: 464453
URL: http://svn.apache.org/viewvc?view=rev&rev=464453
Log:
TOMAHAWK-743 implemented
Added:
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/FishEyeCommandLink.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/FishEyeCommandLinkTag.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/FishEyeItem.java
myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_fishey_commandlink_attributes.xml
myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/fisheye/labels.properties
Modified:
myfaces/tomahawk/trunk/core/pom.xml
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenu.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenuRenderer.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenuTag.java
myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_fisheyelist_attributes.xml
myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/fisheye/FishEyeHandler.java
myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/fisheye.jsp
Modified: myfaces/tomahawk/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/pom.xml?view=diff&rev=464453&r1=464452&r2=464453
==============================================================================
--- myfaces/tomahawk/trunk/core/pom.xml (original)
+++ myfaces/tomahawk/trunk/core/pom.xml Mon Oct 16 04:55:58 2006
@@ -230,6 +230,18 @@
<plugins>
<plugin>
+ <groupId>org.apache.myfaces.maven</groupId>
+ <artifactId>facelets-plugin</artifactId>
+ <version>1.0.5-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <phase>compile</phase>
+ <goals><goal>generate-taglibs</goal></goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/FishEyeCommandLink.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/FishEyeCommandLink.java?view=auto&rev=464453
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/FishEyeCommandLink.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/FishEyeCommandLink.java Mon Oct 16 04:55:58 2006
@@ -0,0 +1,66 @@
+package org.apache.myfaces.custom.fisheye;
+
+import org.apache.myfaces.shared_tomahawk.util._ComponentUtils;
+
+import javax.faces.component.UICommand;
+import javax.faces.el.ValueBinding;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Thomas Spiegl
+ */
+public class FishEyeCommandLink extends UICommand {
+ private String _caption;
+ private String _iconSrc;
+ private String _target;
+
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.FishEyeCommandLink";
+ public static final String RENDERER_TYPE = "org.apache.myfaces.FishEyeCommandLink";
+
+ public String getCaption() {
+ if (_caption != null) return _caption;
+ ValueBinding vb = getValueBinding("caption");
+ return vb != null ? _ComponentUtils.getStringValue(getFacesContext(), vb) : null;
+ }
+
+ public void setCaption(String caption) {
+ _caption = caption;
+ }
+
+ public String getIconSrc() {
+ if (_iconSrc != null) return _iconSrc;
+ ValueBinding vb = getValueBinding("iconSrc");
+ return vb != null ? _ComponentUtils.getStringValue(getFacesContext(), vb) : null;
+ }
+
+ public void setIconSrc(String iconSrc) {
+ _iconSrc = iconSrc;
+ }
+
+ public String getTarget() {
+ if (_target != null) return _target;
+ ValueBinding vb = getValueBinding("target");
+ return vb != null ? _ComponentUtils.getStringValue(getFacesContext(), vb) : null;
+ }
+
+ public void setTarget(String target) {
+ _target = target;
+ }
+
+ public Object saveState(FacesContext context) {
+ Object[] state = new Object[4];
+ state[0] = super.saveState(context);
+ state[1] = _caption;
+ state[2] = _iconSrc;
+ state[3] = _target;
+ return state;
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ Object values[] = (Object[])state;
+ super.restoreState(context, values[0]);
+ _caption = (String)values[1];
+ _iconSrc = (String)values[2];
+ _target = (String)values[3];
+ }
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/FishEyeCommandLinkTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/FishEyeCommandLinkTag.java?view=auto&rev=464453
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/FishEyeCommandLinkTag.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/FishEyeCommandLinkTag.java Mon Oct 16 04:55:58 2006
@@ -0,0 +1,77 @@
+package org.apache.myfaces.custom.fisheye;
+
+import org.apache.myfaces.shared_tomahawk.taglib.UIComponentTagBase;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * JSP Tag for the FishEyeList component
+ *
+ * @author Jurgen Lust (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class FishEyeCommandLinkTag extends UIComponentTagBase
+{
+ private static final String CAPTION_ATTR = "caption";
+ private static final String ICONSRC_ATTR = "iconSrc";
+ private static final String TARGET_ATTR = "target";
+
+ private String _caption;
+ private String _iconSrc;
+ private String _target;
+ private String _action;
+ private String _actionListener;
+ private String _immediate;
+
+ public String getComponentType() {
+ return FishEyeCommandLink.COMPONENT_TYPE;
+ }
+
+ public String getRendererType() {
+ return FishEyeCommandLink.RENDERER_TYPE;
+ }
+
+ protected void setProperties(UIComponent component) {
+ super.setProperties(component);
+ setStringProperty(component, CAPTION_ATTR, _caption);
+ setStringProperty(component, ICONSRC_ATTR, _iconSrc);
+ setStringProperty(component, TARGET_ATTR, _target);
+ setActionProperty(component, _action);
+ setActionListenerProperty(component, _actionListener);
+ setBooleanProperty(component, org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr.IMMEDIATE_ATTR, _immediate);
+ }
+
+ public void release() {
+ super.release();
+ _caption = null;
+ _iconSrc = null;
+ _target = null;
+ _action = null;
+ _actionListener = null;
+ _immediate = null;
+ }
+
+ public void setCaption(String caption) {
+ _caption = caption;
+ }
+
+ public void setIconSrc(String iconSrc) {
+ _iconSrc = iconSrc;
+ }
+
+ public void setTarget(String target) {
+ _target = target;
+ }
+
+ public void setAction(String action) {
+ _action = action;
+ }
+
+ public void setActionListener(String actionListener) {
+ _actionListener = actionListener;
+ }
+
+ public void setImmediate(String immediate) {
+ _immediate = immediate;
+ }
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/FishEyeItem.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/FishEyeItem.java?view=auto&rev=464453
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/FishEyeItem.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/FishEyeItem.java Mon Oct 16 04:55:58 2006
@@ -0,0 +1,45 @@
+package org.apache.myfaces.custom.fisheye;
+
+/**
+ * @author Thomas Spiegl
+ */
+public class FishEyeItem {
+ private String _caption;
+ private String _iconSrc;
+ private String _target;
+
+ public FishEyeItem(String caption, String iconSrc) {
+ _caption = caption;
+ _iconSrc = iconSrc;
+ }
+
+ public FishEyeItem(String caption, String iconSrc, String target) {
+ _caption = caption;
+ _iconSrc = iconSrc;
+ _target = target;
+ }
+
+ public String getCaption() {
+ return _caption;
+ }
+
+ public void setCaption(String caption) {
+ _caption = caption;
+ }
+
+ public String getIconSrc() {
+ return _iconSrc;
+ }
+
+ public void setIconSrc(String iconSrc) {
+ _iconSrc = iconSrc;
+ }
+
+ public String getTarget() {
+ return _target;
+ }
+
+ public void setTarget(String target) {
+ _target = target;
+ }
+}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenu.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenu.java?view=diff&rev=464453&r1=464452&r2=464453
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenu.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenu.java Mon Oct 16 04:55:58 2006
@@ -15,10 +15,11 @@
*/
package org.apache.myfaces.custom.fisheye;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
-
-import org.apache.myfaces.custom.div.Div;
+import java.util.Iterator;
/**
* A Mac OSX-style toolbar, using the DOJO toolkit.
@@ -28,7 +29,7 @@
* @author Jurgen Lust (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class HtmlFishEyeNavigationMenu extends Div
+public class HtmlFishEyeNavigationMenu extends UIData
{
public static final String COMPONENT_TYPE = "org.apache.myfaces.FishEyeList";
private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.FishEyeList";
@@ -40,6 +41,7 @@
public static final String EDGE_TOP = "top";
public static final String HORIZONTAL_ORIENTATION = "horizontal";
public static final String VERTICAL_ORIENTATION = "vertical";
+ private static final String NODE_STAMP_FACET_NAME = "nodeStamp";
private String _attachEdge;
private Boolean _conservativeTrigger;
@@ -52,24 +54,69 @@
private String _labelEdge;
private String _orientation;
- private Integer _visibleWindow = null;
-
- public void setVisibleWindow(Integer visibleWindow)
+ private Integer _visibleWindow = null;
+
+ public HtmlFishEyeNavigationMenu()
+ {
+ setRendererType(DEFAULT_RENDERER_TYPE);
+ }
+
+ public void processDecodes(FacesContext context) {
+ super.processDecodes(context);
+ int first = getFirst();
+ int rows = getRows();
+ int last;
+ if (rows == 0)
+ {
+ last = getRowCount();
+ }
+ else
+ {
+ last = first + rows;
+ }
+ for (int rowIndex = first; last==-1 || rowIndex < last; rowIndex++)
+ {
+ setRowIndex(rowIndex);
+
+ //scrolled past the last row
+ if (!isRowAvailable())
+ break;
+
+ for (Iterator it = getChildren().iterator(); it.hasNext();)
+ {
+ UIComponent child = (UIComponent) it.next();
+ if (child instanceof FishEyeCommandLink)
+ {
+ if (!child.isRendered())
+ {
+ //Column is not visible
+ continue;
+ }
+ child.processDecodes(context);
+ }
+ }
+ }
+ }
+
+ public void setVisibleWindow(Integer visibleWindow)
{
_visibleWindow = visibleWindow;
}
+ public void setValueBinding(String string, ValueBinding valueBinding) {
+ super.setValueBinding(string, valueBinding); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
public Integer getVisibleWindow()
{
if (_visibleWindow != null) return _visibleWindow;
ValueBinding vb = getValueBinding("visibleWindow");
return vb != null ? (Integer)vb.getValue(getFacesContext()) : null;
}
-
-
- public HtmlFishEyeNavigationMenu()
+
+ public UIComponent getNodeStamp()
{
- setRendererType(DEFAULT_RENDERER_TYPE);
+ return (UIComponent) getFacets().get(NODE_STAMP_FACET_NAME);
}
public String getAttachEdge()
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenuRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenuRenderer.java?view=diff&rev=464453&r1=464452&r2=464453
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenuRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenuRenderer.java Mon Oct 16 04:55:58 2006
@@ -15,31 +15,26 @@
*/
package org.apache.myfaces.custom.fisheye;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Stack;
-import java.util.TreeMap;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.event.ActionEvent;
-import javax.servlet.http.HttpServletRequest;
-
import org.apache.commons.collections.map.HashedMap;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.custom.dojo.DojoUtils;
import org.apache.myfaces.custom.navmenu.UINavigationMenuItem;
import org.apache.myfaces.renderkit.html.ext.HtmlLinkRenderer;
-import org.apache.myfaces.shared_tomahawk.config.MyfacesConfig;
import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.event.ActionEvent;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.util.*;
+
/**
* Renderer for the FishEyeList component
*
@@ -47,38 +42,25 @@
* @version $Revision$ $Date$
*/
public class HtmlFishEyeNavigationMenuRenderer extends HtmlLinkRenderer {
- private static final String ON_CLICK_ATTR = "onClick";
+ private static final String ON_CLICK_ATTR = "onClick";
private static final String DOJO_COMPONENT_TYPE = "ScrollableFisheyeList";
-
private static final String DOJO_ITEM_TYPE = "ScrollableFisheyeListItem";
-
public static final String ATTACH_EDGE_ATTR = "attachEdge";
-
public static final String CAPTION_ATTR = "caption";
-
public static final String EFFECT_UNITS_ATTR = "effectUnits";
-
public static final String ICON_SRC_ATTR = "iconSrc";
-
public static final String ITEM_HEIGHT_ATTR = "itemHeight";
-
public static final String ITEM_MAX_HEIGHT_ATTR = "itemMaxHeight";
-
public static final String ITEM_MAX_WIDTH_ATTR = "itemMaxWidth";
-
public static final String ITEM_PADDING_ATTR = "itemPadding";
-
public static final String ITEM_WIDTH_ATTR = "itemWidth";
-
public static final String LABEL_EDGE_ATTR = "labelEdge";
-
public static final String ORIENTATION_ATTR = "orientation";
-
public static final String CONSERVATIVE_TRIGGER_ATTR = "conservativeTrigger";
-
public static final String RENDERER_TYPE = "org.apache.myfaces.FishEyeList";
+ private Log log = LogFactory.getLog(HtmlFishEyeNavigationMenuRenderer.class);
/**
* @see javax.faces.render.Renderer#decode(javax.faces.context.FacesContext,
* javax.faces.component.UIComponent)
@@ -89,10 +71,15 @@
String fieldName = HtmlRendererUtils.getHiddenCommandLinkFieldName(nestingForm);
String reqValue = (String) context.getExternalContext().getRequestParameterMap().get(fieldName);
if (reqValue != null && reqValue.length() > 0) {
- UIComponent source = context.getViewRoot().findComponent(reqValue);
- if (source instanceof UINavigationMenuItem) {
- UINavigationMenuItem item = (UINavigationMenuItem) source;
- item.queueEvent(new ActionEvent(item));
+ if (component instanceof FishEyeCommandLink && reqValue.equals(component.getClientId(context))) {
+ component.queueEvent(new ActionEvent(component));
+ } else {
+ // deprecated : the old UINavigationMenuItem way
+ UIComponent source = context.getViewRoot().findComponent(reqValue);
+ if (source instanceof UINavigationMenuItem) {
+ source.queueEvent(new ActionEvent(source));
+ }
+
}
}
}
@@ -205,13 +192,26 @@
public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
ResponseWriter writer = context.getResponseWriter();
List children = component.getChildren();
- Stack menuStack = (Stack) getChildsMenuStack(context, component);
- for (Iterator cit = children.iterator(); cit.hasNext();) {
- UIComponent child = (UIComponent) cit.next();
- if (!child.isRendered())
- continue;
- if (child instanceof UINavigationMenuItem) {
- renderMenuItem(context, writer, component, (UINavigationMenuItem) child, menuStack);
+ Stack menuStack = getChildsMenuStack(context, component);
+ HtmlFishEyeNavigationMenu menu = (HtmlFishEyeNavigationMenu) component;
+ if (menu.getChildCount() == 1 && menu.getChildren().get(0) instanceof FishEyeCommandLink) {
+ FishEyeCommandLink link = (FishEyeCommandLink) menu.getChildren().get(0);
+ for (int i = 0; i < menu.getRowCount(); i++) {
+ menu.setRowIndex(i);
+ if(!menu.isRowAvailable()) {
+ log.error("Model is not available. Rowindex = " + i);
+ break;
+ }
+ renderMenuItem(context, writer, component, link, menuStack);
+ }
+ } else {
+ for (Iterator cit = children.iterator(); cit.hasNext();) {
+ UIComponent child = (UIComponent) cit.next();
+ if (!child.isRendered())
+ continue;
+ if (child instanceof UINavigationMenuItem) {
+ renderMenuItem(context, writer, component, (UINavigationMenuItem) child, menuStack);
+ }
}
}
}
@@ -248,7 +248,7 @@
return true;
}
- protected void renderMenuItem(FacesContext context, ResponseWriter writer, UIComponent menu, UINavigationMenuItem item, Stack childsMenuStack)
+ protected void renderMenuItem(FacesContext context, ResponseWriter writer, UIComponent menu, UIComponent item, Stack childsMenuStack)
throws IOException {
// find the enclosing form
FormInfo formInfo = findNestingForm(item, context);
@@ -272,9 +272,9 @@
// call the clear_<formName> method
onClick.append(HtmlRendererUtils.getClearHiddenCommandFormParamsFunctionName(formName)).append("();");
- if (MyfacesConfig.getCurrentInstance(context.getExternalContext()).isAutoScroll()) {
- HtmlRendererUtils.appendAutoScrollAssignment(onClick, formName);
- }
+ //if (MyfacesConfig.getCurrentInstance(context.getExternalContext()).isAutoScroll()) {
+ //HtmlRendererUtils.appendAutoScrollAssignment(onClick, formName);
+ //}
// add id parameter for decode
String hiddenFieldName = HtmlRendererUtils.getHiddenCommandLinkFieldName(formInfo);
@@ -283,9 +283,22 @@
onClick.append(".value='").append(clientId).append("';");
addHiddenCommandParameter(context, nestingForm, hiddenFieldName);
}
+ String target;
+ String caption;
+ String iconSrc;
+ if (item instanceof UINavigationMenuItem) {
+ target = ((UINavigationMenuItem)item).getTarget();
+ caption = ((UINavigationMenuItem)item).getItemLabel();
+ iconSrc = ((UINavigationMenuItem)item).getIcon();
+ } else if (item instanceof FishEyeCommandLink) {
+ target = ((FishEyeCommandLink)item).getTarget();
+ caption = ((FishEyeCommandLink)item).getCaption();
+ iconSrc = ((FishEyeCommandLink)item).getIconSrc();
+ } else {
+ throw new IllegalArgumentException("expected UINavigationMenuItem or FisheyCommandLink");
+ }
// add the target window
- String target = item.getTarget();
if (target != null && target.trim().length() > 0) {
onClick.append(jsForm);
onClick.append(".target='");
@@ -304,8 +317,8 @@
// the click
Map paramMap = new HashMap();
- paramMap.put(CAPTION_ATTR, item.getItemLabel());
- paramMap.put(ICON_SRC_ATTR, item.getIcon());
+ paramMap.put(CAPTION_ATTR, caption);
+ paramMap.put(ICON_SRC_ATTR, iconSrc);
paramMap.put(ON_CLICK_ATTR, new StringBuffer("function () {").append(onClick).append("}"));
// push the onclick as lambda and use a stringbuffer so that we do not
// get enclosing quotes
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenuTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenuTag.java?view=diff&rev=464453&r1=464452&r2=464453
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenuTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenuTag.java Mon Oct 16 04:55:58 2006
@@ -20,6 +20,7 @@
import javax.faces.context.FacesContext;
import org.apache.myfaces.custom.div.DivTag;
+import org.apache.myfaces.shared_tomahawk.taglib.UIComponentTagBase;
/**
* JSP Tag for the FishEyeList component
@@ -27,7 +28,7 @@
* @author Jurgen Lust (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class HtmlFishEyeNavigationMenuTag extends DivTag
+public class HtmlFishEyeNavigationMenuTag extends UIComponentTagBase
{
private String _attachEdge;
private String _conservativeTrigger;
@@ -39,77 +40,40 @@
private String _itemWidth;
private String _labelEdge;
private String _orientation;
- private String _visibleWindow = null;
+ private String _visibleWindow;
+ private String _var;
+ private String _immediate;
-
-
- public static final String TAG_PARAM_VisibleWindow = "visibleWindow";
-
-
- public void setVisibleWindow(String visibleWindow) {
- _visibleWindow = visibleWindow;
- }
-
-
-
- public String getAttachEdge()
- {
- return _attachEdge;
+ public void setValue(String value) {
+ super.setValue(value); //To change body of overridden methods use File | Settings | File Templates.
}
+ public static final String TAG_PARAM_VisibleWindow = "visibleWindow";
+
public String getComponentType()
{
return HtmlFishEyeNavigationMenu.COMPONENT_TYPE;
}
- public String getConservativeTrigger()
- {
- return _conservativeTrigger;
- }
-
- public String getEffectUnits()
- {
- return _effectUnits;
- }
-
- public String getItemHeight()
- {
- return _itemHeight;
- }
-
- public String getItemMaxHeight()
- {
- return _itemMaxHeight;
- }
-
- public String getItemMaxWidth()
- {
- return _itemMaxWidth;
- }
-
- public String getItemPadding()
- {
- return _itemPadding;
- }
-
- public String getItemWidth()
- {
- return _itemWidth;
- }
-
- public String getLabelEdge()
- {
- return _labelEdge;
- }
-
- public String getOrientation()
- {
- return _orientation;
+ public String getRendererType() {
+ return HtmlFishEyeNavigationMenuRenderer.RENDERER_TYPE;
}
- public String getRendererType()
+ protected void setProperties(UIComponent component)
{
- return HtmlFishEyeNavigationMenuRenderer.RENDERER_TYPE;
+ super.setProperties(component);
+ setStringProperty(component, "attachedEdge", _attachEdge);
+ setIntegerProperty(component, "effectUnits", _effectUnits);
+ setIntegerProperty(component, "itemHeight", _itemHeight);
+ setIntegerProperty(component, "itemMaxHeight", _itemMaxHeight);
+ setIntegerProperty(component, "itemMaxWidth", _itemMaxWidth);
+ setIntegerProperty(component, "itemPadding", _itemPadding);
+ setIntegerProperty(component, "itemWidth", _itemWidth);
+ setStringProperty(component, "labelEdge", _labelEdge);
+ setStringProperty(component, "orientation", _orientation);
+ setBooleanProperty(component, "conservativeTrigger", _conservativeTrigger);
+ setIntegerProperty(component, "visibleWindow", _visibleWindow);
+ setStringProperty(component, "var", _var);
}
public void release()
@@ -125,6 +89,17 @@
_labelEdge = null;
_orientation = null;
_visibleWindow = null;
+ _var = null;
+ }
+
+ public void setVisibleWindow(String visibleWindow)
+ {
+ _visibleWindow = visibleWindow;
+ }
+
+ public String getConservativeTrigger()
+ {
+ return _conservativeTrigger;
}
public void setAttachEdge(String attachEdge)
@@ -177,148 +152,8 @@
this._orientation = orientation;
}
- protected void setProperties(UIComponent component)
+ public void setVar(String var)
{
- super.setProperties(component);
- HtmlFishEyeNavigationMenu fisheye = (HtmlFishEyeNavigationMenu) component;
- FacesContext context = FacesContext.getCurrentInstance();
- Application app = context.getApplication();
- if (_attachEdge != null)
- {
- if (isValueReference(_attachEdge))
- {
- fisheye.setValueBinding("attachEdge", app
- .createValueBinding(_attachEdge));
- }
- else
- {
- fisheye.setAttachEdge(_attachEdge);
- }
- }
- if (_effectUnits != null)
- {
- if (isValueReference(_effectUnits))
- {
- fisheye.setValueBinding("effectUnits", app
- .createValueBinding(_effectUnits));
- }
- else
- {
- fisheye.setEffectUnits(new Integer(_effectUnits));
- }
- }
- if (_itemHeight != null)
- {
- if (isValueReference(_itemHeight))
- {
- fisheye.setValueBinding("itemHeight", app
- .createValueBinding(_itemHeight));
- }
- else
- {
- fisheye.setItemHeight(new Integer(_itemHeight));
- }
- }
- if (_itemMaxHeight != null)
- {
- if (isValueReference(_itemMaxHeight))
- {
- fisheye.setValueBinding("itemMaxHeight", app
- .createValueBinding(_itemMaxHeight));
- }
- else
- {
- fisheye.setItemMaxHeight(new Integer(_itemMaxHeight));
- }
- }
- if (_itemMaxWidth != null)
- {
- if (isValueReference(_itemMaxWidth))
- {
- fisheye.setValueBinding("itemMaxWidth", app
- .createValueBinding(_itemMaxWidth));
- }
- else
- {
- fisheye.setItemMaxWidth(new Integer(_itemMaxWidth));
- }
- }
- if (_itemPadding != null)
- {
- if (isValueReference(_itemPadding))
- {
- fisheye.setValueBinding("itemPadding", app
- .createValueBinding(_itemPadding));
- }
- else
- {
- fisheye.setItemPadding(new Integer(_itemPadding));
- }
- }
- if (_itemWidth != null)
- {
- if (isValueReference(_itemWidth))
- {
- fisheye.setValueBinding("itemWidth", app
- .createValueBinding(_itemWidth));
- }
- else
- {
- fisheye.setItemWidth(new Integer(_itemWidth));
- }
- }
- if (_labelEdge != null)
- {
- if (isValueReference(_labelEdge))
- {
- fisheye.setValueBinding("labelEdge", app
- .createValueBinding(_labelEdge));
- }
- else
- {
- fisheye.setLabelEdge(_labelEdge);
- }
- }
- if (_orientation != null)
- {
- if (isValueReference(_orientation))
- {
- fisheye.setValueBinding("orientation", app
- .createValueBinding(_orientation));
- }
- else
- {
- fisheye.setOrientation(_orientation);
- }
- }
- if (_conservativeTrigger != null)
- {
- if (isValueReference(_conservativeTrigger))
- {
- fisheye.setValueBinding("conservativeTrigger", app
- .createValueBinding(_conservativeTrigger));
- }
- else
- {
- fisheye.setConservativeTrigger(Boolean
- .valueOf(_conservativeTrigger));
- }
- }
- if (_visibleWindow != null)
- {
- if (isValueReference(_visibleWindow))
- {
- fisheye.setValueBinding("visibleWindow", app
- .createValueBinding(_visibleWindow));
- }
- else
- {
- fisheye.setVisibleWindow(Integer
- .valueOf(_visibleWindow));
- }
- }
-
-
+ _var = var;
}
-
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml?view=diff&rev=464453&r1=464452&r2=464453
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml Mon Oct 16 04:55:58 2006
@@ -181,6 +181,11 @@
<component-class>org.apache.myfaces.custom.fisheye.HtmlFishEyeNavigationMenu</component-class>
</component>
+ <component>
+ <component-type>org.apache.myfaces.FishEyeCommandLink</component-type>
+ <component-class>org.apache.myfaces.custom.fisheye.FishEyeCommandLink</component-class>
+ </component>
+
<component>
<component-type>org.apache.myfaces.TimedNotifier</component-type>
<component-class>org.apache.myfaces.custom.timednotifier.TimedNotifier</component-class>
@@ -430,10 +435,16 @@
</renderer>
<renderer>
- <component-family>javax.faces.Output</component-family>
+ <component-family>javax.faces.Data</component-family>
<renderer-type>org.apache.myfaces.FishEyeList</renderer-type>
<renderer-class>org.apache.myfaces.custom.fisheye.HtmlFishEyeNavigationMenuRenderer</renderer-class>
</renderer>
+
+ <renderer>
+ <component-family>javax.faces.Command</component-family>
+ <renderer-type>org.apache.myfaces.FishEyeCommandLink</renderer-type>
+ <renderer-class>org.apache.myfaces.custom.fisheye.HtmlFishEyeNavigationMenuRenderer</renderer-class>
+ </renderer>
<renderer>
<component-family>javax.faces.Output</component-family>
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_fishey_commandlink_attributes.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_fishey_commandlink_attributes.xml?view=auto&rev=464453
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_fishey_commandlink_attributes.xml (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_fishey_commandlink_attributes.xml Mon Oct 16 04:55:58 2006
@@ -0,0 +1,18 @@
+ <attribute>
+ <name>caption</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <name>iconSrc</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.Integer</type>
+ </attribute>
+ <attribute>
+ <name>target</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>java.lang.Integer</type>
+ </attribute>
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_fisheyelist_attributes.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_fisheyelist_attributes.xml?view=diff&rev=464453&r1=464452&r2=464453
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_fisheyelist_attributes.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/html_fisheyelist_attributes.xml Mon Oct 16 04:55:58 2006
@@ -64,4 +64,15 @@
<rtexprvalue>false</rtexprvalue>
<type>java.lang.Integer</type>
</attribute>
-
\ No newline at end of file
+ <attribute>
+ <name>value</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <name>var</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ </attribute>
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld?view=diff&rev=464453&r1=464452&r2=464453
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld Mon Oct 16 04:55:58 2006
@@ -123,6 +123,7 @@
<!ENTITY table_suggest_ajax_attributes SYSTEM "entities/table_suggest_ajax_attributes.xml">
<!ENTITY suggest_ajax_attributes SYSTEM "entities/suggest_ajax_attributes.xml">
<!ENTITY html_fisheye_list_attributes SYSTEM "entities/html_fisheyelist_attributes.xml">
+<!ENTITY html_fishey_commandlink_attributes SYSTEM "entities/html_fishey_commandlink_attributes.xml">
<!ENTITY html_timed_notifier_attributes SYSTEM "entities/html_timed_notifier_attributes.xml">
<!ENTITY start_conversation_attributes SYSTEM "entities/start_conversation_attributes.xml">
<!ENTITY end_conversation_attributes SYSTEM "entities/end_conversation_attributes.xml">
@@ -1030,7 +1031,7 @@
</attribute>
</tag>
- <!-- fishEyeList -->
+ <!-- fishEye -->
<tag>
<name>fishEyeNavigationMenu</name>
<tag-class>org.apache.myfaces.custom.fisheye.HtmlFishEyeNavigationMenuTag</tag-class>
@@ -1042,6 +1043,18 @@
&html_fisheye_list_attributes;
</tag>
+ <tag>
+ <name>fishEyeCommandLink</name>
+ <tag-class>org.apache.myfaces.custom.fisheye.FishEyeCommandLinkTag</tag-class>
+ <body-content>JSP</body-content>
+ <display-name>fishEye commandLink component</display-name>
+ <description>CommandLink component that can be used in nodeStamp facet</description>
+ &faces_id_optional_attribute;
+ &faces_rendered_attribute;
+ &ui_command_attributes;
+
+ &html_fishey_commandlink_attributes;
+ </tag>
<!-- timed notifier -->
<tag>
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/fisheye/FishEyeHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/fisheye/FishEyeHandler.java?view=diff&rev=464453&r1=464452&r2=464453
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/fisheye/FishEyeHandler.java (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/fisheye/FishEyeHandler.java Mon Oct 16 04:55:58 2006
@@ -16,11 +16,15 @@
package org.apache.myfaces.examples.fisheye;
import java.io.Serializable;
+import java.util.*;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
+import javax.faces.component.UIComponent;
import org.apache.myfaces.custom.navmenu.UINavigationMenuItem;
+import org.apache.myfaces.custom.fisheye.FishEyeItem;
+import org.apache.myfaces.custom.fisheye.FishEyeCommandLink;
/**
* Handler for the FishEye example
@@ -31,6 +35,12 @@
public class FishEyeHandler implements Serializable
{
private String _actionName;
+ private static BundleMap _labels;
+ static {
+ _labels = new BundleMap(ResourceBundle.getBundle("org.apache.myfaces.examples.fisheye.labels",
+ Locale.ENGLISH,
+ Thread.currentThread().getContextClassLoader()));
+ }
public FishEyeHandler()
{
@@ -43,9 +53,152 @@
}
public void processAction(ActionEvent event) throws AbortProcessingException
- {
- UINavigationMenuItem comp = (UINavigationMenuItem) event.getComponent();
- this._actionName = comp.getItemLabel() + " item was clicked";
-
+ {
+ UIComponent comp = event.getComponent();
+ String caption;
+ if (comp instanceof FishEyeCommandLink) {
+ caption = ((FishEyeCommandLink) comp).getCaption();
+ } else {
+ // deprecated
+ caption = ((UINavigationMenuItem) comp).getItemLabel();
+ }
+ _actionName = caption + " item was clicked";
+ }
+
+ public List getItems() {
+ List list = new ArrayList();
+ list.add(new FishEyeItem("browser","images/icon_browser.png"));
+ list.add(new FishEyeItem("cal", "images/icon_calendar.png"));
+ list.add(new FishEyeItem("email", "images/icon_email.png"));
+ list.add(new FishEyeItem("texteditor", "images/icon_texteditor.png"));
+ list.add(new FishEyeItem("swupdate", "images/icon_update.png"));
+ list.add(new FishEyeItem("users", "images/icon_users.png"));
+ return list;
+ }
+
+ public Map getLabels() {
+ return _labels;
+ }
+
+ private static class BundleMap implements Map
+ {
+ private ResourceBundle _bundle;
+ private List _values;
+
+ public BundleMap(ResourceBundle bundle)
+ {
+ _bundle = bundle;
+ }
+
+ //Optimized methods
+
+ public Object get(Object key)
+ {
+ try {
+ return _bundle.getObject(key.toString());
+ } catch (Exception e) {
+ return "MISSING: " + key + " :MISSING";
+ }
+ }
+
+ public boolean isEmpty()
+ {
+ return !_bundle.getKeys().hasMoreElements();
+ }
+
+ public boolean containsKey(Object key)
+ {
+ try {
+ return _bundle.getObject(key.toString()) != null;
+ } catch (MissingResourceException e) {
+ return false;
+ }
+ }
+
+
+ //Unoptimized methods
+
+ public Collection values()
+ {
+ if (_values == null)
+ {
+ _values = new ArrayList();
+ for (Enumeration enumer = _bundle.getKeys(); enumer.hasMoreElements(); )
+ {
+ String v = _bundle.getString((String)enumer.nextElement());
+ _values.add(v);
+ }
+ }
+ return _values;
+ }
+
+ public int size()
+ {
+ return values().size();
+ }
+
+ public boolean containsValue(Object value)
+ {
+ return values().contains(value);
+ }
+
+ public Set entrySet()
+ {
+ Set set = new HashSet();
+ for (Enumeration enumer = _bundle.getKeys(); enumer.hasMoreElements(); )
+ {
+ final String k = (String)enumer.nextElement();
+ set.add(new Map.Entry() {
+ public Object getKey()
+ {
+ return k;
+ }
+
+ public Object getValue()
+ {
+ return _bundle.getObject(k);
+ }
+
+ public Object setValue(Object value)
+ {
+ throw new UnsupportedOperationException(this.getClass().getName() + " UnsupportedOperationException");
+ }
+ });
+ }
+ return set;
+ }
+
+ public Set keySet()
+ {
+ Set set = new HashSet();
+ for (Enumeration enumer = _bundle.getKeys(); enumer.hasMoreElements(); )
+ {
+ set.add(enumer.nextElement());
+ }
+ return set;
+ }
+
+
+ //Unsupported methods
+
+ public Object remove(Object key)
+ {
+ throw new UnsupportedOperationException(this.getClass().getName() + " UnsupportedOperationException");
+ }
+
+ public void putAll(Map t)
+ {
+ throw new UnsupportedOperationException(this.getClass().getName() + " UnsupportedOperationException");
+ }
+
+ public Object put(Object key, Object value)
+ {
+ throw new UnsupportedOperationException(this.getClass().getName() + " UnsupportedOperationException");
+ }
+
+ public void clear()
+ {
+ throw new UnsupportedOperationException(this.getClass().getName() + " UnsupportedOperationException");
+ }
}
-}
\ No newline at end of file
+}
Added: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/fisheye/labels.properties
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/fisheye/labels.properties?view=auto&rev=464453
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/fisheye/labels.properties (added)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/fisheye/labels.properties Mon Oct 16 04:55:58 2006
@@ -0,0 +1,6 @@
+browser=Web Browser
+cal=Calendar
+email= Email
+texteditor=TextEditor
+swupdate=Software Update
+users=Users
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/fisheye.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/fisheye.jsp?view=diff&rev=464453&r1=464452&r2=464453
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/fisheye.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/fisheye.jsp Mon Oct 16 04:55:58 2006
@@ -36,7 +36,7 @@
.outerbar {
background-color: #666;
text-align: center;
- position: absolute;
+ position: absolute;
left: 0px;
top: 0px;
width: 100%;
@@ -56,32 +56,16 @@
</head>
<body>
<f:view>
- <h:form>
+ <f:loadBundle basename="org.apache.myfaces.examples.fisheye.labels" var="label"/>
+ <h:form>
<t:div styleClass="outerbar">
- <s:fishEyeNavigationMenu itemWidth="50" itemHeight="50" itemMaxWidth="200"
- itemMaxHeight="200" orientation="horizontal" effectUnits="2"
- itemPadding="10" attachEdge="top" labelEdge="bottom" visibleWindow="3" >
-
- <t:navigationMenuItem icon="images/icon_browser.png"
- itemLabel="Web Browser"
- actionListener="#{fisheye.processAction}" />
- <t:navigationMenuItem icon="images/icon_calendar.png"
- itemLabel="Calendar"
- actionListener="#{fisheye.processAction}" />
- <t:navigationMenuItem icon="images/icon_email.png" itemLabel="Email"
- actionListener="#{fisheye.processAction}" />
- <t:navigationMenuItem icon="images/icon_texteditor.png"
- itemLabel="Text Editor"
- actionListener="#{fisheye.processAction}" />
- <t:navigationMenuItem icon="images/icon_update.png"
- itemLabel="Software Update"
- actionListener="#{fisheye.processAction}" />
- <t:navigationMenuItem icon="images/icon_users.png" itemLabel="Users"
- actionListener="#{fisheye.processAction}" />
-
- </s:fishEyeNavigationMenu>
+ <s:fishEyeNavigationMenu itemWidth="50" itemHeight="50" itemMaxWidth="80"
+ itemMaxHeight="80" orientation="horizontal" effectUnits="2" var="item" value="#{fisheye.items}"
+ itemPadding="10" attachEdge="top" labelEdge="bottom" visibleWindow="3" >
+ <s:fishEyeCommandLink caption="#{fisheye.labels[item.caption]}" iconSrc="#{item.iconSrc}" target="#{item.target}"
+ actionListener="#{fisheye.processAction}"/>
+ </s:fishEyeNavigationMenu>
</t:div>
-
<t:div styleClass="page">
<t:outputText value="#{fisheye.actionName}" />
<%@include file="../inc/page_footer.jsp"%>
@@ -89,4 +73,4 @@
</h:form>
</f:view>
</body>
-</html>
+</html>
\ No newline at end of file