1 package com.atlassian.plugins.codegen.modules.jira;
2
3 import com.atlassian.plugins.codegen.PluginProjectChangeset;
4 import com.atlassian.plugins.codegen.annotations.JiraPluginModuleCreator;
5 import com.atlassian.plugins.codegen.modules.AbstractPluginModuleCreator;
6
7 import static com.atlassian.plugins.codegen.modules.Dependencies.MOCKITO_TEST;
8 import static com.atlassian.plugins.codegen.modules.Dependencies.SLF4J;
9
10
11
12
13 @JiraPluginModuleCreator
14 public class ComponentTabPanelModuleCreator extends AbstractPluginModuleCreator<TabPanelProperties>
15 {
16
17 public static final String GENERIC_CLASS = "GenericTabPanel";
18 public static final String GENERIC_PACKAGE = "com.atlassian.jira.plugin.componentpanel.impl";
19 public static final String FQ_GENERIC_CLASS = GENERIC_PACKAGE + "." + GENERIC_CLASS;
20
21 public static final String MODULE_NAME = "Component Tab Panel";
22 private static final String TEMPLATE_PREFIX = "templates/jira/tabpanel/component/";
23
24
25 private static final String CLASS_TEMPLATE = TEMPLATE_PREFIX + "ComponentTabPanel.java.vtl";
26 private static final String UNIT_TEST_TEMPLATE = "templates/generic/GenericTest.java.vtl";
27 private static final String VIEW_TEMPLATE = TEMPLATE_PREFIX + "component-tab-panel.vm.vtl";
28
29
30 private static final String EXAMPLE_CLASS_TEMPLATE = TEMPLATE_PREFIX + "Example" + CLASS_TEMPLATE;
31
32 private static final String PLUGIN_MODULE_TEMPLATE = TEMPLATE_PREFIX + "component-tab-panel-plugin.xml.vtl";
33
34 @Override
35 public PluginProjectChangeset createModule(TabPanelProperties props) throws Exception
36 {
37 PluginProjectChangeset ret = new PluginProjectChangeset()
38 .with(SLF4J,
39 MOCKITO_TEST)
40 .with(createModule(props, PLUGIN_MODULE_TEMPLATE));
41
42 if (props.includeExamples())
43 {
44 return ret.with(createClass(props, EXAMPLE_CLASS_TEMPLATE));
45 }
46 else
47 {
48 if (props.isUseCustomClass())
49 {
50 ret = ret.with(createClassAndTests(props, CLASS_TEMPLATE, UNIT_TEST_TEMPLATE));
51 }
52 return ret.with(createTemplateResource(props, "tabpanels", props.getModuleKey() + ".vm", VIEW_TEMPLATE));
53 }
54 }
55
56 @Override
57 public String getModuleName()
58 {
59 return MODULE_NAME;
60 }
61 }