Skip to content

Commit

Permalink
Replace deprecated FileTypeDescriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
PHPirates committed Dec 13, 2024
1 parent 7d4c704 commit ffc5181
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package nl.hannahsten.texifyidea.run.bibtex

import com.intellij.execution.configuration.EnvironmentVariablesComponent
import com.intellij.openapi.fileChooser.FileChooserDescriptor
import com.intellij.openapi.fileChooser.FileTypeDescriptor
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
import com.intellij.openapi.options.SettingsEditor
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ProjectRootManager
Expand Down Expand Up @@ -108,7 +108,9 @@ class BibtexSettingsEditor(private val project: Project) : SettingsEditor<Bibtex
val mainFileField = TextFieldWithBrowseButton().apply {
addBrowseFolderListener(
TextBrowseFolderListener(
FileTypeDescriptor("Choose the Main .tex File", "tex")
FileChooserDescriptorFactory.createSingleFileDescriptor()
.withTitle("Choose the Main .tex File")
.withExtensionFilter("tex")
.withRoots(*ProjectRootManager.getInstance(project).contentRootsFromAllModules.toSet().toTypedArray())
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package nl.hannahsten.texifyidea.run.latex.externaltool

import com.intellij.openapi.fileChooser.FileChooserDescriptor
import com.intellij.openapi.fileChooser.FileTypeDescriptor
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
import com.intellij.openapi.options.SettingsEditor
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ProjectRootManager
Expand Down Expand Up @@ -53,7 +53,9 @@ class ExternalToolSettingsEditor(private val project: Project) : SettingsEditor<
val mainFileField = TextFieldWithBrowseButton().apply {
addBrowseFolderListener(
TextBrowseFolderListener(
FileTypeDescriptor("Choose Main LaTeX File", "tex")
FileChooserDescriptorFactory.createSingleFileDescriptor()
.withTitle("Choose Main LaTeX File")
.withExtensionFilter("tex")
.withRoots(*ProjectRootManager.getInstance(project).contentRootsFromAllModules.toSet().toTypedArray())
)
)
Expand Down
17 changes: 10 additions & 7 deletions src/nl/hannahsten/texifyidea/run/latex/ui/LatexSettingsEditor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package nl.hannahsten.texifyidea.run.latex.ui

import com.intellij.execution.configuration.EnvironmentVariablesComponent
import com.intellij.openapi.fileChooser.FileChooserDescriptor
import com.intellij.openapi.fileChooser.FileTypeDescriptor
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
import com.intellij.openapi.fileTypes.PlainTextFileType
import com.intellij.openapi.options.ConfigurationException
import com.intellij.openapi.options.SettingsEditor
Expand Down Expand Up @@ -33,7 +33,11 @@ import nl.hannahsten.texifyidea.run.sumatra.SumatraAvailabilityChecker
import nl.hannahsten.texifyidea.settings.sdk.LatexSdkUtil
import nl.hannahsten.texifyidea.util.runInBackground
import java.awt.event.ItemEvent
import javax.swing.*
import javax.swing.InputVerifier
import javax.swing.JComponent
import javax.swing.JLabel
import javax.swing.JPanel
import kotlin.Throws

/**
* @author Sten Wessel
Expand Down Expand Up @@ -302,11 +306,10 @@ class LatexSettingsEditor(private var project: Project?) : SettingsEditor<LatexR
val mainFileField = TextFieldWithBrowseButton()
mainFileField.addBrowseFolderListener(
TextBrowseFolderListener(
FileTypeDescriptor("Choose a File to Compile", "tex")
.withRoots(
*ProjectRootManager.getInstance(project!!)
.contentRootsFromAllModules.toSet().toTypedArray()
)
FileChooserDescriptorFactory.createSingleFileDescriptor()
.withTitle("Choose a File to Compile")
.withExtensionFilter("tex")
.withRoots(*ProjectRootManager.getInstance(project!!).contentRootsFromAllModules.toSet().toTypedArray())
)
)
mainFile = LabeledComponent.create(mainFileField, "Main file to compile")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package nl.hannahsten.texifyidea.run.makeindex

import com.intellij.openapi.fileChooser.FileChooserDescriptor
import com.intellij.openapi.fileChooser.FileTypeDescriptor
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
import com.intellij.openapi.options.SettingsEditor
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ProjectRootManager
Expand Down Expand Up @@ -57,7 +57,9 @@ class MakeindexSettingsEditor(private val project: Project) : SettingsEditor<Mak
val mainFileField = TextFieldWithBrowseButton().apply {
addBrowseFolderListener(
TextBrowseFolderListener(
FileTypeDescriptor("Choose the Main .tex File", "tex")
FileChooserDescriptorFactory.createSingleFileDescriptor()
.withTitle("Choose the Main .tex File")
.withExtensionFilter("tex")
.withRoots(*ProjectRootManager.getInstance(project).contentRootsFromAllModules.toSet().toTypedArray())
)
)
Expand Down

0 comments on commit ffc5181

Please sign in to comment.