mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
IDEA-344208 Rid of DialogWrapper.setBackgroundImage
GitOrigin-RevId: 3f1e5c9c59b059afd6de5c7496e78b1511ea7cb6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7c81752689
commit
213618dfea
@@ -204,9 +204,6 @@ public abstract class DialogWrapper {
|
||||
protected JCheckBox myCheckBoxDoNotShowDialog;
|
||||
protected JComponent myPreferredFocusedComponent;
|
||||
|
||||
private @Nullable Image myBackgroundImage;
|
||||
private @Nullable Disposable myBackgroundImageDisposable;
|
||||
|
||||
/**
|
||||
* Creates modal {@code DialogWrapper}. The currently active window will be the dialog's parent.
|
||||
*
|
||||
@@ -2052,21 +2049,6 @@ public abstract class DialogWrapper {
|
||||
myInfo = info;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public void setBackgroundImage(@Nullable Image backgroundImage) {
|
||||
myBackgroundImage = backgroundImage;
|
||||
|
||||
if (myBackgroundImageDisposable != null) {
|
||||
Disposer.dispose(myBackgroundImageDisposable);
|
||||
myBackgroundImageDisposable = null;
|
||||
}
|
||||
|
||||
if (myBackgroundImage != null) {
|
||||
myBackgroundImageDisposable = Disposer.newDisposable(myDisposable);
|
||||
OnboardingBackgroundImageProvider.getInstance().installBackgroundImageToDialog(this, myBackgroundImage, myBackgroundImageDisposable);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateComponentErrors(@NotNull List<ValidationInfo> info) {
|
||||
// clear current component errors
|
||||
myInfo.stream()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.ui
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
@@ -22,5 +21,5 @@ interface OnboardingBackgroundImageProvider {
|
||||
|
||||
fun getImageUrl(): URL?
|
||||
fun loadImage(callback: Consumer<Image?>)
|
||||
fun installBackgroundImageToDialog(dialog: DialogWrapper, image: Image, disposable: Disposable)
|
||||
fun setBackgroundImageToDialog(dialog: DialogWrapper, image: Image?)
|
||||
}
|
||||
@@ -5,6 +5,9 @@ import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
import com.intellij.openapi.ui.OnboardingBackgroundImageProvider
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.ui.ClientProperty
|
||||
import com.intellij.util.SVGLoader
|
||||
import com.intellij.util.ui.JBInsets
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
@@ -32,7 +35,17 @@ abstract class OnboardingBackgroundImageProviderBase : OnboardingBackgroundImage
|
||||
}
|
||||
}
|
||||
|
||||
override fun installBackgroundImageToDialog(dialog: DialogWrapper, image: Image, disposable: Disposable) {
|
||||
override fun setBackgroundImageToDialog(dialog: DialogWrapper, image: Image?) {
|
||||
ClientProperty.get(dialog.rootPane, BACKGROUND_IMAGE_DISPOSABLE_KEY)?.let { previousDisposable ->
|
||||
Disposer.dispose(previousDisposable)
|
||||
ClientProperty.remove(dialog.rootPane, BACKGROUND_IMAGE_DISPOSABLE_KEY)
|
||||
}
|
||||
|
||||
if (image == null) return
|
||||
|
||||
val disposable = Disposer.newDisposable(dialog.disposable)
|
||||
ClientProperty.put(dialog.rootPane, BACKGROUND_IMAGE_DISPOSABLE_KEY, disposable)
|
||||
|
||||
IdeBackgroundUtil.createTemporaryBackgroundTransform(dialog.rootPane,
|
||||
image,
|
||||
IdeBackgroundUtil.Fill.SCALE,
|
||||
@@ -41,4 +54,8 @@ abstract class OnboardingBackgroundImageProviderBase : OnboardingBackgroundImage
|
||||
JBInsets.emptyInsets(),
|
||||
disposable)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val BACKGROUND_IMAGE_DISPOSABLE_KEY: Key<Disposable> = Key.create("ide.background.image.provider.background.image")
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ide.startup.importSettings.chooser.ui
|
||||
|
||||
import com.intellij.ide.startup.importSettings.data.*
|
||||
import com.intellij.ide.startup.importSettings.data.NotificationData
|
||||
import com.intellij.ide.startup.importSettings.data.StartupWizardService
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
import com.intellij.openapi.ui.OnboardingBackgroundImageProvider
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.util.NlsContexts
|
||||
import com.intellij.platform.ide.bootstrap.StartupWizardStage
|
||||
@@ -72,7 +74,7 @@ class OnboardingDialog(var titleGetter: (StartupWizardStage?) -> @NlsContexts.Di
|
||||
currentPage = page
|
||||
tracker.onEnter(page.stage)
|
||||
|
||||
setBackgroundImage(page.backgroundImage)
|
||||
OnboardingBackgroundImageProvider.getInstance().setBackgroundImageToDialog(this, page.backgroundImage)
|
||||
}
|
||||
|
||||
override fun createContentPaneBorder(): Border {
|
||||
|
||||
Reference in New Issue
Block a user