Author: konstantin.mishin
Date: 2010-07-28 11:59:19 -0400 (Wed, 28 Jul 2010)
New Revision: 18262
Added:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBottom.java
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowLeft.java
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowRight.java
Removed:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/handler.gif
Modified:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.ecss
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/templates/inputnumberslider.template.xml
Log:
RF-8983
Added:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java
===================================================================
---
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java
(rev 0)
+++
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java 2010-07-28
15:59:19 UTC (rev 18262)
@@ -0,0 +1,102 @@
+/*
+ * 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.renderkit.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.resource.ImageType;
+import org.richfaces.resource.Java2DUserResource;
+import org.richfaces.resource.StateHolderResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+@DynamicResource
+public abstract class SliderArrowBase implements Java2DUserResource, StateHolderResource
{
+
+ private Dimension dimension = new Dimension(7, 7);
+ private int color;
+ private final String colorName;
+
+ public SliderArrowBase() {
+ this(Skin.GENERAL_TEXT_COLOR);
+ }
+
+ public SliderArrowBase(String colorName) {
+ this.colorName = colorName;
+ }
+
+ private void initialize() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
+ this.color = skin.getColorParameter(context, colorName);
+ }
+
+ public Dimension getDimension() {
+ return dimension;
+ }
+ public void paint(Graphics2D graphics2d, Dimension dimension) {
+ graphics2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
+ graphics2d.setColor(new Color(color));
+ }
+
+ public void writeState(FacesContext context, DataOutput dataOutput) throws
IOException {
+ initialize();
+ dataOutput.writeInt(this.color);
+ }
+
+ public void readState(FacesContext context, DataInput dataInput) throws IOException
{
+ this.color = dataInput.readInt();
+ }
+
+ public Map<String, String> getResponseHeaders() {
+ return null;
+ }
+
+ public Date getLastModified() {
+ return null;
+ }
+
+ public ImageType getImageType() {
+ return ImageType.PNG;
+ }
+
+ public boolean isTransient() {
+ return false;
+ }
+
+}
Property changes on:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBottom.java
===================================================================
---
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBottom.java
(rev 0)
+++
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBottom.java 2010-07-28
15:59:19 UTC (rev 18262)
@@ -0,0 +1,42 @@
+/*
+ * 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.renderkit.html.images;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class SliderArrowBottom extends SliderArrowBase {
+
+ @Override
+ public void paint(Graphics2D graphics2d, Dimension dimension) {
+ super.paint(graphics2d, dimension);
+ graphics2d.drawLine(0, 1, 6, 1);
+ graphics2d.drawLine(1, 2, 5, 2);
+ graphics2d.drawLine(2, 3, 4, 3);
+ graphics2d.drawLine(3, 4, 3, 4);
+ }
+}
Added:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowLeft.java
===================================================================
---
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowLeft.java
(rev 0)
+++
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowLeft.java 2010-07-28
15:59:19 UTC (rev 18262)
@@ -0,0 +1,42 @@
+/*
+ * 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.renderkit.html.images;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class SliderArrowLeft extends SliderArrowBase {
+
+ @Override
+ public void paint(Graphics2D graphics2d, Dimension dimension) {
+ super.paint(graphics2d, dimension);
+ graphics2d.drawLine(4, 0, 4, 6);
+ graphics2d.drawLine(3, 1, 3, 5);
+ graphics2d.drawLine(2, 2, 2, 4);
+ graphics2d.drawLine(1, 3, 1, 3);
+ }
+}
Added:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowRight.java
===================================================================
---
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowRight.java
(rev 0)
+++
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowRight.java 2010-07-28
15:59:19 UTC (rev 18262)
@@ -0,0 +1,42 @@
+/*
+ * 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.renderkit.html.images;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class SliderArrowRight extends SliderArrowBase {
+
+ @Override
+ public void paint(Graphics2D graphics2d, Dimension dimension) {
+ super.paint(graphics2d, dimension);
+ graphics2d.drawLine(2, 0, 2, 6);
+ graphics2d.drawLine(3, 1, 3, 5);
+ graphics2d.drawLine(4, 2, 4, 4);
+ graphics2d.drawLine(5, 3, 5, 3);
+ }
+}
Deleted:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/handler.gif
===================================================================
(Binary files differ)
Modified:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.ecss
===================================================================
---
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.ecss 2010-07-28
14:46:12 UTC (rev 18261)
+++
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.ecss 2010-07-28
15:59:19 UTC (rev 18262)
@@ -38,8 +38,6 @@
}
.rf-ins-mn, .rf-ins-mx {
- width: 25%;
- overflow: hidden;
display: block;
margin-bottom: 3px;
}
@@ -57,15 +55,14 @@
text-align: right;
}
-.rf-ins-i {
+input.rf-ins-i {
background: url("#{resource['bg_field.gif']}") top repeat-x #fff;
border: 1px inset #C0C0C0;
- margin: 0px 10px 0px 10px;
+ margin-left: 10px;
}
.rf-ins-tt {
- position: relative;
- top: -17px;
+ position: absolute;
display: none;
}
@@ -73,15 +70,24 @@
background: url("#{resource['bg.gif']}") 1px 1px repeat-x #FFFFFF;
border: 1px solid #C0C0C0;
display: block;
- font-size: 1px;
height: 6px;
clear: both;
}
+.rf-ins-h, .rf-ins-db, .rf-ins-ib {
+ display: inline-block;
+ width: 7px;
+ height: 7px;
+}
+
.rf-ins-h {
- width: 7px;
- height: 8px;
- border: none;
- position: relative;
- top: -1px;
+ background-image:
url("#{resource['org.richfaces.renderkit.html.images.SliderArrowBottom']}");
+}
+
+.rf-ins-db {
+ background-image:
url("#{resource['org.richfaces.renderkit.html.images.SliderArrowLeft']}");
+}
+
+.rf-ins-ib {
+ background-image:
url("#{resource['org.richfaces.renderkit.html.images.SliderArrowRight']}");
}
\ No newline at end of file
Modified:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js
===================================================================
---
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js 2010-07-28
14:46:12 UTC (rev 18261)
+++
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js 2010-07-28
15:59:19 UTC (rev 18262)
@@ -41,13 +41,15 @@
this.tooltip = this.element.find(".rf-ins-tt");
this.track[0].tabIndex = 0;
- this.handle.css("left", this.input.val() * (this.track.width() -
this.handle.width()) / this.range);
+ this.handle.css("margin-left", this.input.val() * (this.track.width()
- this.handle.width()) / this.range);
var proxy = jQuery.proxy(this.__inputHandler, this)
this.input.change(proxy);
this.input.submit(proxy);
+ this.track.keydown(jQuery.proxy(this.__keydownHandler, this));
+
this.element.find(".rf-ins-db").mousedown(jQuery.proxy(this.__decreaseHandler,
this));
+
this.element.find(".rf-ins-ib").mousedown(jQuery.proxy(this.__increaseHandler,
this));
this.track.mousedown(jQuery.proxy(this.__mousedownHandler, this));
- this.track.keydown(jQuery.proxy(this.__keydownHandler, this));
},
setValue: function (value) {
@@ -57,14 +59,14 @@
} else if (value < this.minValue) {
value = this.minValue;
} else {
- value = Math.round(value / this.step) * this.step; //TODO Add support of float
values.
+ value = Math.round(value / this.step) * this.step; //TODO Add normal support of
float values. E.g. '0.3' should be instead of '0.30000000000000004'.
}
if (value != this.input.val()) {
this.input.val(value);
var left = value * (this.track.width() - this.handle.width()) / this.range;
- this.handle.css("left", left);
+ this.handle.css("margin-left", left);
this.tooltip.text(value);
- this.tooltip.css("left", left - this.handle.width());
+ this.tooltip.setPosition(this.handle,{from: 'LT', offset: [0, -3]});
//TODO Seems offset doesn't work now.
}
},
@@ -82,6 +84,14 @@
}
},
+ __decreaseHandler: function (event) {
+ this.setValue(Number(this.input.val()) - this.step);
+ },
+
+ __increaseHandler: function (event) {
+ this.setValue(Number(this.input.val()) + this.step);
+ },
+
__mousedownHandler: function (event) {
this.__mousemoveHandler(event);
this.track.focus();
Modified:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/templates/inputnumberslider.template.xml
===================================================================
---
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/templates/inputnumberslider.template.xml 2010-07-28
14:46:12 UTC (rev 18261)
+++
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/templates/inputnumberslider.template.xml 2010-07-28
15:59:19 UTC (rev 18262)
@@ -33,22 +33,23 @@
<cdk:resource-dependency name="inputNumberSlider.ecss" />
<cdk:resource-dependency library="javax.faces" name="jsf.js"
/>
<cdk:resource-dependency name="jquery.js" />
+ <cdk:resource-dependency name="jquery.position.js" />
<cdk:resource-dependency name="richfaces.js" />
- <cdk:resource-dependency name="richfaces.js" />
<cdk:resource-dependency name="richfaces-base-component.js" />
<cdk:resource-dependency name="inputNumberSlider.js" />
</cc:interface>
<cc:implementation>
<span id="#{clientId}" class="rf-ins">
+ <a class="rf-ins-db" href="javascript:void(0);" />
<span class="rf-ins-ta">
<span class="rf-ins-mn">0</span>
<span class="rf-ins-mx">100</span>
<span class="rf-ins-t">
- <img
src="#{facesContext.application.resourceHandler.createResource('handler.gif').requestPath}"
- alt="" class="rf-ins-h" />
+ <span class="rf-ins-h" />
<span class="rf-ins-tt">#{getInputValue(facesContext,
component)}</span>
</span>
</span>
+ <a class="rf-ins-ib" href="javascript:void(0);" />
<input name="#{clientId}" type="text"
class="rf-ins-i" size="3"
value="#{getInputValue(facesContext, component)}" />
<script type="text/javascript">new
RichFaces.ui.InputNumberSlider('#{clientId}');</script>