read-only sources must works without configured ICS repo — ui

This commit is contained in:
Vladimir Krivosheev
2016-12-27 11:48:27 +01:00
parent d707262f9d
commit 5a6ed128ab
3 changed files with 20 additions and 10 deletions
@@ -49,7 +49,11 @@ internal class IcsConfigurableUi : ConfigurableUi<IcsSettings>, Disposable {
override fun apply(settings: IcsSettings) {
settings.autoSync = autoSync.isSelected
editors.forEach { it.apply(settings) }
editors.forEach {
if (it.isModified(settings)) {
it.apply(settings)
}
}
saveSettings(settings, icsManager.settingsFile)
}
@@ -15,6 +15,7 @@
*/
package org.jetbrains.settingsRepository
import com.intellij.openapi.diagnostic.catchAndLog
import com.intellij.openapi.diagnostic.debug
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.util.AtomicClearableLazyValue
@@ -40,7 +41,11 @@ class ReadOnlySourceManager(private val settings: IcsSettings, val rootDir: Path
}
return settings.readOnlySources.mapSmartNotNull { source ->
try {
LOG.catchAndLog {
if (!source.active) {
return@mapSmartNotNull null
}
val path = source.path ?: return@mapSmartNotNull null
val dir = rootDir.resolve(path)
if (dir.exists()) {
@@ -49,12 +54,8 @@ class ReadOnlySourceManager(private val settings: IcsSettings, val rootDir: Path
else {
LOG.warn("Skip read-only source ${source.url} because dir doesn't exist")
}
null
}
catch (e: Exception) {
LOG.error(e)
}
null
}
}
}
@@ -54,8 +54,13 @@ internal fun createRepositoryListEditor(): ConfigurableUi<IcsSettings> {
override fun getComponent() = panel {
row("Repository:") {
editor.comboBox()
deleteButton()
if (editor.model.isEmpty) {
hint("Use File -> Settings Repository... to configure")
}
else {
editor.comboBox()
deleteButton()
}
}
}
@@ -69,7 +74,7 @@ internal fun createRepositoryListEditor(): ConfigurableUi<IcsSettings> {
override fun reset(settings: IcsSettings) {
val list = ArrayList<RepositoryItem>()
val upstream = icsManager.repositoryManager.getUpstream()?.let { RepositoryItem(it) }
val upstream = icsManager.repositoryManager.getUpstream()?.let(::RepositoryItem)
upstream?.let {
list.add(it)
}