Commit 79204ae5 authored by Evan W. Patton's avatar Evan W. Patton Committed by Jeffrey Schiller

Fix galleryId, repo, and template URLs when autoload is false

Change-Id: If329454dfdb33f99df07be008369d220a4a11de9
parent aa050c6c
...@@ -583,58 +583,72 @@ public class Ode implements EntryPoint { ...@@ -583,58 +583,72 @@ public class Ode implements EntryPoint {
resizeWorkArea((WorkAreaPanel) deckPanel.getWidget(debuggingTabIndex)); resizeWorkArea((WorkAreaPanel) deckPanel.getWidget(debuggingTabIndex));
} }
public void openPreviousProject() { /**
* Processes the template and galleryId flags.
*
* @return true if a template or gallery id is present and being handled, otherwise false.
*/
private boolean handleQueryString() {
if (userSettings == null) { if (userSettings == null) {
OdeLog.wlog("Ignoring openPreviousProject() since userSettings is null"); return false;
return;
} }
OdeLog.log("Ode.openPreviousProject called");
final String value = userSettings.getSettings(SettingsConstants.USER_GENERAL_SETTINGS).
getPropertyValue(SettingsConstants.GENERAL_SETTINGS_CURRENT_PROJECT_ID);
// Retrieve the userTemplates // Retrieve the userTemplates
String userTemplates = userSettings.getSettings(SettingsConstants.USER_GENERAL_SETTINGS). String userTemplates = userSettings.getSettings(SettingsConstants.USER_GENERAL_SETTINGS)
getPropertyValue(SettingsConstants.USER_TEMPLATE_URLS); .getPropertyValue(SettingsConstants.USER_TEMPLATE_URLS);
TemplateUploadWizard.setStoredTemplateUrls(userTemplates); TemplateUploadWizard.setStoredTemplateUrls(userTemplates);
if (templateLoadingFlag) { // We are loading a template, open it instead if (templateLoadingFlag) { // We are loading a template, open it instead
// of the last project // of the last project
NewProjectCommand callbackCommand = new NewProjectCommand() { NewProjectCommand callbackCommand = new NewProjectCommand() {
@Override @Override
public void execute(Project project) { public void execute(Project project) {
templateLoadingFlag = false; templateLoadingFlag = false;
Ode.getInstance().openYoungAndroidProjectInDesigner(project); Ode.getInstance().openYoungAndroidProjectInDesigner(project);
} }
}; };
TemplateUploadWizard.openProjectFromTemplate(templatePath, callbackCommand); TemplateUploadWizard.openProjectFromTemplate(templatePath, callbackCommand);
} else if(galleryIdLoadingFlag){ return true;
} else if (galleryIdLoadingFlag) {
try { try {
long galleryId_Long = Long.valueOf(galleryId); long galleryId = Long.parseLong(this.galleryId);
final OdeAsyncCallback<GalleryApp> callback = new OdeAsyncCallback<GalleryApp>( final OdeAsyncCallback<GalleryApp> callback = new OdeAsyncCallback<GalleryApp>(
// failure message // failure message
MESSAGES.galleryError()) { MESSAGES.galleryError()) {
@Override @Override
public void onSuccess(GalleryApp app) { public void onSuccess(GalleryApp app) {
if(app == null){ if (app == null) {
openProject(value); Window.alert(MESSAGES.galleryIdNotExist());
Window.alert(MESSAGES.galleryIdNotExist()); // Reset the galleryId flag and then load the previous project
}else{ galleryIdLoadingFlag = false;
Ode.getInstance().switchToGalleryAppView(app, GalleryPage.VIEWAPP); openPreviousProject();
} } else {
} Ode.getInstance().switchToGalleryAppView(app, GalleryPage.VIEWAPP);
}; }
Ode.getInstance().getGalleryService().getApp(galleryId_Long, callback); }
};
Ode.getInstance().getGalleryService().getApp(galleryId, callback);
return true;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
openProject(value);
Window.alert(MESSAGES.galleryIdNotExist()); Window.alert(MESSAGES.galleryIdNotExist());
} }
} else {
openProject(value);
} }
return false;
}
/**
* Opens the user's last project, if the information is known.
*/
private void openPreviousProject() {
if (userSettings == null) {
OdeLog.wlog("Ignoring openPreviousProject() since userSettings is null");
return;
}
final String value = userSettings.getSettings(SettingsConstants.USER_GENERAL_SETTINGS)
.getPropertyValue(SettingsConstants.GENERAL_SETTINGS_CURRENT_PROJECT_ID);
openProject(value);
} }
private void openProject(String projectIdString) { private void openProject(String projectIdString) {
OdeLog.log("Ode.openProject called for " + projectIdString);
if (projectIdString.equals("")) { if (projectIdString.equals("")) {
openPreviousProject(); openPreviousProject();
} else if (!projectIdString.equals("0")) { } else if (!projectIdString.equals("0")) {
...@@ -853,7 +867,7 @@ public class Ode implements EntryPoint { ...@@ -853,7 +867,7 @@ public class Ode implements EntryPoint {
@Override @Override
public void onProjectsLoaded() { public void onProjectsLoaded() {
projectManager.removeProjectManagerEventListener(this); projectManager.removeProjectManagerEventListener(this);
if (shouldAutoloadLastProject()) { if (!handleQueryString() && shouldAutoloadLastProject()) {
openPreviousProject(); openPreviousProject();
} }
......
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