PageRenderTime 18ms CodeModel.GetById 10ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/mmeinhold/amps
Java | 72 lines | 53 code | 16 blank | 3 comment | 1 complexity | 69052d3e754bd608c7239d8321ef183d 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.ComponentTabPanelModuleCreator;
 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(ComponentTabPanelModuleCreator.class)
18public class ComponentTabPanelPrompter extends AbstractModulePrompter<TabPanelProperties>
19{
20
21    public ComponentTabPanelPrompter(Prompter prompter)
22    {
23        super(prompter);
24
25    }
26
27    @Override
28    public TabPanelProperties promptForBasicProperties(PluginModuleLocation moduleLocation) throws PrompterException
29    {
30
31        TabPanelProperties props;
32        boolean useGenericClass = promptForBoolean("Use " + ComponentTabPanelModuleCreator.GENERIC_CLASS + "?", "Y");
33
34        if (useGenericClass)
35        {
36            props = new TabPanelProperties(ComponentTabPanelModuleCreator.FQ_GENERIC_CLASS);
37            props.setModuleNameAndKey(promptNotBlank("Enter Plugin Module Name", "My Component Tab Panel"));
38            suppressAdvancedNamePrompt();
39        } else
40        {
41            String className = promptJavaClassname("Enter New Classname", "MyComponentTabPanel");
42            String packageName = promptJavaPackagename("Enter Package Name", getDefaultBasePackage() + ".jira.tabpanels");
43            String fqClass = ClassnameUtil.fullyQualifiedName(packageName, className);
44
45            props = new TabPanelProperties(fqClass);
46        }
47
48        Label label = new Label(props.getModuleKey() + ".label", props.getModuleName());
49        props.setLabel(label);
50
51        props.setUseCustomClass(!useGenericClass);
52
53        return props;
54    }
55
56    @Override
57    public void promptForAdvancedProperties(TabPanelProperties props, PluginModuleLocation moduleLocation) throws PrompterException
58    {
59        props.setOrder(promptForInt("Order", 10));
60
61        Label label = props.getLabel();
62        String labelKey = promptNotBlank("Enter Label Key", props.getLabel()
63                .getKey());
64        String labelValue = promptNotBlank("Enter Label Value", props.getLabel()
65                .getValue());
66
67        label.setKey(labelKey);
68        label.setValue(labelValue);
69
70        props.addI18nProperty(labelKey, labelValue);
71    }
72}