[split] don't change the value of 'confirmOpenNewProject' option in remote development sessions (RDCT-1505, GTW-9099)

ProjectLifecycleUiCustomization service is introduced to allow always opening projects in a new window without modifying the option. This way we ensure that users won't be able to change the value of this option manually after it set in code in remote dev mode. Also, running the IDE in remote dev mode won't affect settings for monolith (full) IDE.

GitOrigin-RevId: 794486d9146a616277933585ab9cc32485414bcc
This commit is contained in:
Nikolay Chashnikov
2024-07-10 13:03:39 +02:00
committed by intellij-monorepo-bot
parent 9347cbcae2
commit 039ff79573
4 changed files with 52 additions and 15 deletions

View File

@@ -16,6 +16,7 @@
<applicationService serviceImplementation="com.intellij.openapi.editor.ex.EditorSettingsExternalizable" client="all"/>
<applicationService serviceImplementation="com.intellij.platform.ide.core.customization.IdeLifecycleUiCustomization"/>
<applicationService serviceImplementation="com.intellij.platform.ide.core.customization.ProjectLifecycleUiCustomization"/>
<applicationService serviceInterface="com.intellij.psi.impl.DocumentCommitProcessor"
serviceImplementation="com.intellij.psi.impl.DocumentCommitThread"/>

View File

@@ -6,6 +6,7 @@ import com.intellij.ide.util.PropertiesComponent
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.*
import com.intellij.platform.ide.core.customization.IdeLifecycleUiCustomization
import com.intellij.platform.ide.core.customization.ProjectLifecycleUiCustomization
import com.intellij.util.PlatformUtils
import com.intellij.util.xmlb.annotations.OptionTag
import kotlinx.coroutines.channels.BufferOverflow
@@ -110,7 +111,12 @@ class GeneralSettings : PersistentStateComponent<GeneralSettingsState> {
*/
@get:OpenNewProjectOption
var confirmOpenNewProject: Int
get() = state.confirmOpenNewProject2 ?: defaultConfirmNewProject()
get() {
return if (ProjectLifecycleUiCustomization.getInstance().alwaysOpenProjectInNewWindow) {
OPEN_PROJECT_NEW_WINDOW
}
else state.confirmOpenNewProject2 ?: defaultConfirmNewProject()
}
set(value) {
state.confirmOpenNewProject2 = value
}

View File

@@ -0,0 +1,27 @@
// 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.platform.ide.core.customization
import com.intellij.openapi.components.service
import org.jetbrains.annotations.ApiStatus
/**
* Override this service to customize UI elements related to project's lifecycle.
* It is supposed to be overriden by parts of the platform used when the IDE is running in different modes, and isn't supposed to be
* overridden in plugins.
*/
@ApiStatus.Internal
open class ProjectLifecycleUiCustomization {
/**
* Returns `false` if the IDE should ask user whether to open a project in new windows or in the same window, and allow a user to choose
* the default choice in Settings.
* Returns `true` if the IDE should always open projects in a new window without asking for confirmation, and shouldn't allow changing
* this.
*/
open val alwaysOpenProjectInNewWindow: Boolean
get() = false
companion object {
@JvmStatic
fun getInstance(): ProjectLifecycleUiCustomization = service()
}
}

View File

@@ -13,6 +13,7 @@ import com.intellij.openapi.options.SearchableConfigurable
import com.intellij.openapi.options.ex.ConfigurableWrapper
import com.intellij.openapi.ui.DialogPanel
import com.intellij.platform.ide.core.customization.IdeLifecycleUiCustomization
import com.intellij.platform.ide.core.customization.ProjectLifecycleUiCustomization
import com.intellij.ui.IdeUICustomization
import com.intellij.ui.dsl.builder.*
import com.intellij.util.PlatformUtils
@@ -84,20 +85,22 @@ private class GeneralSettingsConfigurable :
row {
checkBox(myChkReopenLastProject)
}
buttonsGroup {
row(IdeUICustomization.getInstance().projectMessage("label.open.project.in")) {
radioButton(IdeUICustomization.getInstance().projectMessage("radio.button.open.project.in.the.new.window"),
GeneralSettings.OPEN_PROJECT_NEW_WINDOW)
radioButton(IdeUICustomization.getInstance().projectMessage("radio.button.open.project.in.the.same.window"),
GeneralSettings.OPEN_PROJECT_SAME_WINDOW)
radioButton(IdeUICustomization.getInstance().projectMessage("radio.button.confirm.window.to.open.project.in"),
GeneralSettings.OPEN_PROJECT_ASK)
if (PlatformUtils.isDataSpell()) {
radioButton(IdeUICustomization.getInstance().projectMessage("radio.button.attach"),
GeneralSettings.OPEN_PROJECT_SAME_WINDOW_ATTACH)
}
}.layout(RowLayout.INDEPENDENT)
}.bind(getter = { model.confirmOpenNewProject2 ?: GeneralSettings.defaultConfirmNewProject() }, setter = { model.confirmOpenNewProject2 = it })
if (!ProjectLifecycleUiCustomization.getInstance().alwaysOpenProjectInNewWindow) {
buttonsGroup {
row(IdeUICustomization.getInstance().projectMessage("label.open.project.in")) {
radioButton(IdeUICustomization.getInstance().projectMessage("radio.button.open.project.in.the.new.window"),
GeneralSettings.OPEN_PROJECT_NEW_WINDOW)
radioButton(IdeUICustomization.getInstance().projectMessage("radio.button.open.project.in.the.same.window"),
GeneralSettings.OPEN_PROJECT_SAME_WINDOW)
radioButton(IdeUICustomization.getInstance().projectMessage("radio.button.confirm.window.to.open.project.in"),
GeneralSettings.OPEN_PROJECT_ASK)
if (PlatformUtils.isDataSpell()) {
radioButton(IdeUICustomization.getInstance().projectMessage("radio.button.attach"),
GeneralSettings.OPEN_PROJECT_SAME_WINDOW_ATTACH)
}
}.layout(RowLayout.INDEPENDENT)
}.bind(getter = { model.confirmOpenNewProject2 ?: GeneralSettings.defaultConfirmNewProject() }, setter = { model.confirmOpenNewProject2 = it })
}
row(IdeUICustomization.getInstance().projectMessage("settings.general.default.directory")) {
textFieldWithBrowseButton(fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor()