Unverified Commit 017b0bf9 authored by Evan W. Patton's avatar Evan W. Patton Committed by GitHub

Load built-in templates via the repo parameter (#2470)

* Load built-in templates via the repo parameter

Change-Id: I62265b3a60ecf7b651d9a22a32775e5d7434d5e5
parent e97f1470
...@@ -766,10 +766,6 @@ public class Ode implements EntryPoint { ...@@ -766,10 +766,6 @@ public class Ode implements EntryPoint {
@Override @Override
public void onProjectsLoaded() { public void onProjectsLoaded() {
projectManager.removeProjectManagerEventListener(this); projectManager.removeProjectManagerEventListener(this);
if (!handleQueryString() && shouldAutoloadLastProject()) {
openPreviousProject();
}
// This handles any built-in templates stored in /war // This handles any built-in templates stored in /war
// Retrieve template data stored in war/templates folder and // Retrieve template data stored in war/templates folder and
// and save it for later use in TemplateUploadWizard // and save it for later use in TemplateUploadWizard
...@@ -781,6 +777,10 @@ public class Ode implements EntryPoint { ...@@ -781,6 +777,10 @@ public class Ode implements EntryPoint {
public void onSuccess(String json) { public void onSuccess(String json) {
// Save the templateData // Save the templateData
TemplateUploadWizard.initializeBuiltInTemplates(json); TemplateUploadWizard.initializeBuiltInTemplates(json);
if (!handleQueryString() && shouldAutoloadLastProject()) {
openPreviousProject();
}
} }
}; };
Ode.getInstance().getProjectService().retrieveTemplateData(TemplateUploadWizard.TEMPLATES_ROOT_DIRECTORY, templateCallback); Ode.getInstance().getProjectService().retrieveTemplateData(TemplateUploadWizard.TEMPLATES_ROOT_DIRECTORY, templateCallback);
......
...@@ -631,6 +631,15 @@ public class TemplateUploadWizard extends Wizard implements NewUrlDialogCallback ...@@ -631,6 +631,15 @@ public class TemplateUploadWizard extends Wizard implements NewUrlDialogCallback
} }
} }
private static boolean isTemplateName(String name) {
for (TemplateInfo template : builtInTemplates) {
if (template.name.equals(name)) {
return true;
}
}
return false;
}
/** /**
* Called from Ode when a template Url is passed as GET parameter. * Called from Ode when a template Url is passed as GET parameter.
* The Url could take two forms: * The Url could take two forms:
...@@ -643,6 +652,17 @@ public class TemplateUploadWizard extends Wizard implements NewUrlDialogCallback ...@@ -643,6 +652,17 @@ public class TemplateUploadWizard extends Wizard implements NewUrlDialogCallback
* @param onSuccessCommand command to open the project * @param onSuccessCommand command to open the project
*/ */
public static void openProjectFromTemplate(String url, final NewProjectCommand onSuccessCommand) { public static void openProjectFromTemplate(String url, final NewProjectCommand onSuccessCommand) {
if (isTemplateName(url)) {
if (TextValidators.checkNewProjectName(url)) {
new TemplateUploadWizard().createProjectFromExistingZip(url, new NewProjectCommand() {
@Override
public void execute(Project project) {
Ode.getInstance().openYoungAndroidProjectInDesigner(project);
}
});
}
return;
}
if(!url.startsWith("http")) { if(!url.startsWith("http")) {
url = "http://" + url; url = "http://" + url;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment