Skip to content

Commit

Permalink
#2915 Fixed the problem caused by breaking changes in the platform
Browse files Browse the repository at this point in the history
  • Loading branch information
hurricup committed Dec 15, 2024
1 parent 6441ec2 commit 017cf50
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 Alexandr Evstigneev
* Copyright 2015-2024 Alexandr Evstigneev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,8 +16,12 @@

package com.perl5.lang.perl.idea.configuration.module;

import com.intellij.openapi.ui.VerticalFlowLayout;

import javax.swing.*;

public class PerlProjectGeneratorPeer extends PerlProjectGeneratorPeerBase<PerlProjectGenerationSettings> {
public PerlProjectGeneratorPeer() {
super(new PerlProjectGenerationSettings());
super(new PerlProjectGenerationSettings(), new JPanel(new VerticalFlowLayout()));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2020 Alexandr Evstigneev
* Copyright 2015-2024 Alexandr Evstigneev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,7 @@
package com.perl5.lang.perl.idea.configuration.module;

import com.intellij.openapi.options.UnnamedConfigurable;
import com.intellij.openapi.ui.VerticalFlowLayout;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.util.AtomicNotNullLazyValue;
import com.intellij.platform.GeneratorPeerImpl;
import com.perl5.lang.perl.idea.configuration.settings.sdk.Perl5SdkConfigurable;
Expand All @@ -28,17 +28,27 @@

public abstract class PerlProjectGeneratorPeerBase<Settings extends PerlProjectGenerationSettings> extends GeneratorPeerImpl<Settings>
implements UnnamedConfigurable {
private final @NotNull JComponent myMainComponent;
private final @NotNull Perl5SdkConfigurable mySdkConfigurable;
private final AtomicNotNullLazyValue<JComponent> myComponentProvider = AtomicNotNullLazyValue.createValue(
() -> initializeComponent(super.getComponent()));
this::initializeComponent);

public PerlProjectGeneratorPeerBase(@NotNull Settings settings) {
super(settings, new JPanel(new VerticalFlowLayout()));
public PerlProjectGeneratorPeerBase(@NotNull Settings settings, @NotNull JComponent mainComponent) {
super(settings, mainComponent);
myMainComponent = mainComponent;
mySdkConfigurable = new Perl5SdkConfigurable(getSettings(), null);
}

@Override
public final @NotNull JComponent getComponent() {
public @NotNull JComponent getComponent(@NotNull TextFieldWithBrowseButton myLocationField, @NotNull Runnable checkValid) {
// this initializes parent parts
super.getComponent(myLocationField, checkValid);
return myComponentProvider.getValue();
}

@SuppressWarnings("deprecation")
@Override
public @NotNull JComponent getComponent() {
return myComponentProvider.getValue();
}

Expand All @@ -47,15 +57,15 @@ public void disposeUIResources() {
mySdkConfigurable.disposeUIResources();
}

protected @NotNull JComponent initializeComponent(@NotNull JComponent component) {
component.add(mySdkConfigurable.createComponent());
protected @NotNull JComponent initializeComponent() {
myMainComponent.add(mySdkConfigurable.createComponent());
mySdkConfigurable.setEnabled(PerlProjectManager.getSdk(getSettings().getProject()) == null);
return component;
return myMainComponent;
}

@Override
public final @NotNull JComponent createComponent() {
return getComponent();
return myMainComponent;
}

@Override
Expand Down

0 comments on commit 017cf50

Please sign in to comment.