mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 1055666 - Remember last selected project in WebIDE. r=jryans
This commit is contained in:
parent
4a1e8018d2
commit
2163c86b40
@ -62,7 +62,7 @@ let UI = {
|
||||
window.addEventListener("focus", this.onfocus, true);
|
||||
|
||||
AppProjects.load().then(() => {
|
||||
this.openLastProject();
|
||||
this.autoSelectProject();
|
||||
});
|
||||
|
||||
// Auto install the ADB Addon Helper. Only once.
|
||||
@ -80,21 +80,6 @@ let UI = {
|
||||
this.setupDeck();
|
||||
},
|
||||
|
||||
openLastProject: function() {
|
||||
let lastProjectLocation = Services.prefs.getCharPref("devtools.webide.lastprojectlocation");
|
||||
let shouldRestore = Services.prefs.getBoolPref("devtools.webide.restoreLastProject");
|
||||
if (lastProjectLocation && shouldRestore) {
|
||||
let lastProject = AppProjects.get(lastProjectLocation);
|
||||
if (lastProject) {
|
||||
AppManager.selectedProject = lastProject;
|
||||
} else {
|
||||
AppManager.selectedProject = null;
|
||||
}
|
||||
} else {
|
||||
AppManager.selectedProject = null;
|
||||
}
|
||||
},
|
||||
|
||||
uninit: function() {
|
||||
window.removeEventListener("focus", this.onfocus, true);
|
||||
AppManager.off("app-manager-update", this.appManagerUpdate);
|
||||
@ -141,6 +126,7 @@ let UI = {
|
||||
UI.updateProjectButton();
|
||||
UI.openProject();
|
||||
UI.autoStartProject();
|
||||
UI.saveLastSelectedProject();
|
||||
});
|
||||
return;
|
||||
case "project-is-not-running":
|
||||
@ -160,6 +146,10 @@ let UI = {
|
||||
break;
|
||||
case "install-progress":
|
||||
this.updateProgress(Math.round(100 * details.bytesSent / details.totalBytes));
|
||||
break;
|
||||
case "runtime-apps-found":
|
||||
this.autoSelectProject();
|
||||
break;
|
||||
};
|
||||
this._updatePromise = promise.resolve();
|
||||
},
|
||||
@ -497,12 +487,6 @@ let UI = {
|
||||
return;
|
||||
}
|
||||
|
||||
// Save last project location
|
||||
|
||||
if (project.location) {
|
||||
Services.prefs.setCharPref("devtools.webide.lastprojectlocation", project.location);
|
||||
}
|
||||
|
||||
// Make sure the directory exist before we show Project Editor
|
||||
|
||||
let forceDetailsOnly = false;
|
||||
@ -570,6 +554,89 @@ let UI = {
|
||||
AppManager.selectedProject = project;
|
||||
}),
|
||||
|
||||
// Remember the last selected project on the runtime
|
||||
saveLastSelectedProject: function() {
|
||||
let shouldRestore = Services.prefs.getBoolPref("devtools.webide.restoreLastProject");
|
||||
if (!shouldRestore) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ignore unselection of project on runtime disconnection
|
||||
if (AppManager.connection.status != Connection.Status.CONNECTED) {
|
||||
return;
|
||||
}
|
||||
|
||||
let project = "", type = "";
|
||||
let selected = AppManager.selectedProject;
|
||||
if (selected) {
|
||||
if (selected.type == "runtimeApp") {
|
||||
type = "runtimeApp";
|
||||
project = selected.app.manifestURL;
|
||||
} else if (selected.type == "mainProcess") {
|
||||
type = "mainProcess";
|
||||
} else if (selected.type == "packaged" ||
|
||||
selected.type == "hosted") {
|
||||
type = "local";
|
||||
project = selected.location;
|
||||
}
|
||||
}
|
||||
if (type) {
|
||||
Services.prefs.setCharPref("devtools.webide.lastSelectedProject",
|
||||
type + ":" + project);
|
||||
} else {
|
||||
Services.prefs.clearUserPref("devtools.webide.lastSelectedProject");
|
||||
}
|
||||
},
|
||||
|
||||
autoSelectProject: function() {
|
||||
if (AppManager.selectedProject) {
|
||||
return;
|
||||
}
|
||||
let shouldRestore = Services.prefs.getBoolPref("devtools.webide.restoreLastProject");
|
||||
if (!shouldRestore) {
|
||||
return;
|
||||
}
|
||||
let pref = Services.prefs.getCharPref("devtools.webide.lastSelectedProject");
|
||||
if (!pref) {
|
||||
return;
|
||||
}
|
||||
let m = pref.match(/^(\w+):(.*)$/);
|
||||
if (!m) {
|
||||
return;
|
||||
}
|
||||
let [_, type, project] = m;
|
||||
|
||||
if (type == "local") {
|
||||
let lastProject = AppProjects.get(project);
|
||||
if (lastProject) {
|
||||
AppManager.selectedProject = lastProject;
|
||||
}
|
||||
}
|
||||
|
||||
// For other project types, we need to be connected to the runtime
|
||||
if (AppManager.connection.status != Connection.Status.CONNECTED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "mainProcess" && AppManager.isMainProcessDebuggable()) {
|
||||
AppManager.selectedProject = {
|
||||
type: "mainProcess",
|
||||
name: Strings.GetStringFromName("mainProcess_label"),
|
||||
icon: AppManager.DEFAULT_PROJECT_ICON
|
||||
}
|
||||
} else if (type == "runtimeApp") {
|
||||
let app = AppManager.apps.get(project);
|
||||
if (app) {
|
||||
AppManager.selectedProject = {
|
||||
type: "runtimeApp",
|
||||
app: app.manifest,
|
||||
icon: app.iconURL,
|
||||
name: app.manifest.name
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/********** DECK **********/
|
||||
|
||||
setupDeck: function() {
|
||||
|
@ -6,7 +6,6 @@
|
||||
pref("devtools.webide.showProjectEditor", true);
|
||||
pref("devtools.webide.templatesURL", "https://code.cdn.mozilla.net/templates/list.json");
|
||||
pref("devtools.webide.autoinstallADBHelper", true);
|
||||
pref("devtools.webide.lastprojectlocation", "");
|
||||
pref("devtools.webide.restoreLastProject", true);
|
||||
pref("devtools.webide.enableLocalRuntime", false);
|
||||
pref("devtools.webide.addonsURL", "https://ftp.mozilla.org/pub/mozilla.org/labs/fxos-simulator/index.json");
|
||||
@ -16,3 +15,4 @@ pref("devtools.webide.adbAddonURL", "https://ftp.mozilla.org/pub/mozilla.org/lab
|
||||
pref("devtools.webide.adbAddonID", "adbhelper@mozilla.org");
|
||||
pref("devtools.webide.monitorWebSocketURL", "ws://localhost:9000");
|
||||
pref("devtools.webide.lastConnectedRuntime", "");
|
||||
pref("devtools.webide.lastSelectedProject", "");
|
||||
|
@ -18,7 +18,6 @@ const PR_TRUNCATE = 0x20;
|
||||
const CHUNK_SIZE = 10000;
|
||||
|
||||
const appTargets = new Map();
|
||||
const fronts = new Map();
|
||||
|
||||
function addDirToZip(writer, dir, basePath) {
|
||||
let files = dir.directoryEntries;
|
||||
@ -436,10 +435,6 @@ App.prototype = {
|
||||
* `AppActorFront` is a client for the webapps actor.
|
||||
*/
|
||||
function AppActorFront(client, form) {
|
||||
if (fronts.has(form.webappsActor)) {
|
||||
return fronts.get(form.webappsActor);
|
||||
}
|
||||
fronts.set(form.webappsActor, this);
|
||||
this.client = client;
|
||||
this.actor = form.webappsActor;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user