Author: alexsmirnov
Date: 2010-11-01 18:21:36 -0400 (Mon, 01 Nov 2010)
New Revision: 19864
Added:
branches/RF-8742/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
branches/RF-8742/examples/iteration-demo/src/main/java/org/richfaces/demo/TracingSet.java
branches/RF-8742/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/BaseTreeImage.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineImage.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineLastImage.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeMinusImage.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreePlusImage.java
Removed:
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/last.gif
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/line.gif
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/minus.gif
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/plus.gif
Modified:
branches/RF-8742/
branches/RF-8742/examples/input-demo/src/main/webapp/examples/calendar.xhtml
branches/RF-8742/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java
branches/RF-8742/examples/iteration-demo/src/main/webapp/tree.xhtml
branches/RF-8742/examples/pom.xml
branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.ecss
branches/RF-8742/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionEvent.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties
Log:
Merged revisions 19852-19855,19857-19860 via svnmerge from
https://svn.jboss.org/repos/richfaces/trunk
.......
r19852 | amarkhel | 2010-11-01 09:20:40 -0700 (Mon, 01 Nov 2010) | 1 line
RF-9603
.......
r19853 | amarkhel | 2010-11-01 09:23:04 -0700 (Mon, 01 Nov 2010) | 1 line
extend calendar demo
.......
r19854 | nbelaevski | 2010-11-01 09:42:07 -0700 (Mon, 01 Nov 2010) | 2 lines
https://jira.jboss.org/browse/RF-9315
- selection refactoring
.......
r19855 | amarkhel | 2010-11-01 09:54:18 -0700 (Mon, 01 Nov 2010) | 1 line
RF-9598, RF-9594
.......
r19857 | nbelaevski | 2010-11-01 11:02:02 -0700 (Mon, 01 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9316
.......
r19858 | nbelaevski | 2010-11-01 12:09:23 -0700 (Mon, 01 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9609
.......
r19859 | nbelaevski | 2010-11-01 12:11:05 -0700 (Mon, 01 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9600
.......
r19860 | nbelaevski | 2010-11-01 12:15:29 -0700 (Mon, 01 Nov 2010) | 1 line
Added mergeinfo for RF-7817
.......
Property changes on: branches/RF-8742
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-19851
+ /trunk:1-19863
Copied:
branches/RF-8742/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
(from rev 19860,
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java)
===================================================================
---
branches/RF-8742/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
(rev 0)
+++
branches/RF-8742/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -0,0 +1,86 @@
+package org.richfaces.demo;
+
+import java.util.Date;
+import java.util.Locale;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+import javax.faces.event.ValueChangeEvent;
+
+@ManagedBean
+@RequestScoped
+public class CalendarBean {
+
+ private Locale locale;
+ private boolean popup;
+ private String pattern;
+ private Date selectedDate;
+ private boolean showApply = true;
+ private boolean useCustomDayLabels;
+
+ public CalendarBean() {
+
+ locale = Locale.US;
+ popup = true;
+ pattern = "d/M/yy HH:mm";
+ }
+
+ public Locale getLocale() {
+ return locale;
+ }
+
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+ public boolean isPopup() {
+ return popup;
+ }
+
+ public void setPopup(boolean popup) {
+ this.popup = popup;
+ }
+
+ public String getPattern() {
+ return pattern;
+ }
+
+ public void setPattern(String pattern) {
+ this.pattern = pattern;
+ }
+
+ public void selectLocale(ValueChangeEvent event) {
+
+ String tLocale = (String) event.getNewValue();
+ if (tLocale != null) {
+ String lang = tLocale.substring(0, 2);
+ String country = tLocale.substring(3);
+ locale = new Locale(lang, country, "");
+ }
+ }
+
+ public boolean isUseCustomDayLabels() {
+ return useCustomDayLabels;
+ }
+
+ public void setUseCustomDayLabels(boolean useCustomDayLabels) {
+ this.useCustomDayLabels = useCustomDayLabels;
+ }
+
+ public Date getSelectedDate() {
+ return selectedDate;
+ }
+
+ public void setSelectedDate(Date selectedDate) {
+ this.selectedDate = selectedDate;
+ }
+
+ public boolean isShowApply() {
+ return showApply;
+ }
+
+ public void setShowApply(boolean showApply) {
+ this.showApply = showApply;
+ }
+
+}
\ No newline at end of file
Modified: branches/RF-8742/examples/input-demo/src/main/webapp/examples/calendar.xhtml
===================================================================
---
branches/RF-8742/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-01
21:31:19 UTC (rev 19863)
+++
branches/RF-8742/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-01
22:21:36 UTC (rev 19864)
@@ -29,13 +29,52 @@
Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-->
- <h:head>
- <title>Richfaces Calendar Demo</title>
- </h:head>
- <h:body>
- <h:form id="form">
- <calendar:calendar popup="true"/>
- <h:commandButton value="submit"></h:commandButton>
- </h:form>
- </h:body>
+<h:head>
+ <title>Richfaces Calendar Demo</title>
+</h:head>
+<h:body>
+ <h:form id="form">
+ <h:panelGrid id="panel" columns="2">
+ <h:panelGroup layout="block">
+ <calendar:calendar value="#{calendarBean.selectedDate}"
id="calendar"
+ locale="#{calendarBean.locale}" popup="#{calendarBean.popup}"
+ datePattern="#{calendarBean.pattern}"
+ showApplyButton="#{calendarBean.showApply}" cellWidth="24px"
+ cellHeight="22px" style="width:200px">
+ <f:convertDateTime pattern="#{calendarBean.pattern}"
+ onchange="alert('1')" />
+ </calendar:calendar>
+ </h:panelGroup>
+ <h:panelGrid columns="2">
+ <h:outputText value="Popup Mode:" />
+ <h:selectBooleanCheckbox value="#{calendarBean.popup}">
+ <f:ajax event="click" execute="@form" render="calendar
@this" />
+ </h:selectBooleanCheckbox>
+ <h:outputText value="Apply Button:" />
+ <h:selectBooleanCheckbox value="#{calendarBean.showApply}">
+ <f:ajax event="click" execute="@form" render="calendar
@this" />
+ </h:selectBooleanCheckbox>
+ <h:outputText value="Select Locale" />
+ <h:selectOneRadio value="en/US"
+ valueChangeListener="#{calendarBean.selectLocale}">
+ <f:ajax execute="@form" event="click" render="calendar
@this" />
+ <f:selectItem itemLabel="US" itemValue="en/US" />
+ <f:selectItem itemLabel="DE" itemValue="de/DE" />
+ <f:selectItem itemLabel="FR" itemValue="fr/FR" />
+ <f:selectItem itemLabel="RU" itemValue="ru/RU" />
+ </h:selectOneRadio>
+
+ <h:outputText value="Select Date Pattern:" />
+ <h:selectOneMenu value="#{calendarBean.pattern}">
+ <f:ajax execute="@form" event="change" render="calendar
@this" />
+ <f:selectItem itemLabel="d/M/yy HH:mm" itemValue="d/M/yy
HH:mm" />
+ <f:selectItem itemLabel="dd/M/yy hh:mm a"
+ itemValue="dd/M/yy hh:mm a" />
+ <f:selectItem itemLabel="d/MMM/y" itemValue="d/MMM/y" />
+ <f:selectItem itemLabel="MMM d, yyyy" itemValue="MMM d, yyyy"
/>
+ </h:selectOneMenu>
+ </h:panelGrid>
+ </h:panelGrid>
+ </h:form>
+</h:body>
</html>
Copied:
branches/RF-8742/examples/iteration-demo/src/main/java/org/richfaces/demo/TracingSet.java
(from rev 19860,
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TracingSet.java)
===================================================================
---
branches/RF-8742/examples/iteration-demo/src/main/java/org/richfaces/demo/TracingSet.java
(rev 0)
+++
branches/RF-8742/examples/iteration-demo/src/main/java/org/richfaces/demo/TracingSet.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -0,0 +1,117 @@
+/*
+ * 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.demo;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import org.richfaces.log.LogFactory;
+import org.richfaces.log.Logger;
+
+import com.google.common.collect.ForwardingIterator;
+import com.google.common.collect.ForwardingSet;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class TracingSet<E> extends ForwardingSet<E> implements Serializable
{
+
+ private static final long serialVersionUID = 267329344963751893L;
+
+ private static final Logger LOGGER = LogFactory.getLogger(TracingSet.class);
+
+ private class TracingIterator extends ForwardingIterator<E> {
+
+ private final Iterator<E> itr = backingCollection.iterator();
+
+ private E lastObject;
+
+ @Override
+ protected Iterator<E> delegate() {
+ return itr;
+ }
+
+ @Override
+ public E next() {
+ try {
+ lastObject = super.next();
+ return lastObject;
+ } catch (NoSuchElementException e) {
+ lastObject = null;
+ throw e;
+ }
+ }
+
+ @Override
+ public void remove() {
+ LOGGER.info("TracingSet.TracingIterator.remove() " + lastObject);
+ super.remove();
+ }
+ }
+
+ private Set<E> backingCollection = new HashSet<E>();
+
+ @Override
+ protected Set<E> delegate() {
+ return backingCollection;
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> collection) {
+ LOGGER.info("TracingSet.removeAll() " + collection);
+ return super.removeAll(collection);
+ }
+
+ @Override
+ public boolean add(E element) {
+ LOGGER.info("TracingSet.add() " + element);
+ return super.add(element);
+ }
+
+ @Override
+ public boolean remove(Object object) {
+ LOGGER.info("TracingSet.remove() " + object);
+ return super.remove(object);
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends E> collection) {
+ LOGGER.info("TracingSet.addAll() " + collection);
+ return super.addAll(collection);
+ }
+
+ @Override
+ public void clear() {
+ LOGGER.info("TracingSet.clear()");
+ super.clear();
+ }
+
+ @Override
+ public Iterator<E> iterator() {
+ return new TracingIterator();
+ }
+}
Modified:
branches/RF-8742/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java
===================================================================
---
branches/RF-8742/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java 2010-11-01
21:31:19 UTC (rev 19863)
+++
branches/RF-8742/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -56,7 +56,7 @@
private Object nodeData;
- private Collection<Object> selection;
+ private Collection<Object> selection = new TracingSet<Object>();
@PostConstruct
public void init() {
Modified: branches/RF-8742/examples/iteration-demo/src/main/webapp/tree.xhtml
===================================================================
--- branches/RF-8742/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-11-01
21:31:19 UTC (rev 19863)
+++ branches/RF-8742/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-11-01
22:21:36 UTC (rev 19864)
@@ -24,7 +24,8 @@
</h:form>
<h:form id="form">
- <it:tree id="tree" nodeType="#{node.parent == null ?
'rootNode': 'childNode'}" var="node"
value="#{treeBean.rootNodes}"
selectionType="#{treeBean.selectionType}"
toggleType="#{treeBean.toggleType}">
+ <it:tree id="tree" nodeType="#{node.parent == null ?
'rootNode': 'childNode'}" var="node"
value="#{treeBean.rootNodes}"
+ selectionType="#{treeBean.selectionType}"
toggleType="#{treeBean.toggleType}"
selection="#{treeBean.selection}">
<it:treeNode type="rootNode">
<h:panelGroup id="rootNodeGroup">
Root node: #{node.data} -
Modified: branches/RF-8742/examples/pom.xml
===================================================================
--- branches/RF-8742/examples/pom.xml 2010-11-01 21:31:19 UTC (rev 19863)
+++ branches/RF-8742/examples/pom.xml 2010-11-01 22:21:36 UTC (rev 19864)
@@ -45,7 +45,7 @@
<module>output-demo</module>
<module>input-demo</module>
<module>repeater-demo</module>
- <!--module>iteration-demo</module-->
+ <module>iteration-demo</module>
<module>richfaces-showcase</module>
<!--<module>dist</module>-->
</modules>
Modified:
branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
---
branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-11-01
21:31:19 UTC (rev 19863)
+++
branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -572,7 +572,7 @@
public void buildAddLocaleScript(ResponseWriter writer, FacesContext facesContext,
UIComponent component) throws IOException {
if(component instanceof AbstractCalendar) {
AbstractCalendar calendar = (AbstractCalendar)component;
- JSFunction function = new
JSFunction("RichFaces.ui.Calendar.addLocale",
CalendarHelper.getAsLocale(facesContext, calendar), getLocaleOptions(facesContext,
calendar));
+ JSFunction function = new
JSFunction("RichFaces.ui.Calendar.addLocale",
CalendarHelper.getAsLocale(facesContext, calendar).toString(),
getLocaleOptions(facesContext, calendar));
writer.write(function.toScript());
writer.write(";");
}
@@ -582,7 +582,7 @@
if(component instanceof AbstractCalendar) {
AbstractCalendar calendar = (AbstractCalendar)component;
ScriptOptions scriptOptions = createCalendarScriptOption(facesContext,
calendar);
- JSFunction function = new JSFunction("new RichFaces.ui.Calendar",
calendar.getClientId(facesContext), CalendarHelper.getAsLocale(facesContext, calendar),
scriptOptions, "");
+ JSFunction function = new JSFunction("new RichFaces.ui.Calendar",
calendar.getClientId(facesContext), CalendarHelper.getAsLocale(facesContext,
calendar).toString(), scriptOptions, "");
StringBuffer scriptBuffer = new StringBuffer();
scriptBuffer.append(function.toScript()).append(".load();");
writer.write(scriptBuffer.toString());
Modified:
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.ecss
===================================================================
---
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.ecss 2010-11-01
21:31:19 UTC (rev 19863)
+++
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.ecss 2010-11-01
22:21:36 UTC (rev 19864)
@@ -243,7 +243,6 @@
.rf-ca-edtr-shdw {
background: '#{richSkin.tableBackgroundColor}';
opacity: 0.5;
- filter: alpha(opacity=50);
}
.rf-ca-time-layout {
@@ -328,18 +327,20 @@
margin: 0px 2px;
}
-.rf-ca-sp-up {
- background-image:
"url(#{resource['org.richfaces.renderkit.html.images.StandardButtonBgImage']})";
+.rf-ca-sp-up, .rf-ca-sp-down {
+ background-repeat: no-repeat;
+ background-position: 50% 40%;
height: 7px;
width: 14px;
- margin: 0px 1px 1px 0px;
+ margin: 0px 1px 1px 0px;
}
+.rf-ca-sp-up {
+ background-image:
"url(#{resource['org.richfaces.renderkit.html.images.SpinnerArrowTop']})";
+}
+
.rf-ca-sp-down {
- background-image:
"url(#{resource['org.richfaces.renderkit.html.images.StandardButtonPressedBgImage']})";
- height: 7px;
- width: 14px;
- margin: 0px 1px 1px 0px;
+ background-image:
"url(#{resource['org.richfaces.renderkit.html.images.SpinnerArrowBottom']})";
}
.rf-ca-sp-press {
@@ -356,7 +357,6 @@
background-color: '#{richSkin.shadowBackgroundColor}';
position: absolute;
opacity: 0.3;
- filter: alpha(opacity=30);
}
.rf-ca-edtr-btn {
Modified:
branches/RF-8742/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionEvent.java
===================================================================
---
branches/RF-8742/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionEvent.java 2010-11-01
21:31:19 UTC (rev 19863)
+++
branches/RF-8742/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionEvent.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -22,7 +22,6 @@
package org.richfaces.event;
import java.util.Collection;
-import java.util.HashSet;
import javax.faces.component.UIComponent;
import javax.faces.event.FacesEvent;
@@ -36,15 +35,15 @@
private static final long serialVersionUID = 6292604445872458007L;
- private Collection<Object> addedKeys = new HashSet<Object>();
+ private Collection<Object> oldSelection;
- private Collection<Object> removedKeys = new HashSet<Object>();
+ private Collection<Object> newSelection;
- public TreeSelectionEvent(UIComponent component, Collection<Object> addedKeys,
Collection<Object> removedKeys) {
+ public TreeSelectionEvent(UIComponent component, Collection<Object>
oldSelection, Collection<Object> newSelection) {
super(component);
-
- this.addedKeys = addedKeys;
- this.removedKeys = removedKeys;
+
+ this.oldSelection = oldSelection;
+ this.newSelection = newSelection;
}
@Override
@@ -57,11 +56,12 @@
((TreeSelectionListener) listener).processSelection(this);
}
- public Collection<Object> getAddedKeys() {
- return addedKeys;
+ public Collection<Object> getOldSelection() {
+ return oldSelection;
}
- public Collection<Object> getRemovedKeys() {
- return removedKeys;
+ public Collection<Object> getNewSelection() {
+ return newSelection;
}
+
}
Copied:
branches/RF-8742/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java
(from rev 19860,
trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java)
===================================================================
---
branches/RF-8742/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java
(rev 0)
+++
branches/RF-8742/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -0,0 +1,49 @@
+/*
+ * 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.Iterator;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+//TODO - add necessary methods for tree adaptors support
+public interface TreeDataModel<E> {
+
+ public Object getRowKey();
+
+ public void setRowKey(Object rowKey);
+
+ public boolean isDataAvailable();
+
+ public E getData();
+
+ public Iterator<Object> getChildrenRowKeysIterator(Object rowKey);
+
+ public Object getParentRowKey(Object rowKey);
+
+ public Object getWrappedData();
+
+ public void setWrappedData(Object data);
+
+}
Modified:
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
---
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-01
21:31:19 UTC (rev 19863)
+++
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -43,6 +43,7 @@
import javax.faces.event.ExceptionQueuedEventContext;
import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
+import javax.swing.tree.TreeNode;
import org.ajax4jsf.model.DataComponentState;
import org.ajax4jsf.model.ExtendedDataModel;
@@ -62,10 +63,13 @@
import org.richfaces.event.TreeSelectionListener;
import org.richfaces.event.TreeToggleEvent;
import org.richfaces.event.TreeToggleListener;
-import org.richfaces.model.TreeDataModelImpl;
+import org.richfaces.model.ExtendedTreeDataModelImpl;
+import org.richfaces.model.SwingTreeNodeDataModelImpl;
+import org.richfaces.model.TreeDataModel;
import org.richfaces.renderkit.MetaComponentRenderer;
import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
/**
@@ -209,12 +213,9 @@
getStateHelper().put(PropertyKeys.expanded, this.getClientId(getFacesContext()),
newValue);
}
- /* (non-Javadoc)
- * @see org.richfaces.component.UIDataAdaptor#createExtendedDataModel()
- */
@Override
protected ExtendedDataModel<?> createExtendedDataModel() {
- TreeDataModelImpl model = new TreeDataModelImpl();
+ ExtendedTreeDataModelImpl<?> model = new
ExtendedTreeDataModelImpl<TreeNode>(new SwingTreeNodeDataModelImpl());
model.setWrappedData(getValue());
return model;
}
@@ -234,8 +235,9 @@
return converter;
}
- public Iterator<Object> getChildrenIterator(FacesContext faces, Object rowKey)
{
- return ((TreeDataModelImpl) getExtendedDataModel()).getChildrenIterator(faces,
rowKey);
+ public Iterator<Object> getChildrenRowKeysIterator(FacesContext faces, Object
rowKey) {
+ TreeDataModel<?> dataModel = (TreeDataModel<?>)
getExtendedDataModel();
+ return dataModel.getChildrenRowKeysIterator(rowKey);
}
public AbstractTreeNode getTreeNodeComponent() {
@@ -313,14 +315,18 @@
} else if (event instanceof TreeSelectionEvent) {
TreeSelectionEvent selectionEvent = (TreeSelectionEvent) event;
- Collection<Object> selection = getSelection();
+ final Collection<Object> newSelection =
selectionEvent.getNewSelection();
+
+ Collection<Object> selectionCollection = getSelection();
- for (Object addedKey: selectionEvent.getAddedKeys()) {
- selection.add(addedKey);
- }
+ Iterables.removeIf(selectionCollection, new Predicate<Object>() {
+ public boolean apply(Object input) {
+ return !newSelection.contains(input);
+ };
+ });
- for (Object removedKey: selectionEvent.getRemovedKeys()) {
- selection.remove(removedKey);
+ if (!newSelection.isEmpty()) {
+ Iterables.addAll(selectionCollection, newSelection);
}
}
}
Copied:
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java
(from rev 19860,
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java)
===================================================================
---
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java
(rev 0)
+++
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -0,0 +1,131 @@
+/*
+ * 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.Iterator;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitResult;
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.richfaces.component.TreeRange;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class ExtendedTreeDataModelImpl<E> extends ExtendedDataModel<E>
implements TreeDataModel<E> {
+
+ private TreeDataModel<E> wrappedModel;
+
+ public ExtendedTreeDataModelImpl(TreeDataModel<E> wrappedModel) {
+ super();
+ this.wrappedModel = wrappedModel;
+ }
+
+ public boolean isDataAvailable() {
+ return wrappedModel.isDataAvailable();
+ }
+
+ public E getData() {
+ return wrappedModel.getData();
+ }
+
+ public Iterator<Object> getChildrenRowKeysIterator(Object rowKey) {
+ return wrappedModel.getChildrenRowKeysIterator(rowKey);
+ }
+
+ public Object getParentRowKey(Object rowKey) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setRowKey(Object key) {
+ wrappedModel.setRowKey(key);
+ }
+
+ @Override
+ public Object getRowKey() {
+ return wrappedModel.getRowKey();
+ }
+
+ protected void walk(FacesContext context, DataVisitor visitor, Range range, Object
argument, Iterator<Object> keysIterator) {
+ while (keysIterator.hasNext()) {
+ Object object = (Object) keysIterator.next();
+
+ DataVisitResult visitResult = visitor.process(context, object, argument);
+ if (visitResult == DataVisitResult.CONTINUE) {
+ if (((TreeRange) range).shouldIterateChildren(object)) {
+ Iterator<Object> childrenIterator =
getChildrenRowKeysIterator(object);
+ walk(context, visitor, range, argument, childrenIterator);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void walk(FacesContext context, DataVisitor visitor, Range range, Object
argument) {
+ TreeRange treeRange = (TreeRange) range;
+ if (treeRange.shouldIterateChildren(null)) {
+ Iterator<Object> iterator = getChildrenRowKeysIterator(null);
+ walk(context, visitor, range, argument, iterator);
+ }
+ }
+
+ @Override
+ public boolean isRowAvailable() {
+ return wrappedModel.isDataAvailable();
+ }
+
+ @Override
+ public int getRowCount() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public E getRowData() {
+ return wrappedModel.getData();
+ }
+
+ @Override
+ public int getRowIndex() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setRowIndex(int rowIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Object getWrappedData() {
+ return wrappedModel.getWrappedData();
+ }
+
+ @Override
+ public void setWrappedData(Object data) {
+ wrappedModel.setWrappedData(data);
+ }
+
+
+}
Modified:
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java
===================================================================
---
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java 2010-11-01
21:31:19 UTC (rev 19863)
+++
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -74,4 +74,9 @@
}
return true;
}
+
+ @Override
+ public String toString() {
+ return getClass().getName() + Arrays.toString(simpleKeys);
+ }
}
Copied:
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java
(from rev 19860,
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java)
===================================================================
---
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java
(rev 0)
+++
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -0,0 +1,179 @@
+/*
+ * 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 implements TreeDataModel<TreeNode> {
+
+ /**
+ * @author Nick Belaevski
+ *
+ */
+ private final class FakeRootNode implements TreeNode {
+ 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());
+ }
+ }
+
+ private static final SequenceRowKey<Integer> EMPTY_SEQUENCE_ROW_KEY = new
SequenceRowKey<Integer>();
+
+ private Collection<TreeNode> wrappedData = null;
+
+ private TreeNode fakeRootNode = new FakeRootNode();
+
+ private TreeNode selectedNode;
+
+ private SequenceRowKey<Integer> selectedRowKey;
+
+ private Iterator<TreeNode> findChildren(SequenceRowKey<Integer>
compositeKey) {
+ TreeNode treeNode = findNode(compositeKey);
+
+ if (treeNode == null) {
+ return Iterators.emptyIterator();
+ }
+
+ return Iterators.forEnumeration((Enumeration<TreeNode>)
treeNode.children());
+ }
+
+ private TreeNode findNode(SequenceRowKey<Integer> compositeKey) {
+ if (compositeKey == null) {
+ return null;
+ }
+
+ TreeNode result = fakeRootNode;
+
+ for (Integer simpleKey : compositeKey.getSimpleKeys()) {
+ int idx = simpleKey.intValue();
+
+ if (idx < result.getChildCount()) {
+ result = result.getChildAt(idx);
+ } else {
+ result = null;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ public void setRowKey(Object key) {
+ this.selectedRowKey = (SequenceRowKey<Integer>) key;
+ this.selectedNode = findNode(selectedRowKey);
+ }
+
+ public Object getRowKey() {
+ return selectedRowKey;
+ }
+
+ private SequenceRowKey<Integer> castKeyAndWrapNull(Object rowKey) {
+ if (rowKey == null) {
+ return EMPTY_SEQUENCE_ROW_KEY;
+ }
+
+ return (SequenceRowKey<Integer>) rowKey;
+ }
+
+ public Iterator<Object> getChildrenRowKeysIterator(Object rowKey) {
+ SequenceRowKey<Integer> sequenceKey = castKeyAndWrapNull(rowKey);
+ Iterator<TreeNode> itr = findChildren(sequenceKey);
+
+ return new SequenceRowKeyIterator<TreeNode>(sequenceKey, itr);
+ }
+
+ public TreeNode getData() {
+ if (!isDataAvailable()) {
+ throw new IllegalArgumentException();
+ }
+
+ return selectedNode;
+ }
+
+ public Object getParentRowKey(Object rowKey) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isDataAvailable() {
+ return selectedNode != null;
+ }
+
+ public Object getWrappedData() {
+ return wrappedData;
+ }
+
+ public void setWrappedData(Object wrappedData) {
+ this.wrappedData = (Collection<TreeNode>) wrappedData;
+ }
+}
Deleted:
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java
===================================================================
---
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java 2010-11-01
21:31:19 UTC (rev 19863)
+++
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -1,184 +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 java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.faces.context.FacesContext;
-import javax.swing.tree.TreeNode;
-
-import org.ajax4jsf.model.DataVisitResult;
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.richfaces.component.TreeRange;
-
-import com.google.common.collect.Iterators;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class TreeDataModelImpl extends ExtendedDataModel<TreeNode> {
-
- private static final SequenceRowKey<Integer> EMPTY_SEQUENCE_ROW_KEY = new
SequenceRowKey<Integer>();
-
- private SwingTreeNodeImpl<?> rootNode;
-
- private TreeNode selectedNode;
-
- private SequenceRowKey<Integer> selectedRowKey;
-
- private Iterator<TreeNode> findChildren(SequenceRowKey<Integer>
compositeKey) {
- TreeNode treeNode = findNode(compositeKey);
-
- if (treeNode == null) {
- return Iterators.emptyIterator();
- }
-
- return Iterators.forEnumeration((Enumeration<TreeNode>)
treeNode.children());
- }
-
- private TreeNode findNode(SequenceRowKey<Integer> compositeKey) {
- if (compositeKey == null) {
- return null;
- }
-
- TreeNode result = rootNode;
-
- for (Integer simpleKey : compositeKey.getSimpleKeys()) {
- int idx = simpleKey.intValue();
-
- if (idx < result.getChildCount()) {
- result = result.getChildAt(idx);
- } else {
- result = null;
- break;
- }
- }
-
- return result;
- }
-
- @Override
- public void setRowKey(Object key) {
- this.selectedRowKey = (SequenceRowKey<Integer>) key;
- this.selectedNode = findNode(selectedRowKey);
- }
-
- @Override
- public Object getRowKey() {
- return selectedRowKey;
- }
-
- @Override
- public boolean isRowAvailable() {
- return selectedNode != null;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowCount()
- */
- @Override
- public int getRowCount() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public TreeNode getRowData() {
- return selectedNode;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowIndex()
- */
- @Override
- public int getRowIndex() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#setRowIndex(int)
- */
- @Override
- public void setRowIndex(int rowIndex) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public Object getWrappedData() {
- return rootNode.getChildrenList();
- }
-
- @Override
- public void setWrappedData(Object data) {
- this.rootNode = new SwingTreeNodeImpl((List<TreeNode>) data);
- }
-
- private SequenceRowKey<Integer> castKeyAndWrapNull(Object rowKey) {
- if (rowKey == null) {
- return EMPTY_SEQUENCE_ROW_KEY;
- }
-
- return (SequenceRowKey<Integer>) rowKey;
- }
-
- public Iterator<Object> getChildrenIterator(FacesContext faces, Object rowKey)
{
- SequenceRowKey<Integer> sequenceKey = castKeyAndWrapNull(rowKey);
- Iterator<TreeNode> itr = findChildren(sequenceKey);
-
- return new SequenceRowKeyIterator<TreeNode>(sequenceKey, itr);
- }
-
- protected void walk(FacesContext context, DataVisitor visitor, Range range, Object
argument, Iterator<Object> keysIterator) {
- while (keysIterator.hasNext()) {
- Object object = (Object) keysIterator.next();
-
- DataVisitResult visitResult = visitor.process(context, object, argument);
- if (visitResult == DataVisitResult.CONTINUE) {
- if (((TreeRange) range).shouldIterateChildren(object)) {
- Iterator<Object> childrenIterator =
getChildrenIterator(context, object);
- walk(context, visitor, range, argument, childrenIterator);
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext,
org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)
- */
- @Override
- public void walk(FacesContext context, DataVisitor visitor, Range range, Object
argument) {
- // TODO Auto-generated method stub
-
- if (((TreeRange) range).shouldIterateChildren(null)) {
- Iterator<Object> iterator = getChildrenIterator(context, null);
- walk(context, visitor, range, argument, iterator);
- }
- }
-
-}
Modified:
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
===================================================================
---
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-11-01
21:31:19 UTC (rev 19863)
+++
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -104,7 +104,7 @@
boolean iterateChildren = treeRange.shouldIterateChildren(rowKey);
if (iterateChildren) {
- encodeTree(tree.getChildrenIterator(context, rowKey));
+ encodeTree(tree.getChildrenRowKeysIterator(context, rowKey));
}
QueuedData data = queuedData.removeLast();
Modified:
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java
===================================================================
---
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java 2010-11-01
21:31:19 UTC (rev 19863)
+++
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -38,7 +38,7 @@
public void encode() throws java.io.IOException {
Object initialRowKey = tree.getRowKey();
try {
- encodeTree(tree.getChildrenIterator(context, null));
+ encodeTree(tree.getChildrenRowKeysIterator(context, null));
} finally {
try {
tree.setRowKey(context, initialRowKey);
Modified:
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
---
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-11-01
21:31:19 UTC (rev 19863)
+++
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -29,10 +29,9 @@
import java.io.IOException;
import java.util.Collection;
-import java.util.HashSet;
+import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
-import java.util.Set;
import javax.faces.component.UIComponent;
import javax.faces.component.UINamingContainer;
@@ -54,6 +53,7 @@
import org.richfaces.log.RichfacesLogger;
import com.google.common.base.Strings;
+import com.google.common.collect.Sets;
/**
@@ -304,18 +304,20 @@
Collection<Object> selection = tree.getSelection();
- Set<Object> addedKeys = new HashSet<Object>(2);
- Set<Object> removedKeys = new HashSet<Object>(2);
-
+ Collection<Object> newSelection = null;
+
if (selectionRowKey == null) {
- removedKeys.addAll(selection);
- } else if (!selection.contains(selectionRowKey)) {
- addedKeys.add(selectionRowKey);
- removedKeys.addAll(selection);
+ if (!selection.isEmpty()) {
+ newSelection = Collections.emptySet();
+ }
+ } else {
+ if (!selection.contains(selectionRowKey)) {
+ newSelection = Collections.singleton(selectionRowKey);
+ }
}
-
- if (!removedKeys.isEmpty() || !addedKeys.isEmpty()) {
- new TreeSelectionEvent(component, addedKeys, removedKeys).queue();
+
+ if (newSelection != null) {
+ new TreeSelectionEvent(component, Sets.newHashSet(selection),
newSelection).queue();
}
PartialViewContext pvc = context.getPartialViewContext();
Copied:
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/BaseTreeImage.java
(from rev 19860,
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/BaseTreeImage.java)
===================================================================
---
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/BaseTreeImage.java
(rev 0)
+++
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/BaseTreeImage.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -0,0 +1,84 @@
+/*
+ * 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.html.images;
+
+import java.awt.Dimension;
+import java.util.Date;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.CacheableResource;
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.resource.ImageType;
+import org.richfaces.resource.Java2DUserResource;
+import org.richfaces.resource.StateHolderResource;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public abstract class BaseTreeImage implements Java2DUserResource, StateHolderResource,
CacheableResource {
+
+ private Dimension dimension;
+
+ protected BaseTreeImage(Dimension dimension) {
+ super();
+ this.dimension = dimension;
+ }
+ public boolean isCacheable(FacesContext context) {
+ return true;
+ }
+ public Date getExpires(FacesContext context) {
+ return null;
+ }
+
+ public int getTimeToLive(FacesContext context) {
+ return -1;
+ }
+
+ public String getEntityTag(FacesContext context) {
+ return null;
+ }
+
+ public boolean isTransient() {
+ return false;
+ }
+
+ public Map<String, String> getResponseHeaders() {
+ return null;
+ }
+
+ public Date getLastModified() {
+ return null;
+ }
+
+ public ImageType getImageType() {
+ return ImageType.PNG;
+ }
+
+ public Dimension getDimension() {
+ return dimension;
+ }
+
+}
Copied:
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineImage.java
(from rev 19860,
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineImage.java)
===================================================================
---
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineImage.java
(rev 0)
+++
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineImage.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -0,0 +1,82 @@
+/*
+ * 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.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.resource.PostConstructResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public class TreeLineImage extends BaseTreeImage {
+
+ private static final Dimension DIMENSION = new Dimension(16, 16);
+
+ protected Integer trimColorValue;
+
+ public TreeLineImage() {
+ super(DIMENSION);
+ }
+
+ protected TreeLineImage(Dimension dimension) {
+ super(dimension);
+ }
+
+ @PostConstructResource
+ public void init() {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
+
+ trimColorValue = skin.getColorParameter(context, Skin.TRIM_COLOR);
+ }
+
+ public void paint(Graphics2D g2d, Dimension dimension) {
+ g2d.setColor(new Color(trimColorValue));
+
+ g2d.drawLine(7, 0, 7, 15);
+ }
+
+ public void writeState(FacesContext context, DataOutput dataOutput) throws
IOException {
+ dataOutput.writeInt(trimColorValue);
+ }
+
+ public void readState(FacesContext context, DataInput dataInput) throws IOException
{
+ trimColorValue = dataInput.readInt();
+ }
+
+
+
+}
Copied:
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineLastImage.java
(from rev 19860,
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineLastImage.java)
===================================================================
---
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineLastImage.java
(rev 0)
+++
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineLastImage.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -0,0 +1,50 @@
+/*
+ * 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.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+
+import org.richfaces.resource.DynamicResource;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public class TreeLineLastImage extends TreeLineImage {
+
+ private static final Dimension DIMENSION = new Dimension(16, 200);
+
+ public TreeLineLastImage() {
+ super(DIMENSION);
+ }
+
+ public void paint(Graphics2D g2d, Dimension dimension) {
+ g2d.setColor(new Color(trimColorValue));
+
+ g2d.drawLine(7, 0, 7, 99);
+ g2d.drawLine(7, 99, 15, 99);
+ }
+
+}
Copied:
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeMinusImage.java
(from rev 19860,
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeMinusImage.java)
===================================================================
---
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeMinusImage.java
(rev 0)
+++
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeMinusImage.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -0,0 +1,41 @@
+/*
+ * 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.html.images;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+
+import org.richfaces.resource.DynamicResource;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public class TreeMinusImage extends TreePlusImage {
+
+ public void paint(Graphics2D g2d, Dimension dimension) {
+ drawFrame(g2d);
+ drawHorizontalCrossLine(g2d);
+ }
+
+}
Copied:
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreePlusImage.java
(from rev 19860,
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreePlusImage.java)
===================================================================
---
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreePlusImage.java
(rev 0)
+++
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreePlusImage.java 2010-11-01
22:21:36 UTC (rev 19864)
@@ -0,0 +1,114 @@
+/*
+ * 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.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.geom.Rectangle2D;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.resource.PostConstructResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public class TreePlusImage extends BaseTreeImage {
+
+ private static final Dimension DIMENSION = new Dimension(16, 16);
+
+ protected Integer generalColorValue;
+
+ protected Integer controlColorValue;
+
+ protected Integer trimColorValue;
+
+ public TreePlusImage() {
+ super(DIMENSION);
+ }
+
+ @PostConstructResource
+ public void init() {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
+
+ generalColorValue = skin.getColorParameter(context, Skin.GENERAL_TEXT_COLOR);
+ controlColorValue = skin.getColorParameter(context,
Skin.CONTROL_BACKGROUND_COLOR);
+ trimColorValue = skin.getColorParameter(context, Skin.TRIM_COLOR);
+ }
+
+ protected void drawFrame(Graphics2D g2d) {
+ Color trimColor = new Color(trimColorValue);
+ Color controlColor = new Color(controlColorValue);
+
+ g2d.setColor(trimColor);
+ g2d.drawRect(3, 3, 8, 8);
+
+ Rectangle2D rect = new Rectangle2D.Float(4, 4, 7, 7);
+ GradientPaint gragient = new GradientPaint(4, 4, controlColor, 13, 13,
trimColor);
+ g2d.setPaint(gragient);
+ g2d.fill(rect);
+ }
+
+ public void paint(Graphics2D g2d, Dimension dimension) {
+ drawFrame(g2d);
+
+ drawHorizontalCrossLine(g2d);
+ drawVerticalCrossLine(g2d);
+ }
+
+ protected void drawVerticalCrossLine(Graphics2D g2d) {
+ g2d.setColor(new Color(generalColorValue));
+ //vertical cross line
+ g2d.drawLine(7, 5, 7, 9);
+ }
+
+ protected void drawHorizontalCrossLine(Graphics2D g2d) {
+ g2d.setColor(new Color(generalColorValue));
+ //horizontal cross line
+ g2d.drawLine(5, 7, 9, 7);
+ }
+
+ public void writeState(FacesContext context, DataOutput dataOutput) throws
IOException {
+ dataOutput.writeInt(generalColorValue);
+ dataOutput.writeInt(controlColorValue);
+ dataOutput.writeInt(trimColorValue);
+ }
+
+ public void readState(FacesContext context, DataInput dataInput) throws IOException
{
+ generalColorValue = dataInput.readInt();
+ controlColorValue = dataInput.readInt();
+ trimColorValue = dataInput.readInt();
+ }
+
+}
Deleted:
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/last.gif
===================================================================
(Binary files differ)
Deleted:
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/line.gif
===================================================================
(Binary files differ)
Deleted:
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/minus.gif
===================================================================
(Binary files differ)
Deleted:
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/plus.gif
===================================================================
(Binary files differ)
Modified:
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss
===================================================================
---
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss 2010-11-01
21:31:19 UTC (rev 19863)
+++
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss 2010-11-01
22:21:36 UTC (rev 19864)
@@ -1,5 +1,5 @@
.rf-trn {
- background: "url(#{resource['org.richfaces.images:last.gif']}) no-repeat
center left";
+ background: "url(#{resource['org.richfaces.images:last.png']}) no-repeat
center left";
cursor: default;
font-size: '#{richSkin.generalSizeFont}';
font-family: '#{richSkin.generalFamilyFont}';
@@ -26,7 +26,7 @@
}
.rf-tr-nd {
- background: "url(#{resource['org.richfaces.images:line.gif']})
repeat-y";
+ background: "url(#{resource['org.richfaces.images:line.png']})
repeat-y";
}
.rf-tr-nd-last {
@@ -51,11 +51,11 @@
}
.rf-trn-hnd-colps {
- background: "url(#{resource['org.richfaces.images:plus.gif']}) no-repeat
center";
+ background: "url(#{resource['org.richfaces.images:plus.png']}) no-repeat
center";
}
.rf-trn-hnd-exp {
- background: "url(#{resource['org.richfaces.images:minus.gif']}) no-repeat
center";
+ background: "url(#{resource['org.richfaces.images:minus.png']}) no-repeat
center";
}
.rf-trn-ico-nd {
Modified:
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties
===================================================================
---
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties 2010-11-01
21:31:19 UTC (rev 19863)
+++
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties 2010-11-01
22:21:36 UTC (rev 19864)
@@ -6,9 +6,9 @@
{baseColorParam=additionalBackgroundColor, gradientColorParam=tableBackgroundColor}
org.richfaces.images\:colHdrGrad.png=org.richfaces.renderkit.html.BaseGradient\
{baseColorParam=tableSubHeaderBackgroundColor,
gradientColorParam=tableHeaderBackgroundColor}
-org.richfaces.images\:last.gif=org.richfaces\:last.gif
-org.richfaces.images\:line.gif=org.richfaces\:line.gif
-org.richfaces.images\:plus.gif=org.richfaces\:plus.gif
-org.richfaces.images\:minus.gif=org.richfaces\:minus.gif
+org.richfaces.images\:last.png=org.richfaces.renderkit.html.images.TreeLineLastImage
+org.richfaces.images\:line.png=org.richfaces.renderkit.html.images.TreeLineImage
+org.richfaces.images\:plus.png=org.richfaces.renderkit.html.images.TreePlusImage
+org.richfaces.images\:minus.png=org.richfaces.renderkit.html.images.TreeMinusImage
org.richfaces.images\:node_icon.gif=org.richfaces\:node_icon.gif
org.richfaces.images\:leaf_icon.gif=org.richfaces\:leaf_icon.gif
\ No newline at end of file