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

Commit

Permalink
FullCalendar support for select and unselect callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
koljascasino authored and koljascasino committed Apr 6, 2015
1 parent 6c3f1cb commit e0c56bf
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -209,6 +218,7 @@ public JsArray<JavaScriptObject> getJavaScriptParameters() {
setParameter(params, getDayNames());
setParameter(params, getDragResizeConfig());
setParameter(params, getClickHoverConfig());
setParameter(params, getSelectConfig());
setParameter(params, getEventConfig());
setParameter(params, getColumnFormat());
setParameter(params, getTimeFormat());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ public void setStart(final Date d) {
}

private native void setStart(String start) /*-{
var theInstance = this;
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;
}-*/;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}-*/;
}
Original file line number Diff line number Diff line change
@@ -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 <code>JavaScriptObject</code>
*
* @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;
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
<module>
<inherits name="com.google.gwt.user.User"/>
<source path="client"/>
<entry-point class="org.gwtbootstrap3.extras.fullcalendar.client.FullCalendarEntryPoint"/>
</module>

0 comments on commit e0c56bf

Please sign in to comment.