use remembered value of "open in new window" also when opening a new project; rename option (IDEA-58404)

This commit is contained in:
Dmitry Jemerov
2010-10-21 18:29:02 +04:00
parent c4946f1d1c
commit 2d382834d2
4 changed files with 23 additions and 31 deletions
@@ -19,6 +19,7 @@
*/
package com.intellij.ide.impl;
import com.intellij.ide.GeneralSettings;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.util.newProjectWizard.AddModuleWizard;
import com.intellij.ide.util.projectWizard.ProjectBuilder;
@@ -188,13 +189,16 @@ public class NewProjectUtil {
public static void closePreviousProject(final Project projectToClose) {
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
if (openProjects.length > 0) {
int exitCode = Messages.showDialog(IdeBundle.message("prompt.open.project.in.new.frame"), IdeBundle.message("title.new.project"),
new String[]{IdeBundle.message("button.newframe"), IdeBundle.message("button.existingframe")}, 1, 0,
Messages.getQuestionIcon());
final GeneralSettings settings = GeneralSettings.getInstance();
int exitCode = settings.getConfirmOpenNewProject();
if (exitCode < 0) {
exitCode = Messages.showDialog(IdeBundle.message("prompt.open.project.in.new.frame"), IdeBundle.message("title.new.project"),
new String[]{IdeBundle.message("button.newframe"), IdeBundle.message("button.existingframe")}, 1, 0,
Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption());
}
if (exitCode == 1) { // "No" option
ProjectUtil.closeProject(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1]);
}
}
}
}
@@ -51,7 +51,7 @@
</constraints>
<properties>
<margin top="2" left="0" bottom="2" right="2"/>
<text value="Confirm frame to open project in"/>
<text value="Confirm window to open project in"/>
</properties>
</component>
</children>
@@ -150,16 +150,7 @@ public class ProjectUtil {
}
if (!forceOpenInNewFrame && openProjects.length > 0) {
final GeneralSettings settings = GeneralSettings.getInstance();
int exitCode;
if (settings.getConfirmOpenNewProject() < 0) {
exitCode = Messages.showDialog(IdeBundle.message("prompt.open.project.in.new.frame"), IdeBundle.message("title.open.project"),
new String[]{IdeBundle.message("button.newframe"), IdeBundle.message("button.existingframe"),
CommonBundle.getCancelButtonText()}, 1, 0, Messages.getQuestionIcon(),
new ProjectNewWindowDoNotAskOption());
} else {
exitCode = settings.getConfirmOpenNewProject();
}
int exitCode = confirmOpenNewProject();
if (exitCode == 1) { // "No" option
if (!closeProject(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1])) return null;
}
@@ -190,6 +181,18 @@ public class ProjectUtil {
return project;
}
public static int confirmOpenNewProject() {
final GeneralSettings settings = GeneralSettings.getInstance();
if (settings.getConfirmOpenNewProject() < 0) {
return Messages.showDialog(IdeBundle.message("prompt.open.project.in.new.frame"), IdeBundle.message("title.open.project"),
new String[]{IdeBundle.message("button.newframe"), IdeBundle.message("button.existingframe"),
CommonBundle.getCancelButtonText()}, 1, 0, Messages.getQuestionIcon(),
new ProjectNewWindowDoNotAskOption());
} else {
return settings.getConfirmOpenNewProject();
}
}
private static boolean isSameProject(String path, Project p) {
final IProjectStore projectStore = ((ProjectEx)p).getStateStore();
@@ -15,10 +15,6 @@
*/
package com.intellij.platform;
import com.intellij.CommonBundle;
import com.intellij.ide.GeneralSettings;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.impl.ProjectNewWindowDoNotAskOption;
import com.intellij.ide.impl.ProjectUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.Extensions;
@@ -29,7 +25,6 @@ import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.project.impl.ProjectManagerImpl;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.ToolWindowManager;
@@ -78,17 +73,7 @@ public class PlatformProjectOpenProcessor extends ProjectOpenProcessor {
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
if (!forceOpenInNewFrame && openProjects.length > 0) {
final GeneralSettings settings = GeneralSettings.getInstance();
int exitCode;
if (settings.getConfirmOpenNewProject() < 0) {
exitCode = Messages.showDialog(IdeBundle.message("prompt.open.project.in.new.frame"), IdeBundle.message("title.open.project"),
new String[]{IdeBundle.message("button.newframe"), IdeBundle.message("button.existingframe"),
CommonBundle.getCancelButtonText()}, 1, 0, Messages.getQuestionIcon(),
new ProjectNewWindowDoNotAskOption());
}
else {
exitCode = settings.getConfirmOpenNewProject();
}
int exitCode = ProjectUtil.confirmOpenNewProject();
if (exitCode == 1) { // "No" option
if (!ProjectUtil.closeProject(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1])) return null;
}