Skip to content
This repository was archived by the owner on Apr 8, 2019. It is now read-only.

Commit f7a5829

Browse files
committed
update
1 parent 5c03ac4 commit f7a5829

File tree

10 files changed

+322
-5
lines changed

10 files changed

+322
-5
lines changed

.classpath

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
<classpath>
33
<classpathentry kind="src" path="src"/>
44
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5-
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER/GWT (2)"/>
6-
<classpathentry kind="lib" path="lib/guava-16.0.jar" sourcepath="C:/java/lib/guava-16.0-sources.jar"/>
7-
<classpathentry kind="lib" path="lib/guava-gwt-16.0.jar"/>
5+
<classpathentry kind="lib" path="/GWTLib2011/lib/guava-gwt.jar"/>
6+
<classpathentry kind="lib" path="/GWTLib2011/lib/guava-sources.jar"/>
7+
<classpathentry kind="lib" path="/GWTLib2011/lib/guava.jar"/>
8+
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER/gwt-2.6.1"/>
89
<classpathentry kind="output" path="war/WEB-INF/classes"/>
910
</classpath>

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</fileset>
2323
</path>
2424
<javac destdir="tmp" srcdir="src">
25-
<classpath path="C:\eclipse\plugins\com.google.gwt.eclipse.sdkbundle_2.5.1\gwt-2.5.1\gwt-user.jar;C:\eclipse\plugins\com.google.gwt.eclipse.sdkbundle_2.5.1\gwt-2.5.1\gwt-dev.jar">
25+
<classpath path="C:\eclipse\gwt-2.6.1\gwt-user.jar;C:\eclipse\gwt-2.6.1\gwt-dev.jar">
2626
<path refid="libs"/>
2727
</classpath>
2828
</javac>

built/akjavahtml5gwt_150706.jar

328 KB
Binary file not shown.
Binary file not shown.

src/com/akjava/gwt/html5/client/file/FileUploadForm.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ public void setEnabled(boolean bool){
6060
public void setAccept(String accept){
6161
fileUpload.getElement().setAttribute("accept", accept);
6262
}
63+
public void setAccept(String... accepts){
64+
fileUpload.getElement().setAttribute("accept", Joiner.on(",").join(accepts));
65+
}
6366

6467
public void setAccept(List<String> accepts){
6568
fileUpload.getElement().setAttribute("accept", Joiner.on(",").join(accepts));

src/com/akjava/gwt/html5/client/file/ui/DataUrlDropVerticalRootPanel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public DataUrlDropVerticalRootPanel(boolean addRootLayoutPanel) {
1515

1616
@Override
1717
public void callback(final File file, String parent) {
18-
18+
1919
if(file==null){
2020
return;
2121
}
@@ -26,6 +26,7 @@ public void onLoad() {
2626

2727
String dataUrl=reader.getResultAsString();
2828
loadFile(file, dataUrl);
29+
loadFileIndex++;
2930
}
3031
});
3132

src/com/akjava/gwt/html5/client/file/ui/DropVerticalRootPanel.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,14 @@ public void onDragLeave(DragLeaveEvent event) {
6464
}
6565
}
6666

67+
protected int loadFileIndex;//reset on drop start,increment in callback by yourselef
6768
public void entryCallback(final FileEntry entry,final FilePathCallback callback,String path){
6869
if(entry==null){
6970
return;
7071
}
7172
if (entry.isFile()) {
7273
entry.file(callback,path);
74+
7375
} else if (entry.isDirectory()) {
7476
entry.getReader().readEntries(
7577
new DirectoryCallback() {
@@ -87,6 +89,7 @@ public void callback(
8789
}
8890

8991
public void onDropFiles(List<FileEntry> files){
92+
loadFileIndex=0;
9093
for(FileEntry file:files){
9194
entryCallback(file,this,"");
9295
}
Lines changed: 309 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,309 @@
1+
package com.akjava.gwt.html5.client.input;
2+
3+
/*
4+
* based on Hidden,Checkbox,ListBox
5+
*
6+
* Copyright 2008 Google Inc.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
9+
* use this file except in compliance with the License. You may obtain a copy of
10+
* the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17+
* License for the specific language governing permissions and limitations under
18+
* the License.
19+
*/
20+
21+
22+
import com.google.gwt.dom.client.Document;
23+
import com.google.gwt.dom.client.Element;
24+
import com.google.gwt.dom.client.InputElement;
25+
import com.google.gwt.editor.client.IsEditor;
26+
import com.google.gwt.editor.client.LeafValueEditor;
27+
import com.google.gwt.editor.client.adapters.TakesValueEditor;
28+
import com.google.gwt.event.dom.client.ChangeEvent;
29+
import com.google.gwt.event.dom.client.ChangeHandler;
30+
import com.google.gwt.event.logical.shared.ValueChangeEvent;
31+
import com.google.gwt.event.logical.shared.ValueChangeHandler;
32+
import com.google.gwt.event.shared.HandlerRegistration;
33+
import com.google.gwt.user.client.ui.HasName;
34+
import com.google.gwt.user.client.ui.HasValue;
35+
import com.google.gwt.user.client.ui.RootPanel;
36+
import com.google.gwt.user.client.ui.Widget;
37+
38+
/**
39+
*
40+
* @author aki
41+
*
42+
*/
43+
public class Range extends Widget implements HasName,HasValue<Number>, IsEditor<LeafValueEditor<Number>> {
44+
45+
/**
46+
* Creates a range widget that wraps an existing &lt;input type='range'&gt;
47+
* element.
48+
*
49+
* This element must already be attached to the document. If the element is
50+
* removed from the document, you must call
51+
* {@link RootPanel#detachNow(Widget)}.
52+
*
53+
* @param element the element to be wrapped
54+
*/
55+
public static Range wrap(Element element) {
56+
// Assert that the element is attached.
57+
assert Document.get().getBody().isOrHasChild(element);
58+
59+
Range range = new Range(element);
60+
61+
// Mark it attached and remember it for cleanup.
62+
range.onAttach();
63+
RootPanel.detachOnWindowClose(range);
64+
65+
return range;
66+
}
67+
68+
protected void ensureDomEventHandlers() {
69+
addChangeHandler(new ChangeHandler() {
70+
@Override
71+
public void onChange(ChangeEvent event) {
72+
ValueChangeEvent.fire(Range.this, getValue());
73+
}
74+
});
75+
76+
77+
}
78+
79+
protected HandlerRegistration addChangeHandler(ChangeHandler handler) {
80+
return addDomHandler(handler, ChangeEvent.getType());
81+
}
82+
83+
private LeafValueEditor<Number> editor;
84+
85+
/**
86+
* Constructor for <code>range</code>.
87+
*/
88+
public Range() {
89+
InputElement input=Document.get().createHiddenInputElement();
90+
input.setAttribute("type", "range");
91+
setElement(input);
92+
}
93+
94+
/**
95+
* Constructor for <code>Hidden</code>.
96+
*
97+
* @param name name of the hidden field
98+
*/
99+
public Range(String name) {
100+
this();
101+
setName(name);
102+
}
103+
104+
/**
105+
* Constructor for <code>Hidden</code>.
106+
*
107+
* @param name name of the hidden field
108+
* @param value value of the hidden field
109+
*/
110+
public Range(String name, Number min,Number max,Number step) {
111+
this(name);
112+
//setValue(value);
113+
getInputElement().setAttribute("min", String.valueOf(min));
114+
getInputElement().setAttribute("max", String.valueOf(max));
115+
getInputElement().setAttribute("step", String.valueOf(step));
116+
}
117+
118+
public void setMin(double value){
119+
getInputElement().setAttribute("min", String.valueOf(value));
120+
}
121+
public void setMax(double value){
122+
getInputElement().setAttribute("max", String.valueOf(value));
123+
}
124+
public double getMax(){
125+
if(getInputElement().getAttribute("max")==null){
126+
return 0;
127+
}
128+
return Double.parseDouble(getInputElement().getAttribute("max"));
129+
}
130+
public double getMin(){
131+
if(getInputElement().getAttribute("min")==null){
132+
return 0;
133+
}
134+
return Double.parseDouble(getInputElement().getAttribute("min"));
135+
}
136+
137+
public Range(String name, Number min,Number max){
138+
this(name,min,max,1);
139+
}
140+
141+
142+
/**
143+
* This constructor may be used by subclasses to explicitly use an existing
144+
* element. This element must be an &lt;input&gt; element whose type is
145+
* 'hidden'.
146+
*
147+
* @param element the element to be used
148+
*/
149+
protected Range(Element element) {
150+
assert InputElement.as(element).getType().equalsIgnoreCase("range");
151+
setElement(element);
152+
}
153+
154+
public LeafValueEditor<Number> asEditor() {
155+
if (editor == null) {
156+
editor = TakesValueEditor.of(this);
157+
}
158+
return editor;
159+
}
160+
161+
/**
162+
* Gets the default value of the range field.
163+
*
164+
* @return the default value
165+
*/
166+
public Number getDefaultValue() {
167+
return Double.valueOf(getInputElement().getDefaultValue());
168+
}
169+
170+
/**
171+
* Gets the id of the range field.
172+
*
173+
* @return the id
174+
*/
175+
public String getID() {
176+
return getElement().getId();
177+
}
178+
179+
/**
180+
* Gets the name of the range field.
181+
*
182+
* @return the name
183+
*/
184+
185+
public String getName() {
186+
return getInputElement().getName();
187+
}
188+
189+
/**
190+
* Gets the value of the range field.
191+
* must start # & not empty
192+
* @return the value
193+
*/
194+
public Number getValue() {
195+
String value=getInputElement().getValue();
196+
197+
return Double.valueOf(value);
198+
}
199+
200+
/**
201+
* get raw value
202+
* @return
203+
*/
204+
public Number getInputValue() {
205+
return Double.valueOf(getInputElement().getValue());
206+
}
207+
208+
/**
209+
* Sets the default value of the range field.
210+
*
211+
* @param defaultValue default value to set
212+
*/
213+
public void setDefaultValue(Integer defaultValue) {
214+
getInputElement().setDefaultValue(String.valueOf(defaultValue));
215+
}
216+
217+
/**
218+
* Sets the id of the range field.
219+
*
220+
* @param id id to set
221+
*/
222+
public void setID(String id) {
223+
getElement().setId(id);
224+
}
225+
226+
/**
227+
* Sets the name of the range field.
228+
*
229+
* @param name name of the field
230+
*/
231+
public void setName(String name) {
232+
if (name == null) {
233+
throw new NullPointerException("Name cannot be null");
234+
} else if (name.equals("")) {
235+
throw new IllegalArgumentException("Name cannot be an empty string.");
236+
}
237+
238+
getInputElement().setName(name);
239+
}
240+
241+
/**
242+
* Sets the value of the range field.
243+
*
244+
* @param value value to set
245+
*/
246+
public void setValue(Number value) {
247+
//getInputElement().setValue(String.valueOf(value));
248+
setValue(value,false);
249+
}
250+
251+
public final native void setValue(Element element,Number value) /*-{
252+
element.value = value;
253+
}-*/;
254+
255+
private InputElement getInputElement() {
256+
return getElement().cast();
257+
}
258+
259+
/*
260+
* i have no idea so far
261+
@Override
262+
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<String> handler) {
263+
// TODO Auto-generated method stub
264+
return null;
265+
}
266+
*/
267+
268+
@Override
269+
public void setValue(Number value, boolean fireEvents) {
270+
if (value == null) {
271+
value = 0;
272+
}
273+
274+
Number oldValue = getValue();
275+
setValue(getInputElement(),value);
276+
277+
if (value.equals(oldValue)) {
278+
return;
279+
}
280+
281+
if (fireEvents) {
282+
ValueChangeEvent.fire(this, value);
283+
}
284+
285+
//setValue(value);
286+
}
287+
288+
private boolean valueChangeHandlerInitialized;
289+
@Override
290+
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Number> handler) {
291+
// Is this the first value change handler? If so, time to add handlers
292+
if (!valueChangeHandlerInitialized) {
293+
ensureDomEventHandlers();
294+
valueChangeHandlerInitialized = true;
295+
}
296+
return addHandler(handler, ValueChangeEvent.getType());
297+
}
298+
299+
/*
300+
don't wrok
301+
public HandlerRegistration addValueChangeHandler(
302+
ValueChangeHandler<String> handler) {
303+
return addHandler(handler, ValueChangeEvent.getType());
304+
}
305+
*/
306+
307+
308+
}
309+

war/WEB-INF/lib/gwt-servlet.jar

2.88 MB
Binary file not shown.

0 commit comments

Comments
 (0)