aboutsummaryrefslogtreecommitdiff
path: root/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizardState.java
blob: 9cd3a6dcff81937fa5dc38cef809ed3e96318137 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Eclipse Public License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.eclipse.org/org/documents/epl-v10.php
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.ide.eclipse.adt.internal.wizards.templates;

import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.CATEGORY_PROJECTS;

import com.android.ide.eclipse.adt.AdtUtils;
import com.android.ide.eclipse.adt.internal.assetstudio.CreateAssetSetWizardState;
import com.android.sdklib.IAndroidTarget;

import org.eclipse.ui.IWorkingSet;

import java.util.HashMap;
import java.util.Map;

/**
 * Value object which holds the current state of the wizard pages for the
 * {@link NewProjectWizard}
 */
public class NewProjectWizardState {
    /** Creates a new {@link NewProjectWizardState} */
    public NewProjectWizardState() {
        template = TemplateHandler.createFromName(CATEGORY_PROJECTS,
                "NewAndroidApplication"); //$NON-NLS-1$
    }

    /** The template handler instantiating the project */
    public final TemplateHandler template;

    /** The name of the project */
    public String projectName;

    /** The derived name of the activity, if any */
    public String activityName;

    /** The derived title of the activity, if any */
    public String activityTitle;

    /** The application name */
    public String applicationName;

    /** The package name */
    public String packageName;

    /** Whether the project name has been edited by the user */
    public boolean projectModified;

    /** Whether the package name has been edited by the user */
    public boolean packageModified;

    /** Whether the activity name has been edited by the user */
    public boolean activityNameModified;

    /** Whether the activity title has been edited by the user */
    public boolean activityTitleModified;

    /** Whether the application name has been edited by the user */
    public boolean applicationModified;

    /** The compilation target to use for this project */
    public IAndroidTarget target;

    /** The minimum SDK API level, as a string (if the API is a preview release with a codename) */
    public String minSdk;

    /** The minimum SDK API level to use */
    public int minSdkLevel;

    /** The target SDK level */
    public int targetSdkLevel = AdtUtils.getHighestKnownApiLevel();

    /** Whether this project should be marked as a library project */
    public boolean isLibrary;

    /** Whether to create an activity (if so, the activity state is stored in
     * {@link #activityValues}) */
    public boolean createActivity = true;

    /** Whether a custom icon should be created instead of just reusing the default (if so,
     * the icon wizard state is stored in {@link #iconState}) */
    public boolean createIcon = true;

    // Delegated wizards

    /** State for the asset studio wizard, used to create custom icons */
    public CreateAssetSetWizardState iconState = new CreateAssetSetWizardState();

    /** State for the template wizard, used to embed an activity template */
    public NewTemplateWizardState activityValues = new NewTemplateWizardState();

    /** Whether a custom location should be used */
    public boolean useDefaultLocation = true;

    /** Folder where the project should be created. */
    public String projectLocation;

    /** Configured parameters, by id */
    public final Map<String, Object> parameters = new HashMap<String, Object>();

    /** The set of chosen working sets to use when creating the project */
    public IWorkingSet[] workingSets = new IWorkingSet[0];

    /**
     * Returns the build target API level
     *
     * @return the build target API level
     */
    public int getBuildApi() {
        return target != null ? target.getVersion().getApiLevel() : minSdkLevel;
    }
}