PageRenderTime 32ms CodeModel.GetById 12ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 1ms

/plugin-module-codegen-maven-client/src/main/java/com/atlassian/maven/plugins/amps/codegen/prompter/jira/ProjectTabPanelPrompter.java

https://bitbucket.org/mmeinhold/amps
Java | 71 lines | 53 code | 15 blank | 3 comment | 1 complexity | a1cabd5b81c36217e39e1f0edc9cfd4e MD5 | raw file
 1package com.atlassian.maven.plugins.amps.codegen.prompter.jira;
 2
 3import com.atlassian.maven.plugins.amps.codegen.annotations.ModuleCreatorClass;
 4import com.atlassian.maven.plugins.amps.codegen.prompter.AbstractModulePrompter;
 5import com.atlassian.plugins.codegen.modules.PluginModuleLocation;
 6import com.atlassian.plugins.codegen.modules.common.Label;
 7import com.atlassian.plugins.codegen.modules.jira.ProjectTabPanelModuleCreator;
 8import com.atlassian.plugins.codegen.modules.jira.TabPanelProperties;
 9import com.atlassian.plugins.codegen.util.ClassnameUtil;
10
11import org.codehaus.plexus.components.interactivity.Prompter;
12import org.codehaus.plexus.components.interactivity.PrompterException;
13
14/**
15 * @since 3.6
16 */
17@ModuleCreatorClass(ProjectTabPanelModuleCreator.class)
18public 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}