mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup Kotlin UI DSL, clarify docs about panel fillX and and add FAQ about cell grow/push
This commit is contained in:
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.credentialStore
|
||||
|
||||
import com.intellij.ide.passwordSafe.PasswordSafe
|
||||
@@ -150,7 +136,7 @@ internal class PasswordSafeConfigurableUi : ConfigurableUi<PasswordSafeSettings>
|
||||
|
||||
fun getCurrentDbFile() = keePassDbFile.text.trim().nullize()?.let { Paths.get(it) }
|
||||
|
||||
fun updateEnabledState() {
|
||||
private fun updateEnabledState() {
|
||||
modeToRow[ProviderType.KEEPASS]?.subRowsEnabled = getProviderType() == ProviderType.KEEPASS
|
||||
}
|
||||
|
||||
@@ -177,7 +163,7 @@ internal class PasswordSafeConfigurableUi : ConfigurableUi<PasswordSafeSettings>
|
||||
}
|
||||
keePassDbFile = textFieldWithBrowseButton("KeePass Database File",
|
||||
fileChooserDescriptor = fileChooserDescriptor,
|
||||
fileChoosen = ::normalizeSelectedFile)
|
||||
fileChosen = ::normalizeSelectedFile)
|
||||
gearButton(
|
||||
object : AnAction("Clear") {
|
||||
override fun actionPerformed(event: AnActionEvent) {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
@file:Suppress("FunctionName")
|
||||
|
||||
package com.intellij.ui.components
|
||||
|
||||
import com.intellij.BundleBase
|
||||
@@ -88,7 +90,7 @@ fun noteComponent(note: String): JComponent {
|
||||
@JvmOverloads
|
||||
fun htmlComponent(text: String = "", font: Font = UIUtil.getLabelFont(), background: Color? = null, foreground: Color? = null, lineWrap: Boolean = false): JEditorPane {
|
||||
val pane = SwingHelper.createHtmlViewer(lineWrap, font, background, foreground)
|
||||
if (!text.isNullOrEmpty()) {
|
||||
if (!text.isEmpty()) {
|
||||
pane.text = "<html><head>${UIUtil.getCssFontDeclaration(font, UIUtil.getLabelForeground(), null, null)}</head><body>$text</body></html>"
|
||||
}
|
||||
pane.border = null
|
||||
@@ -161,15 +163,15 @@ fun <T : JComponent> installFileCompletionAndBrowseDialog(project: Project?,
|
||||
@Nls(capitalization = Nls.Capitalization.Title) browseDialogTitle: String,
|
||||
fileChooserDescriptor: FileChooserDescriptor,
|
||||
textComponentAccessor: TextComponentAccessor<T>,
|
||||
fileChoosen: ((chosenFile: VirtualFile) -> String)? = null) {
|
||||
fileChosen: ((chosenFile: VirtualFile) -> String)? = null) {
|
||||
component.addActionListener(
|
||||
object : BrowseFolderActionListener<T>(browseDialogTitle, null, component, project, fileChooserDescriptor, textComponentAccessor) {
|
||||
override fun onFileChosen(chosenFile: VirtualFile) {
|
||||
if (fileChoosen == null) {
|
||||
if (fileChosen == null) {
|
||||
super.onFileChosen(chosenFile)
|
||||
}
|
||||
else {
|
||||
textComponentAccessor.setText(myTextComponent.childComponent, fileChoosen(chosenFile))
|
||||
textComponentAccessor.setText(myTextComponent.childComponent, fileChosen(chosenFile))
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -181,7 +183,7 @@ fun textFieldWithHistoryWithBrowseButton(project: Project?,
|
||||
browseDialogTitle: String,
|
||||
fileChooserDescriptor: FileChooserDescriptor,
|
||||
historyProvider: (() -> List<String>)? = null,
|
||||
fileChoosen: ((chosenFile: VirtualFile) -> String)? = null): TextFieldWithHistoryWithBrowseButton {
|
||||
fileChosen: ((chosenFile: VirtualFile) -> String)? = null): TextFieldWithHistoryWithBrowseButton {
|
||||
val component = TextFieldWithHistoryWithBrowseButton()
|
||||
val textFieldWithHistory = component.childComponent
|
||||
textFieldWithHistory.setHistorySize(-1)
|
||||
@@ -196,7 +198,7 @@ fun textFieldWithHistoryWithBrowseButton(project: Project?,
|
||||
browseDialogTitle,
|
||||
fileChooserDescriptor,
|
||||
TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT,
|
||||
fileChoosen = fileChoosen
|
||||
fileChosen = fileChosen
|
||||
)
|
||||
return component
|
||||
}
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ui.layout
|
||||
|
||||
import com.intellij.codeInspection.SmartHashMap
|
||||
@@ -204,7 +190,6 @@ private class MigLayoutRow(private val componentConstraints: MutableMap<Componen
|
||||
get() = _subRows ?: emptyList()
|
||||
|
||||
override var enabled: Boolean = true
|
||||
get() = field
|
||||
set(value) {
|
||||
if (field == value) {
|
||||
return
|
||||
@@ -217,7 +202,6 @@ private class MigLayoutRow(private val componentConstraints: MutableMap<Componen
|
||||
}
|
||||
|
||||
override var visible: Boolean = true
|
||||
get() = field
|
||||
set(value) {
|
||||
if (field == value) {
|
||||
return
|
||||
@@ -230,7 +214,6 @@ private class MigLayoutRow(private val componentConstraints: MutableMap<Componen
|
||||
}
|
||||
|
||||
override var subRowsEnabled: Boolean = true
|
||||
get() = field
|
||||
set(value) {
|
||||
if (field == value) {
|
||||
return
|
||||
@@ -241,7 +224,6 @@ private class MigLayoutRow(private val componentConstraints: MutableMap<Componen
|
||||
}
|
||||
|
||||
override var subRowsVisible: Boolean = true
|
||||
get() = field
|
||||
set(value) {
|
||||
if (field == value) {
|
||||
return
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ui.layout
|
||||
|
||||
import com.intellij.BundleBase
|
||||
@@ -42,7 +28,7 @@ import javax.swing.JButton
|
||||
import javax.swing.JComponent
|
||||
import javax.swing.JLabel
|
||||
|
||||
abstract class Row() {
|
||||
abstract class Row {
|
||||
abstract var enabled: Boolean
|
||||
|
||||
abstract var visible: Boolean
|
||||
@@ -76,8 +62,8 @@ abstract class Row() {
|
||||
project: Project? = null,
|
||||
fileChooserDescriptor: FileChooserDescriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(),
|
||||
historyProvider: (() -> List<String>)? = null,
|
||||
fileChoosen: ((chosenFile: VirtualFile) -> String)? = null): TextFieldWithHistoryWithBrowseButton {
|
||||
val component = textFieldWithHistoryWithBrowseButton(project, browseDialogTitle, fileChooserDescriptor, historyProvider, fileChoosen)
|
||||
fileChosen: ((chosenFile: VirtualFile) -> String)? = null): TextFieldWithHistoryWithBrowseButton {
|
||||
val component = textFieldWithHistoryWithBrowseButton(project, browseDialogTitle, fileChooserDescriptor, historyProvider, fileChosen)
|
||||
value?.let { component.text = it }
|
||||
component()
|
||||
return component
|
||||
@@ -121,7 +107,8 @@ abstract class Row() {
|
||||
init()
|
||||
}
|
||||
|
||||
protected abstract fun alignRight()
|
||||
@PublishedApi
|
||||
internal abstract fun alignRight()
|
||||
|
||||
inline fun row(label: String, init: Row.() -> Unit): Row {
|
||||
val row = createRow(label)
|
||||
@@ -136,7 +123,8 @@ abstract class Row() {
|
||||
return row
|
||||
}
|
||||
|
||||
protected abstract fun createRow(label: String?): Row
|
||||
@PublishedApi
|
||||
internal abstract fun createRow(label: String?): Row
|
||||
|
||||
@Deprecated(message = "Nested row is prohibited", level = DeprecationLevel.ERROR)
|
||||
fun row(label: JLabel? = null, init: Row.() -> Unit) {
|
||||
|
||||
@@ -1,18 +1,6 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
@file:Suppress("EnumEntryName")
|
||||
|
||||
package com.intellij.ui.layout
|
||||
|
||||
// http://www.migcalendar.com/miglayout/mavensite/docs/cheatsheet.pdf
|
||||
@@ -43,6 +31,9 @@ enum class LCFlags {
|
||||
debug
|
||||
}
|
||||
|
||||
/**
|
||||
* See FAQ in the [docs](https://github.com/JetBrains/intellij-community/tree/master/platform/platform-impl/src/com/intellij/ui/layout).
|
||||
*/
|
||||
enum class CCFlags {
|
||||
/**
|
||||
* Wrap to the next line/column **after** the component that this constraint belongs to.
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ui.layout
|
||||
|
||||
import com.intellij.ui.components.Panel
|
||||
@@ -20,7 +6,7 @@ import com.intellij.ui.layout.LCFlags.*
|
||||
import javax.swing.JPanel
|
||||
|
||||
/**
|
||||
* Claims all available space in the container for the columns ([LCFlags.fillX]).
|
||||
* Claims all available space in the container for the columns ([LCFlags.fillX], if `constraints` is passed, `fillX` will be not applied - add it explicitly if need).
|
||||
* At least one component need to have a [CCFlags.grow] constraint for it to fill the container.
|
||||
*
|
||||
* See [docs](https://github.com/JetBrains/intellij-community/tree/master/platform/platform-impl/src/com/intellij/ui/layout)
|
||||
|
||||
@@ -44,4 +44,10 @@ val panel = panel {
|
||||
}
|
||||
noteRow("""Do not have an account? <a href="https://account.jetbrains.com/login">Sign Up</a>""")
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
## FAQ
|
||||
|
||||
### One cell is minimum, second one is maximum
|
||||
|
||||
Set `CCFlags.growX` and `CCFlags.pushX` for some component in the second cell.
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.settingsRepository
|
||||
|
||||
import com.intellij.credentialStore.Credentials
|
||||
@@ -30,7 +16,7 @@ import javax.swing.JTextField
|
||||
import javax.swing.event.DocumentEvent
|
||||
|
||||
fun showAuthenticationForm(credentials: Credentials?, uri: String, host: String?, path: String?, sshKeyFile: String?): Credentials? {
|
||||
if (ApplicationManager.getApplication()?.isUnitTestMode === true) {
|
||||
if (ApplicationManager.getApplication()?.isUnitTestMode == true) {
|
||||
throw AssertionError("showAuthenticationForm called from tests")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user