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

Commit 5218469

Browse files
committed
Merge pull request #167 from koljascasino/master
FullCalendar support for select and unselect callbacks
2 parents 6c3f1cb + d3fa7db commit 5218469

File tree

6 files changed

+118
-0
lines changed

6 files changed

+118
-0
lines changed

src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/CalendarConfig.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class CalendarConfig {
3333
private Language langauge;//http://arshaw.com/fullcalendar/docs/text/lang/
3434

3535
private ClickAndHoverConfig clickHoverConfig;//http://arshaw.com/fullcalendar/docs/mouse/
36+
private SelectConfig selectConfig;//http://arshaw.com/fullcalendar/docs/selection/
3637
private DragAndResizeConfig dragResizeConfig;//http://arshaw.com/fullcalendar/docs/event_ui/;
3738
private EventDataConfig eventConfig;//http://arshaw.com/fullcalendar/docs/event_data/
3839
private GeneralDisplay generalDisplay;//http://arshaw.com/fullcalendar/docs/display/
@@ -171,6 +172,14 @@ public ClickAndHoverConfig getClickHoverConfig() {
171172
public void setClickHoverConfig(final ClickAndHoverConfig clickHoverConfig) {
172173
this.clickHoverConfig = clickHoverConfig;
173174
}
175+
176+
public SelectConfig getSelectConfig() {
177+
return selectConfig;
178+
}
179+
180+
public void setSelectConfig(final SelectConfig selectConfig) {
181+
this.selectConfig = selectConfig;
182+
}
174183

175184
public DragAndResizeConfig getDragResizeConfig() {
176185
return dragResizeConfig;
@@ -209,6 +218,7 @@ public JsArray<JavaScriptObject> getJavaScriptParameters() {
209218
setParameter(params, getDayNames());
210219
setParameter(params, getDragResizeConfig());
211220
setParameter(params, getClickHoverConfig());
221+
setParameter(params, getSelectConfig());
212222
setParameter(params, getEventConfig());
213223
setParameter(params, getColumnFormat());
214224
setParameter(params, getTimeFormat());

src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/Event.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ private native void setStart(String start) /*-{
9797
theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.Event::event.start = start;
9898
}-*/;
9999

100+
public native void setStart(final JavaScriptObject start) /*-{
101+
var theInstance = this;
102+
theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.Event::event.start = start;
103+
}-*/;
104+
100105
public native JsDate getStart() /*-{
101106
var theInstance = this;
102107
if (theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.Event::event.start) {
@@ -135,6 +140,11 @@ private native void setEnd(String end) /*-{
135140
theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.Event::event.end = end;
136141
}-*/;
137142

143+
public native void setEnd(final JavaScriptObject end) /*-{
144+
var theInstance = this;
145+
theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.Event::event.end = end;
146+
}-*/;
147+
138148
public native JsDate getEnd() /*-{
139149
var theInstance = this;
140150
if (theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.Event::event.end) {

src/main/java/org/gwtbootstrap3/extras/fullcalendar/client/ui/FullCalendar.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,4 +373,12 @@ private native void setAspectRatio(String id, double ratio) /*-{
373373
public native void excecuteFunction(JavaScriptObject revertFunction)/*-{
374374
revertFunction();
375375
}-*/;
376+
377+
public void unselect() {
378+
unselect(getElement().getId());
379+
}
380+
381+
private native void unselect(String id) /*-{
382+
$wnd.jQuery('#' + id).fullCalendar('unselect');
383+
}-*/;
376384
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package org.gwtbootstrap3.extras.fullcalendar.client.ui;
2+
3+
/*
4+
* #%L
5+
* GwtBootstrap3
6+
* %%
7+
* Copyright (C) 2013 - 2015 GwtBootstrap3
8+
* %%
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
* #L%
21+
*/
22+
23+
import com.google.gwt.core.client.JavaScriptObject;
24+
25+
/**
26+
* Wraps selection events inside a <code>JavaScriptObject</code>
27+
*
28+
* @see http://fullcalendar.io/docs/selection/
29+
*/
30+
public class SelectConfig implements IsJavaScriptObject {
31+
private JavaScriptObject script;
32+
33+
public SelectConfig(final SelectEventCallback handler) {
34+
if (handler != null) {
35+
newInstance(handler);
36+
}
37+
}
38+
39+
private native void newInstance(SelectEventCallback handler) /*-{
40+
var theInstance = this;
41+
var mouseHandler = handler;
42+
theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.SelectConfig::script = {};
43+
theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.SelectConfig::script.select = function (start, end, jsEvent, view) {
44+
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);
45+
};
46+
theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.SelectConfig::script.unselect = function (view, jsEvent) {
47+
mouseHandler.@org.gwtbootstrap3.extras.fullcalendar.client.ui.SelectEventCallback::unselect(Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/dom/client/NativeEvent;)(view, jsEvent);
48+
};
49+
}-*/;
50+
51+
@Override
52+
public JavaScriptObject toJavaScript() {
53+
return script;
54+
}
55+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.gwtbootstrap3.extras.fullcalendar.client.ui;
2+
3+
/*
4+
* #%L
5+
* GwtBootstrap3
6+
* %%
7+
* Copyright (C) 2013 - 2015 GwtBootstrap3
8+
* %%
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
* #L%
21+
*/
22+
23+
import com.google.gwt.core.client.JavaScriptObject;
24+
import com.google.gwt.dom.client.NativeEvent;
25+
26+
/**
27+
* Selection callback interface
28+
*
29+
*/
30+
public interface SelectEventCallback {
31+
public void select(JavaScriptObject start, JavaScriptObject end, NativeEvent event, JavaScriptObject viewObject);
32+
33+
public void unselect(JavaScriptObject viewObject, NativeEvent event);
34+
}

src/main/resources/org/gwtbootstrap3/extras/fullcalendar/FullCalendar.gwt.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@
2424
<module>
2525
<inherits name="com.google.gwt.user.User"/>
2626
<source path="client"/>
27+
<entry-point class="org.gwtbootstrap3.extras.fullcalendar.client.FullCalendarEntryPoint"/>
2728
</module>

0 commit comments

Comments
 (0)