1 17 package org.alfresco.web.bean.wizard; 18 19 import java.util.ResourceBundle ; 20 21 import javax.faces.context.FacesContext; 22 import javax.faces.event.ValueChangeEvent; 23 24 import org.alfresco.web.app.Application; 25 import org.alfresco.web.bean.repository.Repository; 26 27 32 public class CreateContentWizard extends BaseContentWizard 33 { 34 protected static final String CONTENT_TEXT = "txt"; 35 protected static final String CONTENT_HTML = "html"; 36 37 private static final String WIZARD_TITLE_ID = "create_content_title"; 39 private static final String WIZARD_DESC_ID = "create_content_desc"; 40 private static final String STEP1_TITLE_ID = "create_content_step1_title"; 41 private static final String STEP1_DESCRIPTION_ID = "create_content_step1_desc"; 42 private static final String STEP2_TITLE_ID = "create_content_step2_title"; 43 private static final String STEP2_DESCRIPTION_ID = "create_content_step2_desc"; 44 private static final String STEP3_TITLE_ID = "create_content_step3_title"; 45 private static final String STEP3_DESCRIPTION_ID = "create_content_step3_desc"; 46 47 protected String content; 49 protected String createType = CONTENT_HTML; 50 51 52 57 public String finish() 58 { 59 return saveContent(null, this.content); 60 } 61 62 65 public String getWizardDescription() 66 { 67 return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_DESC_ID); 68 } 69 70 73 public String getWizardTitle() 74 { 75 return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_TITLE_ID); 76 } 77 78 81 public String getStepDescription() 82 { 83 String stepDesc = null; 84 85 switch (this.currentStep) 86 { 87 case 1: 88 { 89 stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), STEP1_DESCRIPTION_ID); 90 break; 91 } 92 case 2: 93 { 94 stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), STEP2_DESCRIPTION_ID); 95 break; 96 } 97 case 3: 98 { 99 stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), STEP3_DESCRIPTION_ID); 100 break; 101 } 102 case 4: 103 { 104 stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), SUMMARY_DESCRIPTION_ID); 105 break; 106 } 107 default: 108 { 109 stepDesc = ""; 110 } 111 } 112 113 return stepDesc; 114 } 115 116 119 public String getStepInstructions() 120 { 121 String stepInstruction = null; 122 123 switch (this.currentStep) 124 { 125 case 4: 126 { 127 stepInstruction = Application.getMessage(FacesContext.getCurrentInstance(), FINISH_INSTRUCTION_ID); 128 break; 129 } 130 default: 131 { 132 stepInstruction = Application.getMessage(FacesContext.getCurrentInstance(), DEFAULT_INSTRUCTION_ID); 133 } 134 } 135 136 return stepInstruction; 137 } 138 139 142 public String getStepTitle() 143 { 144 String stepTitle = null; 145 146 switch (this.currentStep) 147 { 148 case 1: 149 { 150 stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP1_TITLE_ID); 151 break; 152 } 153 case 2: 154 { 155 stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP2_TITLE_ID); 156 break; 157 } 158 case 3: 159 { 160 stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP3_TITLE_ID); 161 break; 162 } 163 case 4: 164 { 165 stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), SUMMARY_TITLE_ID); 166 break; 167 } 168 default: 169 { 170 stepTitle = ""; 171 } 172 } 173 174 return stepTitle; 175 } 176 177 180 public String getContent() 181 { 182 return this.content; 183 } 184 185 188 public void setContent(String content) 189 { 190 this.content = content; 191 } 192 193 196 public void init() 197 { 198 super.init(); 199 200 this.content = null; 201 202 this.inlineEdit = true; 204 } 205 206 209 public String getSummary() 210 { 211 ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance()); 212 213 return buildSummary( 215 new String [] {bundle.getString("file_name"), bundle.getString("type"), 216 bundle.getString("content_type"), bundle.getString("title"), 217 bundle.getString("description"), bundle.getString("author")}, 218 new String [] {this.fileName, getSummaryObjectType(), getSummaryContentType(), 219 this.title, this.description, this.author}); 220 } 221 222 225 protected String determineOutcomeForStep(int step) 226 { 227 String outcome = null; 228 229 switch(step) 230 { 231 case 1: 232 { 233 outcome = "select"; 234 break; 235 } 236 case 2: 237 { 238 if (getCreateType().equals(CONTENT_HTML)) 239 { 240 outcome = "create-html"; 241 } 242 else if (getCreateType().equals(CONTENT_TEXT)) 243 { 244 outcome = "create-text"; 245 } 246 break; 247 } 248 case 3: 249 { 250 this.fileName = "newfile." + getCreateType(); 251 this.contentType = Repository.getMimeTypeForFileName( 252 FacesContext.getCurrentInstance(), this.fileName); 253 this.title = this.fileName; 254 255 outcome = "properties"; 256 break; 257 } 258 case 4: 259 { 260 outcome = "summary"; 261 break; 262 } 263 default: 264 { 265 outcome = CANCEL_OUTCOME; 266 } 267 } 268 269 return outcome; 270 } 271 272 275 public void createContentChanged(ValueChangeEvent event) 276 { 277 this.content = null; 279 } 280 281 284 public String getCreateType() 285 { 286 return this.createType; 287 } 288 289 292 public void setCreateType(String createType) 293 { 294 this.createType = createType; 295 } 296 } 297 | Popular Tags |