1   package com.atlassian.plugins.codegen.modules.common.web;
2   
3   import java.util.HashMap;
4   import java.util.Map;
5   
6   import com.atlassian.plugins.codegen.modules.common.Icon;
7   import com.atlassian.plugins.codegen.modules.common.Label;
8   import com.atlassian.plugins.codegen.modules.common.Link;
9   import com.atlassian.plugins.codegen.modules.common.Tooltip;
10  
11  /**
12   * @since 3.6
13   */
14  public class WebItemProperties extends AbstractWebFragmentProperties
15  {
16  
17      public static final String SECTION = "SECTION";
18      public static final String ICON = "ICON";
19      public static final String STYLE_CLASS = "STYLE_CLASS";
20      public static final String LINK = "LINK";
21      public static final String LABEL = "LABEL";
22      public static final String PARAMS = "PARAMS";
23      public static final String TOOLTIP = "TOOLTIP";
24  
25      public WebItemProperties()
26      {
27          this("My Web Item");
28      }
29  
30      public WebItemProperties(String moduleName)
31      {
32          super(moduleName);
33          setParams(new HashMap<String, String>());
34      }
35  
36      public WebItemProperties(String moduleName, String section)
37      {
38          this(moduleName);
39          setSection(section);
40      }
41  
42      public void setSection(String section)
43      {
44          setProperty(SECTION, section);
45      }
46  
47      public String getSection()
48      {
49          return getProperty(SECTION);
50      }
51  
52      public void setLink(Link link)
53      {
54          put(LINK, link);
55      }
56  
57      public Link getLink()
58      {
59          Link link = null;
60          if (keySet().contains(LINK))
61          {
62              link = (Link) get(LINK);
63          }
64          return link;
65      }
66  
67      public void setIcon(Icon icon)
68      {
69          put(ICON, icon);
70      }
71  
72      public Icon getIcon()
73      {
74          Icon icon = null;
75          if (keySet().contains(ICON))
76          {
77              icon = (Icon) get(ICON);
78          }
79          return icon;
80      }
81  
82      public void setStyleClass(String styleClass)
83      {
84          setProperty(STYLE_CLASS, styleClass);
85      }
86  
87      public String getStyleClass()
88      {
89          return getProperty(STYLE_CLASS);
90      }
91  
92      public void setLabel(Label label)
93      {
94          put(LABEL, label);
95          addI18nProperty(label.getKey(), label.getValue());
96      }
97  
98      public Label getLabel()
99      {
100         Label label = null;
101         if (keySet().contains(LABEL))
102         {
103             label = (Label) get(LABEL);
104         }
105         return label;
106     }
107 
108     public void setTooltip(Tooltip tooltip)
109     {
110         put(TOOLTIP, tooltip);
111         addI18nProperty(tooltip.getKey(), tooltip.getValue());
112     }
113 
114     public Tooltip getTooltip()
115     {
116         Tooltip tooltip = null;
117         if (keySet().contains(TOOLTIP))
118         {
119             tooltip = (Tooltip) get(TOOLTIP);
120         }
121         return tooltip;
122     }
123 
124     public void setParams(Map<String, String> params)
125     {
126         put(PARAMS, params);
127     }
128 
129     public void addParam(String name, String value)
130     {
131         getParams().put(name, value);
132     }
133 
134     public String getParam(String name)
135     {
136         return getParams().get(name);
137     }
138 
139     private Map<String, String> getParams()
140     {
141         return ((Map<String, String>) get(PARAMS));
142     }
143 }