RDCT-1444 Convert TaskCancellation to kotlin, so it can be marked as Serializable

`TaskCancellation` as a part of `ProgressStartedEvent` needs to be serializable, so it can be put to Rhizome DB

GitOrigin-RevId: ff3054f3a16260c0951af714cb652230a1b5d3ce
This commit is contained in:
Kate Botsman
2024-06-26 16:38:27 +02:00
committed by intellij-monorepo-bot
parent 14a2344ea4
commit dfd9408eb2
4 changed files with 55 additions and 80 deletions

View File

@@ -3,12 +3,16 @@ com.intellij.platform.ide.progress.ModalTaskOwner
- s:guess():com.intellij.platform.ide.progress.ModalTaskOwner
- s:project(com.intellij.openapi.project.Project):com.intellij.platform.ide.progress.ModalTaskOwner
com.intellij.platform.ide.progress.TaskCancellation
- sf:Companion:com.intellij.platform.ide.progress.TaskCancellation$Companion
- s:cancellable():com.intellij.platform.ide.progress.TaskCancellation$Cancellable
- s:nonCancellable():com.intellij.platform.ide.progress.TaskCancellation$NonCancellable
com.intellij.platform.ide.progress.TaskCancellation$Cancellable
- com.intellij.platform.ide.progress.TaskCancellation
- a:withButtonText(java.lang.String):com.intellij.platform.ide.progress.TaskCancellation$Cancellable
- a:withTooltipText(java.lang.String):com.intellij.platform.ide.progress.TaskCancellation$Cancellable
f:com.intellij.platform.ide.progress.TaskCancellation$Companion
- f:cancellable():com.intellij.platform.ide.progress.TaskCancellation$Cancellable
- f:nonCancellable():com.intellij.platform.ide.progress.TaskCancellation$NonCancellable
com.intellij.platform.ide.progress.TaskCancellation$NonCancellable
- com.intellij.platform.ide.progress.TaskCancellation
f:com.intellij.platform.ide.progress.TasksKt

View File

@@ -1,43 +1,24 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.platform.ide.progress;
package com.intellij.platform.ide.progress
import com.intellij.openapi.util.NlsContexts.Button;
import com.intellij.openapi.util.NlsContexts.Tooltip;
import org.jetbrains.annotations.ApiStatus.Internal;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.intellij.openapi.util.NlsContexts
import org.jetbrains.annotations.ApiStatus
@Internal
public final class CancellableTaskCancellation implements TaskCancellation.Cancellable {
static final Cancellable DEFAULT = new CancellableTaskCancellation(null, null);
private final @Button @Nullable String buttonText;
private final @Tooltip @Nullable String tooltipText;
private CancellableTaskCancellation(
@Button @Nullable String buttonText,
@Tooltip @Nullable String tooltipText
) {
this.buttonText = buttonText;
this.tooltipText = tooltipText;
@ApiStatus.Internal
class CancellableTaskCancellation private constructor(
val buttonText: @NlsContexts.Button String?,
val tooltipText: @NlsContexts.Tooltip String?
) : TaskCancellation.Cancellable {
override fun withButtonText(@NlsContexts.Button buttonText: String): TaskCancellation.Cancellable {
return CancellableTaskCancellation(buttonText, this.tooltipText)
}
public @Button @Nullable String getButtonText() {
return buttonText;
override fun withTooltipText(@NlsContexts.Tooltip tooltipText: String): TaskCancellation.Cancellable {
return CancellableTaskCancellation(this.buttonText, tooltipText)
}
public @Tooltip @Nullable String getTooltipText() {
return tooltipText;
}
@Override
public @NotNull Cancellable withButtonText(@NotNull String buttonText) {
return new CancellableTaskCancellation(buttonText, this.tooltipText);
}
@Override
public @NotNull Cancellable withTooltipText(@NotNull String tooltipText) {
return new CancellableTaskCancellation(this.buttonText, tooltipText);
companion object {
@JvmStatic
val DEFAULT: TaskCancellation.Cancellable = CancellableTaskCancellation(null, null)
}
}

View File

@@ -1,12 +1,7 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.platform.ide.progress;
package com.intellij.platform.ide.progress
import org.jetbrains.annotations.ApiStatus.Internal;
import org.jetbrains.annotations.ApiStatus
@Internal
public final class NonCancellableTaskCancellation implements TaskCancellation.NonCancellable {
static final TaskCancellation.NonCancellable INSTANCE = new NonCancellableTaskCancellation();
private NonCancellableTaskCancellation() { }
}
@ApiStatus.Internal
data object NonCancellableTaskCancellation: TaskCancellation.NonCancellable

View File

@@ -1,47 +1,42 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.platform.ide.progress;
package com.intellij.platform.ide.progress
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import com.intellij.openapi.util.NlsContexts
import org.jetbrains.annotations.Contract
import static com.intellij.openapi.util.NlsContexts.Button;
import static com.intellij.openapi.util.NlsContexts.Tooltip;
sealed interface TaskCancellation {
public sealed interface TaskCancellation
permits TaskCancellation.NonCancellable,
TaskCancellation.Cancellable {
sealed interface NonCancellable : TaskCancellation
/**
* @return a cancellation instance, which means that the cancel button should not be displayed in the UI
*/
@Contract(pure = true)
static @NotNull NonCancellable nonCancellable() {
return NonCancellableTaskCancellation.INSTANCE;
}
sealed interface NonCancellable extends TaskCancellation
permits NonCancellableTaskCancellation {
}
/**
* The returned instance can optionally be customized with button text and/or tooltip text.
* If {@link Cancellable#withButtonText the button text} is not specified,
* then {@link com.intellij.CommonBundle#getCancelButtonText the default text} is used.
*
* @return a cancellation instance, which means that the cancel button should be displayed in the UI
*/
@Contract(pure = true)
static @NotNull Cancellable cancellable() {
return CancellableTaskCancellation.DEFAULT;
}
sealed interface Cancellable extends TaskCancellation
permits CancellableTaskCancellation {
sealed interface Cancellable : TaskCancellation {
@Contract(value = "_ -> new", pure = true)
fun withButtonText(buttonText: @NlsContexts.Button String): Cancellable
@Contract(value = "_ -> new", pure = true)
@NotNull Cancellable withButtonText(@Button @NotNull String buttonText);
fun withTooltipText(tooltipText: @NlsContexts.Tooltip String): Cancellable
}
@Contract(value = "_ -> new", pure = true)
@NotNull Cancellable withTooltipText(@Tooltip @NotNull String tooltipText);
companion object {
/**
* @return a cancellation instance, which means that the cancel button should not be displayed in the UI
*/
@Contract(pure = true)
@JvmStatic
fun nonCancellable(): NonCancellable {
return NonCancellableTaskCancellation
}
/**
* The returned instance can optionally be customized with button text and/or tooltip text.
* If [the button text][Cancellable.withButtonText] is not specified,
* then [the default text][com.intellij.CommonBundle.getCancelButtonText] is used.
*
* @return a cancellation instance, which means that the cancel button should be displayed in the UI
*/
@Contract(pure = true)
@JvmStatic
fun cancellable(): Cancellable {
return CancellableTaskCancellation.DEFAULT
}
}
}