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 LINK = "LINK";
20      public static final String LABEL = "LABEL";
21      public static final String PARAMS = "PARAMS";
22      public static final String TOOLTIP = "TOOLTIP";
23  
24      public WebItemProperties()
25      {
26          this("My Web Item");
27      }
28  
29      public WebItemProperties(String moduleName)
30      {
31          super(moduleName);
32          setParams(new HashMap<String, String>());
33      }
34  
35      public WebItemProperties(String moduleName, String section)
36      {
37          this(moduleName);
38          setSection(section);
39      }
40  
41      public void setSection(String section)
42      {
43          setProperty(SECTION, section);
44      }
45  
46      public String getSection()
47      {
48          return getProperty(SECTION);
49      }
50  
51      public void setLink(Link link)
52      {
53          put(LINK, link);
54      }
55  
56      public Link getLink()
57      {
58          Link link = null;
59          if (keySet().contains(LINK))
60          {
61              link = (Link) get(LINK);
62          }
63          return link;
64      }
65  
66      public void setIcon(Icon icon)
67      {
68          put(ICON, icon);
69      }
70  
71      public Icon getIcon()
72      {
73          Icon icon = null;
74          if (keySet().contains(ICON))
75          {
76              icon = (Icon) get(ICON);
77          }
78          return icon;
79      }
80  
81      public void setLabel(Label label)
82      {
83          put(LABEL, label);
84          addI18nProperty(label.getKey(), label.getValue());
85      }
86  
87      public Label getLabel()
88      {
89          Label label = null;
90          if (keySet().contains(LABEL))
91          {
92              label = (Label) get(LABEL);
93          }
94          return label;
95      }
96  
97      public void setTooltip(Tooltip tooltip)
98      {
99          put(TOOLTIP, tooltip);
100         addI18nProperty(tooltip.getKey(), tooltip.getValue());
101     }
102 
103     public Tooltip getTooltip()
104     {
105         Tooltip tooltip = null;
106         if (keySet().contains(TOOLTIP))
107         {
108             tooltip = (Tooltip) get(TOOLTIP);
109         }
110         return tooltip;
111     }
112 
113     public void setParams(Map<String, String> params)
114     {
115         put(PARAMS, params);
116     }
117 
118     public void addParam(String name, String value)
119     {
120         ((Map<String, String>) get(PARAMS)).put(name, value);
121     }
122 
123 }