Author: ndkhoiits
Date: 2010-04-20 22:09:40 -0400 (Tue, 20 Apr 2010)
New Revision: 2702
Added:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageNodeForm2.java
Removed:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageNodeForm2.java
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNode.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java
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_vi.properties
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIWizardPageSetInfo.java
Log:
GTNPORTAL-1065 Fix bugs relate publication date when create new page node or edit a node.
allow Start date or end date is null
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNode.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNode.java 2010-04-21
01:23:26 UTC (rev 2701)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNode.java 2010-04-21
02:09:40 UTC (rev 2702)
@@ -289,14 +289,21 @@
private boolean isInPublicationDate()
{
- if (startPublicationDate != null && endPublicationDate != null)
- {
- Date currentDate = new Date();
-
- //
- return currentDate.compareTo(startPublicationDate) >= 0 &&
currentDate.compareTo(endPublicationDate) <= 0;
- }
- else return startPublicationDate == null && endPublicationDate == null;
+ Date currentDate = new Date();
+
+ // Case 1: start date, end date are not null and current date is between start and
end date
+ boolean case1 = (startPublicationDate != null) && (endPublicationDate !=
null) && (currentDate.compareTo(startPublicationDate) >= 0 &&
currentDate.compareTo(endPublicationDate) <= 0);
+
+ // Case 2: start date is null, end date is not null and current date is before end
date
+ boolean case2 = (startPublicationDate == null) && (endPublicationDate !=
null) && (currentDate.compareTo(endPublicationDate) <= 0);
+
+ // Case 3: start date is not null, end date is null and current date is after start
date
+ boolean case3 = (startPublicationDate != null) && (endPublicationDate ==
null) && (currentDate.compareTo(startPublicationDate) >= 0);
+
+ // Case 4: start date and end date are null both
+ boolean case4 = (startPublicationDate == null) && (endPublicationDate ==
null);
+
+ return case1 || case2 || case3 || case4;
}
public void setShowPublicationDate(Boolean show)
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java 2010-04-21
01:23:26 UTC (rev 2701)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java 2010-04-21
02:09:40 UTC (rev 2702)
@@ -72,6 +72,7 @@
@EventConfig(listeners = UIPageNodeForm2.SaveActionListener.class),
@EventConfig(listeners = UIGroupNavigationManagement.BackActionListener.class,
phase = Phase.DECODE),
@EventConfig(listeners = UIPageNodeForm2.SwitchPublicationDateActionListener.class,
phase = Phase.DECODE),
+ @EventConfig(listeners = UIPageNodeForm2.SwitchVisibleActionListener.class, phase =
Phase.DECODE),
@EventConfig(listeners = UIPageNodeForm2.ClearPageActionListener.class, phase =
Phase.DECODE),
@EventConfig(listeners = UIPageNodeForm2.CreatePageActionListener.class, phase =
Phase.DECODE)})})
public class UIGroupNavigationManagement extends UIContainer
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java 2010-04-21
01:23:26 UTC (rev 2701)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java 2010-04-21
02:09:40 UTC (rev 2702)
@@ -73,6 +73,7 @@
@EventConfig(listeners = UIPageNodeForm2.SaveActionListener.class),
@EventConfig(listeners = UISiteManagement.BackActionListener.class, phase =
Phase.DECODE),
@EventConfig(listeners = UIPageNodeForm2.SwitchPublicationDateActionListener.class,
phase = Phase.DECODE),
+ @EventConfig(listeners = UIPageNodeForm2.SwitchVisibleActionListener.class, phase =
Phase.DECODE),
@EventConfig(listeners = UIPageNodeForm2.ClearPageActionListener.class, phase =
Phase.DECODE),
@EventConfig(listeners = UIPageNodeForm2.CreatePageActionListener.class, phase =
Phase.DECODE)})})
public class UISiteManagement extends UIContainer
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-21
01:23:26 UTC (rev 2701)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties 2010-04-21
02:09:40 UTC (rev 2702)
@@ -510,6 +510,8 @@
UIPageNodeForm2.msg.SameName=This node name already exists.
UIPageNodeForm2.msg.selectPage=You have to select a page.
UIPageNodeForm2.msg.startDateBeforeEndDate=The end date must be after the start date.
+UIPageNodeForm2.msg.currentDateBeforeStartDate=The start date must be after the current
date or empty.
+UIPageNodeForm2.msg.currentDateBeforeEndDate=The end date must be after the current date
or empty.
UIPageNodeForm2.action.Save=#{word.save}
UIPageNodeForm2.action.Back=#{word.back}
UIPageNodeForm2.action.Close=#{word.cancel}
Modified:
portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_vi.properties
===================================================================
---
portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_vi.properties 2010-04-21
01:23:26 UTC (rev 2701)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_vi.properties 2010-04-21
02:09:40 UTC (rev 2702)
@@ -480,6 +480,8 @@
UIPageNodeForm2.msg.SameName=Tên của node mà bạn nhập đang tồn tại, hãy thử với tên
khác!
UIPageNodeForm2.msg.selectPage=Bạn phải chọn một trang!
UIPageNodeForm2.msg.startDateBeforeEndDate=Thời gian kết thúc phải lớn hơn hoặc bằng thời
gian hiện tại.
+UIPageNodeForm2.msg.currentDateBeforeStartDate=Thời gian bắt đầu phải sau thời gian hiện
tại hoặc để trống.
+UIPageNodeForm2.msg.currentDateBeforeEndDate=Thời gian kết thúc phải sau thời gian hiện
tại hoặc để trống.
UIPageNodeForm2.action.Save=#{word.save}
UIPageNodeForm2.action.Back=#{word.back}
UIPageNodeForm2.action.Close=#{word.cancel}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java 2010-04-21
01:23:26 UTC (rev 2701)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java 2010-04-21
02:09:40 UTC (rev 2702)
@@ -61,7 +61,7 @@
final public static int FIRST_STEP = 1;
- final public static int SECONDE_STEP = 2;
+ final public static int SECOND_STEP = 2;
final public static int THIRD_STEP = 3;
@@ -194,9 +194,9 @@
UIPortalApplication uiPortalApp =
uiWizard.getAncestorOfType(UIPortalApplication.class);
UIWorkingWorkspace uiWorkingWS =
uiWizard.getAncestorOfType(UIWorkingWorkspace.class);
uiWorkingWS.findFirstComponentOfType(UIPortalComposer.class).setRendered(false);
- uiWizard.viewStep(SECONDE_STEP);
+ uiWizard.viewStep(SECOND_STEP);
- if (uiWizard.getSelectedStep() < SECONDE_STEP)
+ if (uiWizard.getSelectedStep() < SECOND_STEP)
{
uiPortalApp.addMessage(new
ApplicationMessage("UIPageCreationWizard.msg.StepByStep", null));
uiWizard.viewStep(FIRST_STEP);
@@ -226,21 +226,45 @@
if
(uiPageSetInfo.getUIFormCheckBoxInput(UIWizardPageSetInfo.SHOW_PUBLICATION_DATE).isChecked())
{
+
+ Calendar currentCalendar = Calendar.getInstance();
+ currentCalendar.set(currentCalendar.get(Calendar.YEAR),
currentCalendar.get(Calendar.MONTH), currentCalendar.get(Calendar.DAY_OF_MONTH), 0, 0,
0);
+ Date currentDate = currentCalendar.getTime();
+
Calendar startCalendar =
uiPageSetInfo.getUIFormDateTimeInput(UIWizardPageSetInfo.START_PUBLICATION_DATE).getCalendar();
- Date startDate = startCalendar.getTime();
+ Date startDate = (startCalendar != null) ? startCalendar.getTime() :
currentDate;
Calendar endCalendar =
uiPageSetInfo.getUIFormDateTimeInput(UIWizardPageSetInfo.END_PUBLICATION_DATE).getCalendar();
- Date endDate = endCalendar.getTime();
- if (startDate.after(endDate))
+ Date endDate = (endCalendar != null) ? endCalendar.getTime() : null;
+
+ // Case 1: current date after start date
+ if (currentDate.after(startDate))
{
- uiPortalApp.addMessage(new
ApplicationMessage("UIPageNodeForm2.msg.startDateBeforeEndDate", null));
+ Object[] args = {};
+ uiPortalApp.addMessage(new
ApplicationMessage("UIPageNodeForm2.msg.currentDateBeforeStartDate", args,
ApplicationMessage.WARNING));
uiWizard.viewStep(FIRST_STEP);
return;
}
+ // Case 2: start date after end date
+ else if ((endCalendar != null) && (startCalendar != null) &&
(startDate.after(endDate)))
+ {
+ Object[] args = {};
+ uiPortalApp.addMessage(new
ApplicationMessage("UIPageNodeForm2.msg.startDateBeforeEndDate", args,
ApplicationMessage.WARNING));
+ uiWizard.viewStep(FIRST_STEP);
+ return;
+ }
+ // Case 3: start date is null and current date after end date
+ else if((endCalendar != null) && (currentDate.after(endDate)))
+ {
+ Object[] args = {};
+ uiPortalApp.addMessage(new
ApplicationMessage("UIPageNodeForm2.msg.currentDateBeforeEndDate", args,
ApplicationMessage.WARNING));
+ uiWizard.viewStep(FIRST_STEP);
+ return;
+ }
}
-
}
+
}
static public class ViewStep3ActionListener extends
EventListener<UIPageCreationWizard>
Deleted:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageNodeForm2.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageNodeForm2.java 2010-04-21
01:23:26 UTC (rev 2701)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageNodeForm2.java 2010-04-21
02:09:40 UTC (rev 2702)
@@ -1,426 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.webui.page;
-
-import org.exoplatform.portal.application.PortalRequestContext;
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.UserACL;
-import org.exoplatform.portal.config.model.ModelObject;
-import org.exoplatform.portal.config.model.Page;
-import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.config.model.PageNode;
-import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.webui.navigation.PageNavigationUtils;
-import org.exoplatform.portal.webui.portal.UIPortal;
-import org.exoplatform.portal.webui.util.Util;
-import org.exoplatform.portal.webui.workspace.UIPortalApplication;
-import org.exoplatform.web.application.ApplicationMessage;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.webui.core.UIApplication;
-import org.exoplatform.webui.core.UIComponent;
-import org.exoplatform.webui.core.UIPopupWindow;
-import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
-import org.exoplatform.webui.event.Event.Phase;
-import org.exoplatform.webui.exception.MessageException;
-import org.exoplatform.webui.form.UIFormCheckBoxInput;
-import org.exoplatform.webui.form.UIFormDateTimeInput;
-import org.exoplatform.webui.form.UIFormInputBase;
-import org.exoplatform.webui.form.UIFormInputIconSelector;
-import org.exoplatform.webui.form.UIFormInputSet;
-import org.exoplatform.webui.form.UIFormStringInput;
-import org.exoplatform.webui.form.UIFormTabPane;
-import org.exoplatform.webui.form.validator.DateTimeValidator;
-import org.exoplatform.webui.form.validator.IdentifierValidator;
-import org.exoplatform.webui.form.validator.MandatoryValidator;
-import org.exoplatform.webui.form.validator.StringLengthValidator;
-import org.exoplatform.webui.form.validator.Validator;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-
-/**
- * Author : Dang Van Minh, Pham Tuan minhdv81(a)yahoo.com Jun 14, 2006
- */
-public class UIPageNodeForm2 extends UIFormTabPane
-{
-
- private PageNode pageNode_;
-
- private String owner_;
-
- private String ownerType_;
-
- private Object selectedParent;
-
- final private static String SHOW_PUBLICATION_DATE = "showPublicationDate";
-
- final private static String START_PUBLICATION_DATE =
"startPublicationDate";
-
- final private static String END_PUBLICATION_DATE = "endPublicationDate";
-
- public UIPageNodeForm2() throws Exception
- {
- super("UIPageNodeForm");
-
- UIFormInputSet uiSettingSet = new UIFormInputSet("PageNodeSetting");
- UIFormCheckBoxInput<Boolean> uiDateInputCheck =
- new UIFormCheckBoxInput<Boolean>(SHOW_PUBLICATION_DATE,
SHOW_PUBLICATION_DATE, false);
- uiDateInputCheck.setOnChange("SwitchPublicationDate");
- uiSettingSet.addUIFormInput(new UIFormStringInput("uri", "uri",
null).setEditable(false)).addUIFormInput(
- new UIFormStringInput("name", "name",
null).addValidator(MandatoryValidator.class).addValidator(
- StringLengthValidator.class, 3,
30).addValidator(IdentifierValidator.class)).addUIFormInput(
- new UIFormStringInput("label", "label",
null).addValidator(StringLengthValidator.class, 3, 120))
- .addUIFormInput(new UIFormCheckBoxInput<Boolean>("visible",
"visible", true).setChecked(true)).addUIFormInput(
- uiDateInputCheck).addUIFormInput(
- new UIFormDateTimeInput(START_PUBLICATION_DATE, null,
null).addValidator(MandatoryValidator.class)
- .addValidator(DateTimeValidator.class)).addUIFormInput(
- new UIFormDateTimeInput(END_PUBLICATION_DATE, null,
null).addValidator(MandatoryValidator.class)
- .addValidator(DateTimeValidator.class));
- addUIFormInput(uiSettingSet);
- setSelectedTab(uiSettingSet.getId());
-
- UIPageSelector2 uiPageSelector = createUIComponent(UIPageSelector2.class, null,
null);
- uiPageSelector.configure("UIPageSelector2", "pageReference");
- addUIFormInput(uiPageSelector);
-
- UIFormInputIconSelector uiIconSelector = new
UIFormInputIconSelector("Icon", "icon");
- addUIFormInput(uiIconSelector);
- setActions(new String[]{"Save", "Back"});
- }
-
- public PageNode getPageNode()
- {
- return pageNode_;
- }
-
- public void setValues(PageNode pageNode) throws Exception
- {
- pageNode_ = pageNode;
- if (pageNode == null)
- {
- getUIStringInput("name").setEditable(UIFormStringInput.ENABLE);
- getChild(UIFormInputIconSelector.class).setSelectedIcon("Default");
- setShowPublicationDate(false);
- return;
- }
- getUIStringInput("name").setEditable(UIFormStringInput.DISABLE);
- invokeGetBindingBean(pageNode_);
- }
-
- public void invokeGetBindingBean(Object bean) throws Exception
- {
- super.invokeGetBindingBean(bean);
- PageNode pageNode = (PageNode)bean;
- String icon = pageNode_.getIcon();
- if (icon == null || icon.length() < 0)
- icon = "Default";
- getChild(UIFormInputIconSelector.class).setSelectedIcon(icon);
- getUIStringInput("label").setValue(pageNode_.getLabel());
- getUIFormCheckBoxInput("visible").setChecked(pageNode_.isVisible());
- setShowPublicationDate(pageNode.isShowPublicationDate());
- Calendar cal = Calendar.getInstance();
- if (pageNode.getStartPublicationDate() != null)
- {
- cal.setTime(pageNode.getStartPublicationDate());
- getUIFormDateTimeInput(START_PUBLICATION_DATE).setCalendar(cal);
- }
- else
- getUIFormDateTimeInput(START_PUBLICATION_DATE).setValue(null);
- if (pageNode.getEndPublicationDate() != null)
- {
- cal.setTime(pageNode.getEndPublicationDate());
- getUIFormDateTimeInput(END_PUBLICATION_DATE).setCalendar(cal);
- }
- else
- getUIFormDateTimeInput(END_PUBLICATION_DATE).setValue(null);
- }
-
- public void invokeSetBindingBean(Object bean) throws Exception
- {
- super.invokeSetBindingBean(bean);
- PageNode node = (PageNode)bean;
- Calendar cal = getUIFormDateTimeInput(START_PUBLICATION_DATE).getCalendar();
- Date date = (cal != null) ? cal.getTime() : null;
- node.setStartPublicationDate(date);
- cal = getUIFormDateTimeInput(END_PUBLICATION_DATE).getCalendar();
- date = (cal != null) ? cal.getTime() : null;
- node.setEndPublicationDate(date);
- }
-
- public void setShowPublicationDate(boolean show)
- {
- getUIFormCheckBoxInput(SHOW_PUBLICATION_DATE).setChecked(show);
- getUIFormDateTimeInput(START_PUBLICATION_DATE).setRendered(show);
- getUIFormDateTimeInput(END_PUBLICATION_DATE).setRendered(show);
- }
-
- public Object getSelectedParent()
- {
- return selectedParent;
- }
-
- public void setSelectedParent(Object obj)
- {
- this.selectedParent = obj;
- }
-
- public void processRender(WebuiRequestContext context) throws Exception
- {
- super.processRender(context);
-
- UIPageSelector2 uiPageSelector = getChild(UIPageSelector2.class);
- if (uiPageSelector == null)
- return;
- UIPopupWindow uiPopupWindowPage = uiPageSelector.getChild(UIPopupWindow.class);
- if (uiPopupWindowPage == null)
- return;
- uiPopupWindowPage.processRender(context);
- }
-
- public void setOwner(String owner_)
- {
- this.owner_ = owner_;
- }
-
- public String getOwner()
- {
- return owner_;
- }
-
- public void setOwnerType(String ownerType_)
- {
- this.ownerType_ = ownerType_;
- }
-
- public String getOwnerType()
- {
- return ownerType_;
- }
-
- static public class SaveActionListener extends EventListener<UIPageNodeForm2>
- {
- public void execute(Event<UIPageNodeForm2> event) throws Exception
- {
- WebuiRequestContext ctx = event.getRequestContext();
- UIPageNodeForm2 uiPageNodeForm = event.getSource();
- UIApplication uiApp = ctx.getUIApplication();
- if (uiPageNodeForm.getUIFormCheckBoxInput(SHOW_PUBLICATION_DATE).isChecked())
- {
- Calendar startCalendar =
-
uiPageNodeForm.getUIFormDateTimeInput(UIWizardPageSetInfo.START_PUBLICATION_DATE).getCalendar();
- Date startDate = startCalendar.getTime();
- Calendar endCalendar =
-
uiPageNodeForm.getUIFormDateTimeInput(UIWizardPageSetInfo.END_PUBLICATION_DATE).getCalendar();
- Date endDate = endCalendar.getTime();
- if (startDate.after(endDate))
- {
- uiApp.addMessage(new
ApplicationMessage("UIPageNodeForm2.msg.startDateBeforeEndDate", null));
- return;
- }
- }
-
- PageNode pageNode = uiPageNodeForm.getPageNode();
- if (pageNode == null)
- pageNode = new PageNode();
- uiPageNodeForm.invokeSetBindingBean(pageNode);
- UIPageSelector2 pageSelector = uiPageNodeForm.getChild(UIPageSelector2.class);
- if (pageSelector.getPage() == null)
- pageNode.setPageReference(null);
- UIFormInputIconSelector uiIconSelector =
uiPageNodeForm.getChild(UIFormInputIconSelector.class);
- if (uiIconSelector.getSelectedIcon().equals("Default"))
- pageNode.setIcon(null);
- else
- pageNode.setIcon(uiIconSelector.getSelectedIcon());
- if (pageNode.getLabel() == null)
- pageNode.setLabel(pageNode.getName());
-
- String remoteUser = ctx.getRemoteUser();
- Object selectedParent = uiPageNodeForm.getSelectedParent();
- PageNavigation pageNav = null;
-
- if (selectedParent instanceof PageNavigation)
- {
- pageNav = (PageNavigation)selectedParent;
- pageNode.setUri(pageNode.getName());
- if (!pageNav.getNodes().contains(pageNode))
- {
- if (PageNavigationUtils.searchPageNodeByUri(pageNav, pageNode.getUri()) !=
null)
- {
- uiApp.addMessage(new
ApplicationMessage("UIPageNodeForm2.msg.SameName", null));
- return;
- }
- pageNav.addNode(pageNode);
- }
- }
- else if (selectedParent instanceof PageNode)
- {
- PageNode parentNode = (PageNode)selectedParent;
- List<PageNode> children = parentNode.getChildren();
- if (children == null)
- {
- children = new ArrayList<PageNode>();
- parentNode.setChildren((ArrayList<PageNode>)children);
- }
- pageNode.setUri(parentNode.getUri() + "/" + pageNode.getName());
- if (!children.contains(pageNode))
- {
- if (PageNavigationUtils.searchPageNodeByUri(parentNode, pageNode.getUri())
!= null)
- {
- uiApp.addMessage(new
ApplicationMessage("UIPageNodeForm2.msg.SameName", null));
- return;
- }
- children.add(pageNode);
- }
- }
- uiPageNodeForm.createEvent("Back", Phase.DECODE, ctx).broadcast();
- }
- }
-
- static public class BackActionListener extends EventListener<UIPageNodeForm2>
- {
-
- public void execute(Event<UIPageNodeForm2> event) throws Exception
- {
- }
-
- }
-
- static public class SwitchPublicationDateActionListener extends
EventListener<UIPageNodeForm2>
- {
- public void execute(Event<UIPageNodeForm2> event) throws Exception
- {
- UIPageNodeForm2 uiForm = event.getSource();
- boolean isCheck =
uiForm.getUIFormCheckBoxInput(SHOW_PUBLICATION_DATE).isChecked();
- uiForm.getUIFormDateTimeInput(START_PUBLICATION_DATE).setRendered(isCheck);
- uiForm.getUIFormDateTimeInput(END_PUBLICATION_DATE).setRendered(isCheck);
- event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
- }
- }
-
- static public class ClearPageActionListener extends
EventListener<UIPageNodeForm2>
- {
- public void execute(Event<UIPageNodeForm2> event) throws Exception
- {
- UIPageNodeForm2 uiForm = event.getSource();
- UIPageSelector2 pageSelector =
uiForm.findFirstComponentOfType(UIPageSelector2.class);
- pageSelector.setPage(null);
- event.getRequestContext().addUIComponentToUpdateByAjax(pageSelector);
- }
- }
-
- static public class CreatePageActionListener extends
EventListener<UIPageNodeForm2>
- {
- public void execute(Event<UIPageNodeForm2> event) throws Exception
- {
- UIPageNodeForm2 uiForm = event.getSource();
- UIPageSelector2 pageSelector =
uiForm.findFirstComponentOfType(UIPageSelector2.class);
-
- PortalRequestContext pcontext = Util.getPortalRequestContext();
- UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
-
- UIFormInputSet uiInputSet = pageSelector.getChild(UIFormInputSet.class);
- List<UIComponent> children = uiInputSet.getChildren();
- /*********************************************************************/
- for (UIComponent uiChild : children)
- {
- if (uiChild instanceof UIFormInputBase)
- {
- UIFormInputBase uiInput = (UIFormInputBase)uiChild;
- if (!uiInput.isValid())
- continue;
- List<Validator> validators = uiInput.getValidators();
- if (validators == null)
- continue;
- try
- {
- for (Validator validator : validators)
- validator.validate(uiInput);
- }
- catch (MessageException ex)
- {
- uiPortalApp.addMessage(ex.getDetailMessage());
- return;
- }
- catch (Exception ex)
- {
- //TODO: This is a critical exception and should be handle in the
UIApplication
- uiPortalApp.addMessage(new ApplicationMessage(ex.getMessage(), null));
- return;
- }
- }
- }
-
- UserACL userACL = uiForm.getApplicationComponent(UserACL.class);
-
- String ownerId = uiForm.getOwner();
- String[] accessPermission = new String[1];
- accessPermission[0] = "*:" + ownerId;
- String editPermission = userACL.getMakableMT() + ":" + ownerId;
-
- if (PortalConfig.PORTAL_TYPE.equals(uiForm.getOwnerType()))
- {
- UIPortal uiPortal = Util.getUIPortal();
- accessPermission = uiPortal.getAccessPermissions();
- editPermission = uiPortal.getEditPermission();
- }
-
-
- UIFormStringInput uiPageName = uiInputSet.getChildById("pageName");
- UIFormStringInput uiPageTitle = uiInputSet.getChildById("pageTitle");
-
- Page page = new Page();
- page.setOwnerType(uiForm.getOwnerType());
- page.setOwnerId(ownerId);
- page.setName(uiPageName.getValue());
- String title = uiPageTitle.getValue();;
- if (title == null || title.trim().length() < 1)
- title = page.getName();
- page.setTitle(title);
-
- page.setShowMaxWindow(false);
-
- page.setAccessPermissions(accessPermission);
- page.setEditPermission(editPermission);
-
- userACL.hasPermission(page);
-
- page.setModifiable(true);
- if (page.getChildren() == null)
- page.setChildren(new ArrayList<ModelObject>());
-
- // check page is exist
- DataStorage dataService = uiForm.getApplicationComponent(DataStorage.class);
- Page existPage = dataService.getPage(page.getPageId());
- if (existPage != null)
- {
- uiPortalApp.addMessage(new
ApplicationMessage("UIPageForm.msg.sameName", null));
- pcontext.addUIComponentToUpdateByAjax(uiPortalApp.getUIPopupMessages());
- return;
- }
-
- // save page to database
- dataService.create(page);
- pageSelector.setValue(page.getPageId());
- }
- }
-}
Copied:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageNodeForm2.java
(from rev 2683,
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageNodeForm2.java)
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageNodeForm2.java
(rev 0)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageNodeForm2.java 2010-04-21
02:09:40 UTC (rev 2702)
@@ -0,0 +1,469 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.webui.page;
+
+import org.exoplatform.portal.application.PortalRequestContext;
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.UserACL;
+import org.exoplatform.portal.config.model.ModelObject;
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.webui.navigation.PageNavigationUtils;
+import org.exoplatform.portal.webui.portal.UIPortal;
+import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.portal.webui.workspace.UIPortalApplication;
+import org.exoplatform.web.application.ApplicationMessage;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.core.UIApplication;
+import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.core.UIPopupWindow;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
+import org.exoplatform.webui.event.Event.Phase;
+import org.exoplatform.webui.exception.MessageException;
+import org.exoplatform.webui.form.UIFormCheckBoxInput;
+import org.exoplatform.webui.form.UIFormDateTimeInput;
+import org.exoplatform.webui.form.UIFormInputBase;
+import org.exoplatform.webui.form.UIFormInputIconSelector;
+import org.exoplatform.webui.form.UIFormInputSet;
+import org.exoplatform.webui.form.UIFormStringInput;
+import org.exoplatform.webui.form.UIFormTabPane;
+import org.exoplatform.webui.form.validator.DateTimeValidator;
+import org.exoplatform.webui.form.validator.IdentifierValidator;
+import org.exoplatform.webui.form.validator.MandatoryValidator;
+import org.exoplatform.webui.form.validator.StringLengthValidator;
+import org.exoplatform.webui.form.validator.Validator;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Author : Dang Van Minh, Pham Tuan minhdv81(a)yahoo.com Jun 14, 2006
+ */
+public class UIPageNodeForm2 extends UIFormTabPane
+{
+
+ private PageNode pageNode_;
+
+ private String owner_;
+
+ private String ownerType_;
+
+ private Object selectedParent;
+
+ final private static String SHOW_PUBLICATION_DATE = "showPublicationDate";
+
+ final private static String START_PUBLICATION_DATE =
"startPublicationDate";
+
+ final private static String END_PUBLICATION_DATE = "endPublicationDate";
+
+ final private static String VISIBLE = "visible";
+
+ public UIPageNodeForm2() throws Exception
+ {
+ super("UIPageNodeForm");
+
+ UIFormInputSet uiSettingSet = new UIFormInputSet("PageNodeSetting");
+ UIFormCheckBoxInput<Boolean> uiDateInputCheck =
+ new UIFormCheckBoxInput<Boolean>(SHOW_PUBLICATION_DATE,
SHOW_PUBLICATION_DATE, false);
+ UIFormCheckBoxInput<Boolean> uiVisibleCheck = new
UIFormCheckBoxInput<Boolean>(VISIBLE, VISIBLE, true);
+
+ uiDateInputCheck.setOnChange("SwitchPublicationDate");
+ uiVisibleCheck.setOnChange("SwitchVisible");
+ uiSettingSet.addUIFormInput(new UIFormStringInput("uri", "uri",
null).setEditable(false))
+ .addUIFormInput(new UIFormStringInput("name", "name",
null).addValidator(MandatoryValidator.class).addValidator(StringLengthValidator.class, 3,
30).addValidator(IdentifierValidator.class))
+ .addUIFormInput(new UIFormStringInput("label", "label",
null).addValidator(StringLengthValidator.class, 3, 120))
+ .addUIFormInput(uiVisibleCheck.setChecked(true))
+ .addUIFormInput(uiDateInputCheck)
+ .addUIFormInput(new UIFormDateTimeInput(START_PUBLICATION_DATE, null,
null).addValidator(DateTimeValidator.class))
+ .addUIFormInput(new UIFormDateTimeInput(END_PUBLICATION_DATE, null,
null).addValidator(DateTimeValidator.class));
+
+ addUIFormInput(uiSettingSet);
+ setSelectedTab(uiSettingSet.getId());
+
+ UIPageSelector2 uiPageSelector = createUIComponent(UIPageSelector2.class, null,
null);
+ uiPageSelector.configure("UIPageSelector2", "pageReference");
+ addUIFormInput(uiPageSelector);
+
+ UIFormInputIconSelector uiIconSelector = new
UIFormInputIconSelector("Icon", "icon");
+ addUIFormInput(uiIconSelector);
+ setActions(new String[]{"Save", "Back"});
+ }
+
+ public PageNode getPageNode()
+ {
+ return pageNode_;
+ }
+
+ public void setValues(PageNode pageNode) throws Exception
+ {
+ pageNode_ = pageNode;
+ if (pageNode == null)
+ {
+ getUIStringInput("name").setEditable(UIFormStringInput.ENABLE);
+ getChild(UIFormInputIconSelector.class).setSelectedIcon("Default");
+ setShowPublicationDate(false);
+ return;
+ }
+ getUIStringInput("name").setEditable(UIFormStringInput.DISABLE);
+ invokeGetBindingBean(pageNode_);
+ }
+
+ public void invokeGetBindingBean(Object bean) throws Exception
+ {
+ super.invokeGetBindingBean(bean);
+ PageNode pageNode = (PageNode)bean;
+ String icon = pageNode_.getIcon();
+ if (icon == null || icon.length() < 0)
+ icon = "Default";
+ getChild(UIFormInputIconSelector.class).setSelectedIcon(icon);
+ getUIStringInput("label").setValue(pageNode_.getLabel());
+ getUIFormCheckBoxInput(VISIBLE).setChecked(pageNode_.isVisible());
+
getUIFormCheckBoxInput(SHOW_PUBLICATION_DATE).setChecked(pageNode.isShowPublicationDate());
+ setShowCheckPublicationDate(pageNode_.isVisible());
+ Calendar cal = Calendar.getInstance();
+ if (pageNode.getStartPublicationDate() != null)
+ {
+ cal.setTime(pageNode.getStartPublicationDate());
+ getUIFormDateTimeInput(START_PUBLICATION_DATE).setCalendar(cal);
+ }
+ else
+ getUIFormDateTimeInput(START_PUBLICATION_DATE).setValue(null);
+ if (pageNode.getEndPublicationDate() != null)
+ {
+ cal.setTime(pageNode.getEndPublicationDate());
+ getUIFormDateTimeInput(END_PUBLICATION_DATE).setCalendar(cal);
+ }
+ else
+ getUIFormDateTimeInput(END_PUBLICATION_DATE).setValue(null);
+ }
+
+ public void invokeSetBindingBean(Object bean) throws Exception
+ {
+ super.invokeSetBindingBean(bean);
+ PageNode node = (PageNode)bean;
+ Calendar cal = getUIFormDateTimeInput(START_PUBLICATION_DATE).getCalendar();
+ Date date = (cal != null) ? cal.getTime() : null;
+ node.setStartPublicationDate(date);
+ cal = getUIFormDateTimeInput(END_PUBLICATION_DATE).getCalendar();
+ date = (cal != null) ? cal.getTime() : null;
+ node.setEndPublicationDate(date);
+ }
+
+ public void setShowCheckPublicationDate(boolean show)
+ {
+ getUIFormCheckBoxInput(VISIBLE).setChecked(show);
+ UIFormCheckBoxInput<Boolean> uiForm =
getUIFormCheckBoxInput(SHOW_PUBLICATION_DATE);
+ uiForm.setRendered(show);
+ setShowPublicationDate(show && uiForm.isChecked());
+ }
+
+ public void setShowPublicationDate(boolean show)
+ {
+ getUIFormDateTimeInput(START_PUBLICATION_DATE).setRendered(show);
+ getUIFormDateTimeInput(END_PUBLICATION_DATE).setRendered(show);
+ }
+
+ public Object getSelectedParent()
+ {
+ return selectedParent;
+ }
+
+ public void setSelectedParent(Object obj)
+ {
+ this.selectedParent = obj;
+ }
+
+ public void processRender(WebuiRequestContext context) throws Exception
+ {
+ super.processRender(context);
+
+ UIPageSelector2 uiPageSelector = getChild(UIPageSelector2.class);
+ if (uiPageSelector == null)
+ return;
+ UIPopupWindow uiPopupWindowPage = uiPageSelector.getChild(UIPopupWindow.class);
+ if (uiPopupWindowPage == null)
+ return;
+ uiPopupWindowPage.processRender(context);
+ }
+
+ public void setOwner(String owner_)
+ {
+ this.owner_ = owner_;
+ }
+
+ public String getOwner()
+ {
+ return owner_;
+ }
+
+ public void setOwnerType(String ownerType_)
+ {
+ this.ownerType_ = ownerType_;
+ }
+
+ public String getOwnerType()
+ {
+ return ownerType_;
+ }
+
+ static public class SaveActionListener extends EventListener<UIPageNodeForm2>
+ {
+ public void execute(Event<UIPageNodeForm2> event) throws Exception
+ {
+ WebuiRequestContext ctx = event.getRequestContext();
+ UIPageNodeForm2 uiPageNodeForm = event.getSource();
+ UIApplication uiPortalApp = ctx.getUIApplication();
+ if (uiPageNodeForm.getUIFormCheckBoxInput(SHOW_PUBLICATION_DATE).isChecked())
+ {
+ Calendar currentCalendar = Calendar.getInstance();
+ currentCalendar.set(currentCalendar.get(Calendar.YEAR),
currentCalendar.get(Calendar.MONTH), currentCalendar.get(Calendar.DAY_OF_MONTH), 0, 0,
0);
+ Date currentDate = currentCalendar.getTime();
+
+ Calendar startCalendar =
+
uiPageNodeForm.getUIFormDateTimeInput(UIWizardPageSetInfo.START_PUBLICATION_DATE).getCalendar();
+ Date startDate = startCalendar != null ? startCalendar.getTime() :
currentDate;
+ Calendar endCalendar =
+
uiPageNodeForm.getUIFormDateTimeInput(UIWizardPageSetInfo.END_PUBLICATION_DATE).getCalendar();
+ Date endDate = endCalendar != null ? endCalendar.getTime() : null;
+
+ // Case 1: current date after start date
+ if (currentDate.after(startDate))
+ {
+ Object[] args = {};
+ uiPortalApp.addMessage(new
ApplicationMessage("UIPageNodeForm2.msg.currentDateBeforeStartDate", args,
ApplicationMessage.WARNING));
+ return;
+ }
+ // Case 2: start date after end date
+ else if ((endCalendar != null) && (startCalendar != null) &&
(startDate.after(endDate)))
+ {
+ Object[] args = {};
+ uiPortalApp.addMessage(new
ApplicationMessage("UIPageNodeForm2.msg.startDateBeforeEndDate", args,
ApplicationMessage.WARNING));
+ return;
+ }
+ // Case 3: start date is null and current date after end date
+ else if((endCalendar != null) && (currentDate.after(endDate)))
+ {
+ Object[] args = {};
+ uiPortalApp.addMessage(new
ApplicationMessage("UIPageNodeForm2.msg.currentDateBeforeEndDate", args,
ApplicationMessage.WARNING));
+ return;
+ }
+
+ }
+
+ PageNode pageNode = uiPageNodeForm.getPageNode();
+ if (pageNode == null)
+ pageNode = new PageNode();
+ uiPageNodeForm.invokeSetBindingBean(pageNode);
+ UIPageSelector2 pageSelector = uiPageNodeForm.getChild(UIPageSelector2.class);
+ if (pageSelector.getPage() == null)
+ pageNode.setPageReference(null);
+ UIFormInputIconSelector uiIconSelector =
uiPageNodeForm.getChild(UIFormInputIconSelector.class);
+ if (uiIconSelector.getSelectedIcon().equals("Default"))
+ pageNode.setIcon(null);
+ else
+ pageNode.setIcon(uiIconSelector.getSelectedIcon());
+ if (pageNode.getLabel() == null)
+ pageNode.setLabel(pageNode.getName());
+
+ Object selectedParent = uiPageNodeForm.getSelectedParent();
+ PageNavigation pageNav = null;
+
+ if (selectedParent instanceof PageNavigation)
+ {
+ pageNav = (PageNavigation)selectedParent;
+ pageNode.setUri(pageNode.getName());
+ if (!pageNav.getNodes().contains(pageNode))
+ {
+ if (PageNavigationUtils.searchPageNodeByUri(pageNav, pageNode.getUri()) !=
null)
+ {
+ uiPortalApp.addMessage(new
ApplicationMessage("UIPageNodeForm2.msg.SameName", null));
+ return;
+ }
+ pageNav.addNode(pageNode);
+ }
+ }
+ else if (selectedParent instanceof PageNode)
+ {
+ PageNode parentNode = (PageNode)selectedParent;
+ List<PageNode> children = parentNode.getChildren();
+ if (children == null)
+ {
+ children = new ArrayList<PageNode>();
+ parentNode.setChildren((ArrayList<PageNode>)children);
+ }
+ pageNode.setUri(parentNode.getUri() + "/" + pageNode.getName());
+ if (!children.contains(pageNode))
+ {
+ if (PageNavigationUtils.searchPageNodeByUri(parentNode, pageNode.getUri())
!= null)
+ {
+ uiPortalApp.addMessage(new
ApplicationMessage("UIPageNodeForm2.msg.SameName", null));
+ return;
+ }
+ children.add(pageNode);
+ }
+ }
+ uiPageNodeForm.createEvent("Back", Phase.DECODE, ctx).broadcast();
+ }
+ }
+
+ static public class BackActionListener extends EventListener<UIPageNodeForm2>
+ {
+
+ public void execute(Event<UIPageNodeForm2> event) throws Exception
+ {
+ }
+
+ }
+
+ static public class SwitchPublicationDateActionListener extends
EventListener<UIPageNodeForm2>
+ {
+ public void execute(Event<UIPageNodeForm2> event) throws Exception
+ {
+ UIPageNodeForm2 uiForm = event.getSource();
+ boolean isCheck =
uiForm.getUIFormCheckBoxInput(SHOW_PUBLICATION_DATE).isChecked();
+ uiForm.setShowPublicationDate(isCheck);
+ event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
+ }
+ }
+
+ static public class SwitchVisibleActionListener extends
EventListener<UIPageNodeForm2>
+ {
+ @Override
+ public void execute(Event<UIPageNodeForm2> event) throws Exception
+ {
+ UIPageNodeForm2 uiForm = event.getSource();
+ boolean isCheck = uiForm.getUIFormCheckBoxInput(VISIBLE).isChecked();
+ uiForm.setShowCheckPublicationDate(isCheck);
+ event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
+ }
+ }
+
+ static public class ClearPageActionListener extends
EventListener<UIPageNodeForm2>
+ {
+ public void execute(Event<UIPageNodeForm2> event) throws Exception
+ {
+ UIPageNodeForm2 uiForm = event.getSource();
+ UIPageSelector2 pageSelector =
uiForm.findFirstComponentOfType(UIPageSelector2.class);
+ pageSelector.setPage(null);
+ event.getRequestContext().addUIComponentToUpdateByAjax(pageSelector);
+ }
+ }
+
+ static public class CreatePageActionListener extends
EventListener<UIPageNodeForm2>
+ {
+ public void execute(Event<UIPageNodeForm2> event) throws Exception
+ {
+ UIPageNodeForm2 uiForm = event.getSource();
+ UIPageSelector2 pageSelector =
uiForm.findFirstComponentOfType(UIPageSelector2.class);
+
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+ UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
+
+ UIFormInputSet uiInputSet = pageSelector.getChild(UIFormInputSet.class);
+ List<UIComponent> children = uiInputSet.getChildren();
+ /*********************************************************************/
+ for (UIComponent uiChild : children)
+ {
+ if (uiChild instanceof UIFormInputBase)
+ {
+ UIFormInputBase uiInput = (UIFormInputBase)uiChild;
+ if (!uiInput.isValid())
+ continue;
+ List<Validator> validators = uiInput.getValidators();
+ if (validators == null)
+ continue;
+ try
+ {
+ for (Validator validator : validators)
+ validator.validate(uiInput);
+ }
+ catch (MessageException ex)
+ {
+ uiPortalApp.addMessage(ex.getDetailMessage());
+ return;
+ }
+ catch (Exception ex)
+ {
+ //TODO: This is a critical exception and should be handle in the
UIApplication
+ uiPortalApp.addMessage(new ApplicationMessage(ex.getMessage(), null));
+ return;
+ }
+ }
+ }
+
+ UserACL userACL = uiForm.getApplicationComponent(UserACL.class);
+
+ String ownerId = uiForm.getOwner();
+ String[] accessPermission = new String[1];
+ accessPermission[0] = "*:" + ownerId;
+ String editPermission = userACL.getMakableMT() + ":" + ownerId;
+
+ if (PortalConfig.PORTAL_TYPE.equals(uiForm.getOwnerType()))
+ {
+ UIPortal uiPortal = Util.getUIPortal();
+ accessPermission = uiPortal.getAccessPermissions();
+ editPermission = uiPortal.getEditPermission();
+ }
+
+
+ UIFormStringInput uiPageName = uiInputSet.getChildById("pageName");
+ UIFormStringInput uiPageTitle = uiInputSet.getChildById("pageTitle");
+
+ Page page = new Page();
+ page.setOwnerType(uiForm.getOwnerType());
+ page.setOwnerId(ownerId);
+ page.setName(uiPageName.getValue());
+ String title = uiPageTitle.getValue();;
+ if (title == null || title.trim().length() < 1)
+ title = page.getName();
+ page.setTitle(title);
+
+ page.setShowMaxWindow(false);
+
+ page.setAccessPermissions(accessPermission);
+ page.setEditPermission(editPermission);
+
+ userACL.hasPermission(page);
+
+ page.setModifiable(true);
+ if (page.getChildren() == null)
+ page.setChildren(new ArrayList<ModelObject>());
+
+ // check page is exist
+ DataStorage dataService = uiForm.getApplicationComponent(DataStorage.class);
+ Page existPage = dataService.getPage(page.getPageId());
+ if (existPage != null)
+ {
+ uiPortalApp.addMessage(new
ApplicationMessage("UIPageForm.msg.sameName", null));
+ pcontext.addUIComponentToUpdateByAjax(uiPortalApp.getUIPopupMessages());
+ return;
+ }
+
+ // save page to database
+ dataService.create(page);
+ pageSelector.setValue(page.getPageId());
+ }
+ }
+}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIWizardPageSetInfo.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIWizardPageSetInfo.java 2010-04-21
01:23:26 UTC (rev 2701)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIWizardPageSetInfo.java 2010-04-21
02:09:40 UTC (rev 2702)
@@ -60,6 +60,7 @@
*/
@ComponentConfigs({@ComponentConfig(lifecycle = UIFormLifecycle.class, template =
"system:/groovy/portal/webui/page/UIWizardPageSetInfo.gtmpl", events = {
@EventConfig(listeners = UIWizardPageSetInfo.ChangeNodeActionListener.class, phase =
Phase.DECODE),
+ @EventConfig(listeners = UIWizardPageSetInfo.SwitchVisibleActionListener.class, phase
= Phase.DECODE),
@EventConfig(listeners =
UIWizardPageSetInfo.SwitchPublicationDateActionListener.class, phase = Phase.DECODE)})})
public class UIWizardPageSetInfo extends UIForm
{
@@ -82,20 +83,21 @@
public UIWizardPageSetInfo() throws Exception
{
+ UIFormCheckBoxInput<Boolean> uiDateInputCheck =
+ new UIFormCheckBoxInput<Boolean>(SHOW_PUBLICATION_DATE,
SHOW_PUBLICATION_DATE, false);
+ UIFormCheckBoxInput<Boolean> uiVisibleCheck = new
UIFormCheckBoxInput<Boolean>(VISIBLE, VISIBLE, false);
+ uiDateInputCheck.setOnChange("SwitchPublicationDate");
+ uiVisibleCheck.setOnChange("SwitchVisible");
+
addChild(UIPageNodeSelector.class, null, null);
addUIFormInput(new UIFormStringInput(PAGE_NAME, "name",
null).addValidator(MandatoryValidator.class)
- .addValidator(StringLengthValidator.class, 3,
30).addValidator(IdentifierValidator.class));
- addUIFormInput(new UIFormStringInput(PAGE_DISPLAY_NAME, "label",
null).setMaxLength(255).addValidator(
- StringLengthValidator.class, 3, 120));
- addUIFormInput(new UIFormCheckBoxInput<Boolean>(VISIBLE, VISIBLE,
false).setChecked(true));
- UIFormCheckBoxInput<Boolean> uiDateInputCheck =
- new UIFormCheckBoxInput<Boolean>(SHOW_PUBLICATION_DATE,
SHOW_PUBLICATION_DATE, false);
- uiDateInputCheck.setOnChange("SwitchPublicationDate");
+ .addValidator(StringLengthValidator.class, 3,
30).addValidator(IdentifierValidator.class));
+ addUIFormInput(new UIFormStringInput(PAGE_DISPLAY_NAME, "label", null)
+ .setMaxLength(255).addValidator(StringLengthValidator.class, 3, 120));
+ addUIFormInput(uiVisibleCheck.setChecked(true));
addUIFormInput(uiDateInputCheck);
- addUIFormInput(new UIFormDateTimeInput(START_PUBLICATION_DATE, null,
null).addValidator(DateTimeValidator.class)
- .addValidator(MandatoryValidator.class));
- addUIFormInput(new UIFormDateTimeInput(END_PUBLICATION_DATE, null,
null).addValidator(DateTimeValidator.class)
- .addValidator(MandatoryValidator.class));
+ addUIFormInput(new UIFormDateTimeInput(START_PUBLICATION_DATE, null,
null).addValidator(DateTimeValidator.class));
+ addUIFormInput(new UIFormDateTimeInput(END_PUBLICATION_DATE, null,
null).addValidator(DateTimeValidator.class));
}
public void setEditMode() throws Exception
@@ -114,7 +116,10 @@
{
super.invokeSetBindingBean(bean);
PageNode node = (PageNode)bean;
- node.setVisible(getUIFormCheckBoxInput(VISIBLE).isChecked());
+ if(!getUIFormCheckBoxInput(SHOW_PUBLICATION_DATE).isChecked())
+ {
+ node.setVisible(getUIFormCheckBoxInput(VISIBLE).isChecked());
+ }
Calendar cal = getUIFormDateTimeInput(START_PUBLICATION_DATE).getCalendar();
Date date = (cal != null) ? cal.getTime() : null;
node.setStartPublicationDate(date);
@@ -161,9 +166,16 @@
return pageNode;
}
+ public void setShowCheckPublicationDate(boolean show)
+ {
+ getUIFormCheckBoxInput(VISIBLE).setChecked(show);
+ UIFormCheckBoxInput<Boolean> uiForm =
getUIFormCheckBoxInput(SHOW_PUBLICATION_DATE);
+ uiForm.setRendered(show);
+ setShowPublicationDate(show && uiForm.isChecked());
+ }
+
public void setShowPublicationDate(boolean show)
{
- getUIFormCheckBoxInput(SHOW_PUBLICATION_DATE).setChecked(show);
getUIFormDateTimeInput(START_PUBLICATION_DATE).setRendered(show);
getUIFormDateTimeInput(END_PUBLICATION_DATE).setRendered(show);
}
@@ -304,5 +316,17 @@
}
}
+
+ static public class SwitchVisibleActionListener extends
EventListener<UIWizardPageSetInfo>
+ {
+ @Override
+ public void execute(Event<UIWizardPageSetInfo> event) throws Exception
+ {
+ UIWizardPageSetInfo uiForm = event.getSource();
+ boolean isCheck = uiForm.getUIFormCheckBoxInput(VISIBLE).isChecked();
+ uiForm.setShowCheckPublicationDate(isCheck);
+ event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
+ }
+ }
}