1 19 20 package com.sslexplorer.wizard; 21 22 import java.util.ArrayList ; 23 import java.util.HashMap ; 24 import java.util.List ; 25 import java.util.Map ; 26 27 import org.apache.struts.action.ActionForward; 28 29 import com.sslexplorer.security.SessionInfo; 30 import com.sslexplorer.wizard.forms.AbstractWizardForm; 31 32 41 public abstract class AbstractWizardSequence { 42 43 45 private HashMap attributes; 46 private ActionForward finishActionForward; 47 private AbstractWizardForm currentPageForm; 48 private String resourcePrefix; 49 private String resourceBundle; 50 private List steps; 51 private String referer; 52 private List forms; 53 private String wizardName; 54 private SessionInfo session; 55 56 66 public AbstractWizardSequence(ActionForward finishActionForward, String resourceBundle, String resourcePrefix, String referer, String wizardName, SessionInfo session) { 67 super(); 68 this.finishActionForward = finishActionForward; 69 this.resourceBundle = resourceBundle; 70 this.resourcePrefix = resourcePrefix; 71 this.referer = referer; 72 this.wizardName = wizardName; 73 this.session = session; 74 steps = new ArrayList (); 75 attributes = new HashMap (); 76 forms = new ArrayList (); 77 } 78 79 84 public List getForms() { 85 return forms; 86 } 87 88 93 public List getSteps() { 94 return steps; 95 } 96 97 100 public void addStep(WizardStep step) { 101 steps.add(step); 102 } 103 104 109 public AbstractWizardForm getCurrentPageForm() { 110 return currentPageForm; 111 } 112 113 120 public void setCurrentPageForm(AbstractWizardForm currentPageForm) { 121 this.currentPageForm = currentPageForm; 122 for(int i = 0; i < currentPageForm.getStepIndex(); i++) { 123 ((WizardStep)steps.get(i)).setAvailable(true); 124 } 125 if(!forms.contains(currentPageForm)) { 126 forms.add(currentPageForm); 127 } 128 } 129 130 135 public Map getAttributes() { 136 return attributes; 137 } 138 139 146 public Object putAttribute(Object key, Object val) { 147 return attributes.put(key, val); 148 } 149 150 157 public Object getAttribute(Object key, Object defVal) { 158 Object o = attributes.get(key); 159 return o == null ? defVal : o; 160 } 161 162 167 public ActionForward getFinishActionForward() { 168 return finishActionForward; 169 } 170 171 176 public void removeAttribute(String key) { 177 attributes.remove(key); 178 } 179 180 183 public String getResourceBundle() { 184 return resourceBundle; 185 } 186 187 190 public String getResourcePrefix() { 191 return resourcePrefix; 192 } 193 194 197 public String getReferer() { 198 return referer; 199 } 200 201 207 public boolean hasAttribute(String key) { 208 return attributes.containsKey(key); 209 } 210 211 214 public String getWizardName() { 215 return wizardName; 216 } 217 218 223 public SessionInfo getSession() { 224 return session; 225 } 226 } 227 | Popular Tags |