mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
passing correct projectToClose
This commit is contained in:
+10
-7
@@ -28,13 +28,14 @@ import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.platform.CustomStepProjectGenerator;
|
||||
import com.intellij.platform.DirectoryProjectGenerator;
|
||||
import com.intellij.platform.PlatformProjectOpenProcessor;
|
||||
@@ -158,9 +159,11 @@ public class AbstractNewProjectStep extends DefaultActionGroup implements DumbAw
|
||||
public void consume(@Nullable final ProjectSettingsStepBase settings) {
|
||||
if (settings == null) return;
|
||||
|
||||
final Project project = ProjectManager.getInstance().getDefaultProject();
|
||||
// todo projectToClose should be passed from calling action, this is just a quick workaround
|
||||
IdeFrame frame = IdeFocusManager.getGlobalInstance().getLastFocusedFrame();
|
||||
final Project projectToClose = frame != null ? frame.getProject() : null;
|
||||
final DirectoryProjectGenerator generator = settings.getProjectGenerator();
|
||||
doGenerateProject(project, settings.getProjectLocation(), generator,
|
||||
doGenerateProject(projectToClose, settings.getProjectLocation(), generator,
|
||||
file -> getProjectSettings(generator));
|
||||
}
|
||||
|
||||
@@ -168,14 +171,14 @@ public class AbstractNewProjectStep extends DefaultActionGroup implements DumbAw
|
||||
abstract protected Object getProjectSettings(@NotNull DirectoryProjectGenerator generator);
|
||||
}
|
||||
|
||||
public static Project doGenerateProject(@Nullable final Project project,
|
||||
public static Project doGenerateProject(@Nullable final Project projectToClose,
|
||||
@NotNull final String locationString,
|
||||
@Nullable final DirectoryProjectGenerator generator,
|
||||
@NotNull final Function<VirtualFile, Object> settingsComputable) {
|
||||
final File location = new File(FileUtil.toSystemDependentName(locationString));
|
||||
if (!location.exists() && !location.mkdirs()) {
|
||||
String message = ActionsBundle.message("action.NewDirectoryProject.cannot.create.dir", location.getAbsolutePath());
|
||||
Messages.showErrorDialog(project, message, ActionsBundle.message("action.NewDirectoryProject.title"));
|
||||
Messages.showErrorDialog(projectToClose, message, ActionsBundle.message("action.NewDirectoryProject.title"));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -188,7 +191,7 @@ public class AbstractNewProjectStep extends DefaultActionGroup implements DumbAw
|
||||
|
||||
if (baseDir.getChildren().length > 0) {
|
||||
String message = ActionsBundle.message("action.NewDirectoryProject.not.empty", location.getAbsolutePath());
|
||||
int rc = Messages.showYesNoDialog(project, message, ActionsBundle.message("action.NewDirectoryProject.title"), Messages.getQuestionIcon());
|
||||
int rc = Messages.showYesNoDialog(projectToClose, message, ActionsBundle.message("action.NewDirectoryProject.title"), Messages.getQuestionIcon());
|
||||
if (rc == Messages.YES) {
|
||||
return PlatformProjectOpenProcessor.getInstance().doOpenProject(baseDir, null, false);
|
||||
}
|
||||
@@ -221,6 +224,6 @@ public class AbstractNewProjectStep extends DefaultActionGroup implements DumbAw
|
||||
};
|
||||
}
|
||||
EnumSet<PlatformProjectOpenProcessor.Option> options = EnumSet.noneOf(PlatformProjectOpenProcessor.Option.class);
|
||||
return PlatformProjectOpenProcessor.doOpenProject(baseDir, null, -1, callback, options);
|
||||
return PlatformProjectOpenProcessor.doOpenProject(baseDir, projectToClose, -1, callback, options);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user