Author: ndkhoiits
Date: 2010-04-28 22:48:03 -0400 (Wed, 28 Apr 2010)
New Revision: 2887
Added:
portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIConfirmation.gtmpl
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIConfirmation.java
Modified:
portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties
Log:
GTNPORTAL-1023 Implement the UIConfirmation component. We can use this component when want
to confirm, please read spec in
wiki-int.exoplatform.org
Modified:
portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties
===================================================================
---
portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties 2010-04-29
01:47:23 UTC (rev 2886)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties 2010-04-29
02:48:03 UTC (rev 2887)
@@ -1370,3 +1370,10 @@
UIListPermissionSelectorPopup.title.ListPermissionSelector=Select Permission
UIUserToolBarDashboard.page.ClickAndType=Click & Type Page Name
+
+ #######################################################################
+ # org.exoplatform.webui.core.UIConfirmation #
+ #######################################################################
+
+UIConfirmation.title.exoMessages=Confirm message
+UIConfirmation.Close=Close
Added: portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIConfirmation.gtmpl
===================================================================
--- portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIConfirmation.gtmpl
(rev 0)
+++
portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIConfirmation.gtmpl 2010-04-29
02:48:03 UTC (rev 2887)
@@ -0,0 +1,144 @@
+<%
+ /**
+ * Created by The eXo Platform SAS
+ * Author : Nguyen Duc Khoi
+ * khoi.nguyen(a)exoplatform.com
+ * Apr 22, 2010
+ */
+%>
+<%
+ import org.exoplatform.webui.core.UIConfirmation.ActionConfirm;
+
+ String popupId = uicomponent.getId();
+ def rcontext = _ctx.getRequestContext();
+ rcontext.getJavascriptManager().importJavascript('eXo.webui.UIHorizontalTabs');
+ rcontext.getJavascriptManager().importJavascript('eXo.webui.UIPopupWindow');
+
+ def message = uicomponent.getMessage();
+ def actions = uicomponent.getActions();
+
+ void printTab(String messages, String title, boolean isSelected)
+ {
+ String cssClass = "NormalTab";
+ if(!isSelected) {
+ cssClass = "SelectedTab";
+ isSelected = true;
+ }
+ println """
+ <div class="UITab MessageTabDialog">
+ <div class="$cssClass">
+ <div class="LeftTab">
+ <div class="RightTab">
+ """;
+ println "<div class=\"MiddleTab\"
onclick=\"eXo.webui.UIHorizontalTabs.displayTabContent(this)\"><div
class=\"TabIcon
${title}Icon\">"+_ctx.appRes("UIPopupMessages.label."+"${title}")
+"</div></div>";
+ println """
+ </div>
+ </div>
+ </div>
+ </div>
+ """;
+ }
+
+ void printMessage(String message, String messageType)
+ {
+ println "<div class=\"UITabContent\"";
+ println " <div class=\"PopupMessageBox\">";
+ println " <div class=\"$messageType\">";
+ println " <div class=\"PopupMessageContainer\">";
+ println " <div class=\"MessageContainer\">";
+ println " <div class=\"PopupIcon
${messageType}Icon\"><span></span></div>";
+ println " <div class=\"PopupMessage\">";
+ println message;
+ println " </div>";
+ println " <div
style=\"clear:left\"><span></span></div>";
+ println " </div>";
+ println " </div>";
+ println " </div>";
+ println " </div>";
+ println "</div>";
+ }
+
+ void printAction(List actions)
+ {
+ for(act in actions)
+ {
+ println "<td>";
+ println " <div onclick="+uicomponent.event("Click",
act.getEventId())+" class=\"ActionButton LightBlueStyle\">";
+ println " <div class=\"ButtonLeft\">";
+ println " <div class=\"ButtonRight\">";
+ println " <div class=\"ButtonMiddle\">";
+ println " <a href=\"javascript:void(0);\">
${act.getActionKey()} </a>";
+ println " </div>";
+ println " </div>";
+ println " </div>";
+ println " </div>";
+ println "</td>";
+ }
+ }
+%>
+ <div class="UIPopupWindow" id="$popupId" style="width:
550px; display: none;">
+ <div class="ExoMessageDecorator">
+ <div class="TopLeftCornerDecorator">
+ <div class="TopRightCornerDecorator">
+ <div class="TopCenterDecorator">
+ <div class="OverflowContainer">
+ <div class="PopupTitleIcon"><span></span></div>
+ <div class="CloseButton"
title="<%=_ctx.appRes("UIConfirmation.Close")%>"
onclick="<%=uicomponent.event("Close")%>"><span></span></div>
+ <div class="PopupTitle"><%=
_ctx.appRes("UIConfirmation.title.exoMessages") %></div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="MiddleLeftSideDecorator">
+ <div class="MiddleRightSideDecorator">
+ <div class="MiddleCenterDecorator">
+ <div class="UIWindowContent">
+ <div class="PopupContent">
+ <div class="UIPopupMessages">
+ <div class="UIHorizontalTabs">
+ <div class="TabsContainer">
+ <%
+ boolean flag = true
+ flag = printTab(message, "Warning", flag);
+ %>
+ </div>
+ </div>
+ <div class="UITabContentContainer">
+ <%
+ printMessage(message, "ErrorMessage");
+ %>
+ </div>
+ <div class="MessageActionBar">
+ <div class="UIAction">
+ <table class="ActionContainer">
+ <tr>
+ <%
+ printAction(actions);
+ %>
+ </tr>
+ </table>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div><span></span></div>
+ <div class="BottomLeftCornerDecorator">
+ <div class="BottomRightCornerDecorator">
+ <div
class="BottomCenterDecorator"><span></span></div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <%
+ rcontext.getJavascriptManager().addJavascript("eXo.webui.UIPopupWindow.init('$popupId',
false);");
+ if(uicomponent.hasMessage()){
+ rcontext.getJavascriptManager().addJavascript("eXo.webui.UIPopupWindow.show('$popupId');");
+ rcontext.getJavascriptManager().addJavascript("window.setTimeout(\"eXo.webui.UIPopupWindow.increasezIndex('$popupId')\",
100);");
+ }
+ %>
\ No newline at end of file
Added:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIConfirmation.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIConfirmation.java
(rev 0)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIConfirmation.java 2010-04-29
02:48:03 UTC (rev 2887)
@@ -0,0 +1,209 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not,
see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.webui.core;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.config.annotation.EventConfig;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
+import org.exoplatform.webui.form.UIFormInputWithActions.ActionData;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : Nguyen Duc Khoi
+ * khoi.nguyen(a)exoplatform.com
+ * Apr 22, 2010
+ *
+ * Display a confirm popup message
+ *
+ */
+
+@ComponentConfig(
+ template = "system:/groovy/webui/core/UIConfirmation.gtmpl",
+ events={
+ @EventConfig(listeners = UIConfirmation.CloseActionListener.class),
+ @EventConfig(listeners = UIConfirmation.ClickActionListener.class)
+ }
+)
+
+public class UIConfirmation extends UIPopupWindow
+{
+ private String message_;
+
+ private Object caller_;
+
+ private List<ActionConfirm> actions_;
+
+ public UIConfirmation()
+ {
+ this.message_ = "";
+ this.caller_ = new Object();
+ setShow(true);
+ }
+
+ public UIConfirmation(String message, Object caller)
+ {
+ this.message_ = message;
+ this.caller_ = caller;
+ setShow(true);
+ }
+
+ public void setMessage(String message)
+ {
+ this.message_ = message;
+ }
+
+ public String getMessage()
+ {
+ return message_;
+ }
+
+ public Object getCaller()
+ {
+ return caller_;
+ }
+
+ public void setCaller(Object caller)
+ {
+ this.caller_ = caller;
+ }
+
+ public void addMessage(String message)
+ {
+ this.message_ = message;
+ }
+
+ public void clearMessage()
+ {
+ this.message_ = "";
+ }
+
+ public void setActions(List<ActionConfirm> actions_)
+ {
+ this.actions_ = actions_;
+ }
+
+ public List<ActionConfirm> getActions()
+ {
+ return actions_;
+ }
+
+ /**
+ * Check if message null or empty then don't display popup
+ *
+ * @return {@link Boolean}
+ */
+ public boolean hasMessage()
+ {
+ return (message_!=null) && (!message_.equals(""));
+ }
+
+ private void hidePopup(WebuiRequestContext context)
+ {
+ this.clearMessage();
+ if(this.getParent() == null)
+ {
+ context.addUIComponentToUpdateByAjax(this);
+ return;
+ }
+
+ if(!this.isShow())
+ {
+ return;
+ }
+ }
+
+ public static class CloseActionListener extends EventListener<UIConfirmation>
+ {
+ @Override
+ public void execute(Event<UIConfirmation> event) throws Exception
+ {
+ UIConfirmation uiConfirmation = event.getSource();
+ WebuiRequestContext context = event.getRequestContext();
+ uiConfirmation.hidePopup(context);
+ }
+ }
+
+ public static class ClickActionListener extends EventListener<UIConfirmation>
+ {
+ @Override
+ public void execute(Event<UIConfirmation> event) throws Exception
+ {
+ WebuiRequestContext context = event.getRequestContext();
+ UIConfirmation uiConfirmation = event.getSource();
+
+ UIComponent uiComponent = (UIComponent)uiConfirmation.getCaller();
+ Event<UIComponent> xEvent =
uiComponent.createEvent(context.getRequestParameter(OBJECTID), event.getExecutionPhase(),
context);
+
+ if(xEvent != null)
+ {
+ xEvent.broadcast();
+ }
+
+ uiConfirmation.hidePopup(context);
+ }
+ }
+
+ /**
+ * Created by The eXo Platform SAS
+ * Author : Nguyen Duc Khoi
+ * khoi.nguyen(a)exoplatform.com
+ * Apr 22, 2010
+ *
+ * Define actions which are rendered
+ *
+ */
+
+ public static class ActionConfirm implements Serializable
+ {
+ private String eventId_;
+
+ private String actionKey_;
+
+ public ActionConfirm(){ }
+
+ public ActionConfirm(String eventId, String actionKey)
+ {
+ this.eventId_ = eventId;
+ this.actionKey_ = actionKey;
+ }
+
+ public void setEventId(String eventId)
+ {
+ this.eventId_ = eventId;
+ }
+
+ public String getEventId()
+ {
+ return eventId_;
+ }
+
+ public void setActionKey(String actionKey)
+ {
+ this.actionKey_ = actionKey;
+ }
+
+ public String getActionKey()
+ {
+ return actionKey_;
+ }
+ }
+}