Skip to content

Commit

Permalink
[project] pruning FileChooserDescriptor overrides (IJPL-150176 prer…
Browse files Browse the repository at this point in the history
…equisite)

`BrowseFolderRunnable` and `*WithBrowseButton` family: getting rid of separate "title" and "description" parameters in favor of the chooser descriptor object, to avoid cloning the latter down the road.

GitOrigin-RevId: 33ec5968a1db953c60848974135055c288accf85
  • Loading branch information
trespasserw authored and intellij-monorepo-bot committed Sep 11, 2024
1 parent 6149860 commit cc726e8
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import com.intellij.openapi.editor.colors.EditorFontType
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.TextFieldWithBrowseButton
import com.intellij.openapi.util.NlsContexts
import com.intellij.ui.components.fields.ExpandableTextField
import com.intellij.ui.dsl.builder.Cell
import com.intellij.ui.dsl.builder.Row
import com.intellij.ui.dsl.builder.bindText
import com.jetbrains.rdclient.util.idea.toIOFile
import com.jetbrains.observables.ObservableProperty
import com.jetbrains.rdclient.util.idea.toIOFile
import java.io.File
import javax.swing.JComponent

Expand All @@ -25,13 +26,12 @@ fun JComponent.monospaced(): JComponent =
}

fun Row.textFieldForRelativeFolder(
basePathGetter: () -> String,
project: Project? = null,
browseDialogTitle: String? = null,
basePathGetter: () -> String,
project: Project? = null,
browseDialogTitle: @NlsContexts.DialogTitle String? = null,
): Cell<TextFieldWithBrowseButton> {

val fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor()
val textFieldWithBrowseButtonCell = textFieldWithBrowseButton(browseDialogTitle, project, fileChooserDescriptor) {
val fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor().withTitle(browseDialogTitle)
val textFieldWithBrowseButtonCell = textFieldWithBrowseButton(fileChooserDescriptor, project) {
val pathRelativeToAsFile = File(basePathGetter()).path
it.toIOFile().relativeTo(File(pathRelativeToAsFile)).path
}
Expand Down

0 comments on commit cc726e8

Please sign in to comment.