001/* 002 * (C) Copyright 2006-2008 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * bstefanescu 018 */ 019package org.nuxeo.ecm.webengine.ui.wizard; 020 021import java.io.Serializable; 022 023import org.nuxeo.ecm.webengine.forms.validation.Form; 024 025/** 026 * @author <a href="mailto:[email protected]">Bogdan Stefanescu</a> 027 */ 028public class WizardPage implements Serializable { 029 030 private static final long serialVersionUID = -1156377274574342525L; 031 032 public static final String NEXT_PAGE = ""; 033 034 public static final int NEXT = 1; 035 036 public static final int BACK = 2; 037 038 public static final int CANCEL = 4; 039 040 public static final int OK = 8; 041 042 public static final int INITIAL = NEXT | CANCEL; 043 044 public static final int MIDDLE = INITIAL | BACK; 045 046 public static final int LAST = OK | BACK | CANCEL; 047 048 protected int index; 049 050 protected final String nextPageId; 051 052 protected final Class<? extends Form> formType; 053 054 protected final String id; 055 056 protected final int style; 057 058 protected Form form; // the submitted form if any 059 060 protected WizardPage prev; // to implement a stack of pages 061 062 public WizardPage(String id, Class<? extends Form> formType) { 063 this(id, formType, MIDDLE); 064 } 065 066 public WizardPage(String id, Class<? extends Form> formType, int style) { 067 this(id, formType, NEXT_PAGE, style); 068 } 069 070 public WizardPage(String id, Class<? extends Form> formType, String nextPageId) { 071 this(id, formType, nextPageId, MIDDLE); 072 } 073 074 public WizardPage(String id, Class<? extends Form> formType, String nextPageId, int style) { 075 this.id = id; 076 this.formType = formType; 077 this.nextPageId = nextPageId; 078 this.style = style; 079 this.prev = null; 080 } 081 082 public Class<? extends Form> getFormType() { 083 return formType; 084 } 085 086 public String getId() { 087 return id; 088 } 089 090 public boolean isNextEnabled() { 091 return (style & NEXT) != 0; 092 } 093 094 public boolean isBackEnabled() { 095 return (style & BACK) != 0; 096 } 097 098 public boolean isOkEnabled() { 099 return (style & OK) != 0; 100 } 101 102 public boolean isCancelEnabled() { 103 return (style & CANCEL) != 0; 104 } 105 106 public void setForm(Form form) { 107 this.form = form; 108 } 109 110 public Form getForm() { 111 return form; 112 } 113 114 public void setIndex(int index) { 115 this.index = index; 116 } 117 118 public int getIndex() { 119 return index; 120 } 121 122 public <T extends Form> String getNextPage(Wizard wizard, T form) { 123 return nextPageId; 124 } 125 126}