JBoss Rich Faces SVN: r20262 - in trunk/ui: iteration/ui/src/main/java/org/richfaces/renderkit and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-01 11:30:13 -0500 (Wed, 01 Dec 2010)
New Revision: 20262
Modified:
trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
Log:
RF-9680:
- Added children() method to TreeDataModel & tuples
- Related refactorings for UIDataAdaptor
- Redesign API for walking over model
- Renderer updated for new API
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-12-01 16:27:24 UTC (rev 20261)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-12-01 16:30:13 UTC (rev 20262)
@@ -246,6 +246,10 @@
private Object rowKey = null;
+ private boolean rowDataIsSet = false;
+
+ private Object rowData;
+
private String clientId;
private Object originalVarValue;
@@ -367,6 +371,34 @@
return rowKey;
}
+ private void setRowKeyAndData(FacesContext facesContext, Object rowKey, boolean localRowDataAvailable, Object localRowData) {
+ this.saveChildState(facesContext);
+
+ this.rowKey = rowKey;
+
+ if (localRowDataAvailable) {
+ this.rowData = localRowData;
+ this.rowDataIsSet = (rowKey != null);
+ } else {
+ this.rowData = null;
+ this.rowDataIsSet = false;
+
+ getExtendedDataModel().setRowKey(rowKey);
+ }
+
+ this.clientId = null;
+
+ boolean rowSelected = (rowKey != null) && isRowAvailable();
+
+ setupVariable(facesContext, rowSelected);
+
+ this.restoreChildState(facesContext);
+ }
+
+ protected void setRowKeyAndData(FacesContext facesContext, Object rowKey, Object localRowData) {
+ setRowKeyAndData(facesContext, rowKey, true, localRowData);
+ }
+
/**
* Setup current row by key. Perform same functionality as
* {@link javax.faces.component.UIData#setRowIndex(int)}, but for key object - it may be not only
@@ -615,11 +647,15 @@
}
public Object getRowData() {
+ if (rowDataIsSet) {
+ return rowData;
+ }
+
return getExtendedDataModel().getRowData();
}
public boolean isRowAvailable() {
- return getExtendedDataModel().isRowAvailable();
+ return rowDataIsSet || getExtendedDataModel().isRowAvailable();
}
/**
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-12-01 16:27:24 UTC (rev 20261)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-12-01 16:30:13 UTC (rev 20262)
@@ -162,7 +162,8 @@
writeTreeNodeEndElement();
} catch (IOException e) {
- throw new FacesException(e.getMessage(), e);
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
}
15 years, 1 month
JBoss Rich Faces SVN: r20261 - in trunk/ui: iteration/ui/src/main/java/org/richfaces/component and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-01 11:27:24 -0500 (Wed, 01 Dec 2010)
New Revision: 20261
Added:
trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java.orig
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java.orig
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java.orig
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java.orig
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java.orig
Log:
RF-9680
Added: trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java.orig
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java.orig (rev 0)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java.orig 2010-12-01 16:27:24 UTC (rev 20261)
@@ -0,0 +1,1523 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.component;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.ContextCallback;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.PartialStateHolder;
+import javax.faces.component.StateHelper;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIForm;
+import javax.faces.component.UINamingContainer;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.UniqueIdVendor;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.component.visit.VisitResult;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ComponentSystemEvent;
+import javax.faces.event.ComponentSystemEventListener;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.ListenerFor;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PostValidateEvent;
+import javax.faces.event.PreRenderComponentEvent;
+import javax.faces.event.PreValidateEvent;
+import javax.faces.render.Renderer;
+
+import org.ajax4jsf.component.IterationStateHolder;
+import org.ajax4jsf.model.DataComponentState;
+import org.ajax4jsf.model.DataVisitResult;
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SerializableDataModel;
+import org.richfaces.context.ExtendedVisitContext;
+import org.richfaces.log.Logger;
+import org.richfaces.log.RichfacesLogger;
+
+/**
+ * Base class for iterable components, like dataTable, Tomahawk dataList, Facelets repeat, tree etc., with support for
+ * partial rendering on AJAX responces for one or more selected iterations.
+ *
+ * @author shura
+ */
+@ListenerFor(systemEventClass = PreRenderComponentEvent.class)
+public abstract class UIDataAdaptor extends UIComponentBase implements NamingContainer,
+ UniqueIdVendor, IterationStateHolder, ComponentSystemEventListener {
+
+ /**
+ * <p>The standard component family for this component.</p>
+ */
+ public static final String COMPONENT_FAMILY = "org.richfaces.Data";
+
+ /**
+ * <p>The standard component type for this component.</p>
+ */
+ public static final String COMPONENT_TYPE = "org.richfaces.Data";
+
+ private static final class IterationState implements Serializable {
+
+ private static final long serialVersionUID = -3502645160277416066L;
+
+ private DataComponentState componentState;
+
+ private Object savedComponentState;
+
+ private boolean componentStateIsStateHolder;
+
+ private ExtendedDataModel<?> dataModel;
+
+ public IterationState() {
+ super();
+ }
+
+ public IterationState(DataComponentState componentState, ExtendedDataModel<?> dataModel) {
+ super();
+ this.componentState = componentState;
+ this.dataModel = dataModel;
+ }
+
+ public ExtendedDataModel<?> getDataModel() {
+ return dataModel;
+ }
+
+ public DataComponentState getComponentState() {
+ return componentState;
+ }
+
+ /**
+ * @param uiDataAdaptor
+ */
+ public void restoreComponentState(UIDataAdaptor uiDataAdaptor) {
+ if (savedComponentState != null && componentStateIsStateHolder) {
+ componentState = uiDataAdaptor.createComponentState();
+ ((StateHolder) componentState).restoreState(FacesContext.getCurrentInstance(), savedComponentState);
+ savedComponentState = null;
+ }
+ }
+
+ final Object saveState() {
+ boolean localComponentStateIsHolder = false;
+ Object localSavedComponentState = null;
+
+ if (componentState != null) {
+ if (componentState instanceof StateHolder) {
+ localComponentStateIsHolder = true;
+
+ StateHolder stateHolder = (StateHolder) componentState;
+ if (!stateHolder.isTransient()) {
+ localSavedComponentState = stateHolder.saveState(FacesContext.getCurrentInstance());
+ }
+ } else {
+ if (componentState instanceof Serializable) {
+ localSavedComponentState = componentState;
+ }
+ }
+ }
+
+ Object savedSerializableModel = null;
+
+ if (componentState != null && dataModel != null) {
+ // TODO handle model serialization - "execute" model
+ savedSerializableModel = dataModel.getSerializableModel(componentState.getRange());
+ }
+
+ if (localSavedComponentState != null || savedSerializableModel != null) {
+ return new Object[] {
+ localComponentStateIsHolder,
+ localSavedComponentState,
+ savedSerializableModel
+ };
+ } else {
+ return null;
+ }
+ }
+
+ final void restoreState(Object stateObject) {
+ if (stateObject != null) {
+ Object[] state = (Object[]) stateObject;
+ componentStateIsStateHolder = Boolean.TRUE.equals(state[0]);
+ Object localSavedComponentState = state[1];
+
+ if (componentStateIsStateHolder) {
+ savedComponentState = localSavedComponentState;
+ } else {
+ componentState = (DataComponentState) localSavedComponentState;
+ }
+
+ dataModel = (ExtendedDataModel<?>) state[2];
+ }
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out)
+ throws IOException {
+
+ out.writeObject(saveState());
+ }
+
+ private void readObject(java.io.ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+
+ restoreState(in.readObject());
+ }
+ }
+
+ private static final VisitCallback STUB_CALLBACK = new VisitCallback() {
+
+ public VisitResult visit(VisitContext context, UIComponent target) {
+ return VisitResult.ACCEPT;
+ }
+ };
+
+ private static final Logger LOG = RichfacesLogger.COMPONENTS.getLogger();
+
+ /**
+ * Visitor for process decode on children components.
+ */
+ protected ComponentVisitor decodeVisitor = new ComponentVisitor() {
+ @Override
+ public void processComponent(FacesContext context, UIComponent c, Object argument) {
+ c.processDecodes(context);
+ }
+ };
+
+ /**
+ * Visitor for process validation phase
+ */
+ protected ComponentVisitor validateVisitor = new ComponentVisitor() {
+ @Override
+ public void processComponent(FacesContext context, UIComponent c, Object argument) {
+ c.processValidators(context);
+ }
+ };
+
+ /**
+ * Visitor for process update model phase.
+ */
+ protected ComponentVisitor updateVisitor = new ComponentVisitor() {
+ @Override
+ public void processComponent(FacesContext context, UIComponent c, Object argument) {
+ c.processUpdates(context);
+ }
+ };
+
+ //TODO nick - PSH support?
+ private DataComponentState componentState = null;
+ private ExtendedDataModel<?> extendedDataModel = null;
+
+ private Object rowKey = null;
+
+ private boolean rowDataIsSet = false;
+
+ private Object rowData;
+
+ private String clientId;
+
+ private Object originalVarValue;
+
+ private Converter rowKeyConverter;
+
+ /**
+ * @author Nick Belaevski
+ *
+ */
+ private final class DataVisitorForVisitTree implements DataVisitor {
+ /**
+ *
+ */
+ private final VisitCallback callback;
+ /**
+ *
+ */
+ private final VisitContext visitContext;
+ /**
+ *
+ */
+ private boolean visitResult;
+
+ /**
+ * @param callback
+ * @param visitContext
+ */
+ private DataVisitorForVisitTree(VisitCallback callback, VisitContext visitContext) {
+ this.callback = callback;
+ this.visitContext = visitContext;
+ }
+
+ public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
+ setRowKey(context, rowKey);
+
+ if (isRowAvailable()) {
+ VisitResult result = VisitResult.ACCEPT;
+
+ if (visitContext instanceof ExtendedVisitContext) {
+ result = visitContext.invokeVisitCallback(UIDataAdaptor.this, callback);
+ if (VisitResult.COMPLETE.equals(result)) {
+ visitResult = true;
+
+ return DataVisitResult.STOP;
+ }
+
+ if (result == VisitResult.ACCEPT) {
+ result = visitDataChildrenMetaComponents((ExtendedVisitContext) visitContext, callback);
+ if (VisitResult.COMPLETE.equals(result)) {
+ visitResult = true;
+
+ return DataVisitResult.STOP;
+ }
+ }
+ }
+
+ if (VisitResult.ACCEPT.equals(result)) {
+ Iterator<UIComponent> dataChildrenItr = dataChildren();
+
+ while (dataChildrenItr.hasNext()) {
+ UIComponent dataChild = dataChildrenItr.next();
+
+ if (dataChild.visitTree(visitContext, callback)) {
+ visitResult = true;
+
+ return DataVisitResult.STOP;
+ }
+ }
+ }
+ }
+
+ return DataVisitResult.CONTINUE;
+ }
+
+ public boolean getVisitResult() {
+ return visitResult;
+ }
+ }
+
+ private enum PropertyKeys {
+ lastId, var, rowKeyVar, stateVar, childState, rowKeyConverter, rowKeyConverterSet, keepSaved
+ }
+
+ public UIDataAdaptor() {
+ super();
+ }
+
+ protected Map<String, Object> getVariablesMap(FacesContext facesContext) {
+ return facesContext.getExternalContext().getRequestMap();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UniqueIdVendor#createUniqueId(javax.faces.context.FacesContext, java.lang.String)
+ */
+ public String createUniqueId(FacesContext context, String seed) {
+ Integer i = (Integer) getStateHelper().get(PropertyKeys.lastId);
+ int lastId = (i != null) ? i : 0;
+
+ getStateHelper().put(PropertyKeys.lastId, ++lastId);
+
+ return UIViewRoot.UNIQUE_ID_PREFIX + ((seed == null) ? lastId : seed);
+ }
+
+ /**
+ * @return the rowKey
+ */
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ private void setRowKeyAndData(FacesContext facesContext, Object rowKey, boolean localRowDataAvailable, Object localRowData) {
+ this.saveChildState(facesContext);
+
+ this.rowKey = rowKey;
+
+ if (localRowDataAvailable) {
+ this.rowData = localRowData;
+ this.rowDataIsSet = (rowKey != null);
+ } else {
+ this.rowData = null;
+ this.rowDataIsSet = false;
+
+ getExtendedDataModel().setRowKey(rowKey);
+ }
+
+ this.clientId = null;
+
+ boolean rowSelected = (rowKey != null) && isRowAvailable();
+
+ setupVariable(facesContext, rowSelected);
+
+ this.restoreChildState(facesContext);
+ }
+
+ protected void setRowKeyAndData(FacesContext facesContext, Object rowKey, Object localRowData) {
+ setRowKeyAndData(facesContext, rowKey, true, localRowData);
+ }
+
+ /**
+ * Setup current row by key. Perform same functionality as
+ * {@link javax.faces.component.UIData#setRowIndex(int)}, but for key object - it may be not only
+ * row number in sequence data, but, for example - path to current node in
+ * tree.
+ *
+ * @param faces -
+ * current FacesContext
+ * @param key new key value.
+ */
+ public void setRowKey(FacesContext facesContext, Object rowKey) {
+<<<<<<< HEAD
+ this.saveChildState(facesContext);
+
+ this.rowKey = rowKey;
+
+ getExtendedDataModel().setRowKey(rowKey);
+
+ this.clientId = null;
+
+ boolean rowSelected = (rowKey != null) && isRowAvailable();
+
+ setupVariable(facesContext, rowSelected);
+
+ this.restoreChildState(facesContext);
+=======
+ setRowKeyAndData(facesContext, rowKey, false, null);
+>>>>>>> RF-9680:
+ }
+
+ /**
+ * Save values of {@link EditableValueHolder} fields before change current
+ * row.
+ *
+ * @param faces
+ */
+ protected void saveChildState(FacesContext facesContext) {
+ Iterator<UIComponent> itr = dataChildren();
+
+ while (itr.hasNext()) {
+ this.saveChildState(facesContext, (UIComponent) itr.next());
+ }
+ }
+
+ /**
+ * @param facesContext
+ * @param next
+ * @param childState
+ */
+ protected void saveChildState(FacesContext facesContext, UIComponent component) {
+
+ // TODO - is it right?
+ if (component.isTransient()) {
+ return;
+ }
+
+ SavedState state = null;
+
+ if (component instanceof IterationStateHolder) {
+ IterationStateHolder ish = (IterationStateHolder) component;
+
+ state = new SavedState(ish);
+ } else if (component instanceof EditableValueHolder) {
+ EditableValueHolder evh = (EditableValueHolder) component;
+
+ state = new SavedState(evh);
+ } else if (component instanceof UIForm) {
+ UIForm form = (UIForm) component;
+
+ state = new SavedState(form);
+ }
+
+ if (state != null) {
+
+ // TODO - use local map - children save their state themselves using visitors
+ getStateHelper().put(PropertyKeys.childState, component.getClientId(facesContext), state);
+ }
+
+ if (component.getChildCount() > 0) {
+ for (UIComponent child : component.getChildren()) {
+ saveChildState(facesContext, child);
+ }
+ }
+
+ if (component.getFacetCount() > 0) {
+ for (UIComponent facet : component.getFacets().values()) {
+ saveChildState(facesContext, facet);
+ }
+ }
+ }
+
+ protected Iterator<UIComponent> dataChildren() {
+ if (getChildCount() > 0) {
+ return getChildren().iterator();
+ } else {
+ return Collections.<UIComponent>emptyList().iterator();
+ }
+ }
+
+ protected Iterator<UIComponent> fixedChildren() {
+ if (getFacetCount() > 0) {
+ return getFacets().values().iterator();
+ } else {
+ return Collections.<UIComponent>emptyList().iterator();
+ }
+ }
+
+ /**
+ * @param facesContext
+ */
+ protected void restoreChildState(FacesContext facesContext) {
+ Iterator<UIComponent> itr = dataChildren();
+
+ while (itr.hasNext()) {
+ this.restoreChildState(facesContext, (UIComponent) itr.next());
+ }
+ }
+
+ /**
+ * Restore values of {@link EditableValueHolder} fields after change current
+ * row.
+ *
+ * @param facesContext
+ * @param next
+ * @param childState
+ */
+ protected void restoreChildState(FacesContext facesContext, UIComponent component) {
+ String id = component.getId();
+
+ component.setId(id); // Forces client id to be reset
+
+ SavedState savedState = null;
+ @SuppressWarnings("unchecked")
+ Map<String, SavedState> savedStatesMap = (Map<String, SavedState>) getStateHelper()
+ .get(PropertyKeys.childState);
+
+ if (savedStatesMap != null) {
+ savedState = savedStatesMap.get(component.getClientId(facesContext));
+ }
+
+ if (savedState == null) {
+ savedState = SavedState.EMPTY;
+ }
+
+ if (component instanceof IterationStateHolder) {
+ IterationStateHolder ish = (IterationStateHolder) component;
+
+ savedState.apply(ish);
+ } else if (component instanceof EditableValueHolder) {
+ EditableValueHolder evh = (EditableValueHolder) component;
+
+ savedState.apply(evh);
+ } else if (component instanceof UIForm) {
+ UIForm form = (UIForm) component;
+
+ savedState.apply(form);
+ }
+
+ if (component.getChildCount() > 0) {
+ for (UIComponent child : component.getChildren()) {
+ restoreChildState(facesContext, child);
+ }
+ }
+
+ if (component.getFacetCount() > 0) {
+ for (UIComponent facet : component.getFacets().values()) {
+ restoreChildState(facesContext, facet);
+ }
+ }
+ }
+
+ public void setRowKey(Object rowKey) {
+ setRowKey(getFacesContext(), rowKey);
+ }
+
+ protected FacesEvent wrapEvent(FacesEvent event) {
+ return new RowKeyContextEventWrapper(this, event, getRowKey());
+ }
+
+ @Override
+ public void queueEvent(FacesEvent event) {
+ super.queueEvent(wrapEvent(event));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
+ */
+ @Override
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ if (event instanceof RowKeyContextEventWrapper) {
+ RowKeyContextEventWrapper eventWrapper = (RowKeyContextEventWrapper) event;
+
+ eventWrapper.broadcast(getFacesContext());
+ } else {
+ super.broadcast(event);
+ }
+ }
+
+ /**
+ * @return the extendedDataModel
+ */
+ protected ExtendedDataModel<?> getExtendedDataModel() {
+ if (extendedDataModel == null) {
+ extendedDataModel = createExtendedDataModel();
+ }
+
+ return extendedDataModel;
+ }
+
+ /**
+ * @return
+ */
+ protected abstract ExtendedDataModel<?> createExtendedDataModel();
+
+ /**
+ * @param extendedDataModel the extendedDataModel to set
+ */
+ protected void setExtendedDataModel(ExtendedDataModel<?> extendedDataModel) {
+ this.extendedDataModel = extendedDataModel;
+ }
+
+ public String getVar() {
+ return (String) getStateHelper().get(PropertyKeys.var);
+ }
+
+ public void setVar(String var) {
+ getStateHelper().put(PropertyKeys.var, var);
+ }
+
+ public String getRowKeyVar() {
+ return (String) getStateHelper().get(PropertyKeys.rowKeyVar);
+ }
+
+ public void setRowKeyVar(String rowKeyVar) {
+ getStateHelper().put(PropertyKeys.rowKeyVar, rowKeyVar);
+ }
+
+ public String getStateVar() {
+ return (String) getStateHelper().get(PropertyKeys.stateVar);
+ }
+
+ public void setStateVar(String stateVar) {
+ getStateHelper().put(PropertyKeys.stateVar, stateVar);
+ }
+
+ //XXX - review and probably remove - useful method, should be left
+ public int getRowCount() {
+ return getExtendedDataModel().getRowCount();
+ }
+
+ public Object getRowData() {
+ if (rowDataIsSet) {
+ return rowData;
+ }
+
+ return getExtendedDataModel().getRowData();
+ }
+
+ public boolean isRowAvailable() {
+ return rowDataIsSet || getExtendedDataModel().isRowAvailable();
+ }
+
+ /**
+ * Boolean attribute that defines whether this iteration component will reset saved children's state
+ * before rendering. By default state is reset if there are no faces messages with severity error or higher.
+ * @return
+ */
+ public boolean isKeepSaved() {
+ Object value = getStateHelper().eval(PropertyKeys.keepSaved);
+
+ if (value == null) {
+ return keepSaved(getFacesContext());
+ } else {
+ return Boolean.valueOf(value.toString());
+ }
+ }
+
+ public void setKeepSaved(boolean keepSaved) {
+ getStateHelper().put(PropertyKeys.keepSaved, keepSaved);
+ }
+
+ /**
+ * Setup EL variable for different iteration. Value of row data and
+ * component state will be put into request scope attributes with names
+ * given by "var" and "varState" bean properties.
+ * <p/>
+ * Changed: does not check for row availability now
+ *
+ * @param faces current faces context
+ * @param localModel
+ * @param rowSelected
+ */
+ protected void setupVariable(FacesContext faces, boolean rowSelected) {
+ Map<String, Object> attrs = getVariablesMap(faces);
+
+ if (rowSelected) {
+
+ // Current row data.
+ setupVariable(getVar(), attrs, getRowData());
+
+ // Component state variable.
+ setupVariable(getStateVar(), attrs, getComponentState());
+
+ // Row key Data variable.
+ setupVariable(getRowKeyVar(), attrs, getRowKey());
+ } else {
+ removeVariable(getVar(), attrs);
+ removeVariable(getStateVar(), attrs);
+ removeVariable(getRowKeyVar(), attrs);
+ }
+ }
+
+ /**
+ * @return
+ */
+ public DataComponentState getComponentState() {
+ if (componentState != null) {
+ return componentState;
+ }
+
+ ValueExpression componentStateExpression = getValueExpression("componentState");
+
+ if (componentStateExpression != null) {
+ componentState = (DataComponentState) componentStateExpression.getValue(getFacesContext().getELContext());
+ }
+
+ if (componentState == null) {
+ componentState = createComponentState();
+
+ if ((componentStateExpression != null)
+ && !componentStateExpression.isReadOnly(getFacesContext().getELContext())) {
+ componentStateExpression.setValue(getFacesContext().getELContext(), componentState);
+ }
+ }
+
+ return componentState;
+ }
+
+ protected abstract DataComponentState createComponentState();
+
+ /**
+ * @param var
+ * @param attrs
+ * @param rowData
+ */
+ private void setupVariable(String var, Map<String, Object> attrs, Object rowData) {
+ if (var != null) {
+ attrs.put(var, rowData);
+ }
+ }
+
+ /**
+ * @param var
+ * @param attrs
+ * @param rowData
+ */
+ private void removeVariable(String var, Map<String, Object> attrs) {
+ if (var != null) {
+ attrs.remove(var);
+ }
+ }
+
+ public Converter getRowKeyConverter() {
+ if (this.rowKeyConverter != null) {
+ return this.rowKeyConverter;
+ }
+
+ return (Converter) getStateHelper().eval(PropertyKeys.rowKeyConverter);
+ }
+
+ public void setRowKeyConverter(Converter converter) {
+ StateHelper stateHelper = getStateHelper();
+ if (initialStateMarked()) {
+ stateHelper.put(PropertyKeys.rowKeyConverterSet, Boolean.TRUE);
+ }
+
+ this.rowKeyConverter = converter;
+ }
+
+ private boolean isSetRowKeyConverter() {
+ Boolean value = (Boolean) getStateHelper().get(PropertyKeys.rowKeyConverterSet);
+ return Boolean.TRUE.equals(value);
+ }
+
+ @Override
+ public String getClientId(FacesContext facesContext) {
+ if (facesContext == null) {
+ throw new NullPointerException("context");
+ }
+
+ if (null == clientId) {
+ StringBuilder id = new StringBuilder(super.getClientId(facesContext));
+ Object rowKey = getRowKey();
+
+ if (rowKey != null) {
+
+ // Use converter to get String representation ot the row key.
+ Converter rowKeyConverter = getRowKeyConverter();
+
+ if (null == rowKeyConverter) {
+
+ // Create default converter for a row key.
+ rowKeyConverter = facesContext.getApplication().createConverter(rowKey.getClass());
+
+ // Store converter for a invokeOnComponents call.
+ if (null != rowKeyConverter) {
+ // TODO - review
+ setRowKeyConverter(rowKeyConverter);
+ }
+ }
+
+ String rowKeyString;
+
+ if (null != rowKeyConverter) {
+
+ // Temporary set clientId, to avoid infinite calls from converter.
+ clientId = id.toString();
+ rowKeyString = rowKeyConverter.getAsString(facesContext, this, rowKey);
+ } else {
+ rowKeyString = rowKey.toString();
+ }
+
+ id.append(UINamingContainer.getSeparatorChar(facesContext)).append(rowKeyString);
+ }
+
+ Renderer renderer = getRenderer(facesContext);
+
+ if (null != renderer) {
+ clientId = renderer.convertClientId(facesContext, id.toString());
+ } else {
+ clientId = id.toString();
+ }
+ }
+
+ return clientId;
+ }
+
+ public String getBaseClientId(FacesContext context) {
+ return super.getClientId(context);
+ }
+
+ /**
+ * Save current state of data variable.
+ *
+ * @param faces current faces context
+ */
+
+ // TODO move into walk() method body
+ public void captureOrigValue(FacesContext faces) {
+ String var = getVar();
+
+ if (var != null) {
+ Map<String, Object> attrs = getVariablesMap(faces);
+
+ this.originalVarValue = attrs.get(var);
+ }
+
+ // TODO add support for another variables
+ }
+
+ /**
+ * Restore value of data variable after processing phase.
+ *
+ * @param faces current faces context
+ */
+ public void restoreOrigValue(FacesContext faces) {
+ String var = getVar();
+
+ if (var != null) {
+ Map<String, Object> attrs = getVariablesMap(faces);
+
+ if (this.originalVarValue != null) {
+ attrs.put(var, this.originalVarValue);
+ } else {
+ attrs.remove(var);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UIComponent#setValueExpression(java.lang.String, javax.el.ValueExpression)
+ */
+ @Override
+ public void setValueExpression(String name, ValueExpression binding) {
+ if ("var".equals(name) || "rowKeyVar".equals(name) || "stateVar".equals(name)) {
+ throw new IllegalArgumentException(MessageFormat.format("{0} cannot be EL-expression", name));
+ }
+
+ super.setValueExpression(name, binding);
+ }
+
+ /**
+ * Check for validation errors on children components. If true, saved values
+ * must be keep on render phase
+ *
+ * @param context
+ * @return
+ */
+ protected boolean keepSaved(FacesContext context) {
+
+ // For an any validation errors, children components state should be preserved
+ FacesMessage.Severity sev = context.getMaximumSeverity();
+
+ return (sev != null) && (FacesMessage.SEVERITY_ERROR.compareTo(sev) >= 0);
+ }
+
+ /**
+ * Perform iteration on all children components and all data rows with given
+ * visitor.
+ *
+ * @param faces
+ * @param visitor
+ */
+ protected void iterate(FacesContext faces, ComponentVisitor visitor) {
+
+ // stop if not rendered
+ if (!this.isRendered()) {
+ return;
+ }
+
+ // reset rowIndex
+ this.captureOrigValue(faces);
+ this.setRowKey(faces, null);
+
+ try {
+ Iterator<UIComponent> fixedChildren = fixedChildren();
+
+ while (fixedChildren.hasNext()) {
+ UIComponent component = fixedChildren.next();
+
+ visitor.processComponent(faces, component, null);
+ }
+
+ walk(faces, visitor, null);
+ } catch (Exception e) {
+ throw new FacesException(e);
+ } finally {
+ this.setRowKey(faces, null);
+ this.restoreOrigValue(faces);
+ }
+ }
+
+ /**
+ * Walk ( visit ) this component on all data-aware children for each row.
+ *
+ * @param faces
+ * @param visitor
+ */
+ public void walk(FacesContext faces, DataVisitor visitor, Object argument) {
+ Object key = getRowKey();
+ captureOrigValue(faces);
+
+ Range range = null;
+ DataComponentState componentState = getComponentState();
+
+ if (componentState != null) {
+ range = componentState.getRange();
+ }
+
+ getExtendedDataModel().walk(faces, visitor, range, argument);
+
+ setRowKey(faces, key);
+ restoreOrigValue(faces);
+ }
+
+ public void processDecodes(FacesContext faces) {
+ if (!this.isRendered()) {
+ return;
+ }
+
+ pushComponentToEL(faces, this);
+ preDecode(faces);
+ this.iterate(faces, decodeVisitor);
+ this.decode(faces);
+ popComponentFromEL(faces);
+ }
+
+ public void processValidators(FacesContext faces) {
+ if (!this.isRendered()) {
+ return;
+ }
+
+ pushComponentToEL(faces, this);
+ Application app = faces.getApplication();
+ app.publishEvent(faces, PreValidateEvent.class, this);
+ preValidate(faces);
+ this.iterate(faces, validateVisitor);
+ app.publishEvent(faces, PostValidateEvent.class, this);
+ popComponentFromEL(faces);
+ }
+
+ public void processUpdates(FacesContext faces) {
+ if (!this.isRendered()) {
+ return;
+ }
+
+ pushComponentToEL(faces, this);
+ preUpdate(faces);
+ this.iterate(faces, updateVisitor);
+
+ ExtendedDataModel<?> dataModel = getExtendedDataModel();
+
+ // If no validation errors, update values for serializable model,
+ // restored from view.
+ if ((dataModel instanceof SerializableDataModel) && (!isKeepSaved())) {
+ SerializableDataModel serializableModel = (SerializableDataModel) dataModel;
+
+ serializableModel.update();
+ }
+
+ doUpdate();
+
+ popComponentFromEL(faces);
+ }
+
+ protected void doUpdate() {
+
+ }
+
+ @Override
+ public void setId(String id) {
+ super.setId(id);
+ this.clientId = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.ajax4jsf.component.IterationStateHolder#getIterationState()
+ */
+ public Object getIterationState() {
+ assert rowKey == null;
+
+ return new IterationState(this.componentState, this.extendedDataModel);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.component.IterationStateHolder#setIterationState(java.lang.Object)
+ */
+ public void setIterationState(Object stateObject) {
+ assert rowKey == null;
+
+ // TODO - ?
+ // restoreChildState(getFacesContext());
+ if (stateObject != null) {
+ IterationState iterationState = (IterationState) stateObject;
+ iterationState.restoreComponentState(this);
+
+ this.componentState = iterationState.getComponentState();
+ this.extendedDataModel = iterationState.getDataModel();
+ } else {
+ this.componentState = null;
+ this.extendedDataModel = null;
+ }
+ }
+
+ protected void resetDataModel() {
+ this.extendedDataModel = null;
+ }
+
+ protected void resetChildState() {
+ getStateHelper().remove(PropertyKeys.childState);
+ }
+
+ protected void preDecode(FacesContext context) {
+ resetDataModel();
+
+ Object savedChildState = getStateHelper().get(PropertyKeys.childState);
+ // TODO - verify the check for null: savedChildState == null
+ if (savedChildState == null || !isKeepSaved()) {
+ resetChildState();
+ }
+ }
+
+ // TODO - do we need this method?
+ protected void preValidate(FacesContext context) {
+ }
+
+ // TODO - do we need this method?
+ protected void preUpdate(FacesContext context) {
+ }
+
+ protected void preEncodeBegin(FacesContext context) {
+ resetDataModel();
+
+ if (!isKeepSaved()) {
+ //TODO - this also resets state for the nested iteration components - is it correct?
+ resetChildState();
+ }
+ }
+
+ @Override
+ public void markInitialState() {
+ super.markInitialState();
+
+ if (rowKeyConverter instanceof PartialStateHolder) {
+ ((PartialStateHolder) rowKeyConverter).markInitialState();
+ }
+ }
+
+ @Override
+ public void clearInitialState() {
+ super.clearInitialState();
+
+ if (rowKeyConverter instanceof PartialStateHolder) {
+ ((PartialStateHolder) rowKeyConverter).clearInitialState();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UIComponentBase#saveState(javax.faces.context.FacesContext)
+ */
+ @Override
+ public Object saveState(FacesContext context) {
+ Object parentState = super.saveState(context);
+ Object savedComponentState = new IterationState(componentState, extendedDataModel).saveState();
+
+ Object converterState = null;
+ boolean nullDelta = true;
+
+ boolean converterHasPartialState = false;
+
+ if (initialStateMarked()) {
+ if (!isSetRowKeyConverter() && rowKeyConverter != null && rowKeyConverter instanceof PartialStateHolder) {
+ // Delta
+ StateHolder holder = (StateHolder) rowKeyConverter;
+ if (!holder.isTransient()) {
+ Object attachedState = holder.saveState(context);
+ if (attachedState != null) {
+ nullDelta = false;
+ converterState = attachedState;
+ }
+ converterHasPartialState = true;
+ } else {
+ converterState = null;
+ }
+ } else if (isSetRowKeyConverter() || rowKeyConverter != null) {
+ // Full
+ converterState = saveAttachedState(context, rowKeyConverter);
+ nullDelta = false;
+ }
+
+ if (parentState == null && savedComponentState == null && nullDelta) {
+ // No values
+ return null;
+ }
+ } else {
+ converterState = saveAttachedState(context, rowKeyConverter);
+ }
+
+ return new Object[] {
+ parentState,
+ savedComponentState,
+ converterHasPartialState,
+ converterState
+ };
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponentBase#restoreState(javax.faces.context.FacesContext, java.lang.Object)
+ */
+ @Override
+ public void restoreState(FacesContext context, Object stateObject) {
+ if (stateObject == null) {
+ return ;
+ }
+
+ Object[] state = (Object[]) stateObject;
+
+ super.restoreState(context, state[0]);
+
+ if (state[1] != null) {
+ IterationState iterationState = new IterationState();
+ iterationState.restoreState(state[1]);
+ iterationState.restoreComponentState(this);
+
+ // TODO update state model binding
+ componentState = iterationState.getComponentState();
+ extendedDataModel = iterationState.getDataModel();
+ }
+
+ boolean converterHasPartialState = Boolean.TRUE.equals(state[2]);
+ Object savedConverterState = state[3];
+ if (converterHasPartialState) {
+ ((StateHolder) rowKeyConverter).restoreState(context, savedConverterState);
+ } else {
+ rowKeyConverter = (Converter) UIComponentBase.restoreAttachedState(context, savedConverterState);
+ }
+ }
+
+ private boolean matchesBaseId(String clientId, String baseId, char separatorChar) {
+ if (clientId.equals(baseId)) {
+ return true;
+ }
+
+ // if clientId.startsWith(baseId + separatorChar)
+ if (clientId.startsWith(baseId) && (clientId.length() > baseId.length())
+ && (clientId.charAt(baseId.length()) == separatorChar)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback)
+ throws FacesException {
+
+ if ((null == context) || (null == clientId) || (null == callback)) {
+ throw new NullPointerException();
+ }
+
+ String baseId = super.getClientId(context);
+
+ if (!matchesBaseId(clientId, baseId, UINamingContainer.getSeparatorChar(context))) {
+ return false;
+ }
+
+ boolean found = false;
+ Object oldRowKey = getRowKey();
+
+ // TODO - this does not seem right
+ captureOrigValue(context);
+
+ try {
+
+ // TODO - ?
+ // if (null != oldRowKey) {
+ setRowKey(context, null);
+
+ // }
+ if (clientId.equals(baseId)) {
+ callback.invokeContextCallback(context, this);
+ found = true;
+ } else {
+ Iterator<UIComponent> fixedChildrenItr = fixedChildren();
+
+ while (fixedChildrenItr.hasNext() && !found) {
+ UIComponent fixedChild = fixedChildrenItr.next();
+
+ found = fixedChild.invokeOnComponent(context, clientId, callback);
+ }
+ }
+
+ if (!found) {
+ Object newRowKey = null;
+
+ // Call for a child component - try to detect row key
+ // baseId.length() + 1 expression skips SEPARATOR_CHAR
+ //TODO - convertKeyString
+ String rowKeyString = extractKeySegment(context, clientId.substring(baseId.length() + 1));
+
+ if (rowKeyString != null) {
+ Converter keyConverter = getRowKeyConverter();
+
+ if (null != keyConverter) {
+ try {
+ //TODO: review
+ newRowKey = keyConverter.getAsObject(context, this, rowKeyString);
+ } catch (ConverterException e) {
+
+ // TODO: LOG error
+ }
+ }
+ }
+
+ setRowKey(context, newRowKey);
+
+ if (isRowAvailable()) {
+ Iterator<UIComponent> dataChildrenItr = dataChildren();
+
+ while (dataChildrenItr.hasNext() && !found) {
+ UIComponent dataChild = dataChildrenItr.next();
+
+ found = dataChild.invokeOnComponent(context, clientId, callback);
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new FacesException(e);
+ } finally {
+
+ // if (null != oldRowKey) {
+ try {
+ setRowKey(context, oldRowKey);
+ restoreOrigValue(context);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ }
+
+ // }
+ }
+
+ return found;
+ }
+
+ // Tests whether we need to visit our children as part of
+ // a tree visit
+ private boolean doVisitChildren(VisitContext context, boolean visitRows) {
+
+ // Just need to check whether there are any ids under this
+ // subtree. Make sure row index is cleared out since
+ // getSubtreeIdsToVisit() needs our row-less client id.
+
+ // TODO check this
+ if (visitRows) {
+ setRowKey(context.getFacesContext(), null);
+ }
+
+ // TODO optimize for returned IDs
+ Collection<String> idsToVisit = context.getSubtreeIdsToVisit(this);
+
+ assert idsToVisit != null;
+
+ if (idsToVisit == VisitContext.ALL_IDS) {
+ // TODO
+ }
+
+ // All ids or non-empty collection means we need to visit our children.
+ return !idsToVisit.isEmpty();
+ }
+
+ private boolean visitComponents(Iterator<UIComponent> components, VisitContext context, VisitCallback callback) {
+
+ while (components.hasNext()) {
+ UIComponent nextChild = components.next();
+
+ if (nextChild.visitTree(context, callback)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ protected boolean visitFixedChildren(VisitContext visitContext, VisitCallback callback) {
+
+ return visitComponents(fixedChildren(), visitContext, callback);
+ }
+
+ protected VisitResult visitDataChildrenMetaComponents(ExtendedVisitContext extendedVisitContext, VisitCallback callback) {
+ return VisitResult.ACCEPT;
+ }
+
+ protected boolean visitDataChildren(VisitContext visitContext, VisitCallback callback, boolean visitRows) {
+
+ if (visitRows) {
+ FacesContext facesContext = visitContext.getFacesContext();
+
+ DataVisitorForVisitTree dataVisitor = new DataVisitorForVisitTree(callback, visitContext);
+ this.walk(facesContext, dataVisitor, null);
+
+ return dataVisitor.getVisitResult();
+ } else {
+ return visitComponents(dataChildren(), visitContext, callback);
+ }
+ }
+
+ @Override
+ public boolean visitTree(VisitContext visitContext, VisitCallback callback) {
+
+ // First check to see whether we are visitable. If not
+ // short-circuit out of this subtree, though allow the
+ // visit to proceed through to other subtrees.
+ if (!isVisitable(visitContext)) {
+ return false;
+ }
+
+ // Clear out the row index is one is set so that
+ // we start from a clean slate.
+ FacesContext facesContext = visitContext.getFacesContext();
+
+ // NOTE: that the visitRows local will be obsolete once the
+ // appropriate visit hints have been added to the API
+ boolean visitRows = requiresRowIteration(facesContext);
+
+ Object oldRowKey = null;
+ if (visitRows) {
+ captureOrigValue(facesContext);
+ oldRowKey = getRowKey();
+ setRowKey(facesContext, null);
+ }
+
+ // Push ourselves to EL
+ pushComponentToEL(facesContext, null);
+
+ try {
+
+ // Visit ourselves. Note that we delegate to the
+ // VisitContext to actually perform the visit.
+ VisitResult result = visitContext.invokeVisitCallback(this, callback);
+
+ // If the visit is complete, short-circuit out and end the visit
+ if (result == VisitResult.COMPLETE) {
+ return true;
+ }
+
+ // Visit children, short-circuiting as necessary
+ if ((result == VisitResult.ACCEPT) && doVisitChildren(visitContext, visitRows)) {
+ if (visitRows) {
+ setRowKey(facesContext, null);
+ }
+
+ if (visitFixedChildren(visitContext, callback)) {
+ return true;
+ }
+
+ if (visitContext instanceof ExtendedVisitContext) {
+ ExtendedVisitContext extendedVisitContext = (ExtendedVisitContext) visitContext;
+
+ Collection<String> directSubtreeIdsToVisit = extendedVisitContext.getDirectSubtreeIdsToVisit(this);
+ if (directSubtreeIdsToVisit != VisitContext.ALL_IDS) {
+ if (directSubtreeIdsToVisit.isEmpty()) {
+ return false;
+ } else {
+ VisitContext directChildrenVisitContext =
+ extendedVisitContext.createNamingContainerVisitContext(this, directSubtreeIdsToVisit);
+
+ if (visitRows) {
+ setRowKey(facesContext, null);
+ }
+ if (visitFixedChildren(directChildrenVisitContext, STUB_CALLBACK)) {
+ return false;
+ }
+ }
+ }
+ }
+
+ if (visitDataChildren(visitContext, callback, visitRows)) {
+ return true;
+ }
+ }
+ } finally {
+
+ // Clean up - pop EL and restore old row index
+ popComponentFromEL(facesContext);
+
+ if (visitRows) {
+ try {
+ setRowKey(facesContext, oldRowKey);
+ restoreOrigValue(facesContext);
+ } catch (Exception e) {
+
+ // TODO: handle exception
+ LOG.error(e.getMessage(), e);
+ }
+ }
+ }
+
+ // Return false to allow the visit to continue
+ return false;
+ }
+
+ /**
+ * @param facesContext
+ * @return
+ */
+ private boolean requiresRowIteration(FacesContext context) {
+ return (!PhaseId.RESTORE_VIEW.equals(context.getCurrentPhaseId()));
+ }
+
+ /**
+ * @param context
+ * @param substring
+ * @return
+ */
+ // TODO review!
+ protected String extractKeySegment(FacesContext context, String substring) {
+ char separatorChar = UINamingContainer.getSeparatorChar(context);
+ int separatorIndex = substring.indexOf(separatorChar);
+
+ if (separatorIndex < 0) {
+ return null;
+ } else {
+ return substring.substring(0, separatorIndex);
+ }
+ }
+
+ /**
+ * Base class for visit data model at phases decode, validation and update model
+ *
+ * @author shura
+ */
+ protected abstract class ComponentVisitor implements DataVisitor {
+ public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
+ setRowKey(context, rowKey);
+
+ if (isRowAvailable()) {
+ Iterator<UIComponent> childIterator = dataChildren();
+
+ while (childIterator.hasNext()) {
+ UIComponent component = childIterator.next();
+
+ processComponent(context, component, argument);
+ }
+ }
+
+ return DataVisitResult.CONTINUE;
+ }
+
+ public abstract void processComponent(FacesContext context, UIComponent c, Object argument);
+ }
+
+ @Override
+ public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
+ super.processEvent(event);
+
+ if (event instanceof PreRenderComponentEvent) {
+ preEncodeBegin(getFacesContext());
+ }
+ }
+
+ protected DataComponentState getLocalComponentState() {
+ return componentState;
+ }
+}
Added: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java.orig
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java.orig (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java.orig 2010-12-01 16:27:24 UTC (rev 20261)
@@ -0,0 +1,575 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.component;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UpdateModelException;
+import javax.faces.component.html.HtmlOutputText;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.component.visit.VisitResult;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ExceptionQueuedEvent;
+import javax.faces.event.ExceptionQueuedEventContext;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
+
+import org.ajax4jsf.model.DataComponentState;
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.richfaces.application.MessageFactory;
+import org.richfaces.application.ServiceTracker;
+import org.richfaces.appplication.FacesMessages;
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Signature;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.component.util.MessageUtil;
+import org.richfaces.context.ExtendedVisitContext;
+import org.richfaces.context.ExtendedVisitContextMode;
+import org.richfaces.convert.SequenceRowKeyConverter;
+import org.richfaces.event.TreeSelectionChangeEvent;
+import org.richfaces.event.TreeSelectionChangeListener;
+import org.richfaces.event.TreeSelectionChangeSource;
+import org.richfaces.event.TreeToggleEvent;
+import org.richfaces.event.TreeToggleListener;
+import org.richfaces.event.TreeToggleSource;
+import org.richfaces.model.DeclarativeTreeDataModelImpl;
+<<<<<<< HEAD
+import org.richfaces.model.DeclarativeTreeModel;
+=======
+>>>>>>> RF-9680
+import org.richfaces.model.SwingTreeNodeDataModelImpl;
+import org.richfaces.model.TreeDataModel;
+import org.richfaces.model.TreeDataModelTuple;
+import org.richfaces.model.TreeDataVisitor;
+import org.richfaces.renderkit.MetaComponentRenderer;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Strings;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Iterators;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@JsfComponent(
+ type = AbstractTree.COMPONENT_TYPE,
+ family = AbstractTree.COMPONENT_FAMILY,
+ tag = @Tag(name = "tree", handler = "org.richfaces.view.facelets.TreeHandler"),
+ renderer = @JsfRenderer(type = "org.richfaces.TreeRenderer"),
+ attributes = {"events-props.xml", "core-props.xml", "i18n-props.xml"}
+)
+//TODO add rowData caching for wrapper events
+public abstract class AbstractTree extends UIDataAdaptor implements MetaComponentResolver, MetaComponentEncoder, TreeSelectionChangeSource, TreeToggleSource {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.Tree";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.Tree";
+
+ public static final String SELECTION_META_COMPONENT_ID = "selection";
+
+ private static final String DEFAULT_TREE_NODE_CREATED = AbstractTree.class.getName() + ":DEFAULT_TREE_NODE_CREATED";
+
+ private static final class MatchingTreeNodePredicate implements Predicate<UIComponent> {
+
+ private String type;
+
+ public MatchingTreeNodePredicate(String type) {
+ super();
+ this.type = type;
+ }
+
+ public boolean apply(UIComponent input) {
+ if (!(input instanceof AbstractTreeNode)) {
+ return false;
+ }
+
+ String nodeType = ((AbstractTreeNode) input).getType();
+ if (type == null && nodeType == null) {
+ return true;
+ }
+
+ return type != null && type.equals(nodeType);
+ }
+ };
+
+ private static final Converter ROW_KEY_CONVERTER = new SequenceRowKeyConverter();
+
+ private enum PropertyKeys {
+ selection
+ }
+
+ @SuppressWarnings("unused")
+ @Attribute(generate = false, signature = @Signature(returnType = Void.class, parameters = TreeSelectionChangeEvent.class))
+ private MethodExpression selectionChangeListener;
+
+ @SuppressWarnings("unused")
+ @Attribute(generate = false, signature = @Signature(returnType = Void.class, parameters = TreeToggleListener.class))
+ private MethodExpression toggleListener;
+
+ private transient TreeRange treeRange;
+
+ public AbstractTree() {
+ setKeepSaved(true);
+ setRendererType("org.richfaces.TreeRenderer");
+ }
+
+ protected TreeRange getTreeRange() {
+ if (treeRange == null) {
+ treeRange = new TreeRange(this);
+ }
+
+ return treeRange;
+ }
+
+ public abstract Object getValue();
+
+ public abstract boolean isImmediate();
+
+ public abstract String getIconLeaf();
+
+ public abstract String getIconExpanded();
+
+ public abstract String getIconCollapsed();
+
+ public abstract String getNodeClass();
+
+ public abstract String getHandleClass();
+
+ public abstract String getIconClass();
+
+ public abstract String getLabelClass();
+
+ @Attribute(events = @EventName("nodetoggle"))
+ public abstract String getOnnodetoggle();
+
+ @Attribute(events = @EventName("beforenodetoggle"))
+ public abstract String getOnbeforenodetoggle();
+
+ @Attribute(events = @EventName("selectionchange"))
+ public abstract String getOnselectionchange();
+
+ @Attribute(events = @EventName("beforeselectionchange"))
+ public abstract String getOnbeforeselectionchange();
+
+ @Attribute(defaultValue = "SwitchType.DEFAULT")
+ public abstract SwitchType getToggleType();
+
+ @Attribute(defaultValue = "SwitchType.client")
+ public abstract SwitchType getSelectionType();
+
+ public abstract String getNodeType();
+
+ public abstract String getToggleNodeEvent();
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ public Collection<Object> getSelection() {
+ @SuppressWarnings("unchecked")
+ Collection<Object> selection = (Collection<Object>) getStateHelper().eval(PropertyKeys.selection);
+ if (selection == null) {
+ selection = new HashSet<Object>();
+
+ ValueExpression ve = getValueExpression(PropertyKeys.selection.toString());
+ if (ve != null) {
+ ve.setValue(getFacesContext().getELContext(), selection);
+ } else {
+ getStateHelper().put(PropertyKeys.selection, selection);
+ }
+ }
+
+ return selection;
+ }
+
+ public void setSelection(Collection<Object> selection) {
+ getStateHelper().put(PropertyKeys.selection, selection);
+ }
+
+ @Override
+ protected DataComponentState createComponentState() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Converter getRowKeyConverter() {
+ Converter converter = super.getRowKeyConverter();
+ if (converter == null) {
+ converter = ROW_KEY_CONVERTER;
+ }
+ return converter;
+ }
+
+ protected Iterator<UIComponent> findMatchingTreeNodeComponent(String nodeType, UIComponent parentComponent) {
+ Iterator<UIComponent> children = parentComponent.getChildren().iterator();
+ if (parentComponent != this) {
+ children = Iterators.concat(children, this.getChildren().iterator());
+ }
+
+ return Iterators.filter(children, new MatchingTreeNodePredicate(nodeType));
+ }
+
+ protected UIComponent getCurrentComponent() {
+ ExtendedDataModel<?> dataModel = getExtendedDataModel();
+ if (dataModel instanceof DeclarativeTreeModel) {
+ return ((DeclarativeTreeModel) dataModel).getCurrentComponent();
+ }
+
+ return this;
+ }
+
+ public AbstractTreeNode findTreeNodeComponent() {
+ FacesContext facesContext = getFacesContext();
+
+ String nodeType = getNodeType();
+
+ Iterator<UIComponent> nodesItr = findMatchingTreeNodeComponent(nodeType, getCurrentComponent());
+
+ if (nodesItr.hasNext()) {
+ Iterator<UIComponent> renderedNodesItr = Iterators.filter(nodesItr, ComponentPredicates.isRendered());
+ if (renderedNodesItr.hasNext()) {
+ return (AbstractTreeNode) renderedNodesItr.next();
+ }
+
+ return null;
+ }
+
+ if (Strings.isNullOrEmpty(nodeType)) {
+ if (getAttributes().put(DEFAULT_TREE_NODE_CREATED, Boolean.TRUE) != null) {
+ return null;
+ }
+
+ Application application = facesContext.getApplication();
+ AbstractTreeNode treeNode = (AbstractTreeNode) application.createComponent(AbstractTreeNode.COMPONENT_TYPE);
+ treeNode.setId("__defaultTreeNode");
+
+ getChildren().add(treeNode);
+
+ UIComponent text = application.createComponent(HtmlOutputText.COMPONENT_TYPE);
+ text.setValueExpression("value", application.getExpressionFactory().createValueExpression(facesContext.getELContext(),
+ "#{" + getVar() + "}", String.class));
+ treeNode.getChildren().add(text);
+
+ return treeNode;
+ }
+
+ return null;
+ }
+
+ @Override
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ super.broadcast(event);
+
+ if (event instanceof TreeSelectionChangeEvent) {
+ TreeSelectionChangeEvent selectionEvent = (TreeSelectionChangeEvent) event;
+
+ final Collection<Object> newSelection = selectionEvent.getNewSelection();
+
+ Collection<Object> selectionCollection = getSelection();
+
+ Iterables.removeIf(selectionCollection, new Predicate<Object>() {
+ public boolean apply(Object input) {
+ return !newSelection.contains(input);
+ };
+ });
+
+ if (!newSelection.isEmpty()) {
+ Iterables.addAll(selectionCollection, newSelection);
+ }
+ } else if (event instanceof TreeToggleEvent) {
+ TreeToggleEvent toggleEvent = (TreeToggleEvent) event;
+ AbstractTreeNode treeNodeComponent = findTreeNodeComponent();
+
+ boolean newExpandedValue = toggleEvent.isExpanded();
+
+ FacesContext context = getFacesContext();
+ ValueExpression expression = getValueExpression(AbstractTreeNode.PropertyKeys.expanded.toString());
+ if (expression != null) {
+ ELContext elContext = context.getELContext();
+ Exception caught = null;
+ FacesMessage message = null;
+ try {
+ expression.setValue(elContext, newExpandedValue);
+ } catch (ELException e) {
+ caught = e;
+ String messageStr = e.getMessage();
+ Throwable result = e.getCause();
+ while (null != result &&
+ result.getClass().isAssignableFrom(ELException.class)) {
+ messageStr = result.getMessage();
+ result = result.getCause();
+ }
+ if (null == messageStr) {
+ MessageFactory messageFactory = ServiceTracker.getService(MessageFactory.class);
+ message =
+ messageFactory.createMessage(context, FacesMessages.UIINPUT_UPDATE,
+ MessageUtil.getLabel(context, this));
+ } else {
+ message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
+ messageStr,
+ messageStr);
+ }
+ } catch (Exception e) {
+ caught = e;
+ MessageFactory messageFactory = ServiceTracker.getService(MessageFactory.class);
+ message =
+ messageFactory.createMessage(context, FacesMessages.UIINPUT_UPDATE,
+ MessageUtil.getLabel(context, this));
+ }
+ if (caught != null) {
+ assert(message != null);
+ UpdateModelException toQueue = new UpdateModelException(message, caught);
+ ExceptionQueuedEventContext eventContext =
+ new ExceptionQueuedEventContext(context,
+ toQueue,
+ this,
+ PhaseId.UPDATE_MODEL_VALUES);
+ context.getApplication().publishEvent(context,
+ ExceptionQueuedEvent.class,
+ eventContext);
+ }
+ } else {
+ treeNodeComponent.setExpanded(newExpandedValue);
+ }
+ }
+ }
+
+ @Override
+ protected boolean visitFixedChildren(VisitContext visitContext, VisitCallback callback) {
+ if (visitContext instanceof ExtendedVisitContext) {
+ ExtendedVisitContext extendedVisitContext = (ExtendedVisitContext) visitContext;
+
+ if (ExtendedVisitContextMode.RENDER == extendedVisitContext.getVisitMode()) {
+ VisitResult result = extendedVisitContext.invokeMetaComponentVisitCallback(this, callback, SELECTION_META_COMPONENT_ID);
+ if (result != VisitResult.ACCEPT) {
+ return result == VisitResult.COMPLETE;
+ }
+ }
+ }
+
+ return super.visitFixedChildren(visitContext, callback);
+ }
+
+ void decodeMetaComponent(FacesContext context, String metaComponentId) {
+ ((MetaComponentRenderer) getRenderer(context)).decodeMetaComponent(context, this, metaComponentId);
+ }
+
+ public void encodeMetaComponent(FacesContext context, String metaComponentId) throws IOException {
+ ((MetaComponentRenderer) getRenderer(context)).encodeMetaComponent(context, this, metaComponentId);
+ }
+
+ public String resolveClientId(FacesContext facesContext, UIComponent contextComponent, String metaComponentId) {
+ if (SELECTION_META_COMPONENT_ID.equals(metaComponentId)) {
+ return getClientId(facesContext) + MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR + metaComponentId;
+ }
+
+ return null;
+ }
+
+ public String substituteUnresolvedClientId(FacesContext facesContext, UIComponent contextComponent,
+ String metaComponentId) {
+
+ return null;
+ }
+
+ @Override
+ protected Iterator<UIComponent> dataChildren() {
+ AbstractTreeNode treeNodeComponent = findTreeNodeComponent();
+ if (treeNodeComponent != null) {
+ return Iterators.<UIComponent>singletonIterator(treeNodeComponent);
+ } else {
+ return Iterators.<UIComponent>emptyIterator();
+ }
+ }
+
+ public void addTreeSelectionChangeListener(TreeSelectionChangeListener listener) {
+ addFacesListener(listener);
+ }
+
+ @Attribute(hidden = true)
+ public TreeSelectionChangeListener[] getTreeSelectionChangeListeners() {
+ return (TreeSelectionChangeListener[]) getFacesListeners(TreeSelectionChangeListener.class);
+ }
+
+ public void removeTreeSelectionChangeListener(TreeSelectionChangeListener listener) {
+ removeFacesListener(listener);
+ }
+
+ public void addTreeToggleListener(TreeToggleListener listener) {
+ addFacesListener(listener);
+ }
+
+ @Attribute(hidden = true)
+ public TreeToggleListener[] getTreeToggleListeners() {
+ return (TreeToggleListener[]) getFacesListeners(TreeToggleListener.class);
+ }
+
+ public void removeTreeToggleListener(TreeToggleListener listener) {
+ removeFacesListener(listener);
+ }
+
+ @Attribute(hidden = true)
+ public boolean isExpanded() {
+ if (getRowKey() == null) {
+ return true;
+ }
+
+ AbstractTreeNode treeNode = findTreeNodeComponent();
+ if (treeNode == null) {
+ return false;
+ }
+
+ return treeNode.isExpanded();
+ }
+
+ //TODO review
+ protected TreeDataModel<?> getTreeDataModel() {
+ return (TreeDataModel<?>) getExtendedDataModel();
+ }
+
+ @Attribute(hidden = true)
+ public boolean isLeaf() {
+ if (getRowKey() == null) {
+ return false;
+ }
+
+ return getTreeDataModel().isLeaf();
+ }
+
+ @Override
+ public void walk(final FacesContext faces, final DataVisitor visitor, final Object argument) {
+ walkModel(faces, new TreeDataVisitor() {
+
+ public void enterNode() {
+ visitor.process(faces, getRowKey(), argument);
+ }
+
+ public void exitNode() {
+ }
+
+ public void beforeChildrenVisit() {
+ }
+
+ public void afterChildrenVisit() {
+ }
+
+ });
+ }
+
+ @Override
+ protected ExtendedDataModel<?> createExtendedDataModel() {
+ ExtendedDataModel<?> dataModel;
+
+ Object value = getValue();
+ if (value == null) {
+ dataModel = new DeclarativeTreeDataModelImpl(this, getVar(), getVariablesMap(getFacesContext()));
+ } else {
+ dataModel = new SwingTreeNodeDataModelImpl();
+ dataModel.setWrappedData(getValue());
+ }
+
+ return dataModel;
+ }
+
+ public void walkModel(FacesContext context, TreeDataVisitor dataVisitor) {
+ TreeDataModel<?> model = getTreeDataModel();
+
+ if (!getTreeRange().shouldProcessNode()) {
+ return;
+ }
+
+ boolean isRootNode = (getRowKey() == null);
+
+ if (!isRootNode) {
+ dataVisitor.enterNode();
+ }
+
+ walkModelChildren(context, dataVisitor, model);
+
+ if (!isRootNode) {
+ dataVisitor.exitNode();
+ }
+ }
+
+ private void walkModelChildren(FacesContext context, TreeDataVisitor dataVisitor, TreeDataModel<?> model) {
+ if (!getTreeRange().shouldIterateChildren()) {
+ return;
+ }
+
+ dataVisitor.beforeChildrenVisit();
+
+ Iterator<TreeDataModelTuple> childrenTuples = model.children();
+ while (childrenTuples.hasNext()) {
+ TreeDataModelTuple tuple = childrenTuples.next();
+
+ restoreFromSnapshot(context, tuple);
+
+ if (!getTreeRange().shouldProcessNode()) {
+ continue;
+ }
+
+ dataVisitor.enterNode();
+
+ walkModelChildren(context, dataVisitor, model);
+
+ dataVisitor.exitNode();
+ }
+
+ dataVisitor.afterChildrenVisit();
+ }
+
+ @Override
+ protected void resetDataModel() {
+ super.resetDataModel();
+ treeRange = null;
+ }
+
+ public TreeDataModelTuple createSnapshot() {
+ return getTreeDataModel().createSnapshot();
+ }
+
+ public void restoreFromSnapshot(FacesContext context, TreeDataModelTuple tuple) {
+ getTreeDataModel().restoreFromSnapshot(tuple);
+ setRowKey(context, tuple.getRowKey());
+ }
+
+}
Added: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java.orig
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java.orig (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java.orig 2010-12-01 16:27:24 UTC (rev 20261)
@@ -0,0 +1,196 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.model;
+
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import javax.swing.tree.TreeNode;
+
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Iterators;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class SwingTreeNodeDataModelImpl extends TreeSequenceKeyModel<Integer, TreeNode> {
+
+ private final class SwingTreeNodeRowKeyIterator implements Iterator<TreeDataModelTuple> {
+
+ private SequenceRowKey<Integer> baseKey;
+
+ private Iterator<TreeNode> children;
+
+ private int counter = 0;
+
+ private SwingTreeNodeRowKeyIterator(SequenceRowKey<Integer> baseKey, Iterator<TreeNode> children) {
+ this.baseKey = baseKey;
+ this.children = children;
+ }
+
+ private int getNextCounterValue() {
+ return counter++;
+ }
+
+ public boolean hasNext() {
+ return children.hasNext();
+ }
+
+ public TreeDataModelTuple next() {
+ TreeNode node = children.next();
+
+ SequenceRowKey<Integer> key;
+
+ if (baseKey != null) {
+ key = baseKey.append(getNextCounterValue());
+ } else {
+ key = new SequenceRowKey<Integer>(getNextCounterValue());
+ }
+
+ return new TreeDataModelTuple(key, node);
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ }
+
+ private final class FakeRootNode implements TreeNode {
+
+ private Collection<TreeNode> wrappedData;
+
+ public FakeRootNode(Collection<TreeNode> wrappedData) {
+ super();
+ this.wrappedData = wrappedData;
+ }
+
+ public boolean isLeaf() {
+ return !wrappedData.isEmpty();
+ }
+
+ public TreeNode getParent() {
+ return null;
+ }
+
+ public int getIndex(TreeNode node) {
+ if (wrappedData == null) {
+ return -1;
+ }
+
+ return Iterables.indexOf(wrappedData, Predicates.equalTo(node));
+ }
+
+ public int getChildCount() {
+ if (wrappedData == null) {
+ return 0;
+ }
+
+ return wrappedData.size();
+ }
+
+ public TreeNode getChildAt(int childIndex) {
+ if (wrappedData == null) {
+ throw new NoSuchElementException(String.valueOf(childIndex));
+ }
+
+ return Iterables.get(wrappedData, childIndex);
+ }
+
+ public boolean getAllowsChildren() {
+ return true;
+ }
+
+ public Enumeration<?> children() {
+ if (wrappedData == null) {
+ return Iterators.asEnumeration(Iterators.emptyIterator());
+ }
+
+ return Iterators.asEnumeration(wrappedData.iterator());
+ }
+
+ public Collection<TreeNode> getWrappedData() {
+ return wrappedData;
+ }
+ }
+
+ private boolean asksAllowsChildren = false;
+
+ private Iterator<TreeNode> safeGetChildren(TreeNode treeNode) {
+ if (treeNode == null) {
+ return Iterators.emptyIterator();
+ }
+
+ return Iterators.forEnumeration((Enumeration<TreeNode>) treeNode.children());
+ }
+
+
+ public Object getParentRowKey(Object rowKey) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setWrappedData(Object data) {
+ setRootNode(new FakeRootNode((Collection<TreeNode>) data));
+ }
+
+ public Collection<TreeNode> getWrappedData() {
+ FakeRootNode rootNode = (FakeRootNode) getRootNode();
+ if (rootNode == null) {
+ return null;
+ }
+ return rootNode.getWrappedData();
+ }
+
+ protected TreeNode findChild(TreeNode parent, Integer simpleKey) {
+ return parent.getChildAt(simpleKey.intValue());
+ }
+
+ public Iterator<TreeDataModelTuple> children() {
+ return new SwingTreeNodeRowKeyIterator(getRowKey(), safeGetChildren(getData()));
+ }
+
+
+ public boolean isLeaf() {
+ if (!asksAllowsChildren) {
+ return getData().isLeaf();
+ } else {
+ return !getData().getAllowsChildren();
+ }
+ }
+
+ @Override
+ protected void walkNext(Integer segment) {
+ TreeNode child = findChild(getData(), segment);
+ //TODO what if node is missing?
+ //TODO - optimize - remove partial keys creation
+ setRowKeyAndData(safeGetRowKey().append(segment), child);
+ }
+<<<<<<< HEAD
+
+=======
+
+>>>>>>> RF-9680
+}
\ No newline at end of file
Added: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java.orig
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java.orig (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java.orig 2010-12-01 16:27:24 UTC (rev 20261)
@@ -0,0 +1,180 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.model;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public abstract class TreeSequenceKeyModel<K, V> extends ExtendedDataModel<V> implements TreeDataModel<V> {
+
+ private final SequenceRowKey<K> emptyKey = new SequenceRowKey<K>();
+
+<<<<<<< HEAD
+ private V rootNode;
+
+=======
+>>>>>>> RF-9680:
+ private V data;
+
+ private SequenceRowKey<K> rowKey;
+
+ public SequenceRowKey<K> getRowKey() {
+ return rowKey;
+ }
+
+ protected SequenceRowKey<K> safeGetRowKey() {
+ SequenceRowKey<K> key = getRowKey();
+
+ if (key == null) {
+ key = emptyKey;
+ }
+
+ return key;
+ }
+
+ public void setRowKey(Object rowKey) {
+ if (this.rowKey == null || !this.rowKey.equals(rowKey)) {
+<<<<<<< HEAD
+ walkKey((SequenceRowKey<K>) rowKey);
+ }
+ }
+
+ protected void resetRowKeyAndData() {
+ setRowKeyAndData(null, rootNode);
+ }
+
+=======
+ this.rowKey = (SequenceRowKey<K>) rowKey;
+ this.data = findData(this.rowKey);
+ }
+ }
+
+>>>>>>> RF-9680:
+ protected void setRowKeyAndData(SequenceRowKey<K> key, V data) {
+ this.rowKey = key;
+ this.data = data;
+ }
+
+ public boolean isDataAvailable() {
+<<<<<<< HEAD
+ return getRowKey() == null || data != null;
+=======
+ return data != null;
+>>>>>>> RF-9680:
+ }
+
+ public V getData() {
+ if (!isDataAvailable()) {
+ throw new IllegalArgumentException();
+ }
+
+ return data;
+ }
+<<<<<<< HEAD
+
+ protected void walkKey(SequenceRowKey<K> key) {
+ resetRowKeyAndData();
+=======
+
+ protected V findData(SequenceRowKey<K> key) {
+ if (key == null) {
+ return rootNode;
+ }
+
+ V result = rootNode;
+
+ for (K simpleKey : key.getSimpleKeys()) {
+ result = findChild(result, simpleKey);
+>>>>>>> RF-9680:
+
+ if (key != null) {
+ for (K simpleKey: key.getSimpleKeys()) {
+ walkNext(simpleKey);
+ }
+ }
+ }
+
+ protected abstract void walkNext(K segment);
+
+ protected V getRootNode() {
+ return rootNode;
+ }
+
+ protected void setRootNode(V rootNode) {
+ this.rootNode = rootNode;
+ }
+
+ //TODO ExtendedDataModel legacy
+ @Override
+ public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ @Override
+ public boolean isRowAvailable() {
+ return isDataAvailable();
+ }
+
+
+ @Override
+ public int getRowCount() {
+ throw new UnsupportedOperationException();
+ }
+
+
+ @Override
+ public V getRowData() {
+ return getData();
+ }
+
+
+ @Override
+ public int getRowIndex() {
+ throw new UnsupportedOperationException();
+ }
+
+
+ @Override
+ public void setRowIndex(int rowIndex) {
+ throw new UnsupportedOperationException();
+<<<<<<< HEAD
+ }
+
+ public TreeDataModelTuple createSnapshot() {
+ return new TreeDataModelTuple(getRowKey(), getData());
+ }
+
+ public void restoreFromSnapshot(TreeDataModelTuple tuple) {
+ setRowKeyAndData((SequenceRowKey<K>) tuple.getRowKey(), (V) tuple.getData());
+=======
+>>>>>>> RF-9680:
+ }
+}
Added: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java.orig
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java.orig (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java.orig 2010-12-01 16:27:24 UTC (rev 20261)
@@ -0,0 +1,227 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.JSFunction;
+import org.richfaces.component.AbstractTree;
+import org.richfaces.component.AbstractTreeNode;
+import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.model.TreeDataModelTuple;
+import org.richfaces.model.TreeDataVisitor;
+
+abstract class TreeEncoderBase implements TreeDataVisitor {
+
+ private static final class QueuedData {
+
+ private enum State {
+ initial, visited, encoded
+ }
+
+ private State state = State.initial;
+
+ private TreeDataModelTuple tuple;
+
+ public QueuedData(TreeDataModelTuple tuple) {
+ super();
+ this.tuple = tuple;
+ }
+
+ public boolean isEncoded() {
+ return state == State.encoded;
+ }
+
+ public void makeEncoded() {
+ this.state = State.encoded;
+ }
+
+ public void makeVisited() {
+ this.state = State.visited;
+ }
+
+ public boolean isVisited() {
+ return state == State.visited;
+ }
+
+ public TreeDataModelTuple getTuple() {
+ return tuple;
+ }
+
+ }
+
+ static final String TREE_NODE_STATE_ATTRIBUTE = "__treeNodeState";
+
+ protected final FacesContext context;
+
+ protected final ResponseWriter responseWriter;
+
+ protected final AbstractTree tree;
+
+<<<<<<< HEAD
+ private LinkedList<QueuedData> queuedDataList = new LinkedList<QueuedData>();
+
+=======
+>>>>>>> RF-9680:
+ public TreeEncoderBase(FacesContext context, AbstractTree tree) {
+ super();
+ this.context = context;
+ this.responseWriter = context.getResponseWriter();
+ this.tree = tree;
+ }
+
+ protected void encodeTree() throws IOException {
+ tree.walkModel(context, this);
+ }
+
+<<<<<<< HEAD
+ protected void flushParentNode() throws IOException {
+ if (queuedDataList.isEmpty()) {
+ return;
+ }
+
+ QueuedData data = queuedDataList.getLast();
+ if (!data.isEncoded()) {
+ data.makeEncoded();
+ tree.restoreFromSnapshot(context, data.getTuple());
+
+ TreeNodeState nodeState = getNodeState(tree.isLeaf(), false);
+
+ writeTreeNodeStartElement(nodeState);
+ tree.findTreeNodeComponent().encodeAll(context);
+ }
+ }
+
+ private TreeNodeState getNodeState(boolean leaf, boolean visited) {
+ TreeNodeState nodeState;
+ if (leaf) {
+ nodeState = TreeNodeState.leaf;
+ } else if (visited) {
+ nodeState = TreeNodeState.expandedNoChildren;
+ } else if (tree.isExpanded()) {
+ nodeState = TreeNodeState.expanded;
+ } else {
+ nodeState = TreeNodeState.collapsed;
+ }
+ return nodeState;
+ }
+
+ public void beforeChildrenVisit() {
+ if (!queuedDataList.isEmpty()) {
+ queuedDataList.getLast().makeVisited();
+ }
+ }
+
+ public void afterChildrenVisit() {
+ }
+
+ public void enterNode() {
+ TreeDataModelTuple tuple = tree.createSnapshot();
+ QueuedData queuedData = new QueuedData(tuple);
+
+ try {
+ flushParentNode();
+ } catch (IOException e) {
+ throw new FacesException(e.getMessage(), e);
+ }
+
+ tree.restoreFromSnapshot(context, tuple);
+ queuedDataList.add(queuedData);
+ }
+
+ public void exitNode() {
+ QueuedData data = queuedDataList.removeLast();
+
+ tree.restoreFromSnapshot(context, data.getTuple());
+ try {
+ if (!data.isEncoded()) {
+ writeTreeNodeStartElement(getNodeState(tree.isLeaf(), data.isVisited()));
+ tree.findTreeNodeComponent().encodeAll(context);
+ }
+
+=======
+ public void enterNode() {
+ TreeNodeState state;
+ if (tree.isLeaf()) {
+ state = TreeNodeState.leaf;
+ } else {
+ if (tree.isExpanded()) {
+ state = TreeNodeState.expanded;
+ } else {
+ state = TreeNodeState.collapsed;
+ }
+ }
+
+ try {
+ writeTreeNodeStartElement(state);
+ tree.findTreeNodeComponent().encodeAll(context);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void exitNode() {
+ try {
+>>>>>>> RF-9680:
+ writeTreeNodeEndElement();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ protected void writeTreeNodeStartElement(TreeNodeState nodeState) throws IOException {
+ AbstractTreeNode treeNodeComponent = tree.findTreeNodeComponent();
+
+ context.getAttributes().put(TREE_NODE_STATE_ATTRIBUTE, nodeState);
+
+ responseWriter.startElement(HtmlConstants.DIV_ELEM, tree);
+ responseWriter.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
+ HtmlUtil.concatClasses("rf-tr-nd", nodeState.getNodeClass()),
+ null);
+ responseWriter.writeAttribute(HtmlConstants.ID_ATTRIBUTE, treeNodeComponent.getClientId(context), null);
+
+ emitClientToggleEvent(treeNodeComponent, nodeState);
+ }
+
+ protected void writeTreeNodeEndElement() throws IOException {
+ responseWriter.endElement(HtmlConstants.DIV_ELEM);
+ }
+
+ public abstract void encode() throws IOException;
+
+ private void emitClientToggleEvent(AbstractTreeNode treeNode, TreeNodeState nodeState) {
+ if (treeNode.getClientId(context).equals(context.getAttributes().get(TreeNodeRendererBase.AJAX_TOGGLED_NODE_ATTRIBUTE))) {
+ TreeNodeState initialState = (TreeNodeState) context.getAttributes().get(TreeNodeRendererBase.AJAX_TOGGLED_NODE_STATE_ATTRIBUTE);
+
+ if (initialState.isDifferentThan(nodeState)) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ ajaxContext.appendOncomplete(new JSFunction("RichFaces.ui.TreeNode.emitToggleEvent", treeNode.getClientId(context)));
+ }
+ }
+ }
+}
\ No newline at end of file
15 years, 1 month
JBoss Rich Faces SVN: r20260 - trunk/ui/iteration/ui/src/main/java/org/richfaces/model.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-01 11:24:19 -0500 (Wed, 01 Dec 2010)
New Revision: 20260
Removed:
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeModel.java
Log:
Duplicating DeclarativeTreeModel deleted
Deleted: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeModel.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeModel.java 2010-12-01 16:22:40 UTC (rev 20259)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeModel.java 2010-12-01 16:24:19 UTC (rev 20260)
@@ -1,34 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.model;
-
-import javax.faces.component.UIComponent;
-
-/**
- * @author Nick Belaevski
- *
- */
-public interface DeclarativeTreeModel {
-
- public UIComponent getCurrentComponent();
-
-}
15 years, 1 month
JBoss Rich Faces SVN: r20259 - in trunk/ui: iteration/ui/src/main/java/org/richfaces/renderkit and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-01 11:22:40 -0500 (Wed, 01 Dec 2010)
New Revision: 20259
Modified:
trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
Log:
https://jira.jboss.org/browse/RF-9680
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-12-01 16:19:43 UTC (rev 20258)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-12-01 16:22:40 UTC (rev 20259)
@@ -246,10 +246,6 @@
private Object rowKey = null;
- private boolean rowDataIsSet = false;
-
- private Object rowData;
-
private String clientId;
private Object originalVarValue;
@@ -371,34 +367,6 @@
return rowKey;
}
- private void setRowKeyAndData(FacesContext facesContext, Object rowKey, boolean localRowDataAvailable, Object localRowData) {
- this.saveChildState(facesContext);
-
- this.rowKey = rowKey;
-
- if (localRowDataAvailable) {
- this.rowData = localRowData;
- this.rowDataIsSet = (rowKey != null);
- } else {
- this.rowData = null;
- this.rowDataIsSet = false;
-
- getExtendedDataModel().setRowKey(rowKey);
- }
-
- this.clientId = null;
-
- boolean rowSelected = (rowKey != null) && isRowAvailable();
-
- setupVariable(facesContext, rowSelected);
-
- this.restoreChildState(facesContext);
- }
-
- protected void setRowKeyAndData(FacesContext facesContext, Object rowKey, Object localRowData) {
- setRowKeyAndData(facesContext, rowKey, true, localRowData);
- }
-
/**
* Setup current row by key. Perform same functionality as
* {@link javax.faces.component.UIData#setRowIndex(int)}, but for key object - it may be not only
@@ -647,15 +615,11 @@
}
public Object getRowData() {
- if (rowDataIsSet) {
- return rowData;
- }
-
return getExtendedDataModel().getRowData();
}
public boolean isRowAvailable() {
- return rowDataIsSet || getExtendedDataModel().isRowAvailable();
+ return getExtendedDataModel().isRowAvailable();
}
/**
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-12-01 16:19:43 UTC (rev 20258)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-12-01 16:22:40 UTC (rev 20259)
@@ -162,8 +162,7 @@
writeTreeNodeEndElement();
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw new FacesException(e.getMessage(), e);
}
}
15 years, 1 month
JBoss Rich Faces SVN: r20258 - trunk/ui/iteration/ui/src/main/java/org/richfaces/model.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-01 11:19:43 -0500 (Wed, 01 Dec 2010)
New Revision: 20258
Added:
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeModel.java
Log:
https://jira.jboss.org/browse/RF-9680
Added: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeModel.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeModel.java (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeModel.java 2010-12-01 16:19:43 UTC (rev 20258)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.model;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface DeclarativeTreeModel {
+
+ public UIComponent getCurrentComponent();
+
+}
15 years, 1 month
JBoss Rich Faces SVN: r20257 - trunk/ui/iteration/ui/src/main/java/org/richfaces/model.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-01 11:18:03 -0500 (Wed, 01 Dec 2010)
New Revision: 20257
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java
Log:
RF-9680
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java 2010-12-01 16:17:30 UTC (rev 20256)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java 2010-12-01 16:18:03 UTC (rev 20257)
@@ -187,5 +187,4 @@
//TODO - optimize - remove partial keys creation
setRowKeyAndData(safeGetRowKey().append(segment), child);
}
-
}
\ No newline at end of file
15 years, 1 month
JBoss Rich Faces SVN: r20256 - in sandbox/trunk/ui/fileupload/ui/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-12-01 11:17:30 -0500 (Wed, 01 Dec 2010)
New Revision: 20256
Modified:
sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss
sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js
sandbox/trunk/ui/fileupload/ui/src/main/templates/fileupload.template.xml
Log:
RF-9496
Modified: sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss
===================================================================
--- sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss 2010-12-01 16:16:19 UTC (rev 20255)
+++ sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss 2010-12-01 16:17:30 UTC (rev 20256)
@@ -44,7 +44,7 @@
overflow-y: auto;
}
-.rf-fu-frm {
+.rf-fu-cntr-hdn {
display: none;
}
Modified: sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js
===================================================================
--- sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js 2010-12-01 16:16:19 UTC (rev 20255)
+++ sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js 2010-12-01 16:17:30 UTC (rev 20256)
@@ -62,9 +62,10 @@
this.inputContainer = this.addButton.find(".rf-fu-inp-cntr:first");
this.input = this.inputContainer.children("input");
this.list = header.next();
- this.progressBarElement = this.list.next();
+ this.hiddenContainer = this.list.next();
+ this.iframe = this.hiddenContainer.children("iframe:first");
+ this.progressBarElement = this.iframe.next();
this.progressBar = richfaces.$(this.progressBarElement);
- this.iframe = this.progressBarElement.next();
this.cleanInput = this.input.clone();
this.addProxy = jQuery.proxy(this.__addItem, this);
this.input.change(this.addProxy);
@@ -232,15 +233,18 @@
this.fileUpload.__submit();
var params = {};
params[UID] = this.uid;
- this.fileUpload.progressBar.setValue(0);
- this.state.html(this.fileUpload.progressBarElement.detach());
- this.fileUpload.progressBar.enable(params);
+ if (this.fileUpload.progressBar) {
+ this.fileUpload.progressBar.setValue(0);
+ this.state.html(this.fileUpload.progressBarElement.detach());
+ this.fileUpload.progressBar.enable(params);
+ }
},
finishUploading: function() {
- this.fileUpload.progressBar.disable();
- this.fileUpload.progressBar.setValue(101);
- this.fileUpload.element.append(this.fileUpload.progressBarElement.detach());
+ if (this.fileUpload.progressBar) {
+ this.fileUpload.progressBar.disable();
+ this.fileUpload.hiddenContainer.append(this.fileUpload.progressBarElement.detach());
+ }
this.input.remove();
this.state.html("Done");
this.link.html("Clear");
Modified: sandbox/trunk/ui/fileupload/ui/src/main/templates/fileupload.template.xml
===================================================================
--- sandbox/trunk/ui/fileupload/ui/src/main/templates/fileupload.template.xml 2010-12-01 16:16:19 UTC (rev 20255)
+++ sandbox/trunk/ui/fileupload/ui/src/main/templates/fileupload.template.xml 2010-12-01 16:17:30 UTC (rev 20256)
@@ -69,11 +69,13 @@
</div>
<div class="rf-fu-lst"/>
<c:if test="#{enabled}">
- <cdk:object name="progressBar" value="#{component.facets['progress']}"/>
- <c:if test="#{progressBar.isRendered()}">
- <cdk:call expression="progressBar.encodeAll(facesContext)" />
- </c:if>
- <iframe name="#{clientId}" class="rf-fu-frm"/>
+ <div class="rf-fu-cntr-hdn">
+ <iframe name="#{clientId}"/>
+ <cdk:object name="progressBar" value="#{component.facets['progress']}"/>
+ <c:if test="#{progressBar.isRendered()}">
+ <cdk:call expression="progressBar.encodeAll(facesContext)" />
+ </c:if>
+ </div>
<cdk:scriptObject name="options">
<cdk:scriptOption attributes="acceptedTypes noDuplicate onfilesubmit onuploadcomplete"/>
</cdk:scriptObject>
15 years, 1 month
JBoss Rich Faces SVN: r20255 - in trunk/ui: iteration/ui/src/main/java/org/richfaces/model and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-01 11:16:19 -0500 (Wed, 01 Dec 2010)
New Revision: 20255
Modified:
trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
Log:
RF-9680:
- Added children() method to TreeDataModel & tuples
- Related refactorings for UIDataAdaptor
- Redesign API for walking over model
- Renderer updated for new API
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-12-01 15:23:37 UTC (rev 20254)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-12-01 16:16:19 UTC (rev 20255)
@@ -246,6 +246,10 @@
private Object rowKey = null;
+ private boolean rowDataIsSet = false;
+
+ private Object rowData;
+
private String clientId;
private Object originalVarValue;
@@ -367,6 +371,34 @@
return rowKey;
}
+ private void setRowKeyAndData(FacesContext facesContext, Object rowKey, boolean localRowDataAvailable, Object localRowData) {
+ this.saveChildState(facesContext);
+
+ this.rowKey = rowKey;
+
+ if (localRowDataAvailable) {
+ this.rowData = localRowData;
+ this.rowDataIsSet = (rowKey != null);
+ } else {
+ this.rowData = null;
+ this.rowDataIsSet = false;
+
+ getExtendedDataModel().setRowKey(rowKey);
+ }
+
+ this.clientId = null;
+
+ boolean rowSelected = (rowKey != null) && isRowAvailable();
+
+ setupVariable(facesContext, rowSelected);
+
+ this.restoreChildState(facesContext);
+ }
+
+ protected void setRowKeyAndData(FacesContext facesContext, Object rowKey, Object localRowData) {
+ setRowKeyAndData(facesContext, rowKey, true, localRowData);
+ }
+
/**
* Setup current row by key. Perform same functionality as
* {@link javax.faces.component.UIData#setRowIndex(int)}, but for key object - it may be not only
@@ -615,11 +647,15 @@
}
public Object getRowData() {
+ if (rowDataIsSet) {
+ return rowData;
+ }
+
return getExtendedDataModel().getRowData();
}
public boolean isRowAvailable() {
- return getExtendedDataModel().isRowAvailable();
+ return rowDataIsSet || getExtendedDataModel().isRowAvailable();
}
/**
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java 2010-12-01 15:23:37 UTC (rev 20254)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java 2010-12-01 16:16:19 UTC (rev 20255)
@@ -172,7 +172,6 @@
return new SwingTreeNodeRowKeyIterator(getRowKey(), safeGetChildren(getData()));
}
-
public boolean isLeaf() {
if (!asksAllowsChildren) {
return getData().isLeaf();
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java 2010-12-01 15:23:37 UTC (rev 20254)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java 2010-12-01 16:16:19 UTC (rev 20255)
@@ -146,5 +146,4 @@
public void restoreFromSnapshot(TreeDataModelTuple tuple) {
setRowKeyAndData((SequenceRowKey<K>) tuple.getRowKey(), (V) tuple.getData());
}
-
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-12-01 15:23:37 UTC (rev 20254)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-12-01 16:16:19 UTC (rev 20255)
@@ -162,7 +162,8 @@
writeTreeNodeEndElement();
} catch (IOException e) {
- throw new FacesException(e.getMessage(), e);
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
}
15 years, 1 month
JBoss Rich Faces SVN: r20254 - trunk/examples/validator-demo.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-12-01 10:23:37 -0500 (Wed, 01 Dec 2010)
New Revision: 20254
Modified:
trunk/examples/validator-demo/pom.xml
Log:
* project name changed from Outputs to Validators
Modified: trunk/examples/validator-demo/pom.xml
===================================================================
--- trunk/examples/validator-demo/pom.xml 2010-12-01 15:12:38 UTC (rev 20253)
+++ trunk/examples/validator-demo/pom.xml 2010-12-01 15:23:37 UTC (rev 20254)
@@ -13,7 +13,7 @@
<groupId>org.richfaces.examples</groupId>
<artifactId>validator-demo</artifactId>
<version>4.0.0-SNAPSHOT</version>
- <name>Richfaces Examples: Outputs</name>
+ <name>Richfaces Examples: Validators</name>
<packaging>war</packaging>
<properties>
15 years, 1 month
JBoss Rich Faces SVN: r20253 - in trunk: examples/output-demo/src/main/webapp/resources and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-12-01 10:12:38 -0500 (Wed, 01 Dec 2010)
New Revision: 20253
Added:
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/PanelMenu.js
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/PanelMenuGroup.js
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/PanelMenuItem.js
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-group.xmlunit.xml
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-groupDis.xmlunit.xml
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-item.xmlunit.xml
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-itemDis.xmlunit.xml
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-topGroup.xmlunit.xml
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-topGroupDis.xmlunit.xml
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-topItem.xmlunit.xml
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-topItemDis.xmlunit.xml
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance.xhtml
Removed:
trunk/examples/output-demo/src/main/webapp/resources/PanelMenu.js
trunk/examples/output-demo/src/main/webapp/resources/PanelMenuGroup.js
trunk/examples/output-demo/src/main/webapp/resources/PanelMenuItem.js
Modified:
trunk/examples/output-demo/src/main/webapp/qunit/panelMenu.xhtml
trunk/ui/output/api/src/main/java/org/richfaces/PanelMenuMode.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenu.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenuGroup.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenuItem.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanelMenu.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanelMenuGroup.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanelMenuItem.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlPanelMenu.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlPanelMenuGroup.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlPanelMenuItem.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java
trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/panelMenu.ecss
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/PanelMenuGroupRendererTest.java
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup-expanded.xhtml
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup-expanded.xmlunit.xml
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup-topGroup.xmlunit.xml
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup.xhtml
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup.xmlunit.xml
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuItem.xhtml
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuItem.xmlunit.xml
Log:
RF-9317 panelMenu components
icons attributes
Modified: trunk/examples/output-demo/src/main/webapp/qunit/panelMenu.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/qunit/panelMenu.xhtml 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/examples/output-demo/src/main/webapp/qunit/panelMenu.xhtml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -50,26 +50,53 @@
<p>Page</p>
<h:form id="f" style="border:blue solid thin;">
- <pn:panelMenu id="panelMenu" expandSingle="true" activeItem="myFavariteIten">
- <pn:panelMenuGroup label="Group 1" mode="ajax" expandSingle="true">
- <pn:panelMenuItem label="Item 1.1" mode="ajax"/>
- <pn:panelMenuItem label="Item 1.2" mode="ajax"/>
- <pn:panelMenuItem label="Item 1.3" mode="ajax"/>
+ <pn:panelMenu
+ id="panelMenu"
+ expandSingle="true"
+ itemMode="ajax"
+ groupMode="ajax"
+ activeItem="myFavariteIten"
+ itemDisableIconLeft="disc"
+ groupDisableIconLeft="disc"
+ topItemDisableIconLeft="disc"
+ topGroupDisableIconLeft="disc"
+ >
+ <pn:panelMenuGroup label="Group 1">
+ <pn:panelMenuItem label="Item 1.1" />
+ <pn:panelMenuItem label="Item 1.2" />
+ <pn:panelMenuItem label="Item 1.3" />
</pn:panelMenuGroup>
- <pn:panelMenuGroup label="Group 2" mode="ajax" expandSingle="true">
- <pn:panelMenuItem label="Item 2.1" mode="ajax"/>
- <pn:panelMenuGroup label="Group 2.2" mode="ajax" expandSingle="true">
- <pn:panelMenuItem label="Item 2.2.1" mode="ajax"/>
- <pn:panelMenuItem name="myFavariteIten" label="Item 2.2.2" mode="ajax"/>
- <pn:panelMenuItem label="Item 2.2.3" mode="ajax"/>
+ <pn:panelMenuGroup
+ label="Group 2"
+ iconLeftCollapsed="triangle"
+ iconLeftExpanded="triangleDown">
+ <pn:panelMenuItem label="Item 2.1" />
+ <pn:panelMenuGroup
+ label="Group 2.2"
+ iconLeftCollapsed="chevron"
+ iconLeftExpanded="chevronDown">
+ <pn:panelMenuItem label="Item 2.2.1" />
+ <pn:panelMenuItem label="Item 2.2.2" name="myFavariteIten" />
+ <pn:panelMenuItem label="Item 2.2.3"/>
</pn:panelMenuGroup>
- <pn:panelMenuItem label="Item 2.3" mode="ajax"/>
+ <pn:panelMenuItem label="Item 2.3"/>
</pn:panelMenuGroup>
- <pn:panelMenuGroup label="Group 3" mode="ajax" expandSingle="true">
- <pn:panelMenuItem label="Item 3.1" mode="ajax"/>
- <pn:panelMenuItem label="Item 3.2" mode="ajax"/>
- <pn:panelMenuItem label="Item 3.3" mode="ajax" />
+ <pn:panelMenuGroup label="Group 3" >
+ <pn:panelMenuItem label="Item 3.1" disabled="true"/>
+ <pn:panelMenuItem label="Item 3.2"/>
+ <pn:panelMenuItem label="Item 3.3"/>
+ <pn:panelMenuGroup label="Group 3.4" disabled="true">
+ <pn:panelMenuItem label="Item 3.4.1" />
+ <pn:panelMenuItem label="Item 3.4.2" name="mySecondFavariteIten"/>
+ <pn:panelMenuItem label="Item 3.4.3"/>
+ </pn:panelMenuGroup>
</pn:panelMenuGroup>
+ <pn:panelMenuGroup label="Group 4">
+ <pn:panelMenuItem label="Item 4.1" />
+ <pn:panelMenuItem label="Item 4.2" />
+ <pn:panelMenuItem label="Item 4.3" />
+ </pn:panelMenuGroup>
+ <pn:panelMenuGroup label="Group 5" disabled="true" />
</pn:panelMenu>
</h:form>
Deleted: trunk/examples/output-demo/src/main/webapp/resources/PanelMenu.js
===================================================================
--- trunk/examples/output-demo/src/main/webapp/resources/PanelMenu.js 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/examples/output-demo/src/main/webapp/resources/PanelMenu.js 2010-12-01 15:12:38 UTC (rev 20253)
@@ -1,208 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-
-(function ($, rf) {
-
- rf.ui = rf.ui || {};
-
- var __DEFAULT_OPTIONS = {
- expandSingle : true
- };
-
- rf.ui.PanelMenu = rf.BaseComponent.extendClass({
- // class name
- name:"PanelMenu",
-
- /**
- * @class PanelMenu
- * @name PanelMenu
- *
- * @constructor
- * @param {String} componentId - component id
- * @param {Hash} options - params
- * */
- init : function (componentId, options) {
- this.id = componentId;
- this.items = [];
- this.attachToDom(componentId);
-
- this.options = $.extend({}, __DEFAULT_OPTIONS, options || {});
- this.activeItem = this.__getValueInput().value;
- this.nestingLevel = 0;
-
- var menuGroup = this;
- if (menuGroup.options.expandSingle) {
- menuGroup.__panelMenu().bind("expand", function (event) {
- menuGroup.__childGroups().each (function (index, group) {
- if (event.target.id != group.id) {
- rf.$(group.id).collapse();
- }
- });
-
- event.stopPropagation();
- });
- }
-
- if (menuGroup.activeItem) {
- this.__panelMenu().ready(function () {
- var item = menuGroup.items[menuGroup.activeItem];
- item.__select();
- item.__fireSelect();
- })
- }
-
- this.__addUserEventHandler("collapse");
- this.__addUserEventHandler("expand");
- },
-
- getItems: function () {
- return this.items;
- },
-
- getItem: function (name) {
- return this.items[name];
- },
-
- /***************************** Public Methods ****************************************************************/
- /**
- * @methodOf
- * @name PanelMenu#selectItem
- *
- * TODO ...
- *
- * @param {String} name
- * @return {void} TODO ...
- */
- selectItem: function (name) {
- // TODO implement
- },
-
- /**
- * @methodOf
- * @name PanelMenu#selectedItem
- *
- * TODO ...
- *
- * @return {String} TODO ...
- */
- selectedItem: function (id) {
- if (id != undefined) {
- var valueInput = this.__getValueInput();
- var prevActiveItem = valueInput.value;
-
- this.activeItem = id;
- valueInput.value = id;
-
- return prevActiveItem;
- } else {
- return this.activeItem;
- }
- },
-
- __getValueInput : function() {
- return document.getElementById(this.id + "-value");
- },
-
- selectItem: function (itemName) {
- // TODO
- },
-
- /**
- * @methodOf
- * @name PanelMenu#expandAll
- *
- * TODO ...
- *
- * @return {void} TODO ...
- */
- expandAll: function () {
- // TODO implement
- },
-
- /**
- * @methodOf
- * @name PanelMenu#collapseAll
- *
- * TODO ...
- *
- * @return {void} TODO ...
- */
- collapseAll: function () {
- // TODO implement
- },
-
- /**
- * @methodOf
- * @name PanelMenu#expandGroup
- *
- * TODO ...
- *
- * @param {String} groupName
- * @return {void} TODO ...
- */
- expandGroup: function (groupName) {
- // TODO implement
- },
-
- /**
- * @methodOf
- * @name PanelMenu#collapseGroup
- *
- * TODO ...
- *
- * @param {String} groupName
- * @return {void} TODO ...
- */
- collapseGroup: function (groupName) {
- // TODO implement
- },
-
-
- /***************************** Private Methods ****************************************************************/
-
-
- __panelMenu : function () {
- return $(rf.getDomElement(this.id));
- },
-
- __childGroups : function () {
- return this.__panelMenu().children(".rf-pm-top-gr")
- },
-
- /**
- * @private
- * */
- __addUserEventHandler : function (name) {
- var handler = this.options["on" + name];
- if (handler) {
- rf.Event.bindById(this.id, name, handler);
- }
- },
-
- destroy: function () {
- rf.Event.unbindById(this.id, "."+this.namespace);
-
- this.$super.destroy.call(this);
- }
- });
-})(jQuery, RichFaces);
Deleted: trunk/examples/output-demo/src/main/webapp/resources/PanelMenuGroup.js
===================================================================
--- trunk/examples/output-demo/src/main/webapp/resources/PanelMenuGroup.js 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/examples/output-demo/src/main/webapp/resources/PanelMenuGroup.js 2010-12-01 15:12:38 UTC (rev 20253)
@@ -1,355 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-
-(function ($, rf) {
-
- rf.ui = rf.ui || {};
-
- var __DEFAULT_OPTIONS = {
- expanded : false,
- expandSingle : true,
- bubbleSelection : true,
- stylePrefix : "rf-pm-gr",
-
- // TODO we should use selectionType = {none, selectable, unselectable}
- selectable : false,
- unselectable : false // unselectable can be only selectable item => if selectable == false than unselectable = false
- };
-
- var EXPAND_ITEM = {
-
- /**
- *
- * @return {void}
- * */
- exec : function (group, expand) {
- var mode = group.mode;
- if (mode == "server") {
- return this.execServer(group);
- } else if (mode == "ajax") {
- return this.execAjax(group);
- } else if (mode == "client" || mode == "none") {
- return this.execClient(group, expand);
- } else {
- rf.log.error("EXPAND_ITEM.exec : unknown mode (" + mode + ")");
- }
- },
-
- /**
- * @protected
- *
- * @return {Boolean} false
- * */
- execServer : function (group) {
- group.__changeState();
- rf.submitForm(this.__getParentForm(group));
-
- return false;
- },
-
- /**
- * @protected
- *
- * @return {Boolean} false
- * */
- execAjax : function (group) {
- var oldState = group.__changeState();
- rf.ajax(group.id, null, $.extend({}, group.options["ajax"], {}));
- group.__restoreState(oldState);
-
- return true;
- },
-
- /**
- * @protected
- *
- * @param {PanelMenuGroup} group
- * @param {Boolean} expand
- * @return {undefined}
- * - false - if process has been terminated
- * - true - in other cases
- * */
- execClient : function (group, expand) {
- if (expand) {
- group.expand();
- } else {
- group.collapse();
- }
-
- return group.__fireSwitch();
- },
-
- /**
- * @private
- * */
- __getParentForm : function (item) {
- return $($(rf.getDomElement(item.id)).parents("form")[0]);
- }
- };
-
- rf.ui.PanelMenuGroup = rf.ui.PanelMenuItem.extendClass({
- // class name
- name:"PanelMenuGroup",
-
- /**
- * @class PanelMenuGroup
- * @name PanelMenuGroup
- *
- * @constructor
- * @param {String} componentId - component id
- * @param {Hash} options - params
- * */
- init : function (componentId, options) {
- this.options = $.extend({}, __DEFAULT_OPTIONS, options || {});
-
- rf.ui.PanelMenuItem.call(this, componentId);
-
- if (!this.options.disabled) {
- var menuGroup = this;
-
- if (!this.options.selectable) {
- this.__header().bind("click", function () {
- return menuGroup.switchExpantion();
- });
- }
-
- if (this.options.selectable || this.options.bubbleSelection) {
- this.__content().bind("select", function (event) {
- if (menuGroup.options.selectable && menuGroup.__isMyEvent(event)) {
- menuGroup.expand();
- }
-
- if (menuGroup.options.bubbleSelection && !menuGroup.__isMyEvent(event)) {
- menuGroup.__select();
- if (!menuGroup.expanded()) {
- menuGroup.expand();
- }
- }
- });
-
- this.__content().bind("unselect", function (event) {
- if (menuGroup.options.selectable && menuGroup.__isMyEvent(event)) {
- menuGroup.collapse();
- }
-
- if (menuGroup.options.bubbleSelection && !menuGroup.__isMyEvent(event)) {
- menuGroup.__unselect();
- }
- });
- }
-
- if (menuGroup.options.expandSingle) {
- menuGroup.__group().bind("expand", function (event) {
- if (menuGroup.__isMyEvent(event)) {
- return;
- }
-
- menuGroup.__childGroups().each (function (index, group) {
- var rfGroup = rf.$(group);
- if (!rfGroup.__isMyEvent(event)) {
- rfGroup.collapse();
- }
- });
-
- event.stopPropagation();
- });
- }
-
- this.__addUserEventHandler("collapse");
- this.__addUserEventHandler("expand");
- }
- },
-
- /***************************** Public Methods ****************************************************************/
- expanded : function () {
- // TODO check invariant in dev mode
- // return this.__content().hasClass("rf-pm-exp")
- return this.__getExpandValue();
- },
-
- expand : function () {
- this.__expand();
-
- return this.__fireExpand();
- },
-
- __expand : function () {
- this.__content().removeClass("rf-pm-colps").addClass("rf-pm-exp");
- this.__setExpandValue(true);
- },
-
- collapsed : function () {
- // TODO check invariant in dev mode
- // return this.__content().hasClass("rf-pm-colps")
- return !this.__getExpandValue();
- },
-
- collapse : function () {
- this.__collapse();
-
- this.__childGroups().each (function(index, group) {
- rf.$(group.id).__collapse();
- });
-
- this.__fireCollapse();
- },
-
- __collapse : function () {
- this.__content().addClass("rf-pm-colps").removeClass("rf-pm-exp");
- this.__setExpandValue(false);
- },
-
- /**
- * @methodOf
- * @name PanelMenuGroup#switch
- *
- * TODO ...
- *
- * @param {boolean} expand
- * @return {void} TODO ...
- */
- switchExpantion : function () { // TODO rename
- var continueProcess = this.__fireBeforeSwitch();
- if (!continueProcess) {
- return false;
- }
-
- EXPAND_ITEM.exec(this, !this.expanded());
- },
-
- /**
- * please, remove this method when client side ajax events will be added
- *
- * */
- onCompleteHandler : function () {
- EXPAND_ITEM.execClient(this, this.expanded());
- },
-
- __switch : function (expand) {
- if (expand) {
- this.expand();
- } else {
- this.collapse();
- }
- },
-
- /***************************** Private Methods ****************************************************************/
- __childGroups : function () {
- return this.__content().children(".rf-pm-gr")
- },
-
- __group : function () {
- return $(rf.getDomElement(this.id))
- },
-
- __header : function () {
- return $(rf.getDomElement(this.id + ":hdr"))
- },
-
- __content : function () {
- return $(rf.getDomElement(this.id + ":cnt"))
- },
-
- __expandValueInput : function () {
- return document.getElementById(this.id + ":expanded");
- },
-
- __getExpandValue : function () {
- return this.__expandValueInput().value == "true";
- },
-
- /**
- * @methodOf
- * @name PanelMenuGroup#__setExpandValue
- *
- * @param {boolean} value - is group expanded?
- * @return {boolean} preview value
- */
- __setExpandValue : function (value) {
- var input = this.__expandValueInput();
- var oldValue = input.value;
-
- input.value = value;
-
- return oldValue;
- },
-
- __changeState : function () {
- var state = {};
- state["expanded"] = this.__setExpandValue(!this.__getExpandValue());
- if (this.options.selectable) {
- state["itemName"] = this.__rfPanelMenu().selectedItem(this.itemName); // TODO bad function name for function which change component state
- }
-
- return state;
- },
-
- __restoreState : function (state) {
- if (!state) {
- return;
- }
-
- if (state["expanded"]) {
- this.__setExpandValue(state["expanded"]);
- }
-
- if (state["itemName"]) {
- this.__rfPanelMenu().selectedItem(state["itemName"]);
- }
- },
-
- __fireSwitch : function () {
- return new rf.Event.fireById(this.id, "switch", {
- id: this.id
- });
- },
-
- __isMyEvent: function (event) {
- return this.id == event.target.id;
- },
-
- __fireBeforeSwitch : function () {
- return rf.Event.fireById(this.id, "beforeswitch", {
- id: this.id
- });
- },
-
- __fireCollapse : function () {
- return new rf.Event.fireById(this.id, "collapse", {
- id: this.id
- });
- },
-
- __fireExpand : function () {
- return new rf.Event.fireById(this.id, "expand", {
- id: this.id
- });
- },
-
- destroy: function () {
- rf.Event.unbindById(this.id, "."+this.namespace);
-
- this.$super.destroy.call(this);
- }
- });
-})(jQuery, RichFaces);
Deleted: trunk/examples/output-demo/src/main/webapp/resources/PanelMenuItem.js
===================================================================
--- trunk/examples/output-demo/src/main/webapp/resources/PanelMenuItem.js 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/examples/output-demo/src/main/webapp/resources/PanelMenuItem.js 2010-12-01 15:12:38 UTC (rev 20253)
@@ -1,319 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-
-(function ($, rf) {
-
- rf.ui = rf.ui || {};
-
- var __DEFAULT_OPTIONS = {
- disabled : false,
- selectable: true,
- mode: "client",
- unselectable: false,
- highlight: true,
- stylePrefix: "rf-pm-itm",
- itemStep: 20
- };
-
- var SELECT_ITEM = {
-
- /**
- *
- * @return {void}
- * */
- exec : function (item) {
- var mode = item.mode;
- if (mode == "server") {
- return this.execServer(item);
- } else if (mode == "ajax") {
- return this.execAjax(item);
- } else if (mode == "client" || mode == "none") {
- return this.execClient(item);
- } else {
- rf.log.error("SELECT_ITEM.exec : unknown mode (" + mode + ")");
- }
- },
-
- /**
- * @protected
- *
- * @return {Boolean} false
- * */
- execServer : function (item) {
- item.__changeState();
- rf.submitForm(this.__getParentForm(item));
-
- return false;
- },
-
- /**
- * @protected
- *
- * @return {Boolean} false
- * */
- execAjax : function (item) {
- var oldItem = item.__changeState();
- rf.ajax(item.__panelMenu().id, null, $.extend({}, item.options["ajax"], {}));
- item.__restoreState(oldItem);
-
- return true;
- },
-
- /**
- * @protected
- *
- * @return {undefined}
- * - false - if process has been terminated
- * - true - in other cases
- * */
- execClient : function (item) {
- var panelMenu = item.__rfPanelMenu();
- if (panelMenu.selectedItem()) {
- panelMenu.getItems()[panelMenu.selectedItem()].unselect();
- }
- panelMenu.selectedItem(item.itemName);
-
- item.__select();
-
- return item.__fireSelect();
- },
-
- /**
- * @private
- * */
- __getParentForm : function (item) {
- return $($(rf.getDomElement(item.id)).parents("form")[0]);
- }
- };
-
- rf.ui.PanelMenuItem = rf.BaseComponent.extendClass({
- // class name
- name:"PanelMenuItem",
-
- /**
- * @class PanelMenuItem
- * @name PanelMenuItem
- *
- * @constructor
- * @param {String} componentId - component id
- * @param {Hash} options - params
- * */
- init : function (componentId, options) {
- this.id = componentId;
- this.attachToDom(componentId);
-
- this.options = $.extend({}, __DEFAULT_OPTIONS, this.options || {}, options || {});
-
- this.mode = this.options.mode
- this.itemName = this.options.name
- this.__rfPanelMenu().getItems()[this.itemName] = this;
-
- // todo move it
- this.selectionClass = this.options.stylePrefix + "-sel";
- this.hoverClass = this.options.stylePrefix + "-hov";
-
- if (!this.options.disabled) {
- var item = this;
- if (this.options.highlight) {
- this.__item().bind("mouseenter", function() {
- item.highlight(true);
- });
- this.__item().bind("mouseleave", function() {
- item.highlight(false);
- });
- }
-
- if (this.options.selectable) {
- this.__header().bind("click", function() {
- if (item.__rfPanelMenu().selectedItem() == item.id) {
- if (item.options.unselectable) {
- return item.unselect();
- }
-
- // we shouldn't select one item several times
- } else {
- return item.select();
- }
- });
- }
- }
-
- item = this;
- $(this.__panelMenu()).ready(function () {
- item.__renderNestingLevel();
- });
-
- this.__addUserEventHandler("select");
- },
-
- /***************************** Public Methods ****************************************************************/
- highlight : function (highlight) {
- if (highlight && !this.selected()) {
- this.__header().addClass(this.hoverClass);
- } else {
- this.__header().removeClass(this.hoverClass);
- }
- },
-
- selected : function () {
- return this.__header().hasClass(this.selectionClass);
- },
-
- /**
- * @methodOf
- * @name PanelMenuItem#select
- *
- * TODO ...
- *
- * @return {void} TODO ...
- */
- select: function () {
- var continueProcess = this.__fireBeforeSelect();
- if (!continueProcess) {
- return false;
- }
-
- return SELECT_ITEM.exec(this)
- },
-
- /**
- * please, remove this method when client side ajax events will be added
- *
- * */
- onCompleteHandler : function () {
- SELECT_ITEM.execClient(this);
- },
-
- unselect: function () {
- var panelMenu = this.__rfPanelMenu();
- if (panelMenu.selectedItem() == this.itemName) {
- panelMenu.selectedItem(null);
- } else {
- rf.warn("You try unselect item (name=" + this.itemName + ") that isn't seleted")
- }
-
- this.__unselect();
-
- return this.__fireUnselect();
- },
-
- /***************************** Private Methods ****************************************************************/
- __rfParentItem : function () {
- var res = this.__item().parents(".rf-pm-gr")[0];
- if (!res) {
- res = this.__item().parents(".rf-pm-top-gr")[0];
- }
-
- if (!res) {
- res = this.__panelMenu();
- }
-
- return res ? rf.$(res) : null;
- },
-
- __getNestingLevel : function () {
- if (!this.nestingLevel) {
- var parentItem = this.__rfParentItem();
- if (parentItem && parentItem.__getNestingLevel) {
- this.nestingLevel = parentItem.__getNestingLevel() + 1;
- } else {
- this.nestingLevel = 0;
- }
- }
-
- return this.nestingLevel;
- },
-
- __renderNestingLevel : function () {
- this.__item().find("td").first().css("padding-left", this.options.itemStep * this.__getNestingLevel());
- },
-
- __panelMenu : function () {
- return this.__item().parents(".rf-pm")[0];
- },
-
- __rfPanelMenu : function () {
- return rf.$(this.__item().parents(".rf-pm")[0]);
- },
-
- __changeState : function () {
- return this.__rfPanelMenu().selectedItem(this.itemName);
- },
-
- __restoreState : function (state) {
- if (state) {
- this.__rfPanelMenu().selectedItem(state);
- }
- },
-
- __item : function () {
- return $(rf.getDomElement(this.id));
- },
-
- __header : function () {
- return this.__item();
- },
-
- __select: function () {
- this.__header().addClass(this.selectionClass);
- },
-
- __unselect: function () {
- this.__header().removeClass(this.selectionClass);
- },
-
- __fireBeforeSelect : function () {
- return new rf.Event.fireById(this.id, "beforeselect", {
- id: this.id
- });
- },
-
- __fireSelect : function () {
- return new rf.Event.fireById(this.id, "select", {
- id: this.id
- });
- },
-
- __fireUnselect : function () {
- return new rf.Event.fireById(this.id, "unselect", {
- id: this.id
- });
- },
-
- /**
- * @private
- * */
- __addUserEventHandler : function (name) {
- var handler = this.options["on" + name];
- if (handler) {
- rf.Event.bindById(this.id, name, handler);
- }
- },
-
- destroy: function () {
- delete this.__rfPanelMenu().getItems()[this.itemName];
-
- rf.ui.PanelMenuItem.$super.destroy.call(this);
- }
- });
-})(jQuery, RichFaces);
Modified: trunk/ui/output/api/src/main/java/org/richfaces/PanelMenuMode.java
===================================================================
--- trunk/ui/output/api/src/main/java/org/richfaces/PanelMenuMode.java 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/api/src/main/java/org/richfaces/PanelMenuMode.java 2010-12-01 15:12:38 UTC (rev 20253)
@@ -6,7 +6,8 @@
*/
public enum PanelMenuMode {
ajax,
- server;
+ server,
+ client;
- public static final PanelMenuMode DEFAULT = server;
+ public static final PanelMenuMode DEFAULT = ajax;
}
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenu.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenu.java 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenu.java 2010-12-01 15:12:38 UTC (rev 20253)
@@ -23,7 +23,6 @@
package org.richfaces.component;
-import org.richfaces.ExpandMode;
import org.richfaces.PanelMenuMode;
import org.richfaces.event.ItemChangeEvent;
@@ -168,7 +167,7 @@
public abstract String getCollapseEvent();
- public abstract ExpandMode getGroupMode();
+ public abstract PanelMenuMode getGroupMode();
public abstract boolean isExpandSingle();
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenuGroup.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenuGroup.java 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenuGroup.java 2010-12-01 15:12:38 UTC (rev 20253)
@@ -161,20 +161,13 @@
- public abstract boolean getBubbleSelection();
-
public abstract boolean isExpandSingle();
public abstract String getCollapseEvent();
public abstract String getExpandEvent();
- public abstract String getIconCollapsed();
+ public abstract boolean isBubbleSelection();
- public abstract String getIconExpanded();
-
public abstract String getChangeExpandListener();
-
-
-
}
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenuItem.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenuItem.java 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenuItem.java 2010-12-01 15:12:38 UTC (rev 20253)
@@ -47,7 +47,7 @@
triangle("rf-pm-triangle"),
triangleUp("rf-pm-triangle-up"),
triangleDown("rf-pm-triangle-down");
-
+
public static final Icons DEFAULT = grid;
private final String cssClass;
@@ -101,8 +101,6 @@
return COMPONENT_FAMILY;
}
- public abstract String getIcon();
-
public abstract PanelMenuMode getMode();
public abstract String getLabel();
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanelMenu.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanelMenu.java 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanelMenu.java 2010-12-01 15:12:38 UTC (rev 20253)
@@ -23,12 +23,11 @@
package org.richfaces.component;
-import org.richfaces.ExpandMode;
import org.richfaces.PanelMenuMode;
/**
* @author akolonitsky
- * @since 2010-10-25
+ * @since 2010-11-29
*/
public class UIPanelMenu extends AbstractPanelMenu {
@@ -40,6 +39,7 @@
expandSingle,
itemMode,
bubbleSelection,
+ activeItem,
itemChangeListener,
bypassUpdates,
limitToList,
@@ -73,11 +73,11 @@
getStateHelper().put(PropertyKeys.collapseEvent, collapseEvent);
}
- public ExpandMode getGroupMode() {
- return (ExpandMode) getStateHelper().eval(PropertyKeys.groupMode, ExpandMode.DEFAULT);
+ public PanelMenuMode getGroupMode() {
+ return (PanelMenuMode) getStateHelper().eval(PropertyKeys.groupMode, PanelMenuMode.client);
}
- public void setGroupMode(ExpandMode groupMode) {
+ public void setGroupMode(PanelMenuMode groupMode) {
getStateHelper().put(PropertyKeys.groupMode, groupMode);
}
@@ -105,6 +105,14 @@
getStateHelper().put(PropertyKeys.bubbleSelection, bubbleSelection);
}
+ public String getActiveItem() {
+ return (String) getStateHelper().eval(PropertyKeys.activeItem);
+ }
+
+ public void setActiveItem(String activeItem) {
+ getStateHelper().put(PropertyKeys.activeItem, activeItem);
+ }
+
public String getItemChangeListener() {
return (String) getStateHelper().eval(PropertyKeys.itemChangeListener);
}
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanelMenuGroup.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanelMenuGroup.java 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanelMenuGroup.java 2010-12-01 15:12:38 UTC (rev 20253)
@@ -23,8 +23,8 @@
package org.richfaces.component;
+import org.richfaces.PanelMenuMode;
-
/**
* @author akolonitsky
* @since 2010-10-25
@@ -32,28 +32,26 @@
public class UIPanelMenuGroup extends AbstractPanelMenuGroup {
public enum PropertyKeys {
- bubbleSelection,
expanded,
expandSingle,
collapseEvent,
expandEvent,
- iconCollapsed,
- iconExpanded,
+ bubbleSelection,
changeExpandListener
}
-
-
- public boolean getBubbleSelection() {
- return Boolean.valueOf(String.valueOf(getStateHelper().eval(PropertyKeys.bubbleSelection, true)));
+ @Override
+ public PanelMenuMode getMode() {
+ return (PanelMenuMode) getStateHelper().eval(UIPanelMenuItem.PropertyKeys.mode, getPanelMenu().getGroupMode());
}
- public void setBubbleSelection(boolean bubbleSelection) {
- getStateHelper().put(PropertyKeys.bubbleSelection, bubbleSelection);
+ @Override
+ public void setMode(PanelMenuMode mode) {
+ super.setMode(mode); //To change body of overridden methods use File | Settings | File Templates.
}
public boolean isExpandSingle() {
- return Boolean.valueOf(String.valueOf(getStateHelper().eval(PropertyKeys.expandSingle, true)));
+ return Boolean.valueOf(String.valueOf(getStateHelper().eval(PropertyKeys.expandSingle, getPanelMenu().isExpandSingle())));
}
public void setExpandSingle(boolean expandSingle) {
@@ -76,22 +74,14 @@
getStateHelper().put(PropertyKeys.expandEvent, expandEvent);
}
- public String getIconCollapsed() {
- return (String) getStateHelper().eval(PropertyKeys.iconCollapsed);
+ public boolean isBubbleSelection() {
+ return Boolean.valueOf(String.valueOf(getStateHelper().eval(PropertyKeys.bubbleSelection, getPanelMenu().isBubbleSelection())));
}
- public void setIconCollapsed(String iconCollapsed) {
- getStateHelper().put(PropertyKeys.iconCollapsed, iconCollapsed);
+ public void setBubbleSelection(boolean bubbleSelection) {
+ getStateHelper().put(PropertyKeys.bubbleSelection, bubbleSelection);
}
- public String getIconExpanded() {
- return (String) getStateHelper().eval(PropertyKeys.iconExpanded);
- }
-
- public void setIconExpanded(String iconExpanded) {
- getStateHelper().put(PropertyKeys.iconExpanded, iconExpanded);
- }
-
public String getChangeExpandListener() {
return (String) getStateHelper().eval(PropertyKeys.changeExpandListener);
}
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanelMenuItem.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanelMenuItem.java 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanelMenuItem.java 2010-12-01 15:12:38 UTC (rev 20253)
@@ -27,12 +27,11 @@
/**
* @author akolonitsky
- * @since 2010-10-25
+ * @since 2010-11-29
*/
public class UIPanelMenuItem extends AbstractPanelMenuItem {
public enum PropertyKeys {
- icon,
mode,
label,
name,
@@ -45,16 +44,8 @@
render
}
- public String getIcon() {
- return (String) getStateHelper().eval(PropertyKeys.icon, Icons.DEFAULT.toString());
- }
-
- public void setIcon(String icon) {
- getStateHelper().put(PropertyKeys.icon, icon);
- }
-
public PanelMenuMode getMode() {
- return (PanelMenuMode) getStateHelper().eval(PropertyKeys.mode, PanelMenuMode.DEFAULT);
+ return (PanelMenuMode) getStateHelper().eval(PropertyKeys.mode, getPanelMenu().getItemMode());
}
public void setMode(PanelMenuMode mode) {
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlPanelMenu.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlPanelMenu.java 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlPanelMenu.java 2010-12-01 15:12:38 UTC (rev 20253)
@@ -24,15 +24,17 @@
package org.richfaces.component.html;
import org.richfaces.component.UIPanelMenu;
+
import javax.faces.component.behavior.ClientBehaviorHolder;
-
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import static org.richfaces.component.AbstractPanelMenuItem.Icons;
+
/**
* @author akolonitsky
- * @since 2010-10-25
+ * @since 2010-11-29
*/
public class HtmlPanelMenu extends UIPanelMenu implements ClientBehaviorHolder {
@@ -56,31 +58,33 @@
styleClass,
width,
itemClass,
- itemHoverClass,
itemDisableClass,
- itemIcon,
- itemDisableIcon,
- itemIconPosition,
+ itemIconLeft,
+ itemIconRight,
+ itemDisableIconLeft,
+ itemDisableIconRight,
topItemClass,
- topItemHoverClass,
topItemDisableClass,
- topItemIcon,
- topItemDisableIcon,
- topItemIconPosition,
+ topItemIconLeft,
+ topItemIconRight,
+ topItemDisableIconLeft,
+ topItemDisableIconRight,
groupClass,
- groupHoverClass,
groupDisableClass,
- groupCollapseIcon,
- groupExpandIcon,
- groupDisableIcon,
- groupIconPosition,
+ groupExpandIconLeft,
+ groupExpandIconRight,
+ groupCollapseIconLeft,
+ groupCollapseIconRight,
+ groupDisableIconLeft,
+ groupDisableIconRight,
topGroupClass,
- topGroupHoverClass,
topGroupDisableClass,
- topGroupCollapseIcon,
- topGroupExpandIcon,
- topGroupDisableIcon,
- topGroupIconPosition,
+ topGroupExpandIconLeft,
+ topGroupExpandIconRight,
+ topGroupCollapseIconLeft,
+ topGroupCollapseIconRight,
+ topGroupDisableIconLeft,
+ topGroupDisableIconRight,
onclick,
ondblclick,
onmousedown,
@@ -131,14 +135,6 @@
getStateHelper().put(PropertyKeys.itemClass, itemClass);
}
- public String getItemHoverClass() {
- return (String) getStateHelper().eval(PropertyKeys.itemHoverClass);
- }
-
- public void setItemHoverClass(String itemHoverClass) {
- getStateHelper().put(PropertyKeys.itemHoverClass, itemHoverClass);
- }
-
public String getItemDisableClass() {
return (String) getStateHelper().eval(PropertyKeys.itemDisableClass);
}
@@ -147,30 +143,38 @@
getStateHelper().put(PropertyKeys.itemDisableClass, itemDisableClass);
}
- public String getItemIcon() {
- return (String) getStateHelper().eval(PropertyKeys.itemIcon);
+ public String getItemIconLeft() {
+ return (String) getStateHelper().eval(PropertyKeys.itemIconLeft, Icons.DEFAULT.toString());
}
- public void setItemIcon(String itemIcon) {
- getStateHelper().put(PropertyKeys.itemIcon, itemIcon);
+ public void setItemIconLeft(String itemIconLeft) {
+ getStateHelper().put(PropertyKeys.itemIconLeft, itemIconLeft);
}
- public String getItemDisableIcon() {
- return (String) getStateHelper().eval(PropertyKeys.itemDisableIcon);
+ public String getItemIconRight() {
+ return (String) getStateHelper().eval(PropertyKeys.itemIconRight, Icons.DEFAULT.toString());
}
- public void setItemDisableIcon(String itemDisableIcon) {
- getStateHelper().put(PropertyKeys.itemDisableIcon, itemDisableIcon);
+ public void setItemIconRight(String itemIconRight) {
+ getStateHelper().put(PropertyKeys.itemIconRight, itemIconRight);
}
- public String getItemIconPosition() {
- return (String) getStateHelper().eval(PropertyKeys.itemIconPosition);
+ public String getItemDisableIconLeft() {
+ return (String) getStateHelper().eval(PropertyKeys.itemDisableIconLeft, Icons.DEFAULT.toString());
}
- public void setItemIconPosition(String itemIconPosition) {
- getStateHelper().put(PropertyKeys.itemIconPosition, itemIconPosition);
+ public void setItemDisableIconLeft(String itemDisableIconLeft) {
+ getStateHelper().put(PropertyKeys.itemDisableIconLeft, itemDisableIconLeft);
}
+ public String getItemDisableIconRight() {
+ return (String) getStateHelper().eval(PropertyKeys.itemDisableIconRight, Icons.DEFAULT.toString());
+ }
+
+ public void setItemDisableIconRight(String itemDisableIconRight) {
+ getStateHelper().put(PropertyKeys.itemDisableIconRight, itemDisableIconRight);
+ }
+
public String getTopItemClass() {
return (String) getStateHelper().eval(PropertyKeys.topItemClass);
}
@@ -179,14 +183,6 @@
getStateHelper().put(PropertyKeys.topItemClass, topItemClass);
}
- public String getTopItemHoverClass() {
- return (String) getStateHelper().eval(PropertyKeys.topItemHoverClass);
- }
-
- public void setTopItemHoverClass(String topItemHoverClass) {
- getStateHelper().put(PropertyKeys.topItemHoverClass, topItemHoverClass);
- }
-
public String getTopItemDisableClass() {
return (String) getStateHelper().eval(PropertyKeys.topItemDisableClass);
}
@@ -195,30 +191,38 @@
getStateHelper().put(PropertyKeys.topItemDisableClass, topItemDisableClass);
}
- public String getTopItemIcon() {
- return (String) getStateHelper().eval(PropertyKeys.topItemIcon);
+ public String getTopItemIconLeft() {
+ return (String) getStateHelper().eval(PropertyKeys.topItemIconLeft, Icons.DEFAULT.toString());
}
- public void setTopItemIcon(String topItemIcon) {
- getStateHelper().put(PropertyKeys.topItemIcon, topItemIcon);
+ public void setTopItemIconLeft(String topItemIconLeft) {
+ getStateHelper().put(PropertyKeys.topItemIconLeft, topItemIconLeft);
}
- public String getTopItemDisableIcon() {
- return (String) getStateHelper().eval(PropertyKeys.topItemDisableIcon);
+ public String getTopItemIconRight() {
+ return (String) getStateHelper().eval(PropertyKeys.topItemIconRight, Icons.DEFAULT.toString());
}
- public void setTopItemDisableIcon(String topItemDisableIcon) {
- getStateHelper().put(PropertyKeys.topItemDisableIcon, topItemDisableIcon);
+ public void setTopItemIconRight(String topItemIconRight) {
+ getStateHelper().put(PropertyKeys.topItemIconRight, topItemIconRight);
}
- public String getTopItemIconPosition() {
- return (String) getStateHelper().eval(PropertyKeys.topItemIconPosition);
+ public String getTopItemDisableIconLeft() {
+ return (String) getStateHelper().eval(PropertyKeys.topItemDisableIconLeft, Icons.DEFAULT.toString());
}
- public void setTopItemIconPosition(String topItemIconPosition) {
- getStateHelper().put(PropertyKeys.topItemIconPosition, topItemIconPosition);
+ public void setTopItemDisableIconLeft(String topItemDisableIconLeft) {
+ getStateHelper().put(PropertyKeys.topItemDisableIconLeft, topItemDisableIconLeft);
}
+ public String getTopItemDisableIconRight() {
+ return (String) getStateHelper().eval(PropertyKeys.topItemDisableIconRight, Icons.DEFAULT.toString());
+ }
+
+ public void setTopItemDisableIconRight(String topItemDisableIconRight) {
+ getStateHelper().put(PropertyKeys.topItemDisableIconRight, topItemDisableIconRight);
+ }
+
public String getGroupClass() {
return (String) getStateHelper().eval(PropertyKeys.groupClass);
}
@@ -227,14 +231,6 @@
getStateHelper().put(PropertyKeys.groupClass, groupClass);
}
- public String getGroupHoverClass() {
- return (String) getStateHelper().eval(PropertyKeys.groupHoverClass);
- }
-
- public void setGroupHoverClass(String groupHoverClass) {
- getStateHelper().put(PropertyKeys.groupHoverClass, groupHoverClass);
- }
-
public String getGroupDisableClass() {
return (String) getStateHelper().eval(PropertyKeys.groupDisableClass);
}
@@ -243,38 +239,54 @@
getStateHelper().put(PropertyKeys.groupDisableClass, groupDisableClass);
}
- public String getGroupCollapseIcon() {
- return (String) getStateHelper().eval(PropertyKeys.groupCollapseIcon);
+ public String getGroupExpandIconLeft() {
+ return (String) getStateHelper().eval(PropertyKeys.groupExpandIconLeft, Icons.DEFAULT.toString());
}
- public void setGroupCollapseIcon(String groupCollapseIcon) {
- getStateHelper().put(PropertyKeys.groupCollapseIcon, groupCollapseIcon);
+ public void setGroupExpandIconLeft(String groupExpandIconLeft) {
+ getStateHelper().put(PropertyKeys.groupExpandIconLeft, groupExpandIconLeft);
}
- public String getGroupExpandIcon() {
- return (String) getStateHelper().eval(PropertyKeys.groupExpandIcon);
+ public String getGroupExpandIconRight() {
+ return (String) getStateHelper().eval(PropertyKeys.groupExpandIconRight, Icons.DEFAULT.toString());
}
- public void setGroupExpandIcon(String groupExpandIcon) {
- getStateHelper().put(PropertyKeys.groupExpandIcon, groupExpandIcon);
+ public void setGroupExpandIconRight(String groupExpandIconRight) {
+ getStateHelper().put(PropertyKeys.groupExpandIconRight, groupExpandIconRight);
}
- public String getGroupDisableIcon() {
- return (String) getStateHelper().eval(PropertyKeys.groupDisableIcon);
+ public String getGroupCollapseIconLeft() {
+ return (String) getStateHelper().eval(PropertyKeys.groupCollapseIconLeft, Icons.DEFAULT.toString());
}
- public void setGroupDisableIcon(String groupDisableIcon) {
- getStateHelper().put(PropertyKeys.groupDisableIcon, groupDisableIcon);
+ public void setGroupCollapseIconLeft(String groupCollapseIconLeft) {
+ getStateHelper().put(PropertyKeys.groupCollapseIconLeft, groupCollapseIconLeft);
}
- public String getGroupIconPosition() {
- return (String) getStateHelper().eval(PropertyKeys.groupIconPosition);
+ public String getGroupCollapseIconRight() {
+ return (String) getStateHelper().eval(PropertyKeys.groupCollapseIconRight, Icons.DEFAULT.toString());
}
- public void setGroupIconPosition(String groupIconPosition) {
- getStateHelper().put(PropertyKeys.groupIconPosition, groupIconPosition);
+ public void setGroupCollapseIconRight(String groupCollapseIconRight) {
+ getStateHelper().put(PropertyKeys.groupCollapseIconRight, groupCollapseIconRight);
}
+ public String getGroupDisableIconLeft() {
+ return (String) getStateHelper().eval(PropertyKeys.groupDisableIconLeft, Icons.DEFAULT.toString());
+ }
+
+ public void setGroupDisableIconLeft(String groupDisableIconLeft) {
+ getStateHelper().put(PropertyKeys.groupDisableIconLeft, groupDisableIconLeft);
+ }
+
+ public String getGroupDisableIconRight() {
+ return (String) getStateHelper().eval(PropertyKeys.groupDisableIconRight, Icons.DEFAULT.toString());
+ }
+
+ public void setGroupDisableIconRight(String groupDisableIconRight) {
+ getStateHelper().put(PropertyKeys.groupDisableIconRight, groupDisableIconRight);
+ }
+
public String getTopGroupClass() {
return (String) getStateHelper().eval(PropertyKeys.topGroupClass);
}
@@ -283,14 +295,6 @@
getStateHelper().put(PropertyKeys.topGroupClass, topGroupClass);
}
- public String getTopGroupHoverClass() {
- return (String) getStateHelper().eval(PropertyKeys.topGroupHoverClass);
- }
-
- public void setTopGroupHoverClass(String topGroupHoverClass) {
- getStateHelper().put(PropertyKeys.topGroupHoverClass, topGroupHoverClass);
- }
-
public String getTopGroupDisableClass() {
return (String) getStateHelper().eval(PropertyKeys.topGroupDisableClass);
}
@@ -299,38 +303,54 @@
getStateHelper().put(PropertyKeys.topGroupDisableClass, topGroupDisableClass);
}
- public String getTopGroupCollapseIcon() {
- return (String) getStateHelper().eval(PropertyKeys.topGroupCollapseIcon);
+ public String getTopGroupExpandIconLeft() {
+ return (String) getStateHelper().eval(PropertyKeys.topGroupExpandIconLeft, Icons.DEFAULT.toString());
}
- public void setTopGroupCollapseIcon(String topGroupCollapseIcon) {
- getStateHelper().put(PropertyKeys.topGroupCollapseIcon, topGroupCollapseIcon);
+ public void setTopGroupExpandIconLeft(String topGroupExpandIconLeft) {
+ getStateHelper().put(PropertyKeys.topGroupExpandIconLeft, topGroupExpandIconLeft);
}
- public String getTopGroupExpandIcon() {
- return (String) getStateHelper().eval(PropertyKeys.topGroupExpandIcon);
+ public String getTopGroupExpandIconRight() {
+ return (String) getStateHelper().eval(PropertyKeys.topGroupExpandIconRight, Icons.DEFAULT.toString());
}
- public void setTopGroupExpandIcon(String topGroupExpandIcon) {
- getStateHelper().put(PropertyKeys.topGroupExpandIcon, topGroupExpandIcon);
+ public void setTopGroupExpandIconRight(String topGroupExpandIconRight) {
+ getStateHelper().put(PropertyKeys.topGroupExpandIconRight, topGroupExpandIconRight);
}
- public String getTopGroupDisableIcon() {
- return (String) getStateHelper().eval(PropertyKeys.topGroupDisableIcon);
+ public String getTopGroupCollapseIconLeft() {
+ return (String) getStateHelper().eval(PropertyKeys.topGroupCollapseIconLeft, Icons.DEFAULT.toString());
}
- public void setTopGroupDisableIcon(String topGroupDisableIcon) {
- getStateHelper().put(PropertyKeys.topGroupDisableIcon, topGroupDisableIcon);
+ public void setTopGroupCollapseIconLeft(String topGroupCollapseIconLeft) {
+ getStateHelper().put(PropertyKeys.topGroupCollapseIconLeft, topGroupCollapseIconLeft);
}
- public String getTopGroupIconPosition() {
- return (String) getStateHelper().eval(PropertyKeys.topGroupIconPosition);
+ public String getTopGroupCollapseIconRight() {
+ return (String) getStateHelper().eval(PropertyKeys.topGroupCollapseIconRight, Icons.DEFAULT.toString());
}
- public void setTopGroupIconPosition(String topGroupIconPosition) {
- getStateHelper().put(PropertyKeys.topGroupIconPosition, topGroupIconPosition);
+ public void setTopGroupCollapseIconRight(String topGroupCollapseIconRight) {
+ getStateHelper().put(PropertyKeys.topGroupCollapseIconRight, topGroupCollapseIconRight);
}
+ public String getTopGroupDisableIconLeft() {
+ return (String) getStateHelper().eval(PropertyKeys.topGroupDisableIconLeft, Icons.DEFAULT.toString());
+ }
+
+ public void setTopGroupDisableIconLeft(String topGroupDisableIconLeft) {
+ getStateHelper().put(PropertyKeys.topGroupDisableIconLeft, topGroupDisableIconLeft);
+ }
+
+ public String getTopGroupDisableIconRight() {
+ return (String) getStateHelper().eval(PropertyKeys.topGroupDisableIconRight, Icons.DEFAULT.toString());
+ }
+
+ public void setTopGroupDisableIconRight(String topGroupDisableIconRight) {
+ getStateHelper().put(PropertyKeys.topGroupDisableIconRight, topGroupDisableIconRight);
+ }
+
public String getOnclick() {
return (String) getStateHelper().eval(PropertyKeys.onclick);
}
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlPanelMenuGroup.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlPanelMenuGroup.java 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlPanelMenuGroup.java 2010-12-01 15:12:38 UTC (rev 20253)
@@ -24,15 +24,15 @@
package org.richfaces.component.html;
import org.richfaces.component.UIPanelMenuGroup;
+
import javax.faces.component.behavior.ClientBehaviorHolder;
-
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
/**
* @author akolonitsky
- * @since 2010-10-25
+ * @since 2010-11-29
*/
public class HtmlPanelMenuGroup extends UIPanelMenuGroup implements ClientBehaviorHolder {
@@ -41,6 +41,19 @@
public static final String COMPONENT_FAMILY = "org.richfaces.PanelMenuGroup";
private static final Collection<String> EVENT_NAMES = Collections.unmodifiableCollection(Arrays.asList(
+ "beforedomupdate",
+ "complete",
+ "click",
+ "dblclick",
+ "mousedown",
+ "mousemove",
+ "mouseout",
+ "mouseover",
+ "mouseup",
+ "unselect",
+ "select",
+ "beforeselect",
+
"collapse",
"expand",
"switch",
@@ -51,12 +64,39 @@
public enum PropertyKeys {
+ iconLeftCollapsed,
+ iconLeftExpanded,
+ iconLeftDisabled,
+
+ iconRightCollapsed,
+ iconRightExpanded,
+ iconRightDisabled,
+
oncollapse,
onexpand,
onswitch,
onbeforecollapse,
onbeforeexpand,
- onbeforeswitch
+ onbeforeswitch,
+
+ disabledClass,
+ hoverClass,
+ iconLeftClass,
+ iconRightClass,
+ style,
+ styleClass,
+ onbeforedomupdate,
+ oncomplete,
+ onclick,
+ ondblclick,
+ onmousedown,
+ onmousemove,
+ onmouseout,
+ onmouseover,
+ onmouseup,
+ onunselect,
+ onselect,
+ onbeforeselect
}
public HtmlPanelMenuGroup() {
@@ -68,6 +108,65 @@
return COMPONENT_FAMILY;
}
+ @Override
+ public HtmlPanelMenu getPanelMenu() {
+ return (HtmlPanelMenu) super.getPanelMenu();
+ }
+
+ public String getIconLeftCollapsed() {
+ return (String) getStateHelper().eval(PropertyKeys.iconLeftCollapsed,
+ isTopItem() ? getPanelMenu().getTopGroupCollapseIconLeft() : getPanelMenu().getGroupCollapseIconLeft());
+ }
+
+ public void setIconLeftCollapsed(String iconLeftCollapsed) {
+ getStateHelper().put(PropertyKeys.iconLeftCollapsed, iconLeftCollapsed);
+ }
+
+ public String getIconLeftExpanded() {
+ return (String) getStateHelper().eval(PropertyKeys.iconLeftExpanded,
+ isTopItem() ? getPanelMenu().getTopGroupExpandIconLeft() : getPanelMenu().getGroupExpandIconLeft());
+ }
+
+ public void setIconLeftExpanded(String iconLeftExpanded) {
+ getStateHelper().put(PropertyKeys.iconLeftExpanded, iconLeftExpanded);
+ }
+
+ public String getIconLeftDisabled() {
+ return (String) getStateHelper().eval(PropertyKeys.iconLeftDisabled,
+ isTopItem() ? getPanelMenu().getTopGroupDisableIconLeft() : getPanelMenu().getGroupDisableIconLeft());
+ }
+
+ public void setIconLeftDisabled(String iconLeftDisabled) {
+ getStateHelper().put(PropertyKeys.iconLeftDisabled, iconLeftDisabled);
+ }
+
+ public String getIconRightCollapsed() {
+ return (String) getStateHelper().eval(PropertyKeys.iconRightCollapsed,
+ isTopItem() ? getPanelMenu().getTopGroupCollapseIconRight() : getPanelMenu().getGroupCollapseIconRight());
+ }
+
+ public void setIconRightCollapsed(String iconRightCollapsed) {
+ getStateHelper().put(PropertyKeys.iconRightCollapsed, iconRightCollapsed);
+ }
+
+ public String getIconRightExpanded() {
+ return (String) getStateHelper().eval(PropertyKeys.iconRightExpanded,
+ isTopItem() ? getPanelMenu().getTopGroupExpandIconRight() : getPanelMenu().getGroupExpandIconRight());
+ }
+
+ public void setIconRightExpanded(String iconRightExpanded) {
+ getStateHelper().put(PropertyKeys.iconRightExpanded, iconRightExpanded);
+ }
+
+ public String getIconRightDisabled() {
+ return (String) getStateHelper().eval(PropertyKeys.iconRightDisabled,
+ isTopItem() ? getPanelMenu().getTopGroupDisableIconRight() : getPanelMenu().getGroupDisableIconRight());
+ }
+
+ public void setIconRightDisabled(String iconRightDisabled) {
+ getStateHelper().put(PropertyKeys.iconRightDisabled, iconRightDisabled);
+ }
+
public String getOncollapse() {
return (String) getStateHelper().eval(PropertyKeys.oncollapse);
}
@@ -116,8 +215,153 @@
getStateHelper().put(PropertyKeys.onbeforeswitch, onbeforeswitch);
}
+ public String getDisabledClass() {
+ return (String) getStateHelper().eval(PropertyKeys.disabledClass,
+ isTopItem() ? getPanelMenu().getTopGroupDisableClass() : getPanelMenu().getGroupDisableClass());
+ }
+ public void setDisabledClass(String disabledClass) {
+ getStateHelper().put(PropertyKeys.disabledClass, disabledClass);
+ }
+ public String getHoverClass() {
+ return (String) getStateHelper().eval(PropertyKeys.hoverClass);
+ }
+
+ public void setHoverClass(String hoverClass) {
+ getStateHelper().put(PropertyKeys.hoverClass, hoverClass);
+ }
+
+ public String getIconLeftClass() {
+ return (String) getStateHelper().eval(PropertyKeys.iconLeftClass);
+ }
+
+ public void setIconLeftClass(String iconLeftClass) {
+ getStateHelper().put(PropertyKeys.iconLeftClass, iconLeftClass);
+ }
+
+ public String getIconRightClass() {
+ return (String) getStateHelper().eval(PropertyKeys.iconRightClass);
+ }
+
+ public void setIconRightClass(String iconRightClass) {
+ getStateHelper().put(PropertyKeys.iconRightClass, iconRightClass);
+ }
+
+ public String getStyle() {
+ return (String) getStateHelper().eval(PropertyKeys.style);
+ }
+
+ public void setStyle(String style) {
+ getStateHelper().put(PropertyKeys.style, style);
+ }
+
+ public String getStyleClass() {
+ return (String) getStateHelper().eval(PropertyKeys.styleClass,
+ isTopItem() ? getPanelMenu().getTopGroupClass() : getPanelMenu().getGroupClass() );
+ }
+
+ public void setStyleClass(String styleClass) {
+ getStateHelper().put(PropertyKeys.styleClass, styleClass);
+ }
+
+ public String getOnbeforedomupdate() {
+ return (String) getStateHelper().eval(PropertyKeys.onbeforedomupdate);
+ }
+
+ public void setOnbeforedomupdate(String onbeforedomupdate) {
+ getStateHelper().put(PropertyKeys.onbeforedomupdate, onbeforedomupdate);
+ }
+
+ public String getOncomplete() {
+ return (String) getStateHelper().eval(PropertyKeys.oncomplete);
+ }
+
+ public void setOncomplete(String oncomplete) {
+ getStateHelper().put(PropertyKeys.oncomplete, oncomplete);
+ }
+
+ public String getOnclick() {
+ return (String) getStateHelper().eval(PropertyKeys.onclick);
+ }
+
+ public void setOnclick(String onclick) {
+ getStateHelper().put(PropertyKeys.onclick, onclick);
+ }
+
+ public String getOndblclick() {
+ return (String) getStateHelper().eval(PropertyKeys.ondblclick);
+ }
+
+ public void setOndblclick(String ondblclick) {
+ getStateHelper().put(PropertyKeys.ondblclick, ondblclick);
+ }
+
+ public String getOnmousedown() {
+ return (String) getStateHelper().eval(PropertyKeys.onmousedown);
+ }
+
+ public void setOnmousedown(String onmousedown) {
+ getStateHelper().put(PropertyKeys.onmousedown, onmousedown);
+ }
+
+ public String getOnmousemove() {
+ return (String) getStateHelper().eval(PropertyKeys.onmousemove);
+ }
+
+ public void setOnmousemove(String onmousemove) {
+ getStateHelper().put(PropertyKeys.onmousemove, onmousemove);
+ }
+
+ public String getOnmouseout() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseout);
+ }
+
+ public void setOnmouseout(String onmouseout) {
+ getStateHelper().put(PropertyKeys.onmouseout, onmouseout);
+ }
+
+ public String getOnmouseover() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseover);
+ }
+
+ public void setOnmouseover(String onmouseover) {
+ getStateHelper().put(PropertyKeys.onmouseover, onmouseover);
+ }
+
+ public String getOnmouseup() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseup);
+ }
+
+ public void setOnmouseup(String onmouseup) {
+ getStateHelper().put(PropertyKeys.onmouseup, onmouseup);
+ }
+
+ public String getOnunselect() {
+ return (String) getStateHelper().eval(PropertyKeys.onunselect);
+ }
+
+ public void setOnunselect(String onunselect) {
+ getStateHelper().put(PropertyKeys.onunselect, onunselect);
+ }
+
+ public String getOnselect() {
+ return (String) getStateHelper().eval(PropertyKeys.onselect);
+ }
+
+ public void setOnselect(String onselect) {
+ getStateHelper().put(PropertyKeys.onselect, onselect);
+ }
+
+ public String getOnbeforeselect() {
+ return (String) getStateHelper().eval(PropertyKeys.onbeforeselect);
+ }
+
+ public void setOnbeforeselect(String onbeforeselect) {
+ getStateHelper().put(PropertyKeys.onbeforeselect, onbeforeselect);
+ }
+
+
@Override
public Collection<String> getEventNames() {
return EVENT_NAMES;
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlPanelMenuItem.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlPanelMenuItem.java 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlPanelMenuItem.java 2010-12-01 15:12:38 UTC (rev 20253)
@@ -24,8 +24,8 @@
package org.richfaces.component.html;
import org.richfaces.component.UIPanelMenuItem;
+
import javax.faces.component.behavior.ClientBehaviorHolder;
-
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -58,12 +58,13 @@
public enum PropertyKeys {
disabledClass,
- disabledStyle,
hoverClass,
- hoverStyle,
- iconClass,
- iconDisabled,
- iconStyle,
+ iconLeft,
+ iconLeftClass,
+ iconLeftDisabled,
+ iconRight,
+ iconRightClass,
+ iconRightDisabled,
style,
styleClass,
onbeforedomupdate,
@@ -85,26 +86,24 @@
}
@Override
+ public HtmlPanelMenu getPanelMenu() {
+ return (HtmlPanelMenu) super.getPanelMenu();
+ }
+
+ @Override
public String getFamily() {
return COMPONENT_FAMILY;
}
public String getDisabledClass() {
- return (String) getStateHelper().eval(PropertyKeys.disabledClass);
+ return (String) getStateHelper().eval(PropertyKeys.disabledClass,
+ isTopItem() ? getPanelMenu().getTopItemDisableClass() : getPanelMenu().getItemDisableClass());
}
public void setDisabledClass(String disabledClass) {
getStateHelper().put(PropertyKeys.disabledClass, disabledClass);
}
- public String getDisabledStyle() {
- return (String) getStateHelper().eval(PropertyKeys.disabledStyle);
- }
-
- public void setDisabledStyle(String disabledStyle) {
- getStateHelper().put(PropertyKeys.disabledStyle, disabledStyle);
- }
-
public String getHoverClass() {
return (String) getStateHelper().eval(PropertyKeys.hoverClass);
}
@@ -113,38 +112,58 @@
getStateHelper().put(PropertyKeys.hoverClass, hoverClass);
}
- public String getHoverStyle() {
- return (String) getStateHelper().eval(PropertyKeys.hoverStyle);
+ public String getIconLeft() {
+ return (String) getStateHelper().eval(PropertyKeys.iconLeft,
+ isTopItem() ? getPanelMenu().getTopItemIconLeft() : getPanelMenu().getItemIconLeft());
}
- public void setHoverStyle(String hoverStyle) {
- getStateHelper().put(PropertyKeys.hoverStyle, hoverStyle);
+ public void setIconLeft(String iconLeft) {
+ getStateHelper().put(PropertyKeys.iconLeft, iconLeft);
}
- public String getIconClass() {
- return (String) getStateHelper().eval(PropertyKeys.iconClass);
+ public String getIconLeftClass() {
+ return (String) getStateHelper().eval(PropertyKeys.iconLeftClass);
}
- public void setIconClass(String iconClass) {
- getStateHelper().put(PropertyKeys.iconClass, iconClass);
+ public void setIconLeftClass(String iconLeftClass) {
+ getStateHelper().put(PropertyKeys.iconLeftClass, iconLeftClass);
}
- public String getIconDisabled() {
- return (String) getStateHelper().eval(PropertyKeys.iconDisabled);
+ public String getIconLeftDisabled() {
+ return (String) getStateHelper().eval(PropertyKeys.iconLeftDisabled,
+ isTopItem() ? getPanelMenu().getTopItemDisableIconLeft() : getPanelMenu().getItemDisableIconLeft());
}
- public void setIconDisabled(String iconDisabled) {
- getStateHelper().put(PropertyKeys.iconDisabled, iconDisabled);
+ public void setIconLeftDisabled(String iconLeftDisabled) {
+ getStateHelper().put(PropertyKeys.iconLeftDisabled, iconLeftDisabled);
}
- public String getIconStyle() {
- return (String) getStateHelper().eval(PropertyKeys.iconStyle);
+ public String getIconRight() {
+ return (String) getStateHelper().eval(PropertyKeys.iconRight,
+ isTopItem() ? getPanelMenu().getTopItemIconRight() : getPanelMenu().getItemIconRight());
}
- public void setIconStyle(String iconStyle) {
- getStateHelper().put(PropertyKeys.iconStyle, iconStyle);
+ public void setIconRight(String iconRight) {
+ getStateHelper().put(PropertyKeys.iconRight, iconRight);
}
+ public String getIconRightClass() {
+ return (String) getStateHelper().eval(PropertyKeys.iconRightClass);
+ }
+
+ public void setIconRightClass(String iconRightClass) {
+ getStateHelper().put(PropertyKeys.iconRightClass, iconRightClass);
+ }
+
+ public String getIconRightDisabled() {
+ return (String) getStateHelper().eval(PropertyKeys.iconRightDisabled,
+ isTopItem() ? getPanelMenu().getTopItemDisableIconRight() : getPanelMenu().getItemDisableIconRight());
+ }
+
+ public void setIconRightDisabled(String iconRightDisabled) {
+ getStateHelper().put(PropertyKeys.iconRightDisabled, iconRightDisabled);
+ }
+
public String getStyle() {
return (String) getStateHelper().eval(PropertyKeys.style);
}
@@ -154,7 +173,8 @@
}
public String getStyleClass() {
- return (String) getStateHelper().eval(PropertyKeys.styleClass);
+ return (String) getStateHelper().eval(PropertyKeys.styleClass,
+ isTopItem() ? getPanelMenu().getTopItemClass() : getPanelMenu().getItemClass() );
}
public void setStyleClass(String styleClass) {
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2010-12-01 15:12:38 UTC (rev 20253)
@@ -29,6 +29,7 @@
import org.richfaces.component.AbstractPanelMenuItem;
import org.richfaces.component.html.HtmlPanelMenuGroup;
import org.richfaces.renderkit.HtmlConstants;
+import org.richfaces.renderkit.RenderKitUtils;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -37,7 +38,6 @@
import java.util.HashMap;
import java.util.Map;
-import static org.richfaces.component.util.HtmlUtil.concatClasses;
import static org.richfaces.renderkit.html.TogglePanelRenderer.addEventOption;
import static org.richfaces.renderkit.html.TogglePanelRenderer.getAjaxOptions;
@@ -109,11 +109,79 @@
writer.startElement("div", null);
writer.writeAttribute("id", menuGroup.getClientId(context) + ":hdr", null);
writer.writeAttribute("class", getCssClass(menuGroup, "-hdr"), null);
- PanelMenuItemRenderer.encodeHeaderGroup(writer, context, menuGroup, getCssClass(menuGroup, ""));
-// writer.writeText(menuGroup.getLabel(), null);
+ encodeHeaderGroup(writer, context, menuGroup, getCssClass(menuGroup, ""));
writer.endElement("div");
}
+ private void encodeHeaderGroup(ResponseWriter writer, FacesContext context, HtmlPanelMenuGroup menuItem, String classPrefix) throws IOException {
+ writer.startElement("table", null);
+ writer.writeAttribute("class", classPrefix + "-gr", null);
+ writer.startElement("tr", null);
+
+ encodeHeaderGroupIconLeft(writer, context, menuItem, classPrefix);
+
+ writer.startElement("td", null);
+ writer.writeAttribute("class", classPrefix + "-lbl", null);
+ writer.writeText(menuItem.getLabel(), null);
+ writer.endElement("td");
+
+ encodeHeaderGroupIconRight(writer, context, menuItem, classPrefix);
+
+ writer.endElement("tr");
+ writer.endElement("table");
+ }
+
+ private void encodeHeaderGroupIconLeft(ResponseWriter writer, FacesContext context, HtmlPanelMenuGroup menuGroup, String classPrefix) throws IOException {
+ String iconCollapsed = menuGroup.isDisabled() ? menuGroup.getIconLeftDisabled() : menuGroup.getIconLeftCollapsed();
+ String iconExpanded = menuGroup.isDisabled() ? menuGroup.getIconLeftDisabled() : menuGroup.getIconLeftExpanded();
+
+ encodeTdIcon(writer, context, classPrefix + "-ico", menuGroup.isExpanded(), iconCollapsed, iconExpanded);
+ }
+
+ private void encodeHeaderGroupIconRight(ResponseWriter writer, FacesContext context, HtmlPanelMenuGroup menuItem, String classPrefix) throws IOException {
+ String iconCollapsed = menuItem.isDisabled() ? menuItem.getIconRightDisabled() : menuItem.getIconRightCollapsed();
+ String iconExpanded = menuItem.isDisabled() ? menuItem.getIconRightDisabled() : menuItem.getIconRightExpanded();
+
+ encodeTdIcon(writer, context, classPrefix + "-exp-ico", menuItem.isExpanded(), iconCollapsed, iconExpanded);
+ }
+
+ private void encodeTdIcon(ResponseWriter writer, FacesContext context, String cssClass, boolean isExpanded, String attrIconCollapsedValue, String attrIconExpandedValue) throws IOException {
+ writer.startElement("td", null);
+ writer.writeAttribute("class", cssClass, null);
+ try {
+ AbstractPanelMenuItem.Icons iconCollapsed = AbstractPanelMenuItem.Icons.valueOf(attrIconCollapsedValue);
+ writer.startElement("div", null);
+ writer.writeAttribute("class", concatClasses("rf-pm-ico-colps", iconCollapsed.cssClass()), null);
+ writer.writeAttribute("style", styleElement("display", isExpanded ? "none" : "block"), null);
+ writer.endElement("div");
+ } catch (IllegalArgumentException e) {
+ if(attrIconCollapsedValue != null && attrIconCollapsedValue.trim().length() != 0) {
+ writer.startElement(HtmlConstants.IMG_ELEMENT, null);
+ writer.writeAttribute(HtmlConstants.ALT_ATTRIBUTE, "", null);
+ writer.writeURIAttribute(HtmlConstants.SRC_ATTRIBUTE, RenderKitUtils.getResourceURL(attrIconCollapsedValue, context), null);
+ writer.endElement(HtmlConstants.IMG_ELEMENT);
+ }
+ }
+
+ try {
+ AbstractPanelMenuItem.Icons iconExpanded = AbstractPanelMenuItem.Icons.valueOf(attrIconExpandedValue);
+ writer.startElement("div", null);
+ writer.writeAttribute("class", concatClasses("rf-pm-ico-exp", iconExpanded.cssClass()), null);
+ writer.writeAttribute("style", styleElement("display", isExpanded ? "block" : "none"), null);
+ writer.endElement("div");
+ } catch (IllegalArgumentException e) {
+ if(attrIconExpandedValue != null && attrIconExpandedValue.trim().length() != 0) {
+ writer.startElement(HtmlConstants.IMG_ELEMENT, null);
+ writer.writeAttribute(HtmlConstants.ALT_ATTRIBUTE, "", null);
+ writer.writeURIAttribute(HtmlConstants.SRC_ATTRIBUTE, RenderKitUtils.getResourceURL(attrIconExpandedValue, context), null);
+ writer.endElement(HtmlConstants.IMG_ELEMENT);
+ }
+ }
+
+ writer.endElement("td");
+ }
+
+
public String getCssClass(AbstractPanelMenuItem item, String postfix) {
return (item.isTopItem() ? TOP_CSS_CLASS_PREFIX : CSS_CLASS_PREFIX) + postfix;
}
@@ -132,7 +200,12 @@
@Override
protected String getStyleClass(UIComponent component) {
- return concatClasses(getCssClass((AbstractPanelMenuItem) component, ""), attributeAsString(component, "styleClass"));
+ AbstractPanelMenuItem menuItem = (AbstractPanelMenuItem) component;
+
+ return concatClasses(getCssClass(menuItem, ""),
+ attributeAsString(component, "styleClass"),
+ menuItem.isDisabled() ? getCssClass(menuItem, "-dis") : "",
+ menuItem.isDisabled() ? attributeAsString(component, "disabledClass") : "");
}
@Override
@@ -149,10 +222,11 @@
options.put("ajax", getAjaxOptions(context, panelMenuGroup));
options.put("name", panelMenuGroup.getName());
options.put("mode", panelMenuGroup.getMode());
+ options.put("disabled", panelMenuGroup.isDisabled());
options.put("expandEvent", panelMenuGroup.getExpandEvent());
options.put("collapseEvent", panelMenuGroup.getCollapseEvent());
options.put("expandSingle", panelMenuGroup.isExpandSingle());
- options.put("bubbleSelection", panelMenuGroup.getBubbleSelection());
+ options.put("bubbleSelection", panelMenuGroup.isBubbleSelection());
options.put("expanded", panelMenuGroup.isExpanded());
addEventOption(context, panelMenuGroup, options, COLLAPSE);
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java 2010-12-01 15:12:38 UTC (rev 20253)
@@ -26,7 +26,6 @@
import org.ajax4jsf.javascript.JSObject;
import org.richfaces.component.AbstractPanelMenuItem;
import org.richfaces.component.html.HtmlPanelMenuItem;
-import org.richfaces.component.util.HtmlUtil;
import org.richfaces.renderkit.HtmlConstants;
import org.richfaces.renderkit.RenderKitUtils;
@@ -51,41 +50,55 @@
public static final String BEFORE_SELECT = "beforeselect";
private static final String CSS_CLASS_PREFIX = "rf-pm-itm";
+ private static final String TOP_CSS_CLASS_PREFIX = "rf-pm-top-itm";
@Override
protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
super.doEncodeBegin(writer, context, component);
- encodeHeaderGroup(writer, context, (AbstractPanelMenuItem) component, CSS_CLASS_PREFIX);
+ HtmlPanelMenuItem menuItem = (HtmlPanelMenuItem) component;
+ encodeHeaderGroup(writer, context, menuItem, menuItem.isTopItem() ? TOP_CSS_CLASS_PREFIX : CSS_CLASS_PREFIX);
}
- static void encodeHeaderGroup(ResponseWriter writer, FacesContext context, AbstractPanelMenuItem menuItem, String classPrefix) throws IOException {
+ private void encodeHeaderGroup(ResponseWriter writer, FacesContext context, HtmlPanelMenuItem menuItem, String classPrefix) throws IOException {
writer.startElement("table", null);
writer.writeAttribute("class", classPrefix + "-gr", null);
writer.startElement("tr", null);
- encodeTdIcon(writer, context, classPrefix, menuItem.getIcon());
+ encodeHeaderGroupLeftIcon(writer, context, menuItem, classPrefix);
writer.startElement("td", null);
writer.writeAttribute("class", classPrefix + "-lbl", null);
writer.writeText(menuItem.getLabel(), null);
writer.endElement("td");
- writer.startElement("td", null);
- writer.writeAttribute("class", HtmlUtil.concatClasses(classPrefix + "-exp-ico", "rf-pm-triangle-down"), null);
- writer.endElement("td");
+ encodeHeaderGroupRightIcon(writer, context, menuItem, classPrefix);
writer.endElement("tr");
writer.endElement("table");
}
- private static void encodeTdIcon(ResponseWriter writer, FacesContext context, String classPrefix, String attrIconValue) throws IOException {
+ private void encodeHeaderGroupRightIcon(ResponseWriter writer, FacesContext context, HtmlPanelMenuItem menuItem, String classPrefix) throws IOException {
+ String icon = menuItem.isDisabled() ? menuItem.getIconRightDisabled() : menuItem.getIconRight();
+ String cssClasses = concatClasses(classPrefix + "-exp-ico", menuItem.getIconLeftClass());
+
+ encodeTdIcon(writer, context, cssClasses, icon);
+ }
+
+ private void encodeHeaderGroupLeftIcon(ResponseWriter writer, FacesContext context, HtmlPanelMenuItem menuItem, String classPrefix) throws IOException {
+ String icon = menuItem.isDisabled() ? menuItem.getIconLeftDisabled() : menuItem.getIconLeft();
+ String cssClasses = concatClasses(classPrefix + "-ico", menuItem.getIconLeftClass());
+
+ encodeTdIcon(writer, context, cssClasses, icon);
+ }
+
+ public void encodeTdIcon(ResponseWriter writer, FacesContext context, String classPrefix, String attrIconValue) throws IOException {
writer.startElement("td", null);
try {
AbstractPanelMenuItem.Icons icon = AbstractPanelMenuItem.Icons.valueOf(attrIconValue);
- writer.writeAttribute("class", HtmlUtil.concatClasses(classPrefix + "-ico", icon.cssClass()), null);
+ writer.writeAttribute("class", concatClasses(classPrefix, icon.cssClass()), null);
} catch (IllegalArgumentException e) {
- writer.writeAttribute("class", classPrefix + "-ico", null);
+ writer.writeAttribute("class", classPrefix, null);
if(attrIconValue != null && attrIconValue.trim().length() != 0) {
writer.startElement(HtmlConstants.IMG_ELEMENT, null);
writer.writeAttribute(HtmlConstants.ALT_ATTRIBUTE, "", null);
@@ -99,9 +112,17 @@
@Override
protected String getStyleClass(UIComponent component) {
- return concatClasses(CSS_CLASS_PREFIX, attributeAsString(component, "styleClass"));
+ AbstractPanelMenuItem menuItem = (AbstractPanelMenuItem) component;
+ return concatClasses(getCssClass(menuItem, ""),
+ attributeAsString(component, "styleClass"),
+ menuItem.isDisabled() ? getCssClass(menuItem, "-dis") : "",
+ menuItem.isDisabled() ? attributeAsString(component, "disabledClass") : "");
}
+ public String getCssClass(AbstractPanelMenuItem item, String postfix) {
+ return (item.isTopItem() ? TOP_CSS_CLASS_PREFIX : CSS_CLASS_PREFIX) + postfix;
+ }
+
@Override
protected JSObject getScriptObject(FacesContext context, UIComponent component) {
return new JSObject("RichFaces.ui.PanelMenuItem",
Modified: trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -1605,16 +1605,31 @@
</property>
<property>
<description></description>
- <property-name>iconCollapsed</property-name>
+ <property-name>bubbleSelection</property-name>
+ <property-class>boolean</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>iconLeftCollapsed</property-name>
<property-class>java.lang.String</property-class>
</property>
<property>
<description></description>
- <property-name>iconExpanded</property-name>
+ <property-name>iconLeftExpanded</property-name>
<property-class>java.lang.String</property-class>
</property>
<property>
<description></description>
+ <property-name>iconRightCollapsed</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>iconRightExpanded</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <description></description>
<property-name>changeExpandListener</property-name>
<property-class>java.lang.String</property-class>
</property>
@@ -1641,7 +1656,7 @@
<property>
<description></description>
<property-name>groupMode</property-name>
- <property-class>org.richfaces.ExpandMode</property-class>
+ <property-class>org.richfaces.PanelMenuMode</property-class>
</property>
<property>
<description></description>
@@ -1698,6 +1713,7 @@
<property-name>render</property-name>
<property-class>java.lang.Object</property-class>
</property>
+
</component>
<render-kit>
Modified: trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -290,32 +290,27 @@
</attribute>
<attribute>
<description></description>
- <name>disabledStyle</name>
- <type>java.lang.String</type>
- </attribute>
- <attribute>
- <description></description>
<name>hoverClass</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>hoverStyle</name>
+ <name>iconLeftClass</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>iconClass</name>
+ <name>iconLeftDisabled</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>iconDisabled</name>
+ <name>iconRightClass</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>iconStyle</name>
+ <name>iconRightDisabled</name>
<type>java.lang.String</type>
</attribute>
<attribute>
@@ -419,16 +414,31 @@
</attribute>
<attribute>
<description></description>
- <name>iconCollapsed</name>
+ <name>bubbleSelection</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>iconLeftCollapsed</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>iconExpanded</name>
+ <name>iconLeftExpanded</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
+ <name>iconRightCollapsed</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>iconRightExpanded</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
<name>changeExpandListener</name>
<type>java.lang.String</type>
</attribute>
@@ -559,7 +569,7 @@
<attribute>
<description></description>
<name>groupMode</name>
- <type>org.richfaces.ExpandMode</type>
+ <type>org.richfaces.PanelMenuMode</type>
</attribute>
<attribute>
<description></description>
@@ -653,27 +663,27 @@
</attribute>
<attribute>
<description></description>
- <name>itemHoverClass</name>
+ <name>itemDisableClass</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>itemDisableClass</name>
+ <name>itemIconLeft</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>itemIcon</name>
+ <name>itemIconRight</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>itemDisableIcon</name>
+ <name>itemDisableIconLeft</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>itemIconPosition</name>
+ <name>itemDisableIconRight</name>
<type>java.lang.String</type>
</attribute>
<attribute>
@@ -683,27 +693,27 @@
</attribute>
<attribute>
<description></description>
- <name>topItemHoverClass</name>
+ <name>topItemDisableClass</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>topItemDisableClass</name>
+ <name>topItemIconLeft</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>topItemIcon</name>
+ <name>topItemIconRight</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>topItemDisableIcon</name>
+ <name>topItemDisableIconLeft</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>topItemIconPosition</name>
+ <name>topItemDisableIconRight</name>
<type>java.lang.String</type>
</attribute>
<attribute>
@@ -713,42 +723,42 @@
</attribute>
<attribute>
<description></description>
- <name>groupHoverClass</name>
+ <name>groupDisableClass</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>groupDisableClass</name>
+ <name>groupExpandIconLeft</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>groupCollapseIcon</name>
+ <name>groupExpandIconRight</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>groupExpandIcon</name>
+ <name>groupCollapseIconLeft</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>groupDisableIcon</name>
+ <name>groupCollapseIconRight</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>groupIconPosition</name>
+ <name>groupDisableIconLeft</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>topGroupClass</name>
+ <name>groupDisableIconRight</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>topGroupHoverClass</name>
+ <name>topGroupClass</name>
<type>java.lang.String</type>
</attribute>
<attribute>
@@ -758,26 +768,36 @@
</attribute>
<attribute>
<description></description>
- <name>topGroupCollapseIcon</name>
+ <name>topGroupExpandIconLeft</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>topGroupExpandIcon</name>
+ <name>topGroupExpandIconRight</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>topGroupDisableIcon</name>
+ <name>topGroupCollapseIconLeft</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
- <name>topGroupIconPosition</name>
+ <name>topGroupCollapseIconRight</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<description></description>
+ <name>topGroupDisableIconLeft</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>topGroupDisableIconRight</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
<name>onclick</name>
<type>java.lang.String</type>
</attribute>
Copied: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/PanelMenu.js (from rev 20205, trunk/examples/output-demo/src/main/webapp/resources/PanelMenu.js)
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/PanelMenu.js (rev 0)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/PanelMenu.js 2010-12-01 15:12:38 UTC (rev 20253)
@@ -0,0 +1,208 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+(function ($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ var __DEFAULT_OPTIONS = {
+ expandSingle : true
+ };
+
+ rf.ui.PanelMenu = rf.BaseComponent.extendClass({
+ // class name
+ name:"PanelMenu",
+
+ /**
+ * @class PanelMenu
+ * @name PanelMenu
+ *
+ * @constructor
+ * @param {String} componentId - component id
+ * @param {Hash} options - params
+ * */
+ init : function (componentId, options) {
+ this.id = componentId;
+ this.items = [];
+ this.attachToDom(componentId);
+
+ this.options = $.extend({}, __DEFAULT_OPTIONS, options || {});
+ this.activeItem = this.__getValueInput().value;
+ this.nestingLevel = 0;
+
+ var menuGroup = this;
+ if (menuGroup.options.expandSingle) {
+ menuGroup.__panelMenu().bind("expand", function (event) {
+ menuGroup.__childGroups().each (function (index, group) {
+ if (event.target.id != group.id) {
+ rf.$(group.id).collapse();
+ }
+ });
+
+ event.stopPropagation();
+ });
+ }
+
+ if (menuGroup.activeItem) {
+ this.__panelMenu().ready(function () {
+ var item = menuGroup.items[menuGroup.activeItem];
+ item.__select();
+ item.__fireSelect();
+ })
+ }
+
+ this.__addUserEventHandler("collapse");
+ this.__addUserEventHandler("expand");
+ },
+
+ getItems: function () {
+ return this.items;
+ },
+
+ getItem: function (name) {
+ return this.items[name];
+ },
+
+ /***************************** Public Methods ****************************************************************/
+ /**
+ * @methodOf
+ * @name PanelMenu#selectItem
+ *
+ * TODO ...
+ *
+ * @param {String} name
+ * @return {void} TODO ...
+ */
+ selectItem: function (name) {
+ // TODO implement
+ },
+
+ /**
+ * @methodOf
+ * @name PanelMenu#selectedItem
+ *
+ * TODO ...
+ *
+ * @return {String} TODO ...
+ */
+ selectedItem: function (id) {
+ if (id != undefined) {
+ var valueInput = this.__getValueInput();
+ var prevActiveItem = valueInput.value;
+
+ this.activeItem = id;
+ valueInput.value = id;
+
+ return prevActiveItem;
+ } else {
+ return this.activeItem;
+ }
+ },
+
+ __getValueInput : function() {
+ return document.getElementById(this.id + "-value");
+ },
+
+ selectItem: function (itemName) {
+ // TODO
+ },
+
+ /**
+ * @methodOf
+ * @name PanelMenu#expandAll
+ *
+ * TODO ...
+ *
+ * @return {void} TODO ...
+ */
+ expandAll: function () {
+ // TODO implement
+ },
+
+ /**
+ * @methodOf
+ * @name PanelMenu#collapseAll
+ *
+ * TODO ...
+ *
+ * @return {void} TODO ...
+ */
+ collapseAll: function () {
+ // TODO implement
+ },
+
+ /**
+ * @methodOf
+ * @name PanelMenu#expandGroup
+ *
+ * TODO ...
+ *
+ * @param {String} groupName
+ * @return {void} TODO ...
+ */
+ expandGroup: function (groupName) {
+ // TODO implement
+ },
+
+ /**
+ * @methodOf
+ * @name PanelMenu#collapseGroup
+ *
+ * TODO ...
+ *
+ * @param {String} groupName
+ * @return {void} TODO ...
+ */
+ collapseGroup: function (groupName) {
+ // TODO implement
+ },
+
+
+ /***************************** Private Methods ****************************************************************/
+
+
+ __panelMenu : function () {
+ return $(rf.getDomElement(this.id));
+ },
+
+ __childGroups : function () {
+ return this.__panelMenu().children(".rf-pm-top-gr")
+ },
+
+ /**
+ * @private
+ * */
+ __addUserEventHandler : function (name) {
+ var handler = this.options["on" + name];
+ if (handler) {
+ rf.Event.bindById(this.id, name, handler);
+ }
+ },
+
+ destroy: function () {
+ rf.Event.unbindById(this.id, "."+this.namespace);
+
+ this.$super.destroy.call(this);
+ }
+ });
+})(jQuery, RichFaces);
Copied: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/PanelMenuGroup.js (from rev 20205, trunk/examples/output-demo/src/main/webapp/resources/PanelMenuGroup.js)
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/PanelMenuGroup.js (rev 0)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/PanelMenuGroup.js 2010-12-01 15:12:38 UTC (rev 20253)
@@ -0,0 +1,363 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+(function ($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ var __DEFAULT_OPTIONS = {
+ expanded : false,
+ expandSingle : true,
+ bubbleSelection : true,
+ stylePrefix : "rf-pm-gr",
+
+ // TODO we should use selectionType = {none, selectable, unselectable}
+ selectable : false,
+ unselectable : false // unselectable can be only selectable item => if selectable == false than unselectable = false
+ };
+
+ var EXPAND_ITEM = {
+
+ /**
+ *
+ * @return {void}
+ * */
+ exec : function (group, expand) {
+ var mode = group.mode;
+ if (mode == "server") {
+ return this.execServer(group);
+ } else if (mode == "ajax") {
+ return this.execAjax(group);
+ } else if (mode == "client" || mode == "none") {
+ return this.execClient(group, expand);
+ } else {
+ rf.log.error("EXPAND_ITEM.exec : unknown mode (" + mode + ")");
+ }
+ },
+
+ /**
+ * @protected
+ *
+ * @return {Boolean} false
+ * */
+ execServer : function (group) {
+ group.__changeState();
+ rf.submitForm(this.__getParentForm(group));
+
+ return false;
+ },
+
+ /**
+ * @protected
+ *
+ * @return {Boolean} false
+ * */
+ execAjax : function (group) {
+ var oldState = group.__changeState();
+ rf.ajax(group.id, null, $.extend({}, group.options["ajax"], {}));
+ group.__restoreState(oldState);
+
+ return true;
+ },
+
+ /**
+ * @protected
+ *
+ * @param {PanelMenuGroup} group
+ * @param {Boolean} expand
+ * @return {undefined}
+ * - false - if process has been terminated
+ * - true - in other cases
+ * */
+ execClient : function (group, expand) {
+ if (expand) {
+ group.expand();
+ } else {
+ group.collapse();
+ }
+
+ return group.__fireSwitch();
+ },
+
+ /**
+ * @private
+ * */
+ __getParentForm : function (item) {
+ return $($(rf.getDomElement(item.id)).parents("form")[0]);
+ }
+ };
+
+ rf.ui.PanelMenuGroup = rf.ui.PanelMenuItem.extendClass({
+ // class name
+ name:"PanelMenuGroup",
+
+ /**
+ * @class PanelMenuGroup
+ * @name PanelMenuGroup
+ *
+ * @constructor
+ * @param {String} componentId - component id
+ * @param {Hash} options - params
+ * */
+ init : function (componentId, options) {
+ this.options = $.extend({}, __DEFAULT_OPTIONS, options || {});
+
+ rf.ui.PanelMenuItem.call(this, componentId);
+
+ if (!this.options.disabled) {
+ var menuGroup = this;
+
+ if (!this.options.selectable) {
+ this.__header().bind("click", function () {
+ return menuGroup.switchExpantion();
+ });
+ }
+
+ if (this.options.selectable || this.options.bubbleSelection) {
+ this.__content().bind("select", function (event) {
+ if (menuGroup.options.selectable && menuGroup.__isMyEvent(event)) {
+ menuGroup.expand();
+ }
+
+ if (menuGroup.options.bubbleSelection && !menuGroup.__isMyEvent(event)) {
+ menuGroup.__select();
+ if (!menuGroup.expanded()) {
+ menuGroup.expand();
+ }
+ }
+ });
+
+ this.__content().bind("unselect", function (event) {
+ if (menuGroup.options.selectable && menuGroup.__isMyEvent(event)) {
+ menuGroup.collapse();
+ }
+
+ if (menuGroup.options.bubbleSelection && !menuGroup.__isMyEvent(event)) {
+ menuGroup.__unselect();
+ }
+ });
+ }
+
+ if (menuGroup.options.expandSingle) {
+ menuGroup.__group().bind("expand", function (event) {
+ if (menuGroup.__isMyEvent(event)) {
+ return;
+ }
+
+ menuGroup.__childGroups().each (function (index, group) {
+ var rfGroup = rf.$(group);
+ if (!rfGroup.__isMyEvent(event)) {
+ rfGroup.collapse();
+ }
+ });
+
+ event.stopPropagation();
+ });
+ }
+
+ this.__addUserEventHandler("collapse");
+ this.__addUserEventHandler("expand");
+ }
+ },
+
+ /***************************** Public Methods ****************************************************************/
+ expanded : function () {
+ // TODO check invariant in dev mode
+ // return this.__content().hasClass("rf-pm-exp")
+ return this.__getExpandValue();
+ },
+
+ expand : function () {
+ this.__expand();
+
+ return this.__fireExpand();
+ },
+
+ __expand : function () {
+ this.__content().removeClass("rf-pm-colps").addClass("rf-pm-exp");
+ var header = this.__header();
+ header.find(".rf-pm-ico-colps").hide();
+ header.find(".rf-pm-ico-exp").show();
+
+ this.__setExpandValue(true);
+ },
+
+ collapsed : function () {
+ // TODO check invariant in dev mode
+ // return this.__content().hasClass("rf-pm-colps")
+ return !this.__getExpandValue();
+ },
+
+ collapse : function () {
+ this.__collapse();
+
+ this.__childGroups().each (function(index, group) {
+ rf.$(group.id).__collapse();
+ });
+
+ this.__fireCollapse();
+ },
+
+ __collapse : function () {
+ this.__content().addClass("rf-pm-colps").removeClass("rf-pm-exp");
+ var header = this.__header();
+ header.find(".rf-pm-ico-exp").hide();
+ header.find(".rf-pm-ico-colps").show();
+
+ this.__setExpandValue(false);
+ },
+
+ /**
+ * @methodOf
+ * @name PanelMenuGroup#switch
+ *
+ * TODO ...
+ *
+ * @param {boolean} expand
+ * @return {void} TODO ...
+ */
+ switchExpantion : function () { // TODO rename
+ var continueProcess = this.__fireBeforeSwitch();
+ if (!continueProcess) {
+ return false;
+ }
+
+ EXPAND_ITEM.exec(this, !this.expanded());
+ },
+
+ /**
+ * please, remove this method when client side ajax events will be added
+ *
+ * */
+ onCompleteHandler : function () {
+ EXPAND_ITEM.execClient(this, this.expanded());
+ },
+
+ __switch : function (expand) {
+ if (expand) {
+ this.expand();
+ } else {
+ this.collapse();
+ }
+ },
+
+ /***************************** Private Methods ****************************************************************/
+ __childGroups : function () {
+ return this.__content().children(".rf-pm-gr")
+ },
+
+ __group : function () {
+ return $(rf.getDomElement(this.id))
+ },
+
+ __header : function () {
+ return $(rf.getDomElement(this.id + ":hdr"))
+ },
+
+ __content : function () {
+ return $(rf.getDomElement(this.id + ":cnt"))
+ },
+
+ __expandValueInput : function () {
+ return document.getElementById(this.id + ":expanded");
+ },
+
+ __getExpandValue : function () {
+ return this.__expandValueInput().value == "true";
+ },
+
+ /**
+ * @methodOf
+ * @name PanelMenuGroup#__setExpandValue
+ *
+ * @param {boolean} value - is group expanded?
+ * @return {boolean} preview value
+ */
+ __setExpandValue : function (value) {
+ var input = this.__expandValueInput();
+ var oldValue = input.value;
+
+ input.value = value;
+
+ return oldValue;
+ },
+
+ __changeState : function () {
+ var state = {};
+ state["expanded"] = this.__setExpandValue(!this.__getExpandValue());
+ if (this.options.selectable) {
+ state["itemName"] = this.__rfPanelMenu().selectedItem(this.itemName); // TODO bad function name for function which change component state
+ }
+
+ return state;
+ },
+
+ __restoreState : function (state) {
+ if (!state) {
+ return;
+ }
+
+ if (state["expanded"]) {
+ this.__setExpandValue(state["expanded"]);
+ }
+
+ if (state["itemName"]) {
+ this.__rfPanelMenu().selectedItem(state["itemName"]);
+ }
+ },
+
+ __fireSwitch : function () {
+ return new rf.Event.fireById(this.id, "switch", {
+ id: this.id
+ });
+ },
+
+ __isMyEvent: function (event) {
+ return this.id == event.target.id;
+ },
+
+ __fireBeforeSwitch : function () {
+ return rf.Event.fireById(this.id, "beforeswitch", {
+ id: this.id
+ });
+ },
+
+ __fireCollapse : function () {
+ return new rf.Event.fireById(this.id, "collapse", {
+ id: this.id
+ });
+ },
+
+ __fireExpand : function () {
+ return new rf.Event.fireById(this.id, "expand", {
+ id: this.id
+ });
+ },
+
+ destroy: function () {
+ rf.Event.unbindById(this.id, "."+this.namespace);
+
+ this.$super.destroy.call(this);
+ }
+ });
+})(jQuery, RichFaces);
Copied: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/PanelMenuItem.js (from rev 20205, trunk/examples/output-demo/src/main/webapp/resources/PanelMenuItem.js)
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/PanelMenuItem.js (rev 0)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/PanelMenuItem.js 2010-12-01 15:12:38 UTC (rev 20253)
@@ -0,0 +1,319 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+(function ($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ var __DEFAULT_OPTIONS = {
+ disabled : false,
+ selectable: true,
+ mode: "client",
+ unselectable: false,
+ highlight: true,
+ stylePrefix: "rf-pm-itm",
+ itemStep: 20
+ };
+
+ var SELECT_ITEM = {
+
+ /**
+ *
+ * @return {void}
+ * */
+ exec : function (item) {
+ var mode = item.mode;
+ if (mode == "server") {
+ return this.execServer(item);
+ } else if (mode == "ajax") {
+ return this.execAjax(item);
+ } else if (mode == "client" || mode == "none") {
+ return this.execClient(item);
+ } else {
+ rf.log.error("SELECT_ITEM.exec : unknown mode (" + mode + ")");
+ }
+ },
+
+ /**
+ * @protected
+ *
+ * @return {Boolean} false
+ * */
+ execServer : function (item) {
+ item.__changeState();
+ rf.submitForm(this.__getParentForm(item));
+
+ return false;
+ },
+
+ /**
+ * @protected
+ *
+ * @return {Boolean} false
+ * */
+ execAjax : function (item) {
+ var oldItem = item.__changeState();
+ rf.ajax(item.__panelMenu().id, null, $.extend({}, item.options["ajax"], {}));
+ item.__restoreState(oldItem);
+
+ return true;
+ },
+
+ /**
+ * @protected
+ *
+ * @return {undefined}
+ * - false - if process has been terminated
+ * - true - in other cases
+ * */
+ execClient : function (item) {
+ var panelMenu = item.__rfPanelMenu();
+ if (panelMenu.selectedItem()) {
+ panelMenu.getItems()[panelMenu.selectedItem()].unselect();
+ }
+ panelMenu.selectedItem(item.itemName);
+
+ item.__select();
+
+ return item.__fireSelect();
+ },
+
+ /**
+ * @private
+ * */
+ __getParentForm : function (item) {
+ return $($(rf.getDomElement(item.id)).parents("form")[0]);
+ }
+ };
+
+ rf.ui.PanelMenuItem = rf.BaseComponent.extendClass({
+ // class name
+ name:"PanelMenuItem",
+
+ /**
+ * @class PanelMenuItem
+ * @name PanelMenuItem
+ *
+ * @constructor
+ * @param {String} componentId - component id
+ * @param {Hash} options - params
+ * */
+ init : function (componentId, options) {
+ this.id = componentId;
+ this.attachToDom(componentId);
+
+ this.options = $.extend({}, __DEFAULT_OPTIONS, this.options || {}, options || {});
+
+ this.mode = this.options.mode
+ this.itemName = this.options.name
+ this.__rfPanelMenu().getItems()[this.itemName] = this;
+
+ // todo move it
+ this.selectionClass = this.options.stylePrefix + "-sel";
+ this.hoverClass = this.options.stylePrefix + "-hov";
+
+ if (!this.options.disabled) {
+ var item = this;
+ if (this.options.highlight) {
+ this.__item().bind("mouseenter", function() {
+ item.highlight(true);
+ });
+ this.__item().bind("mouseleave", function() {
+ item.highlight(false);
+ });
+ }
+
+ if (this.options.selectable) {
+ this.__header().bind("click", function() {
+ if (item.__rfPanelMenu().selectedItem() == item.id) {
+ if (item.options.unselectable) {
+ return item.unselect();
+ }
+
+ // we shouldn't select one item several times
+ } else {
+ return item.select();
+ }
+ });
+ }
+ }
+
+ item = this;
+ $(this.__panelMenu()).ready(function () {
+ item.__renderNestingLevel();
+ });
+
+ this.__addUserEventHandler("select");
+ },
+
+ /***************************** Public Methods ****************************************************************/
+ highlight : function (highlight) {
+ if (highlight && !this.selected()) {
+ this.__header().addClass(this.hoverClass);
+ } else {
+ this.__header().removeClass(this.hoverClass);
+ }
+ },
+
+ selected : function () {
+ return this.__header().hasClass(this.selectionClass);
+ },
+
+ /**
+ * @methodOf
+ * @name PanelMenuItem#select
+ *
+ * TODO ...
+ *
+ * @return {void} TODO ...
+ */
+ select: function () {
+ var continueProcess = this.__fireBeforeSelect();
+ if (!continueProcess) {
+ return false;
+ }
+
+ return SELECT_ITEM.exec(this)
+ },
+
+ /**
+ * please, remove this method when client side ajax events will be added
+ *
+ * */
+ onCompleteHandler : function () {
+ SELECT_ITEM.execClient(this);
+ },
+
+ unselect: function () {
+ var panelMenu = this.__rfPanelMenu();
+ if (panelMenu.selectedItem() == this.itemName) {
+ panelMenu.selectedItem(null);
+ } else {
+ rf.warn("You try unselect item (name=" + this.itemName + ") that isn't seleted")
+ }
+
+ this.__unselect();
+
+ return this.__fireUnselect();
+ },
+
+ /***************************** Private Methods ****************************************************************/
+ __rfParentItem : function () {
+ var res = this.__item().parents(".rf-pm-gr")[0];
+ if (!res) {
+ res = this.__item().parents(".rf-pm-top-gr")[0];
+ }
+
+ if (!res) {
+ res = this.__panelMenu();
+ }
+
+ return res ? rf.$(res) : null;
+ },
+
+ __getNestingLevel : function () {
+ if (!this.nestingLevel) {
+ var parentItem = this.__rfParentItem();
+ if (parentItem && parentItem.__getNestingLevel) {
+ this.nestingLevel = parentItem.__getNestingLevel() + 1;
+ } else {
+ this.nestingLevel = 0;
+ }
+ }
+
+ return this.nestingLevel;
+ },
+
+ __renderNestingLevel : function () {
+ this.__item().find("td").first().css("padding-left", this.options.itemStep * this.__getNestingLevel());
+ },
+
+ __panelMenu : function () {
+ return this.__item().parents(".rf-pm")[0];
+ },
+
+ __rfPanelMenu : function () {
+ return rf.$(this.__item().parents(".rf-pm")[0]);
+ },
+
+ __changeState : function () {
+ return this.__rfPanelMenu().selectedItem(this.itemName);
+ },
+
+ __restoreState : function (state) {
+ if (state) {
+ this.__rfPanelMenu().selectedItem(state);
+ }
+ },
+
+ __item : function () {
+ return $(rf.getDomElement(this.id));
+ },
+
+ __header : function () {
+ return this.__item();
+ },
+
+ __select: function () {
+ this.__header().addClass(this.selectionClass);
+ },
+
+ __unselect: function () {
+ this.__header().removeClass(this.selectionClass);
+ },
+
+ __fireBeforeSelect : function () {
+ return new rf.Event.fireById(this.id, "beforeselect", {
+ id: this.id
+ });
+ },
+
+ __fireSelect : function () {
+ return new rf.Event.fireById(this.id, "select", {
+ id: this.id
+ });
+ },
+
+ __fireUnselect : function () {
+ return new rf.Event.fireById(this.id, "unselect", {
+ id: this.id
+ });
+ },
+
+ /**
+ * @private
+ * */
+ __addUserEventHandler : function (name) {
+ var handler = this.options["on" + name];
+ if (handler) {
+ rf.Event.bindById(this.id, name, handler);
+ }
+ },
+
+ destroy: function () {
+ delete this.__rfPanelMenu().getItems()[this.itemName];
+
+ rf.ui.PanelMenuItem.$super.destroy.call(this);
+ }
+ });
+})(jQuery, RichFaces);
Modified: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/panelMenu.ecss
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/panelMenu.ecss 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/panelMenu.ecss 2010-12-01 15:12:38 UTC (rev 20253)
@@ -62,6 +62,10 @@
margin: 0px 3px;
}
+.rf-pm-itm-dis {
+ color: #BED6F8;
+}
+
.rf-pm-itm-hov {
background-color: '#{richSkin.additionalBackgroundColor}';
}
@@ -79,10 +83,14 @@
margin-bottom: 3px
}
+.rf-pm-gr-dis {
+ color: #BED6F8;
+}
+
.rf-pm-gr-hov {
background: '#{richSkin.additionalBackgroundColor}';
- color: white;
+ color: white; /*TODO skin?*/
}
.rf-pm-gr-sel {
@@ -169,6 +177,10 @@
margin: 0px 3px;
}
+.rf-pm-top-itm-dis {
+ color: #BED6F8;
+}
+
.rf-pm-top-itm-hov {
background-color:#ffd700;
}
@@ -185,9 +197,13 @@
margin-bottom: 3px
}
+.rf-pm-top-gr-dis {
+ color: #BED6F8;
+}
+
.rf-pm-top-gr-hov {
background-color: green;
- color: white;
+ color: white; /*TODO skin?*/
}
.rf-pm-top-gr-sel {
@@ -251,17 +267,20 @@
display: block;
}
+.rf-pm-ico-colps {}
+.rf-pm-ico-exp {}
+
/* Icons */
-.rf-pm-chevron { background-image: "url(#{resource['org.richfaces.images:Chevron.png']})" }
-.rf-pm-chevron-down { background-image: "url(#{resource['org.richfaces.images:ChevronDown.png']})" }
-.rf-pm-chevron-left { background-image: "url(#{resource['org.richfaces.images:ChevronLeft.png']})" }
-.rf-pm-chevron-up { background-image: "url(#{resource['org.richfaces.images:ChevronUp.png']})" }
-.rf-pm-disc { background-image: "url(#{resource['org.richfaces.images:Disc.png']})" }
-.rf-pm-grid { background-image: "url(#{resource['org.richfaces.images:Grid.png']})" }
-.rf-pm-spacer { background-image: "url(#{resource['org.richfaces.images:Spacer.png']})" }
-.rf-pm-triangle { background-image: "url(#{resource['org.richfaces.images:Triangle.png']})" }
-.rf-pm-triangle-down { background-image: "url(#{resource['org.richfaces.images:TriangleDown.png']})" }
-.rf-pm-triangle-left { background-image: "url(#{resource['org.richfaces.images:TriangleLeft.png']})" }
-.rf-pm-triangle-up { background-image: "url(#{resource['org.richfaces.images:TriangleUp.png']})" }
\ No newline at end of file
+.rf-pm-chevron { width: 16px; height: 16px; background-image: "url(#{resource['org.richfaces.images:Chevron.png']})" }
+.rf-pm-chevron-down { width: 16px; height: 16px; background-image: "url(#{resource['org.richfaces.images:ChevronDown.png']})" }
+.rf-pm-chevron-left { width: 16px; height: 16px; background-image: "url(#{resource['org.richfaces.images:ChevronLeft.png']})" }
+.rf-pm-chevron-up { width: 16px; height: 16px; background-image: "url(#{resource['org.richfaces.images:ChevronUp.png']})" }
+.rf-pm-disc { width: 16px; height: 16px; background-image: "url(#{resource['org.richfaces.images:Disc.png']})" }
+.rf-pm-grid { width: 16px; height: 16px; background-image: "url(#{resource['org.richfaces.images:Grid.png']})" }
+.rf-pm-spacer { width: 16px; height: 16px; background-image: "url(#{resource['org.richfaces.images:Spacer.png']})" }
+.rf-pm-triangle { width: 16px; height: 16px; background-image: "url(#{resource['org.richfaces.images:Triangle.png']})" }
+.rf-pm-triangle-down { width: 16px; height: 16px; background-image: "url(#{resource['org.richfaces.images:TriangleDown.png']})" }
+.rf-pm-triangle-left { width: 16px; height: 16px; background-image: "url(#{resource['org.richfaces.images:TriangleLeft.png']})" }
+.rf-pm-triangle-up { width: 16px; height: 16px; background-image: "url(#{resource['org.richfaces.images:TriangleUp.png']})" }
\ No newline at end of file
Modified: trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/PanelMenuGroupRendererTest.java
===================================================================
--- trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/PanelMenuGroupRendererTest.java 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/PanelMenuGroupRendererTest.java 2010-12-01 15:12:38 UTC (rev 20253)
@@ -25,11 +25,15 @@
import java.io.IOException;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
import org.junit.Ignore;
import org.junit.Test;
import org.xml.sax.SAXException;
- /**
+import static org.junit.Assert.assertNotNull;
+
+/**
* @author akolonitsky
* @since 2010-10-25
*/
@@ -50,6 +54,30 @@
doTest("panelMenuGroup-topGroup", "f:panelMenuGroup");
}
+ @Test
+ public void testIconsInheritanceTopGroup() throws IOException, SAXException {
+ doTest("panelMenu-icons-inheritance", "panelMenu-icons-inheritance-topGroup", "f:panelMenuGroup-top");
+ doTest("panelMenu-icons-inheritance", "panelMenu-icons-inheritance-topGroupDis", "f:panelMenuGroup-topDis");
+ }
+
+ @Test
+ public void testIconsInheritanceTopItem() throws IOException, SAXException {
+ doTest("panelMenu-icons-inheritance", "panelMenu-icons-inheritance-topItem", "f:panelMenuItem-top");
+ doTest("panelMenu-icons-inheritance", "panelMenu-icons-inheritance-topItemDis", "f:panelMenuItem-topDis");
+ }
+
+ @Test
+ public void testIconsInheritanceItem() throws IOException, SAXException {
+ doTest("panelMenu-icons-inheritance", "panelMenu-icons-inheritance-item", "f:panelMenuItem");
+ doTest("panelMenu-icons-inheritance", "panelMenu-icons-inheritance-itemDis", "f:panelMenuItem-dis");
+ }
+
+ @Test
+ public void testIconsInheritanceGroup() throws IOException, SAXException {
+ doTest("panelMenu-icons-inheritance", "panelMenu-icons-inheritance-group", "f:panelMenuGroup");
+ doTest("panelMenu-icons-inheritance", "panelMenu-icons-inheritance-groupDis", "f:panelMenuGroup-dis");
+ }
+
}
Modified: trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
===================================================================
--- trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java 2010-12-01 15:12:38 UTC (rev 20253)
@@ -71,17 +71,21 @@
}
protected void doTest(String pageName, String pageElementToTest) throws IOException, SAXException {
- HtmlPage page = environment.getPage('/' + pageName + ".jsf");
+ doTest(pageName, pageName, pageElementToTest);
+ }
+
+ protected void doTest(String jsfPage, String xmlPage, String pageElementToTest) throws IOException, SAXException {
+ HtmlPage page = environment.getPage('/' + jsfPage + ".jsf");
HtmlElement panel = page.getElementById(pageElementToTest);
assertNotNull(panel);
- checkXmlStructure(pageName, panel.asXml());
+ checkXmlStructure(xmlPage, panel.asXml());
}
protected void checkXmlStructure(String pageName, String pageCode) throws SAXException, IOException {
InputStream expectedPageCode = this.getClass().getResourceAsStream(pageName + ".xmlunit.xml");
if (expectedPageCode == null) {
- return;
+ throw new IllegalArgumentException("Page: " + pageName + ".xmlunit.xml doesn't exist.");
}
Diff xmlDiff = new Diff(new InputStreamReader(expectedPageCode), new StringReader(pageCode));
Added: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-group.xmlunit.xml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-group.xmlunit.xml (rev 0)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-group.xmlunit.xml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -0,0 +1,26 @@
+<div id="f:panelMenuGroup" class="rf-pm-gr groupClass">
+ <input id="f:panelMenuGroup:expanded" name="f:panelMenuGroup:expanded" type="hidden" value="false"/>
+ <div id="f:panelMenuGroup:hdr" class="rf-pm-gr-hdr">
+ <table class="rf-pm-gr-gr">
+ <tbody>
+ <tr>
+ <td class="rf-pm-gr-ico">
+ <div class="rf-pm-ico-colps rf-pm-triangle-down" style="display:block"></div>
+ <div class="rf-pm-ico-exp rf-pm-disc" style="display:none"></div>
+ </td>
+ <td class="rf-pm-gr-lbl">panelMenuGroup-top</td>
+ <td class="rf-pm-gr-exp-ico">
+ <div class="rf-pm-ico-colps rf-pm-triangle-up" style="display:block"></div>
+ <div class="rf-pm-ico-exp rf-pm-disc" style="display:none"></div>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ <div id="f:panelMenuGroup:cnt" class="rf-pm-gr-cnt rf-pm-colps">
+ <script type="text/javascript">
+ // Text
+ </script>
+
+ </div>
+</div>
\ No newline at end of file
Added: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-groupDis.xmlunit.xml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-groupDis.xmlunit.xml (rev 0)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-groupDis.xmlunit.xml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -0,0 +1,26 @@
+<div id="f:panelMenuGroup-dis" class="rf-pm-gr groupClass rf-pm-gr-dis groupDisableClass">
+ <input id="f:panelMenuGroup-dis:expanded" name="f:panelMenuGroup-dis:expanded" type="hidden" value="false"/>
+ <div id="f:panelMenuGroup-dis:hdr" class="rf-pm-gr-hdr">
+ <table class="rf-pm-gr-gr">
+ <tbody>
+ <tr>
+ <td class="rf-pm-gr-ico">
+ <div class="rf-pm-ico-colps rf-pm-chevron-down" style="display:block"></div>
+ <div class="rf-pm-ico-exp rf-pm-chevron-down" style="display:none"></div>
+ </td>
+ <td class="rf-pm-gr-lbl">panelMenuGroup-top</td>
+ <td class="rf-pm-gr-exp-ico">
+ <div class="rf-pm-ico-colps rf-pm-chevron-up" style="display:block"></div>
+ <div class="rf-pm-ico-exp rf-pm-chevron-up" style="display:none"></div>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ <div id="f:panelMenuGroup-dis:cnt" class="rf-pm-gr-cnt rf-pm-colps">
+ <script type="text/javascript">
+ // Text
+ </script>
+
+ </div>
+</div>
\ No newline at end of file
Added: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-item.xmlunit.xml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-item.xmlunit.xml (rev 0)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-item.xmlunit.xml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -0,0 +1,15 @@
+<div id="f:panelMenuItem" class="rf-pm-itm itemClass">
+ <table class="rf-pm-itm-gr">
+ <tbody>
+ <tr>
+ <td class="rf-pm-itm-ico rf-pm-triangle-down"></td>
+ <td class="rf-pm-itm-lbl">panelMenuItem</td>
+ <td class="rf-pm-itm-exp-ico rf-pm-triangle-up"></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <script type="text/javascript">
+ // Text
+ </script>
+</div>
Added: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-itemDis.xmlunit.xml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-itemDis.xmlunit.xml (rev 0)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-itemDis.xmlunit.xml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -0,0 +1,15 @@
+<div id="f:panelMenuItem-dis" class="rf-pm-itm itemClass rf-pm-itm-dis itemDisableClass">
+ <table class="rf-pm-itm-gr">
+ <tbody>
+ <tr>
+ <td class="rf-pm-itm-ico rf-pm-chevron-down"></td>
+ <td class="rf-pm-itm-lbl">panelMenuItem</td>
+ <td class="rf-pm-itm-exp-ico rf-pm-chevron-up"></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <script type="text/javascript">
+ // Text
+ </script>
+</div>
Added: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-topGroup.xmlunit.xml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-topGroup.xmlunit.xml (rev 0)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-topGroup.xmlunit.xml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -0,0 +1,26 @@
+<div id="f:panelMenuGroup-top" class="rf-pm-top-gr topGroupClass">
+ <input id="f:panelMenuGroup-top:expanded" name="f:panelMenuGroup-top:expanded" type="hidden" value="false"/>
+ <div id="f:panelMenuGroup-top:hdr" class="rf-pm-top-gr-hdr">
+ <table class="rf-pm-top-gr-gr">
+ <tbody>
+ <tr>
+ <td class="rf-pm-top-gr-ico">
+ <div class="rf-pm-ico-colps rf-pm-triangle" style="display:block"></div>
+ <div class="rf-pm-ico-exp rf-pm-disc" style="display:none"></div>
+ </td>
+ <td class="rf-pm-top-gr-lbl">panelMenuGroup-top</td>
+ <td class="rf-pm-top-gr-exp-ico">
+ <div class="rf-pm-ico-colps rf-pm-triangle" style="display:block"></div>
+ <div class="rf-pm-ico-exp rf-pm-disc" style="display:none"></div>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ <div id="f:panelMenuGroup-top:cnt" class="rf-pm-top-gr-cnt rf-pm-colps">
+ <script type="text/javascript">
+ // Text
+ </script>
+
+ </div>
+</div>
\ No newline at end of file
Added: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-topGroupDis.xmlunit.xml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-topGroupDis.xmlunit.xml (rev 0)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-topGroupDis.xmlunit.xml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -0,0 +1,26 @@
+<div id="f:panelMenuGroup-topDis" class="rf-pm-top-gr topGroupClass rf-pm-top-gr-dis topGroupDisableClass">
+ <input id="f:panelMenuGroup-topDis:expanded" name="f:panelMenuGroup-topDis:expanded" type="hidden" value="false"/>
+ <div id="f:panelMenuGroup-topDis:hdr" class="rf-pm-top-gr-hdr">
+ <table class="rf-pm-top-gr-gr">
+ <tbody>
+ <tr>
+ <td class="rf-pm-top-gr-ico">
+ <div class="rf-pm-ico-colps rf-pm-chevron" style="display:block"></div>
+ <div class="rf-pm-ico-exp rf-pm-chevron" style="display:none"></div>
+ </td>
+ <td class="rf-pm-top-gr-lbl">panelMenuGroup-top</td>
+ <td class="rf-pm-top-gr-exp-ico">
+ <div class="rf-pm-ico-colps rf-pm-chevron" style="display:block"></div>
+ <div class="rf-pm-ico-exp rf-pm-chevron" style="display:none"></div>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ <div id="f:panelMenuGroup-topDis:cnt" class="rf-pm-top-gr-cnt rf-pm-colps">
+ <script type="text/javascript">
+ // Text
+ </script>
+
+ </div>
+</div>
\ No newline at end of file
Added: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-topItem.xmlunit.xml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-topItem.xmlunit.xml (rev 0)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-topItem.xmlunit.xml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -0,0 +1,15 @@
+<div id="f:panelMenuItem-top" class="rf-pm-top-itm topItemClass">
+ <table class="rf-pm-top-itm-gr">
+ <tbody>
+ <tr>
+ <td class="rf-pm-top-itm-ico rf-pm-triangle"></td>
+ <td class="rf-pm-top-itm-lbl">panelMenuItem</td>
+ <td class="rf-pm-top-itm-exp-ico rf-pm-triangle"></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <script type="text/javascript">
+ // Text
+ </script>
+</div>
Added: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-topItemDis.xmlunit.xml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-topItemDis.xmlunit.xml (rev 0)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance-topItemDis.xmlunit.xml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -0,0 +1,15 @@
+<div id="f:panelMenuItem-topDis" class="rf-pm-top-itm topItemClass rf-pm-top-itm-dis topItemDisableClass">
+ <table class="rf-pm-top-itm-gr">
+ <tbody>
+ <tr>
+ <td class="rf-pm-top-itm-ico rf-pm-chevron"></td>
+ <td class="rf-pm-top-itm-lbl">panelMenuItem</td>
+ <td class="rf-pm-top-itm-exp-ico rf-pm-chevron"></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <script type="text/javascript">
+ // Text
+ </script>
+</div>
Added: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance.xhtml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance.xhtml (rev 0)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu-icons-inheritance.xhtml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -0,0 +1,93 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright ${year}, Red Hat, Inc. and individual contributors
+ by the @authors tag. See the copyright.txt in the distribution for a
+ full listing of individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:fn="http://java.sun.com/jsp/jstl/functions"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:pn="http://richfaces.org/output"
+ xmlns:rich="http://richfaces.org/rich">
+
+ <h:head>
+ <title>Richfaces PanelMenuGroup Test</title>
+ </h:head>
+
+<h:body>
+ <h:form id="f">
+ <pn:panelMenu
+ itemIconRight="triangleUp"
+ itemIconLeft="triangleDown"
+ itemClass="itemClass"
+
+ itemDisableIconRight="chevronUp"
+ itemDisableIconLeft="chevronDown"
+ itemDisableClass="itemDisableClass"
+
+ topItemIconRight="triangle"
+ topItemIconLeft="triangle"
+ topItemClass="topItemClass"
+
+ topItemDisableIconRight="chevron"
+ topItemDisableIconLeft="chevron"
+ topItemDisableClass="topItemDisableClass"
+
+ groupCollapseIconRight="triangleUp"
+ groupExpandIconRight="disc"
+ groupCollapseIconLeft="triangleDown"
+ groupExpandIconLeft="disc"
+ groupClass="groupClass"
+
+ groupDisableIconRight="chevronUp"
+ groupDisableIconLeft="chevronDown"
+ groupDisableClass="groupDisableClass"
+
+ topGroupCollapseIconRight="triangle"
+ topGroupExpandIconRight="disc"
+ topGroupCollapseIconLeft="triangle"
+ topGroupExpandIconLeft="disc"
+ topGroupClass="topGroupClass"
+
+ topGroupDisableIconRight="chevron"
+ topGroupDisableIconLeft="chevron"
+ topGroupDisableClass="topGroupDisableClass"
+ >
+
+ <pn:panelMenuGroup id="panelMenuGroup-top"></pn:panelMenuGroup>
+ <pn:panelMenuGroup id="panelMenuGroup-topDis" disabled="true"></pn:panelMenuGroup>
+ <pn:panelMenuItem id="panelMenuItem-top"></pn:panelMenuItem>
+ <pn:panelMenuItem id="panelMenuItem-topDis" disabled="true"></pn:panelMenuItem>
+ <pn:panelMenuGroup>
+ <pn:panelMenuGroup id="panelMenuGroup"></pn:panelMenuGroup>
+ <pn:panelMenuGroup id="panelMenuGroup-dis" disabled="true"></pn:panelMenuGroup>
+ <pn:panelMenuItem id="panelMenuItem"></pn:panelMenuItem>
+ <pn:panelMenuItem id="panelMenuItem-dis" disabled="true"></pn:panelMenuItem>
+ </pn:panelMenuGroup>
+ </pn:panelMenu>
+ </h:form>
+</h:body>
+</html>
+
+
Modified: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup-expanded.xhtml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup-expanded.xhtml 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup-expanded.xhtml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -37,9 +37,13 @@
<h:body>
<h:form id="f" style="border:blue solid thin;">
- <pn:panelMenuGroup id="panelMenuGroup" expanded="true" label="Group Label">
- <!-- TODO -->
- </pn:panelMenuGroup>
+ <pn:panelMenu>
+ <pn:panelMenuGroup>
+ <pn:panelMenuGroup id="panelMenuGroup" expanded="true" label="Group Label">
+ <!-- TODO -->
+ </pn:panelMenuGroup>
+ </pn:panelMenuGroup>
+ </pn:panelMenu>
</h:form>
</h:body>
</html>
Modified: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup-expanded.xmlunit.xml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup-expanded.xmlunit.xml 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup-expanded.xmlunit.xml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -4,9 +4,15 @@
<table class="rf-pm-gr-gr">
<tbody>
<tr>
- <td class="rf-pm-gr-ico rf-pm-grid"></td>
+ <td class="rf-pm-gr-ico">
+ <div class="rf-pm-ico-colps rf-pm-grid" style="display:none"></div>
+ <div class="rf-pm-ico-exp rf-pm-grid" style="display:block"></div>
+ </td>
<td class="rf-pm-gr-lbl">Group Label</td>
- <td class="rf-pm-gr-exp-ico rf-pm-triangle-down"></td>
+ <td class="rf-pm-gr-exp-ico">
+ <div class="rf-pm-ico-colps rf-pm-grid" style="display:none"></div>
+ <div class="rf-pm-ico-exp rf-pm-grid" style="display:block"></div>
+ </td>
</tr>
</tbody>
</table>
Modified: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup-topGroup.xmlunit.xml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup-topGroup.xmlunit.xml 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup-topGroup.xmlunit.xml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -4,9 +4,15 @@
<table class="rf-pm-top-gr-gr">
<tbody>
<tr>
- <td class="rf-pm-top-gr-ico rf-pm-grid"></td>
+ <td class="rf-pm-top-gr-ico">
+ <div class="rf-pm-ico-colps rf-pm-grid" style="display:none"></div>
+ <div class="rf-pm-ico-exp rf-pm-grid" style="display:block"></div>
+ </td>
<td class="rf-pm-top-gr-lbl">Group Label</td>
- <td class="rf-pm-top-gr-exp-ico rf-pm-triangle-down"></td>
+ <td class="rf-pm-top-gr-exp-ico">
+ <div class="rf-pm-ico-colps rf-pm-grid" style="display:none"></div>
+ <div class="rf-pm-ico-exp rf-pm-grid" style="display:block"></div>
+ </td>
</tr>
</tbody>
</table>
Modified: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup.xhtml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup.xhtml 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup.xhtml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -37,9 +37,13 @@
<h:body>
<h:form id="f" style="border:blue solid thin;">
- <pn:panelMenuGroup id="panelMenuGroup">
- <!-- TODO -->
- </pn:panelMenuGroup>
+ <pn:panelMenu>
+ <pn:panelMenuGroup>
+ <pn:panelMenuGroup id="panelMenuGroup">
+ <!-- TODO -->
+ </pn:panelMenuGroup>
+ </pn:panelMenuGroup>
+ </pn:panelMenu>
</h:form>
</h:body>
</html>
Modified: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup.xmlunit.xml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup.xmlunit.xml 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuGroup.xmlunit.xml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -4,9 +4,15 @@
<table class="rf-pm-gr-gr">
<tbody>
<tr>
- <td class="rf-pm-gr-ico rf-pm-grid"></td>
+ <td class="rf-pm-gr-ico">
+ <div class="rf-pm-ico-colps rf-pm-grid" style="display:block"></div>
+ <div class="rf-pm-ico-exp rf-pm-grid" style="display:none"></div>
+ </td>
<td class="rf-pm-gr-lbl">panelMenuGroup</td>
- <td class="rf-pm-gr-exp-ico rf-pm-triangle-down"></td>
+ <td class="rf-pm-gr-exp-ico">
+ <div class="rf-pm-ico-colps rf-pm-grid" style="display:block"></div>
+ <div class="rf-pm-ico-exp rf-pm-grid" style="display:none"></div>
+ </td>
</tr>
</tbody>
</table>
Modified: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuItem.xhtml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuItem.xhtml 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuItem.xhtml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -37,9 +37,13 @@
<h:body>
<h:form id="f" style="border:blue solid thin;">
- <pn:panelMenuItem id="panelMenuItem">
- <!-- TODO -->
- </pn:panelMenuItem>
+ <pn:panelMenu>
+ <pn:panelMenuGroup>
+ <pn:panelMenuItem id="panelMenuItem">
+ <!-- TODO -->
+ </pn:panelMenuItem>
+ </pn:panelMenuGroup>
+ </pn:panelMenu>
</h:form>
</h:body>
</html>
Modified: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuItem.xmlunit.xml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuItem.xmlunit.xml 2010-12-01 15:01:15 UTC (rev 20252)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenuItem.xmlunit.xml 2010-12-01 15:12:38 UTC (rev 20253)
@@ -4,7 +4,7 @@
<tr>
<td class="rf-pm-itm-ico rf-pm-grid"></td>
<td class="rf-pm-itm-lbl">panelMenuItem</td>
- <td class="rf-pm-itm-exp-ico rf-pm-triangle-down"></td>
+ <td class="rf-pm-itm-exp-ico rf-pm-grid"></td>
</tr>
</tbody>
</table>
15 years, 1 month