[kune-commits] r1750 - in trunk: . img src/main/java/cc/kune/chat/client/actions src/main/java/cc/kune/common/client/ui/dialogs src/main/java/cc/kune/common/client/utils src/main/java/cc/kune/common/shared/res src/main/java/cc/kune/common/shared/utils src/main/java/cc/kune/core/server src/main/java/cc/kune/core/server/content src/main/java/cc/kune/core/server/manager/file src/main/java/cc/kune/core/server/state src/main/java/cc/kune/core/shared src/main/java/cc/kune/events/client src/main/java/cc/kune/events/client/actions src/main/java/cc/kune/events/client/viewer src/main/java/cc/kune/events/server src/main/java/cc/kune/events/server/utils src/main/java/cc/kune/events/shared src/main/java/cc/kune/lists/client/actions src/test/java/cc/kune/events/server src/test/java/cc/kune/events/server/utils src/test/java/cc/kune/events/shared
Vicente J. Ruiz Jurado
vjrj_ at ourproject.org
Fri Mar 9 02:22:14 CET 2012
Author: vjrj_
Date: 2012-03-09 02:22:13 +0100 (Fri, 09 Mar 2012)
New Revision: 1750
Added:
trunk/img/kunecc-avatar.png
trunk/img/kunecc-background.png
trunk/src/main/java/cc/kune/common/shared/utils/DateFormatConstants.java
trunk/src/main/java/cc/kune/events/client/actions/ExportCalendarMenuItem.java
trunk/src/main/java/cc/kune/events/server/EventsServlet.java
trunk/src/main/java/cc/kune/events/server/utils/
trunk/src/main/java/cc/kune/events/server/utils/DateUtils.java
trunk/src/main/java/cc/kune/events/server/utils/DateUtilsTest.java
trunk/src/main/java/cc/kune/events/server/utils/EventsServerConversionUtil.java
trunk/src/test/java/cc/kune/events/server/utils/
trunk/src/test/java/cc/kune/events/server/utils/BasicCalendarTest.java
trunk/src/test/java/cc/kune/events/server/utils/EventsServerConversionUtilTest.java
Removed:
trunk/src/main/java/cc/kune/events/server/CalendarServerUtils.java
trunk/src/test/java/cc/kune/events/server/CalendarServerUtilsTest.java
trunk/src/test/java/cc/kune/events/shared/BasicCalendarTest.java
trunk/src/test/java/cc/kune/events/shared/EventsServerConversionUtilTest.java
Modified:
trunk/img/kune-logos.svg
trunk/pom.xml
trunk/src/main/java/cc/kune/chat/client/actions/NewRoomBtn.java
trunk/src/main/java/cc/kune/common/client/ui/dialogs/PromptTopDialog.java
trunk/src/main/java/cc/kune/common/client/utils/DateUtils.java
trunk/src/main/java/cc/kune/common/shared/res/ICalConstants.java
trunk/src/main/java/cc/kune/core/server/KuneRackModule.java
trunk/src/main/java/cc/kune/core/server/content/ContainerManager.java
trunk/src/main/java/cc/kune/core/server/manager/file/EntityBackgroundDownloadManager.java
trunk/src/main/java/cc/kune/core/server/manager/file/EntityLogoDownloadManager.java
trunk/src/main/java/cc/kune/core/server/manager/file/FileDownloadManager.java
trunk/src/main/java/cc/kune/core/server/manager/file/FileDownloadManagerUtils.java
trunk/src/main/java/cc/kune/core/server/state/StateServiceDefault.java
trunk/src/main/java/cc/kune/core/shared/FileConstants.java
trunk/src/main/java/cc/kune/events/client/EventsClientTool.java
trunk/src/main/java/cc/kune/events/client/actions/EventAddMenuItem.java
trunk/src/main/java/cc/kune/events/client/actions/EventsClientActions.java
trunk/src/main/java/cc/kune/events/client/actions/NewMeetingBtn.java
trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPanel.java
trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java
trunk/src/main/java/cc/kune/events/shared/EventsClientConversionUtil.java
trunk/src/main/java/cc/kune/events/shared/EventsSharedConversionUtil.java
trunk/src/main/java/cc/kune/lists/client/actions/NewListAction.java
trunk/src/main/java/cc/kune/lists/client/actions/NewListPostAction.java
Log:
CLOSED - # 158: Add a Calendar view to event tool
http://kune.ourproject.org/issues/ticket/158
Modified: trunk/img/kune-logos.svg
===================================================================
--- trunk/img/kune-logos.svg 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/img/kune-logos.svg 2012-03-09 01:22:13 UTC (rev 1750)
@@ -57,15 +57,15 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="1"
- inkscape:cx="518.29119"
- inkscape:cy="649.99995"
+ inkscape:zoom="1.27"
+ inkscape:cx="372.04724"
+ inkscape:cy="526.18109"
inkscape:document-units="px"
inkscape:current-layer="layer1"
inkscape:window-width="1078"
inkscape:window-height="1867"
- inkscape:window-x="1"
- inkscape:window-y="52"
+ inkscape:window-x="0"
+ inkscape:window-y="24"
showguides="true"
inkscape:guide-bbox="true"
inkscape:guide-points="true"
@@ -807,5 +807,113 @@
id="path4197"
transform="matrix(0.240856,0.12287,-0.12287,0.240856,101.5762,778.871)" />
</g>
+ <text
+ xml:space="preserve"
+ style="font-size:12px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:125%;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#a56941;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:4;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Ubuntu;-inkscape-font-specification:Ubuntu Bold"
+ x="613"
+ y="545.36218"
+ id="text3299"
+ sodipodi:linespacing="125%"><tspan
+ sodipodi:role="line"
+ id="tspan3301"
+ x="613"
+ y="545.36218"
+ style="font-size:46px;fill:#a56941;fill-opacity:1">kune</tspan></text>
+ <g
+ id="g3393"
+ inkscape:export-filename="/home/vjrj/proyectos/dev/kune/trunk/img/kunecc-avatar.png"
+ inkscape:export-xdpi="90.000046"
+ inkscape:export-ydpi="90.000046">
+ <rect
+ y="501.61716"
+ x="544.79126"
+ height="60"
+ width="60"
+ id="rect3297"
+ style="color:#000000;fill:none;stroke:none;stroke-width:0.98360658;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <g
+ id="g3384">
+ <path
+ style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;opacity:0.11000001;color:#000000;fill:#dd8a3d;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:12.30341816;marker:none;visibility:visible;display:block;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans"
+ d="m 551.98038,509.70847 a 4.489481,4.489481 0 0 0 -1.91552,8.52862 l 10.07928,5.13085 -4.72039,9.23554 a 4.4894802,4.4894802 0 0 0 -0.25084,0.50168 l -7.06917,13.81909 a 4.4924325,4.4924325 0 1 0 8.00413,4.08188 l 5.10804,-10.01086 9.646,4.90281 a 4.4924325,4.4924325 0 0 0 0.0228,0.0228 l 13.97872,7.11478 a 4.4924325,4.4924325 0 1 0 4.08188,-8.00413 l -10.07928,-5.13085 4.33272,-8.50582 a 4.4894789,4.4894789 0 0 0 1.09458,-2.16636 l 6.6131,-12.92974 a 4.4894795,4.4894795 0 0 0 -4.17309,-6.56749 4.4894795,4.4894795 0 0 0 -3.83104,2.48561 l -5.10805,10.01086 -0.72972,-0.38766 a 4.4894789,4.4894789 0 0 0 -0.72972,-0.29645 4.4894789,4.4894789 0 0 0 -0.11402,-0.0456 l -7.16038,-3.67141 a 4.4894799,4.4894799 0 0 0 -1.68748,-0.84374 l -13.249,-6.74992 a 4.489481,4.489481 0 0 0 -2.14356,-0.52449 z m 16.16788,17.74135 5.54132,2.82767 -2.82767,5.54132 -5.54132,-2.82767 2.82767,-5.54132 z"
+ id="path3318"
+ inkscape:connector-curvature="0" />
+ <g
+ inkscape:export-ydpi="90"
+ inkscape:export-xdpi="90"
+ inkscape:export-filename="/home/vjrj/proyectos/ourproject.org/documentos/fsm-virtual/kune-ico.png"
+ transform="matrix(0.26464389,0,0,0.26430342,550.52866,280.17578)"
+ id="g3303">
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(0.240856,0.12287,-0.12287,0.240856,101.5762,778.871)"
+ id="path3306"
+ d="m 60.321717,411.99998 377.014613,0"
+ style="color:#000000;fill:#69312f;fill-opacity:1;fill-rule:nonzero;stroke:#dd8a3d;stroke-width:109.23953247;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker:none;visibility:visible;display:block" />
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(0.240856,0.12287,-0.12287,0.240856,101.5762,778.871)"
+ id="path3308"
+ d="m 252.61203,788.60332 0,-377.01178"
+ style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#ffdb6b;stroke-width:109.23950958;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker:none;visibility:visible;display:block" />
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(0.240856,0.12287,-0.12287,0.240856,101.5762,778.871)"
+ id="path3310"
+ d="m 252.86937,597.15755 377.0124,0"
+ style="color:#000000;fill:#69312f;fill-opacity:1;fill-rule:nonzero;stroke:#69312f;stroke-width:109.23951721;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker:none;visibility:visible;display:block" />
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(0.240856,0.12287,-0.12287,0.240856,101.5762,778.871)"
+ id="path3312"
+ d="m 437.45588,596.97447 0,-377.01491"
+ style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#cc6633;stroke-width:109.23950195;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker:none;visibility:visible;display:block" />
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(0.240856,0.12287,-0.12287,0.240856,101.5762,778.871)"
+ id="path3314"
+ d="m 372.87905,411.27704 64.93441,0"
+ style="color:#000000;fill:#69312f;fill-opacity:1;fill-rule:nonzero;stroke:#dd8a3d;stroke-width:109.23947906;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker:none;visibility:visible;display:block" />
+ </g>
+ </g>
+ </g>
+ <g
+ style="opacity:0.2"
+ inkscape:export-ydpi="1797.08"
+ inkscape:export-xdpi="1797.08"
+ inkscape:export-filename="/home/vjrj/proyectos/dev/kune/trunk/img/kunecc-background.png"
+ transform="matrix(0.41681287,0,0,0.41627661,518.36566,339.18061)"
+ id="g3338">
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(0.240856,0.12287,-0.12287,0.240856,101.5762,778.871)"
+ id="path3340"
+ d="m 60.321717,411.99998 377.014613,0"
+ style="color:#000000;fill:#69312f;fill-opacity:1;fill-rule:nonzero;stroke:#dd8a3d;stroke-width:109.23953247000000033;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker:none;visibility:visible;display:block" />
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(0.240856,0.12287,-0.12287,0.240856,101.5762,778.871)"
+ id="path3342"
+ d="m 252.61203,788.60332 0,-377.01178"
+ style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#ffdb6b;stroke-width:109.23950958000000355;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker:none;visibility:visible;display:block" />
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(0.240856,0.12287,-0.12287,0.240856,101.5762,778.871)"
+ id="path3344"
+ d="m 252.86937,597.15755 377.0124,0"
+ style="color:#000000;fill:#69312f;fill-opacity:1;fill-rule:nonzero;stroke:#69312f;stroke-width:109.23951720999998827;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker:none;visibility:visible;display:block" />
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(0.240856,0.12287,-0.12287,0.240856,101.5762,778.871)"
+ id="path3346"
+ d="m 437.45588,596.97447 0,-377.01491"
+ style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#cc6633;stroke-width:109.23950195000000463;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker:none;visibility:visible;display:block" />
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(0.240856,0.12287,-0.12287,0.240856,101.5762,778.871)"
+ id="path3348"
+ d="m 372.87905,411.27704 64.93441,0"
+ style="color:#000000;fill:#69312f;fill-opacity:1;fill-rule:nonzero;stroke:#dd8a3d;stroke-width:109.23947905999999364;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker:none;visibility:visible;display:block" />
+ </g>
</g>
</svg>
Added: trunk/img/kunecc-avatar.png
===================================================================
(Binary files differ)
Property changes on: trunk/img/kunecc-avatar.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/img/kunecc-background.png
===================================================================
(Binary files differ)
Property changes on: trunk/img/kunecc-background.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/pom.xml 2012-03-09 01:22:13 UTC (rev 1750)
@@ -523,41 +523,6 @@
</dependency>
<dependency>
<groupId>org.waveprotocol</groupId>
- <artifactId>gwt-util-src</artifactId>
- <version>${wiab.version}</version>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava-gwt</artifactId>
- <version>r09</version>
- </dependency>
- <dependency>
- <groupId>org.waveprotocol</groupId>
- <artifactId>box</artifactId>
- <version>${wiab.version}</version>
- </dependency>
- <dependency>
- <groupId>org.waveprotocol</groupId>
- <artifactId>box-src</artifactId>
- <version>${wiab.version}</version>
- </dependency>
- <dependency>
- <groupId>org.waveprotocol</groupId>
- <artifactId>model-src</artifactId>
- <version>${wiab.version}</version>
- </dependency>
- <dependency>
- <groupId>org.waveprotocol</groupId>
- <artifactId>client</artifactId>
- <version>${wiab.version}</version>
- </dependency>
- <dependency>
- <groupId>org.waveprotocol</groupId>
- <artifactId>client-src</artifactId>
- <version>${wiab.version}</version>
- </dependency>
- <dependency>
- <groupId>org.waveprotocol</groupId>
<artifactId>client-common</artifactId>
<version>${wiab.version}</version>
</dependency>
@@ -567,21 +532,6 @@
<version>${wiab.version}</version>
</dependency>
<dependency>
- <groupId>org.waveprotocol</groupId>
- <artifactId>waveinabox-server-0.3</artifactId>
- <version>${wiab.version}</version>
- </dependency>
- <dependency>
- <groupId>org.waveprotocol</groupId>
- <artifactId>proto-msg</artifactId>
- <version>${wiab.version}</version>
- </dependency>
- <dependency>
- <groupId>org.waveprotocol</groupId>
- <artifactId>gwt-util-src</artifactId>
- <version>${wiab.version}</version>
- </dependency>
- <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-gwt</artifactId>
<version>r09</version>
@@ -598,27 +548,27 @@
</dependency>
<dependency>
<groupId>org.waveprotocol</groupId>
- <artifactId>model-src</artifactId>
+ <artifactId>waveinabox-server-0.3</artifactId>
<version>${wiab.version}</version>
</dependency>
<dependency>
<groupId>org.waveprotocol</groupId>
- <artifactId>client</artifactId>
+ <artifactId>gwt-util-src</artifactId>
<version>${wiab.version}</version>
</dependency>
<dependency>
<groupId>org.waveprotocol</groupId>
- <artifactId>client-src</artifactId>
+ <artifactId>model-src</artifactId>
<version>${wiab.version}</version>
</dependency>
<dependency>
<groupId>org.waveprotocol</groupId>
- <artifactId>client-common</artifactId>
+ <artifactId>client</artifactId>
<version>${wiab.version}</version>
</dependency>
<dependency>
<groupId>org.waveprotocol</groupId>
- <artifactId>client-common-src</artifactId>
+ <artifactId>client-src</artifactId>
<version>${wiab.version}</version>
</dependency>
<dependency>
@@ -725,42 +675,42 @@
<version>1.0.2</version>
</dependency>
<!-- openfire auth integration -->
-<!-- <dependency> -->
-<!-- <groupId>org.igniterealtime</groupId> -->
-<!-- <artifactId>openfire</artifactId> -->
-<!-- <version>3.7.0</version> -->
-<!-- <scope>provided</scope> -->
-<!-- <exclusions> -->
-<!-- <exclusion> -->
-<!-- <groupId>org.eclipse.jetty</groupId> -->
-<!-- <artifactId>hibernate</artifactId> -->
-<!-- </exclusion> -->
-<!-- <exclusion> -->
-<!-- <groupId>org.slf4j</groupId> -->
-<!-- <artifactId>spi</artifactId> -->
-<!-- </exclusion> -->
-<!-- <exclusion> -->
-<!-- <groupId>org.slf4j</groupId> -->
-<!-- <artifactId>slf4j-api</artifactId> -->
-<!-- </exclusion> -->
-<!-- <exclusion> -->
-<!-- <groupId>org.slf4j</groupId> -->
-<!-- <artifactId>jcl-over-slf4j</artifactId> -->
-<!-- </exclusion> -->
-<!-- <exclusion> -->
-<!-- <groupId>org.slf4j</groupId> -->
-<!-- <artifactId>jcl-over-slf4j</artifactId> -->
-<!-- </exclusion> -->
-<!-- <exclusion> -->
-<!-- <groupId>org.apache</groupId> -->
-<!-- <artifactId>commons</artifactId> -->
-<!-- </exclusion> -->
-<!-- <exclusion> -->
-<!-- <groupId>org.apache.commons</groupId> -->
-<!-- <artifactId>logging</artifactId> -->
-<!-- </exclusion> -->
-<!-- </exclusions> -->
-<!-- </dependency> -->
+ <!-- <dependency> -->
+ <!-- <groupId>org.igniterealtime</groupId> -->
+ <!-- <artifactId>openfire</artifactId> -->
+ <!-- <version>3.7.0</version> -->
+ <!-- <scope>provided</scope> -->
+ <!-- <exclusions> -->
+ <!-- <exclusion> -->
+ <!-- <groupId>org.eclipse.jetty</groupId> -->
+ <!-- <artifactId>hibernate</artifactId> -->
+ <!-- </exclusion> -->
+ <!-- <exclusion> -->
+ <!-- <groupId>org.slf4j</groupId> -->
+ <!-- <artifactId>spi</artifactId> -->
+ <!-- </exclusion> -->
+ <!-- <exclusion> -->
+ <!-- <groupId>org.slf4j</groupId> -->
+ <!-- <artifactId>slf4j-api</artifactId> -->
+ <!-- </exclusion> -->
+ <!-- <exclusion> -->
+ <!-- <groupId>org.slf4j</groupId> -->
+ <!-- <artifactId>jcl-over-slf4j</artifactId> -->
+ <!-- </exclusion> -->
+ <!-- <exclusion> -->
+ <!-- <groupId>org.slf4j</groupId> -->
+ <!-- <artifactId>jcl-over-slf4j</artifactId> -->
+ <!-- </exclusion> -->
+ <!-- <exclusion> -->
+ <!-- <groupId>org.apache</groupId> -->
+ <!-- <artifactId>commons</artifactId> -->
+ <!-- </exclusion> -->
+ <!-- <exclusion> -->
+ <!-- <groupId>org.apache.commons</groupId> -->
+ <!-- <artifactId>logging</artifactId> -->
+ <!-- </exclusion> -->
+ <!-- </exclusions> -->
+ <!-- </dependency> -->
</dependencies>
<!-- <dependency> -->
<!-- <groupId>dom4j</groupId> -->
Modified: trunk/src/main/java/cc/kune/chat/client/actions/NewRoomBtn.java
===================================================================
--- trunk/src/main/java/cc/kune/chat/client/actions/NewRoomBtn.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/chat/client/actions/NewRoomBtn.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -24,6 +24,7 @@
import cc.kune.common.client.notify.NotifyUser;
import cc.kune.common.client.ui.dialogs.PromptTopDialog;
import cc.kune.common.client.ui.dialogs.PromptTopDialog.Builder;
+import cc.kune.common.client.ui.dialogs.PromptTopDialog.OnEnter;
import cc.kune.common.shared.i18n.I18nTranslationService;
import cc.kune.common.shared.utils.TextUtils;
import cc.kune.core.client.actions.RolAction;
@@ -50,6 +51,7 @@
private static final String ID = "k-nrbt-dialog";
private static final String TEXTBOX_ID = "k-nrbt-textbox";
private final Provider<ContentServiceAsync> contentService;
+ private PromptTopDialog diag;
private final I18nTranslationService i18n;
private final Session session;
private final StateManager stateManager;
@@ -67,7 +69,12 @@
@Override
public void actionPerformed(final ActionEvent event) {
final Builder builder = new PromptTopDialog.Builder(ID, i18n.t("Name of the new chatroom?"),
- false, true, i18n.getDirection());
+ false, true, i18n.getDirection(), new OnEnter() {
+ @Override
+ public void onEnter() {
+ doAction();
+ }
+ });
builder.width("200px").height("50px").firstButtonTitle(i18n.t("Create")).sndButtonTitle(
i18n.t("Cancel")).firstButtonId(CREATE_ID).sndButtonId(CANCEL_ID);
builder.regex(TextUtils.UNIX_NAME).regexText(
@@ -75,7 +82,7 @@
builder.minLength(3).maxLength(15).allowBlank(false).minLengthText(
CoreMessages.FIELD_MUST_BE_BETWEEN_3_AND_15_NO_CHARS).maxLengthText(
CoreMessages.FIELD_MUST_BE_BETWEEN_3_AND_15_NO_CHARS);
- final PromptTopDialog diag = builder.build();
+ diag = builder.build();
diag.showCentered();
diag.focusOnTextBox();
diag.getSecondBtn().addClickHandler(new ClickHandler() {
@@ -87,26 +94,30 @@
diag.getFirstBtn().addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
- if (diag.isValid()) {
- NotifyUser.showProgress();
- final String groupShortName = session.getCurrentState().getGroup().getShortName();
- final StateToken parentToken = session.getContainerState().getRootContainer().getStateToken();
- contentService.get().addRoom(session.getUserHash(), parentToken,
- groupShortName + "-" + diag.getTextFieldValue(),
- new AsyncCallbackSimple<StateContainerDTO>() {
- @Override
- public void onSuccess(final StateContainerDTO state) {
- stateManager.removeCache(parentToken);
- stateManager.setRetrievedStateAndGo(state);
- NotifyUser.hideProgress();
- NotifyUser.info(i18n.t("Chatroom created"));
- }
- });
- diag.hide();
- }
+ doAction();
}
});
}
+
+ private void doAction() {
+ if (diag.isValid()) {
+ NotifyUser.showProgress();
+ final String groupShortName = session.getCurrentState().getGroup().getShortName();
+ final StateToken parentToken = session.getContainerState().getRootContainer().getStateToken();
+ contentService.get().addRoom(session.getUserHash(), parentToken,
+ groupShortName + "-" + diag.getTextFieldValue(),
+ new AsyncCallbackSimple<StateContainerDTO>() {
+ @Override
+ public void onSuccess(final StateContainerDTO state) {
+ stateManager.removeCache(parentToken);
+ stateManager.setRetrievedStateAndGo(state);
+ NotifyUser.hideProgress();
+ NotifyUser.info(i18n.t("Chatroom created"));
+ }
+ });
+ diag.hide();
+ }
+ }
}
@Inject
Modified: trunk/src/main/java/cc/kune/common/client/ui/dialogs/PromptTopDialog.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/ui/dialogs/PromptTopDialog.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/common/client/ui/dialogs/PromptTopDialog.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -19,81 +19,204 @@
*/
package cc.kune.common.client.ui.dialogs;
+import com.extjs.gxt.ui.client.event.Events;
+import com.extjs.gxt.ui.client.event.FieldEvent;
+import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.google.gwt.i18n.client.HasDirection.Direction;
+/**
+ * The Class PromptTopDialog shows a top dialog with some textfield and two
+ * buttons
+ */
public class PromptTopDialog extends BasicTopDialog {
+ /**
+ * The Class Builder.
+ */
public static class Builder extends BasicTopDialog.Builder {
+ /** The allow blank. */
private boolean allowBlank = false;
+
+ /** The field width. */
private int fieldWidth;
+
+ /** The max length. */
private int maxLength = 0;
+
+ /** The max length text. */
private String maxLengthText;
+
+ /** The min length. */
private int minLength = 0;
+
+ /** The min length text. */
private String minLengthText;
+
+ /** The on enter. */
+ private final OnEnter onEnter;
+
+ /** The regex. */
private String regex;
+
+ /** The regex text. */
private String regexText;
+
+ /** The textbox id. */
private String textboxId;
+
+ /** The width. */
private int width = 0;
+ /**
+ * Instantiates a new builder.
+ *
+ * @param dialogId
+ * the dialog id (used for debuggin)
+ * @param promptText
+ * the prompt text
+ * @param autohide
+ * the autohide
+ * @param modal
+ * the modal
+ * @param direction
+ * the direction
+ * @param onEnter
+ * the on enter
+ */
public Builder(final String dialogId, final String promptText, final boolean autohide,
- final boolean modal, final Direction direction) {
+ final boolean modal, final Direction direction, final OnEnter onEnter) {
super(dialogId, autohide, modal, direction);
+ this.onEnter = onEnter;
super.title(promptText);
+ super.tabIndexStart(1);
}
+ /**
+ * Allow blank.
+ *
+ * @param allowBlank
+ * the allow blank
+ * @return the builder
+ */
public Builder allowBlank(final boolean allowBlank) {
this.allowBlank = allowBlank;
return this;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see cc.kune.common.client.ui.dialogs.BasicTopDialog.Builder#build()
+ */
@Override
public PromptTopDialog build() {
final PromptTopDialog dialog = new PromptTopDialog(this);
return dialog;
}
+ /**
+ * Field width.
+ *
+ * @param fieldWidth
+ * the field width
+ * @return the builder
+ */
public Builder fieldWidth(final int fieldWidth) {
this.fieldWidth = fieldWidth;
return this;
}
+ /**
+ * Max length.
+ *
+ * @param maxLength
+ * the max length
+ * @return the builder
+ */
public Builder maxLength(final int maxLength) {
this.maxLength = maxLength;
return this;
}
+ /**
+ * Max length text.
+ *
+ * @param maxLengthText
+ * the max length text
+ * @return the builder
+ */
public Builder maxLengthText(final String maxLengthText) {
this.maxLengthText = maxLengthText;
return this;
}
+ /**
+ * Min length.
+ *
+ * @param minLength
+ * the min length
+ * @return the builder
+ */
public Builder minLength(final int minLength) {
this.minLength = minLength;
return this;
}
+ /**
+ * Min length text.
+ *
+ * @param minLengthText
+ * the min length text
+ * @return the builder
+ */
public Builder minLengthText(final String minLengthText) {
this.minLengthText = minLengthText;
return this;
}
+ /**
+ * Regex.
+ *
+ * @param regex
+ * the regex
+ * @return the builder
+ */
public Builder regex(final String regex) {
this.regex = regex;
return this;
}
+ /**
+ * Regex text.
+ *
+ * @param regexText
+ * the regex text
+ * @return the builder
+ */
public Builder regexText(final String regexText) {
this.regexText = regexText;
return this;
}
+ /**
+ * Textbox id.
+ *
+ * @param textboxId
+ * the textbox id
+ * @return the builder
+ */
public Builder textboxId(final String textboxId) {
this.textboxId = textboxId;
return this;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see cc.kune.common.client.ui.dialogs.BasicTopDialog.Builder#width(int)
+ */
@Override
public Builder width(final int width) {
this.width = width;
@@ -101,8 +224,23 @@
}
}
+ public interface OnEnter {
+
+ /**
+ * On enter what to do
+ */
+ void onEnter();
+ }
+
+ /** The text field of the Prompt. */
private final TextField<String> textField;
+ /**
+ * Instantiates a new prompt top dialog.
+ *
+ * @param builder
+ * the builder
+ */
protected PromptTopDialog(final Builder builder) {
super(builder);
textField = new TextField<String>();
@@ -122,25 +260,55 @@
}
textField.setWidth(builder.fieldWidth);
textField.setAllowBlank(builder.allowBlank);
+ textField.addListener(Events.OnKeyPress, new Listener<FieldEvent>() {
+ @Override
+ public void handleEvent(final FieldEvent fe) {
+ if (fe.getEvent().getKeyCode() == 13) {
+ builder.onEnter.onEnter();
+ }
+ }
+ });
super.getInnerPanel().add(textField);
}
+ /**
+ * Clear text field value.
+ */
public void clearTextFieldValue() {
textField.reset();
}
+ /**
+ * Focus on text box.
+ */
public void focusOnTextBox() {
textField.focus();
}
+ /**
+ * Gets the text field value.
+ *
+ * @return the text field value
+ */
public String getTextFieldValue() {
return textField.getValue();
}
+ /**
+ * Checks if is valid.
+ *
+ * @return true, if is valid
+ */
public boolean isValid() {
return textField.isValid();
}
+ /**
+ * Sets the text field value.
+ *
+ * @param text
+ * the new text field value
+ */
public void setTextFieldValue(final String text) {
textField.setValue(text);
}
Modified: trunk/src/main/java/cc/kune/common/client/utils/DateUtils.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/utils/DateUtils.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/common/client/utils/DateUtils.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -2,33 +2,33 @@
import java.util.Date;
+import cc.kune.common.shared.utils.DateFormatConstants;
+
import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
/**
* The Class DateUtils try to follow ISO_8601 (previously RFC 2445 date-time
* formats).
*/
-public class DateUtils {
+public class DateUtils extends DateFormatConstants {
- private static DateTimeFormat iso_8601 = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601);
- // Sample DTSTART:19980118T230000
- private static DateTimeFormat rfcDateFormat = DateTimeFormat.getFormat("'DTSTART':yyyyMMdd'T'Hmmss");
+ private static final DateTimeFormat iso_8601 = DateTimeFormat.getFormat(DATE_EXPORT_FORMAT);
public static Date toDate(final String date) {
try {
return iso_8601.parse(date);
} catch (final IllegalArgumentException e) {
try {
- return rfcDateFormat.parse(date);
+ // try old (buggy) hour formats
+ // Sample DTSTART:19980118T230000
+ return DateTimeFormat.getFormat(OLD1_DATE_EXPORT_FORMAT).parse(date);
} catch (final IllegalArgumentException e1) {
- // try old (buggy) hour formats
// DTSTART:20120229T120000
try {
- return DateTimeFormat.getFormat("'DTSTART':yyyyMMdd'T'hhmmss").parse(date);
+ return DateTimeFormat.getFormat(OLD2_DATE_EXPORT_FORMAT).parse(date);
} catch (final IllegalArgumentException e2) {
// DTSTART:20120225T1300
- return DateTimeFormat.getFormat("'DTSTART':yyyyMMdd'T'hhmm").parse(date);
+ return DateTimeFormat.getFormat(OLD3_DATE_EXPORT_FORMAT).parse(date);
}
}
}
Modified: trunk/src/main/java/cc/kune/common/shared/res/ICalConstants.java
===================================================================
--- trunk/src/main/java/cc/kune/common/shared/res/ICalConstants.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/common/shared/res/ICalConstants.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -12,6 +12,7 @@
public static final String LOCATION = "LOCATION";
public static final String ORGANIZER = "ORGANIZER";
public static final String SUMMARY = "SUMMARY";
- public static final String[] TOTAL_LIST = new String[] { DATE_TIME_START, DATE_TIME_END, DESCRIPTION,
- LOCATION, ORGANIZER, SUMMARY, _ALL_DAY, _INTERNAL_ID };
+ public static final String UID = "UID";
+ public static final String[] ZTOTAL_LIST = new String[] { DATE_TIME_START, DATE_TIME_END, DESCRIPTION,
+ LOCATION, ORGANIZER, SUMMARY, _ALL_DAY, _INTERNAL_ID, UID };
}
\ No newline at end of file
Added: trunk/src/main/java/cc/kune/common/shared/utils/DateFormatConstants.java
===================================================================
--- trunk/src/main/java/cc/kune/common/shared/utils/DateFormatConstants.java (rev 0)
+++ trunk/src/main/java/cc/kune/common/shared/utils/DateFormatConstants.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -0,0 +1,17 @@
+package cc.kune.common.shared.utils;
+
+public class DateFormatConstants {
+
+ public static final String DATE_EXPORT_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZ";
+ @Deprecated
+ public static final String OLD1_DATE_EXPORT_FORMAT = "'DTSTART':yyyyMMdd'T'Hmmss";
+ @Deprecated
+ public static final String OLD2_DATE_EXPORT_FORMAT = "'DTSTART':yyyyMMdd'T'hhmmss";
+ @Deprecated
+ public static final String OLD3_DATE_EXPORT_FORMAT = "'DTSTART':yyyyMMdd'T'hhmm";
+
+ public DateFormatConstants() {
+ super();
+ }
+
+}
\ No newline at end of file
Modified: trunk/src/main/java/cc/kune/core/server/KuneRackModule.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/KuneRackModule.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/core/server/KuneRackModule.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -55,8 +55,9 @@
import cc.kune.core.server.rest.UserJSONService;
import cc.kune.core.server.scheduler.CronServerTasksManager;
import cc.kune.docs.server.DocumentServerModule;
-import cc.kune.events.server.CalendarServerUtils;
+import cc.kune.events.server.EventsServlet;
import cc.kune.events.server.EventsServerModule;
+import cc.kune.events.server.utils.EventsServerConversionUtil;
import cc.kune.hspace.client.ClientStatsService;
import cc.kune.lists.client.rpc.ListsService;
import cc.kune.lists.server.ListsServerModule;
@@ -97,7 +98,7 @@
// This can be used also in Gin:
// http://code.google.com/p/google-gin/issues/detail?id=60
requestStaticInjection(KuneWaveServerUtils.class);
- requestStaticInjection(CalendarServerUtils.class);
+ requestStaticInjection(EventsServerConversionUtil.class);
requestStaticInjection(GroupServerUtils.class);
}
};
@@ -157,7 +158,7 @@
builder.installServlet("^" + suffix + "/servlets/", FileUploadManager.class,
FileDownloadManager.class, EntityLogoUploadManager.class, EntityLogoDownloadManager.class,
FileGwtUploadServlet.class, EntityBackgroundDownloadManager.class,
- EntityBackgroundUploadManager.class, UserLogoDownloadManager.class);
+ EntityBackgroundUploadManager.class, UserLogoDownloadManager.class, EventsServlet.class);
builder.at("^" + suffix + "/(.*)$").install(
new ForwardFilter("^" + suffix + "/(.*)$", suffix + "/{0}"));
Modified: trunk/src/main/java/cc/kune/core/server/content/ContainerManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/content/ContainerManager.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/core/server/content/ContainerManager.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -33,9 +33,6 @@
Container createRootFolder(Group group, String toolName, String name, String type);
- @Override
- Container find(Long id);
-
boolean findIfExistsTitle(Container container, String title);
void moveContainer(Container container, Container newContainer);
Modified: trunk/src/main/java/cc/kune/core/server/manager/file/EntityBackgroundDownloadManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/file/EntityBackgroundDownloadManager.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/core/server/manager/file/EntityBackgroundDownloadManager.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -113,7 +113,7 @@
final OutputStream out = resp.getOutputStream();
FileDownloadManagerUtils.returnFile(absFilename, out);
} catch (final ContentNotFoundException e) {
- FileDownloadManagerUtils.returnNotFound(resp);
+ FileDownloadManagerUtils.returnNotFound404(resp);
return;
}
}
Modified: trunk/src/main/java/cc/kune/core/server/manager/file/EntityLogoDownloadManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/file/EntityLogoDownloadManager.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/core/server/manager/file/EntityLogoDownloadManager.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -69,7 +69,7 @@
resp.getOutputStream().write(logo);
}
} catch (final NoResultException e) {
- FileDownloadManagerUtils.returnNotFound(resp);
+ FileDownloadManagerUtils.returnNotFound404(resp);
return;
}
}
Modified: trunk/src/main/java/cc/kune/core/server/manager/file/FileDownloadManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/file/FileDownloadManager.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/core/server/manager/file/FileDownloadManager.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -87,7 +87,7 @@
final OutputStream out = resp.getOutputStream();
FileDownloadManagerUtils.returnFile(absFilename, out);
} catch (final ContentNotFoundException e) {
- FileDownloadManagerUtils.returnNotFound(resp);
+ FileDownloadManagerUtils.returnNotFound404(resp);
return;
}
}
Modified: trunk/src/main/java/cc/kune/core/server/manager/file/FileDownloadManagerUtils.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/file/FileDownloadManagerUtils.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/core/server/manager/file/FileDownloadManagerUtils.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -47,7 +47,7 @@
}
}
- public static void returnNotFound(final HttpServletResponse resp) throws IOException {
+ public static void returnNotFound404(final HttpServletResponse resp) throws IOException {
resp.getWriter().println("Content not found");
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
Modified: trunk/src/main/java/cc/kune/core/server/state/StateServiceDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/state/StateServiceDefault.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/core/server/state/StateServiceDefault.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -35,7 +35,7 @@
import cc.kune.domain.License;
import cc.kune.domain.Revision;
import cc.kune.domain.User;
-import cc.kune.events.server.CalendarServerUtils;
+import cc.kune.events.server.utils.EventsServerConversionUtil;
import cc.kune.events.shared.EventsConstants;
import cc.kune.wave.server.kspecific.KuneWaveService;
@@ -86,7 +86,7 @@
final Group group = container.getOwner();
setCommon(state, userLogged, group, container);
if (isCalendar) {
- ((StateEventContainer) state).setAppointments(CalendarServerUtils.getAppointments(container));
+ ((StateEventContainer) state).setAppointments(EventsServerConversionUtil.getAppointments(container));
}
return state;
}
Modified: trunk/src/main/java/cc/kune/core/shared/FileConstants.java
===================================================================
--- trunk/src/main/java/cc/kune/core/shared/FileConstants.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/core/shared/FileConstants.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -27,11 +27,12 @@
+ "servlets/EntityBackgroundDownloadManager";
public final static String DOWNLOAD = "download";
public static final String DOWNLOADSERVLET = ASITE_PREFIX + "servlets/FileDownloadManager";
+ public static final String EVENTSSERVLET = ASITE_PREFIX + "servlets/EventsServlet";
public final static String FILENAME = "filename";
public final static String GROUP_LOGO_FIELD = "k-glogov-ff";
public static final String GROUP_NO_AVATAR_IMAGE = "others/defgroup.gif";
+
public final static String HASH = "hash";
-
public final static String IMGSIZE = "imgsize";
public final static int LOGO_DEF_HEIGHT = 60;
public final static int LOGO_DEF_WIDTH = 468;
Modified: trunk/src/main/java/cc/kune/events/client/EventsClientTool.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/EventsClientTool.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/events/client/EventsClientTool.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -64,7 +64,7 @@
private void registerIcons() {
registerContentTypeIcon(TYPE_ROOT, icons.events());
- registerContentTypeIcon(TYPE_MEETING, navResources.calendar());
+ registerContentTypeIcon(TYPE_MEETING, icons.events());
registerEmptyMessages(TYPE_ROOT, i18n.t("There isn't any meeting, create one"));
registerEmptyMessagesNotLogged(TYPE_ROOT, i18n.t("There isn't any meeting"));
}
Modified: trunk/src/main/java/cc/kune/events/client/actions/EventAddMenuItem.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/actions/EventAddMenuItem.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/events/client/actions/EventAddMenuItem.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -6,6 +6,7 @@
import cc.kune.common.client.actions.ui.descrip.MenuItemDescriptor;
import cc.kune.common.client.ui.dialogs.PromptTopDialog;
import cc.kune.common.client.ui.dialogs.PromptTopDialog.Builder;
+import cc.kune.common.client.ui.dialogs.PromptTopDialog.OnEnter;
import cc.kune.common.shared.i18n.I18nTranslationService;
import cc.kune.core.client.resources.nav.NavResources;
import cc.kune.core.client.rpcservices.AsyncCallbackSimple;
@@ -16,8 +17,8 @@
import cc.kune.core.shared.dto.AccessRolDTO;
import cc.kune.core.shared.dto.StateContentDTO;
import cc.kune.events.client.viewer.CalendarViewer;
+import cc.kune.events.shared.EventsClientConversionUtil;
import cc.kune.events.shared.EventsConstants;
-import cc.kune.events.shared.EventsClientConversionUtil;
import com.bradrydzewski.gwt.calendar.client.Appointment;
import com.bradrydzewski.gwt.calendar.client.AppointmentStyle;
@@ -35,7 +36,9 @@
private final Provider<ContentServiceAsync> contService;
private PromptTopDialog dialog;
private final I18nTranslationService i18n;
+ private boolean openAfterCreation;
private final Session session;
+ private final StateManager stateManager;
@Inject
public EventAddAction(final NavResources res, final I18nTranslationService i18n,
@@ -46,6 +49,7 @@
this.calendar = calendar;
this.contService = contService;
this.session = session;
+ this.stateManager = stateManager;
withText(i18n.t("Add an appointment")).withIcon(res.calendarAdd());
}
@@ -53,43 +57,19 @@
public void actionPerformed(final ActionEvent event) {
if (dialog == null) {
final Builder builder = new PromptTopDialog.Builder(CREATE_APP_ID,
- i18n.t("Description of the appointment"), true, true, i18n.getDirection());
+ i18n.t("Description of the appointment"), true, true, i18n.getDirection(), new OnEnter() {
+ @Override
+ public void onEnter() {
+ doAction();
+ }
+ });
builder.firstButtonTitle(i18n.t("Add")).firstButtonId(CREATE_APP_ADD_ID);
builder.sndButtonTitle(i18n.t("Cancel")).sndButtonId(CREATE_APP_CANCEL_ID);
dialog = builder.build();
dialog.getFirstBtn().addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
- if (dialog.isValid()) {
-
- final String title = dialog.getTextFieldValue();
- final Date onOverDate = calendar.get().getOnOverDate();
- final Appointment appt = new Appointment();
- appt.setStart(onOverDate);
- // http://stackoverflow.com/questions/2527845/how-to-do-calendar-operations-in-java-gwt-how-to-add-days-to-a-dateSessionConstants._AN_HOUR
- final Date endDate = new Date(onOverDate.getTime() + SessionConstants._AN_HOUR);
- appt.setEnd(endDate);
- appt.setTitle(title);
- appt.setStyle(AppointmentStyle.ORANGE);
-
- contService.get().addNewContentWithGadgetAndState(session.getUserHash(),
- session.getContainerState().getStateToken(),
- EventsConstants.TYPE_MEETING_DEF_GADGETNAME, EventsConstants.TYPE_MEETING, title,
- "", EventsClientConversionUtil.toMap(appt), new AsyncCallbackSimple<StateContentDTO>() {
- @Override
- public void onFailure(final Throwable caught) {
- super.onFailure(caught);
- }
-
- @Override
- public void onSuccess(final StateContentDTO result) {
- appt.setId(result.getStateToken().toString());
- // Should this be used or serialize from server side?
- calendar.get().addAppointment(appt);
- }
- });
- dialog.hide();
- }
+ doAction();
}
});
dialog.getSecondBtn().addClickHandler(new ClickHandler() {
@@ -103,6 +83,51 @@
dialog.showCentered();
dialog.focusOnTextBox();
}
+
+ private void doAction() {
+ if (dialog.isValid()) {
+
+ final String title = dialog.getTextFieldValue();
+ final Date onOverDate = calendar.get().getOnOverDate();
+ final Appointment appt = new Appointment();
+ final Date startDate = onOverDate != null ? onOverDate : new Date();
+ if (onOverDate != null) {
+ openAfterCreation = false;
+ }
+ appt.setStart(startDate);
+ // http://stackoverflow.com/questions/2527845/how-to-do-calendar-operations-in-java-gwt-how-to-add-days-to-a-dateSessionConstants._AN_HOUR
+ final Date endDate = new Date(startDate.getTime() + SessionConstants._AN_HOUR);
+ appt.setEnd(endDate);
+ appt.setTitle(title);
+ appt.setStyle(AppointmentStyle.ORANGE);
+
+ contService.get().addNewContentWithGadgetAndState(session.getUserHash(),
+ session.getContainerState().getStateToken(), EventsConstants.TYPE_MEETING_DEF_GADGETNAME,
+ EventsConstants.TYPE_MEETING, title, "", EventsClientConversionUtil.toMap(appt),
+ new AsyncCallbackSimple<StateContentDTO>() {
+ @Override
+ public void onFailure(final Throwable caught) {
+ super.onFailure(caught);
+ }
+
+ @Override
+ public void onSuccess(final StateContentDTO result) {
+ // FIXME this should be setted for real...
+ appt.setId(result.getStateToken().toString());
+ // Should this be used or serialize from server side?
+ calendar.get().addAppointment(appt);
+ if (openAfterCreation) {
+ stateManager.gotoHistoryToken(appt.getId());
+ }
+ }
+ });
+ dialog.hide();
+ }
+ }
+
+ public void setOpenAfterCreation(final boolean openAfterCreation) {
+ this.openAfterCreation = openAfterCreation;
+ }
}
public static final String CREATE_APP_ADD_ID = "event-add-menu-item-add-btn";
@@ -113,5 +138,6 @@
public EventAddMenuItem(final EventAddAction action, final CalendarOnOverMenu cal) {
super(action);
setParent(cal.get());
+ action.setOpenAfterCreation(false);
}
}
Modified: trunk/src/main/java/cc/kune/events/client/actions/EventsClientActions.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/actions/EventsClientActions.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/events/client/actions/EventsClientActions.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -62,8 +62,9 @@
final Provider<EventAddMenuItem> eventAddMenuItem,
final Provider<EventOpenMenuItem> eventOpenMenuItem, final Provider<CalendarGoPrevBtn> calPrevBtn,
final Provider<EventRemoveMenuItem> eventRemoveMenuItem,
- final Provider<CalendarGoNextBtn> calNextBtn, final CalendarOnOverMenu onOverMenu,
- final Provider<CalendarGoTodayBtn> goToday, final Provider<RefreshContentMenuItem> refresh) {
+ final Provider<ExportCalendarMenuItem> export, final Provider<CalendarGoNextBtn> calNextBtn,
+ final CalendarOnOverMenu onOverMenu, final Provider<CalendarGoTodayBtn> goToday,
+ final Provider<RefreshContentMenuItem> refresh) {
super(session, stateManager, i18n, registry);
actionsRegistry.addAction(ActionGroups.TOOLBAR, optionsMenuContent, all);
actionsRegistry.addAction(ActionGroups.TOOLBAR, addAllMenuItem, contents);
@@ -78,6 +79,7 @@
actionsRegistry.addAction(ActionGroups.TOOLBAR, calMonthBtn, containers);
actionsRegistry.addAction(ActionGroups.TOOLBAR, calNextBtn, containers);
actionsRegistry.addAction(ActionGroups.TOOLBAR, participateBtn, contents);
+ actionsRegistry.addAction(ActionGroups.TOOLBAR, export, all);
actionsRegistry.addAction(ActionGroups.TOOLBAR, folderGoUp, contents);
// On over calendar menu
actionsRegistry.addAction(ActionGroups.TOOLBAR, onOverMenu, containers);
@@ -86,9 +88,9 @@
eventAddMenuItem.get();
eventRemoveMenuItem.get();
+ actionsRegistry.addAction(ActionGroups.TOOLBAR, newMeetingsBtn, containers);
+
// For now, commented:
- // actionsRegistry.addAction(ActionGroups.TOOLBAR, newMeetingsBtn,
- // containers);
// actionsRegistry.addAction(ActionGroups.ITEM_MENU, openContentMenuItem,
// contents);
// actionsRegistry.addAction(ActionGroups.ITEM_MENU, openContentMenuItem,
Added: trunk/src/main/java/cc/kune/events/client/actions/ExportCalendarMenuItem.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/actions/ExportCalendarMenuItem.java (rev 0)
+++ trunk/src/main/java/cc/kune/events/client/actions/ExportCalendarMenuItem.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -0,0 +1,75 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.events.client.actions;
+
+import cc.kune.common.client.actions.ActionEvent;
+import cc.kune.common.client.actions.ui.descrip.MenuItemDescriptor;
+import cc.kune.common.client.notify.NotifyUser;
+import cc.kune.common.shared.i18n.I18nTranslationService;
+import cc.kune.common.shared.utils.TextUtils;
+import cc.kune.common.shared.utils.Url;
+import cc.kune.common.shared.utils.UrlParam;
+import cc.kune.core.client.actions.RolAction;
+import cc.kune.core.client.resources.nav.NavResources;
+import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.FileConstants;
+import cc.kune.core.shared.domain.utils.StateToken;
+import cc.kune.core.shared.dto.AccessRolDTO;
+import cc.kune.gspace.client.actions.ContentViewerOptionsMenu;
+
+import com.google.inject.Inject;
+
+public class ExportCalendarMenuItem extends MenuItemDescriptor {
+
+ public static class ExportCalendarAction extends RolAction {
+ private final I18nTranslationService i18n;
+ private final Session session;
+
+ @Inject
+ public ExportCalendarAction(final Session session, final I18nTranslationService i18n) {
+ super(AccessRolDTO.Editor, false);
+ this.session = session;
+ this.i18n = i18n;
+ }
+
+ @Override
+ public void actionPerformed(final ActionEvent event) {
+ final StateToken token = session.getCurrentStateToken().copy().clearDocument();
+ final String url = new Url(session.getSiteUrl() + FileConstants.EVENTSSERVLET, new UrlParam(
+ FileConstants.TOKEN, token.toString())).toString();
+ NotifyUser.info(
+ i18n.t("Calendar exporting"),
+ i18n.t(
+ "Open or use this address in your prefered calendar program for instance in your mobile: [%s]",
+ TextUtils.generateHtmlLink(url, url, true)), ID, true);
+ }
+
+ }
+
+ public static final String ID = "k-export-cal-menuid";
+
+ @Inject
+ public ExportCalendarMenuItem(final I18nTranslationService i18n, final ExportCalendarAction action,
+ final ContentViewerOptionsMenu optionsMenu, final NavResources res) {
+ super(action);
+ this.withText(i18n.t("Export this calendar")).withIcon(res.calendar()).withParent(optionsMenu, false);
+ }
+
+}
Modified: trunk/src/main/java/cc/kune/events/client/actions/NewMeetingBtn.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/actions/NewMeetingBtn.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/events/client/actions/NewMeetingBtn.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -19,22 +19,22 @@
*/
package cc.kune.events.client.actions;
+import cc.kune.common.client.actions.ui.descrip.ButtonDescriptor;
import cc.kune.common.client.shortcuts.GlobalShortcutRegister;
import cc.kune.common.shared.i18n.I18nTranslationService;
import cc.kune.core.client.resources.nav.NavResources;
-import cc.kune.events.shared.EventsConstants;
-import cc.kune.gspace.client.actions.NewContentAction;
-import cc.kune.gspace.client.actions.NewContentBtn;
+import cc.kune.events.client.actions.EventAddMenuItem.EventAddAction;
import com.google.inject.Inject;
-public class NewMeetingBtn extends NewContentBtn {
+public class NewMeetingBtn extends ButtonDescriptor {
@Inject
- public NewMeetingBtn(final I18nTranslationService i18n, final NewContentAction action,
+ public NewMeetingBtn(final I18nTranslationService i18n, final EventAddAction action,
final NavResources res, final GlobalShortcutRegister shorcutReg) {
- super(i18n, action, res.calendarAdd(), shorcutReg, i18n.t("New meeting"),
- i18n.t("Create a New Meeting here"), i18n.t("New meeting"), EventsConstants.TYPE_MEETING);
+ super(i18n.t("New meeting"), action);
+ withIcon(res.calendarAdd()).withToolTip(i18n.t("Create a New Meeting"));
+ action.setOpenAfterCreation(true);
}
}
Modified: trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPanel.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPanel.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -22,7 +22,6 @@
import com.bradrydzewski.gwt.calendar.client.Appointment;
import com.bradrydzewski.gwt.calendar.client.Calendar;
import com.bradrydzewski.gwt.calendar.client.CalendarSettings;
-import com.bradrydzewski.gwt.calendar.client.CalendarSettings.Click;
import com.bradrydzewski.gwt.calendar.client.CalendarViews;
import com.bradrydzewski.gwt.calendar.client.event.CreateHandler;
import com.bradrydzewski.gwt.calendar.client.event.DateRequestHandler;
@@ -66,7 +65,8 @@
final CalendarSettings settings = new CalendarSettings();
settings.setIntervalsPerHour(4);
settings.setPixelsPerInterval(10);
- settings.setTimeBlockClickNumber(Click.Single);
+ // With Single is very annoying
+ // settings.setTimeBlockClickNumber(Click.Single);
// settings.setOffsetHourLabels(true);
settings.setScrollToHour(8);
calendar = new Calendar();
Modified: trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -290,14 +290,18 @@
getView().clearAppointments();
getView().suspendLayout();
for (final Map<String, String> map : eventState.getAppointments()) {
- final Appointment app = EventsClientConversionUtil.toApp(map);
- app.setId(map.get(ICalConstants._INTERNAL_ID));
- app.setStyle(AppointmentStyle.GREEN);
- if (isValid(app)) {
- getView().addAppointment(app);
-
- } else {
- Log.error("Appointment is not valid: " + app);
+ Appointment app;
+ try {
+ app = EventsClientConversionUtil.toApp(map);
+ app.setId(map.get(ICalConstants._INTERNAL_ID));
+ app.setStyle(AppointmentStyle.GREEN);
+ if (isValid(app)) {
+ getView().addAppointment(app);
+ } else {
+ Log.error("Appointment is not valid: " + app);
+ }
+ } catch (final Exception e) {
+ Log.error("Appointment is not valid");
}
}
getView().resumeLayout();
Deleted: trunk/src/main/java/cc/kune/events/server/CalendarServerUtils.java
===================================================================
--- trunk/src/main/java/cc/kune/events/server/CalendarServerUtils.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/events/server/CalendarServerUtils.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -1,123 +0,0 @@
-package cc.kune.events.server;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import net.fortuna.ical4j.model.Date;
-import net.fortuna.ical4j.model.DateTime;
-import net.fortuna.ical4j.model.Property;
-import net.fortuna.ical4j.model.TimeZone;
-import net.fortuna.ical4j.model.component.VEvent;
-import net.fortuna.ical4j.model.parameter.Value;
-import net.fortuna.ical4j.model.property.Description;
-import net.fortuna.ical4j.model.property.DtEnd;
-import net.fortuna.ical4j.model.property.DtStart;
-import net.fortuna.ical4j.model.property.Location;
-import net.fortuna.ical4j.model.property.Summary;
-
-import org.waveprotocol.wave.model.waveref.InvalidWaveRefException;
-import org.waveprotocol.wave.util.escapers.jvm.JavaWaverefEncoder;
-
-import cc.kune.common.shared.res.ICalConstants;
-import cc.kune.domain.Container;
-import cc.kune.domain.Content;
-import cc.kune.wave.server.kspecific.KuneWaveService;
-
-import com.bradrydzewski.gwt.calendar.client.Appointment;
-import com.google.inject.Inject;
-import com.google.wave.api.Gadget;
-
-public class CalendarServerUtils {
-
- @Inject
- private static EventsServerTool eventTool;
-
- @Inject
- private static KuneWaveService kuneWaveService;
- private static final Logger LOG = Logger.getLogger(CalendarServerUtils.class.getName());
-
- public static VEvent from(final Appointment app) {
- // final TimeZoneRegistry registry =
- // TimeZoneRegistryFactory.getInstance().createRegistry();
- // final TimeZone timezone = registry.getTimeZone("GMT");
- // final VTimeZone tz = timezone.getVTimeZone();
- // FIXME here v timezone!!!
-
- final DateTime start = new DateTime(app.getStart().getTime());
- final TimeZone timezone = start.getTimeZone();
- // start.setTimeZone(timezone);
- final DateTime end = new DateTime(app.getEnd().getTime());
- // end.setTimeZone(timezone);
- VEvent event;
- if (app.isAllDay()) {
- event = new VEvent();
- final DtStart eventStart = new DtStart(new Date(app.getStart().getTime()));
- eventStart.setTimeZone(timezone);
- event.getProperties().add(eventStart);
- final DtEnd eventEnd = new DtEnd(new Date(app.getEnd().getTime()));
- eventStart.setTimeZone(timezone);
- event.getProperties().add(eventEnd);
- event.getProperties().getProperty(Property.DTSTART).getParameters().add(Value.DATE);
- event.getProperties().getProperty(Property.DTEND).getParameters().add(Value.DATE);
- } else {
- event = new VEvent(start, end, app.getTitle());
- event.getProperties().getProperty(Property.DTSTART).getParameters().add(Value.DATE_TIME);
- event.getProperties().getProperty(Property.DTEND).getParameters().add(Value.DATE_TIME);
- }
- event.getProperties().add(new Summary(app.getTitle()));
- event.getProperties().add(new Description(app.getDescription()));
- event.getProperties().add(new Location(app.getLocation()));
- // FIXME uid
- // event.getProperties().add( new UidGenerator()app.getId()));
- return event;
- }
-
- public static List<Map<String, String>> getAppointments(final Container container) {
- final List<Map<String, String>> list = new ArrayList<Map<String, String>>();
- for (final Content content : container.getContents()) {
- final String waveId = content.getWaveId();
- try {
- final Gadget gadget = kuneWaveService.getGadget(
- JavaWaverefEncoder.decodeWaveRefFromPath(waveId),
- content.getAuthors().get(0).getShortName(), eventTool.getGadgetUrl());
- final Map<String, String> gadgetProps = gadget.getProperties();
- final HashMap<String, String> map = new HashMap<String, String>();
- for (final String var : ICalConstants.TOTAL_LIST) {
- final String value = gadgetProps.get(var);
- if (value != null) {
- map.put(var, value);
- }
- }
- map.put(ICalConstants._INTERNAL_ID, content.getStateToken().toString());
- list.add(map);
- } catch (final InvalidWaveRefException e) {
- LOG.log(Level.SEVERE, "Invalid Waveref", e);
- }
- }
- return list;
- }
-
- public static Appointment to(final VEvent event) {
- final Appointment app = new Appointment();
-
- // FIXME: see spec
- app.setDescription(event.getDescription().getValue());
- app.setStart(new java.util.Date(event.getStartDate().getDate().getTime()));
- app.setEnd(new java.util.Date(event.getEndDate().getDate().getTime()));
-
- // FIXME: see spec
- app.setLocation(event.getLocation().getValue());
- // final Uid uid = event.getUid();
- // if (uid != null) {
- // app.setId(uid.getValue());
- // }
- app.setAllDay(!(event.getStartDate().getDate() instanceof DateTime));
- app.setTitle(event.getSummary().getValue());
- return app;
- }
-
-}
Added: trunk/src/main/java/cc/kune/events/server/EventsServlet.java
===================================================================
--- trunk/src/main/java/cc/kune/events/server/EventsServlet.java (rev 0)
+++ trunk/src/main/java/cc/kune/events/server/EventsServlet.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -0,0 +1,110 @@
+package cc.kune.events.server;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import net.fortuna.ical4j.data.CalendarOutputter;
+import net.fortuna.ical4j.model.Calendar;
+import net.fortuna.ical4j.model.ValidationException;
+import net.fortuna.ical4j.model.component.VEvent;
+import net.fortuna.ical4j.model.property.CalScale;
+import net.fortuna.ical4j.model.property.ProdId;
+import net.fortuna.ical4j.model.property.Version;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import cc.kune.core.client.errors.ContentNotFoundException;
+import cc.kune.core.server.auth.ActionLevel;
+import cc.kune.core.server.auth.Authenticated;
+import cc.kune.core.server.auth.Authorizated;
+import cc.kune.core.server.content.ContainerManager;
+import cc.kune.core.server.content.ContentUtils;
+import cc.kune.core.server.manager.file.FileDownloadManagerUtils;
+import cc.kune.core.server.manager.file.FileUtils;
+import cc.kune.core.server.properties.KuneProperties;
+import cc.kune.core.shared.FileConstants;
+import cc.kune.core.shared.domain.AccessRol;
+import cc.kune.core.shared.domain.utils.StateToken;
+import cc.kune.domain.Container;
+import cc.kune.events.server.utils.EventsServerConversionUtil;
+import cc.kune.events.shared.EventsConstants;
+
+import com.google.inject.Inject;
+
+public class EventsServlet extends HttpServlet {
+ private static final Log LOG = LogFactory.getLog(EventsServlet.class);
+ private static final long serialVersionUID = -5559665146847701343L;
+
+ @Inject
+ ContainerManager containerManager;
+ @Inject
+ FileUtils fileUtils;
+ @Inject
+ KuneProperties kuneProperties;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void doGet(final HttpServletRequest req, final HttpServletResponse resp)
+ throws ServletException, IOException {
+
+ final String userHash = req.getParameter(FileConstants.HASH);
+ final StateToken token = new StateToken(req.getParameter(FileConstants.TOKEN));
+
+ final Calendar calendar = new Calendar();
+ calendar.getProperties().add(new ProdId("-//Ben Fortuna//iCal4j 1.0//EN"));
+ calendar.getProperties().add(Version.VERSION_2_0);
+ calendar.getProperties().add(CalScale.GREGORIAN);
+ final List<VEvent> events = new ArrayList<VEvent>();
+
+ try {
+ final Container cnt = getContainer(userHash, token);
+ if (cnt.getTypeId().equals(EventsConstants.TYPE_ROOT)) {
+ final List<Map<String, String>> listOfProps = EventsServerConversionUtil.getAppointments(cnt);
+ for (final Map<String, String> props : listOfProps) {
+ try {
+ final VEvent vEvent = EventsServerConversionUtil.toVEvent(EventsServerConversionUtil.toApp(props));
+ events.add(vEvent);
+ } catch (final Exception e) {
+ LOG.warn("Invalid appointments in " + token, e);
+ }
+ }
+ } else {
+ return404(resp);
+ return;
+ }
+ calendar.getComponents().addAll(events);
+ resp.setContentType("text/calendar");
+ final OutputStream out = resp.getOutputStream();
+ final CalendarOutputter outputter = new CalendarOutputter();
+ outputter.output(calendar, out);
+
+ } catch (final ContentNotFoundException e) {
+ return404(resp);
+ return;
+ } catch (final ValidationException e) {
+ LOG.warn("Invalid calendar conversion in " + token, e);
+ }
+
+ }
+
+ @Authenticated(mandatory = false)
+ @Authorizated(accessRolRequired = AccessRol.Viewer, actionLevel = ActionLevel.container)
+ private Container getContainer(final String userHash, final StateToken stateToken)
+ throws ContentNotFoundException {
+ return containerManager.find(ContentUtils.parseId(stateToken.getFolder()));
+ }
+
+ private void return404(final HttpServletResponse resp) throws IOException {
+ FileDownloadManagerUtils.returnNotFound404(resp);
+ }
+
+}
Added: trunk/src/main/java/cc/kune/events/server/utils/DateUtils.java
===================================================================
--- trunk/src/main/java/cc/kune/events/server/utils/DateUtils.java (rev 0)
+++ trunk/src/main/java/cc/kune/events/server/utils/DateUtils.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -0,0 +1,27 @@
+package cc.kune.events.server.utils;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import cc.kune.common.shared.utils.DateFormatConstants;
+
+public class DateUtils {
+
+ private static final SimpleDateFormat FORMATTER = new SimpleDateFormat(
+ DateFormatConstants.DATE_EXPORT_FORMAT);
+ public static final String TIMEZONE_REGEXP = "(.*)\\:([0-9][0-9])$";
+
+ public static Date toDate(final String date) throws ParseException {
+ try {
+ return FORMATTER.parse(date);
+ } catch (final ParseException e) {
+ return FORMATTER.parse(date.replaceFirst(TIMEZONE_REGEXP, "$1$2"));
+ }
+ }
+
+ public static String toString(final Date date) {
+ return FORMATTER.format(date);
+ }
+
+}
Added: trunk/src/main/java/cc/kune/events/server/utils/DateUtilsTest.java
===================================================================
--- trunk/src/main/java/cc/kune/events/server/utils/DateUtilsTest.java (rev 0)
+++ trunk/src/main/java/cc/kune/events/server/utils/DateUtilsTest.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -0,0 +1,23 @@
+package cc.kune.events.server.utils;
+
+import static org.junit.Assert.assertEquals;
+
+import java.text.ParseException;
+
+import org.junit.Test;
+
+public class DateUtilsTest {
+
+ private static final String SAMPLE = "2012-03-05T00:00:00.000+0100";
+ private static final String SAMPLE2 = "2012-03-05T00:00:00.000+01:00";
+
+ @Test
+ public void basicTest() throws ParseException {
+
+ DateUtils.toDate(SAMPLE);
+ DateUtils.toDate(SAMPLE2);
+
+ // Difference from GWT timezone and SimpleDate
+ assertEquals("foo+0100", "foo+01:00".replaceFirst(DateUtils.TIMEZONE_REGEXP, "$1$2"));
+ }
+}
Added: trunk/src/main/java/cc/kune/events/server/utils/EventsServerConversionUtil.java
===================================================================
--- trunk/src/main/java/cc/kune/events/server/utils/EventsServerConversionUtil.java (rev 0)
+++ trunk/src/main/java/cc/kune/events/server/utils/EventsServerConversionUtil.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -0,0 +1,154 @@
+package cc.kune.events.server.utils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import net.fortuna.ical4j.model.Date;
+import net.fortuna.ical4j.model.DateTime;
+import net.fortuna.ical4j.model.Property;
+import net.fortuna.ical4j.model.TimeZone;
+import net.fortuna.ical4j.model.component.VEvent;
+import net.fortuna.ical4j.model.parameter.Value;
+import net.fortuna.ical4j.model.property.Description;
+import net.fortuna.ical4j.model.property.DtEnd;
+import net.fortuna.ical4j.model.property.DtStart;
+import net.fortuna.ical4j.model.property.Location;
+import net.fortuna.ical4j.model.property.Summary;
+import net.fortuna.ical4j.model.property.Uid;
+
+import org.waveprotocol.wave.model.waveref.InvalidWaveRefException;
+import org.waveprotocol.wave.util.escapers.jvm.JavaWaverefEncoder;
+
+import cc.kune.common.shared.res.ICalConstants;
+import cc.kune.domain.Container;
+import cc.kune.domain.Content;
+import cc.kune.events.server.EventsServerTool;
+import cc.kune.events.shared.EventsSharedConversionUtil;
+import cc.kune.wave.server.kspecific.KuneWaveService;
+
+import com.bradrydzewski.gwt.calendar.client.Appointment;
+import com.google.inject.Inject;
+import com.google.wave.api.Gadget;
+
+/**
+ * The Class EventsConversionUtil is used to convert Appointments to Gadgets
+ * properties and viceversa
+ */
+public class EventsServerConversionUtil extends EventsSharedConversionUtil {
+
+ @Inject
+ private static EventsServerTool eventTool;
+
+ @Inject
+ private static KuneWaveService kuneWaveService;
+
+ private static final Logger LOG = Logger.getLogger(EventsServerConversionUtil.class.getName());
+
+ public static List<Map<String, String>> getAppointments(final Container container) {
+ final List<Map<String, String>> list = new ArrayList<Map<String, String>>();
+ assert eventTool != null;
+ for (final Content content : container.getContents()) {
+ final String waveId = content.getWaveId();
+ try {
+ final String shortName = content.getAuthors().get(0).getShortName();
+ final Gadget gadget = kuneWaveService.getGadget(
+ JavaWaverefEncoder.decodeWaveRefFromPath(waveId), shortName, eventTool.getGadgetUrl());
+ final Map<String, String> gadgetProps = gadget.getProperties();
+ final HashMap<String, String> map = new HashMap<String, String>();
+ for (final String var : ICalConstants.ZTOTAL_LIST) {
+ final String value = gadgetProps.get(var);
+ if (value != null) {
+ map.put(var, value);
+ }
+ }
+ map.put(ICalConstants.UID, content.getStateToken().toString());
+ map.put(ICalConstants._INTERNAL_ID, content.getStateToken().toString());
+ list.add(map);
+ } catch (final InvalidWaveRefException e) {
+ LOG.log(Level.SEVERE, "Invalid Waveref", e);
+ }
+ }
+ return list;
+ }
+
+ public static Appointment to(final VEvent event) {
+ // http://build.mnode.org/projects/ical4j/apidocs/
+ final Appointment app = new Appointment();
+ // FIXME: see spec
+ app.setDescription(event.getDescription().getValue());
+ app.setStart(new java.util.Date(event.getStartDate().getDate().getTime()));
+ app.setEnd(new java.util.Date(event.getEndDate().getDate().getTime()));
+
+ // FIXME: see spec
+ app.setLocation(event.getLocation().getValue());
+ final Uid uid = event.getUid();
+ if (uid != null) {
+ app.setId(uid.getValue());
+ }
+ app.setAllDay(!(event.getStartDate().getDate() instanceof DateTime));
+ app.setTitle(event.getSummary().getValue());
+ return app;
+ }
+
+ public static Appointment toApp(final Map<String, String> properties) throws Exception {
+ final Appointment app = EventsSharedConversionUtil.toApp(properties);
+ final String start = properties.get(ICalConstants.DATE_TIME_START);
+ if (start != null) {
+ app.setStart(DateUtils.toDate(start));
+ }
+ final String end = properties.get(ICalConstants.DATE_TIME_END);
+ if (end != null) {
+ app.setEnd(DateUtils.toDate(end));
+ }
+ return app;
+ }
+
+ public static Map<String, String> toMap(final Appointment app) {
+ final Map<String, String> properties = EventsSharedConversionUtil.toMap(app);
+ properties.put(ICalConstants.DATE_TIME_START, DateUtils.toString(app.getStart()));
+ properties.put(ICalConstants.DATE_TIME_END, DateUtils.toString(app.getEnd()));
+ return properties;
+ }
+
+ public static VEvent toVEvent(final Appointment app) {
+ // http://build.mnode.org/projects/ical4j/apidocs/
+
+ // final TimeZoneRegistry registry =
+ // TimeZoneRegistryFactory.getInstance().createRegistry();
+ // final TimeZone timezone = registry.getTimeZone("GMT");
+ // final VTimeZone tz = timezone.getVTimeZone();
+ // FIXME here v timezone!!!
+
+ final DateTime start = new DateTime(app.getStart().getTime());
+ final TimeZone timezone = start.getTimeZone();
+ // start.setTimeZone(timezone);
+ final DateTime end = new DateTime(app.getEnd().getTime());
+ // end.setTimeZone(timezone);
+ VEvent event;
+ if (app.isAllDay()) {
+ event = new VEvent();
+ event.getProperties().add(new Summary(app.getTitle()));
+ final DtStart eventStart = new DtStart(new Date(app.getStart().getTime()));
+ eventStart.setTimeZone(timezone);
+ event.getProperties().add(eventStart);
+ final DtEnd eventEnd = new DtEnd(new Date(app.getEnd().getTime()));
+ eventEnd.setTimeZone(timezone);
+ event.getProperties().add(eventEnd);
+ // event.getProperties().getProperty(Property.DTSTART).getParameters().add(Value.DATE);
+ // event.getProperties().getProperty(Property.DTEND).getParameters().add(Value.DATE);
+ } else {
+ event = new VEvent(start, end, app.getTitle());
+ event.getProperties().getProperty(Property.DTSTART).getParameters().add(Value.DATE_TIME);
+ event.getProperties().getProperty(Property.DTEND).getParameters().add(Value.DATE_TIME);
+ }
+ event.getProperties().add(new Description(app.getDescription()));
+ event.getProperties().add(new Location(app.getLocation()));
+ event.getProperties().add(new Uid(app.getId()));
+ return event;
+ }
+
+}
Modified: trunk/src/main/java/cc/kune/events/shared/EventsClientConversionUtil.java
===================================================================
--- trunk/src/main/java/cc/kune/events/shared/EventsClientConversionUtil.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/events/shared/EventsClientConversionUtil.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -13,7 +13,7 @@
*/
public class EventsClientConversionUtil extends EventsSharedConversionUtil {
- public static Appointment toApp(final Map<String, String> properties) {
+ public static Appointment toApp(final Map<String, String> properties) throws Exception {
final Appointment app = EventsSharedConversionUtil.toApp(properties);
final String start = properties.get(ICalConstants.DATE_TIME_START);
if (start != null) {
@@ -23,9 +23,6 @@
if (end != null) {
app.setEnd(DateUtils.toDate(end));
}
- String allDay = properties.get(ICalConstants._ALL_DAY);
- if (allDay != null)
- app.setAllDay(Boolean.parseBoolean(allDay));
return app;
}
@@ -33,7 +30,6 @@
final Map<String, String> properties = EventsSharedConversionUtil.toMap(app);
properties.put(ICalConstants.DATE_TIME_START, DateUtils.toString(app.getStart()));
properties.put(ICalConstants.DATE_TIME_END, DateUtils.toString(app.getEnd()));
- properties.put(ICalConstants._ALL_DAY, Boolean.toString(app.isAllDay()));
return properties;
}
Modified: trunk/src/main/java/cc/kune/events/shared/EventsSharedConversionUtil.java
===================================================================
--- trunk/src/main/java/cc/kune/events/shared/EventsSharedConversionUtil.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/events/shared/EventsSharedConversionUtil.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -13,12 +13,17 @@
*/
public abstract class EventsSharedConversionUtil {
- public static Appointment toApp(final Map<String, String> properties) {
+ public static Appointment toApp(final Map<String, String> properties) throws Exception {
final Appointment app = new Appointment();
app.setDescription(properties.get(ICalConstants.DESCRIPTION));
app.setTitle(properties.get(ICalConstants.SUMMARY));
app.setLocation(properties.get(ICalConstants.LOCATION));
app.setCreatedBy(properties.get(ICalConstants.ORGANIZER));
+ final String allDay = properties.get(ICalConstants._ALL_DAY);
+ app.setId(properties.get(ICalConstants.UID));
+ if (allDay != null) {
+ app.setAllDay(Boolean.parseBoolean(allDay));
+ }
return app;
}
@@ -28,6 +33,8 @@
properties.put(ICalConstants.DESCRIPTION, app.getDescription());
properties.put(ICalConstants.LOCATION, app.getLocation());
properties.put(ICalConstants.ORGANIZER, app.getCreatedBy());
+ properties.put(ICalConstants._ALL_DAY, Boolean.toString(app.isAllDay()));
+ properties.put(ICalConstants.UID, app.getId());
return properties;
}
Modified: trunk/src/main/java/cc/kune/lists/client/actions/NewListAction.java
===================================================================
--- trunk/src/main/java/cc/kune/lists/client/actions/NewListAction.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/lists/client/actions/NewListAction.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -23,6 +23,7 @@
import cc.kune.common.client.notify.NotifyUser;
import cc.kune.common.client.ui.dialogs.PromptTopDialog;
import cc.kune.common.client.ui.dialogs.PromptTopDialog.Builder;
+import cc.kune.common.client.ui.dialogs.PromptTopDialog.OnEnter;
import cc.kune.common.shared.i18n.I18nTranslationService;
import cc.kune.core.client.actions.RolAction;
import cc.kune.core.client.rpcservices.AsyncCallbackSimple;
@@ -49,6 +50,7 @@
public static final String TEXTBOX_ID = "k-nla-textbox";
private final ContentCache cache;
+ private PromptTopDialog diag;
private final FolderViewerPresenter folderViewer;
private final I18nTranslationService i18n;
private final Provider<ListsServiceAsync> listsService;
@@ -71,11 +73,16 @@
@Override
public void actionPerformed(final ActionEvent event) {
final Builder builder = new PromptTopDialog.Builder(ID, i18n.t("Name of the new list?"), false,
- true, i18n.getDirection());
+ true, i18n.getDirection(), new OnEnter() {
+ @Override
+ public void onEnter() {
+ doAction();
+ }
+ });
builder.width("300px").height("50px").firstButtonTitle(i18n.t("Create")).sndButtonTitle(
i18n.t("Cancel")).firstButtonId(CREATE_ID).sndButtonId(CANCEL_ID).width(270);
builder.textboxId(TEXTBOX_ID);
- final PromptTopDialog diag = builder.build();
+ diag = builder.build();
diag.showCentered();
diag.focusOnTextBox();
diag.getSecondBtn().addClickHandler(new ClickHandler() {
@@ -85,28 +92,33 @@
}
});
diag.getFirstBtn().addClickHandler(new ClickHandler() {
+
@Override
public void onClick(final ClickEvent event) {
- if (diag.isValid()) {
- NotifyUser.showProgress();
- diag.hide();
- listsService.get().createList(session.getUserHash(), session.getCurrentStateToken(),
- diag.getTextFieldValue(), ListsConstants.TYPE_LIST, true,
- new AsyncCallbackSimple<StateContainerDTO>() {
- @Override
- public void onSuccess(final StateContainerDTO state) {
- stateManager.setRetrievedStateAndGo(state);
- NotifyUser.hideProgress();
-
- NotifyUser.info(i18n.t("List created"));
- folderViewer.highlightTitle();
- }
- });
- cache.remove(session.getCurrentStateToken());
- }
+ doAction();
}
});
}
+ private void doAction() {
+ if (diag.isValid()) {
+ NotifyUser.showProgress();
+ diag.hide();
+ listsService.get().createList(session.getUserHash(), session.getCurrentStateToken(),
+ diag.getTextFieldValue(), ListsConstants.TYPE_LIST, true,
+ new AsyncCallbackSimple<StateContainerDTO>() {
+ @Override
+ public void onSuccess(final StateContainerDTO state) {
+ stateManager.setRetrievedStateAndGo(state);
+ NotifyUser.hideProgress();
+
+ NotifyUser.info(i18n.t("List created"));
+ folderViewer.highlightTitle();
+ }
+ });
+ cache.remove(session.getCurrentStateToken());
+ }
+ }
+
}
Modified: trunk/src/main/java/cc/kune/lists/client/actions/NewListPostAction.java
===================================================================
--- trunk/src/main/java/cc/kune/lists/client/actions/NewListPostAction.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/main/java/cc/kune/lists/client/actions/NewListPostAction.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -24,6 +24,7 @@
import cc.kune.common.client.notify.NotifyUser;
import cc.kune.common.client.ui.dialogs.PromptTopDialog;
import cc.kune.common.client.ui.dialogs.PromptTopDialog.Builder;
+import cc.kune.common.client.ui.dialogs.PromptTopDialog.OnEnter;
import cc.kune.common.shared.i18n.I18nTranslationService;
import cc.kune.core.client.actions.RolAction;
import cc.kune.core.client.auth.SignIn;
@@ -52,6 +53,7 @@
public static final String TEXTBOX_ID = "k-nlistpa-textbox";
private final ContentCache cache;
+ private PromptTopDialog diag;
private final FolderViewerPresenter folderViewer;
private final I18nTranslationService i18n;
private final Provider<ListsServiceAsync> listsService;
@@ -77,11 +79,16 @@
public void actionPerformed(final ActionEvent event) {
if (session.isLogged()) {
final Builder builder = new PromptTopDialog.Builder(ID, i18n.t("Title of the new post?"), false,
- true, i18n.getDirection());
+ true, i18n.getDirection(), new OnEnter() {
+ @Override
+ public void onEnter() {
+ doAction();
+ }
+ });
builder.width("300px").height("50px").firstButtonTitle(i18n.t("Post")).sndButtonTitle(
i18n.t("Cancel")).firstButtonId(CREATE_ID).sndButtonId(CANCEL_ID).width(270);
builder.textboxId(TEXTBOX_ID);
- final PromptTopDialog diag = builder.build();
+ diag = builder.build();
diag.showCentered();
diag.focusOnTextBox();
diag.getSecondBtn().addClickHandler(new ClickHandler() {
@@ -93,22 +100,7 @@
diag.getFirstBtn().addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
- if (diag.isValid()) {
- NotifyUser.showProgress();
- diag.hide();
- listsService.get().newPost(session.getUserHash(),
- session.getCurrentStateToken().copy().clearDocument(), diag.getTextFieldValue(),
- new AsyncCallbackSimple<StateContentDTO>() {
- @Override
- public void onSuccess(final StateContentDTO state) {
- stateManager.setRetrievedStateAndGo(state);
- NotifyUser.hideProgress();
- NotifyUser.info(i18n.t("Post created. Edit it"));
- folderViewer.highlightTitle();
- }
- });
- cache.remove(session.getCurrentStateToken());
- }
+ doAction();
}
});
} else {
@@ -119,4 +111,23 @@
}
}
+ private void doAction() {
+ if (diag.isValid()) {
+ NotifyUser.showProgress();
+ diag.hide();
+ listsService.get().newPost(session.getUserHash(),
+ session.getCurrentStateToken().copy().clearDocument(), diag.getTextFieldValue(),
+ new AsyncCallbackSimple<StateContentDTO>() {
+ @Override
+ public void onSuccess(final StateContentDTO state) {
+ stateManager.setRetrievedStateAndGo(state);
+ NotifyUser.hideProgress();
+ NotifyUser.info(i18n.t("Post created. Edit it"));
+ folderViewer.highlightTitle();
+ }
+ });
+ cache.remove(session.getCurrentStateToken());
+ }
+ }
+
}
Deleted: trunk/src/test/java/cc/kune/events/server/CalendarServerUtilsTest.java
===================================================================
--- trunk/src/test/java/cc/kune/events/server/CalendarServerUtilsTest.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/test/java/cc/kune/events/server/CalendarServerUtilsTest.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -1,65 +0,0 @@
-package cc.kune.events.server;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Date;
-
-import net.fortuna.ical4j.model.DateTime;
-import net.fortuna.ical4j.model.component.VEvent;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-import cc.kune.events.shared.BasicCalendarTest;
-
-import com.bradrydzewski.gwt.calendar.client.Appointment;
-
-public class CalendarServerUtilsTest extends BasicCalendarTest {
-
- private void checkConversionFromAndTo(final Appointment initialApp, final boolean allDay) {
- final VEvent vevent = CalendarServerUtils.from(initialApp);
- assertEquals(initialApp.getDescription(), vevent.getDescription().getValue());
- assertEquals(initialApp.getTitle(), vevent.getSummary().getValue());
- if (allDay) {
- final Date start = initialApp.getStart();
- start.setHours(0);
- start.setMinutes(0);
- start.setSeconds(0);
- assertEquals(start, new Date(vevent.getStartDate().getDate().getTime()));
- assertEquals(initialApp.getEnd(), vevent.getEndDate().getDate());
- } else {
- assertEquals(initialApp.getStart().getTime(), vevent.getStartDate().getDate().getTime());
- assertEquals(initialApp.getEnd().getTime(), vevent.getEndDate().getDate().getTime());
- }
- assertEquals(allDay, initialApp.isAllDay());
- assertEquals(allDay, !(vevent.getStartDate().getDate() instanceof DateTime));
- // final Uid uid = vevent.getUid();
- // assertEquals(initialApp.getId(), uid != null ? uid.getValue() : null);
- final Appointment reconvertedApp = CalendarServerUtils.to(vevent);
- assertEquals(initialApp.getTitle(), reconvertedApp.getTitle());
- assertEquals(initialApp.getDescription(), reconvertedApp.getDescription());
- // assertEquals(initialApp.getId(), endApp.getId());
- assertEquals(allDay, reconvertedApp.isAllDay());
- assertEquals(initialApp.getStart().getTime(), reconvertedApp.getStart().getTime());
- assertEquals(initialApp.getEnd().getTime(), reconvertedApp.getEnd().getTime());
- assertTrue(initialApp.compareTo(reconvertedApp) == 0);
- }
-
- @Test
- public void testFromToFrom() {
- final boolean allDay = false;
- final Appointment initialApp = createAppointment(allDay);
- initialApp.setAllDay(allDay);
- checkConversionFromAndTo(initialApp, allDay);
- }
-
- @Ignore
- @Test
- public void testFromToFromAllDay() {
- final boolean allDay = true;
- final Appointment initialApp = createAppointment(allDay);
- checkConversionFromAndTo(initialApp, allDay);
- }
-
-}
Copied: trunk/src/test/java/cc/kune/events/server/utils/BasicCalendarTest.java (from rev 1747, trunk/src/test/java/cc/kune/events/shared/BasicCalendarTest.java)
===================================================================
--- trunk/src/test/java/cc/kune/events/server/utils/BasicCalendarTest.java (rev 0)
+++ trunk/src/test/java/cc/kune/events/server/utils/BasicCalendarTest.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -0,0 +1,41 @@
+package cc.kune.events.server.utils;
+
+import net.fortuna.ical4j.model.Calendar;
+import net.fortuna.ical4j.model.Date;
+import net.fortuna.ical4j.model.property.CalScale;
+import net.fortuna.ical4j.model.property.ProdId;
+import net.fortuna.ical4j.model.property.Version;
+import net.fortuna.ical4j.util.Dates;
+
+import com.bradrydzewski.gwt.calendar.client.Appointment;
+
+public class BasicCalendarTest {
+
+ protected static final String DESCRIPTION = "some description";
+ protected static final String ID = "some id";
+ protected static final String TITLE = "some title";
+
+ protected Appointment createAppointment(final boolean allDay) {
+ final Appointment initialApp = new Appointment();
+ initialApp.setTitle(TITLE);
+ initialApp.setDescription(DESCRIPTION);
+ initialApp.setStart(getNow());
+ initialApp.setEnd(getNow());
+ initialApp.setId(ID);
+ initialApp.setAllDay(allDay);
+ return initialApp;
+ }
+
+ protected Calendar createCal() {
+ final Calendar calendar = new Calendar();
+ calendar.getProperties().add(new ProdId("-//Ben Fortuna//iCal4j 1.0//EN"));
+ calendar.getProperties().add(Version.VERSION_2_0);
+ calendar.getProperties().add(CalScale.GREGORIAN);
+ return calendar;
+ }
+
+ protected Date getNow() {
+ final Date date = new Date(Dates.getCurrentTimeRounded());
+ return date;
+ }
+}
Copied: trunk/src/test/java/cc/kune/events/server/utils/EventsServerConversionUtilTest.java (from rev 1747, trunk/src/test/java/cc/kune/events/shared/EventsServerConversionUtilTest.java)
===================================================================
--- trunk/src/test/java/cc/kune/events/server/utils/EventsServerConversionUtilTest.java (rev 0)
+++ trunk/src/test/java/cc/kune/events/server/utils/EventsServerConversionUtilTest.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -0,0 +1,106 @@
+package cc.kune.events.server.utils;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Date;
+import java.util.Map;
+
+import net.fortuna.ical4j.data.CalendarOutputter;
+import net.fortuna.ical4j.model.Calendar;
+import net.fortuna.ical4j.model.DateTime;
+import net.fortuna.ical4j.model.ValidationException;
+import net.fortuna.ical4j.model.component.VEvent;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.bradrydzewski.gwt.calendar.client.Appointment;
+
+public class EventsServerConversionUtilTest extends BasicCalendarTest {
+ protected static final String DESCRIPTION = "some description";
+ protected static final String ID = "some id";
+ protected static final String TITLE = "some title";
+
+ @SuppressWarnings("deprecation")
+ private void checkConversionFromAndTo(final Appointment initialApp, final boolean allDay)
+ throws IOException, ValidationException {
+ final VEvent vevent = EventsServerConversionUtil.toVEvent(initialApp);
+ assertEquals(initialApp.getDescription(), vevent.getDescription().getValue());
+ assertEquals(initialApp.getTitle(), vevent.getSummary().getValue());
+ if (allDay) {
+ final Date start = initialApp.getStart();
+ start.setHours(0);
+ start.setMinutes(0);
+ start.setSeconds(0);
+ assertEquals(start, new Date(vevent.getStartDate().getDate().getTime()));
+ assertEquals(initialApp.getEnd(), vevent.getEndDate().getDate());
+ } else {
+ assertEquals(initialApp.getStart().getTime(), vevent.getStartDate().getDate().getTime());
+ assertEquals(initialApp.getEnd().getTime(), vevent.getEndDate().getDate().getTime());
+ }
+ assertEquals(allDay, initialApp.isAllDay());
+ assertEquals(allDay, !(vevent.getStartDate().getDate() instanceof DateTime));
+ assertEquals(initialApp.getId(), vevent.getUid().getValue());
+ final Calendar cal = createCal();
+ cal.getComponents().add(vevent);
+
+ final OutputStream out = System.out;
+ final CalendarOutputter outputter = new CalendarOutputter();
+ outputter.output(cal, out);
+
+ final Appointment reconvertedApp = EventsServerConversionUtil.to(vevent);
+ assertEquals(initialApp.getTitle(), reconvertedApp.getTitle());
+ assertEquals(initialApp.getDescription(), reconvertedApp.getDescription());
+ assertEquals(initialApp.getId(), reconvertedApp.getId());
+ assertEquals(allDay, reconvertedApp.isAllDay());
+ assertEquals(initialApp.getStart().getTime(), reconvertedApp.getStart().getTime());
+ assertEquals(initialApp.getEnd().getTime(), reconvertedApp.getEnd().getTime());
+ assertTrue(initialApp.compareTo(reconvertedApp) == 0);
+ }
+
+ private void convertAndTest(final Appointment app, final boolean allDay) throws Exception {
+ final Map<String, String> map = EventsServerConversionUtil.toMap(app);
+ final Appointment appReConverted = EventsServerConversionUtil.toApp(map);
+ assertEquals(app.getStart(), appReConverted.getStart());
+ assertEquals(app.getEnd(), appReConverted.getEnd());
+ assertEquals(app.isAllDay(), appReConverted.isAllDay());
+ assertEquals(allDay, appReConverted.isAllDay());
+ assertEquals(app.getDescription(), appReConverted.getDescription());
+ assertEquals(app.getTitle(), appReConverted.getTitle());
+ assertEquals(app.getLocation(), appReConverted.getLocation());
+ assertEquals(app.getCreatedBy(), appReConverted.getCreatedBy());
+ assertEquals(app.getId(), appReConverted.getId());
+ }
+
+ @Test
+ public void testAllDay() throws Exception {
+ final Appointment app = createAppointment(true);
+ convertAndTest(app, true);
+ }
+
+ @Test
+ public void testFromToFrom() throws IOException, ValidationException {
+ final boolean allDay = false;
+ final Appointment initialApp = createAppointment(allDay);
+ initialApp.setAllDay(allDay);
+ checkConversionFromAndTo(initialApp, allDay);
+ }
+
+ @Ignore
+ @Test
+ public void testFromToFromAllDay() throws IOException, ValidationException {
+ final boolean allDay = true;
+ final Appointment initialApp = createAppointment(allDay);
+ checkConversionFromAndTo(initialApp, allDay);
+ }
+
+ @Test
+ public void testToMap() throws Exception {
+ final Appointment app = createAppointment(false);
+ convertAndTest(app, false);
+ }
+
+}
Deleted: trunk/src/test/java/cc/kune/events/shared/BasicCalendarTest.java
===================================================================
--- trunk/src/test/java/cc/kune/events/shared/BasicCalendarTest.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/test/java/cc/kune/events/shared/BasicCalendarTest.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -1,30 +0,0 @@
-package cc.kune.events.shared;
-
-import net.fortuna.ical4j.model.Date;
-import net.fortuna.ical4j.util.Dates;
-
-import com.bradrydzewski.gwt.calendar.client.Appointment;
-
-public class BasicCalendarTest {
-
- protected static final String DESCRIPTION = "some description";
- protected static final String ID = "some id";
- protected static final String TITLE = "some title";
-
- protected Appointment createAppointment(final boolean allDay) {
- final Appointment initialApp = new Appointment();
- initialApp.setTitle(TITLE);
- initialApp.setDescription(DESCRIPTION);
- initialApp.setStart(getNow());
- initialApp.setEnd(getNow());
- initialApp.setId(ID);
- initialApp.setAllDay(allDay);
- return initialApp;
- }
-
- protected Date getNow() {
- final Date date = new Date(Dates.getCurrentTimeRounded());
- return date;
- }
-
-}
Deleted: trunk/src/test/java/cc/kune/events/shared/EventsServerConversionUtilTest.java
===================================================================
--- trunk/src/test/java/cc/kune/events/shared/EventsServerConversionUtilTest.java 2012-03-08 16:07:23 UTC (rev 1749)
+++ trunk/src/test/java/cc/kune/events/shared/EventsServerConversionUtilTest.java 2012-03-09 01:22:13 UTC (rev 1750)
@@ -1,28 +0,0 @@
-package cc.kune.events.shared;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Map;
-
-import org.junit.Test;
-
-import com.bradrydzewski.gwt.calendar.client.Appointment;
-import com.google.gwt.editor.client.Editor.Ignore;
-
-public class EventsServerConversionUtilTest extends BasicCalendarTest {
-
- @Test
- @Ignore
- public void testToMap() {
- final Appointment app = createAppointment(false);
- final Map<String, String> map = EventsClientConversionUtil.toMap(app);
- final Appointment appReConverted = EventsClientConversionUtil.toApp(map);
- assertEquals(app.getStart(), appReConverted.getStart());
- assertEquals(app.getEnd(), appReConverted.getEnd());
- assertEquals(app.getDescription(), appReConverted.getDescription());
- assertEquals(app.getTitle(), appReConverted.getTitle());
- assertEquals(app.getLocation(), appReConverted.getLocation());
- assertEquals(app.getCreatedBy(), appReConverted.getCreatedBy());
- }
-
-}
More information about the kune-commits
mailing list