PY-75910: Provide project path to the peer component in NPW.

This function was here for ages, but was never used. It useful to have an access to the project location field and disposable as it might be used by project-specific ui


Merge-request: IJ-MR-145450
Merged-by: Ilya Kazakevich <ilya.kazakevich@jetbrains.com>

GitOrigin-RevId: 0d19d80007418c58f1a684c459d8cfad5e6b406e
This commit is contained in:
Ilya Kazakevich
2024-09-25 13:00:36 +00:00
committed by intellij-monorepo-bot
parent 869431ca2a
commit 2e4f6c55a5
11 changed files with 32 additions and 18 deletions

View File

@@ -19108,7 +19108,7 @@ f:com.intellij.lang.javascript.boilerplate.GithubProjectGeneratorPeer
- <init>(com.intellij.lang.javascript.boilerplate.AbstractGithubTagDownloadedProjectGenerator):V
- addSettingsStateListener(com.intellij.platform.WebProjectGenerator$SettingsStateListener):V
- buildUI(com.intellij.ide.util.projectWizard.SettingsStep):V
- getComponent():javax.swing.JComponent
- getComponent(com.intellij.openapi.ui.TextFieldWithBrowseButton,java.lang.Runnable):javax.swing.JComponent
- s:getGithubZipballUrl(java.lang.String,java.lang.String,java.lang.String):java.lang.String
- getSettings():com.intellij.platform.templates.github.GithubTagInfo
- isBackgroundJobRunning():Z

View File

@@ -4,6 +4,7 @@ package com.intellij.ide.util.projectWizard;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.platform.ProjectGeneratorPeer;
@@ -40,14 +41,16 @@ public class EmptyWebProjectTemplate extends WebProjectTemplate<Object> {
@Override
public @NotNull ProjectGeneratorPeer<Object> createPeer() {
return new ProjectGeneratorPeer<>() {
@Override
public @NotNull JComponent getComponent() {
public @NotNull JComponent getComponent(@NotNull TextFieldWithBrowseButton myLocationField,
@NotNull Runnable checkValid) {
return new JPanel();
}
@Override
public void buildUI(@NotNull SettingsStep settingsStep) {
settingsStep.addSettingsComponent(getComponent());
settingsStep.addSettingsComponent(new JPanel());
}
@Override

View File

@@ -67,7 +67,7 @@ public class ProjectSettingsStepBase<T> extends AbstractActionWithPanel implemen
private static final String DEFAULT_PROJECT_NAME = "untitled";
private final @NlsSafe @NotNull String myNewProjectName;
/**
* If {@link ProjectGeneratorPeer#getComponent()} is Kotlin DSL UI, we store it here and use for validation
* If {@link ProjectGeneratorPeer#getComponent(TextFieldWithBrowseButton, Runnable)} is Kotlin DSL UI, we store it here and use for validation
*/
@Nullable
private DialogPanelWrapper myDialogPanelWrapper;
@@ -333,7 +333,7 @@ public class ProjectSettingsStepBase<T> extends AbstractActionWithPanel implemen
protected @Nullable JPanel createAdvancedSettings() {
final JPanel jPanel = new JPanel(new VerticalFlowLayout(0, 5));
var component = getPeer().getComponent();
var component = getPeer().getComponent(myLocationField, () -> checkValid());
// If a component is a DialogPanel, created with Kotlin DSL UI,
// it may have validation which must be obeyed as is done for DialogWrapper
if (component instanceof DialogPanel dialogPanel) {

View File

@@ -6,6 +6,7 @@ import com.intellij.CommonBundle;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.util.projectWizard.SettingsStep;
import com.intellij.lang.LangBundle;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.openapi.util.NlsContexts;
import com.intellij.openapi.util.text.StringUtil;
@@ -156,7 +157,7 @@ public final class GithubProjectGeneratorPeer implements WebProjectGenerator.Gen
@Override
public @NotNull JComponent getComponent() {
public @NotNull JComponent getComponent(@NotNull TextFieldWithBrowseButton myLocationField, @NotNull Runnable checkValid) {
return myComponent;
}

View File

@@ -19369,7 +19369,7 @@ c:com.intellij.platform.GeneratorPeerImpl
- <init>(java.lang.Object,javax.swing.JComponent):V
- addSettingsStateListener(com.intellij.platform.WebProjectGenerator$SettingsStateListener):V
- buildUI(com.intellij.ide.util.projectWizard.SettingsStep):V
- getComponent():javax.swing.JComponent
- getComponent(com.intellij.openapi.ui.TextFieldWithBrowseButton,java.lang.Runnable):javax.swing.JComponent
- getSettings():java.lang.Object
- isBackgroundJobRunning():Z
- validate():com.intellij.openapi.ui.ValidationInfo
@@ -19416,7 +19416,7 @@ com.intellij.platform.ProjectGeneratorPeer
- addSettingsListener(com.intellij.platform.ProjectGeneratorPeer$SettingsListener):V
- addSettingsStateListener(com.intellij.platform.WebProjectGenerator$SettingsStateListener):V
- a:buildUI(com.intellij.ide.util.projectWizard.SettingsStep):V
- a:getComponent():javax.swing.JComponent
- getComponent():javax.swing.JComponent
- getComponent(com.intellij.openapi.ui.TextFieldWithBrowseButton,java.lang.Runnable):javax.swing.JComponent
- a:getSettings():java.lang.Object
- a:isBackgroundJobRunning():Z
@@ -19447,7 +19447,7 @@ com.intellij.platform.WebProjectGenerator$GeneratorPeer
- com.intellij.platform.ProjectGeneratorPeer
- a:addSettingsStateListener(com.intellij.platform.WebProjectGenerator$SettingsStateListener):V
- a:buildUI(com.intellij.ide.util.projectWizard.SettingsStep):V
- a:getComponent():javax.swing.JComponent
- a:getComponent(com.intellij.openapi.ui.TextFieldWithBrowseButton,java.lang.Runnable):javax.swing.JComponent
- a:getSettings():java.lang.Object
- a:isBackgroundJobRunning():Z
- a:validate():com.intellij.openapi.ui.ValidationInfo

View File

@@ -2,6 +2,7 @@
package com.intellij.platform;
import com.intellij.ide.util.projectWizard.SettingsStep;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.ui.ValidationInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -24,7 +25,7 @@ public class GeneratorPeerImpl<T> implements ProjectGeneratorPeer<T> {
}
@Override
public @NotNull JComponent getComponent() {
public @NotNull JComponent getComponent(@NotNull TextFieldWithBrowseButton myLocationField, @NotNull Runnable checkValid) {
return myComponent;
}

View File

@@ -10,16 +10,22 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
public interface ProjectGeneratorPeer<T> {
/**
* Returns a new project settings component.
* If a component is a dialog panel from Kotlin DSL UI, its validation state will be used
*/
default @NotNull JComponent getComponent(final @NotNull TextFieldWithBrowseButton myLocationField, final @NotNull Runnable checkValid) {
return getComponent();
}
/**
* Returns a new project settings component.
* If a component is a dialog panel from Kotlin DSL UI, its validation state will be used
* @deprecated implement {@link #getComponent(TextFieldWithBrowseButton, Runnable)} instead
*/
@Deprecated
@NotNull
JComponent getComponent();
default JComponent getComponent() {
throw new RuntimeException("Do not use this method, use the one above instead");
}
void buildUI(@NotNull SettingsStep settingsStep);
@@ -30,7 +36,7 @@ public interface ProjectGeneratorPeer<T> {
T getSettings();
/**
* if {@link #getComponent()} is Kotlin DSL UI panel, then it will also be validated,
* if {@link #getComponent(TextFieldWithBrowseButton, Runnable)} is Kotlin DSL UI panel, then it will also be validated,
* and this method must check only things not covered by the panel.
*
* @return {@code null} if OK.

View File

@@ -3,6 +3,7 @@ package com.intellij.platform;
import com.intellij.facet.ui.ValidationResult;
import com.intellij.ide.util.projectWizard.SettingsStep;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.openapi.util.NlsContexts.DetailedDescription;
import org.jetbrains.annotations.NotNull;
@@ -38,7 +39,7 @@ public abstract class WebProjectGenerator<T> extends DirectoryProjectGeneratorBa
public interface GeneratorPeer<T> extends ProjectGeneratorPeer<T> {
@Override
@NotNull
JComponent getComponent();
JComponent getComponent(@NotNull TextFieldWithBrowseButton myLocationField, @NotNull Runnable checkValid);
@Override
void buildUI(@NotNull SettingsStep settingsStep);

View File

@@ -6,6 +6,7 @@ import com.intellij.ide.wizard.GeneratorNewProjectWizard
import com.intellij.ide.wizard.NewProjectWizardStepPanel
import com.intellij.openapi.module.Module
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.TextFieldWithBrowseButton
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.platform.DirectoryProjectGeneratorBase
import com.intellij.platform.GeneratorPeerImpl
@@ -33,7 +34,7 @@ open class NewProjectWizardDirectoryGeneratorAdapter<T : Any>(val wizard: Genera
override fun createPeer(): ProjectGeneratorPeer<T> {
val context = WizardContext(null) {}
return object : GeneratorPeerImpl<T>() {
override fun getComponent(): JComponent {
override fun getComponent(myLocationField: TextFieldWithBrowseButton, checkValid: Runnable): JComponent {
panel = NewProjectWizardStepPanel(wizard.createStep(context))
return panel.component
}

View File

@@ -77,7 +77,7 @@ public class ProjectSpecificSettingsStep<T extends PyNewProjectSettings> extends
protected @Nullable JPanel createAdvancedSettings() {
JComponent advancedSettings = null;
if (myProjectGenerator instanceof WebProjectTemplate) {
advancedSettings = getPeer().getComponent();
advancedSettings = getPeer().getComponent(myLocationField, () -> checkValid());
}
if (advancedSettings != null) {
final JPanel jPanel = new JPanel(new VerticalFlowLayout());

View File

@@ -2,6 +2,7 @@
package com.jetbrains.python.newProjectWizard.impl
import com.intellij.ide.util.projectWizard.SettingsStep
import com.intellij.openapi.ui.TextFieldWithBrowseButton
import com.intellij.openapi.ui.ValidationInfo
import com.intellij.platform.ProjectGeneratorPeer
import com.jetbrains.python.newProjectWizard.ProjectPathFlow
@@ -21,7 +22,7 @@ internal class PyV3GeneratorPeer<TYPE_SPECIFIC_SETTINGS : PyV3ProjectTypeSpecifi
private val panel: PyV3VUI<*> = PyV3VUI(settings, projectPath, specificUiAndSettings, allowedInterpreterTypes)
override fun getComponent(): JComponent = panel.mainPanel
override fun getComponent(myLocationField: TextFieldWithBrowseButton, checkValid: Runnable): JComponent = panel.mainPanel
override fun buildUI(settingsStep: SettingsStep) = Unit