-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#265) Settings: some renames and TODO marking
- Loading branch information
Showing
13 changed files
with
117 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 28 additions & 37 deletions
65
src/rider/main/kotlin/me/fornever/avaloniarider/idea/settings/AvaloniaProjectSettings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,40 @@ | ||
package me.fornever.avaloniarider.idea.settings | ||
|
||
import com.intellij.openapi.components.* | ||
import com.intellij.openapi.components.BaseState | ||
import com.intellij.openapi.components.Service | ||
import com.intellij.openapi.components.SimplePersistentStateComponent | ||
import com.intellij.openapi.components.State | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.util.io.FileUtil | ||
import com.intellij.util.application | ||
import com.intellij.util.io.systemIndependentPath | ||
import com.jetbrains.rider.util.idea.getService | ||
import java.io.File | ||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
|
||
class AvaloniaProjectState : BaseState() { | ||
var projectPerEditor by map<String, String>() | ||
|
||
enum class AvaloniaPreviewerMethod { | ||
AvaloniaRemote, | ||
Html | ||
} | ||
|
||
@State(name = "AvaloniaProject", storages = [Storage("avalonia.xml")]) | ||
@Service(Service.Level.PROJECT) | ||
class AvaloniaProjectSettings(private val project: Project) : SimplePersistentStateComponent<AvaloniaProjectState>( | ||
AvaloniaProjectState() | ||
) { | ||
companion object { | ||
fun getInstance(project: Project): AvaloniaProjectSettings = project.getService() | ||
} | ||
class AvaloniaProjectSettingsState : BaseState() { | ||
var previewerMethod by enum(AvaloniaPreviewerMethod.AvaloniaRemote) | ||
|
||
private fun getProjectRelativeSystemIndependentPath(relativePath: Path): String { | ||
val basePath = project.basePath ?: return relativePath.systemIndependentPath | ||
val resultPath = FileUtil.getRelativePath(File(basePath), relativePath.toFile()) | ||
?: return relativePath.systemIndependentPath | ||
return Paths.get(resultPath).systemIndependentPath | ||
} | ||
/** | ||
* Synchronize current run configuration and selected project, when possible. | ||
*/ | ||
var synchronizeWithRunConfiguration by property(false) | ||
|
||
fun storeSelection(xamlFilePath: Path, projectFilePath: Path) { | ||
application.assertIsDispatchThread() | ||
var fpsLimit by property(0) | ||
} | ||
|
||
val relativeXamlPath = getProjectRelativeSystemIndependentPath(xamlFilePath) | ||
val relativeProjectPath = getProjectRelativeSystemIndependentPath(projectFilePath) | ||
state.projectPerEditor[relativeXamlPath] = relativeProjectPath | ||
@State(name = "Avalonia") // TODO[#265]: Move to avalonia.xml | ||
@Service | ||
class AvaloniaProjectSettings : SimplePersistentStateComponent<AvaloniaProjectSettingsState>(AvaloniaProjectSettingsState()) { | ||
companion object { | ||
fun getInstance(project: Project): AvaloniaProjectSettings = project.getService(AvaloniaProjectSettings::class.java) | ||
} | ||
|
||
fun getSelection(xamlFilePath: Path): Path? { | ||
application.assertIsDispatchThread() | ||
val previewerTransportType: AvaloniaPreviewerMethod | ||
get() = state.previewerMethod | ||
|
||
val relativeXamlPath = getProjectRelativeSystemIndependentPath(xamlFilePath) | ||
val relativeProjectPath = state.projectPerEditor[relativeXamlPath] ?: return null | ||
val basePath = project.basePath ?: return Paths.get(relativeProjectPath) | ||
return Paths.get(basePath, relativeProjectPath) | ||
} | ||
val synchronizeWithRunConfiguration: Boolean | ||
get() = state.synchronizeWithRunConfiguration | ||
|
||
val fpsLimit: Int | ||
get() = state.fpsLimit | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
src/rider/main/kotlin/me/fornever/avaloniarider/idea/settings/AvaloniaSettings.kt
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
src/rider/main/kotlin/me/fornever/avaloniarider/idea/settings/AvaloniaWorkspaceSettings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package me.fornever.avaloniarider.idea.settings | ||
|
||
import com.intellij.openapi.components.* | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.util.io.FileUtil | ||
import com.intellij.util.application | ||
import com.intellij.util.io.systemIndependentPath | ||
import com.jetbrains.rider.util.idea.getService | ||
import java.io.File | ||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
|
||
/** | ||
* These are Avalonia workspace-tied settings, not generally meant to be shared across the team. | ||
*/ | ||
class AvaloniaWorkspaceState : BaseState() { | ||
var projectPerEditor by map<String, String>() | ||
} | ||
|
||
@State(name = "AvaloniaProject", storages = [Storage("avalonia.xml")]) // TODO[#265]: move to a workspace-related file | ||
@Service(Service.Level.PROJECT) | ||
class AvaloniaWorkspaceSettings(private val project: Project) : SimplePersistentStateComponent<AvaloniaWorkspaceState>( | ||
AvaloniaWorkspaceState() | ||
) { | ||
companion object { | ||
fun getInstance(project: Project): AvaloniaWorkspaceSettings = project.getService() | ||
} | ||
|
||
private fun getProjectRelativeSystemIndependentPath(relativePath: Path): String { | ||
val basePath = project.basePath ?: return relativePath.systemIndependentPath | ||
val resultPath = FileUtil.getRelativePath(File(basePath), relativePath.toFile()) | ||
?: return relativePath.systemIndependentPath | ||
return Paths.get(resultPath).systemIndependentPath | ||
} | ||
|
||
fun storeSelection(xamlFilePath: Path, projectFilePath: Path) { | ||
application.assertIsDispatchThread() | ||
|
||
val relativeXamlPath = getProjectRelativeSystemIndependentPath(xamlFilePath) | ||
val relativeProjectPath = getProjectRelativeSystemIndependentPath(projectFilePath) | ||
state.projectPerEditor[relativeXamlPath] = relativeProjectPath | ||
} | ||
|
||
fun getSelection(xamlFilePath: Path): Path? { | ||
application.assertIsDispatchThread() | ||
|
||
val relativeXamlPath = getProjectRelativeSystemIndependentPath(xamlFilePath) | ||
val relativeProjectPath = state.projectPerEditor[relativeXamlPath] ?: return null | ||
val basePath = project.basePath ?: return Paths.get(relativeProjectPath) | ||
return Paths.get(basePath, relativeProjectPath) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.