Преглед изворни кода

Merge pull request #61 from windchargerj/upgrade-fix-2024.3

Upgrade fix for API 2024.3
ruki пре 10 месеци
родитељ
комит
ecfeb583a9

+ 4 - 3
build.gradle.kts

@@ -29,7 +29,7 @@ val buildIdeType: String = when (2) {
     else -> "IC"
 }
 
-val buildIdeVersion = "2024.2"
+val buildIdeVersion = "2024.3"
 
 val runIdeType: String = when (2) {
     0 -> "IC" // You can build with the Ultimate version, but run with the Community version.
@@ -39,7 +39,7 @@ val runIdeType: String = when (2) {
     else -> "IC"
 }
 
-val runIdeVersion = "2024.2"
+val runIdeVersion = "2024.3"
 
 plugins {
     id("java")
@@ -105,7 +105,8 @@ tasks {
             listOf(
                 "2023.3",
                 "2024.1",
-                "2024.2"
+                "2024.2",
+                "2024.3"
             )
         )
     }

+ 2 - 2
gradle.properties

@@ -1,6 +1,6 @@
 pluginVersion=1.4.2
-pluginSinceBuild=233.11799.238
-pluginUntilBuild=242.*
+pluginSinceBuild=243.21565.193
+pluginUntilBuild=243.*
 
 # Opt-out flag for bundling Kotlin standard library.
 # See https://kotlinlang.org/docs/reference/using-gradle.html#dependency-on-the-standard-library for details.

+ 0 - 11
src/main/kotlin/io/xmake/project/XMakeConfigData.kt

@@ -1,11 +0,0 @@
-package io.xmake.project
-
-import io.xmake.project.toolkit.Toolkit
-
-@Deprecated("Please refer to the relevant content in folder io/xmake/project/wizard.")
-data class XMakeConfigData(
-    val languagesModel: String,
-    val kindsModel: String,
-    val toolkit: Toolkit?,
-    val remotePath: String? = null,
-)

+ 0 - 129
src/main/kotlin/io/xmake/project/XMakeDirectoryProjectGenerator.kt

@@ -1,129 +0,0 @@
-package io.xmake.project
-
-import com.intellij.execution.RunManager
-import com.intellij.execution.configurations.GeneralCommandLine
-import com.intellij.execution.process.ProcessNotCreatedException
-import com.intellij.ide.util.projectWizard.AbstractNewProjectStep
-import com.intellij.ide.util.projectWizard.CustomStepProjectGenerator
-import com.intellij.openapi.diagnostic.logger
-import com.intellij.openapi.module.Module
-import com.intellij.openapi.project.Project
-import com.intellij.openapi.project.rootManager
-import com.intellij.openapi.vfs.VirtualFile
-import com.intellij.openapi.wm.impl.welcomeScreen.AbstractActionWithPanel
-import com.intellij.platform.DirectoryProjectGenerator
-import com.intellij.platform.DirectoryProjectGeneratorBase
-import com.intellij.platform.ProjectGeneratorPeer
-import io.xmake.icons.XMakeIcons
-import io.xmake.run.XMakeRunConfiguration
-import io.xmake.run.XMakeRunConfigurationType
-import io.xmake.utils.execute.SyncDirection
-import io.xmake.utils.execute.createProcess
-import io.xmake.utils.execute.runProcess
-import io.xmake.utils.execute.transferFolderByToolkit
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.runBlocking
-import java.io.File
-import javax.swing.Icon
-
-@Deprecated("Please refer to the relevant content in folder io/xmake/project/wizard.")
-class XMakeDirectoryProjectGenerator :
-    DirectoryProjectGeneratorBase<XMakeConfigData>(), CustomStepProjectGenerator<XMakeConfigData> {
-
-    private val scope = CoroutineScope(Dispatchers.Default)
-
-    private var peer: XMakeProjectGeneratorPeer? = null
-
-    override fun getName(): String = "XMake"
-    override fun getLogo(): Icon = XMakeIcons.XMAKE
-    override fun createPeer(): ProjectGeneratorPeer<XMakeConfigData> = XMakeProjectGeneratorPeer().also { peer = it }
-
-    override fun generateProject(project: Project, baseDir: VirtualFile, data: XMakeConfigData, module: Module) {
-        // get content entry path
-        val contentEntryPath = baseDir.canonicalPath ?: return
-
-        /* create empty project
-         * @note we muse use ioRunv instead of Runv to read all output, otherwise it will wait forever on windows
-         */
-        val tmpdir = "$contentEntryPath.dir"
-
-        val dir = if (!data.toolkit!!.isOnRemote) tmpdir else data.remotePath!!
-
-        val workingDir = if (!data.toolkit.isOnRemote) contentEntryPath else data.remotePath!!
-
-        Log.debug("dir: $dir")
-
-        val command = listOf(
-            data.toolkit.path,
-            "create",
-            "-P",
-            dir,
-            "-l",
-            data.languagesModel,
-            "-t",
-            data.kindsModel
-        )
-
-        val commandLine: GeneralCommandLine = GeneralCommandLine(command)
-            .withWorkDirectory(workingDir)
-            .withCharset(Charsets.UTF_8)
-            .withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.CONSOLE)
-        val results = try {
-            val (result, _) = runBlocking(Dispatchers.IO) {
-                return@runBlocking runProcess(commandLine.createProcess(data.toolkit))
-            }
-            result.getOrDefault("").split(Regex("\\s+"))
-        } catch (e: ProcessNotCreatedException) {
-            emptyList()
-        }
-
-        Log.info("results: $results")
-
-        with(data.toolkit) {
-            if (!isOnRemote) {
-                val tmpFile = File(tmpdir)
-                if (tmpFile.exists()) {
-                    tmpFile.copyRecursively(File(contentEntryPath), true)
-                    tmpFile.deleteRecursively()
-                }
-            } else {
-                transferFolderByToolkit(
-                    project,
-                    this,
-                    SyncDirection.UPSTREAM_TO_LOCAL,
-                    directoryPath = data.remotePath!!,
-                    null
-                )
-            }
-        }
-
-        val runManager = RunManager.getInstance(project)
-
-        val configSettings =
-            runManager.createConfiguration(project.name, XMakeRunConfigurationType.getInstance().factory)
-        runManager.addConfiguration(configSettings.apply {
-            (configuration as XMakeRunConfiguration).apply {
-                runToolkit = data.toolkit
-                runWorkingDir = workingDir
-            }
-        })
-        runManager.selectedConfiguration = runManager.allSettings.first()
-
-        val contentEntry = module.rootManager.modifiableModel.addContentEntry(contentEntryPath)
-        // add source root
-        val sourceRoot = File(contentEntryPath).path
-        contentEntry.addSourceFolder(sourceRoot, false)
-
-    }
-
-    override fun createStep(
-        projectGenerator: DirectoryProjectGenerator<XMakeConfigData>,
-        callback: AbstractNewProjectStep.AbstractCallback<XMakeConfigData>
-    ): AbstractActionWithPanel = XMakeProjectSettingsStep(projectGenerator)
-
-    companion object {
-        val Log = logger<XMakeDirectoryProjectGenerator>()
-    }
-
-}

+ 0 - 130
src/main/kotlin/io/xmake/project/XMakeModuleBuilder.kt

@@ -1,130 +0,0 @@
-package io.xmake.project
-
-import com.intellij.execution.RunManager
-import com.intellij.execution.configurations.GeneralCommandLine
-import com.intellij.execution.process.ProcessNotCreatedException
-import com.intellij.ide.util.projectWizard.ModuleBuilder
-import com.intellij.ide.util.projectWizard.ModuleWizardStep
-import com.intellij.ide.util.projectWizard.WizardContext
-import com.intellij.openapi.Disposable
-import com.intellij.openapi.diagnostic.Logger
-import com.intellij.openapi.module.ModuleType
-import com.intellij.openapi.projectRoots.SdkTypeId
-import com.intellij.openapi.roots.ModifiableRootModel
-import com.intellij.openapi.util.Disposer
-import com.intellij.openapi.util.io.FileUtil
-import com.intellij.openapi.vfs.LocalFileSystem
-import io.xmake.run.XMakeRunConfiguration
-import io.xmake.run.XMakeRunConfigurationType
-import io.xmake.utils.execute.SyncDirection
-import io.xmake.utils.execute.createProcess
-import io.xmake.utils.execute.runProcess
-import io.xmake.utils.execute.transferFolderByToolkit
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.runBlocking
-import java.io.File
-
-@Deprecated("Please refer to the relevant content in folder io/xmake/project/wizard.")
-class XMakeModuleBuilder : ModuleBuilder() {
-    lateinit var configurationData: XMakeConfigData
-
-    private val scope = CoroutineScope(Dispatchers.Default)
-
-    override fun isSuitableSdkType(sdkType: SdkTypeId?): Boolean = true
-
-
-    override fun setupRootModel(rootModel: ModifiableRootModel) {
-
-        // get content entry path
-        val contentEntryPath = contentEntryPath ?: return
-
-        // get content entry
-        val contentEntry = doAddContentEntry(rootModel) ?: return
-
-        // add source root
-        val sourceRoot =
-            LocalFileSystem.getInstance().refreshAndFindFileByPath(FileUtil.toSystemIndependentName(contentEntryPath))!!
-        contentEntry.addSourceFolder(sourceRoot, false)
-
-        /* create empty project
-         * @note we muse use ioRunv instead of Runv to read all output, otherwise it will wait forever on windows
-         */
-        val tmpdir = "$contentEntryPath.dir"
-
-        val dir = if (!configurationData.toolkit!!.isOnRemote) tmpdir else configurationData.remotePath!!
-
-        val workingDir =
-            if (!configurationData.toolkit!!.isOnRemote) contentEntryPath else configurationData.remotePath!!
-
-        Log.debug("dir: $dir")
-
-        val command = listOf(
-            configurationData.toolkit!!.path,
-            "create",
-            "-P",
-            dir,
-            "-l",
-            configurationData.languagesModel,
-            "-t",
-            configurationData.kindsModel
-        )
-
-        val commandLine: GeneralCommandLine = GeneralCommandLine(command)
-            .withWorkDirectory(workingDir)
-            .withCharset(Charsets.UTF_8)
-            .withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.CONSOLE)
-        val results = try {
-            val (result, _) = runBlocking(Dispatchers.IO) {
-                return@runBlocking runProcess(commandLine.createProcess(configurationData.toolkit!!))
-            }
-            result.getOrDefault("").split(Regex("\\s+"))
-        } catch (e: ProcessNotCreatedException) {
-            emptyList()
-        }
-
-        Log.info("results: $results")
-
-        with(configurationData.toolkit!!) {
-            if (!isOnRemote) {
-                val tmpFile = File(tmpdir)
-                if (tmpFile.exists()) {
-                    tmpFile.copyRecursively(File(contentEntryPath), true)
-                    tmpFile.deleteRecursively()
-                }
-            } else {
-                transferFolderByToolkit(
-                    rootModel.project,
-                    this,
-                    SyncDirection.UPSTREAM_TO_LOCAL,
-                    directoryPath = configurationData.remotePath!!,
-                    null
-                )
-            }
-        }
-
-        val runManager = RunManager.getInstance(rootModel.project)
-
-        val configSettings = runManager.createConfiguration(rootModel.project.name, XMakeRunConfigurationType.getInstance().factory)
-        runManager.addConfiguration(configSettings.apply {
-            (configuration as XMakeRunConfiguration).apply {
-                runToolkit = configurationData.toolkit
-                runWorkingDir = workingDir
-            }
-        })
-        runManager.selectedConfiguration = runManager.allSettings.first()
-    }
-
-    override fun getModuleType(): ModuleType<*> {
-        return XMakeModuleType.instance
-    }
-
-    override fun getCustomOptionsStep(context: WizardContext, parentDisposable: Disposable): ModuleWizardStep =
-        XMakeSdkSettingsStep(context).apply {
-            Disposer.register(parentDisposable, this::disposeUIResources)
-        }
-
-    companion object {
-        private val Log = Logger.getInstance(XMakeModuleBuilder::class.java.getName())
-    }
-}

+ 0 - 41
src/main/kotlin/io/xmake/project/XMakeModuleType.kt

@@ -1,41 +0,0 @@
-package io.xmake.project
-
-import com.intellij.openapi.module.ModuleType
-import com.intellij.openapi.module.ModuleTypeManager
-import io.xmake.icons.XMakeIcons
-import org.jetbrains.jps.model.module.JpsModuleSourceRootType
-import javax.swing.Icon
-
-@Deprecated("Please refer to the relevant content in folder io/xmake/project/wizard.")
-class XMakeModuleType : ModuleType<XMakeModuleBuilder>(MODULE_TYPE) {
-
-    override fun createModuleBuilder(): XMakeModuleBuilder {
-        return XMakeModuleBuilder()
-    }
-
-    override fun getName(): String {
-        return "XMake"
-    }
-
-    override fun getDescription(): String {
-        return "XMake Module"
-    }
-
-    override fun getNodeIcon(b: Boolean): Icon {
-        return XMakeIcons.XMAKE
-    }
-
-    override fun isMarkInnerSupportedFor(type: JpsModuleSourceRootType<*>?): Boolean {
-        return true
-    }
-
-    companion object {
-
-        // the module type name
-        private val MODULE_TYPE = "XMake.Module"
-
-        // the instance
-        val instance: XMakeModuleType
-            get() = ModuleTypeManager.getInstance().findByID(MODULE_TYPE) as XMakeModuleType
-    }
-}

+ 0 - 92
src/main/kotlin/io/xmake/project/XMakeNewProjectPanel.kt

@@ -1,92 +0,0 @@
-package io.xmake.project
-
-import com.intellij.openapi.Disposable
-import com.intellij.openapi.diagnostic.logger
-import com.intellij.openapi.project.ProjectManager
-import com.intellij.ui.dsl.builder.AlignX
-import com.intellij.ui.dsl.builder.Panel
-import com.intellij.ui.layout.ComboBoxPredicate
-import io.xmake.project.directory.ui.DirectoryBrowser
-import io.xmake.project.toolkit.Toolkit
-import io.xmake.project.toolkit.ui.ToolkitComboBox
-import io.xmake.project.toolkit.ui.ToolkitListItem
-import javax.swing.DefaultComboBoxModel
-
-@Deprecated("Please refer to the relevant content in folder io/xmake/project/wizard.")
-class XMakeNewProjectPanel : Disposable {
-
-    // the module kinds
-    private val kindsModel = DefaultComboBoxModel<String>().apply {
-        addElement("Console")
-        addElement("Static Library")
-        addElement("Shared Library")
-    }
-
-    // the module languages
-    private val languagesModel = DefaultComboBoxModel<String>().apply {
-        addElement("C")
-        addElement("C++")
-        addElement("Rust")
-        addElement("Dlang")
-        addElement("Go")
-        addElement("Swift")
-        addElement("Objc")
-        addElement("Objc++")
-    }
-
-    private var toolkit: Toolkit? = null
-    private val toolkitComboBox = ToolkitComboBox(::toolkit)
-
-    private val browser = DirectoryBrowser(ProjectManager.getInstance().defaultProject)
-
-    val data: XMakeConfigData
-        get() = XMakeConfigData(
-            languagesModel.selectedItem.toString().lowercase(),
-            template,
-            toolkit,
-            browser.text
-        ).also { println("XMakeConfigData: ${it.toolkit}, ${it.remotePath}") }
-
-    // get template
-    private val template: String
-        get() = when (kindsModel.selectedItem.toString()) {
-            "Console" -> "console"
-            "Static Library" -> "static"
-            "Shared Library" -> "shared"
-            else -> "console"
-        }
-
-    fun attachTo(layout: Panel) = with(layout) {
-        row("Remote Project Dir:") {
-            cell(browser).align(AlignX.FILL)
-        }.visibleIf(ComboBoxPredicate<ToolkitListItem>(toolkitComboBox) {
-            (it as? ToolkitListItem.ToolkitItem)?.toolkit?.isOnRemote ?: false
-        })
-        row("Xmake Toolkit:") {
-            cell(toolkitComboBox)
-                .applyToComponent {
-                    addToolkitChangedListener { toolkit ->
-                        browser.removeBrowserAllListener()
-                        toolkit?.let {
-                            browser.addBrowserListenerByToolkit(it)
-                        }
-                    }
-                    activatedToolkit?.let { browser.addBrowserListenerByToolkit(it) }
-                }
-                .align(AlignX.FILL)
-        }
-        row("Module Language:") {
-            comboBox(languagesModel).align(AlignX.FILL)
-        }
-        row("Module Type:") {
-            comboBox(kindsModel).align(AlignX.FILL)
-        }
-    }
-
-    override fun dispose() {}
-
-    companion object {
-        val Log = logger<XMakeNewProjectPanel>()
-    }
-
-}

+ 0 - 270
src/main/kotlin/io/xmake/project/XMakeProjectConfigurable.kt

@@ -1,270 +0,0 @@
-package io.xmake.project
-
-import com.intellij.openapi.project.Project
-
-@Deprecated("Migrate to Run Configuration Editor.")
-class XMakeProjectConfigurable(
-    private val project: Project,
-)/* : Configurable, Configurable.NoScroll {
-    private val platformsModel = DefaultComboBoxModel<String>()
-
-    // the architectures ui
-    private val architecturesModel = DefaultComboBoxModel<String>()
-
-    // the modes ui
-    private val modesModel = DefaultComboBoxModel<String>()
-
-    // the additional configuration
-    private val additionalConfiguration = JBTextField()
-
-    // the configuration command text
-    private val configurationCommandText = JTextArea(10, 10)
-
-    // the android NDK directory
-    private val androidNDKDirectory = run {
-        val textField = TextFieldWithBrowseButton().apply {
-            val fileChooser = FileChooserDescriptorFactory.createSingleFolderDescriptor().apply {
-                title = ExecutionBundle.message("select.working.directory.message")
-            }
-            addBrowseFolderListener(null, null, null, fileChooser)
-        }
-        LabeledComponent.create(textField, ExecutionBundle.message("run.configuration.working.directory.label"))
-    }
-
-    // the build output directory
-    private val buildOutputDirectory = run {
-        val textField = TextFieldWithBrowseButton().apply {
-            val fileChooser = FileChooserDescriptorFactory.createSingleFolderDescriptor().apply {
-                title = ExecutionBundle.message("select.working.directory.message")
-            }
-            addBrowseFolderListener(null, null, null, fileChooser)
-        }
-        LabeledComponent.create(textField, ExecutionBundle.message("run.configuration.working.directory.label"))
-    }
-
-    // verbose output
-    private var verboseOutput = JBCheckBox("Show verbose output", true)
-
-    override fun createComponent(): JComponent {
-        return panel {
-            row("Platform:") {
-                comboBox(platformsModel)
-            }
-
-            row("Architecture:") {
-                comboBox(architecturesModel)
-            }
-
-            row("Mode:") {
-                comboBox(modesModel)
-            }
-
-            row("Additional configuration:") {
-                cell(additionalConfiguration).align(AlignX.FILL)
-            }
-
-            row {
-                cell(verboseOutput)
-            }
-
-            row(buildOutputDirectory.label) {
-                cell(buildOutputDirectory).align(AlignX.FILL)
-            }
-            buildOutputDirectory.label.text = "Build directory: "
-
-            row(androidNDKDirectory.label) {
-                cell(androidNDKDirectory).align(AlignX.FILL)
-            }
-            androidNDKDirectory.label.text = "Android NDK directory: "
-
-            row {
-                cell(SeparatorComponent())
-            }
-
-            row {
-                cell(configurationCommandText).applyToComponent {
-                    isEditable = false
-                    font = JBFont.label().asItalic()
-                    foreground = UIUtil.getTextAreaForeground()
-                    background = UIUtil.getFocusedBoundsColor()
-                    border = JBUI.Borders.empty(8)
-                }
-                    .align(AlignY.BOTTOM)
-                    .align(AlignX.FILL)
-            }
-
-            platformsModel.addListDataListener(object : ListDataListener {
-                override fun contentsChanged(e: ListDataEvent) {
-                    architecturesModel.removeAllElements()
-                    for (architecture in XMakeConfiguration.getArchitecturesByPlatform(platformsModel.selectedItem.toString())) {
-                        architecturesModel.addElement(architecture)
-                    }
-                    configurationCommandText.text = previewConfigurationCommand
-                }
-
-                override fun intervalAdded(e: ListDataEvent) {
-                }
-
-                override fun intervalRemoved(e: ListDataEvent) {
-                }
-            })
-
-            architecturesModel.addListDataListener(object : ListDataListener {
-                override fun contentsChanged(e: ListDataEvent) {
-                    configurationCommandText.text = previewConfigurationCommand
-                }
-
-                override fun intervalAdded(e: ListDataEvent) {
-                }
-
-                override fun intervalRemoved(e: ListDataEvent) {
-                }
-            })
-
-            modesModel.addListDataListener(object : ListDataListener {
-                override fun contentsChanged(e: ListDataEvent) {
-                    configurationCommandText.text = previewConfigurationCommand
-                }
-
-                override fun intervalAdded(e: ListDataEvent) {
-                }
-
-                override fun intervalRemoved(e: ListDataEvent) {
-                }
-            })
-
-            additionalConfiguration.addKeyListener(object : KeyListener {
-                override fun keyPressed(keyEvent: KeyEvent) {
-                    configurationCommandText.text = previewConfigurationCommand
-                }
-
-                override fun keyReleased(keyEvent: KeyEvent) {
-                    configurationCommandText.text = previewConfigurationCommand
-                }
-
-                override fun keyTyped(keyEvent: KeyEvent) {
-                    configurationCommandText.text = previewConfigurationCommand
-                }
-            })
-
-            verboseOutput.addItemListener(object : ItemListener {
-                override fun itemStateChanged(e: ItemEvent) {
-                    configurationCommandText.text = previewConfigurationCommand
-                }
-            })
-        }
-    }
-
-    override fun disposeUIResources() {
-    }
-
-    override fun reset() {
-        val xmakeConfiguration = project.xmakeConfigurationOrNull
-        if (xmakeConfiguration != null) {
-            // reset platforms
-            platformsModel.removeAllElements()
-            for (platform in xmakeConfiguration.platforms) {
-                platformsModel.addElement(platform)
-            }
-            platformsModel.selectedItem = xmakeConfiguration.data.currentPlatform
-
-            // reset architectures
-            architecturesModel.removeAllElements()
-            for (architecture in xmakeConfiguration.architectures) {
-                architecturesModel.addElement(architecture)
-            }
-            architecturesModel.selectedItem = xmakeConfiguration.data.currentArchitecture
-
-            // reset modes
-            modesModel.removeAllElements()
-            for (mode in xmakeConfiguration.modes) {
-                modesModel.addElement(mode)
-            }
-            modesModel.selectedItem = xmakeConfiguration.data.currentMode
-
-            // reset additional configuration
-            additionalConfiguration.text = xmakeConfiguration.data.additionalConfiguration
-
-            // reset build output directory
-            buildOutputDirectory.component.text = xmakeConfiguration.data.buildOutputDirectory
-
-            // reset android ndk directory
-            androidNDKDirectory.component.text = xmakeConfiguration.data.androidNDKDirectory
-
-            // reset verbose output
-            verboseOutput.isSelected = xmakeConfiguration.data.verboseOutput
-
-            // reset configuration command text
-            configurationCommandText.text = previewConfigurationCommand
-        }
-    }
-
-    @Throws(ConfigurationException::class)
-    override fun apply() {
-        val xmakeConfiguration = project.xmakeConfigurationOrNull
-        if (xmakeConfiguration != null) {
-            xmakeConfiguration.data.currentPlatform = platformsModel.selectedItem.toString()
-            xmakeConfiguration.data.currentArchitecture = architecturesModel.selectedItem.toString()
-            xmakeConfiguration.data.currentMode = modesModel.selectedItem.toString()
-            xmakeConfiguration.data.additionalConfiguration = additionalConfiguration.text
-            xmakeConfiguration.data.buildOutputDirectory = buildOutputDirectory.component.text
-            xmakeConfiguration.data.androidNDKDirectory = androidNDKDirectory.component.text
-            xmakeConfiguration.data.verboseOutput = verboseOutput.isSelected
-        }
-    }
-
-    override fun isModified(): Boolean {
-        val xmakeConfiguration = project.xmakeConfigurationOrNull
-        if (xmakeConfiguration != null) {
-            if (xmakeConfiguration.data.currentPlatform != platformsModel.selectedItem.toString() ||
-                xmakeConfiguration.data.currentArchitecture != architecturesModel.selectedItem.toString() ||
-                xmakeConfiguration.data.currentMode != modesModel.selectedItem.toString() ||
-                xmakeConfiguration.data.additionalConfiguration != additionalConfiguration.text ||
-                xmakeConfiguration.data.buildOutputDirectory != buildOutputDirectory.component.text ||
-                xmakeConfiguration.data.androidNDKDirectory != androidNDKDirectory.component.text ||
-                xmakeConfiguration.data.verboseOutput != verboseOutput.isSelected
-            ) {
-                xmakeConfiguration.changed = true
-                return true
-            }
-        }
-        return false
-    }
-
-    override fun getDisplayName(): String = "XMake"
-    override fun getHelpTopic(): String? = null
-
-    private fun JPanel.makeWide() {
-        preferredSize = Dimension(1000, height)
-    }
-
-    private val previewConfigurationCommand: String
-        get() {
-            var cmd = "xmake f"
-            val platformItem = platformsModel.selectedItem
-            if (platformItem != null) {
-                cmd += " -p ${platformItem.toString()}"
-            }
-            if (architecturesModel.selectedItem != null) {
-                cmd += " -a ${architecturesModel.selectedItem?.toString()}"
-            }
-            if (modesModel.selectedItem != null) {
-                cmd += " -m ${modesModel.selectedItem?.toString()}"
-            }
-            if (platformItem?.toString() == "android" && androidNDKDirectory.component.text != "") {
-                cmd += " --ndk=\"${androidNDKDirectory.component.text}\""
-            }
-            if (buildOutputDirectory.component.text != "") {
-                cmd += " -o \"${buildOutputDirectory.component.text}\""
-            }
-            if (verboseOutput.isSelected) {
-                cmd += " -v"
-            }
-            cmd += " ${additionalConfiguration.text}"
-            return cmd
-        }
-
-    companion object {
-        private val Log = Logger.getInstance(XMakeProjectConfigurable::class.java.getName())
-    }
-}*/

+ 0 - 39
src/main/kotlin/io/xmake/project/XMakeProjectGeneratorPeer.kt

@@ -1,39 +0,0 @@
-package io.xmake.project
-
-import com.intellij.openapi.ui.TextFieldWithBrowseButton
-import com.intellij.openapi.ui.ValidationInfo
-import com.intellij.platform.GeneratorPeerImpl
-import com.intellij.ui.dsl.builder.panel
-import javax.swing.JComponent
-
-@Deprecated("Please refer to the relevant content in folder io/xmake/project/wizard.")
-class XMakeProjectGeneratorPeer : GeneratorPeerImpl<XMakeConfigData>() {
-
-    private val newProjectPanel = XMakeNewProjectPanel()
-    private var checkValid: Runnable? = null
-
-    override fun getSettings(): XMakeConfigData = newProjectPanel.data
-
-    override fun getComponent(myLocationField: TextFieldWithBrowseButton, checkValid: Runnable): JComponent {
-        this.checkValid = checkValid
-        return super.getComponent(myLocationField, checkValid)
-    }
-
-    override fun getComponent(): JComponent = panel {
-        newProjectPanel.attachTo(this)
-    }
-
-    override fun validate(): ValidationInfo? {
-        with(newProjectPanel.data) {
-            if (toolkit == null)
-                return ValidationInfo("Toolkit is not set")
-
-            // Todo: Check whether working directory is valid.
-            if (toolkit.isOnRemote && remotePath.isNullOrBlank()) {
-                return ValidationInfo("Working directory is not set!")
-            }
-
-            return null
-        }
-    }
-}

+ 0 - 8
src/main/kotlin/io/xmake/project/XMakeProjectSettingsStep.kt

@@ -1,8 +0,0 @@
-package io.xmake.project
-import com.intellij.ide.util.projectWizard.AbstractNewProjectStep
-import com.intellij.ide.util.projectWizard.ProjectSettingsStepBase
-import com.intellij.platform.DirectoryProjectGenerator
-
-@Deprecated("Please refer to the relevant content in folder io/xmake/project/wizard.")
-open class XMakeProjectSettingsStep(generator: DirectoryProjectGenerator<XMakeConfigData>)
-    : ProjectSettingsStepBase<XMakeConfigData>(generator, AbstractNewProjectStep.AbstractCallback())

+ 0 - 61
src/main/kotlin/io/xmake/project/XMakeSdkSettingsStep.kt

@@ -1,61 +0,0 @@
-package io.xmake.project
-
-import com.intellij.execution.configurations.RuntimeConfigurationError
-import com.intellij.ide.util.projectWizard.ModuleBuilder
-import com.intellij.ide.util.projectWizard.ModuleWizardStep
-import com.intellij.ide.util.projectWizard.WizardContext
-import com.intellij.openapi.module.Module
-import com.intellij.openapi.roots.ModifiableRootModel
-import com.intellij.openapi.util.Disposer
-import com.intellij.ui.dsl.builder.panel
-import com.intellij.util.ui.JBEmptyBorder
-import javax.swing.JComponent
-
-@Deprecated("Please refer to the relevant content in folder io/xmake/project/wizard.")
-class XMakeSdkSettingsStep(
-    private val context: WizardContext,
-    private val configurationUpdaterConsumer: ((ModuleBuilder.ModuleConfigurationUpdater) -> Unit)? = null
-) : ModuleWizardStep() {
-
-    private val newProjectPanel = XMakeNewProjectPanel()
-
-    override fun getComponent(): JComponent = panel {
-        newProjectPanel.attachTo(this)
-    }.withBorder(JBEmptyBorder(20, 20, 20, 20))
-
-    override fun disposeUIResources() = Disposer.dispose(newProjectPanel)
-
-    override fun updateDataModel() {
-        val data = newProjectPanel.data
-
-        val projectBuilder = context.projectBuilder
-        if (projectBuilder is XMakeModuleBuilder) {
-            projectBuilder.configurationData = data
-            projectBuilder.addModuleConfigurationUpdater(ConfigurationUpdater)
-        } else {
-            configurationUpdaterConsumer?.invoke(ConfigurationUpdater)
-        }
-    }
-
-    private object ConfigurationUpdater : ModuleBuilder.ModuleConfigurationUpdater() {
-
-        override fun update(module: Module, rootModel: ModifiableRootModel) {
-        }
-    }
-
-    override fun validate(): Boolean {
-
-        with(newProjectPanel.data) {
-            if (toolkit == null) {
-                throw RuntimeConfigurationError("Xmake toolkit is not set!")
-            }
-
-            // Todo: Check whether working directory is valid.
-            if ((toolkit.isOnRemote) && remotePath.isNullOrBlank()) {
-                throw RuntimeConfigurationError("Working directory is not set!")
-            }
-        }
-
-        return true
-    }
-}

+ 4 - 3
src/main/kotlin/io/xmake/project/directory/ui/DirectoryBrowser.kt

@@ -23,11 +23,11 @@ class DirectoryBrowser(val project: Project?) : TextFieldWithBrowseButton() {
     private fun createLocalBrowseListener(): ActionListener {
         val fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor()
         val browseFolderListener = BrowseFolderActionListener(
-            "Working Directory",
-            null,
             this,
             project,
-            fileChooserDescriptor,
+            fileChooserDescriptor
+                .withTitle("Working Directory")
+                .withDescription("Select the working directory"),
             TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT
         )
         return browseFolderListener
@@ -64,6 +64,7 @@ class DirectoryBrowser(val project: Project?) : TextFieldWithBrowseButton() {
                 listeners.add(wslBrowseListener)
                 Log.debug("addActionListener wsl: $wslBrowseListener")
             }
+
             SSH -> {
                 EP_NAME.extensions.first { it.KEY == "SSH" }.let { extension ->
                     println("host: $host")

+ 6 - 2
src/main/kotlin/io/xmake/project/wizard/NewProjectWizardDirectoryGeneratorAdapter.kt

@@ -5,6 +5,7 @@
  * - Changed class from final to open
  * - Date: 2024-08-07
  * - Author: windchargerj
+ * - Reference: [com.jetbrains.python.newProject.NewProjectWizardDirectoryGeneratorAdapter]
  */
 
 package io.xmake.project.wizard
@@ -16,6 +17,7 @@ import com.intellij.ide.wizard.GeneratorNewProjectWizard
 import com.intellij.ide.wizard.NewProjectWizardStepPanel
 import com.intellij.openapi.module.Module
 import com.intellij.openapi.project.Project
+import com.intellij.openapi.ui.TextFieldWithBrowseButton
 import com.intellij.openapi.ui.VerticalFlowLayout
 import com.intellij.openapi.vfs.VirtualFile
 import com.intellij.platform.DirectoryProjectGeneratorBase
@@ -26,6 +28,8 @@ import javax.swing.JButton
 import javax.swing.JComponent
 import javax.swing.JPanel
 
+// Todo: Refactor to transform a project wizard to a [com.intellij.platform.DirectoryProjectGenerator] directly.
+
 /**
  * A base adapter class to turn a [GeneratorNewProjectWizard] into a
  * [com.intellij.platform.DirectoryProjectGenerator] and register as an extension point.
@@ -47,7 +51,7 @@ open class NewProjectWizardDirectoryGeneratorAdapter<T : Any>(val wizard: Genera
     override fun createPeer(): ProjectGeneratorPeer<T> {
         val context = WizardContext(null) {}
         return object : GeneratorPeerImpl<T>() {
-            override fun getComponent(): JComponent {
+            override fun getComponent(myLocationField: TextFieldWithBrowseButton, checkValid: Runnable): JComponent {
                 panel = NewProjectWizardStepPanel(wizard.createStep(context))
                 return panel.component
             }
@@ -68,7 +72,7 @@ open class NewProjectWizardProjectSettingsStep<T : Any>(private val projectGener
 
     override fun createAndFillContentPanel(): JPanel =
         JPanel(VerticalFlowLayout()).apply {
-            add(peer.component)
+            add(peer.getComponent(TextFieldWithBrowseButton()) {})
         }
 
     override fun registerValidators() {}

+ 0 - 63
src/main/kotlin/io/xmake/utils/SystemUtils.kt

@@ -12,77 +12,14 @@ import io.xmake.shared.XMakeProblem
 import io.xmake.utils.exception.XMakeToolkitNotSetException
 import io.xmake.utils.execute.createProcess
 import io.xmake.utils.execute.runProcessWithHandler
-import io.xmake.utils.interact.kXMakeVersion
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.runBlocking
-import java.io.File
 import java.nio.file.Path
 import java.nio.file.Paths
 import java.util.regex.Pattern
 
 object SystemUtils {
 
-    @Deprecated("Please refer to the relevant content in folder io/xmake/project/toolkit.")
-    // the xmake program
-    private var _xmakeProgram: String = ""
-
-    @Deprecated("Please refer to the relevant content in folder io/xmake/project/toolkit.")
-    var xmakeProgram: String
-        get() {
-
-            // cached? return it directly
-            if (_xmakeProgram != "") {
-                return _xmakeProgram
-            }
-
-            // for windows? return xmake directly
-            if (SystemInfo.isWindows) {
-                _xmakeProgram = "xmake"
-                return _xmakeProgram
-            }
-
-            // attempt to get xmake program
-            val programs = arrayOf(
-                "xmake",
-                (System.getenv("HOME") ?: "") + "/.local/bin/xmake",
-                "/usr/local/bin/xmake",
-                "/usr/bin/xmake",
-                "/opt/homebrew/bin/xmake"
-            )
-            for (program in programs) {
-                if (program == "xmake" || File(program).exists()) {
-                    val result = ioRunvInPool(listOf(program, "--version"))
-                    if (result.isNotEmpty()) {
-                        _xmakeProgram = program
-                        break
-                    }
-                }
-            }
-            return _xmakeProgram
-        }
-        set(value) {
-            _xmakeProgram = value
-        }
-
-    @Deprecated("Please refer to the relevant content in folder io/xmake/project/toolkit.")
-    // the xmake version
-    private var _xmakeVersion: String = ""
-
-    @Deprecated("Please refer to the relevant content in folder io/xmake/project/toolkit.")
-    var xmakeVersion: String
-        get() {
-            if (_xmakeVersion == "") {
-                val result = kXMakeVersion
-                if (result.isNotEmpty()) {
-                    _xmakeVersion = result
-                }
-            }
-            return _xmakeVersion
-        }
-        set(value) {
-            _xmakeVersion = value
-        }
-
     // get platform
     fun platform(): String = when {
         SystemInfo.isWindows -> "windows"

+ 2 - 4
src/main/kotlin/io/xmake/utils/extension/SshToolkitHostExtensionImpl.kt

@@ -5,7 +5,6 @@ import com.intellij.execution.configurations.GeneralCommandLine
 import com.intellij.openapi.application.EDT
 import com.intellij.openapi.application.runWriteAction
 import com.intellij.openapi.diagnostic.logger
-import com.intellij.openapi.diagnostic.runAndLogException
 import com.intellij.openapi.progress.ProgressIndicator
 import com.intellij.openapi.progress.ProgressManager
 import com.intellij.openapi.progress.Task
@@ -88,13 +87,12 @@ class SshToolkitHostExtensionImpl : ToolkitHostExtension {
                         when (direction) {
                             SyncDirection.LOCAL_TO_UPSTREAM -> {
 
-                                Log.runAndLogException {
+                                Log.runCatching {
                                     tryRunWithException<SftpChannelNoSuchFileException, List<SftpChannel.FileInfo>> {
                                         sftpChannel.ls(
                                             remoteDirectory
                                         )
-                                    }
-                                        .also { Log.info("before: $it") }
+                                    }.also { Log.info("before: $it") }
                                     sftpChannel.rmRecur(remoteDirectory)
                                     Log.info("after: " + sftpChannel.ls("Project"))
                                 }

+ 1 - 1
src/main/kotlin/io/xmake/utils/extension/ToolkitHostExtension.kt

@@ -34,5 +34,5 @@ interface ToolkitHostExtension {
 
     fun DirectoryBrowser.createBrowseListener(host: ToolkitHost): ActionListener
 
-    fun GeneralCommandLine.createProcess(target: ToolkitHost): Process
+    fun GeneralCommandLine.createProcess(host: ToolkitHost): Process
 }

+ 9 - 9
src/main/resources/META-INF/plugin.xml

@@ -67,47 +67,47 @@
             <action id="XMake.Run"
                     class="io.xmake.actions.RunAction"
                     text="Run Target"
-                    icon="com.intellij.icons.ExpUiIcons.Run.Run"
+                    icon="AllIcons.Actions.Execute"
                     description="Run the current target."/>
             <action id="XMake.Build"
                     class="io.xmake.actions.BuildAction"
                     text="Build Project"
-                    icon="com.intellij.icons.ExpUiIcons.Build.Build"
+                    icon="AllIcons.Actions.Compile"
                     description="Build the current project."/>
             <action id="XMake.Rebuild"
                     class="io.xmake.actions.RebuildAction"
                     text="Rebuild Project"
-                    icon="com.intellij.icons.ExpUiIcons.Run.Restart"
+                    icon="AllIcons.Actions.Restart"
                     description="Rebuild the current project."/>
             <action id="XMake.Clean"
                     class="io.xmake.actions.CleanAction"
                     text="Clean Project"
-                    icon="com.intellij.icons.ExpUiIcons.Actions.ClearCash"
+                    icon="AllIcons.Actions.ClearCash"
                     description="Clean target and object files."/>
             <separator/>
             <reference id="editRunConfigurations"/>
             <action id="XMake.CleanConfiguration"
                     class="io.xmake.actions.CleanConfigurationAction"
                     text="Clean Configuration"
-                    icon="com.intellij.icons.ExpUiIcons.Vcs.Revert"
+                    icon="AllIcons.Diff.Revert"
                     description="Clean the current configuration."/>
             <separator/>
             <action id="XMake.QuickStart"
                     class="io.xmake.actions.QuickStartAction"
                     text="Quick Start"
-                    icon="com.intellij.icons.ExpUiIcons.Actions.Lightning"
+                    icon="AllIcons.Actions.Lightning"
                     description="Quick start a new project."/>
             <action id="XMake.UpdateCmakeLists"
                     class="io.xmake.actions.UpdateCmakeListsAction"
                     text="Update CmakeLists"
-                    icon="com.intellij.icons.ExpUiIcons.FileTypes.Less"
-                    description="Create or update the CmakeLists.txt.">
+                    icon="AllIcons.FileTypes.Csv"
+                    description="Create or update the CMakeLists.txt.">
                 <keyboard-shortcut keymap="$default" first-keystroke="alt U" />
             </action>
             <action id="XMake.UpdateCompileCommands"
                     class="io.xmake.actions.UpdateCompileCommandsAction"
                     text="Update Compile Commands"
-                    icon="com.intellij.icons.ExpUiIcons.FileTypes.SourceMap"
+                    icon="AllIcons.FileTypes.Json"
                     description="Create or update  compile_commands.js.">
             </action>
         </group>