1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Eclipse Public License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.eclipse.org/org/documents/epl-v10.php
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.ide.eclipse.adt.internal.wizards.templates;
18 
19 import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.CATEGORY_PROJECTS;
20 
21 import com.android.ide.eclipse.adt.AdtUtils;
22 import com.android.ide.eclipse.adt.internal.assetstudio.CreateAssetSetWizardState;
23 import com.android.sdklib.IAndroidTarget;
24 
25 import org.eclipse.ui.IWorkingSet;
26 
27 import java.util.HashMap;
28 import java.util.Map;
29 
30 /**
31  * Value object which holds the current state of the wizard pages for the
32  * {@link NewProjectWizard}
33  */
34 public class NewProjectWizardState {
35     /** Creates a new {@link NewProjectWizardState} */
NewProjectWizardState()36     public NewProjectWizardState() {
37         template = TemplateHandler.createFromName(CATEGORY_PROJECTS,
38                 "NewAndroidApplication"); //$NON-NLS-1$
39     }
40 
41     /** The template handler instantiating the project */
42     public final TemplateHandler template;
43 
44     /** The name of the project */
45     public String projectName;
46 
47     /** The derived name of the activity, if any */
48     public String activityName;
49 
50     /** The derived title of the activity, if any */
51     public String activityTitle;
52 
53     /** The application name */
54     public String applicationName;
55 
56     /** The package name */
57     public String packageName;
58 
59     /** Whether the project name has been edited by the user */
60     public boolean projectModified;
61 
62     /** Whether the package name has been edited by the user */
63     public boolean packageModified;
64 
65     /** Whether the activity name has been edited by the user */
66     public boolean activityNameModified;
67 
68     /** Whether the activity title has been edited by the user */
69     public boolean activityTitleModified;
70 
71     /** Whether the application name has been edited by the user */
72     public boolean applicationModified;
73 
74     /** The compilation target to use for this project */
75     public IAndroidTarget target;
76 
77     /** The minimum SDK API level, as a string (if the API is a preview release with a codename) */
78     public String minSdk;
79 
80     /** The minimum SDK API level to use */
81     public int minSdkLevel;
82 
83     /** The target SDK level */
84     public int targetSdkLevel = AdtUtils.getHighestKnownApiLevel();
85 
86     /** Whether this project should be marked as a library project */
87     public boolean isLibrary;
88 
89     /** Whether to create an activity (if so, the activity state is stored in
90      * {@link #activityValues}) */
91     public boolean createActivity = true;
92 
93     /** Whether a custom icon should be created instead of just reusing the default (if so,
94      * the icon wizard state is stored in {@link #iconState}) */
95     public boolean createIcon = true;
96 
97     // Delegated wizards
98 
99     /** State for the asset studio wizard, used to create custom icons */
100     public CreateAssetSetWizardState iconState = new CreateAssetSetWizardState();
101 
102     /** State for the template wizard, used to embed an activity template */
103     public NewTemplateWizardState activityValues = new NewTemplateWizardState();
104 
105     /** Whether a custom location should be used */
106     public boolean useDefaultLocation = true;
107 
108     /** Folder where the project should be created. */
109     public String projectLocation;
110 
111     /** Configured parameters, by id */
112     public final Map<String, Object> parameters = new HashMap<String, Object>();
113 
114     /** The set of chosen working sets to use when creating the project */
115     public IWorkingSet[] workingSets = new IWorkingSet[0];
116 
117     /**
118      * Returns the build target API level
119      *
120      * @return the build target API level
121      */
getBuildApi()122     public int getBuildApi() {
123         return target != null ? target.getVersion().getApiLevel() : minSdkLevel;
124     }
125 }
126