1   package com.atlassian.maven.plugins.amps.codegen.prompter.jira;
2   
3   import com.atlassian.maven.plugins.amps.codegen.annotations.ModuleCreatorClass;
4   import com.atlassian.maven.plugins.amps.codegen.prompter.AbstractModulePrompter;
5   import com.atlassian.plugins.codegen.modules.PluginModuleLocation;
6   import com.atlassian.plugins.codegen.modules.common.Label;
7   import com.atlassian.plugins.codegen.modules.jira.ProjectTabPanelModuleCreator;
8   import com.atlassian.plugins.codegen.modules.jira.TabPanelProperties;
9   import com.atlassian.plugins.codegen.util.ClassnameUtil;
10  
11  import org.codehaus.plexus.components.interactivity.Prompter;
12  import org.codehaus.plexus.components.interactivity.PrompterException;
13  
14  /**
15   * @since 3.5
16   */
17  @ModuleCreatorClass(ProjectTabPanelModuleCreator.class)
18  public class ProjectTabPanelPrompter extends AbstractModulePrompter<TabPanelProperties>
19  {
20  
21      public ProjectTabPanelPrompter(Prompter prompter)
22      {
23          super(prompter);
24  
25      }
26  
27      @Override
28      public TabPanelProperties promptForBasicProperties(PluginModuleLocation moduleLocation) throws PrompterException
29      {
30          TabPanelProperties props;
31          boolean useGenericClass = promptForBoolean("Use " + ProjectTabPanelModuleCreator.GENERIC_CLASS + "?", "Y");
32  
33          if (useGenericClass)
34          {
35              props = new TabPanelProperties(ProjectTabPanelModuleCreator.FQ_GENERIC_CLASS);
36              props.setModuleNameAndKey(promptNotBlank("Enter Plugin Module Name", "My Project Tab Panel"));
37              suppressAdvancedNamePrompt();
38          } else
39          {
40              String className = promptJavaClassname("Enter New Classname", "MyProjectTabPanel");
41              String packageName = promptJavaPackagename("Enter Package Name", getDefaultBasePackage() + ".jira.tabpanels");
42              String fqClass = ClassnameUtil.fullyQualifiedName(packageName, className);
43  
44              props = new TabPanelProperties(fqClass);
45          }
46  
47          Label label = new Label(props.getModuleKey() + ".label", props.getModuleName());
48          props.setLabel(label);
49  
50          props.setUseCustomClass(!useGenericClass);
51  
52          return props;
53      }
54  
55      @Override
56      public void promptForAdvancedProperties(TabPanelProperties props, PluginModuleLocation moduleLocation) throws PrompterException
57      {
58          props.setOrder(promptForInt("Order", 10));
59  
60          Label label = props.getLabel();
61          String labelKey = promptNotBlank("Enter Label Key", props.getLabel()
62                  .getKey());
63          String labelValue = promptNotBlank("Enter Label Value", props.getLabel()
64                  .getValue());
65  
66          label.setKey(labelKey);
67          label.setValue(labelValue);
68  
69          props.addI18nProperty(labelKey, labelValue);
70      }
71  }