Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug fixes

  • Loading branch information...
commit c512f6af41f8e56dba5f6995dc8188025a097dc8 1 parent 1c1c114
@bradseefeld authored
View
13 pom.xml
@@ -6,12 +6,12 @@
<groupId>com.bradley.gwt</groupId>
<artifactId>gwt-ui</artifactId>
<packaging>jar</packaging>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0</version>
<name>GWT Maven Archetype</name>
<properties>
- <gwt.version>2.4.0</gwt.version>
- <plugin.gwt.version>2.3.0</plugin.gwt.version>
+ <gwt.version>2.5.0-rc1</gwt.version>
+ <plugin.gwt.version>2.5.0-rc1</plugin.gwt.version>
<slf4j.version>1.6.1</slf4j.version>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
@@ -76,12 +76,7 @@
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${slf4j.version}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
+ <artifactId>slf4j-jdk14</artifactId>
<version>${slf4j.version}</version>
</dependency>
</dependencies>
View
22 src/main/java/com/bradley/gwt/user/client/google/analytics/GoogleAnalyticsUtil.java
@@ -1,12 +1,30 @@
package com.bradley.gwt.user.client.google.analytics;
+import com.google.gwt.core.client.GWT;
+
public final class GoogleAnalyticsUtil {
- public static native void trackEvent(String category, String action, String label) /*-{
+ public static void trackEvent(String category, String action, String label) {
+ if (!GWT.isProdMode()) {
+ return;
+ }
+
+ _trackEvent(category, action, label);
+ }
+
+ public static void trackEvent(String category, String action, String label, int intArg) {
+ if (!GWT.isProdMode()) {
+ return;
+ }
+
+ _trackEvent(category, action, label, intArg);
+ }
+
+ private static native void _trackEvent(String category, String action, String label) /*-{
$wnd._gaq.push(['_trackEvent', category, action, label]);
}-*/;
- public static native void trackEvent(String category, String action, String label, int intArg) /*-{
+ private static native void _trackEvent(String category, String action, String label, int intArg) /*-{
$wnd._gaq.push(['_trackEvent', category, action, label, intArg]);
}-*/;
}
View
11 src/main/java/com/bradley/gwt/user/client/resource/CellListResources.java
@@ -0,0 +1,11 @@
+package com.bradley.gwt.user.client.resource;
+
+import com.google.gwt.user.cellview.client.CellList;
+
+public interface CellListResources extends CellList.Resources {
+
+ public interface Style extends CellList.Style {}
+
+ @Source("css/cell-list.css")
+ Style cellListStyle();
+}
View
4 src/main/java/com/bradley/gwt/user/client/ui/DateBox.java
@@ -85,8 +85,8 @@ public void setValue(Date value, boolean fireEvents) {
setValue(value);
}
- public void addChangeHandler(ChangeHandler handler) {
- textbox.addChangeHandler(handler);
+ public HandlerRegistration addChangeHandler(ChangeHandler handler) {
+ return textbox.addChangeHandler(handler);
}
@Override
View
45 src/main/java/com/bradley/gwt/user/client/ui/DateTimeEditor.java
@@ -6,6 +6,8 @@
import com.google.gwt.core.client.GWT;
import com.google.gwt.editor.client.LeafValueEditor;
import com.google.gwt.event.dom.client.ChangeHandler;
+import com.google.gwt.event.dom.client.HasChangeHandlers;
+import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
@@ -13,7 +15,7 @@
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
-public class DateTimeEditor extends Composite implements LeafValueEditor<Date> {
+public class DateTimeEditor extends Composite implements LeafValueEditor<Date>, HasChangeHandlers {
@UiField
DateBox date;
@@ -42,9 +44,9 @@ public DateTimeEditor() {
initWidget(binder.createAndBindUi(this));
}
- public void addChangeHandler(ChangeHandler handler) {
- date.addChangeHandler(handler);
+ public HandlerRegistration addChangeHandler(ChangeHandler handler) {
time.addChangeHandler(handler);
+ return date.addChangeHandler(handler);
}
@Override
@@ -71,23 +73,8 @@ public Date getValue() {
if (time == null) {
return day;
}
- LOG.finer("Raw time is " + time.getTime());
-
- long timeMillis = time.getTime() % (24 * 60 * 60 * 1000);
- int offsetMillis = new Date().getTimezoneOffset() * 60 * 1000;
- int dayMillis = 24 * 60 * 60 * 1000;
- if (timeMillis < offsetMillis) {
- // Need to add a day to time to account for day overflow
- timeMillis += dayMillis;
- } else if (timeMillis + offsetMillis > dayMillis) {
- //timeMillis -= dayMillis;
- }
- timeMillis -= offsetMillis;
-
- LOG.finer("Milliseconds into day is " + timeMillis);
- Date d = new Date(day.getTime() + timeMillis);
- return d;
+ return DateTimeEditor.merge(day, time);
}
public DateBox getDateBox() {
@@ -105,4 +92,24 @@ public Label getDateLabel() {
public Label getTimeLabel() {
return timeLabel;
}
+
+ public static Date merge(Date day, Date time) {
+ LOG.finer("Raw time is " + time.getTime());
+
+ long timeMillis = time.getTime() % (24 * 60 * 60 * 1000);
+ int offsetMillis = new Date().getTimezoneOffset() * 60 * 1000;
+ int dayMillis = 24 * 60 * 60 * 1000;
+ if (timeMillis < offsetMillis) {
+ // Need to add a day to time to account for day overflow
+ timeMillis += dayMillis;
+ } else if (timeMillis + offsetMillis > dayMillis) {
+ //timeMillis -= dayMillis;
+ }
+
+ timeMillis -= offsetMillis;
+
+ LOG.finer("Milliseconds into day is " + timeMillis);
+ Date d = new Date(day.getTime() + timeMillis);
+ return d;
+ }
}
View
2  src/main/java/com/bradley/gwt/user/client/ui/DualListBox.java
@@ -11,6 +11,6 @@
* @param <M>
* @param <T>
*/
-public class DualListBox<M, T> extends MultiSelectListBox<M, T> {
+public class DualListBox<M, T> extends MultiSelectSetBox<M, T> {
}
View
165 src/main/java/com/bradley/gwt/user/client/ui/MultiSelectBox.java
@@ -0,0 +1,165 @@
+package com.bradley.gwt.user.client.ui;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import com.google.gwt.user.client.ui.ListBox;
+
+public class MultiSelectBox<M, T> extends ListBox {
+
+ /**
+ * A map of html option value (String) to the type being set/get. This is
+ * really a String repsentation of the values hashcode to the value.
+ */
+ protected Map<String, T> values;
+
+ /**
+ * A renderer that will transform complex objects into Strings for
+ * presentation.
+ */
+ protected Renderer<M> renderer;
+
+ protected List<T> lazySelectValues;
+
+ /** True if the widget has been enhanced by jquery. */
+ protected boolean enhanced = false;
+
+ /** Internal class level logger. */
+ private static final Logger LOG = Logger.getLogger(MultiSelectSetBox.class.getName());
+
+ /**
+ * Default constructor.
+ */
+ public MultiSelectBox() {
+ super(true);
+
+ values = new HashMap<String, T>();
+ }
+
+ @Override
+ public void clear() {
+ values.clear();
+ super.clear();
+ }
+
+ /**
+ * Add an option to the list.
+ *
+ * @param display The text that is displayed in the list.
+ * @param value The value that is given back when this option is selected.
+ */
+ public void addItem(String display, T value) {
+ values.put(valueOf(value), value);
+ super.addItem(display, valueOf(value));
+
+ if (lazySelectValues != null) {
+ setValue(lazySelectValues);
+ }
+ }
+
+ /**
+ * Add an option to the list.
+ *
+ * @param model The model that represents what will be displayed.
+ * @param value The value that is given back when this option is selected.
+ */
+ public void addItem(M model, T value) {
+ values.put(valueOf(value), value);
+ super.addItem(render(model), valueOf(value));
+
+ if (lazySelectValues != null) {
+ setValue(lazySelectValues);
+ }
+ }
+
+ public void setValue(List<T> values) {
+ if (values == null) {
+ return;
+ }
+
+ /*
+ * Sometimes the list of options is loaded lazily from the server. In this
+ * case, we may be setting the selected options before the list of options
+ * actually loads. To support this use case without requiring extra coding
+ * on the developers part, we will hold off on selection until items are
+ * added.
+ */
+ if (getItemCount() == 0) {
+ LOG.fine("Attempting to set values when no options exist. We will " +
+ "hold off on setting the values until some options have been " +
+ "added.");
+ lazySelectValues = values;
+ }
+
+ for (int i = 0; i < getItemCount(); i++) {
+ for (T value : values) {
+ if (getValue(i).equals(valueOf(value))) {
+ setItemSelected(i, true);
+ }
+ }
+ }
+ }
+
+ /**
+ * Set the renderer responsible for generating a valid display value
+ * for the complex model type.
+ *
+ * @param renderer
+ */
+ public void setRenderer(Renderer<M> renderer) {
+ this.renderer = renderer;
+ }
+
+ /**
+ * Remove all selected values.
+ *
+ * @return The items removed.
+ */
+ public Set<T> removeSelected() {
+ Set<T> removed = new HashSet<T>();
+
+ for (int i = getItemCount() - 1; i >= 0; i--) {
+ if (isItemSelected(i)) {
+ String key = getValue(i);
+ removed.add(values.get(key));
+ values.remove(key);
+ removeItem(i);
+ }
+ }
+
+ return removed;
+ }
+
+ /**
+ * Render the complex model into a simple String to be used in the list.
+ *
+ * @param item
+ * @return
+ */
+ protected String render(M item) {
+ if (renderer == null) {
+ return item.toString();
+ }
+
+ return renderer.render(item);
+ }
+
+ /**
+ * Convert this value to a simple String. Should be unique per item given.
+ *
+ * @param item
+ * @return
+ */
+ protected String valueOf(T item) {
+ if (item == null) {
+ return "";
+ }
+
+ return item.toString();
+ }
+}
View
173 src/main/java/com/bradley/gwt/user/client/ui/MultiSelectListBox.java
@@ -1,117 +1,15 @@
package com.bradley.gwt.user.client.ui;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Logger;
+import java.util.LinkedList;
+import java.util.List;
import com.google.gwt.editor.client.LeafValueEditor;
-import com.google.gwt.user.client.ui.ListBox;
-/**
- * A Multiselect list that can be used with the Editor framework.
- *
- * @param <M> The model type that may correspond to T. M is what goes in.
- * @param <T> The type that is actually being edited. For example, if we are editing
- * a list of Roles but the property is actually a Set or String role IDs,
- * T would be String. M would be Role. In other words, T can be thought of
- * as what will come out when getValue() is called.
- */
-public class MultiSelectListBox<M, T> extends ListBox implements LeafValueEditor<Set<T>> {
-
- /**
- * A map of html option value (String) to the type being set/get. This is
- * really a String repsentation of the values hashcode to the value.
- */
- protected Map<String, T> values;
-
- /**
- * A renderer that will transform complex objects into Strings for
- * presentation.
- */
- protected Renderer<M> renderer;
-
- protected Set<T> lazySelectValues;
-
- /** True if the widget has been enhanced by jquery. */
- protected boolean enhanced = false;
-
- /** Internal class level logger. */
- private static final Logger LOG = Logger.getLogger(MultiSelectListBox.class.getName());
-
- /**
- * Default constructor.
- */
- public MultiSelectListBox() {
- super(true);
-
- values = new HashMap<String, T>();
- }
-
- /**
- * Add an option to the list.
- *
- * @param display The text that is displayed in the list.
- * @param value The value that is given back when this option is selected.
- */
- public void addItem(String display, T value) {
- values.put(valueOf(value), value);
- super.addItem(display, valueOf(value));
-
- if (lazySelectValues != null) {
- setValue(lazySelectValues);
- }
- }
-
- /**
- * Add an option to the list.
- *
- * @param model The model that represents what will be displayed.
- * @param value The value that is given back when this option is selected.
- */
- public void addItem(M model, T value) {
- values.put(valueOf(value), value);
- super.addItem(render(model), valueOf(value));
-
- if (lazySelectValues != null) {
- setValue(lazySelectValues);
- }
- }
-
- @Override
- public void setValue(Set<T> values) {
- if (values == null) {
- return;
- }
-
- /*
- * Sometimes the list of options is loaded lazily from the server. In this
- * case, we may be setting the selected options before the list of options
- * actually loads. To support this use case without requiring extra coding
- * on the developers part, we will hold off on selection until items are
- * added.
- */
- if (getItemCount() == 0) {
- LOG.fine("Attempting to set values when no options exist. We will " +
- "hold off on setting the values until some options have been " +
- "added.");
- lazySelectValues = values;
- }
-
- for (int i = 0; i < getItemCount(); i++) {
- for (T value : values) {
- if (getValue(i).equals(valueOf(value))) {
- setItemSelected(i, true);
- }
- }
- }
- }
+public class MultiSelectListBox<M, T> extends MultiSelectBox<M, T> implements LeafValueEditor<List<T>> {
@Override
- public Set<T> getValue() {
-
- Set<T> results = new HashSet<T>();
+ public List<T> getValue() {
+ List<T> results = new LinkedList<T>();
for (int i = 0; i < getItemCount(); i++) {
if (isItemSelected(i)) {
results.add(values.get(getValue(i)));
@@ -120,68 +18,11 @@ public void setValue(Set<T> values) {
if (getItemCount() == 0 && lazySelectValues != null) {
// Remote data never loaded.
- return lazySelectValues;
+ results.addAll(lazySelectValues);
+ return results;
}
lazySelectValues = null;
return results;
}
-
- /**
- * Set the renderer responsible for generating a valid display value
- * for the complex model type.
- *
- * @param renderer
- */
- public void setRenderer(Renderer<M> renderer) {
- this.renderer = renderer;
- }
-
- /**
- * Remove all selected values.
- *
- * @return The items removed.
- */
- public Set<T> removeSelected() {
- Set<T> removed = new HashSet<T>();
-
- for (int i = getItemCount() - 1; i >= 0; i--) {
- if (isItemSelected(i)) {
- String key = getValue(i);
- removed.add(values.get(key));
- values.remove(key);
- removeItem(i);
- }
- }
-
- return removed;
- }
-
- /**
- * Render the complex model into a simple String to be used in the list.
- *
- * @param item
- * @return
- */
- protected String render(M item) {
- if (renderer == null) {
- return item.toString();
- }
-
- return renderer.render(item);
- }
-
- /**
- * Convert this value to a simple String. Should be unique per item given.
- *
- * @param item
- * @return
- */
- protected String valueOf(T item) {
- if (item == null) {
- return "";
- }
-
- return item.toString();
- }
}
View
48 src/main/java/com/bradley/gwt/user/client/ui/MultiSelectSetBox.java
@@ -0,0 +1,48 @@
+package com.bradley.gwt.user.client.ui;
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Set;
+
+import com.google.gwt.editor.client.LeafValueEditor;
+
+/**
+ * A Multiselect list that can be used with the Editor framework.
+ *
+ * @param <M> The model type that may correspond to T. M is what goes in.
+ * @param <T> The type that is actually being edited. For example, if we are editing
+ * a list of Roles but the property is actually a Set or String role IDs,
+ * T would be String. M would be Role. In other words, T can be thought of
+ * as what will come out when getValue() is called.
+ */
+public class MultiSelectSetBox<M, T> extends MultiSelectBox<M, T> implements LeafValueEditor<Set<T>> {
+
+ @Override
+ public void setValue(Set<T> value) {
+ if (value == null) {
+ super.setValue(null);
+ } else {
+ setValue(new LinkedList<T>(value));
+ }
+ }
+
+ @Override
+ public Set<T> getValue() {
+
+ Set<T> results = new HashSet<T>();
+ for (int i = 0; i < getItemCount(); i++) {
+ if (isItemSelected(i)) {
+ results.add(values.get(getValue(i)));
+ }
+ }
+
+ if (getItemCount() == 0 && lazySelectValues != null) {
+ // Remote data never loaded.
+ results.addAll(lazySelectValues);
+ return results;
+ }
+
+ lazySelectValues = null;
+ return results;
+ }
+}
View
6 src/main/resources/com/bradley/gwt/user/client/celltable/cell-table.css
@@ -91,7 +91,6 @@
}
.cellTableKeyboardSelectedRow {
- background-color: #0099FF;
color: black;
}
@@ -99,20 +98,17 @@
* The keyboard selected cell is visible over selection.
*/
.cellTableKeyboardSelectedCell {
- border-color: #0099FF;
+ border-color: none;
}
.cellTableKeyboardSelectedRowCell {
}
.cellTableSelectedRow {
- background: #0099FF;
color: white;
height: auto;
overflow: auto;
- border-color: #0099FF;
}
.cellTableSelectedRowCell {
- border-color: #0099FF;
}
View
23 src/main/resources/com/bradley/gwt/user/client/resource/css/cell-list.css
@@ -0,0 +1,23 @@
+.cellListWidget {
+
+}
+
+.cellListEvenItem {
+ cursor: pointer;
+ zoom: 1;
+}
+
+.cellListOddItem {
+ cursor: pointer;
+ zoom: 1;
+}
+
+.cellListKeyboardSelectedItem {
+ background: #EDEDED;
+}
+
+.cellListSelectedItem {
+ height: auto;
+ overflow: visible;
+ background: #EDEDED;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.