1 25 26 package net.killingar.forum.actions; 27 28 import net.killingar.forum.internal.managers.OptionsManager; 29 import webwork.action.ParameterAware; 30 31 import java.util.ArrayList ; 32 import java.util.List ; 33 import java.util.Map ; 34 35 public class EditAppearance 36 extends net.killingar.forum.actions.area.ActionAreaSupport 37 implements ParameterAware 38 { 39 OptionsManager optionmgr; 40 List stringOptions; 41 String customHtml; 42 Map parameters; 43 44 static final String stringOptionsData[][] = 45 { 46 {"arrow down url", "URL for down arrow picture", "/_common/img/arrowdown.gif"}, 47 {"arrow up url", "URL for up arrow picture", "/_common/img/arrowup.gif"}, 48 {"bar image", "default bar image for polls", "servlet/Pixel?722899"}, 49 {"hr", "horizontal ruler", "<img SRC=\"/_common/img/color.gif\" width=\"100%\" height=\"13\" alt=\"horizontal ruler\"/><br />"}, 50 {"logo url", "contents logo url", "/_common/img/logo_small.gif"}, 51 }; 52 53 public void setParameters(Map map) { parameters = map; } 54 public void setSession(Map map) 55 { 56 super.setSession(map); 57 try 58 { 59 synchronized (map) 60 { 61 optionmgr = (OptionsManager)manager.getManager(OptionsManager.class.getName()); 62 if (optionmgr == null) 63 addErrorMessage("failed to initialize options manager, null returned"); 64 } 65 } 66 catch (Exception exception) 67 { 68 addErrorMessage("failed to initialize options manager, exception thrown (" + exception.toString() + ")"); 69 exception.printStackTrace(); 70 } 71 } 72 73 public List getStringOptions() { return stringOptions; } 74 75 protected String doExecute() 76 { 77 try 78 { 79 if (parameters.containsKey("change")) 80 { 81 for (int k = 0; k < stringOptionsData.length; k++) 82 { 83 if (parameters.containsKey(stringOptionsData[k][0])) 84 { 85 String s = ((String [])parameters.get(stringOptionsData[k][0]))[0]; 86 if (s != null && s.equals(stringOptionsData[k][2])) 87 s = null; 88 optionmgr.set(stringOptionsData[k][0], s); 89 } 90 } 91 92 } 93 stringOptions = new ArrayList (); 94 for (int i = 0; i < stringOptionsData.length; i++) 95 stringOptions.add(new StringOption(stringOptionsData[i][0], stringOptionsData[i][1], optionmgr.get(stringOptionsData[i][0]), stringOptionsData[i][2])); 96 97 return SUCCESS; 98 } 99 catch (Exception exception) 100 { 101 addErrorMessage("edit options failed, exception thrown (" + exception.toString() + ")"); 102 exception.printStackTrace(); 103 return ERROR; 104 } 105 } 106 } | Popular Tags |