public static class ViewStep2ActionListener extends EventListener<UIPageCreationWizard> {
public void execute(Event<UIPageCreationWizard> event) throws Exception {
UIPageCreationWizard uiWizard = event.getSource();
uiWizard.setShowActions(true);
UIPortalApplication uiPortalApp = uiWizard.getAncestorOfType(UIPortalApplication.class);
UIWorkingWorkspace uiWorkingWS = uiWizard.getAncestorOfType(UIWorkingWorkspace.class);
uiWorkingWS.findFirstComponentOfType(UIPortalComposer.class).setRendered(false);
uiWizard.viewStep(SECOND_STEP);
if (uiWizard.getSelectedStep() < SECOND_STEP) {
uiPortalApp.addMessage(new ApplicationMessage("UIPageCreationWizard.msg.StepByStep", null));
uiWizard.viewStep(FIRST_STEP);
uiWizard.updateWizardComponent();
return;
}
if (uiWizard.isSelectedNodeExist()) {
uiPortalApp.addMessage(new ApplicationMessage("UIPageCreationWizard.msg.NameNotSame", null));
uiWizard.viewStep(FIRST_STEP);
uiWizard.updateWizardComponent();
return;
}
UIWizardPageSetInfo uiPageSetInfo = uiWizard.getChild(UIWizardPageSetInfo.class);
UIPageNodeSelector uiNodeSelector = uiPageSetInfo.getChild(UIPageNodeSelector.class);
uiWizard.updateWizardComponent();
UserNavigation navigation = uiNodeSelector.getNavigation();
if (navigation == null) {
uiPortalApp.addMessage(new ApplicationMessage("UIPageCreationWizard.msg.notSelectedPageNavigation",
new String[] {}));
uiWizard.viewStep(FIRST_STEP);
return;
}
if (uiPageSetInfo.getUICheckBoxInput(UIWizardPageSetInfo.VISIBLE).isChecked()
&& uiPageSetInfo.getUICheckBoxInput(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 != null) ? startCalendar.getTime() : currentDate;
Calendar endCalendar = uiPageSetInfo.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("UIPageNodeForm.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("UIPageNodeForm.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("UIPageNodeForm.msg.currentDateBeforeEndDate", args,
ApplicationMessage.WARNING));
uiWizard.viewStep(FIRST_STEP);
return;
}
}