4.0.0
org.gwtbootstrap3
gwtbootstrap3-parent
- 0.9-SNAPSHOT
+ 1.0-SNAPSHOT
gwtbootstrap3-extras
diff --git a/src/main/java/org/gwtbootstrap3/extras/bootbox/client/Bootbox.java b/src/main/java/org/gwtbootstrap3/extras/bootbox/client/Bootbox.java
index a2e09496..c4e7efd6 100644
--- a/src/main/java/org/gwtbootstrap3/extras/bootbox/client/Bootbox.java
+++ b/src/main/java/org/gwtbootstrap3/extras/bootbox/client/Bootbox.java
@@ -20,9 +20,11 @@
* #L%
*/
+import com.google.gwt.core.client.JavaScriptObject;
import org.gwtbootstrap3.extras.bootbox.client.callback.AlertCallback;
import org.gwtbootstrap3.extras.bootbox.client.callback.ConfirmCallback;
import org.gwtbootstrap3.extras.bootbox.client.callback.PromptCallback;
+import org.gwtbootstrap3.extras.bootbox.client.constants.BootboxSize;
/**
* Created by kyle on 2013/12/11.
@@ -75,4 +77,179 @@ public static native void prompt(String msg, PromptCallback callback) /*-{
callback.@org.gwtbootstrap3.extras.bootbox.client.callback.PromptCallback::callback(Ljava/lang/String;)(result);
});
}-*/;
+
+ /**
+ * Displays a completely customisable dialog in a modal dialog box.
+ *
+ * @param dialog the dialog configuration.
+ */
+ public static native void dialog(Dialog dialog) /*-{
+ $wnd.bootbox.dialog(dialog);
+ }-*/;
+
+ /**
+ * Hide all currently active bootbox dialogs.
+ * Individual dialogs can be closed as per normal Bootstrap dialogs: dialog.modal('hide').
+ */
+ public static native void hideAll() /*-{
+ $wnd.bootbox.hideAll();
+ }-*/;
+
+ /**
+ * Creates a Defaults object.
+ */
+ public static Defaults createDefaults() {
+ return Defaults.create();
+ }
+
+ /**
+ * Used to provide defaults configurations to Bootbox.
+ *
+ * @author Tercio Gaudencio Filho (terciofilho [at] gmail.com)
+ */
+ public static class Defaults extends JavaScriptObject {
+
+ protected Defaults() {
+ }
+
+ public static final Defaults create() {
+ return JavaScriptObject.createObject().cast();
+ }
+
+ public final native Defaults setLocale(final String locale) /*-{
+ this.locale = locale;
+ return this;
+ }-*/;
+
+ public final native Defaults setShow(final boolean show) /*-{
+ this.show = show;
+ return this;
+ }-*/;
+
+ public final native Defaults setBackdrop(final boolean backdrop) /*-{
+ this.backdrop = backdrop;
+ return this;
+ }-*/;
+
+ public final native Defaults setCloseButton(final boolean closeButton) /*-{
+ this.closeButton = closeButton;
+ return this;
+ }-*/;
+
+ public final native Defaults setAnimate(final boolean animate) /*-{
+ this.animate = animate;
+ return this;
+ }-*/;
+
+ public final native Defaults setClassName(final String className) /*-{
+ this.className = className;
+ return this;
+ }-*/;
+
+ /**
+ * Define Bootbox defaults. Call this method to set the defaults in Bootbox.
+ */
+ public final native void setDefaults() /*-{
+ $wnd.bootbox.setDefaults(this);
+ }-*/;
+
+ }
+
+ /**
+ * Used to provide a Dialog configuration.
+ *
+ * @author Tercio Gaudencio Filho (terciofilho [at] gmail.com)
+ */
+ public static class Dialog extends JavaScriptObject {
+
+ protected Dialog() {
+ }
+
+ public static final Dialog create() {
+ return JavaScriptObject.createObject().cast();
+ }
+
+ public final native Dialog setMessage(final String message) /*-{
+ this.message = message;
+ return this;
+ }-*/;
+
+ public final native Dialog setTitle(final String title) /*-{
+ this.title = title;
+ return this;
+ }-*/;
+
+ public final native Dialog setOnEscape(final AlertCallback callback) /*-{
+ this.onEscape = function() {
+ callback.@org.gwtbootstrap3.extras.bootbox.client.callback.AlertCallback::callback()();
+ };
+ return this;
+ }-*/;
+
+ public final native Dialog setBackdrop(final boolean backdrop) /*-{
+ this.backdrop = backdrop;
+ return this;
+ }-*/;
+
+ public final native Dialog setCloseButton(final boolean closeButton) /*-{
+ this.closeButton = closeButton;
+ return this;
+ }-*/;
+
+ public final native Dialog setAnimate(final boolean animate) /*-{
+ this.animate = animate;
+ return this;
+ }-*/;
+
+ public final native Dialog setClassName(final String className) /*-{
+ this.className = className;
+ return this;
+ }-*/;
+
+ public final native Dialog setSize(final BootboxSize size) /*-{
+ this.size = size.@org.gwtbootstrap3.extras.bootbox.client.constants.BootboxSize::getSize()();
+ return this;
+ }-*/;
+
+ public final native Dialog addButton(String label , String className, AlertCallback callback) /*-{
+ this.buttons = this.buttons || {};
+ this.buttons[label] = {
+ className: className,
+ callback: function() {
+ callback.@org.gwtbootstrap3.extras.bootbox.client.callback.AlertCallback::callback()();
+ }
+ };
+ return this;
+ }-*/;
+
+ public final native Dialog addButton(String label , String className) /*-{
+ this.buttons = this.buttons || {};
+ this.buttons[label] = {
+ className: className
+ };
+ return this;
+ }-*/;
+
+ public final native Dialog addButton(String label , AlertCallback callback) /*-{
+ this.buttons = this.buttons || {};
+ this.buttons[label] = {
+ callback: function() {
+ callback.@org.gwtbootstrap3.extras.bootbox.client.callback.AlertCallback::callback()();
+ }
+ };
+ return this;
+ }-*/;
+
+ public final native Dialog addButton(String label) /*-{
+ this.buttons = this.buttons || {};
+ this.buttons[label] = {};
+ return this;
+ }-*/;
+
+ public final void show() {
+ Bootbox.dialog(this);
+ }
+
+ }
+
}
diff --git a/src/main/java/org/gwtbootstrap3/extras/bootbox/client/BootboxClientBundle.java b/src/main/java/org/gwtbootstrap3/extras/bootbox/client/BootboxClientBundle.java
index 484ad3d5..4e570a66 100644
--- a/src/main/java/org/gwtbootstrap3/extras/bootbox/client/BootboxClientBundle.java
+++ b/src/main/java/org/gwtbootstrap3/extras/bootbox/client/BootboxClientBundle.java
@@ -31,6 +31,6 @@ interface BootboxClientBundle extends ClientBundle {
static final BootboxClientBundle INSTANCE = GWT.create(BootboxClientBundle.class);
- @Source("resource/js/bootbox-4.1.0.min.cache.js")
+ @Source("resource/js/bootbox-4.4.0.min.cache.js")
TextResource bootbox();
}
diff --git a/src/main/java/org/gwtbootstrap3/extras/bootbox/client/constants/BootboxSize.java b/src/main/java/org/gwtbootstrap3/extras/bootbox/client/constants/BootboxSize.java
new file mode 100644
index 00000000..fe921e9f
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/bootbox/client/constants/BootboxSize.java
@@ -0,0 +1,42 @@
+package org.gwtbootstrap3.extras.bootbox.client.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Bootbox window size.
+ *
+ * @author Tercio Gaudencio Filho (terciofilho [at] gmail.com)
+ */
+public enum BootboxSize {
+
+ LARGE("large"), SMALL("small");
+
+ private String size;
+
+ private BootboxSize(String size) {
+ this.size=size;
+ }
+
+ public String getSize() {
+ return size;
+ }
+
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/DatePickerClientBundle.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/DatePickerClientBundle.java
new file mode 100644
index 00000000..0bf58477
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/DatePickerClientBundle.java
@@ -0,0 +1,213 @@
+package org.gwtbootstrap3.extras.datepicker.client;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.resources.client.ClientBundle;
+import com.google.gwt.resources.client.TextResource;
+
+/**
+ * @author Sven Jacobs
+ */
+public interface DatePickerClientBundle extends ClientBundle {
+
+ static final DatePickerClientBundle INSTANCE = GWT.create(DatePickerClientBundle.class);
+
+ @Source("resource/js/bootstrap-datepicker-1.4.0.min.cache.js")
+ TextResource datePicker();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.ar.min.js")
+ TextResource ar();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.bg.min.js")
+ TextResource bg();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.ca.min.js")
+ TextResource ca();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.cs.min.js")
+ TextResource cs();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.da.min.js")
+ TextResource da();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.de.min.js")
+ TextResource de();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.el.min.js")
+ TextResource el();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.en-GB.min.js")
+ TextResource en_GB();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.es.min.js")
+ TextResource es();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.et.min.js")
+ TextResource et();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.eu.min.js")
+ TextResource eu();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.fa.min.js")
+ TextResource fa();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.fi.min.js")
+ TextResource fi();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.fo.min.js")
+ TextResource fo();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.fr.min.js")
+ TextResource fr();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.fr-CH.min.js")
+ TextResource fr_CH();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.gl.min.js")
+ TextResource gl();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.he.min.js")
+ TextResource he();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.hr.min.js")
+ TextResource hr();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.hu.min.js")
+ TextResource hu();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.hy.min.js")
+ TextResource hy();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.id.min.js")
+ TextResource id();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.is.min.js")
+ TextResource is();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.it.min.js")
+ TextResource it();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.it-CH.min.js")
+ TextResource it_CH();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.ja.min.js")
+ TextResource ja();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.ka.min.js")
+ TextResource ka();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.kh.min.js")
+ TextResource kh();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.kk.min.js")
+ TextResource kk();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.kr.min.js")
+ TextResource kr();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.lt.min.js")
+ TextResource lt();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.lv.min.js")
+ TextResource lv();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.me.min.js")
+ TextResource me();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.mk.min.js")
+ TextResource mk();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.ms.min.js")
+ TextResource ms();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.nb.min.js")
+ TextResource nb();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.nl.min.js")
+ TextResource nl();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.nl-BE.min.js")
+ TextResource nl_BE();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.no.min.js")
+ TextResource no();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.pl.min.js")
+ TextResource pl();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.pt.min.js")
+ TextResource pt();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.pt-BR.min.js")
+ TextResource pt_BR();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.ro.min.js")
+ TextResource ro();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.rs.min.js")
+ TextResource rs();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.rs-latin.min.js")
+ TextResource rs_latin();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.ru.min.js")
+ TextResource ru();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.sk.min.js")
+ TextResource sk();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.sl.min.js")
+ TextResource sl();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.sq.min.js")
+ TextResource sq();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.sr.min.js")
+ TextResource sr();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.sr-latin.min.js")
+ TextResource sr_latin();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.sv.min.js")
+ TextResource sv();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.sw.min.js")
+ TextResource sw();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.th.min.js")
+ TextResource th();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.tr.min.js")
+ TextResource tr();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.uk.min.js")
+ TextResource uk();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.vi.min.js")
+ TextResource vi();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.zh-CN.min.js")
+ TextResource zh_CN();
+
+ @Source("resource/js/locales.cache.1.4.0/bootstrap-datepicker.zh-TW.min.js")
+ TextResource zh_TW();
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/DatePickerEntryPoint.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/DatePickerEntryPoint.java
new file mode 100644
index 00000000..265cf363
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/DatePickerEntryPoint.java
@@ -0,0 +1,35 @@
+package org.gwtbootstrap3.extras.datepicker.client;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.core.client.ScriptInjector;
+
+/**
+ * @author Sven Jacobs
+ */
+public class DatePickerEntryPoint implements EntryPoint {
+
+ @Override
+ public void onModuleLoad() {
+ ScriptInjector.fromString(DatePickerClientBundle.INSTANCE.datePicker().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/DatePicker.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/DatePicker.java
new file mode 100644
index 00000000..0be3dbaf
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/DatePicker.java
@@ -0,0 +1,29 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import org.gwtbootstrap3.extras.datepicker.client.ui.base.DatePickerBase;
+
+/**
+ * @author Joshua Godi
+ */
+public class DatePicker extends DatePickerBase {
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/DatePickerBase.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/DatePickerBase.java
new file mode 100644
index 00000000..956f3df9
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/DatePickerBase.java
@@ -0,0 +1,593 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.core.client.ScriptInjector;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.Style;
+import com.google.gwt.editor.client.IsEditor;
+import com.google.gwt.editor.client.LeafValueEditor;
+import com.google.gwt.editor.client.adapters.TakesValueEditor;
+import com.google.gwt.event.logical.shared.ValueChangeEvent;
+import com.google.gwt.event.logical.shared.ValueChangeHandler;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.ui.*;
+import org.gwtbootstrap3.client.shared.event.HideEvent;
+import org.gwtbootstrap3.client.shared.event.HideHandler;
+import org.gwtbootstrap3.client.shared.event.ShowEvent;
+import org.gwtbootstrap3.client.shared.event.ShowHandler;
+import org.gwtbootstrap3.client.ui.TextBox;
+import org.gwtbootstrap3.client.ui.base.HasId;
+import org.gwtbootstrap3.client.ui.base.HasPlaceholder;
+import org.gwtbootstrap3.client.ui.base.HasResponsiveness;
+import org.gwtbootstrap3.client.ui.base.ValueBoxBase;
+import org.gwtbootstrap3.client.ui.base.helper.StyleHelper;
+import org.gwtbootstrap3.client.ui.constants.DeviceSize;
+import org.gwtbootstrap3.extras.datepicker.client.ui.base.constants.*;
+import org.gwtbootstrap3.extras.datepicker.client.ui.base.events.*;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Joshua Godi
+ */
+public class DatePickerBase extends Widget
+ implements HasEnabled, HasId, HasResponsiveness, HasVisibility, HasPlaceholder, HasAutoClose, HasDaysOfWeekDisabled, HasEndDate, HasForceParse,
+ HasFormat, HasHighlightToday, HasKeyboardNavigation, HasMinView, HasShowTodayButton, HasStartDate, HasStartView, HasViewSelect, HasWeekStart,
+ HasDateTimePickerHandlers, HasLanguage, HasName, HasValue, HasPosition, IsEditor> {
+
+ // Check http://www.gwtproject.org/javadoc/latest/com/google/gwt/i18n/client/DateTimeFormat.html
+ // for more information on syntax
+ private static final Map DATE_TIME_FORMAT_MAP = new HashMap();
+
+ static {
+ DATE_TIME_FORMAT_MAP.put('m', 'M'); // months
+ }
+
+ private final TextBox textBox;
+ private DateTimeFormat dateTimeFormat;
+ private final DateTimeFormat startEndDateFormat = DateTimeFormat.getFormat("MM-dd-yyyy");
+ private LeafValueEditor editor;
+
+ /**
+ * DEFAULT values
+ */
+ private String format = "mm/dd/yyyy";
+ private DatePickerDayOfWeek weekStart = DatePickerDayOfWeek.SUNDAY;
+ private DatePickerDayOfWeek[] daysOfWeekDisabled = {};
+ private boolean autoClose = false;
+ private DatePickerMinView startView = DatePickerMinView.DAY;
+ private DatePickerMinView minView = DatePickerMinView.DAY;
+
+ private boolean showTodayButton = false;
+ private boolean highlightToday = false;
+ private boolean keyboardNavigation = true;
+ private boolean forceParse = true;
+
+ private DatePickerMinView viewSelect = DatePickerMinView.DAY;
+
+ private Widget container = null;
+ private DatePickerLanguage language = DatePickerLanguage.EN;
+ private DatePickerPosition position = DatePickerPosition.TOP_LEFT;
+
+ public DatePickerBase() {
+ textBox = new TextBox();
+ setElement((Element) textBox.getElement());
+ setFormat(format);
+ }
+
+ public void setContainer(final Widget container) {
+ this.container = container;
+ }
+
+ public Widget getContainer() {
+ return container;
+ }
+
+ public TextBox getTextBox() {
+ return textBox;
+ }
+
+ public void setAlignment(final ValueBoxBase.TextAlignment align) {
+ textBox.setAlignment(align);
+ }
+
+ @Override
+ public void setPlaceholder(final String placeHolder) {
+ textBox.setPlaceholder(placeHolder);
+ }
+
+ @Override
+ public String getPlaceholder() {
+ return textBox.getPlaceholder();
+ }
+
+ public void setReadOnly(final boolean readOnly) {
+ textBox.setReadOnly(readOnly);
+ }
+
+ public boolean isReadOnly() {
+ return textBox.isReadOnly();
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return textBox.isEnabled();
+ }
+
+ @Override
+ public void setEnabled(final boolean enabled) {
+ textBox.setEnabled(enabled);
+ }
+
+ @Override
+ public void setId(final String id) {
+ textBox.setId(id);
+ }
+
+ @Override
+ public String getId() {
+ return textBox.getId();
+ }
+
+ @Override
+ public void setName(final String name) {
+ textBox.setName(name);
+ }
+
+ @Override
+ public String getName() {
+ return textBox.getName();
+ }
+
+ @Override
+ public void setVisibleOn(final DeviceSize deviceSize) {
+ StyleHelper.setVisibleOn(this, deviceSize);
+ }
+
+ @Override
+ public void setHiddenOn(final DeviceSize deviceSize) {
+ StyleHelper.setHiddenOn(this, deviceSize);
+ }
+
+ @Override
+ public void setLanguage(final DatePickerLanguage language) {
+ this.language = language;
+
+ // Inject the JS for the language
+ if (language.getJs() != null) {
+ ScriptInjector.fromString(language.getJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
+ }
+ }
+
+ @Override
+ public DatePickerLanguage getLanguage() {
+ return language;
+ }
+
+ @Override
+ public void setPosition(final DatePickerPosition position) {
+ this.position = position;
+ }
+
+ @Override
+ public DatePickerPosition getPosition() {
+ return position;
+ }
+
+ /**
+ * Call this whenever changing any settings: minView, startView, format, etc. If you are changing
+ * format and date value, the updates must take in such order:
+ *
+ * locales.cache.1.4.0. DateTimePicker.reload()
+ * 2. DateTimePicker.setValue(newDate); // Date newDate.
+ *
+ * Otherwise date value is not updated.
+ */
+ public void reload() {
+ configure();
+ }
+
+ public void show() {
+ show(getElement());
+ }
+
+ public void hide() {
+ hide(getElement());
+ }
+
+ @Override
+ public void setAutoClose(final boolean autoClose) {
+ this.autoClose = autoClose;
+ }
+
+ @Override
+ public void onShow(final Event e) {
+ // On show we put focus on the textbox
+ textBox.setFocus(true);
+
+ fireEvent(new ShowEvent(e));
+ }
+
+ @Override
+ public HandlerRegistration addShowHandler(final ShowHandler showHandler) {
+ return addHandler(showHandler, ShowEvent.getType());
+ }
+
+ @Override
+ public void onHide(final Event e) {
+ // On hide we remove focus from the textbox
+ textBox.setFocus(false);
+
+ fireEvent(new HideEvent(e));
+ }
+
+ @Override
+ public HandlerRegistration addHideHandler(final HideHandler hideHandler) {
+ return addHandler(hideHandler, HideEvent.getType());
+ }
+
+ @Override
+ public void onChangeDate(final Event e) {
+ fireEvent(new ChangeDateEvent(e));
+ }
+
+ @Override
+ public HandlerRegistration addChangeDateHandler(final ChangeDateHandler changeDateHandler) {
+ return addHandler(changeDateHandler, ChangeDateEvent.getType());
+ }
+
+ @Override
+ public void onChangeYear(final Event e) {
+ fireEvent(new ChangeYearEvent(e));
+ }
+
+ @Override
+ public HandlerRegistration addChangeYearHandler(final ChangeYearHandler changeYearHandler) {
+ return addHandler(changeYearHandler, ChangeYearEvent.getType());
+ }
+
+ @Override
+ public void onChangeMonth(final Event e) {
+ fireEvent(new ChangeMonthEvent(e));
+ }
+
+ @Override
+ public HandlerRegistration addChangeMonthHandler(final ChangeMonthHandler changeMonthHandler) {
+ return addHandler(changeMonthHandler, ChangeMonthEvent.getType());
+ }
+
+ @Override
+ public void onClearDate(final Event e) {
+ fireEvent(new ClearDateEvent(e));
+ }
+
+ @Override
+ public HandlerRegistration addClearDateHandler(final ClearDateHandler clearDateHandler) {
+ return addHandler(clearDateHandler, ClearDateEvent.getType());
+ }
+
+ @Override
+ public void setDaysOfWeekDisabled(final DatePickerDayOfWeek... daysOfWeekDisabled) {
+ setDaysOfWeekDisabled(getElement(), toDaysOfWeekDisabledString(daysOfWeekDisabled));
+ }
+
+ @Override
+ public void setEndDate(final Date endDate) {
+ // Has to be in the format YYYY-MM-DD
+ setEndDate(startEndDateFormat.format(endDate));
+ }
+
+ @Override
+ public void setEndDate(final String endDate) {
+ // Has to be in the format YYYY-MM-DD
+ setEndDate(getElement(), endDate);
+ }
+
+ @Override
+ public void clearEndDate() {
+ setStartDate(getElement(), null);
+ }
+
+ @Override
+ public void setForceParse(final boolean forceParse) {
+ this.forceParse = forceParse;
+ }
+
+ @Override
+ public void setHighlightToday(final boolean highlightToday) {
+ this.highlightToday = highlightToday;
+ }
+
+ @Override
+ public void setHasKeyboardNavigation(final boolean hasKeyboardNavigation) {
+ this.keyboardNavigation = hasKeyboardNavigation;
+ }
+
+ @Override
+ public void setMinView(final DatePickerMinView datePickerMinView) {
+ this.minView = datePickerMinView;
+
+ // We keep the view select the same as the min view
+ if (viewSelect != minView) {
+ setViewSelect(datePickerMinView);
+ }
+ }
+
+ @Override
+ public void setShowTodayButton(final boolean showTodayButton) {
+ this.showTodayButton = showTodayButton;
+ }
+
+ @Override
+ public void setStartDate(final Date startDate) {
+ // Has to be in the format DD-MM-YYYY
+ setStartDate(startEndDateFormat.format(startDate));
+ }
+
+ @Override
+ public void setStartDate(final String startDate) {
+ // Has to be in the format DD-MM-YYYY
+ setStartDate(getElement(), startDate);
+ }
+
+ @Override
+ public void clearStartDate() {
+ setStartDate(getElement(), null);
+ }
+
+ @Override
+ public void setStartView(final DatePickerMinView datePickerMinView) {
+ this.startView = datePickerMinView;
+ }
+
+ @Override
+ public void setViewSelect(final DatePickerMinView datePickerMinView) {
+ this.viewSelect = datePickerMinView;
+
+ // We keep the min view the same as the view select
+ if (viewSelect != minView) {
+ setMinView(datePickerMinView);
+ }
+ }
+
+ @Override
+ public void setWeekStart(final DatePickerDayOfWeek weekStart) {
+ this.weekStart = weekStart;
+ }
+
+ @Override
+ public void setFormat(final String format) {
+ this.format = format;
+
+ // Get the old value
+ final Date oldValue = getValue();
+
+ // Make the new DateTimeFormat
+ setDateTimeFormat(format);
+
+ if (oldValue != null) {
+ setValue(oldValue);
+ }
+ }
+
+ private void setDateTimeFormat(final String format) {
+ final StringBuilder fb = new StringBuilder(format);
+ for (int i = 0; i < fb.length(); i++) {
+ if (DATE_TIME_FORMAT_MAP.containsKey(fb.charAt(i))) {
+ fb.setCharAt(i, DATE_TIME_FORMAT_MAP.get(fb.charAt(i)));
+ }
+ }
+
+ this.dateTimeFormat = DateTimeFormat.getFormat(fb.toString());
+ }
+
+ @Override
+ public Date getValue() {
+ try {
+ return dateTimeFormat != null && textBox.getValue() != null ? dateTimeFormat.parse(textBox.getValue()) : null;
+ } catch (final Exception e) {
+ return null;
+ }
+ }
+
+ public String getBaseValue() {
+ return textBox.getValue();
+ }
+
+ @Override
+ public HandlerRegistration addValueChangeHandler(final ValueChangeHandler dateValueChangeHandler) {
+ return addHandler(dateValueChangeHandler, ValueChangeEvent.getType());
+ }
+
+ @Override
+ public void setValue(final Date value) {
+ setValue(value, false);
+ }
+
+ @Override
+ public void setValue(final Date value, final boolean fireEvents) {
+ textBox.setValue(value != null ? dateTimeFormat.format(value) : null);
+ update(textBox.getElement());
+
+ if (fireEvents) {
+ ValueChangeEvent.fire(DatePickerBase.this, value);
+ }
+ }
+
+ @Override
+ public LeafValueEditor asEditor() {
+ if (editor == null) {
+ editor = TakesValueEditor.of(this);
+ }
+ return editor;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void onLoad() {
+ super.onLoad();
+ configure();
+
+ // With the new update the parent must have position: relative for positioning to work
+ if (getElement().getParentElement() != null) {
+ getElement().getParentElement().getStyle().setPosition(Style.Position.RELATIVE);
+ }
+ }
+
+ @Override
+ protected void onUnload() {
+ super.onUnload();
+ remove(getElement());
+ }
+
+ protected void configure() {
+ // If the user hasn't specified the container, default to the widget's parent
+ // This makes sure the modal scroll with the content correctly
+ if (container == null) {
+ configure(this, this.getParent());
+ } else {
+ configure(this, container);
+ }
+ }
+
+ protected void configure(final Widget w, final Widget container) {
+ w.getElement().setAttribute("data-date-format", format);
+
+ // If configuring not for the first time, datepicker must be removed first.
+ this.remove(w.getElement());
+
+ configure(w.getElement(), container.getElement(), format, weekStart.getValue(), toDaysOfWeekDisabledString(daysOfWeekDisabled), autoClose,
+ startView.getValue(), minView.getValue(), showTodayButton, highlightToday, keyboardNavigation, forceParse, viewSelect.getValue(),
+ language.getCode(), position.getPosition());
+ }
+
+ protected void execute(final String cmd) {
+ execute(getElement(), cmd);
+ }
+
+ private native void execute(Element e, String cmd) /*-{
+ $wnd.jQuery(e).datepicker(cmd);
+ }-*/;
+
+ private native void remove(Element e) /*-{
+ $wnd.jQuery(e).datepicker('remove');
+ $wnd.jQuery(e).off('show');
+ $wnd.jQuery(e).off('hide');
+ $wnd.jQuery(e).off('changeDate');
+ $wnd.jQuery(e).off('changeYear');
+ $wnd.jQuery(e).off('changeMonth');
+ $wnd.jQuery(e).off('clearDate');
+ }-*/;
+
+ private native void show(Element e) /*-{
+ $wnd.jQuery(e).datepicker('show');
+ }-*/;
+
+ private native void hide(Element e) /*-{
+ $wnd.jQuery(e).datepicker('hide');
+ }-*/;
+
+ private native void update(Element e) /*-{
+ $wnd.jQuery(e).datepicker('update');
+ }-*/;
+
+ private native void setStartDate(Element e, String startDate) /*-{
+ $wnd.jQuery(e).datepicker('setStartDate', startDate);
+ }-*/;
+
+ private native void setEndDate(Element e, String endDate) /*-{
+ $wnd.jQuery(e).datepicker('setEndDate', endDate);
+ }-*/;
+
+ private native void setDaysOfWeekDisabled(Element e, String daysOfWeekDisabled) /*-{
+ $wnd.jQuery(e).datepicker('setDaysOfWeekDisabled', daysOfWeekDisabled);
+ }-*/;
+
+ protected native void configure(Element e, Element p, String format, int weekStart, String daysOfWeekDisabled, boolean autoClose, int startView,
+ int minViewMode, boolean todayBtn, boolean highlightToday, boolean keyboardNavigation, boolean forceParse, int viewSelect, String language,
+ String orientation) /*-{
+
+ if (todayBtn) {
+ todayBtn = "linked";
+ }
+
+ var that = this;
+ $wnd.jQuery(e).datepicker({
+ format: format,
+ language: language,
+ weekStart: weekStart,
+ daysOfWeekDisabled: daysOfWeekDisabled,
+ autoclose: autoClose,
+ startView: startView,
+ minViewMode: minViewMode,
+ todayBtn: todayBtn,
+ todayHighlight: highlightToday,
+ keyboardNavigation: keyboardNavigation,
+ forceParse: forceParse,
+ orientation: orientation,
+ container: p
+ })
+ .on('show', function (e) {
+ that.@org.gwtbootstrap3.extras.datepicker.client.ui.base.DatePickerBase::onShow(Lcom/google/gwt/user/client/Event;)(e);
+ })
+ .on("hide", function (e) {
+ that.@org.gwtbootstrap3.extras.datepicker.client.ui.base.DatePickerBase::onHide(Lcom/google/gwt/user/client/Event;)(e);
+ })
+ .on("changeDate", function (e) {
+ that.@org.gwtbootstrap3.extras.datepicker.client.ui.base.DatePickerBase::onChangeDate(Lcom/google/gwt/user/client/Event;)(e);
+ })
+ .on("changeYear", function (e) {
+ that.@org.gwtbootstrap3.extras.datepicker.client.ui.base.DatePickerBase::onChangeYear(Lcom/google/gwt/user/client/Event;)(e);
+ })
+ .on("changeMonth", function (e) {
+ that.@org.gwtbootstrap3.extras.datepicker.client.ui.base.DatePickerBase::onChangeMonth(Lcom/google/gwt/user/client/Event;)(e);
+ })
+ .on("clearDate", function (e) {
+ that.@org.gwtbootstrap3.extras.datepicker.client.ui.base.DatePickerBase::onClearDate(Lcom/google/gwt/user/client/Event;)(e);
+ });
+ }-*/;
+
+ protected String toDaysOfWeekDisabledString(final DatePickerDayOfWeek... datePickerDayOfWeeks) {
+ this.daysOfWeekDisabled = datePickerDayOfWeeks;
+
+ final StringBuilder builder = new StringBuilder();
+
+ if (datePickerDayOfWeeks != null) {
+ int i = 0;
+ for (final DatePickerDayOfWeek dayOfWeek : datePickerDayOfWeeks) {
+ builder.append(dayOfWeek.getValue());
+
+ i++;
+ if (i < datePickerDayOfWeeks.length) {
+ builder.append(",");
+ }
+ }
+ }
+ return builder.toString();
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/DatePickerDayOfWeek.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/DatePickerDayOfWeek.java
new file mode 100644
index 00000000..ba123928
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/DatePickerDayOfWeek.java
@@ -0,0 +1,46 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Day of the week enum for easy access
+ *
+ * @author Joshua Godi
+ */
+public enum DatePickerDayOfWeek {
+ SUNDAY(0),
+ MONDAY(1),
+ TUESDAY(2),
+ WEDNESDAY(3),
+ THURSDAY(4),
+ FRIDAY(5),
+ SATURDAY(6);
+
+ private final int value;
+
+ DatePickerDayOfWeek(final int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/DatePickerLanguage.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/DatePickerLanguage.java
new file mode 100644
index 00000000..c735e4db
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/DatePickerLanguage.java
@@ -0,0 +1,105 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.resources.client.TextResource;
+import org.gwtbootstrap3.extras.datepicker.client.DatePickerClientBundle;
+
+/**
+ * @author Joshua Godi
+ */
+public enum DatePickerLanguage {
+ AR("ar", DatePickerClientBundle.INSTANCE.ar()),
+ BG("bg", DatePickerClientBundle.INSTANCE.bg()),
+ CA("ca", DatePickerClientBundle.INSTANCE.ca()),
+ CS("cs", DatePickerClientBundle.INSTANCE.cs()),
+ DA("da", DatePickerClientBundle.INSTANCE.da()),
+ DE("de", DatePickerClientBundle.INSTANCE.de()),
+ EL("el", DatePickerClientBundle.INSTANCE.el()),
+ EN_GB("en-GB", DatePickerClientBundle.INSTANCE.en_GB()),
+ ES("es", DatePickerClientBundle.INSTANCE.es()),
+ ET("et", DatePickerClientBundle.INSTANCE.et()),
+ EU("eu", DatePickerClientBundle.INSTANCE.eu()),
+ FA("fa", DatePickerClientBundle.INSTANCE.fa()),
+ FO("fo", DatePickerClientBundle.INSTANCE.fo()),
+ FI("fi", DatePickerClientBundle.INSTANCE.fi()),
+ FR("fr", DatePickerClientBundle.INSTANCE.fr()),
+ FR_CH("fr-CH", DatePickerClientBundle.INSTANCE.fr_CH()),
+ GL("gl", DatePickerClientBundle.INSTANCE.gl()),
+ HE("he", DatePickerClientBundle.INSTANCE.he()),
+ HR("hr", DatePickerClientBundle.INSTANCE.hr()),
+ HU("hu", DatePickerClientBundle.INSTANCE.hu()),
+ HY("hy", DatePickerClientBundle.INSTANCE.hy()),
+ ID("id", DatePickerClientBundle.INSTANCE.id()),
+ IS("is", DatePickerClientBundle.INSTANCE.is()),
+ IT("it", DatePickerClientBundle.INSTANCE.it()),
+ IT_CH("it-CH", DatePickerClientBundle.INSTANCE.it_CH()),
+ JA("ja", DatePickerClientBundle.INSTANCE.ja()),
+ KA("ka", DatePickerClientBundle.INSTANCE.ka()),
+ KH("kh", DatePickerClientBundle.INSTANCE.kh()),
+ KK("kk", DatePickerClientBundle.INSTANCE.kk()),
+ KR("kr", DatePickerClientBundle.INSTANCE.kr()),
+ LT("lt", DatePickerClientBundle.INSTANCE.lt()),
+ LV("lv", DatePickerClientBundle.INSTANCE.lv()),
+ MK("mk", DatePickerClientBundle.INSTANCE.mk()),
+ MS("ms", DatePickerClientBundle.INSTANCE.ms()),
+ NB("nb", DatePickerClientBundle.INSTANCE.nb()),
+ NL("nl", DatePickerClientBundle.INSTANCE.nl()),
+ NL_BE("nl-BE", DatePickerClientBundle.INSTANCE.nl_BE()),
+ NO("no", DatePickerClientBundle.INSTANCE.no()),
+ PL("pl", DatePickerClientBundle.INSTANCE.pl()),
+ PT("pt", DatePickerClientBundle.INSTANCE.pt()),
+ PT_BR("pt-BR", DatePickerClientBundle.INSTANCE.pt_BR()),
+ RO("ro", DatePickerClientBundle.INSTANCE.ro()),
+ RS("rs", DatePickerClientBundle.INSTANCE.rs()),
+ RS_LATIN("rs-latin", DatePickerClientBundle.INSTANCE.rs_latin()),
+ RU("ru", DatePickerClientBundle.INSTANCE.ru()),
+ SK("sk", DatePickerClientBundle.INSTANCE.sk()),
+ SL("sl", DatePickerClientBundle.INSTANCE.sl()),
+ SQ("sq", DatePickerClientBundle.INSTANCE.sq()),
+ SR("sr", DatePickerClientBundle.INSTANCE.sr()),
+ SR_LATIN("sr-latin", DatePickerClientBundle.INSTANCE.sr_latin()),
+ SV("sv", DatePickerClientBundle.INSTANCE.sv()),
+ SW("sw", DatePickerClientBundle.INSTANCE.sw()),
+ TH("th", DatePickerClientBundle.INSTANCE.th()),
+ TR("tr", DatePickerClientBundle.INSTANCE.tr()),
+ VI("vi", DatePickerClientBundle.INSTANCE.vi()),
+ UK("uk", DatePickerClientBundle.INSTANCE.uk()),
+ ZH_CN("zh-CN", DatePickerClientBundle.INSTANCE.zh_CN()),
+ ZH_TW("zh-TW", DatePickerClientBundle.INSTANCE.zh_TW()),
+ EN("en", null); // Base language, don't need another file
+
+ private final String code;
+ private final TextResource js;
+
+ private DatePickerLanguage(final String code, final TextResource js) {
+ this.js = js;
+ this.code = code;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public TextResource getJs() {
+ return js;
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/DatePickerMinView.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/DatePickerMinView.java
new file mode 100644
index 00000000..243cc058
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/DatePickerMinView.java
@@ -0,0 +1,40 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * @author Matt Davis
+ */
+public enum DatePickerMinView {
+ DAY(0),
+ MONTH(1),
+ YEAR(2);
+
+ private final int value;
+
+ DatePickerMinView(final int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/DatePickerPosition.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/DatePickerPosition.java
new file mode 100644
index 00000000..f20a3c21
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/DatePickerPosition.java
@@ -0,0 +1,48 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Position to display the DateTimePicker popup
+ *
+ * @author Joshua Godi
+ */
+public enum DatePickerPosition {
+ AUTO("auto"),
+ TOP_AUTO("top auto"),
+ BOTTOM_AUTO("bottom auto"),
+ AUTO_RIGHT("auto right"),
+ AUTO_LEFT("auto left"),
+ TOP_LEFT("top left"),
+ TOP_RIGHT("top right"),
+ BOTTOM_LEFT("bottom left"),
+ BOTTOM_RIGHT("bottom right");
+
+ private final String position;
+
+ DatePickerPosition(final String position) {
+ this.position = position;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/DatePickerStartView.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/DatePickerStartView.java
new file mode 100644
index 00000000..791aa8fc
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/DatePickerStartView.java
@@ -0,0 +1,40 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * @author Matt Davis
+ */
+public enum DatePickerStartView {
+ MONTH(0),
+ YEAR(1),
+ DECADE(2);
+
+ private final int value;
+
+ DatePickerStartView(final int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasAutoClose.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasAutoClose.java
new file mode 100644
index 00000000..52c87df9
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasAutoClose.java
@@ -0,0 +1,32 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Boolean. Default: false
+ *
+ * Whether or not to close the datetimepicker immediately when a date is selected.
+ *
+ * @author Joshua Godi
+ */
+public interface HasAutoClose {
+ void setAutoClose(boolean autoClose);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasDateTimePickerHandlers.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasDateTimePickerHandlers.java
new file mode 100644
index 00000000..c37ac918
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasDateTimePickerHandlers.java
@@ -0,0 +1,61 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.user.client.Event;
+import com.google.web.bindery.event.shared.HandlerRegistration;
+import org.gwtbootstrap3.client.shared.event.HideHandler;
+import org.gwtbootstrap3.client.shared.event.ShowHandler;
+import org.gwtbootstrap3.extras.datepicker.client.ui.base.events.ChangeDateHandler;
+import org.gwtbootstrap3.extras.datepicker.client.ui.base.events.ChangeMonthHandler;
+import org.gwtbootstrap3.extras.datepicker.client.ui.base.events.ChangeYearHandler;
+import org.gwtbootstrap3.extras.datepicker.client.ui.base.events.ClearDateHandler;
+
+/**
+ * All handlers for the DateTimePicker
+ *
+ * @author Joshua Godi
+ */
+public interface HasDateTimePickerHandlers {
+ void onShow(Event e);
+
+ HandlerRegistration addShowHandler(ShowHandler showHandler);
+
+ void onHide(Event e);
+
+ HandlerRegistration addHideHandler(HideHandler hideHandler);
+
+ void onChangeDate(Event e);
+
+ HandlerRegistration addChangeDateHandler(ChangeDateHandler changeDateHandler);
+
+ void onChangeYear(Event e);
+
+ HandlerRegistration addChangeYearHandler(ChangeYearHandler changeYearHandler);
+
+ void onChangeMonth(Event e);
+
+ HandlerRegistration addChangeMonthHandler(ChangeMonthHandler changeMonthHandler);
+
+ void onClearDate(Event e);
+
+ HandlerRegistration addClearDateHandler(ClearDateHandler outOfRangeHandler);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasDaysOfWeekDisabled.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasDaysOfWeekDisabled.java
new file mode 100644
index 00000000..51234312
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasDaysOfWeekDisabled.java
@@ -0,0 +1,34 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Enum, Array enums. Default: none
+ *
+ * Days of the week that should be disabled. Values are enum of DateTimePickerDayOfWeek.
+ * Multiple values should be comma-separated. Example: disable weekends: SUNDAY, MONDAY.
+ *
+ * @author Joshua Godi
+ * @see org.gwtbootstrap3.extras.datepicker.client.ui.base.constants.DatePickerDayOfWeek
+ */
+public interface HasDaysOfWeekDisabled {
+ void setDaysOfWeekDisabled(DatePickerDayOfWeek... daysOfWeekDisabled);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasEndDate.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasEndDate.java
new file mode 100644
index 00000000..5de86069
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasEndDate.java
@@ -0,0 +1,38 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import java.util.Date;
+
+/**
+ * Date. Default: End of time
+ *
+ * The latest date that may be selected; all later dates will be disabled.
+ *
+ * @author Joshua Godi
+ */
+public interface HasEndDate {
+ void setEndDate(Date endDate);
+
+ void setEndDate(String endDate);
+
+ void clearEndDate();
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasForceParse.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasForceParse.java
new file mode 100644
index 00000000..9b85bed5
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasForceParse.java
@@ -0,0 +1,34 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Boolean. Default: true
+ *
+ * Whether or not to force parsing of the input value when the picker is closed.
+ * That is, when an invalid date is left in the input field by the user, the picker will forcibly parse
+ * that value, and set the input's value to the new, valid date, conforming to the given format.
+ *
+ * @author Joshua Godi
+ */
+public interface HasForceParse {
+ void setForceParse(boolean forceParse);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasFormat.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasFormat.java
new file mode 100644
index 00000000..278c41a6
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasFormat.java
@@ -0,0 +1,50 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * String. Default: 'mm/dd/yyyy'
+ *
+ * The date format, combination of p, P, h, hh, i, ii, s, ss, d, dd, m, mm, M, MM, yy, yyyy.
+ * p : meridian in lower case ('am' or 'pm') - according to locale file
+ * P : meridian in upper case ('AM' or 'PM') - according to locale file
+ * s : seconds without leading zeros
+ * ss : seconds, 2 digits with leading zeros
+ * i : minutes without leading zeros
+ * ii : minutes, 2 digits with leading zeros
+ * h : hour without leading zeros - 24-hour format
+ * hh : hour, 2 digits with leading zeros - 24-hour format
+ * H : hour without leading zeros - 12-hour format
+ * HH : hour, 2 digits with leading zeros - 12-hour format
+ * d : day of the month without leading zeros
+ * dd : day of the month, 2 digits with leading zeros
+ * m : numeric representation of month without leading zeros
+ * mm : numeric representation of the month, 2 digits with leading zeros
+ * M : short textual representation of a month, three letters
+ * MM : full textual representation of a month, such as January or March
+ * yy : two digit representation of a year
+ * yyyy : full numeric representation of a year, 4 digits
+ *
+ * @author Joshua Godi
+ */
+public interface HasFormat {
+ void setFormat(String format);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasHighlightToday.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasHighlightToday.java
new file mode 100644
index 00000000..eaf15fb2
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasHighlightToday.java
@@ -0,0 +1,32 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Boolean. Default: false
+ *
+ * If true, highlights the current date.
+ *
+ * @author Joshua Godi
+ */
+public interface HasHighlightToday {
+ void setHighlightToday(boolean highlightToday);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasKeyboardNavigation.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasKeyboardNavigation.java
new file mode 100644
index 00000000..c3c29f40
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasKeyboardNavigation.java
@@ -0,0 +1,32 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Boolean. Default: true
+ *
+ * Whether or not to allow date navigation by arrow keys.
+ *
+ * @author Joshua Godi
+ */
+public interface HasKeyboardNavigation {
+ void setHasKeyboardNavigation(boolean hasKeyboardNavigation);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasLanguage.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasLanguage.java
new file mode 100644
index 00000000..e2ee827a
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasLanguage.java
@@ -0,0 +1,35 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Setter and getter for the language of the date time picker
+ *
+ * Be sure to load one language, it will use whatever is loaded last
+ *
+ * @author Joshua Godi
+ * @see DatePickerLanguage
+ */
+public interface HasLanguage {
+ void setLanguage(DatePickerLanguage language);
+
+ DatePickerLanguage getLanguage();
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasMinView.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasMinView.java
new file mode 100644
index 00000000..325639fa
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasMinView.java
@@ -0,0 +1,33 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Enum. Default: HOUR
+ *
+ * The lowest view that the datetimepicker should show.
+ *
+ * @author Joshua Godi
+ * @see DatePickerMinView
+ */
+public interface HasMinView {
+ void setMinView(DatePickerMinView datePickerMinView);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasPosition.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasPosition.java
new file mode 100644
index 00000000..9b685266
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasPosition.java
@@ -0,0 +1,42 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Default: BOTTOM_RIGHT
+ *
+ * @author Joshua Godi
+ */
+public interface HasPosition {
+ /**
+ * Set the position of the date time picker
+ *
+ * @param position position
+ */
+ void setPosition(DatePickerPosition position);
+
+ /**
+ * Gets the position of the date time picker
+ *
+ * @return position
+ */
+ DatePickerPosition getPosition();
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasShowTodayButton.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasShowTodayButton.java
new file mode 100644
index 00000000..c744aa3a
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasShowTodayButton.java
@@ -0,0 +1,34 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Boolean, "linked". Default: false
+ *
+ * If true or "linked", displays a "Today" button at the bottom of the datetimepicker to select the current date.
+ * If true, the "Today" button will only move the current date into view; if "linked",
+ * the current date will also be selected.
+ *
+ * @author Joshua Godi
+ */
+public interface HasShowTodayButton {
+ void setShowTodayButton(boolean showTodayButton);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasStartDate.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasStartDate.java
new file mode 100644
index 00000000..4a63b6a5
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasStartDate.java
@@ -0,0 +1,38 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import java.util.Date;
+
+/**
+ * Date. Default: Beginning of time
+ *
+ * The earliest date that may be selected; all earlier dates will be disabled.
+ *
+ * @author Joshua Godi
+ */
+public interface HasStartDate {
+ void setStartDate(Date startDate);
+
+ void setStartDate(String startDate);
+
+ void clearStartDate();
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasStartView.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasStartView.java
new file mode 100644
index 00000000..6c4ffa27
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasStartView.java
@@ -0,0 +1,39 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * ENUM. Default: 2, 'month'
+ *
+ * The view that the datetimepicker should show when it is opened. Accepts values of :
+ *
+ * 'hour' for the hour view
+ * 'day' for the day view
+ * 'month' for month view (the default)
+ * 'year' for the 12-month overview
+ * 'decade' for the 10-year overview. Useful for date-of-birth datetimepickers.
+ *
+ * @author Joshua Godi
+ * @see DatePickerMinView
+ */
+public interface HasStartView {
+ void setStartView(DatePickerMinView datePickerMinView);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasViewSelect.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasViewSelect.java
new file mode 100644
index 00000000..284f0b11
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasViewSelect.java
@@ -0,0 +1,34 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Default: same as minView
+ *
+ * With this option you can select the view from which the date will be selected. By default it's the last one,
+ * however you can choose the first one, so at each click the date will be updated.
+ *
+ * @author Joshua Godi
+ * @see DatePickerMinView
+ */
+public interface HasViewSelect {
+ void setViewSelect(DatePickerMinView datePickerMinView);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasWeekStart.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasWeekStart.java
new file mode 100644
index 00000000..dd483944
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/constants/HasWeekStart.java
@@ -0,0 +1,33 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Enum. Default: SUNDAY
+ *
+ * Day of the week start. SUNDAY - SATURDAY
+ *
+ * @author Joshua Godi
+ * @see DatePickerDayOfWeek
+ */
+public interface HasWeekStart {
+ void setWeekStart(DatePickerDayOfWeek weekStart);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeDateEvent.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeDateEvent.java
new file mode 100644
index 00000000..46e95597
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeDateEvent.java
@@ -0,0 +1,56 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.events;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.GwtEvent;
+import com.google.gwt.user.client.Event;
+
+/**
+ * @author Joshua Godi
+ */
+public class ChangeDateEvent extends GwtEvent {
+
+ private static final Type TYPE = new Type();
+
+ private final Event nativeEvent;
+
+ public static Type getType() {
+ return TYPE;
+ }
+
+ public ChangeDateEvent(final Event nativeEvent) {
+ this.nativeEvent = nativeEvent;
+ }
+
+ public Event getNativeEvent() {
+ return nativeEvent;
+ }
+
+ @Override
+ public Type getAssociatedType() {
+ return TYPE;
+ }
+
+ @Override
+ protected void dispatch(final ChangeDateHandler handler) {
+ handler.onChangeDate(this);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeDateHandler.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeDateHandler.java
new file mode 100644
index 00000000..bd728ba8
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeDateHandler.java
@@ -0,0 +1,30 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.events;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.EventHandler;
+
+/**
+ * @author Joshua Godi
+ */
+public interface ChangeDateHandler extends EventHandler {
+ void onChangeDate(final ChangeDateEvent evt);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeMonthEvent.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeMonthEvent.java
new file mode 100644
index 00000000..c6ce1aff
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeMonthEvent.java
@@ -0,0 +1,56 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.events;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.GwtEvent;
+import com.google.gwt.user.client.Event;
+
+/**
+ * @author Joshua Godi
+ */
+public class ChangeMonthEvent extends GwtEvent {
+
+ private static final Type TYPE = new Type();
+
+ private final Event nativeEvent;
+
+ public static Type getType() {
+ return TYPE;
+ }
+
+ public ChangeMonthEvent(final Event nativeEvent) {
+ this.nativeEvent = nativeEvent;
+ }
+
+ public Event getNativeEvent() {
+ return nativeEvent;
+ }
+
+ @Override
+ public Type getAssociatedType() {
+ return TYPE;
+ }
+
+ @Override
+ protected void dispatch(final ChangeMonthHandler handler) {
+ handler.onChangeMonth(this);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeMonthHandler.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeMonthHandler.java
new file mode 100644
index 00000000..b6542e60
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeMonthHandler.java
@@ -0,0 +1,30 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.events;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.EventHandler;
+
+/**
+ * @author Joshua Godi
+ */
+public interface ChangeMonthHandler extends EventHandler {
+ void onChangeMonth(final ChangeMonthEvent evt);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeYearEvent.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeYearEvent.java
new file mode 100644
index 00000000..21207d78
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeYearEvent.java
@@ -0,0 +1,56 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.events;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.GwtEvent;
+import com.google.gwt.user.client.Event;
+
+/**
+ * @author Joshua Godi
+ */
+public class ChangeYearEvent extends GwtEvent {
+
+ private static final Type TYPE = new Type();
+
+ private final Event nativeEvent;
+
+ public static Type getType() {
+ return TYPE;
+ }
+
+ public ChangeYearEvent(final Event nativeEvent) {
+ this.nativeEvent = nativeEvent;
+ }
+
+ public Event getNativeEvent() {
+ return nativeEvent;
+ }
+
+ @Override
+ public Type getAssociatedType() {
+ return TYPE;
+ }
+
+ @Override
+ protected void dispatch(final ChangeYearHandler handler) {
+ handler.onChangeYear(this);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeYearHandler.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeYearHandler.java
new file mode 100644
index 00000000..03a38da1
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ChangeYearHandler.java
@@ -0,0 +1,31 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.events;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.EventHandler;
+
+/**
+ * @author Joshua Godi
+ */
+public interface ChangeYearHandler extends EventHandler {
+ void onChangeYear(final ChangeYearEvent evt);
+}
+
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ClearDateEvent.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ClearDateEvent.java
new file mode 100644
index 00000000..081408f8
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ClearDateEvent.java
@@ -0,0 +1,56 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.events;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.GwtEvent;
+import com.google.gwt.user.client.Event;
+
+/**
+ * @author Matt Davis
+ */
+public class ClearDateEvent extends GwtEvent {
+
+ private static final Type TYPE = new Type();
+
+ private final Event nativeEvent;
+
+ public static Type getType() {
+ return TYPE;
+ }
+
+ public ClearDateEvent(final Event nativeEvent) {
+ this.nativeEvent = nativeEvent;
+ }
+
+ public Event getNativeEvent() {
+ return nativeEvent;
+ }
+
+ @Override
+ public Type getAssociatedType() {
+ return TYPE;
+ }
+
+ @Override
+ protected void dispatch(final ClearDateHandler handler) {
+ handler.onClearDate(this);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ClearDateHandler.java b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ClearDateHandler.java
new file mode 100644
index 00000000..e660320f
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/datepicker/client/ui/base/events/ClearDateHandler.java
@@ -0,0 +1,31 @@
+package org.gwtbootstrap3.extras.datepicker.client.ui.base.events;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.EventHandler;
+
+/**
+ * @author Matt Davis
+ */
+public interface ClearDateHandler extends EventHandler {
+ void onClearDate(final ClearDateEvent evt);
+}
+
diff --git a/src/main/java/org/gwtbootstrap3/extras/datetimepicker/client/ui/base/DateTimePickerBase.java b/src/main/java/org/gwtbootstrap3/extras/datetimepicker/client/ui/base/DateTimePickerBase.java
index 9a93dcbb..23f18d1e 100644
--- a/src/main/java/org/gwtbootstrap3/extras/datetimepicker/client/ui/base/DateTimePickerBase.java
+++ b/src/main/java/org/gwtbootstrap3/extras/datetimepicker/client/ui/base/DateTimePickerBase.java
@@ -92,6 +92,18 @@ public class DateTimePickerBase extends Widget implements HasEnabled, HasId, Has
HasShowMeridian, HasShowTodayButton, HasStartDate, HasStartView, HasViewSelect, HasWeekStart,
HasDateTimePickerHandlers, HasLanguage, HasName, HasValue, HasPosition, IsEditor> {
+ // Check http://www.gwtproject.org/javadoc/latest/com/google/gwt/i18n/client/DateTimeFormat.html
+ // for more information on syntax
+ private static final Map DATE_TIME_FORMAT_MAP = new HashMap();
+ static {
+ DATE_TIME_FORMAT_MAP.put('h', 'H'); // 12/24 hours
+ DATE_TIME_FORMAT_MAP.put('H', 'h'); // 12/24 hours
+ DATE_TIME_FORMAT_MAP.put('m', 'M'); // months
+ DATE_TIME_FORMAT_MAP.put('i', 'm'); // minutes
+ DATE_TIME_FORMAT_MAP.put('p', 'a'); // meridian
+ DATE_TIME_FORMAT_MAP.put('P', 'a'); // meridian
+ }
+
private final TextBox textBox;
private DateTimeFormat dateTimeFormat;
private final DateTimeFormat startEndDateFormat = DateTimeFormat.getFormat("yyyy-MM-dd");
@@ -436,21 +448,10 @@ public void setFormat(final String format) {
}
private void setDateTimeFormat(final String format) {
- // Check http://www.gwtproject.org/javadoc/latest/com/google/gwt/i18n/client/DateTimeFormat.html
- // for more information on syntax
- final Map map = new HashMap() {{
- put('h', 'H'); // 12/24 hours
- put('H', 'h'); // 12/24 hours
- put('m', 'M'); // months
- put('i', 'm'); // minutes
- put('p', 'a'); // meridian
- put('P', 'a'); // meridian
- }};
-
final StringBuilder fb = new StringBuilder(format);
for (int i = 0; i < fb.length(); i++) {
- if (map.containsKey(fb.charAt(i))) {
- fb.setCharAt(i, map.get(fb.charAt(i)));
+ if (DATE_TIME_FORMAT_MAP.containsKey(fb.charAt(i))) {
+ fb.setCharAt(i, DATE_TIME_FORMAT_MAP.get(fb.charAt(i)));
}
}
diff --git a/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/CalendarConfig.java b/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/CalendarConfig.java
index 87b1807e..0ed92e18 100644
--- a/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/CalendarConfig.java
+++ b/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/CalendarConfig.java
@@ -33,6 +33,7 @@ public class CalendarConfig {
private Language langauge;//http://arshaw.com/fullcalendar/docs/text/lang/
private ClickAndHoverConfig clickHoverConfig;//http://arshaw.com/fullcalendar/docs/mouse/
+ private SelectConfig selectConfig;//http://arshaw.com/fullcalendar/docs/selection/
private DragAndResizeConfig dragResizeConfig;//http://arshaw.com/fullcalendar/docs/event_ui/;
private EventDataConfig eventConfig;//http://arshaw.com/fullcalendar/docs/event_data/
private GeneralDisplay generalDisplay;//http://arshaw.com/fullcalendar/docs/display/
@@ -171,6 +172,14 @@ public ClickAndHoverConfig getClickHoverConfig() {
public void setClickHoverConfig(final ClickAndHoverConfig clickHoverConfig) {
this.clickHoverConfig = clickHoverConfig;
}
+
+ public SelectConfig getSelectConfig() {
+ return selectConfig;
+ }
+
+ public void setSelectConfig(final SelectConfig selectConfig) {
+ this.selectConfig = selectConfig;
+ }
public DragAndResizeConfig getDragResizeConfig() {
return dragResizeConfig;
@@ -209,6 +218,7 @@ public JsArray getJavaScriptParameters() {
setParameter(params, getDayNames());
setParameter(params, getDragResizeConfig());
setParameter(params, getClickHoverConfig());
+ setParameter(params, getSelectConfig());
setParameter(params, getEventConfig());
setParameter(params, getColumnFormat());
setParameter(params, getTimeFormat());
diff --git a/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/Event.java b/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/Event.java
index f61386b2..68331821 100644
--- a/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/Event.java
+++ b/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/Event.java
@@ -97,6 +97,11 @@ private native void setStart(String start) /*-{
theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.Event::event.start = start;
}-*/;
+ public native void setStart(final JavaScriptObject start) /*-{
+ var theInstance = this;
+ theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.Event::event.start = start;
+ }-*/;
+
public native JsDate getStart() /*-{
var theInstance = this;
if (theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.Event::event.start) {
@@ -135,6 +140,11 @@ private native void setEnd(String end) /*-{
theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.Event::event.end = end;
}-*/;
+ public native void setEnd(final JavaScriptObject end) /*-{
+ var theInstance = this;
+ theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.Event::event.end = end;
+ }-*/;
+
public native JsDate getEnd() /*-{
var theInstance = this;
if (theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.Event::event.end) {
diff --git a/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/FullCalendar.java b/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/FullCalendar.java
index 0aaa1902..794e2f16 100644
--- a/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/FullCalendar.java
+++ b/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/FullCalendar.java
@@ -373,4 +373,12 @@ private native void setAspectRatio(String id, double ratio) /*-{
public native void excecuteFunction(JavaScriptObject revertFunction)/*-{
revertFunction();
}-*/;
+
+ public void unselect() {
+ unselect(getElement().getId());
+ }
+
+ private native void unselect(String id) /*-{
+ $wnd.jQuery('#' + id).fullCalendar('unselect');
+ }-*/;
}
diff --git a/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/SelectConfig.java b/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/SelectConfig.java
new file mode 100644
index 00000000..59607d3a
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/SelectConfig.java
@@ -0,0 +1,55 @@
+package org.gwtbootstrap3.extras.fullcalendar.client.ui;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.core.client.JavaScriptObject;
+
+/**
+ * Wraps selection events inside a JavaScriptObject
+ *
+ * @see http://fullcalendar.io/docs/selection/
+ */
+public class SelectConfig implements IsJavaScriptObject {
+ private JavaScriptObject script;
+
+ public SelectConfig(final SelectEventCallback handler) {
+ if (handler != null) {
+ newInstance(handler);
+ }
+ }
+
+ private native void newInstance(SelectEventCallback handler) /*-{
+ var theInstance = this;
+ var mouseHandler = handler;
+ theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.SelectConfig::script = {};
+ theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.SelectConfig::script.select = function (start, end, jsEvent, view) {
+ mouseHandler.@org.gwtbootstrap3.extras.fullcalendar.client.ui.SelectEventCallback::select(Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/dom/client/NativeEvent;Lcom/google/gwt/core/client/JavaScriptObject;)(start, end, jsEvent, view);
+ };
+ theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.SelectConfig::script.unselect = function (view, jsEvent) {
+ mouseHandler.@org.gwtbootstrap3.extras.fullcalendar.client.ui.SelectEventCallback::unselect(Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/dom/client/NativeEvent;)(view, jsEvent);
+ };
+ }-*/;
+
+ @Override
+ public JavaScriptObject toJavaScript() {
+ return script;
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/SelectEventCallback.java b/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/SelectEventCallback.java
new file mode 100644
index 00000000..55c46dd5
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/SelectEventCallback.java
@@ -0,0 +1,34 @@
+package org.gwtbootstrap3.extras.fullcalendar.client.ui;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.dom.client.NativeEvent;
+
+/**
+ * Selection callback interface
+ *
+ */
+public interface SelectEventCallback {
+ public void select(JavaScriptObject start, JavaScriptObject end, NativeEvent event, JavaScriptObject viewObject);
+
+ public void unselect(JavaScriptObject viewObject, NativeEvent event);
+}
\ No newline at end of file
diff --git a/src/main/java/org/gwtbootstrap3/extras/growl/client/ui/Growl.java b/src/main/java/org/gwtbootstrap3/extras/growl/client/ui/Growl.java
index b45e1a74..ba97374e 100644
--- a/src/main/java/org/gwtbootstrap3/extras/growl/client/ui/Growl.java
+++ b/src/main/java/org/gwtbootstrap3/extras/growl/client/ui/Growl.java
@@ -20,10 +20,11 @@
* #L%
*/
-import com.google.gwt.core.client.JavaScriptObject;
import org.gwtbootstrap3.client.ui.constants.IconType;
import org.gwtbootstrap3.client.ui.constants.Styles;
+import com.google.gwt.core.client.JavaScriptObject;
+
/**
* This class represent instance of displayed Growl.
*
@@ -219,7 +220,6 @@ public static final Growl growl(final String title, final String message, final
* @see org.gwtbootstrap3.extras.growl.client.ui.GrowlOptions
*/
public static final native Growl growl(final String message, final GrowlOptions options) /*-{
- console.log(options);
return $wnd.jQuery.growl({ message: message }, options);
}-*/;
diff --git a/src/main/java/org/gwtbootstrap3/extras/notify/client/NotifyClientBundle.java b/src/main/java/org/gwtbootstrap3/extras/notify/client/NotifyClientBundle.java
new file mode 100644
index 00000000..42ca407e
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/notify/client/NotifyClientBundle.java
@@ -0,0 +1,33 @@
+package org.gwtbootstrap3.extras.notify.client;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.resources.client.ClientBundle;
+import com.google.gwt.resources.client.TextResource;
+
+public interface NotifyClientBundle extends ClientBundle {
+
+ static final NotifyClientBundle INSTANCE = GWT.create(NotifyClientBundle.class);
+
+ @Source("resource/js/bootstrap-notify-3.0.0.min.cache.js")
+ TextResource notifyJS();
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/notify/client/NotifyEntryPoint.java b/src/main/java/org/gwtbootstrap3/extras/notify/client/NotifyEntryPoint.java
new file mode 100644
index 00000000..64fc256b
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/notify/client/NotifyEntryPoint.java
@@ -0,0 +1,43 @@
+package org.gwtbootstrap3.extras.notify.client;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.core.client.ScriptInjector;
+
+public class NotifyEntryPoint implements EntryPoint {
+
+ @Override
+ public void onModuleLoad() {
+ if (!isNotifyLoaded()) {
+ ScriptInjector.fromString(NotifyClientBundle.INSTANCE.notifyJS().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
+ }
+ }
+
+ /**
+ * Check if notify is already loaded.
+ *
+ * @return true
if notify is loaded, false
otherwise
+ */
+ private native boolean isNotifyLoaded() /*-{
+ return ($wnd.jQuery && $wnd.jQuery.notify);
+ }-*/;
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/notify/client/constants/NotifyIconType.java b/src/main/java/org/gwtbootstrap3/extras/notify/client/constants/NotifyIconType.java
new file mode 100644
index 00000000..291bcb84
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/notify/client/constants/NotifyIconType.java
@@ -0,0 +1,51 @@
+package org.gwtbootstrap3.extras.notify.client.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import org.gwtbootstrap3.client.ui.constants.Type;
+
+/**
+ * Enumeration of Notify's icon types.
+ *
+ * @author Xiaodong SUN
+ */
+public enum NotifyIconType implements Type {
+
+ CLASS("class"),
+ IMAGE("img"),
+ ;
+
+ private final String type;
+
+ private NotifyIconType(final String type) {
+ this.type = type;
+ }
+
+ /**
+ * Returns the string representation of icon type.
+ *
+ * @return the string representation of icon type
+ */
+ public String getType() {
+ return type;
+ }
+
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/notify/client/constants/NotifyPlacement.java b/src/main/java/org/gwtbootstrap3/extras/notify/client/constants/NotifyPlacement.java
new file mode 100644
index 00000000..4994003b
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/notify/client/constants/NotifyPlacement.java
@@ -0,0 +1,74 @@
+package org.gwtbootstrap3.extras.notify.client.constants;
+
+import org.gwtbootstrap3.client.ui.constants.Type;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Enumeration of possible Notify's screen locations.
+ *
+ * @author Xiaodong SUN
+ */
+public enum NotifyPlacement implements Type {
+
+ TOP_LEFT("top", "left"),
+ TOP_CENTER("top", "center"),
+ TOP_RIGHT("top", "right"),
+ BOTTOM_LEFT("bottom", "left"),
+ BOTTOM_CENTER("bottom", "center"),
+ BOTTOM_RIGHT("bottom", "right");
+
+ private final String from;
+ private final String align;
+
+ private NotifyPlacement(final String from, final String align) {
+ this.from = from;
+ this.align = align;
+ }
+
+ /**
+ * Returns the vertical placement : top or bottom.
+ *
+ * @return the vertical placement
+ */
+ public String getFrom() {
+ return from;
+ }
+
+ /**
+ * Returns the horizontal placement : left, center, or right.
+ *
+ * @return the horizontal placement
+ */
+ public String getAlign() {
+ return align;
+ }
+
+ /**
+ * Returns the string representation of placement.
+ *
+ * @return String representation of placement
+ */
+ public String getPlacement() {
+ return getFrom() + "-" + getAlign();
+ }
+
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/notify/client/constants/NotifyPosition.java b/src/main/java/org/gwtbootstrap3/extras/notify/client/constants/NotifyPosition.java
new file mode 100644
index 00000000..e33465c0
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/notify/client/constants/NotifyPosition.java
@@ -0,0 +1,53 @@
+package org.gwtbootstrap3.extras.notify.client.constants;
+
+import org.gwtbootstrap3.client.ui.constants.Type;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Enumeration of possible Notify's position to the container element.
+ *
+ * @author Xiaodong SUN
+ */
+public enum NotifyPosition implements Type {
+
+ STATIC("static"),
+ FIXED("fixed"),
+ RELATIVE("relative"),
+ ABSOLUTE("absolute"),
+ ;
+
+ private final String position;
+
+ private NotifyPosition(final String position) {
+ this.position = position;
+ }
+
+ /**
+ * Returns the string representation of position.
+ *
+ * @return the string representation of position
+ */
+ public String getPosition() {
+ return position;
+ }
+
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/notify/client/constants/NotifyType.java b/src/main/java/org/gwtbootstrap3/extras/notify/client/constants/NotifyType.java
new file mode 100644
index 00000000..b0bd7513
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/notify/client/constants/NotifyType.java
@@ -0,0 +1,57 @@
+package org.gwtbootstrap3.extras.notify.client.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import org.gwtbootstrap3.client.ui.base.helper.EnumHelper;
+import org.gwtbootstrap3.client.ui.constants.Type;
+
+import com.google.gwt.dom.client.Style.HasCssName;
+
+/**
+ * Enumeration of Notify's types (CSS class names).
+ *
+ * Style name is appended after "alert-", so resulting CSS class name is "alert-[type]".
+ *
+ * @author Pavel Zlámal
+ */
+public enum NotifyType implements Type, HasCssName {
+
+ DANGER("danger"),
+ INFO("info"),
+ SUCCESS("success"),
+ WARNING("warning");
+
+ private final String cssClass;
+
+ private NotifyType(final String cssClass) {
+ this.cssClass = cssClass;
+ }
+
+ public static NotifyType fromStyleName(final String styleName) {
+ return EnumHelper.fromStyleName(styleName, NotifyType.class, INFO);
+ }
+
+ @Override
+ public String getCssName() {
+ return cssClass;
+ }
+
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/notify/client/constants/NotifyUrlTarget.java b/src/main/java/org/gwtbootstrap3/extras/notify/client/constants/NotifyUrlTarget.java
new file mode 100644
index 00000000..abf7b9d7
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/notify/client/constants/NotifyUrlTarget.java
@@ -0,0 +1,53 @@
+package org.gwtbootstrap3.extras.notify.client.constants;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import org.gwtbootstrap3.client.ui.constants.Type;
+
+/**
+ * Enumeration of Notify's URL target types.
+ *
+ * @author Xiaodong SUN
+ */
+public enum NotifyUrlTarget implements Type {
+
+ BLANK("_blank"),
+ SELF("_self"),
+ PARENT("_parent"),
+ TOP("_top"),
+ ;
+
+ private final String target;
+
+ private NotifyUrlTarget(final String target) {
+ this.target = target;
+ }
+
+ /**
+ * Returns the string representation of URL target.
+ *
+ * @return the string representation of URL target
+ */
+ public String getTarget() {
+ return target;
+ }
+
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/notify/client/event/NotifyCloseHandler.java b/src/main/java/org/gwtbootstrap3/extras/notify/client/event/NotifyCloseHandler.java
new file mode 100644
index 00000000..4d63e083
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/notify/client/event/NotifyCloseHandler.java
@@ -0,0 +1,40 @@
+package org.gwtbootstrap3.extras.notify.client.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Handler interface for Notify close events.
+ */
+public interface NotifyCloseHandler {
+
+ /**
+ * Called when Notify close event is fired.
+ */
+ void onClose();
+
+ /**
+ * Default Notify's close handler
+ */
+ static NotifyCloseHandler DEFAULT_CLOSE_HANDLER = new NotifyCloseHandler() {
+ @Override
+ public void onClose() {}
+ };
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/notify/client/event/NotifyClosedHandler.java b/src/main/java/org/gwtbootstrap3/extras/notify/client/event/NotifyClosedHandler.java
new file mode 100644
index 00000000..88a56aa5
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/notify/client/event/NotifyClosedHandler.java
@@ -0,0 +1,40 @@
+package org.gwtbootstrap3.extras.notify.client.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Handler interface for Notify closed events.
+ */
+public interface NotifyClosedHandler {
+
+ /**
+ * Called when Notify closed event is fired.
+ */
+ void onClosed();
+
+ /**
+ * Default Notify's closed handler
+ */
+ static NotifyClosedHandler DEFAULT_CLOSED_HANDLER = new NotifyClosedHandler() {
+ @Override
+ public void onClosed() {}
+ };
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/notify/client/event/NotifyShowHandler.java b/src/main/java/org/gwtbootstrap3/extras/notify/client/event/NotifyShowHandler.java
new file mode 100644
index 00000000..9b227523
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/notify/client/event/NotifyShowHandler.java
@@ -0,0 +1,40 @@
+package org.gwtbootstrap3.extras.notify.client.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Handler interface for Notify show events.
+ */
+public interface NotifyShowHandler {
+
+ /**
+ * Called when Notify show event is fired.
+ */
+ void onShow();
+
+ /**
+ * Default Notify's show handler
+ */
+ static NotifyShowHandler DEFAULT_SHOW_HANDLER = new NotifyShowHandler() {
+ @Override
+ public void onShow() {}
+ };
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/notify/client/event/NotifyShownHandler.java b/src/main/java/org/gwtbootstrap3/extras/notify/client/event/NotifyShownHandler.java
new file mode 100644
index 00000000..efed8833
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/notify/client/event/NotifyShownHandler.java
@@ -0,0 +1,40 @@
+package org.gwtbootstrap3.extras.notify.client.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Handler interface for Notify shown events.
+ */
+public interface NotifyShownHandler {
+
+ /**
+ * Called when Notify shown event is fired.
+ */
+ void onShown();
+
+ /**
+ * Default Notify's shown handler
+ */
+ static NotifyShownHandler DEFAULT_SHOWN_HANDLER = new NotifyShownHandler() {
+ @Override
+ public void onShown() {}
+ };
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/notify/client/ui/Notify.java b/src/main/java/org/gwtbootstrap3/extras/notify/client/ui/Notify.java
new file mode 100644
index 00000000..d1229360
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/notify/client/ui/Notify.java
@@ -0,0 +1,393 @@
+package org.gwtbootstrap3.extras.notify.client.ui;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import org.gwtbootstrap3.client.ui.constants.IconType;
+import org.gwtbootstrap3.client.ui.constants.Styles;
+import org.gwtbootstrap3.extras.notify.client.constants.NotifyPlacement;
+import org.gwtbootstrap3.extras.notify.client.constants.NotifyType;
+
+import com.google.gwt.core.client.JavaScriptObject;
+
+/**
+ * This class represent instance of displayed Notify.
+ *
+ * You can display new Notify using static methods, e.g.:
+ * {@link #notify(String)},
+ * {@link #notify(String, NotifyType)},
+ * {@link #notify(String, NotifySettings)} and others
+ *
+ * To further configure Notify before displaying see:
+ * {@see org.gwtbootstrap3.extras.notify.client.ui.NotifySettings}
+ *
+ * You can update displayed Notify by:
+ * {@link #updateTitle(String)},
+ * {@link #updateMessage(String)},
+ * {@link #updateIcon(String)},
+ * {@link #updateType(NotifyType)},
+ *
+ * You can hide displayed Notify:
+ * {@link #hide()},
+ * {@link #hideAll()},
+ * {@link #hideAll(NotifyPlacement)}
+ *
+ * @author jeffisenhart
+ * @author Sven Jacobs
+ * @author Joshua Godi
+ * @author Pavel Zlámal
+ */
+public class Notify extends JavaScriptObject {
+
+ protected Notify() {
+ }
+
+ /**
+ * Display Notify with custom message, and default settings.
+ *
+ * @param message Message to set
+ * @return Displayed Notify for update or hiding.
+ */
+ public static final native Notify notify(final String message) /*-{
+ return $wnd.jQuery.notify({ message: message }, null);
+ }-*/;
+
+ /**
+ * Display Notify with custom title, message, and default settings.
+ *
+ * @param title Title to set
+ * @param message Message to set
+ * @return Displayed Notify for update or hiding.
+ */
+ public static final native Notify notify(final String title, final String message) /*-{
+ return $wnd.jQuery.notify({ title: title, message: message }, null);
+ }-*/;
+
+ /**
+ * Display Notify with custom title, message, icon, and default settings.
+ *
+ * @param title Title to set
+ * @param message Message to set
+ * @param icon Icon to set
+ * @return Displayed Notify for update or hiding.
+ */
+ public static final native Notify notify(final String title, final String message, final String icon) /*-{
+ return $wnd.jQuery.notify({ title: title, message: message, icon: icon }, null);
+ }-*/;
+
+ /**
+ * Display Notify with custom title, message, icon, and default settings.
+ *
+ * @param title Title to set
+ * @param message Message to set
+ * @param iconType IconType to set
+ * @return Displayed Notify for update or hiding.
+ */
+ public static final Notify notify(final String title, final String message, final IconType iconType) {
+ return Notify.notify(title, message, Styles.FONT_AWESOME_BASE + " " + iconType.getCssName());
+ }
+
+ /**
+ * Display Notify with custom title, message, icon, URL, and default settings.
+ *
+ * @param title Title to set
+ * @param message Message to set
+ * @param icon IconType to set
+ * @param url Url to set
+ * @return Displayed Notify for update or hiding.
+ */
+ public static final native Notify notify(final String title, final String message, final String icon, final String url) /*-{
+ return $wnd.jQuery.notify({ title: title, message: message, icon: icon, url: url }, null);
+ }-*/;
+
+ /**
+ * Display Notify with custom title, message, icon, url and default settings.
+ *
+ * @param title Title to set
+ * @param message Message to set
+ * @param iconType IconType to set
+ * @param url Url to set
+ * @return Displayed Notify for update or hiding.
+ */
+ public static final Notify notify(final String title, final String message, final IconType iconType, final String url) {
+ return Notify.notify(title, message, Styles.FONT_AWESOME_BASE + " " + iconType.getCssName(), url);
+ }
+
+ /**
+ * Display Notify with custom message, type and default settings.
+ *
+ * @param message Message to set
+ * @param type NotifyType
+ * @return Displayed Notify for update or hiding.
+ * @see org.gwtbootstrap3.extras.notify.client.constants.NotifyType
+ */
+ public static final native Notify notify(final String message, final NotifyType type) /*-{
+ return $wnd.jQuery.notify({ message: message }, { type: type.@org.gwtbootstrap3.extras.notify.client.constants.NotifyType::getCssName()() });
+ }-*/;
+
+ /**
+ * Display Notify with custom title, message, type and default settings.
+ *
+ * @param title Title to set
+ * @param message Message to set
+ * @param type NotifyType
+ * @return Displayed Notify for update or hiding.
+ * @see org.gwtbootstrap3.extras.notify.client.constants.NotifyType
+ */
+ public static final native Notify notify(final String title, final String message, final NotifyType type) /*-{
+ return $wnd.jQuery.notify({ title: title, message: message }, { type: type.@org.gwtbootstrap3.extras.notify.client.constants.NotifyType::getCssName()() });
+ }-*/;
+
+ /**
+ * Display Notify with custom title, message, icon, type and default settings.
+ *
+ * @param title Title to set
+ * @param message Message to set
+ * @param icon Icon to set
+ * @param type NotifyType
+ * @return Displayed Notify for update or hiding.
+ * @see org.gwtbootstrap3.extras.notify.client.constants.NotifyType
+ */
+ public static final native Notify notify(final String title, final String message, final String icon, final NotifyType type) /*-{
+ return $wnd.jQuery.notify({ title: title, message: message, icon: icon }, { type: type.@org.gwtbootstrap3.extras.notify.client.constants.NotifyType::getCssName()() });
+ }-*/;
+
+ /**
+ * Display Notify with custom title, message, icon, type and default settings.
+ *
+ * @param title Title to set
+ * @param message Message to set
+ * @param iconType IconType to set (css name of icon form FONT AWESOME)
+ * @param type NotifyType
+ * @return Displayed Notify for update or hiding.
+ * @see org.gwtbootstrap3.extras.notify.client.constants.NotifyType
+ */
+ public static final Notify notify(final String title, final String message, final IconType iconType, final NotifyType type) {
+ return Notify.notify(title, message, Styles.FONT_AWESOME_BASE + " " + iconType.getCssName(), type);
+ }
+
+ /**
+ * Display Notify with custom title, message, icon, url, type and default settings.
+ *
+ * @param title Title to set
+ * @param message Message to set
+ * @param icon Icon to set
+ * @param url Url to set
+ * @param type NotifyType
+ * @return Displayed Notify for update or hiding.
+ * @see org.gwtbootstrap3.extras.notify.client.constants.NotifyType
+ */
+ public static final native Notify notify(final String title, final String message, final String icon, final String url, final NotifyType type) /*-{
+ return $wnd.jQuery.notify({ title: title, message: message, icon: icon, url: url }, { type: type.@org.gwtbootstrap3.extras.notify.client.constants.NotifyType::getCssName()() });
+ }-*/;
+
+ /**
+ * Display Notify with custom title, message, icon, url, type and default settings.
+ *
+ * @param title Title to set
+ * @param message Message to set
+ * @param iconType IconType to set (css name of icon form FONT AWESOME)
+ * @param url Url to set
+ * @param type NotifyType
+ * @return Displayed Notify for update or hiding.
+ * @see org.gwtbootstrap3.extras.notify.client.constants.NotifyType
+ */
+ public static final Notify notify(final String title, final String message, final IconType iconType, final String url, final NotifyType type) {
+ return Notify.notify(title, message, Styles.FONT_AWESOME_BASE + " " + iconType.getCssName(), url, type);
+ }
+
+ /**
+ * Display Notify with custom message and custom settings.
+ *
+ * @param message Message to set
+ * @param settings custom settings
+ * @return Displayed Notify for update or hiding.
+ * @see org.gwtbootstrap3.extras.notify.client.ui.NotifySettings
+ */
+ public static final native Notify notify(final String message, final NotifySettings settings) /*-{
+ return $wnd.jQuery.notify({ message: message }, settings);
+ }-*/;
+
+ /**
+ * Display Notify with custom title, message and custom settings.
+ *
+ * @param title Title to set
+ * @param message Message to set
+ * @param settings custom settings
+ * @return Displayed Notify for update or hiding.
+ * @see org.gwtbootstrap3.extras.notify.client.ui.NotifySettings
+ */
+ public static final native Notify notify(final String title, final String message, final NotifySettings settings) /*-{
+ return $wnd.jQuery.notify({ title: title, message: message }, settings);
+ }-*/;
+
+ /**
+ * Display Notify with custom title, message, icon and custom settings.
+ *
+ * @param title Title to set
+ * @param message Message to set
+ * @param icon Icon to set
+ * @param settings custom settings
+ * @return Displayed Notify for update or hiding.
+ * @see org.gwtbootstrap3.extras.notify.client.ui.NotifySettings
+ */
+ public static final native Notify notify(final String title, final String message, final String icon, final NotifySettings settings) /*-{
+ return $wnd.jQuery.notify({ title: title, message: message, icon: icon }, settings);
+ }-*/;
+
+ /**
+ * Display Notify with custom title, message, icon and custom settings.
+ *
+ * @param title Title to set
+ * @param message Message to set
+ * @param iconType IconType to set (css name of icon form FONT AWESOME)
+ * @param settings custom settings
+ * @return Displayed Notify for update or hiding.
+ * @see org.gwtbootstrap3.extras.notify.client.ui.NotifySettings
+ */
+ public static final Notify notify(final String title, final String message, final IconType iconType, final NotifySettings settings) {
+ return Notify.notify(title, message, Styles.FONT_AWESOME_BASE + " " + iconType.getCssName(), settings);
+ }
+
+ /**
+ * Display Notify with custom title, message, icon, URL and custom settings.
+ *
+ * @param title Title to set
+ * @param message Message to set
+ * @param icon Icon to set
+ * @param url Url to set
+ * @param settings custom settings
+ * @return Displayed Notify for update or hiding.
+ * @see org.gwtbootstrap3.extras.notify.client.ui.NotifySettings
+ */
+ public static final native Notify notify(final String title, final String message, final String icon, final String url, final NotifySettings settings) /*-{
+ return $wnd.jQuery.notify({ title: title, message: message, icon: icon, url: url}, settings);
+ }-*/;
+
+ /**
+ * Display Notify with custom title, message, icon, URL and custom settings.
+ *
+ * @param title Title to set
+ * @param message Message to set
+ * @param iconType IconType to set
+ * @param url Url to set
+ * @param settings custom settings
+ * @return Displayed Notify for update or hiding.
+ * @see org.gwtbootstrap3.extras.notify.client.ui.NotifySettings
+ */
+ public static final Notify notify(final String title, final String message, final IconType iconType, final String url, final NotifySettings settings) {
+ return Notify.notify(title, message, Styles.FONT_AWESOME_BASE + " " + iconType.getCssName(), url, settings);
+ }
+
+ /**
+ * Hide all displayed Notifies.
+ */
+ public static final native void hideAll() /*-{
+ $wnd.jQuery.notifyClose();
+ }-*/;
+
+ /**
+ * Hide all displayed Notifies on specific screen location.
+ *
+ * @param placement Notify's placement on screen.
+ * @see org.gwtbootstrap3.extras.notify.client.constants.NotifyPlacement
+ */
+ public static final native void hideAll(NotifyPlacement placement) /*-{
+ if (plamenet !== null) {
+ $wnd.jQuery.notifyClose(placement.@org.gwtbootstrap3.extras.notify.client.constants.NotifyPlacement::getPlacement()());
+ }
+ }-*/;
+
+ /**
+ * Updates title parameter of once displayed Notify.
+ *
+ * @param title Title to set
+ */
+ public final native void updateTitle(String title) /*-{
+ this.update('title', title);
+ }-*/;
+
+ /**
+ * Updates message parameter of once displayed Notify.
+ *
+ * @param message Message to set
+ */
+ public final native void updateMessage(String message) /*-{
+ this.update('message', message);
+ }-*/;
+
+ /**
+ * Updates Icon parameter of once displayed Notify.
+ *
+ * @param icon Icon to set
+ */
+ public final native void updateIcon(String icon) /*-{
+ this.update('icon', icon);
+ }-*/;
+
+ /**
+ * Updates Icon parameter of once displayed Notify.
+ * This method is shortcut when using FONT AWESOME iconic font.
+ *
+ * @param type IconType to get CSS class name to set
+ */
+ public final void updateIcon(final IconType type) {
+ if (type != null) updateIcon(Styles.FONT_AWESOME_BASE + " " + type.getCssName());
+ }
+
+ /**
+ * Update type of once displayed Notify (CSS style class name).
+ *
+ * @param type one of INFO, WARNING, DANGER, SUCCESS
+ * @see org.gwtbootstrap3.extras.notify.client.constants.NotifyType
+ */
+ public final void updateType(final NotifyType type) {
+ if (type != null) {
+ updateType(type.getCssName());
+ }
+ }
+
+ /**
+ * Update type of once displayed Notify (CSS style class name).
+ * Resulting class name to use is "alert-[type]".
+ *
+ * @param type CSS class name to set
+ */
+ private final native void updateType(String type) /*-{
+ this.update('type', type);
+ }-*/;
+
+ /**
+ * Update URL target of once displayed Notify.
+ *
+ * @param target URL target to set
+ */
+ private final native void updateTarget(String target) /*-{
+ this.update('target', target);
+ }-*/;
+
+ /**
+ * Hide this Notify.
+ */
+ public final native void hide() /*-{
+ this.close();
+ }-*/;
+
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/notify/client/ui/NotifySettings.java b/src/main/java/org/gwtbootstrap3/extras/notify/client/ui/NotifySettings.java
new file mode 100644
index 00000000..21bd6452
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/notify/client/ui/NotifySettings.java
@@ -0,0 +1,396 @@
+package org.gwtbootstrap3.extras.notify.client.ui;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import org.gwtbootstrap3.extras.animate.client.ui.constants.Animation;
+import org.gwtbootstrap3.extras.notify.client.constants.NotifyIconType;
+import org.gwtbootstrap3.extras.notify.client.constants.NotifyPlacement;
+import org.gwtbootstrap3.extras.notify.client.constants.NotifyPosition;
+import org.gwtbootstrap3.extras.notify.client.constants.NotifyType;
+import org.gwtbootstrap3.extras.notify.client.constants.NotifyUrlTarget;
+import org.gwtbootstrap3.extras.notify.client.event.NotifyCloseHandler;
+import org.gwtbootstrap3.extras.notify.client.event.NotifyClosedHandler;
+import org.gwtbootstrap3.extras.notify.client.event.NotifyShowHandler;
+import org.gwtbootstrap3.extras.notify.client.event.NotifyShownHandler;
+
+import com.google.gwt.core.client.JavaScriptObject;
+
+/**
+ * This class represent basic Notify's settings, that you can use to customize display of each Notify.
+ *
+ * You can also set current state as default for all new Notifies.
+ *
+ * @author jeffisenhart
+ * @author Sven Jacobs
+ * @author Joshua Godi
+ * @author Pavel Zlámal
+ * @author Xiaodong SUN
+ * @see #makeDefault()
+ */
+public class NotifySettings extends JavaScriptObject {
+
+ /**
+ * Default constructor
+ */
+ protected NotifySettings() {}
+
+ /**
+ * Creates a new instance of {@link NotifySettings}.
+ *
+ * @return a new instance of {@link NotifySettings}.
+ */
+ public static NotifySettings newSettings() {
+ return JavaScriptObject.createObject().cast();
+ }
+
+ /**
+ * Set element name or class or ID to append Notify to. Default is 'body'.
+ *
+ * @param element Name, class or ID
+ */
+ public final native void setElement(String element) /*-{
+ this.element = element;
+ }-*/;
+
+ /**
+ * Set custom position to the Notify container element. Default is null.
+ *
+ * @param position one of STATIC, FIXED, RELATIVE, ABSOLUTE, or null
+ */
+ public final void setPosition(final NotifyPosition position) {
+ setPosition((position != null) ? position.getPosition() : null);
+ }
+
+ /**
+ * Set native property of Notify's position.
+ *
+ * @param position Notify's position to the container element
+ */
+ private final native void setPosition(String position) /*-{
+ this.position = position;
+ }-*/;
+
+ /**
+ * Set type of Notify (CSS style class name). Default is INFO.
+ *
+ * @param type one of INFO, WARNING, DANGER, SUCCESS
+ * @see NotifyType
+ */
+ public final void setType(final NotifyType type) {
+ setType((type != null) ? type.getCssName() : NotifyType.INFO.getCssName());
+ }
+
+ /**
+ * Set custom style name to Notify. Resulting class name is "alert-[customType]".
+ *
+ * @param customType Style name to set
+ */
+ public final native void setType(String customType) /*-{
+ this.type = customType;
+ }-*/;
+
+ /**
+ * Set placement of Notify on screen. Default placement is {@link NotifyPlacement#TOP_RIGHT}.
+ *
+ * @param placement Notify's placement on screen
+ * @see NotifyPlacement
+ */
+ public final void setPlacement(final NotifyPlacement placement) {
+ setNotifyPlacement((placement != null) ? placement : NotifyPlacement.TOP_RIGHT);
+ }
+
+ /**
+ * If false
, the data-notify="dismiss"
element in
+ * the template will be hidden. Default is true
.
+ *
+ * @param allowDismiss if false
, the close icon will be hidden
+ */
+ public final native void setAllowDismiss(boolean allowDismiss) /*-{
+ this.allow_dismiss = allowDismiss;
+ }-*/;
+
+ /**
+ * If true
, newer notifications push down older ones. Default
+ * is false
.
+ *
+ * WARNING: Be careful when setting
+ * newestOnTop
to true
when a placement that
+ * already contains a notification has newest_on_top
to
+ * false
. It may cause issues with the plug-ins ability to
+ * place the notification in the correct location.
+ *
+ * @param newestOnTop if true
, newer notifications push down older ones
+ * @since 3.0.0
+ */
+ public final native void setNewestOnTop(boolean newestOnTop) /*-{
+ this.newest_on_top = newestOnTop;
+ }-*/;
+
+ /**
+ * Set native property of Notify's placement.
+ *
+ * @param placement Notify's placement on screen
+ */
+ private final native void setNotifyPlacement(final NotifyPlacement placement) /*-{
+ var from = placement.@org.gwtbootstrap3.extras.notify.client.constants.NotifyPlacement::getFrom()();
+ var align = placement.@org.gwtbootstrap3.extras.notify.client.constants.NotifyPlacement::getAlign()();
+ this.placement = { from: from, align: align };
+ }-*/;
+
+ /**
+ * Set offset (space between Notify and screen/browser edges) for each axis. Default is 20 PX for both.
+ *
+ * @param offX Offset for X axis in PX
+ * @param offY Offset for Y axis in PX
+ */
+ public final native void setOffset(int offX, int offY) /*-{
+ this.offset = { x: offX, y: offY };
+ }-*/;
+
+ /**
+ * Set custom spacing between two Notifies. Default is 10 PX.
+ *
+ * @param space Spacing in PX
+ */
+ public final native void setSpacing(int space) /*-{
+ this.spacing = space;
+ }-*/;
+
+ /**
+ * Set custom Z-index. Default is 1031.
+ *
+ * @param zIndex Z-index
+ */
+ public final native void setZIndex(int zIndex) /*-{
+ this.z_index = zIndex;
+ }-*/;
+
+ /**
+ * Set delay, how long Notify stays on screen. Default is 5000 ms.
+ * Set to zero for unlimited time.
+ *
+ * @param mDelay Delay in milliseconds or zero for unlimited
+ */
+ public final native void setDelay(int mDelay) /*-{
+ this.delay = mDelay;
+ }-*/;
+
+ /**
+ * Set timer. It's value is removed from remaining 'delay' on each 'timer' period.
+ * This way you can speed up hiding of Notify. If timer > remaining delay, Notify is
+ * hidden after delay runs out (ignoring timer).
+ *
+ * @param timer Time in milliseconds
+ * @see #setDelay(int)
+ */
+ public final native void setTimer(int timer) /*-{
+ this.timer = timer;
+ }-*/;
+
+ /**
+ * Set custom URL target.
+ *
+ * Defaults to {@link NotifyUrlTarget#BLANK}.
+ *
+ * @param urlTarget URL target
+ */
+ public final void setUrlTarget(NotifyUrlTarget urlTarget) {
+ setUrlTarget((urlTarget != null) ? urlTarget.getTarget() : NotifyUrlTarget.BLANK.getTarget());
+ }
+
+ /**
+ * Set custom URL target. Default is "_blank".
+ *
+ * See http://www.w3schools.com/tags/att_a_target.asp for possible values.
+ *
+ * @param customUrlTarget URL target
+ */
+ public final native void setUrlTarget(String customUrlTarget) /*-{
+ this.url_target = customUrlTarget;
+ }-*/;
+
+ /**
+ * Pause countdown of display timeout when mouse is hovering above the Notify.
+ * Countdown continues (not restarted) if mouse leaves the Notify.
+ *
+ * @param pauseOnMouseOver TRUE = pause / FALSE = not pause
+ */
+ public final native void setPauseOnMouseOver(boolean pauseOnMouseOver) /*-{
+ this.mouse_over = pauseOnMouseOver ? 'pause' : null;
+ }-*/;
+
+ /**
+ * Set Animation to Notify when it enters and exit the screen.
+ *
+ * Default is enter = Animation.FADE_IN_DOWN, exit = Animation.FADE_OUT_UP
+ *
+ * @see org.gwtbootstrap3.extras.animate.client.ui.constants.Animation
+ *
+ * @param enter animation style when Notify enters the screen
+ * @param exit animation style when Notify exists the screen
+ */
+ public final void setAnimation(Animation enter, Animation exit) {
+ setAnimation((enter != null) ? enter.getCssName() : Animation.NO_ANIMATION.getCssName(),
+ (exit != null) ? exit.getCssName() : Animation.NO_ANIMATION.getCssName());
+ }
+
+ /**
+ * Set custom CSS style for animations of Notify when it enters and exits the screen.
+ * You must write your own CSS animation definition.
+ *
+ * @param enter animation style when Notify enters the screen
+ * @param exit animation style when Notify exists the screen
+ */
+ public final native void setAnimation(String enter, String exit) /*-{
+ this.animate = { enter: enter, exit: exit };
+ }-*/;
+
+ /**
+ * Set the Notify's show event handler. The show event fires immediately when
+ * the show instance method is called.
+ *
+ * @param handler
+ */
+ public final void setShowHandler(final NotifyShowHandler handler) {
+ onShow((handler != null) ? handler : NotifyShowHandler.DEFAULT_SHOW_HANDLER);
+ }
+
+ private final native void onShow(NotifyShowHandler handler) /*-{
+ this.onShow = function() {
+ handler.@org.gwtbootstrap3.extras.notify.client.event.NotifyShowHandler::onShow()();
+ };
+ }-*/;
+
+ /**
+ * Set the Notify's shown event handler. This event is fired when the modal has
+ * been made visible to the user (will wait for CSS transitions to complete).
+ *
+ * @param handler
+ */
+ public final void setShownHandler(final NotifyShownHandler handler) {
+ onShown((handler != null) ? handler : NotifyShownHandler.DEFAULT_SHOWN_HANDLER);
+ }
+
+ private final native void onShown(NotifyShownHandler handler) /*-{
+ this.onShow = function() {
+ handler.@org.gwtbootstrap3.extras.notify.client.event.NotifyShownHandler::onShown()();
+ };
+ }-*/;
+
+ /**
+ * Set the Notify's close event handler. This event is fired immediately when
+ * the notification is closing.
+ *
+ * @param handler
+ */
+ public final void setCloseHandler(final NotifyCloseHandler handler) {
+ onClose((handler != null) ? handler : NotifyCloseHandler.DEFAULT_CLOSE_HANDLER);
+ }
+
+ private final native void onClose(NotifyCloseHandler handler) /*-{
+ this.onClose = function() {
+ handler.@org.gwtbootstrap3.extras.notify.client.event.NotifyCloseHandler::onClose()();
+ };
+ }-*/;
+
+ /**
+ * Set the Notify's closed event handler. This event is fired when the modal
+ * has finished closing and is removed from the document (will wait for CSS
+ * transitions to complete).
+ *
+ * @param handler
+ */
+ public final void setClosedHandler(final NotifyClosedHandler handler) {
+ onClosed((handler != null) ? handler : NotifyClosedHandler.DEFAULT_CLOSED_HANDLER);
+ }
+
+ private final native void onClosed(NotifyClosedHandler handler) /*-{
+ this.onClosed = function() {
+ handler.@org.gwtbootstrap3.extras.notify.client.event.NotifyClosedHandler::onClosed()();
+ };
+ }-*/;
+
+ /**
+ * Set icon type you will use for Notify. Default is 'class', which
+ * allows to use iconic fonts like FontAwesome.
+ * If you want to use images instead of class, set value to "image".
+ *
+ * Defaults to {@link NotifyIconType#CLASS}.
+ *
+ * @param iconType the icon type
+ * @see NotifyIconType
+ */
+ public final void setIconType(NotifyIconType iconType) {
+ setIconType((iconType != null) ? iconType.getType() : NotifyIconType.CLASS.getType());
+ }
+
+ /**
+ * Set native property of Notify's icon type.
+ *
+ * @param iconType Notify's icon type.
+ */
+ private final native void setIconType(String iconType) /*-{
+ this.icon_type = iconType;
+ }-*/;
+
+ /**
+ * Set custom HTML Template of Notify. Default value is:
+ *
+ *
+ * <div data-notify="container" class="col-xs-11 col-sm-3 alert alert-{0}" role="alert">
+ * <button type="button" aria-hidden="true" class="close" data-notify="dismiss">x</button>
+ * <span data-notify="icon"></span>
+ * <span data-notify="title">{1}</span>
+ * <span data-notify="message">{2}</span>
+ * <div class="progress" data-notify="progressbar">
+ * <div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>
+ * </div>
+ * <a href="{3}" target="{4}" data-notify="url"></a>
+ * </div>
+ *
+ *
+ * Where:
+ *
+ * - {0} = type
+ * - {1} = title
+ * - {2} = message
+ * - {3} = url
+ * - {4} = target
+ *
+ *
+ * @param html Custom HTML template
+ * @see documentation at: http://bootstrap-notify.remabledesigns.com/
+ */
+ public final native void setTemplate(String html) /*-{
+ this.template = html;
+ }-*/;
+
+ /**
+ * Make this NotifySettings as default for all new Notifies.
+ *
+ * Values set to this NotifySettings overrides original default values.
+ * If value for some property is not set, original default value is kept.
+ */
+ public final native void makeDefault() /*-{
+ $wnd.jQuery.notifyDefaults();
+ }-*/;
+
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/select/client/SelectClientBundle.java b/src/main/java/org/gwtbootstrap3/extras/select/client/SelectClientBundle.java
index 745dcb8a..03d6e6cc 100644
--- a/src/main/java/org/gwtbootstrap3/extras/select/client/SelectClientBundle.java
+++ b/src/main/java/org/gwtbootstrap3/extras/select/client/SelectClientBundle.java
@@ -31,48 +31,63 @@ public interface SelectClientBundle extends ClientBundle {
static final SelectClientBundle INSTANCE = GWT.create(SelectClientBundle.class);
- @Source("resource/js/bootstrap-select-1.6.3.min.cache.js")
+ @Source("resource/js/bootstrap-select-1.6.4.min.cache.js")
TextResource selectJs();
- @Source("resource/js/locales.cache.1.6.3/defaults-cs_CZ.min.js")
+ @Source("resource/js/locales.cache.1.6.4/defaults-cs_CZ.min.js")
TextResource cs();
- @Source("resource/js/locales.cache.1.6.3/defaults-de_DE.min.js")
+ @Source("resource/js/locales.cache.1.6.4/defaults-de_DE.min.js")
TextResource de();
- @Source("resource/js/locales.cache.1.6.3/defaults-en_US.min.js")
+ @Source("resource/js/locales.cache.1.6.4/defaults-en_US.min.js")
TextResource en();
- @Source("resource/js/locales.cache.1.6.3/defaults-es_CL.min.js")
+ @Source("resource/js/locales.cache.1.6.4/defaults-es_CL.min.js")
TextResource es();
- @Source("resource/js/locales.cache.1.6.3/defaults-eu.min.js")
+ @Source("resource/js/locales.cache.1.6.4/defaults-eu.min.js")
TextResource eu();
- @Source("resource/js/locales.cache.1.6.3/defaults-fr_FR.min.js")
+ @Source("resource/js/locales.cache.1.6.4/defaults-fr_FR.min.js")
TextResource fr();
- @Source("resource/js/locales.cache.1.6.3/defaults-it_IT.min.js")
+ @Source("resource/js/locales.cache.1.6.4/defaults-hu_HU.min.js")
+ TextResource hu();
+
+ @Source("resource/js/locales.cache.1.6.4/defaults-it_IT.min.js")
TextResource it();
- @Source("resource/js/locales.cache.1.6.3/defaults-nl_NL.min.js")
+ @Source("resource/js/locales.cache.1.6.4/defaults-nl_NL.min.js")
TextResource nl();
- @Source("resource/js/locales.cache.1.6.3/defaults-pl_PL.min.js")
+ @Source("resource/js/locales.cache.1.6.4/defaults-pl_PL.min.js")
TextResource pl();
- @Source("resource/js/locales.cache.1.6.3/defaults-pt_BR.min.js")
+ @Source("resource/js/locales.cache.1.6.4/defaults-pt_BR.min.js")
TextResource pt_BR();
- @Source("resource/js/locales.cache.1.6.3/defaults-ro_RO.min.js")
+ @Source("resource/js/locales.cache.1.6.4/defaults-ro_RO.min.js")
TextResource ro();
- @Source("resource/js/locales.cache.1.6.3/defaults-ua_UA.min.js")
+ @Source("resource/js/locales.cache.1.6.4/defaults-ru_RU.min.js")
+ TextResource ru();
+
+ @Source("resource/js/locales.cache.1.6.4/defaults-sl_SI.min.js")
+ TextResource sl();
+
+ @Source("resource/js/locales.cache.1.6.4/defaults-sv_SE.min.js")
+ TextResource sv();
+
+ @Source("resource/js/locales.cache.1.6.4/defaults-tr_TR.min.js")
+ TextResource tr();
+
+ @Source("resource/js/locales.cache.1.6.4/defaults-ua_UA.min.js")
TextResource ua();
- @Source("resource/js/locales.cache.1.6.3/defaults-zh_CN.min.js")
+ @Source("resource/js/locales.cache.1.6.4/defaults-zh_CN.min.js")
TextResource zh_CN();
- @Source("resource/js/locales.cache.1.6.3/defaults-zh_TW.min.js")
+ @Source("resource/js/locales.cache.1.6.4/defaults-zh_TW.min.js")
TextResource zh_TW();
}
diff --git a/src/main/java/org/gwtbootstrap3/extras/select/client/SelectEntryPoint.java b/src/main/java/org/gwtbootstrap3/extras/select/client/SelectEntryPoint.java
index b68bc23b..f22773b0 100644
--- a/src/main/java/org/gwtbootstrap3/extras/select/client/SelectEntryPoint.java
+++ b/src/main/java/org/gwtbootstrap3/extras/select/client/SelectEntryPoint.java
@@ -30,7 +30,6 @@ public class SelectEntryPoint implements EntryPoint {
@Override
public void onModuleLoad() {
- ScriptInjector.fromString(SelectClientBundle.INSTANCE.selectJs().getText()).setWindow(ScriptInjector.TOP_WINDOW)
- .inject();
+ ScriptInjector.fromString(SelectClientBundle.INSTANCE.selectJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
}
}
diff --git a/src/main/java/org/gwtbootstrap3/extras/select/client/constants/SelectLanguage.java b/src/main/java/org/gwtbootstrap3/extras/select/client/constants/SelectLanguage.java
index 8ce1b585..c8f448e3 100644
--- a/src/main/java/org/gwtbootstrap3/extras/select/client/constants/SelectLanguage.java
+++ b/src/main/java/org/gwtbootstrap3/extras/select/client/constants/SelectLanguage.java
@@ -30,11 +30,16 @@ public enum SelectLanguage {
ES("es", SelectClientBundle.INSTANCE.es()),
EU("eu", SelectClientBundle.INSTANCE.eu()),
FR("fr", SelectClientBundle.INSTANCE.fr()),
+ HU("hu", SelectClientBundle.INSTANCE.hu()),
IT("it", SelectClientBundle.INSTANCE.it()),
NL("nl", SelectClientBundle.INSTANCE.nl()),
PL("pl", SelectClientBundle.INSTANCE.pl()),
PT_BR("pt-BR", SelectClientBundle.INSTANCE.pt_BR()),
RO("ro", SelectClientBundle.INSTANCE.ro()),
+ RU("ru", SelectClientBundle.INSTANCE.ru()),
+ SL("sl", SelectClientBundle.INSTANCE.sl()),
+ SV("sv", SelectClientBundle.INSTANCE.sv()),
+ TR("tr", SelectClientBundle.INSTANCE.tr()),
UA("ua", SelectClientBundle.INSTANCE.ua()),
ZH_CN("zh-CN", SelectClientBundle.INSTANCE.zh_CN()),
ZH_TW("zh-TW", SelectClientBundle.INSTANCE.zh_TW()),
diff --git a/src/main/java/org/gwtbootstrap3/extras/select/client/ui/Select.java b/src/main/java/org/gwtbootstrap3/extras/select/client/ui/Select.java
index 8d0048e1..1cf9dc98 100644
--- a/src/main/java/org/gwtbootstrap3/extras/select/client/ui/Select.java
+++ b/src/main/java/org/gwtbootstrap3/extras/select/client/ui/Select.java
@@ -327,7 +327,8 @@ public void setValues(final Option... opts) {
* and {@link #getValue(int)} for getting all the values selected or {@link #getAllSelectedValues()}
*/
public String getValue() {
- return getSelectElement().getOptions().getItem(getSelectElement().getSelectedIndex()).getValue();
+ int selectedIndex = getSelectElement().getSelectedIndex();
+ return selectedIndex == -1 ? null : getSelectElement().getOptions().getItem(selectedIndex).getValue();
}
public List getAllSelectedValues() {
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/SliderClientBundle.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/SliderClientBundle.java
index 4b66588e..e8217ba4 100644
--- a/src/main/java/org/gwtbootstrap3/extras/slider/client/SliderClientBundle.java
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/SliderClientBundle.java
@@ -4,7 +4,7 @@
* #%L
* GwtBootstrap3
* %%
- * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,15 +25,12 @@
import com.google.gwt.resources.client.TextResource;
/**
- * @author Sven Jacobs
+ * @author Xiaodong SUN
*/
interface SliderClientBundle extends ClientBundle {
static final SliderClientBundle INSTANCE = GWT.create(SliderClientBundle.class);
- @Source("resource/js/bootstrap-slider-1.4.3.min.cache.js")
+ @Source("resource/js/bootstrap-slider-4.5.6.min.cache.js")
TextResource slider();
-
- @Source("resource/js/modernizr-touch-2.7.1.cache.js")
- TextResource modernizr();
}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/SliderEntryPoint.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/SliderEntryPoint.java
index e0de3e82..06e840e3 100644
--- a/src/main/java/org/gwtbootstrap3/extras/slider/client/SliderEntryPoint.java
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/SliderEntryPoint.java
@@ -4,7 +4,7 @@
* #%L
* GwtBootstrap3
* %%
- * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,14 +24,23 @@
import com.google.gwt.core.client.ScriptInjector;
/**
- * @author Sven Jacobs
+ * @author Xiaodong SUN
*/
public class SliderEntryPoint implements EntryPoint {
@Override
public void onModuleLoad() {
- ScriptInjector.fromString(SliderClientBundle.INSTANCE.slider().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
- ScriptInjector.fromString(SliderClientBundle.INSTANCE.modernizr().getText()).setWindow(ScriptInjector.TOP_WINDOW)
- .inject();
+ if (!isSliderLoaded()) {
+ ScriptInjector.fromString(SliderClientBundle.INSTANCE.slider().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
+ }
}
+
+ /**
+ * Check if slider is already loaded.
+ *
+ * @return true
if slider is loaded, false
otherwise
+ */
+ private native boolean isSliderLoaded() /*-{
+ return (typeof $wnd['Slider'] !== 'undefined');
+ }-*/;
}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/Range.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/Range.java
new file mode 100644
index 00000000..84fc278d
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/Range.java
@@ -0,0 +1,113 @@
+package org.gwtbootstrap3.extras.slider.client.ui;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.core.client.JsArrayNumber;
+import com.google.gwt.core.client.JsonUtils;
+
+/**
+ * Slider range with a min value and a max value.
+ */
+public class Range {
+
+ private double minValue;
+ private double maxValue;
+
+ protected Range() {
+ }
+
+ /**
+ * Create a slider range with a min value and a max value.
+ *
+ * @param minValue
+ * @param maxValue
+ */
+ public Range(final double minValue, final double maxValue) {
+ this.minValue = minValue;
+ this.maxValue = maxValue;
+ }
+
+ /**
+ * Creates a slider range with a JavaScritp number array.
+ *
+ * This constructor is useful in JSNI calls.
+ *
+ * @param array
+ */
+ public Range(final JsArrayNumber array) {
+ this(array.get(0), array.get(1));
+ }
+
+ /**
+ * Returns the min value.
+ *
+ * @return the min value
+ */
+ public double getMinValue() {
+ return minValue;
+ }
+
+ /**
+ * Returns the max value.
+ *
+ * @return the max value
+ */
+ public double getMaxValue() {
+ return maxValue;
+ }
+
+ /**
+ * Converts the range to a JavaScript number array.
+ *
+ * @return a JavaScript number array
+ */
+ public JsArrayNumber toJsArray() {
+ JsArrayNumber array = JavaScriptObject.createArray().cast();
+ array.push(minValue);
+ array.push(maxValue);
+ return array;
+ }
+
+ /**
+ * Converts the given string to a range instance.
+ *
+ * Useful when using UiBinder.
+ *
+ * @param value
+ * @return
+ */
+ public static Range fromString(String value) {
+ if (value == null || value.isEmpty())
+ return null;
+ JsArrayNumber array = JsonUtils.safeEval(value);
+ return new Range(array);
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder("[")
+ .append(getMinValue()).append(", ")
+ .append(getMaxValue())
+ .append("]").toString();
+ }
+
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/RangeSlider.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/RangeSlider.java
new file mode 100644
index 00000000..0f3b25e3
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/RangeSlider.java
@@ -0,0 +1,112 @@
+package org.gwtbootstrap3.extras.slider.client.ui;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import org.gwtbootstrap3.extras.slider.client.ui.base.SliderBase;
+
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.uibinder.client.UiConstructor;
+import com.google.gwt.user.client.Event;
+
+/**
+ * This slider takes as value a range with a min value and a max value.
+ *
+ * @author Xiaodong SUN
+ */
+public class RangeSlider extends SliderBase {
+
+ /**
+ * Creates a range slider.
+ */
+ public RangeSlider() {
+ setRange(true);
+ }
+
+ /**
+ * Creates a range slider with min, max, and range value.
+ *
+ * @param min
+ * @param max
+ * @param range
+ */
+ public RangeSlider(final double min, final double max, final Range range) {
+ this();
+ setMin(min);
+ setMax(max);
+ setValue(range);
+ }
+
+ /**
+ * Creates a range slider with min, max, and range value.
+ *
+ * Useful for UiBinder.
+ *
+ * @param min
+ * @param max
+ * @param value
+ */
+ @UiConstructor
+ public RangeSlider(final double min, final double max, final String value) {
+ this(min, max, Range.fromString(value));
+ }
+
+ @Override
+ protected native void setValue(Element e, Range value) /*-{
+ var range = value.@org.gwtbootstrap3.extras.slider.client.ui.Range::toJsArray()();
+ $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::SET_VALUE, range);
+ }-*/;
+
+ @Override
+ protected native Range getValue(Element e) /*-{
+ var range = $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::GET_VALUE);
+ return @org.gwtbootstrap3.extras.slider.client.ui.Range::new(Lcom/google/gwt/core/client/JsArrayNumber;)(range);
+ }-*/;
+
+ @Override
+ protected Range convertValue(String value) {
+ return Range.fromString(value);
+ }
+
+ @Override
+ protected native void onSlide(Event event) /*-{
+ var range = @org.gwtbootstrap3.extras.slider.client.ui.Range::new(Lcom/google/gwt/core/client/JsArrayNumber;)(event.value);
+ this.@org.gwtbootstrap3.extras.slider.client.ui.RangeSlider::fireSlideEvent(Lorg/gwtbootstrap3/extras/slider/client/ui/Range;)(range);
+ }-*/;
+
+ @Override
+ protected native void onSlideStart(Event event) /*-{
+ var range = @org.gwtbootstrap3.extras.slider.client.ui.Range::new(Lcom/google/gwt/core/client/JsArrayNumber;)(event.value);
+ this.@org.gwtbootstrap3.extras.slider.client.ui.RangeSlider::fireSlideStartEvent(Lorg/gwtbootstrap3/extras/slider/client/ui/Range;)(range);
+ }-*/;
+
+ @Override
+ protected native void onSlideStop(Event event) /*-{
+ var range = @org.gwtbootstrap3.extras.slider.client.ui.Range::new(Lcom/google/gwt/core/client/JsArrayNumber;)(event.value);
+ this.@org.gwtbootstrap3.extras.slider.client.ui.RangeSlider::fireSlideStopEvent(Lorg/gwtbootstrap3/extras/slider/client/ui/Range;)(range);
+ }-*/;
+
+ @Override
+ protected native void onSlideChange(Event event) /*-{
+ var range = @org.gwtbootstrap3.extras.slider.client.ui.Range::new(Lcom/google/gwt/core/client/JsArrayNumber;)(event.value.newValue);
+ this.@org.gwtbootstrap3.extras.slider.client.ui.RangeSlider::fireChangeEvent(Lorg/gwtbootstrap3/extras/slider/client/ui/Range;)(range);
+ }-*/;
+
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/Slider.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/Slider.java
index 122c862e..cafbcf33 100644
--- a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/Slider.java
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/Slider.java
@@ -4,7 +4,7 @@
* #%L
* GwtBootstrap3
* %%
- * Copyright (C) 2013 GwtBootstrap3
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,23 +22,80 @@
import org.gwtbootstrap3.extras.slider.client.ui.base.SliderBase;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.uibinder.client.UiConstructor;
+import com.google.gwt.user.client.Event;
+
/**
- * @author Grant Slender
+ * This slider simply takes a numeric value.
+ *
+ * @author Xiaodong SUN
*/
-public class Slider extends SliderBase {
+public class Slider extends SliderBase {
+ /**
+ * Creates a numerical slider.
+ */
public Slider() {
- super();
+ setRange(false);
}
+ /**
+ * Creates a numerical slider with min, max, and value.
+ *
+ * @param min
+ * @param max
+ * @param value
+ */
+ @UiConstructor
public Slider(final double min, final double max, final double value) {
- super();
+ this();
setMin(min);
setMax(max);
setValue(value);
}
- public Slider(final int min, final int max, final int value) {
- this((double) min, (double) max, (double) value);
+ @Override
+ protected native void setValue(Element e, Double value) /*-{
+ var doubleValue = value.@java.lang.Double::doubleValue()();
+ $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::SET_VALUE, doubleValue);
+ }-*/;
+
+ @Override
+ protected native Double getValue(Element e) /*-{
+ var value = $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::GET_VALUE);
+ return @java.lang.Double::new(D)(value);
+ }-*/;
+
+ @Override
+ protected Double convertValue(String value) {
+ if (value == null || value.isEmpty())
+ return null;
+ return Double.valueOf(value);
}
+
+ @Override
+ protected native void onSlide(Event event) /*-{
+ var value = @java.lang.Double::new(D)(event.value);
+ this.@org.gwtbootstrap3.extras.slider.client.ui.Slider::fireSlideEvent(Ljava/lang/Double;)(value);
+ }-*/;
+
+ @Override
+ protected native void onSlideStart(Event event) /*-{
+ var value = @java.lang.Double::new(D)(event.value);
+ this.@org.gwtbootstrap3.extras.slider.client.ui.Slider::fireSlideStartEvent(Ljava/lang/Double;)(value);
+ }-*/;
+
+ @Override
+ protected native void onSlideStop(Event event) /*-{
+ var value = @java.lang.Double::new(D)(event.value);
+ this.@org.gwtbootstrap3.extras.slider.client.ui.Slider::fireSlideStopEvent(Ljava/lang/Double;)(value);
+ }-*/;
+
+ @Override
+ protected native void onSlideChange(Event event) /*-{
+ var value = @java.lang.Double::new(D)(event.value.newValue);
+ this.@org.gwtbootstrap3.extras.slider.client.ui.Slider::fireChangeEvent(Ljava/lang/Double;)(value);
+ }-*/;
+
}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/FormatterCallback.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/FormatterCallback.java
index 5c714a33..9c9fc6d2 100644
--- a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/FormatterCallback.java
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/FormatterCallback.java
@@ -4,7 +4,7 @@
* #%L
* GwtBootstrap3
* %%
- * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,19 @@
* #L%
*/
+/**
+ * Formatter callback to display the tool-tip text. Defaults to the slider
+ * numeric value.
+ *
+ * @author Xiaodong SUN
+ */
public interface FormatterCallback {
- public String toolTipMsg(double value);
+
+ /**
+ * Returns the formatted tool-tip text to be displayed.
+ *
+ * @param value the slider numeric value
+ * @return the formatted tool-tip text to be displayed.
+ */
+ String formatTooltip(double value);
}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/SliderBase.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/SliderBase.java
index e66a6bb9..422850cf 100644
--- a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/SliderBase.java
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/SliderBase.java
@@ -4,7 +4,7 @@
* #%L
* GwtBootstrap3
* %%
- * Copyright (C) 2013 GwtBootstrap3
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,281 +20,873 @@
* #L%
*/
-import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.editor.client.IsEditor;
-import com.google.gwt.editor.client.LeafValueEditor;
-import com.google.gwt.editor.client.adapters.TakesValueEditor;
-import com.google.gwt.event.logical.shared.HasValueChangeHandlers;
-import com.google.gwt.event.logical.shared.ValueChangeEvent;
-import com.google.gwt.event.logical.shared.ValueChangeHandler;
-import com.google.gwt.event.shared.HandlerRegistration;
-import com.google.gwt.user.client.ui.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
import org.gwtbootstrap3.client.ui.TextBox;
import org.gwtbootstrap3.client.ui.base.HasId;
import org.gwtbootstrap3.client.ui.base.HasResponsiveness;
import org.gwtbootstrap3.client.ui.base.helper.StyleHelper;
+import org.gwtbootstrap3.client.ui.base.mixin.AttributeMixin;
import org.gwtbootstrap3.client.ui.constants.DeviceSize;
import org.gwtbootstrap3.extras.slider.client.ui.base.constants.HandleType;
import org.gwtbootstrap3.extras.slider.client.ui.base.constants.OrientationType;
+import org.gwtbootstrap3.extras.slider.client.ui.base.constants.ScaleType;
import org.gwtbootstrap3.extras.slider.client.ui.base.constants.SelectionType;
import org.gwtbootstrap3.extras.slider.client.ui.base.constants.TooltipType;
+import org.gwtbootstrap3.extras.slider.client.ui.base.event.HasAllSlideHandlers;
+import org.gwtbootstrap3.extras.slider.client.ui.base.event.SlideDisabledEvent;
+import org.gwtbootstrap3.extras.slider.client.ui.base.event.SlideDisabledHandler;
+import org.gwtbootstrap3.extras.slider.client.ui.base.event.SlideEnabledEvent;
+import org.gwtbootstrap3.extras.slider.client.ui.base.event.SlideEnabledHandler;
+import org.gwtbootstrap3.extras.slider.client.ui.base.event.SlideEvent;
+import org.gwtbootstrap3.extras.slider.client.ui.base.event.SlideHandler;
+import org.gwtbootstrap3.extras.slider.client.ui.base.event.SlideStartEvent;
+import org.gwtbootstrap3.extras.slider.client.ui.base.event.SlideStartHandler;
+import org.gwtbootstrap3.extras.slider.client.ui.base.event.SlideStopEvent;
+import org.gwtbootstrap3.extras.slider.client.ui.base.event.SlideStopHandler;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.core.client.JsArrayNumber;
+import com.google.gwt.core.client.JsArrayString;
+import com.google.gwt.core.client.JsonUtils;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.editor.client.IsEditor;
+import com.google.gwt.editor.client.LeafValueEditor;
+import com.google.gwt.editor.client.adapters.TakesValueEditor;
+import com.google.gwt.event.logical.shared.ValueChangeEvent;
+import com.google.gwt.event.logical.shared.ValueChangeHandler;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.ui.HasEnabled;
+import com.google.gwt.user.client.ui.HasValue;
+import com.google.gwt.user.client.ui.UIObject;
+import com.google.gwt.user.client.ui.Widget;
/**
- * @author Grant Slender
+ *
+ *
+ * @param slider value type
+ *
+ * @see https://github.com/seiyria/bootstrap-slider
+ * @author Xiaodong Sun
*/
-public class SliderBase extends Widget implements HasValue, HasEnabled, HasValueChangeHandlers, HasVisibility,
- HasId, HasResponsiveness, IsEditor> {
+public abstract class SliderBase extends Widget implements
+ HasValue, IsEditor>, HasEnabled, HasId,
+ HasResponsiveness, HasAllSlideHandlers {
- /**
- * Orig source from https://github.com/seiyria/bootstrap-slider
- */
private final TextBox textBox;
- private double min = 0;
- private double max = 10;
- private double step = 1;
- OrientationType orient = OrientationType.HORIZONTAL;
- SelectionType selection = SelectionType.BEFORE;
- TooltipType tooltip = TooltipType.SHOW;
- HandleType handle = HandleType.ROUND;
- boolean reversed = false;
private FormatterCallback formatterCallback;
- private LeafValueEditor editor;
+ private LeafValueEditor editor;
- public SliderBase() {
+ private final AttributeMixin> attributeMixin = new AttributeMixin>(this);
+
+ protected SliderBase() {
textBox = new TextBox();
// now remove the bootstrap styles
textBox.removeStyleName(UIObject.getStyleName(textBox.getElement()));
setElement((Element) textBox.getElement());
- setValue(5.0);
}
@Override
protected void onLoad() {
super.onLoad();
- final JavaScriptObject options = getOptions(getId(), getMin(), getMax(), getStep(), getOrientation().getType(), getValue(),
- getSelection().getType(), getTooltip().getType(), getHandle().getType(), isReversed(), isEnabled());
- sliderInit(getElement(), options);
+ final JavaScriptObject options = JavaScriptObject.createObject();
+ if (formatterCallback != null) {
+ setFormatterOption(options);
+ }
+ initSlider(getElement(), options);
+ bindSliderEvents(getElement());
}
@Override
protected void onUnload() {
super.onUnload();
- sliderCommand(getElement(), "destroy");
- unbindHandlers(getElement());
+ unbindSliderEvents(getElement());
+ sliderCommand(getElement(), SliderCommand.DESTROY);
}
- public void onChange(final double value) {
- ValueChangeEvent.fire(this, value);
+ /**
+ * Sets the id of the slider element when it's created.
+ */
+ @Override
+ public void setId(final String id) {
+ updateSlider(SliderOption.ID, id);
}
@Override
- public void setVisibleOn(final DeviceSize deviceSize) {
- StyleHelper.setVisibleOn(this, deviceSize);
+ public String getId() {
+ return getStringAttribute(SliderOption.ID);
}
- @Override
- public void setHiddenOn(final DeviceSize deviceSize) {
- StyleHelper.setHiddenOn(this, deviceSize);
+ public double getMin() {
+ return getDoubleAttribute(SliderOption.MIN, 0);
}
- @Override
- public void setId(final String id) {
- textBox.setId(id);
+ /**
+ * Sets the minimum possible value.
+ *
+ * @param min
+ */
+ public void setMin(final double min) {
+ updateSlider(SliderOption.MIN, min);
}
- @Override
- public String getId() {
- return textBox.getId();
+ public double getMax() {
+ return getDoubleAttribute(SliderOption.MAX, 10);
}
- @Override
- public HandlerRegistration addValueChangeHandler(final ValueChangeHandler handler) {
- return addHandler(handler, ValueChangeEvent.getType());
+ /**
+ * Sets the maximum possible value.
+ *
+ * @param max
+ */
+ public void setMax(final double max) {
+ updateSlider(SliderOption.MAX, max);
+ }
+
+ public double getStep() {
+ return getDoubleAttribute(SliderOption.STEP, 1);
+ }
+
+ /**
+ * Sets the increment step.
+ *
+ * @param step
+ */
+ public void setStep(final double step) {
+ updateSlider(SliderOption.STEP, step);
+ }
+
+ public double getPrecision() {
+ return getDoubleAttribute(SliderOption.PRECISION, 0);
+ }
+
+ /**
+ * Sets the number of digits shown after the decimal.
+ *
+ * Defaults to the number of digits after the decimal of step value.
+ *
+ * @param precision
+ */
+ public void setPrecision(final double precision) {
+ updateSlider(SliderOption.PRECISION, precision);
+ }
+
+ public OrientationType getOrientation() {
+ return getEnumAttribute(SliderOption.ORIENTATION, OrientationType.class, OrientationType.HORIZONTAL);
+ }
+
+ /**
+ * Sets the orientation.
+ *
+ * @param orientation
+ * @see OrientationType
+ */
+ public void setOrientation(final OrientationType orientation) {
+ updateSlider(SliderOption.ORIENTATION, orientation.getType());
+ }
+
+ protected boolean isRange() {
+ return getBooleanAttribute(SliderOption.RANGE, false);
+ }
+
+ /**
+ * Make range slider if set to true
. If initial value is scalar,
+ * max will be used for second value.
+ *
+ * @param range
+ */
+ protected void setRange(final boolean range) {
+ updateSlider(SliderOption.RANGE, range);
+ }
+
+ public SelectionType getSelection() {
+ return getEnumAttribute(SliderOption.SELECTION, SelectionType.class, SelectionType.BEFORE);
+ }
+
+ /**
+ * Sets the selection type.
+ *
+ * @param selection
+ * @see SelectionType
+ */
+ public void setSelection(final SelectionType selection) {
+ updateSlider(SliderOption.SELECTION, selection.getType());
+ }
+
+ public TooltipType getTooltip() {
+ return getEnumAttribute(SliderOption.TOOLTIP, TooltipType.class, TooltipType.SHOW);
+ }
+
+ /**
+ * Sets the tool-tip type.
+ *
+ * @param tooltip
+ * @see TooltipType
+ */
+ public void setTooltip(final TooltipType tooltip) {
+ updateSlider(SliderOption.TOOLTIP, tooltip.getType());
+ }
+
+ public boolean isTooltipSplit() {
+ return getBooleanAttribute(SliderOption.TOOLTIP_SPLIT, false);
+ }
+
+ /**
+ * Show one too-tip if set to false
, otherwise
+ * show two tool-tips one for each handler.
+ *
+ * @param tooltipSplit
+ */
+ public void setTooltipSplit(final boolean tooltipSplit) {
+ updateSlider(SliderOption.TOOLTIP_SPLIT, tooltipSplit);
+ }
+
+ public HandleType getHandle() {
+ return getEnumAttribute(SliderOption.HANDLE, HandleType.class, HandleType.ROUND);
+ }
+
+ /**
+ * Sets the handle shape.
+ *
+ * @param handle
+ * @see HandleType
+ */
+ public void setHandle(final HandleType handle) {
+ updateSlider(SliderOption.HANDLE, handle.getType());
+ }
+
+ public boolean isReversed() {
+ return getBooleanAttribute(SliderOption.REVERSED, false);
+ }
+
+ /**
+ * Sets whether or not the slider should be reversed.
+ *
+ * @param reversed
+ */
+ public void setReversed(final boolean reversed) {
+ updateSlider(SliderOption.REVERSED, reversed);
}
@Override
public boolean isEnabled() {
- return textBox.isEnabled();
- // return isEnabled(getElement());
+ if (isAttached()) {
+ return isEnabled(getElement());
+ }
+ return getBooleanAttribute(SliderOption.ENABLED, true);
}
@Override
public void setEnabled(final boolean enabled) {
- textBox.setEnabled(enabled);
- if (SliderBase.this.isAttached()) {
+ if (isAttached()) {
if (enabled) {
- sliderCommand(getElement(), "enable");
+ sliderCommand(getElement(), SliderCommand.ENABLE);
} else {
- sliderCommand(getElement(), "disable");
+ sliderCommand(getElement(), SliderCommand.DISABLE);
}
+ } else {
+ updateSlider(SliderOption.ENABLED, enabled);
}
}
- public double getMin() {
- return min;
+ /**
+ * Sets the formatter callback.
+ *
+ * @param formatterCallback
+ */
+ public void setFormatter(final FormatterCallback formatterCallback) {
+ this.formatterCallback = formatterCallback;
+ if (isAttached()) {
+ setFormatter(getElement());
+ refresh();
+ }
}
- public void setMin(final double min) {
- this.min = min;
+ private String formatter(final double value) {
+ if (formatterCallback != null)
+ return formatterCallback.formatTooltip(value);
+ return Double.toString(value);
}
- public double getMax() {
- return max;
+ public boolean isNaturalArrowKeys() {
+ return getBooleanAttribute(SliderOption.NATURAL_ARROW_KEYS, false);
}
- public void setMax(final double max) {
- this.max = max;
+ /**
+ * The natural order is used for the arrow keys. Arrow up select the
+ * upper slider value for vertical sliders, arrow right the righter
+ * slider value for a horizontal slider ; no matter if the slider
+ * was reversed or not.
+ *
+ * By default the arrow keys are oriented by arrow up/right to the
+ * higher slider value, arrow down/left to the lower slider value.
+ *
+ * @param naturalArrowKeys
+ */
+ public void setNaturalArrowKeys(final boolean naturalArrowKeys) {
+ updateSlider(SliderOption.NATURAL_ARROW_KEYS, naturalArrowKeys);
}
- public double getStep() {
- return step;
+ public List getTicks() {
+ return getNumberArrayAttribute(SliderOption.TICKS, Collections.emptyList());
}
- public void setStep(final double step) {
- this.step = step;
+ /**
+ * Sets the values of ticks. Tick marks are indicators to denote
+ * special values in the range.
+ *
+ * This option overwrites min and max options.
+ *
+ * @param ticks
+ */
+ public void setTicks(final List ticks) {
+ updateSliderForNumberArray(SliderOption.TICKS, ticks);
}
- public OrientationType getOrientation() {
- return orient;
+ public List getTicksLabels() {
+ return getStringArrayAttribute(SliderOption.TICKS_LABELS, Collections.emptyList());
}
- public void setOrientation(final OrientationType orient) {
- this.orient = orient;
+ /**
+ * Sets the labels below the tick marks.
+ *
+ * Accepts HTML input.
+ *
+ * @param ticksLabels
+ */
+ public void setTicksLabels(final List ticksLabels) {
+ updateSliderForStringArray(SliderOption.TICKS_LABELS, ticksLabels);
}
- public SelectionType getSelection() {
- return selection;
+ public double getTicksSnapBounds() {
+ return getDoubleAttribute(SliderOption.TICKS_SNAP_BOUNDS, 0);
}
- public void setSelection(final SelectionType selection) {
- this.selection = selection;
+ /**
+ * Sets the snap bounds of a tick. Snaps to the tick if value
+ * is within these bounds.
+ *
+ * @param ticksSnapBounds
+ */
+ public void setTicksSnapBounds(final double ticksSnapBounds) {
+ updateSlider(SliderOption.TICKS_SNAP_BOUNDS, ticksSnapBounds);
}
- public TooltipType getTooltip() {
- return tooltip;
+ public ScaleType getScale() {
+ return getEnumAttribute(SliderOption.SCALE, ScaleType.class, ScaleType.LINEAR);
}
- public void setTooltip(final TooltipType tooltip) {
- this.tooltip = tooltip;
+ /**
+ * Sets the slider scale type.
+ *
+ * @param scale
+ * @see ScaleType
+ */
+ public void setScale(final ScaleType scale) {
+ updateSlider(SliderOption.SCALE, scale.getType());
}
- public HandleType getHandle() {
- return handle;
+ @Override
+ public void setVisible(final boolean visible) {
+ if (isAttached()) {
+ Element elem = getElement().getPreviousSiblingElement();
+ if (elem != null) {
+ setVisible(elem, visible);
+ return;
+ }
+ }
+ super.setVisible(visible);
}
- public void setHandle(final HandleType handle) {
- this.handle = handle;
+ @Override
+ public boolean isVisible() {
+ if (isAttached()) {
+ Element elem = getElement().getPreviousSiblingElement();
+ if (elem != null) {
+ return isVisible(elem);
+ }
+ }
+ return isVisible();
}
- public boolean isReversed() {
- return reversed;
+ @Override
+ public void setVisibleOn(final DeviceSize deviceSize) {
+ StyleHelper.setVisibleOn(this, deviceSize);
}
- public void setReversed(final boolean reversed) {
- this.reversed = reversed;
+ @Override
+ public void setHiddenOn(final DeviceSize deviceSize) {
+ StyleHelper.setHiddenOn(this, deviceSize);
}
@Override
- public Double getValue() {
- return Double.valueOf(textBox.getValue());
+ public void setValue(final T value) {
+ setValue(value, false);
}
@Override
- public void setValue(final Double value) {
- textBox.setValue(value.toString());
- if (SliderBase.this.isAttached()) {
- setValue(value, false);
+ public void setValue(final T value, final boolean fireEvents) {
+
+ T oldValue = fireEvents ? getValue() : null;
+
+ if (isAttached()) {
+ setValue(getElement(), value);
+ } else {
+ String attrVal = (value == null) ? null : value.toString();
+ attributeMixin.setAttribute(SliderOption.VALUE.getDataAttribute(), attrVal);
+ }
+
+ if (fireEvents) {
+ T newValue = getValue();
+ ValueChangeEvent.fireIfNotEqual(this, oldValue, newValue);
}
}
+ /**
+ * Sets the given value to the slider. This method is only relevant if the
+ * slider has been initialized and it will NOT fire the slide event.
+ *
+ * @param e
+ * @param value
+ */
+ protected abstract void setValue(Element e, T value);
+
@Override
- public void setValue(final Double value, final boolean fireEvents) {
-
- Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() {
- @Override
- public boolean execute() {
- if (SliderBase.this.isAttached()) {
- setValue(getElement(), value);
-
- if (fireEvents) {
- ValueChangeEvent.fire(SliderBase.this, value);
- }
- return false;
- } else {
- return true;
- }
- }
- }, 100);
+ public T getValue() {
+ if (isAttached()) {
+ return getValue(getElement());
+ }
+ String attrVal = attributeMixin.getAttribute(SliderOption.VALUE.getDataAttribute());
+ return convertValue(attrVal);
+ }
+
+ /**
+ * Returns the value by invoking the JSNI getValue command.
+ *
+ * @param e
+ * @return
+ */
+ protected abstract T getValue(Element e);
+
+ /**
+ * Converts the value of the {@link SliderOption.VALUE} attribute to the
+ * slider value.
+ *
+ * @param value
+ * @return
+ */
+ protected abstract T convertValue(String value);
+
+ /**
+ * Toggles the slider between enabled and disabled.
+ */
+ public void toggle() {
+ if (isAttached()) {
+ sliderCommand(getElement(), SliderCommand.TOGGLE);
+ } else {
+ setEnabled(!isEnabled());
+ }
+ }
+
+ /**
+ * Refreshes the current slider. This method does nothing if the slider has
+ * not been initialized.
+ */
+ public void refresh() {
+ if (isAttached()) {
+ refreshWorkaround(getElement());
+ sliderCommand(getElement(), SliderCommand.REFEESH);
+ }
+ }
+
+ /**
+ * Renders the tool-tip again, after initialization. Useful in situations
+ * when the slider and tool-tip are initially hidden.
+ */
+ public void relayout() {
+ if (isAttached()) {
+ sliderCommand(getElement(), SliderCommand.RELAYOUT);
+ }
}
@Override
- public LeafValueEditor asEditor() {
+ public LeafValueEditor asEditor() {
if (editor == null) {
editor = TakesValueEditor.of(this);
}
return editor;
}
- public void setFormatter(final FormatterCallback formatterCallback) {
- this.formatterCallback = formatterCallback;
+ @Override
+ public HandlerRegistration addValueChangeHandler(final ValueChangeHandler handler) {
+ return addHandler(handler, ValueChangeEvent.getType());
}
- private String formatter(final double value) {
- if (formatterCallback != null)
- return formatterCallback.toolTipMsg(value);
- return Double.toString(value);
+ @Override
+ public HandlerRegistration addSlideHandler(final SlideHandler handler) {
+ return addHandler(handler, SlideEvent.getType());
+ }
+
+ @Override
+ public HandlerRegistration addSlideStartHandler(final SlideStartHandler handler) {
+ return addHandler(handler, SlideStartEvent.getType());
}
-// @formatter:off
+ @Override
+ public HandlerRegistration addSlideStopHandler(final SlideStopHandler handler) {
+ return addHandler(handler, SlideStopEvent.getType());
+ }
+
+ @Override
+ public HandlerRegistration addSlideEnabledHandler(final SlideEnabledHandler handler) {
+ return addHandler(handler, SlideEnabledEvent.getType());
+ }
+
+ @Override
+ public HandlerRegistration addSlideDisabledHandler(final SlideDisabledHandler handler) {
+ return addHandler(handler, SlideDisabledEvent.getType());
+ }
+
+ private void updateSlider(SliderOption option, String value) {
+ if (isAttached()) {
+ setAttribute(getElement(), option.getName(), value);
+ refresh();
+ } else {
+ attributeMixin.setAttribute(option.getDataAttribute(), value);
+ }
+ }
+
+ private void updateSlider(SliderOption option, boolean value) {
+ if (isAttached()) {
+ setAttribute(getElement(), option.getName(), value);
+ refresh();
+ } else {
+ attributeMixin.setAttribute(option.getDataAttribute(), Boolean.toString(value));
+ }
+ }
+
+ private void updateSlider(SliderOption option, double value) {
+ if (isAttached()) {
+ setAttribute(getElement(), option.getName(), value);
+ refresh();
+ } else {
+ attributeMixin.setAttribute(option.getDataAttribute(), Double.toString(value));
+ }
+ }
+
+ private void updateSliderForNumberArray(SliderOption option, List value) {
+ JsArrayNumber array = JavaScriptObject.createArray().cast();
+ for (Double val : value) {
+ array.push(val);
+ }
+ if (isAttached()) {
+ setAttribute(getElement(), option.getName(), array);
+ refresh();
+ } else {
+ String arrayStr = JsonUtils.stringify(array);
+ attributeMixin.setAttribute(option.getDataAttribute(), arrayStr);
+ }
+ }
+
+ private void updateSliderForStringArray(SliderOption option, List value) {
+ JsArrayString array = JavaScriptObject.createArray().cast();
+ for (String val : value) {
+ array.push(val);
+ }
+ if (isAttached()) {
+ setAttribute(getElement(), option.getName(), array);
+ refresh();
+ } else {
+ String arrayStr = JsonUtils.stringify(array);
+ attributeMixin.setAttribute(option.getDataAttribute(), arrayStr);
+ }
+ }
+
+ private String getStringAttribute(SliderOption option) {
+ if (isAttached()) {
+ return getStringAttribute(getElement(), option.getName());
+ }
+ return attributeMixin.getAttribute(option.getDataAttribute());
+ }
+
+ private boolean getBooleanAttribute(SliderOption option, boolean defaultValue) {
+ if (isAttached()) {
+ return getBooleanAttribute(getElement(), option.getName());
+ }
+ String value = attributeMixin.getAttribute(option.getDataAttribute());
+ if (value != null && !value.isEmpty()) {
+ return Boolean.valueOf(value);
+ }
+ return defaultValue;
+ }
+
+ private double getDoubleAttribute(SliderOption option, double defaultValue) {
+ if (isAttached()) {
+ return getDoubleAttribute(getElement(), option.getName());
+ }
+ String value = attributeMixin.getAttribute(option.getDataAttribute());
+ if (value != null && !value.isEmpty()) {
+ return Double.valueOf(value);
+ }
+ return defaultValue;
+ }
+
+ private > E getEnumAttribute(SliderOption option, Class clazz, E defaultValue) {
+ String value;
+ if (isAttached()) {
+ value = getStringAttribute(getElement(), option.getName());
+ } else {
+ value = attributeMixin.getAttribute(option.getDataAttribute());
+ }
+ try {
+ return Enum.valueOf(clazz, value);
+ } catch (Throwable e) {
+ return defaultValue;
+ }
+ }
- private native double getValue(Element e) /*-{
- return $wnd.jQuery(e).slider('getValue');
+ private List getNumberArrayAttribute(SliderOption option, List defaultValue) {
+
+ // Get array attribute
+ JsArrayNumber array = null;
+ if (isAttached()) {
+ array = getNumberArrayAttribute(getElement(), option.getName());
+ } else {
+ String value = attributeMixin.getAttribute(option.getDataAttribute());
+ if (value != null && !value.isEmpty()) {
+ array = JsonUtils.safeEval(value);
+ }
+ }
+
+ // Attribute not set
+ if (array == null) {
+ return defaultValue;
+ }
+
+ // Put array to list
+ List list = new ArrayList(array.length());
+ for (int i = 0; i < array.length(); i++) {
+ list.add(array.get(i));
+ }
+ return list;
+ }
+
+ private List getStringArrayAttribute(SliderOption option, List defaultValue) {
+
+ // Get array attribute
+ JsArrayString array = null;
+ if (isAttached()) {
+ array = getStringArrayAttribute(getElement(), option.getName());
+ } else {
+ String value = attributeMixin.getAttribute(option.getDataAttribute());
+ if (value != null && !value.isEmpty()) {
+ array = JsonUtils.safeEval(value);
+ }
+ }
+
+ // Attribute not set
+ if (array == null) {
+ return defaultValue;
+ }
+
+ // Put array to list
+ List list = new ArrayList(array.length());
+ for (int i = 0; i < array.length(); i++) {
+ list.add(array.get(i));
+ }
+ return list;
+ }
+
+ private native void initSlider(Element e, JavaScriptObject options) /*-{
+ $wnd.jQuery(e).slider(options);
}-*/;
- private native boolean isEnabled(Element e) /*-{
- return $wnd.jQuery(e).slider('isEnabled');
+ /**
+ * Called when a {@link SlideEvent} is fired.
+ *
+ * @param event the native event
+ */
+ protected abstract void onSlide(final Event event);
+
+ /**
+ * Fires a {@link SlideEvent} event.
+ *
+ * @param value the new slide value
+ */
+ protected void fireSlideEvent(final T value) {
+ SlideEvent.fire(this, value);
+ }
+
+ /**
+ * Called when a {@link SlideStartEvent} is fired.
+ *
+ * @param event the native event
+ */
+ protected abstract void onSlideStart(final Event event);
+
+ /**
+ * Fires a {@link SlideStartEvent} event.
+ *
+ * @param value the new slide value
+ */
+ protected void fireSlideStartEvent(final T value) {
+ SlideStartEvent.fire(this, value);
+ }
+
+ /**
+ * Called when a {@link SlideStopEvent} is fired.
+ *
+ * @param event the native event
+ */
+ protected abstract void onSlideStop(final Event event);
+
+ /**
+ * Fires a {@link SlideStopEvent} event.
+ *
+ * @param value the new slide value
+ */
+ protected void fireSlideStopEvent(final T value) {
+ SlideStopEvent.fire(this, value);
+ }
+
+ /**
+ * Called when a {@link ValueChangeEvent} is fired.
+ *
+ * @param event the native event
+ */
+ protected abstract void onSlideChange(final Event event);
+
+ /**
+ * Fires a {@link ValueChangeEvent} event.
+ *
+ * @param value the new slide value
+ */
+ protected void fireChangeEvent(final T value) {
+ ValueChangeEvent.fire(this, value);
+ }
+
+ /**
+ * Binds the slider events.
+ *
+ * @param e
+ */
+ private native void bindSliderEvents(Element e) /*-{
+ var slider = this;
+ $wnd.jQuery(e).on(@org.gwtbootstrap3.extras.slider.client.ui.base.event.HasAllSlideHandlers::SLIDE_EVENT, function(event) {
+ slider.@org.gwtbootstrap3.extras.slider.client.ui.base.SliderBase::onSlide(Lcom/google/gwt/user/client/Event;)(event);
+ });
+ $wnd.jQuery(e).on(@org.gwtbootstrap3.extras.slider.client.ui.base.event.HasAllSlideHandlers::SLIDE_START_EVENT, function(event) {
+ slider.@org.gwtbootstrap3.extras.slider.client.ui.base.SliderBase::onSlideStart(Lcom/google/gwt/user/client/Event;)(event);
+ });
+ $wnd.jQuery(e).on(@org.gwtbootstrap3.extras.slider.client.ui.base.event.HasAllSlideHandlers::SLIDE_STOP_EVENT, function(event) {
+ slider.@org.gwtbootstrap3.extras.slider.client.ui.base.SliderBase::onSlideStop(Lcom/google/gwt/user/client/Event;)(event);
+ });
+ $wnd.jQuery(e).on(@org.gwtbootstrap3.extras.slider.client.ui.base.event.HasAllSlideHandlers::SLIDE_CHANGE_EVENT, function(event) {
+ slider.@org.gwtbootstrap3.extras.slider.client.ui.base.SliderBase::onSlideChange(Lcom/google/gwt/user/client/Event;)(event);
+ });
+ $wnd.jQuery(e).on(@org.gwtbootstrap3.extras.slider.client.ui.base.event.HasAllSlideHandlers::SLIDE_ENABLED_EVENT, function(event) {
+ @org.gwtbootstrap3.extras.slider.client.ui.base.event.SlideEnabledEvent::fire(Lorg/gwtbootstrap3/extras/slider/client/ui/base/event/HasSlideEnabledHandlers;)(slider);
+ });
+ $wnd.jQuery(e).on(@org.gwtbootstrap3.extras.slider.client.ui.base.event.HasAllSlideHandlers::SLIDE_DISABLED_EVENT, function(event) {
+ @org.gwtbootstrap3.extras.slider.client.ui.base.event.SlideDisabledEvent::fire(Lorg/gwtbootstrap3/extras/slider/client/ui/base/event/HasSlideDisabledHandlers;)(slider);
+ });
}-*/;
- private native void setValue(Element e, double value) /*-{
- $wnd.jQuery(e).slider('setValue', value);
+ /**
+ * Unbinds the slider events.
+ *
+ * @param e
+ */
+ private native void unbindSliderEvents(Element e) /*-{
+ $wnd.jQuery(e).off(@org.gwtbootstrap3.extras.slider.client.ui.base.event.HasAllSlideHandlers::SLIDE_EVENT);
+ $wnd.jQuery(e).off(@org.gwtbootstrap3.extras.slider.client.ui.base.event.HasAllSlideHandlers::SLIDE_START_EVENT);
+ $wnd.jQuery(e).off(@org.gwtbootstrap3.extras.slider.client.ui.base.event.HasAllSlideHandlers::SLIDE_STOP_EVENT);
+ $wnd.jQuery(e).off(@org.gwtbootstrap3.extras.slider.client.ui.base.event.HasAllSlideHandlers::SLIDE_CHANGE_EVENT);
+ $wnd.jQuery(e).off(@org.gwtbootstrap3.extras.slider.client.ui.base.event.HasAllSlideHandlers::SLIDE_ENABLED_EVENT);
+ $wnd.jQuery(e).off(@org.gwtbootstrap3.extras.slider.client.ui.base.event.HasAllSlideHandlers::SLIDE_DISABLED_EVENT);
}-*/;
- private native void sliderInit(Element e, JavaScriptObject options) /*-{
- var me = this;
- $wnd.jQuery(e).slider(options)
- .on('slide', function (evt) {
- me.@org.gwtbootstrap3.extras.slider.client.ui.base.SliderBase::onChange(D)(evt.value);
- })
+ private native boolean isEnabled(Element e) /*-{
+ return $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::IS_ENABLED);
}-*/;
- private native JavaScriptObject getOptions(String id, double min, double max, double step, String orient, double value, String selection, String tooltip, String handle, boolean reversed, boolean enabled) /*-{
- var me = this;
- var options = {
- id: id,
- min: min,
- max: max,
- step: step,
- orientation: orient,
- value: value,
- selection: selection,
- tooltip: tooltip,
- handle: handle,
- reversed: reversed,
- enabled: enabled
+ private native void setFormatterOption(JavaScriptObject options) /*-{
+ var slider = this;
+ options.formatter = function(value) {
+ return slider.@org.gwtbootstrap3.extras.slider.client.ui.base.SliderBase::formatter(D)(value);
};
- options.formater = function (val) {
- return me.@org.gwtbootstrap3.extras.slider.client.ui.base.SliderBase::formatter(D)(val);
- };
- return options;
+ }-*/;
+
+ private native void setFormatter(Element e) /*-{
+ var slider = this;
+ var attr = @org.gwtbootstrap3.extras.slider.client.ui.base.SliderOption::FORMATTER;
+ $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::SET_ATTRIBUTE, attr, function(value) {
+ return slider.@org.gwtbootstrap3.extras.slider.client.ui.base.SliderBase::formatter(D)(value);
+ });
+ }-*/;
+
+ /**
+ * FIXME: This is a workaround for the refresh command, since it is buggy in
+ * the current version (4.5.6). After executing this command, the slider
+ * becomes consistently a range slider with 2 handles. This should be
+ * removed once the bug is fixed in a future version.
+ *
+ * @see https://github.com/seiyria/bootstrap-slider/issues/306
+ *
+ * @param e
+ */
+ private native void refreshWorkaround(Element e) /*-{
+ var value = $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::GET_VALUE);
+ var option = @org.gwtbootstrap3.extras.slider.client.ui.base.SliderOption::VALUE;
+ var attr = option.@org.gwtbootstrap3.extras.slider.client.ui.base.SliderOption::getName()();
+ $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::SET_ATTRIBUTE, attr, value);
}-*/;
private native void sliderCommand(Element e, String cmd) /*-{
$wnd.jQuery(e).slider(cmd);
}-*/;
- private native void unbindHandlers(Element e) /*-{
- $wnd.jQuery(e).off('slide');
+ private native void setAttribute(Element e, String attr, String value) /*-{
+ $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::SET_ATTRIBUTE, attr, value);
}-*/;
+
+ private native void setAttribute(Element e, String attr, boolean value) /*-{
+ $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::SET_ATTRIBUTE, attr, value);
+ }-*/;
+
+ private native void setAttribute(Element e, String attr, double value) /*-{
+ $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::SET_ATTRIBUTE, attr, value);
+ }-*/;
+
+ private native void setAttribute(Element e, String attr, JsArrayNumber value) /*-{
+ $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::SET_ATTRIBUTE, attr, value);
+ }-*/;
+
+ private native void setAttribute(Element e, String attr, JsArrayString value) /*-{
+ $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::SET_ATTRIBUTE, attr, value);
+ }-*/;
+
+ private native String getStringAttribute(Element e, String attr) /*-{
+ return $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::GET_ATTRIBUTE, attr);
+ }-*/;
+
+ private native boolean getBooleanAttribute(Element e, String attr) /*-{
+ return $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::GET_ATTRIBUTE, attr);
+ }-*/;
+
+ private native double getDoubleAttribute(Element e, String attr) /*-{
+ return $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::GET_ATTRIBUTE, attr);
+ }-*/;
+
+ private native JsArrayNumber getNumberArrayAttribute(Element e, String attr) /*-{
+ return $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::GET_ATTRIBUTE, attr);
+ }-*/;
+
+ private native JsArrayString getStringArrayAttribute(Element e, String attr) /*-{
+ return $wnd.jQuery(e).slider(@org.gwtbootstrap3.extras.slider.client.ui.base.SliderCommand::GET_ATTRIBUTE, attr);
+ }-*/;
+
}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/SliderCommand.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/SliderCommand.java
new file mode 100644
index 00000000..e589431d
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/SliderCommand.java
@@ -0,0 +1,44 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Boostrap slider commands.
+ *
+ * @author Xiaodong SUN
+ * @see https://github.com/seiyria/bootstrap-slider#functions
+ */
+public interface SliderCommand {
+
+ static final String GET_VALUE = "getValue";
+ static final String SET_VALUE = "setValue";
+ static final String DESTROY = "destroy";
+ static final String DISABLE = "disable";
+ static final String ENABLE = "enable";
+ static final String TOGGLE = "toggle";
+ static final String IS_ENABLED = "isEnabled";
+ static final String SET_ATTRIBUTE = "setAttribute";
+ static final String GET_ATTRIBUTE = "getAttribute";
+ static final String REFEESH = "refresh";
+ static final String ON = "on";
+ static final String RELAYOUT = "relayout";
+
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/SliderOption.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/SliderOption.java
new file mode 100644
index 00000000..f4d6802d
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/SliderOption.java
@@ -0,0 +1,86 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Boostrap slider options enumeration type.
+ *
+ * Options can be passed either as a data (data-slider-foo
)
+ * attribute, or as part of an object in the slider call. The only exception
+ * here is the formatter option, that can not be passed as a
+ * data attribute.
+ *
+ * @author Xiaodong SUN
+ * @see https://github.com/seiyria/bootstrap-slider#options
+ */
+enum SliderOption {
+
+ ID("id"),
+ MIN("min"),
+ MAX("max"),
+ STEP("step"),
+ PRECISION("precision"),
+ ORIENTATION("orientation"),
+ VALUE("value"),
+ RANGE("range"),
+ SELECTION("selection"),
+ TOOLTIP("tooltip"),
+ TOOLTIP_SPLIT("tooltip_split"),
+ HANDLE("handle"),
+ REVERSED("reversed"),
+ ENABLED("enabled"),
+ FORMATTER("formatter"),
+ NATURAL_ARROW_KEYS("natural_arrow_keys"),
+ TICKS("ticks"),
+ TICKS_LABELS("ticks_labels"),
+ TICKS_SNAP_BOUNDS("ticks_snap_bounds"),
+ SCALE("scale"),
+ ;
+
+ private final String name;
+ private final static String DATA_ATTRIBUTE_PREFIX = "data-slider-";
+
+ /**
+ * @param name the option name
+ */
+ private SliderOption(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the option name.
+ *
+ * @return the option name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns the data attribute name prefixed by
+ * {@value #DATA_ATTRIBUTE_PREFIX}.
+ *
+ * @return the data attribute name
+ */
+ public String getDataAttribute() {
+ return DATA_ATTRIBUTE_PREFIX + name;
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/HandleType.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/HandleType.java
index 19f7df9d..4070d505 100644
--- a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/HandleType.java
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/HandleType.java
@@ -1,10 +1,12 @@
package org.gwtbootstrap3.extras.slider.client.ui.base.constants;
+import org.gwtbootstrap3.client.ui.constants.Type;
+
/*
* #%L
* GwtBootstrap3
* %%
- * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,10 +22,18 @@
* #L%
*/
-public enum HandleType {
+/**
+ * Slider handle shape.
+ *
+ * @author Xiaodong SUN
+ */
+public enum HandleType implements Type {
+
ROUND("round"),
SQUARE("square"),
- TRIANGLE("triangle");
+ TRIANGLE("triangle"),
+ CUSTOM("custom"),
+ ;
private final String type;
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/OrientationType.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/OrientationType.java
index 0723e664..bcf6e86d 100644
--- a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/OrientationType.java
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/OrientationType.java
@@ -1,10 +1,12 @@
package org.gwtbootstrap3.extras.slider.client.ui.base.constants;
+import org.gwtbootstrap3.client.ui.constants.Type;
+
/*
* #%L
* GwtBootstrap3
* %%
- * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,9 +22,16 @@
* #L%
*/
-public enum OrientationType {
+/**
+ * Slider orientation : horizontal or vertical.
+ *
+ * @author Xiaodong SUN
+ */
+public enum OrientationType implements Type {
+
HORIZONTAL("horizontal"),
- VERTICAL("vertical");
+ VERTICAL("vertical"),
+ ;
private final String type;
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/ScaleType.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/ScaleType.java
new file mode 100644
index 00000000..364b155d
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/ScaleType.java
@@ -0,0 +1,45 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base.constants;
+
+import org.gwtbootstrap3.client.ui.constants.Type;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Slider scale type: linear or logarithmic.
+ *
+ * @author Xiaodong SUN
+ */
+public enum ScaleType implements Type {
+
+ LINEAR("linear"),
+ LOGARITHMIC("logarithmic"),
+ ;
+
+ private final String type;
+
+ private ScaleType(final String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/SelectionType.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/SelectionType.java
index 5103d67e..55393acb 100644
--- a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/SelectionType.java
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/SelectionType.java
@@ -1,10 +1,12 @@
package org.gwtbootstrap3.extras.slider.client.ui.base.constants;
+import org.gwtbootstrap3.client.ui.constants.Type;
+
/*
* #%L
* GwtBootstrap3
* %%
- * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,10 +22,19 @@
* #L%
*/
-public enum SelectionType {
+/**
+ * Selection placement.
+ *
+ * In case of a range slider, the selection will be placed between the handles.
+ *
+ * @author Xiaodong SUN
+ */
+public enum SelectionType implements Type {
+
BEFORE("before"),
AFTER("after"),
- NONE("none");
+ NONE("none"),
+ ;
private final String type;
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/TooltipType.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/TooltipType.java
index 5ce816ee..d4a61807 100644
--- a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/TooltipType.java
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/constants/TooltipType.java
@@ -1,10 +1,12 @@
package org.gwtbootstrap3.extras.slider.client.ui.base.constants;
+import org.gwtbootstrap3.client.ui.constants.Type;
+
/*
* #%L
* GwtBootstrap3
* %%
- * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,10 +22,18 @@
* #L%
*/
-public enum TooltipType {
+/**
+ * Whether to show the tool-tip on drag, hide the tool-tip,
+ * or always show the tool-tip.
+ *
+ * @author Xiaodong SUN
+ */
+public enum TooltipType implements Type {
+
SHOW("show"),
HIDE("hide"),
- ALWAYS("always");
+ ALWAYS("always"),
+ ;
private final String type;
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasAllSlideHandlers.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasAllSlideHandlers.java
new file mode 100644
index 00000000..e053b5e3
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasAllSlideHandlers.java
@@ -0,0 +1,65 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base.event;
+
+import com.google.gwt.event.logical.shared.HasValueChangeHandlers;
+import com.google.gwt.event.logical.shared.ValueChangeEvent;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+/**
+ * Convenience interface used to implement all slide handlers at once.
+ *
+ * @param slider value type
+ */
+public interface HasAllSlideHandlers extends HasSlideHandlers,
+ HasSlideStartHandlers, HasSlideStopHandlers, HasValueChangeHandlers,
+ HasSlideEnabledHandlers, HasSlideDisabledHandlers {
+
+ /**
+ * The {@link SlideEvent} name
+ */
+ static final String SLIDE_EVENT = "slide";
+
+ /**
+ * The {@link SlideStartEvent} name
+ */
+ static final String SLIDE_START_EVENT = "slideStart";
+
+ /**
+ * The {@link SlideStopEvent} name
+ */
+ static final String SLIDE_STOP_EVENT = "slideStop";
+
+ /**
+ * The {@link ValueChangeEvent} name
+ */
+ static final String SLIDE_CHANGE_EVENT = "change";
+
+ /**
+ * The {@link SlideEnabledEvent} name
+ */
+ static final String SLIDE_ENABLED_EVENT = "slideEnabled";
+
+ /**
+ * The {@link SlideDisabledEvent} name
+ */
+ static final String SLIDE_DISABLED_EVENT = "slideDisabled";
+
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasSlideDisabledHandlers.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasSlideDisabledHandlers.java
new file mode 100644
index 00000000..c012b3ce
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasSlideDisabledHandlers.java
@@ -0,0 +1,39 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.event.shared.HasHandlers;
+
+/**
+ * A widget that implements this interface is a public source of
+ * {@link SlideDisabledEvent} events.
+ */
+public interface HasSlideDisabledHandlers extends HasHandlers {
+
+ /**
+ * Adds a {@link SlideDisabledEvent} handler.
+ *
+ * @param handler the handler
+ * @return the registration for the event
+ */
+ HandlerRegistration addSlideDisabledHandler(SlideDisabledHandler handler);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasSlideEnabledHandlers.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasSlideEnabledHandlers.java
new file mode 100644
index 00000000..f4b47e2f
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasSlideEnabledHandlers.java
@@ -0,0 +1,39 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.event.shared.HasHandlers;
+
+/**
+ * A widget that implements this interface is a public source of
+ * {@link SlideEnabledEvent} events.
+ */
+public interface HasSlideEnabledHandlers extends HasHandlers {
+
+ /**
+ * Adds a {@link SlideEnabledEvent} handler.
+ *
+ * @param handler the handler
+ * @return the registration for the event
+ */
+ HandlerRegistration addSlideEnabledHandler(SlideEnabledHandler handler);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasSlideHandlers.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasSlideHandlers.java
new file mode 100644
index 00000000..cccd87ee
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasSlideHandlers.java
@@ -0,0 +1,41 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.event.shared.HasHandlers;
+
+/**
+ * A widget that implements this interface is a public source of
+ * {@link SlideEvent} events.
+ *
+ * @param slider value type
+ */
+public interface HasSlideHandlers extends HasHandlers {
+
+ /**
+ * Adds a {@link SlideEvent} handler.
+ *
+ * @param handler the handler
+ * @return the registration for the event
+ */
+ HandlerRegistration addSlideHandler(SlideHandler handler);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasSlideStartHandlers.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasSlideStartHandlers.java
new file mode 100644
index 00000000..fa5776ee
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasSlideStartHandlers.java
@@ -0,0 +1,39 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.event.shared.HasHandlers;
+
+/**
+ * A widget that implements this interface is a public source of
+ * {@link SlideStartEvent} events.
+ */
+public interface HasSlideStartHandlers extends HasHandlers {
+
+ /**
+ * Adds a {@link SlideStartEvent} handler.
+ *
+ * @param handler the handler
+ * @return the registration for the event
+ */
+ HandlerRegistration addSlideStartHandler(SlideStartHandler handler);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasSlideStopHandlers.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasSlideStopHandlers.java
new file mode 100644
index 00000000..c9da75eb
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/HasSlideStopHandlers.java
@@ -0,0 +1,41 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.event.shared.HasHandlers;
+
+/**
+ * A widget that implements this interface is a public source of
+ * {@link SlideStopEvent} events.
+ *
+ * @param slider value type
+ */
+public interface HasSlideStopHandlers extends HasHandlers {
+
+ /**
+ * Adds a {@link SlideStopEvent} handler.
+ *
+ * @param handler the handler
+ * @return the registration for the event
+ */
+ HandlerRegistration addSlideStopHandler(SlideStopHandler handler);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideDisabledEvent.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideDisabledEvent.java
new file mode 100644
index 00000000..7e26d3d5
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideDisabledEvent.java
@@ -0,0 +1,72 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.GwtEvent;
+
+/**
+ * The slide disabled event is fired when the slider is disabled.
+ */
+public class SlideDisabledEvent extends GwtEvent {
+
+ private static Type TYPE;
+
+ /**
+ * Fires a slide disabled event on all registered handlers in the handler
+ * manager. If no such handlers exist, this method will do nothing.
+ *
+ * @param source the source of the handlers
+ */
+ public static void fire(final HasSlideDisabledHandlers source) {
+ if (TYPE != null) {
+ SlideDisabledEvent event = new SlideDisabledEvent();
+ source.fireEvent(event);
+ }
+ }
+
+ /**
+ * Gets the type associated with this event.
+ *
+ * @return returns the handler type
+ */
+ public static Type getType() {
+ if (TYPE == null) {
+ TYPE = new Type();
+ }
+ return TYPE;
+ }
+
+ @Override
+ public Type getAssociatedType() {
+ return TYPE;
+ }
+
+ @Override
+ protected void dispatch(final SlideDisabledHandler handler) {
+ handler.onSlideDisabled(this);
+ }
+
+ /**
+ * Creates a slide disabled event.
+ */
+ protected SlideDisabledEvent() {}
+
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideDisabledHandler.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideDisabledHandler.java
new file mode 100644
index 00000000..b41dd37a
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideDisabledHandler.java
@@ -0,0 +1,36 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.EventHandler;
+
+/**
+ * Handler interface for {@link SlideDisabledEvent} events.
+ */
+public interface SlideDisabledHandler extends EventHandler {
+
+ /**
+ * Called when {@link SlideDisabledEvent} is fired.
+ *
+ * @param event the {@link SlideDisabledEvent} that was fired
+ */
+ void onSlideDisabled(SlideDisabledEvent event);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideEnabledEvent.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideEnabledEvent.java
new file mode 100644
index 00000000..f014810e
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideEnabledEvent.java
@@ -0,0 +1,72 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.GwtEvent;
+
+/**
+ * The slide enabled event is fired when the slider is enabled.
+ */
+public class SlideEnabledEvent extends GwtEvent {
+
+ private static Type TYPE;
+
+ /**
+ * Fires a slide enabled event on all registered handlers in the handler
+ * manager. If no such handlers exist, this method will do nothing.
+ *
+ * @param source the source of the handlers
+ */
+ public static void fire(final HasSlideEnabledHandlers source) {
+ if (TYPE != null) {
+ SlideEnabledEvent event = new SlideEnabledEvent();
+ source.fireEvent(event);
+ }
+ }
+
+ /**
+ * Gets the type associated with this event.
+ *
+ * @return returns the handler type
+ */
+ public static Type getType() {
+ if (TYPE == null) {
+ TYPE = new Type();
+ }
+ return TYPE;
+ }
+
+ @Override
+ public Type getAssociatedType() {
+ return TYPE;
+ }
+
+ @Override
+ protected void dispatch(final SlideEnabledHandler handler) {
+ handler.onSlideEnabled(this);
+ }
+
+ /**
+ * Creates a slide enabled event.
+ */
+ protected SlideEnabledEvent() {}
+
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideEnabledHandler.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideEnabledHandler.java
new file mode 100644
index 00000000..96800dc9
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideEnabledHandler.java
@@ -0,0 +1,36 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.EventHandler;
+
+/**
+ * Handler interface for {@link SlideEnabledEvent} events.
+ */
+public interface SlideEnabledHandler extends EventHandler {
+
+ /**
+ * Called when {@link SlideEnabledEvent} is fired.
+ *
+ * @param event the {@link SlideEnabledEvent} that was fired
+ */
+ void onSlideEnabled(SlideEnabledEvent event);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideEvent.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideEvent.java
new file mode 100644
index 00000000..44132351
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideEvent.java
@@ -0,0 +1,93 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.GwtEvent;
+
+/**
+ * The slide event is fired when the slider is dragged.
+ *
+ * @param slider value type
+ */
+public class SlideEvent extends GwtEvent> {
+
+ private static Type> TYPE;
+
+ private T value;
+
+ /**
+ * Fires a slide event on all registered handlers in the handler manager. If
+ * no such handlers exist, this method will do nothing.
+ *
+ * @param source the source of the handlers
+ * @param newValue the new slider value
+ */
+ public static void fire(final HasSlideHandlers source, T newValue) {
+ if (TYPE != null) {
+ SlideEvent event = new SlideEvent(newValue);
+ source.fireEvent(event);
+ }
+ }
+
+ /**
+ * Gets the type associated with this event.
+ *
+ * @return returns the handler type
+ */
+ public static Type> getType() {
+ if (TYPE == null) {
+ TYPE = new Type>();
+ }
+ return TYPE;
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public Type> getAssociatedType() {
+ return (Type) TYPE;
+ }
+
+ @Override
+ protected void dispatch(final SlideHandler handler) {
+ handler.onSlide(this);
+ }
+
+ /**
+ * Creates a slide event with slider value
+ *
+ * @param newValue the new slider value
+ */
+ protected SlideEvent(final T newValue) {
+ this.value = newValue;
+ }
+
+ /**
+ * @return the new slider value
+ */
+ public T getValue() {
+ return value;
+ }
+
+ @Override
+ public String toDebugString() {
+ return super.toDebugString() + getValue();
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideHandler.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideHandler.java
new file mode 100644
index 00000000..78f84b8a
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideHandler.java
@@ -0,0 +1,38 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.EventHandler;
+
+/**
+ * Handler interface for {@link SlideEvent} events.
+ *
+ * @param slider value type
+ */
+public interface SlideHandler extends EventHandler {
+
+ /**
+ * Called when {@link SlideEvent} is fired.
+ *
+ * @param event the {@link SlideEvent} that was fired
+ */
+ void onSlide(SlideEvent event);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideStartEvent.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideStartEvent.java
new file mode 100644
index 00000000..40f76a33
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideStartEvent.java
@@ -0,0 +1,93 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.GwtEvent;
+
+/**
+ * The slide start event is fired when dragging starts.
+ *
+ * @param slider value type
+ */
+public class SlideStartEvent extends GwtEvent> {
+
+ private static Type> TYPE;
+
+ private T value;
+
+ /**
+ * Fires a slide start event on all registered handlers in the handler
+ * manager. If no such handlers exist, this method will do nothing.
+ *
+ * @param source the source of the handlers
+ * @param value the new slider value
+ */
+ public static void fire(final HasSlideStartHandlers source, final T value) {
+ if (TYPE != null) {
+ SlideStartEvent event = new SlideStartEvent(value);
+ source.fireEvent(event);
+ }
+ }
+
+ /**
+ * Gets the type associated with this event.
+ *
+ * @return returns the handler type
+ */
+ public static Type> getType() {
+ if (TYPE == null) {
+ TYPE = new Type>();
+ }
+ return TYPE;
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public Type> getAssociatedType() {
+ return (Type)TYPE;
+ }
+
+ @Override
+ protected void dispatch(final SlideStartHandler handler) {
+ handler.onSlideStart(this);
+ }
+
+ /**
+ * Creates a slide start event.
+ *
+ * @param value the new slider value
+ */
+ protected SlideStartEvent(final T value) {
+ this.value = value;
+ }
+
+ /**
+ * @return the new slider value
+ */
+ public T getValue() {
+ return value;
+ }
+
+ @Override
+ public String toDebugString() {
+ return super.toDebugString() + getValue();
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideStartHandler.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideStartHandler.java
new file mode 100644
index 00000000..6c3ca084
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideStartHandler.java
@@ -0,0 +1,38 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.EventHandler;
+
+/**
+ * Handler interface for {@link SlideStartEvent} events.
+ *
+ * @param slider value type
+ */
+public interface SlideStartHandler extends EventHandler {
+
+ /**
+ * Called when {@link SlideStartEvent} is fired.
+ *
+ * @param event the {@link SlideStartEvent} that was fired
+ */
+ void onSlideStart(SlideStartEvent event);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideStopEvent.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideStopEvent.java
new file mode 100644
index 00000000..21cd1e8c
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideStopEvent.java
@@ -0,0 +1,93 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.GwtEvent;
+
+/**
+ * The slide stop event is fired when dragging stops or has been clicked on.
+ *
+ * @param slider value type
+ */
+public class SlideStopEvent extends GwtEvent> {
+
+ private static Type> TYPE;
+
+ private T value;
+
+ /**
+ * Fires a slide stop event on all registered handlers in the handler
+ * manager. If no such handlers exist, this method will do nothing.
+ *
+ * @param source the source of the handlers
+ * @param value the new slider value
+ */
+ public static void fire(final HasSlideStopHandlers source, final T value) {
+ if (TYPE != null) {
+ SlideStopEvent event = new SlideStopEvent(value);
+ source.fireEvent(event);
+ }
+ }
+
+ /**
+ * Gets the type associated with this event.
+ *
+ * @return returns the handler type
+ */
+ public static Type> getType() {
+ if (TYPE == null) {
+ TYPE = new Type>();
+ }
+ return TYPE;
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public Type> getAssociatedType() {
+ return (Type) TYPE;
+ }
+
+ @Override
+ protected void dispatch(final SlideStopHandler handler) {
+ handler.onSlideStop(this);
+ }
+
+ /**
+ * Creates a slide stop event.
+ *
+ * @param value the new slider value
+ */
+ protected SlideStopEvent(final T value) {
+ this.value = value;
+ }
+
+ /**
+ * @return the new slider value
+ */
+ public T getValue() {
+ return value;
+ }
+
+ @Override
+ public String toDebugString() {
+ return super.toDebugString() + getValue();
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideStopHandler.java b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideStopHandler.java
new file mode 100644
index 00000000..71d5e7a2
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/slider/client/ui/base/event/SlideStopHandler.java
@@ -0,0 +1,38 @@
+package org.gwtbootstrap3.extras.slider.client.ui.base.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.EventHandler;
+
+/**
+ * Handler interface for {@link SlideStopEvent} events.
+ *
+ * @param slider value type
+ */
+public interface SlideStopHandler extends EventHandler {
+
+ /**
+ * Called when {@link SlideStopEvent} is fired.
+ *
+ * @param event the {@link SlideStopEvent} that was fired
+ */
+ void onSlideStop(SlideStopEvent event);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/summernote/client/SummernoteClientBundle.java b/src/main/java/org/gwtbootstrap3/extras/summernote/client/SummernoteClientBundle.java
index 97cfe64b..f98c928c 100644
--- a/src/main/java/org/gwtbootstrap3/extras/summernote/client/SummernoteClientBundle.java
+++ b/src/main/java/org/gwtbootstrap3/extras/summernote/client/SummernoteClientBundle.java
@@ -4,7 +4,7 @@
* #%L
* GwtBootstrap3
* %%
- * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,6 @@
public interface SummernoteClientBundle extends ClientBundle {
public static final SummernoteClientBundle INSTANCE = GWT.create(SummernoteClientBundle.class);
- @Source("resources/js/summernote-0.6.0.min.cache.js")
+ @Source("resources/js/summernote-0.6.2.min.cache.js")
TextResource summernote();
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/summernote/client/event/SummernoteOnPasteEvent.java b/src/main/java/org/gwtbootstrap3/extras/summernote/client/event/SummernoteOnPasteEvent.java
new file mode 100644
index 00000000..537d3395
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/summernote/client/event/SummernoteOnPasteEvent.java
@@ -0,0 +1,67 @@
+package org.gwtbootstrap3.extras.summernote.client.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.GwtEvent;
+import com.google.gwt.user.client.Event;
+import org.gwtbootstrap3.extras.summernote.client.ui.base.SummernoteBase;
+
+
+
+/**
+ * @author martin.matthias
+ */
+public class SummernoteOnPasteEvent extends GwtEvent implements SummernoteEvent {
+
+ private static final Type TYPE = new Type();
+
+ private final SummernoteBase summernote;
+ private final Event nativeEvent;
+
+ public static Type getType() {
+ return TYPE;
+ }
+
+ public SummernoteOnPasteEvent(final SummernoteBase summernote, final Event nativeEvent) {
+ this.summernote = summernote;
+ this.nativeEvent = nativeEvent;
+ }
+
+ @Override
+ public SummernoteBase getSummernote() {
+ return summernote;
+ }
+
+ @Override
+ public Event getNativeEvent() {
+ return nativeEvent;
+ }
+
+ @Override
+ public Type getAssociatedType() {
+ return TYPE;
+ }
+
+ @Override
+ protected void dispatch(final SummernoteOnPasteHandler handler) {
+ handler.onPaste(this);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/gwtbootstrap3/extras/summernote/client/event/SummernoteOnPasteHandler.java b/src/main/java/org/gwtbootstrap3/extras/summernote/client/event/SummernoteOnPasteHandler.java
new file mode 100644
index 00000000..a0938fee
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/summernote/client/event/SummernoteOnPasteHandler.java
@@ -0,0 +1,32 @@
+package org.gwtbootstrap3.extras.summernote.client.event;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.event.shared.EventHandler;
+
+
+
+/**
+ * @author martin.matthias
+ */
+public interface SummernoteOnPasteHandler extends EventHandler {
+ void onPaste(SummernoteOnPasteEvent event);
+}
\ No newline at end of file
diff --git a/src/main/java/org/gwtbootstrap3/extras/summernote/client/ui/base/SummernoteBase.java b/src/main/java/org/gwtbootstrap3/extras/summernote/client/ui/base/SummernoteBase.java
index 6c2336c5..0814ab4d 100644
--- a/src/main/java/org/gwtbootstrap3/extras/summernote/client/ui/base/SummernoteBase.java
+++ b/src/main/java/org/gwtbootstrap3/extras/summernote/client/ui/base/SummernoteBase.java
@@ -90,6 +90,10 @@ public HandlerRegistration addKeyUpHandler(final SummernoteOnKeyUpHandler handle
return addHandler(handler, SummernoteOnKeyUpEvent.getType());
}
+ public HandlerRegistration addPasteHandler(final SummernoteOnPasteHandler handler) {
+ return addHandler(handler, SummernoteOnPasteEvent.getType());
+ }
+
/**
* Gets the HTML code generated from the editor
*
@@ -173,6 +177,10 @@ protected void onKeyDown(final Event evt) {
fireEvent(new SummernoteOnKeyDownEvent(this, evt));
}
+ protected void onPaste(final Event evt) {
+ fireEvent(new SummernoteOnPasteEvent(this, evt));
+ }
+
private native void initialize(Element e, int height, boolean hasFocus, JavaScriptObject toolbar) /*-{
var target = this;
@@ -200,6 +208,9 @@ private native void initialize(Element e, int height, boolean hasFocus, JavaScri
},
onImageUpload: function (evt) {
target.@org.gwtbootstrap3.extras.summernote.client.ui.base.SummernoteBase::onImageUpload(Lcom/google/gwt/user/client/Event;)(evt);
+ },
+ onpaste: function (evt) {
+ target.@org.gwtbootstrap3.extras.summernote.client.ui.base.SummernoteBase::onPaste(Lcom/google/gwt/user/client/Event;)(evt);
}
});
}-*/;
@@ -214,6 +225,7 @@ private native void destroy(Element e) /*-{
$wnd.jQuery(e).off('onkeyup');
$wnd.jQuery(e).off('ononkeydowninit');
$wnd.jQuery(e).off('onImageUpload');
+ $wnd.jQuery(e).off('onpaste');
}-*/;
private native void setCode(Element e, String code) /*-{
diff --git a/src/main/java/org/gwtbootstrap3/extras/toggleswitch/client/ToggleSwitchClientBundle.java b/src/main/java/org/gwtbootstrap3/extras/toggleswitch/client/ToggleSwitchClientBundle.java
index b6c63657..d968c47f 100644
--- a/src/main/java/org/gwtbootstrap3/extras/toggleswitch/client/ToggleSwitchClientBundle.java
+++ b/src/main/java/org/gwtbootstrap3/extras/toggleswitch/client/ToggleSwitchClientBundle.java
@@ -31,6 +31,6 @@ interface ToggleSwitchClientBundle extends ClientBundle {
static final ToggleSwitchClientBundle INSTANCE = GWT.create(ToggleSwitchClientBundle.class);
- @Source("resource/js/bootstrap-switch-3.2.2.min.cache.js")
+ @Source("resource/js/bootstrap-switch-3.3.2.min.cache.js")
TextResource toggleswitch();
}
diff --git a/src/main/java/org/gwtbootstrap3/extras/toggleswitch/client/ui/base/ToggleSwitchBase.java b/src/main/java/org/gwtbootstrap3/extras/toggleswitch/client/ui/base/ToggleSwitchBase.java
index 1d261751..ca12601c 100644
--- a/src/main/java/org/gwtbootstrap3/extras/toggleswitch/client/ui/base/ToggleSwitchBase.java
+++ b/src/main/java/org/gwtbootstrap3/extras/toggleswitch/client/ui/base/ToggleSwitchBase.java
@@ -4,7 +4,7 @@
* #%L
* GwtBootstrap3
* %%
- * Copyright (C) 2013 GwtBootstrap3
+ * Copyright (C) 2013 - 2015 GwtBootstrap3
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
* #L%
*/
-import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.Element;
import com.google.gwt.editor.client.IsEditor;
import com.google.gwt.editor.client.LeafValueEditor;
@@ -196,36 +195,28 @@ public HandlerRegistration addValueChangeHandler(final ValueChangeHandler
+ */
+public interface TypeaheadClientBundle extends ClientBundle {
+ static final TypeaheadClientBundle INSTANCE = GWT.create(TypeaheadClientBundle.class);
+
+ @ClientBundle.Source("resource/js/typeahead.jquery-0.10.5.min.cache.js")
+ TextResource typeahead();
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/typeahead/client/TypeaheadEntryPoint.java b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/TypeaheadEntryPoint.java
new file mode 100644
index 00000000..936e81a7
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/TypeaheadEntryPoint.java
@@ -0,0 +1,37 @@
+package org.gwtbootstrap3.extras.typeahead.client;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.core.client.ScriptInjector;
+
+/**
+ * @author Florian Kremser
+ */
+public class TypeaheadEntryPoint implements EntryPoint {
+
+ @Override
+ public void onModuleLoad() {
+ ScriptInjector.fromString(TypeaheadClientBundle.INSTANCE.typeahead().getText())
+ .setWindow(ScriptInjector.TOP_WINDOW)
+ .inject();
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/CollectionDataset.java b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/CollectionDataset.java
new file mode 100644
index 00000000..c44431e9
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/CollectionDataset.java
@@ -0,0 +1,73 @@
+package org.gwtbootstrap3.extras.typeahead.client.base;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * A Dataset operating on a collection of values.
+ *
+ * @author Florian Kremser
+ */
+public class CollectionDataset extends Dataset {
+ private Collection data;
+
+ public CollectionDataset(final Collection data) {
+ setData(data);
+ }
+
+ public Collection getData() {
+ return data;
+ }
+
+ public void setData(final Collection data) {
+ this.data = data;
+ }
+
+ /**
+ * Return the (display) value associated with a particular datum. If the
+ * given datum is selected from the suggestions, then value will be set as
+ * text of the input.
+ *
+ * @param datum a datum instance from this {@link Dataset}
+ * @return the text representing the data
+ */
+ public String getValue(final T datum) {
+ return datum != null ? datum.toString() : "";
+ }
+
+ @Override
+ public void findMatches(final String query, final SuggestionCallback callback) {
+ String queryLower = query.toLowerCase();
+ Collection> suggestions = new ArrayList>();
+ if (data != null) {
+ for (T datum : data) {
+ String value = getValue(datum);
+ if (value.toLowerCase().contains(queryLower)) {
+ Suggestion suggestion = Suggestion.create(value, datum, this);
+ suggestions.add(suggestion);
+ }
+ }
+ }
+ callback.execute(suggestions);
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/Dataset.java b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/Dataset.java
new file mode 100644
index 00000000..231a9bbe
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/Dataset.java
@@ -0,0 +1,125 @@
+package org.gwtbootstrap3.extras.typeahead.client.base;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+
+/**
+ * A Dataset represents a collection of suggestion objects for a Typeahead.
+ * A Typeahead is composed of one or more Datasets. When an end-user modifies
+ * the value of a Typeahead, each Dataset will attempt to render suggestions
+ * for the new value.
+ *
+ * @author Florian Kremser
+ */
+public abstract class Dataset {
+ private static long nextId = 0;
+ private String name;
+ private Template emptyTemplate;
+ private Template footerTemplate;
+ private Template headerTemplate;
+ private SuggestionTemplate suggestionTemplate;
+
+ protected Dataset() {
+ this.name = "dataset" + nextId++;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Rendered when 0 suggestions are available for the given query.
+ *
+ * @return a template to render in case of 0 results
+ */
+ public Template getEmptyTemplate() {
+ return emptyTemplate;
+ }
+
+ public void setEmptyTemplate(final Template emptyTemplate) {
+ this.emptyTemplate = emptyTemplate;
+ }
+
+ /**
+ * Rendered at the bottom of the dataset.
+ *
+ * @return a template to render at the bottom of the dataset
+ */
+ public Template getFooterTemplate() {
+ return footerTemplate;
+ }
+
+ public void setFooterTemplate(final Template footerTemplate) {
+ this.footerTemplate = footerTemplate;
+ }
+
+ /**
+ * Rendered at the top of the dataset.
+ *
+ * @return a template to render at the top of the dataset
+ */
+ public Template getHeaderTemplate() {
+ return headerTemplate;
+ }
+
+ public void setHeaderTemplate(final Template headerTemplate) {
+ this.headerTemplate = headerTemplate;
+ }
+
+ /**
+ * Renders a single suggestion.
+ *
+ * @return a template for rendering suggestions
+ */
+ public SuggestionTemplate getSuggestionTemplate() {
+ return suggestionTemplate;
+ }
+
+ public void setSuggestionTemplate(final SuggestionTemplate suggestionTemplate) {
+ this.suggestionTemplate = suggestionTemplate;
+ }
+
+ /**
+ * Find all Suggestions matching a search query and pass them to the callback.
+ *
+ * @param query the user input
+ * @param callback callback for suggestions
+ */
+ public abstract void findMatches(final String query, final SuggestionCallback callback);
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Dataset> dataset = (Dataset>) o;
+ if (name != null ? !name.equals(dataset.name) : dataset.name != null) return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return name != null ? name.hashCode() : 0;
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/StringDataset.java b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/StringDataset.java
new file mode 100644
index 00000000..76456c51
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/StringDataset.java
@@ -0,0 +1,34 @@
+package org.gwtbootstrap3.extras.typeahead.client.base;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+
+import java.util.Collection;
+
+/**
+ * @author Florian Kremser
+ */
+public class StringDataset extends CollectionDataset {
+
+ public StringDataset(final Collection data) {
+ super(data);
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/Suggestion.java b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/Suggestion.java
new file mode 100644
index 00000000..b764f4a2
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/Suggestion.java
@@ -0,0 +1,58 @@
+package org.gwtbootstrap3.extras.typeahead.client.base;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+
+import com.google.gwt.core.client.JavaScriptObject;
+
+/**
+ * @author Florian Kremser
+ */
+public final class Suggestion extends JavaScriptObject {
+
+ protected Suggestion() {
+ }
+
+ public native String getValue() /*-{
+ return this.value;
+ }-*/;
+
+ public native T getData() /*-{
+ return this.data;
+ }-*/;
+
+ public native Dataset getDataset() /*-{
+ return this.dataset;
+ }-*/;
+
+ /**
+ * Create a suggestion for a data instance.
+ *
+ * @param value the display value that represents the suggestion's data
+ * @param data the suggestions data
+ * @param dataset the source dataset
+ * @param the type of the data
+ * @return a Suggestion object
+ */
+ public static native Suggestion create(String value, T data, Dataset dataset) /*-{
+ return { value: value, data: data, dataset: dataset };
+ }-*/;
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/SuggestionCallback.java b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/SuggestionCallback.java
new file mode 100644
index 00000000..33c1d074
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/SuggestionCallback.java
@@ -0,0 +1,53 @@
+package org.gwtbootstrap3.extras.typeahead.client.base;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.core.client.JsArray;
+import com.google.gwt.core.client.JsArrayString;
+
+import java.util.Collection;
+
+/**
+ * @author Florian Kremser
+ */
+public class SuggestionCallback {
+ private final JavaScriptObject jsCallback;
+
+ public SuggestionCallback(final JavaScriptObject jsCallback) {
+ this.jsCallback = jsCallback;
+ }
+
+ public void execute(final Collection> suggestions) {
+ JsArray> jsArray = JsArrayString.createArray().cast();
+ if (suggestions != null) {
+ for (Suggestion s : suggestions) {
+ jsArray.push(s);
+ }
+ }
+ invokeCallback(jsCallback, jsArray);
+ }
+
+ private native void invokeCallback(JavaScriptObject callback, JsArray> matches) /*-{
+ callback(matches);
+ }-*/;
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/SuggestionTemplate.java b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/SuggestionTemplate.java
new file mode 100644
index 00000000..dca08107
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/SuggestionTemplate.java
@@ -0,0 +1,29 @@
+package org.gwtbootstrap3.extras.typeahead.client.base;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+
+/**
+ * @author Florian Kremser
+ */
+public interface SuggestionTemplate {
+ String render(Suggestion suggestion);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/Template.java b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/Template.java
new file mode 100644
index 00000000..5e0a2bc2
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/base/Template.java
@@ -0,0 +1,31 @@
+package org.gwtbootstrap3.extras.typeahead.client.base;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+
+/**
+ * A template for rendering components of a Dataset.
+ *
+ * @author Florian Kremser
+ */
+public interface Template {
+ String render();
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadAutoCompletedEvent.java b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadAutoCompletedEvent.java
new file mode 100644
index 00000000..85dc79c0
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadAutoCompletedEvent.java
@@ -0,0 +1,79 @@
+package org.gwtbootstrap3.extras.typeahead.client.events;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+
+import com.google.gwt.event.shared.GwtEvent;
+import com.google.gwt.user.client.Event;
+import org.gwtbootstrap3.extras.typeahead.client.base.Suggestion;
+import org.gwtbootstrap3.extras.typeahead.client.ui.Typeahead;
+
+/**
+ * Triggered when the query is autocompleted. Autocompleted means the query was changed to the hint.
+ *
+ * @author Florian Kremser
+ */
+public class TypeaheadAutoCompletedEvent extends GwtEvent> {
+
+ public static void fire(final Typeahead source, final Suggestion suggestion, final Event nativeEvent) {
+ TypeaheadAutoCompletedEvent event = new TypeaheadAutoCompletedEvent(source, suggestion, nativeEvent);
+ source.fireEvent(event);
+ }
+
+ private static final Type> TYPE = new Type>();
+
+ private final Typeahead typeahead;
+ private final Suggestion suggestion;
+ private final Event nativeEvent;
+
+ public static Type> getType() {
+ return TYPE;
+ }
+
+ private TypeaheadAutoCompletedEvent(final Typeahead typeahead, final Suggestion suggestion, final Event nativeEvent) {
+ this.typeahead = typeahead;
+ this.suggestion = suggestion;
+ this.nativeEvent = nativeEvent;
+ }
+
+ public Typeahead getTypeahead() {
+ return typeahead;
+ }
+
+ public Suggestion getSuggestion() {
+ return suggestion;
+ }
+
+ public Event getNativeEvent() {
+ return nativeEvent;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ @Override
+ public Type> getAssociatedType() {
+ return (Type) TYPE;
+ }
+
+ @Override
+ protected void dispatch(final TypeaheadAutoCompletedHandler handler) {
+ handler.onAutoCompleted(this);
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadAutoCompletedHandler.java b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadAutoCompletedHandler.java
new file mode 100644
index 00000000..d10aabb4
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadAutoCompletedHandler.java
@@ -0,0 +1,31 @@
+package org.gwtbootstrap3.extras.typeahead.client.events;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+
+import com.google.gwt.event.shared.EventHandler;
+
+/**
+ * @author Florian Kremser
+ */
+public interface TypeaheadAutoCompletedHandler extends EventHandler {
+ void onAutoCompleted(TypeaheadAutoCompletedEvent event);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadClosedEvent.java b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadClosedEvent.java
new file mode 100644
index 00000000..3fcea3d9
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadClosedEvent.java
@@ -0,0 +1,72 @@
+package org.gwtbootstrap3.extras.typeahead.client.events;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+
+import com.google.gwt.event.shared.GwtEvent;
+import com.google.gwt.user.client.Event;
+import org.gwtbootstrap3.extras.typeahead.client.ui.Typeahead;
+
+/**
+ * Triggered when the dropdown menu of the typeahead is closed.
+ *
+ * @author Florian Kremser
+ */
+public class TypeaheadClosedEvent extends GwtEvent> {
+
+ public static void fire(final Typeahead source, final Event nativeEvent) {
+ TypeaheadClosedEvent event = new TypeaheadClosedEvent(source, nativeEvent);
+ source.fireEvent(event);
+ }
+
+ private static final Type> TYPE = new Type>();
+
+ private final Typeahead typeahead;
+ private final Event nativeEvent;
+
+ public static Type> getType() {
+ return TYPE;
+ }
+
+ private TypeaheadClosedEvent(final Typeahead typeahead, final Event nativeEvent) {
+ this.typeahead = typeahead;
+ this.nativeEvent = nativeEvent;
+ }
+
+ public Typeahead getTypeahead() {
+ return typeahead;
+ }
+
+ public Event getNativeEvent() {
+ return nativeEvent;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ @Override
+ public Type> getAssociatedType() {
+ return (Type) TYPE;
+ }
+
+ @Override
+ protected void dispatch(final TypeaheadClosedHandler handler) {
+ handler.onClosed(this);
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadClosedHandler.java b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadClosedHandler.java
new file mode 100644
index 00000000..f49c5b15
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadClosedHandler.java
@@ -0,0 +1,31 @@
+package org.gwtbootstrap3.extras.typeahead.client.events;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+
+import com.google.gwt.event.shared.EventHandler;
+
+/**
+ * @author Florian Kremser
+ */
+public interface TypeaheadClosedHandler extends EventHandler {
+ void onClosed(TypeaheadClosedEvent event);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadCursorChangedEvent.java b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadCursorChangedEvent.java
new file mode 100644
index 00000000..8da09644
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadCursorChangedEvent.java
@@ -0,0 +1,79 @@
+package org.gwtbootstrap3.extras.typeahead.client.events;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+
+import com.google.gwt.event.shared.GwtEvent;
+import com.google.gwt.user.client.Event;
+import org.gwtbootstrap3.extras.typeahead.client.base.Suggestion;
+import org.gwtbootstrap3.extras.typeahead.client.ui.Typeahead;
+
+/**
+ * Triggered when the dropdown menu cursor is moved to a different suggestion.
+ *
+ * @author Florian Kremser
+ */
+public class TypeaheadCursorChangedEvent extends GwtEvent> {
+
+ public static void fire(final Typeahead source, final Suggestion suggestion, final Event nativeEvent) {
+ TypeaheadCursorChangedEvent event = new TypeaheadCursorChangedEvent(source, suggestion, nativeEvent);
+ source.fireEvent(event);
+ }
+
+ private static final Type> TYPE = new Type>();
+
+ private final Typeahead typeahead;
+ private final Suggestion suggestion;
+ private final Event nativeEvent;
+
+ public static Type> getType() {
+ return TYPE;
+ }
+
+ private TypeaheadCursorChangedEvent(final Typeahead typeahead, final Suggestion suggestion, final Event nativeEvent) {
+ this.typeahead = typeahead;
+ this.suggestion = suggestion;
+ this.nativeEvent = nativeEvent;
+ }
+
+ public Typeahead getTypeahead() {
+ return typeahead;
+ }
+
+ public Suggestion getSuggestion() {
+ return suggestion;
+ }
+
+ public Event getNativeEvent() {
+ return nativeEvent;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ @Override
+ public Type> getAssociatedType() {
+ return (Type) TYPE;
+ }
+
+ @Override
+ protected void dispatch(final TypeaheadCursorChangedHandler handler) {
+ handler.onCursorChanged(this);
+ }
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadCursorChangedHandler.java b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadCursorChangedHandler.java
new file mode 100644
index 00000000..beb5f455
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadCursorChangedHandler.java
@@ -0,0 +1,31 @@
+package org.gwtbootstrap3.extras.typeahead.client.events;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+
+import com.google.gwt.event.shared.EventHandler;
+
+/**
+ * @author Florian Kremser
+ */
+public interface TypeaheadCursorChangedHandler extends EventHandler {
+ void onCursorChanged(TypeaheadCursorChangedEvent event);
+}
diff --git a/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadOpenedEvent.java b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadOpenedEvent.java
new file mode 100644
index 00000000..350b55e6
--- /dev/null
+++ b/src/main/java/org/gwtbootstrap3/extras/typeahead/client/events/TypeaheadOpenedEvent.java
@@ -0,0 +1,72 @@
+package org.gwtbootstrap3.extras.typeahead.client.events;
+
+/*
+ * #%L
+ * GwtBootstrap3
+ * %%
+ * Copyright (C) 2013 - 2014 GwtBootstrap3
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+
+import com.google.gwt.event.shared.GwtEvent;
+import com.google.gwt.user.client.Event;
+import org.gwtbootstrap3.extras.typeahead.client.ui.Typeahead;
+
+/**
+ * Triggered when the dropdown menu of the typeahead is opened.
+ *
+ * @author Florian Kremser
+ */
+public class TypeaheadOpenedEvent extends GwtEvent