mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
reopen all projects on startup (IDEA-56150)
This commit is contained in:
@@ -32,6 +32,12 @@ public interface AppLifecycleListener {
|
||||
void projectOpenFailed();
|
||||
void welcomeScreenDisplayed();
|
||||
|
||||
/**
|
||||
* Fired before saving settings and before final 'can exit?' check. App may end up not closing if some of the 'can exit?' listeners
|
||||
* return false.
|
||||
*/
|
||||
void appClosing();
|
||||
|
||||
abstract class Adapter implements AppLifecycleListener {
|
||||
public void appFrameCreated(final String[] commandLineArgs, @NotNull final Ref<Boolean> willOpenProject) {
|
||||
}
|
||||
@@ -47,5 +53,8 @@ public interface AppLifecycleListener {
|
||||
|
||||
public void welcomeScreenDisplayed() {
|
||||
}
|
||||
|
||||
public void appClosing() {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@ public abstract class RecentProjectsManagerBase implements PersistentStateCompon
|
||||
|
||||
public static class State {
|
||||
public List<String> recentPaths = new ArrayList<String>();
|
||||
public List<String> openPaths = new ArrayList<String>();
|
||||
public String lastPath;
|
||||
}
|
||||
|
||||
@@ -123,8 +124,13 @@ public abstract class RecentProjectsManagerBase implements PersistentStateCompon
|
||||
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
|
||||
if (openProjects.length == 0) {
|
||||
myState.lastPath = null;
|
||||
myState.openPaths = Collections.emptyList();
|
||||
} else {
|
||||
myState.lastPath = getProjectPath(openProjects[openProjects.length - 1]);
|
||||
myState.openPaths = new ArrayList<String>();
|
||||
for (Project openProject : openProjects) {
|
||||
myState.openPaths.add(getProjectPath(openProject));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,9 +298,17 @@ public abstract class RecentProjectsManagerBase implements PersistentStateCompon
|
||||
if (projectFromCommandLine != null) return;
|
||||
GeneralSettings generalSettings = GeneralSettings.getInstance();
|
||||
if (generalSettings.isReopenLastProject()) {
|
||||
String lastProjectPath = getLastProjectPath();
|
||||
if (lastProjectPath != null) {
|
||||
doOpenProject(lastProjectPath, null, false);
|
||||
List<String> openPaths = myState.openPaths;
|
||||
if (openPaths.size() > 0) {
|
||||
for (String openPath : openPaths) {
|
||||
doOpenProject(openPath, null, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
String lastProjectPath = getLastProjectPath();
|
||||
if (lastProjectPath != null) {
|
||||
doOpenProject(lastProjectPath, null, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -306,5 +320,9 @@ public abstract class RecentProjectsManagerBase implements PersistentStateCompon
|
||||
public void projectOpenFailed() {
|
||||
updateLastProjectPath();
|
||||
}
|
||||
|
||||
public void appClosing() {
|
||||
updateLastProjectPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -688,6 +688,8 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
}
|
||||
}
|
||||
|
||||
getMessageBus().syncPublisher(AppLifecycleListener.TOPIC).appClosing();
|
||||
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
|
||||
saveSettings();
|
||||
|
||||
Reference in New Issue
Block a user