aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins/com.android.ide.eclipse.adt
diff options
context:
space:
mode:
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml17
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/ActivityPage.java50
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java14
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java3
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplatePage.java9
5 files changed, 75 insertions, 18 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml
index 3ca6d03..5979f74 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml
@@ -290,6 +290,22 @@
<wizard
canFinishEarly="false"
category="com.android.ide.eclipse.wizards.category"
+ class="com.android.ide.eclipse.adt.internal.wizards.templates.NewActivityWizard$OtherWizard"
+ finalPerspective="org.eclipse.jdt.ui.JavaPerspective"
+ hasPages="true"
+ icon="icons/newCustomView.png"
+ id="com.android.ide.eclipse.editors.wizards.NewActivityWizard.OtherWizard"
+ name="Android Object"
+ preferredPerspectives="org.eclipse.jdt.ui.JavaPerspective"
+ project="false" >
+ <description>
+ Create an Android object such as a Service, an Activity, a Broadcast Receiver, etc.
+ </description>
+ </wizard>
+ <!-- Available through generic object list above
+ <wizard
+ canFinishEarly="false"
+ category="com.android.ide.eclipse.wizards.category"
class="com.android.ide.eclipse.adt.internal.wizards.templates.NewTemplateWizard$NewCustomViewWizard"
finalPerspective="org.eclipse.jdt.ui.JavaPerspective"
hasPages="true"
@@ -302,6 +318,7 @@
Create an Android custom view
</description>
</wizard>
+ -->
<wizard
canFinishEarly="false"
category="com.android.ide.eclipse.wizards.category"
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/ActivityPage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/ActivityPage.java
index 47ed771..7f67a0d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/ActivityPage.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/ActivityPage.java
@@ -16,6 +16,7 @@
package com.android.ide.eclipse.adt.internal.wizards.templates;
import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.CATEGORY_ACTIVITIES;
+import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.CATEGORY_OTHER;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.PREVIEW_PADDING;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.PREVIEW_WIDTH;
@@ -57,16 +58,29 @@ class ActivityPage extends WizardPage implements SelectionListener {
private Image mPreviewImage;
private Label mHeading;
private Label mDescription;
+ private boolean mOnlyActivities;
+ private boolean mAskCreate;
/**
* Create the wizard.
*/
- ActivityPage(NewProjectWizardState values) {
+ ActivityPage(NewProjectWizardState values, boolean onlyActivities, boolean askCreate) {
super("activityPage"); //$NON-NLS-1$
mValues = values;
+ mOnlyActivities = onlyActivities;
+ mAskCreate = askCreate;
- setTitle("Create Activity");
- setDescription("Select whether to create an activity, and if so, what kind of activity.");
+ if (onlyActivities) {
+ setTitle("Create Activity");
+ } else {
+ setTitle("Create Android Object");
+ }
+ if (onlyActivities && askCreate) {
+ setDescription(
+ "Select whether to create an activity, and if so, what kind of activity.");
+ } else {
+ setDescription("Select which template to use");
+ }
}
@Override
@@ -80,17 +94,23 @@ class ActivityPage extends WizardPage implements SelectionListener {
Composite container = (Composite) getControl();
container.setLayout(new GridLayout(3, false));
- mCreateToggle = new Button(container, SWT.CHECK);
- mCreateToggle.setSelection(true);
- mCreateToggle.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
- mCreateToggle.setText("Create Activity");
- mCreateToggle.addSelectionListener(this);
+ if (mAskCreate) {
+ mCreateToggle = new Button(container, SWT.CHECK);
+ mCreateToggle.setSelection(true);
+ mCreateToggle.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
+ mCreateToggle.setText("Create Activity");
+ mCreateToggle.addSelectionListener(this);
+ }
mList = new List(container, SWT.BORDER | SWT.V_SCROLL);
mList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
- mTemplates = mValues.template.getManager().getTemplates(CATEGORY_ACTIVITIES);
+ TemplateManager manager = mValues.template.getManager();
+ mTemplates = manager.getTemplates(CATEGORY_ACTIVITIES);
+ if (!mOnlyActivities) {
+ mTemplates.addAll(manager.getTemplates(CATEGORY_OTHER));
+ }
java.util.List<String> names = new ArrayList<String>(mTemplates.size());
File current = mValues.activityValues.getTemplateLocation();
int index = -1;
@@ -196,11 +216,13 @@ class ActivityPage extends WizardPage implements SelectionListener {
if (visible) {
mShown = true;
- try {
- mIgnore = true;
- mCreateToggle.setSelection(mValues.createActivity);
- } finally {
- mIgnore = false;
+ if (mAskCreate) {
+ try {
+ mIgnore = true;
+ mCreateToggle.setSelection(mValues.createActivity);
+ } finally {
+ mIgnore = false;
+ }
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java
index d3099bc..85afe77 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java
@@ -45,19 +45,21 @@ public class NewActivityWizard extends TemplateWizard {
private ActivityPage mActivityPage;
private NewProjectWizardState mValues;
private NewTemplateWizardState mActivityValues;
+ protected boolean mOnlyActivities;
/** Creates a new {@link NewActivityWizard} */
public NewActivityWizard() {
+ mOnlyActivities = true;
}
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
super.init(workbench, selection);
- setWindowTitle("New Activity");
+ setWindowTitle(mOnlyActivities ? "New Activity" : "New Android Object");
mValues = new NewProjectWizardState();
- mActivityPage = new ActivityPage(mValues);
+ mActivityPage = new ActivityPage(mValues, mOnlyActivities, false);
mActivityValues = mValues.activityValues;
List<IProject> projects = AdtUtils.getSelectedProjects(selection);
@@ -134,4 +136,12 @@ public class NewActivityWizard extends TemplateWizard {
protected List<Change> computeChanges() {
return mActivityValues.computeChanges();
}
+
+ /** Wizard for creating other Android components */
+ public static class OtherWizard extends NewActivityWizard {
+ /** Create new {@link OtherWizard} */
+ public OtherWizard() {
+ mOnlyActivities = false;
+ }
+ }
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java
index 890074c..99ae611 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java
@@ -72,6 +72,7 @@ public class NewProjectWizard extends TemplateWizard {
static final String ATTR_APP_TITLE = "appTitle"; //$NON-NLS-1$
static final String CATEGORY_PROJECTS = "projects"; //$NON-NLS-1$
static final String CATEGORY_ACTIVITIES = "activities"; //$NON-NLS-1$
+ static final String CATEGORY_OTHER = "other"; //$NON-NLS-1$
private NewProjectPage mMainPage;
private ActivityPage mActivityPage;
@@ -89,7 +90,7 @@ public class NewProjectWizard extends TemplateWizard {
mValues = new NewProjectWizardState();
mMainPage = new NewProjectPage(mValues);
- mActivityPage = new ActivityPage(mValues);
+ mActivityPage = new ActivityPage(mValues, true, true);
}
@Override
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplatePage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplatePage.java
index 815be68..aa35bda 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplatePage.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplatePage.java
@@ -115,6 +115,8 @@ public class NewTemplatePage extends WizardPage
private List<Parameter> mParameters;
private StringEvaluator mEvaluator;
+ private TemplateMetadata mShowingTemplate;
+
/**
* Creates a new {@link NewTemplatePage}
*
@@ -158,6 +160,12 @@ public class NewTemplatePage extends WizardPage
@SuppressWarnings("unused") // SWT constructors have side effects and aren't unused
private void onEnter() {
+ TemplateMetadata template = mValues.getTemplateHandler().getTemplate();
+ if (template == mShowingTemplate) {
+ return;
+ }
+ mShowingTemplate = template;
+
Composite parent = (Composite) getControl();
Control[] children = parent.getChildren();
@@ -198,7 +206,6 @@ public class NewTemplatePage extends WizardPage
// Add parameters
mFirst = null;
- TemplateMetadata template = mValues.getTemplateHandler().getTemplate();
String thumb = null;
if (template != null) {
thumb = template.getThumbnailPath();