mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix ITN (regression after last change)
correctly set focused component to password field if user specified
This commit is contained in:
@@ -54,7 +54,8 @@ class Credentials(user: String?, val password: OneTimeString? = null) {
|
||||
|
||||
fun CredentialAttributes(requestor: Class<*>, userName: String?) = CredentialAttributes(requestor.name, userName, requestor)
|
||||
|
||||
fun Credentials?.isFulfilled() = this != null && userName != null && password != null
|
||||
fun Credentials?.isFulfilled() = this != null && userName != null && !password.isNullOrEmpty()
|
||||
fun Credentials?.hasOnlyUserName() = this != null && userName != null && password.isNullOrEmpty()
|
||||
|
||||
fun Credentials?.isEmpty() = this == null || (userName == null && password == null)
|
||||
|
||||
|
||||
@@ -21,21 +21,29 @@ import javax.swing.JComponent
|
||||
|
||||
fun dialog(title: String,
|
||||
centerPanel: JComponent,
|
||||
resizable: Boolean = true,
|
||||
resizable: Boolean = false,
|
||||
preferedFocusComponent: JComponent? = null,
|
||||
okActionEnabled: Boolean = true,
|
||||
project: Project? = null,
|
||||
parent: Component? = null): DialogBuilder {
|
||||
parent: Component? = null,
|
||||
ok: (() -> Unit)? = null): DialogBuilder {
|
||||
val builder = if (parent == null) DialogBuilder(project) else DialogBuilder(parent)
|
||||
builder
|
||||
.title(title)
|
||||
.centerPanel(centerPanel)
|
||||
.setPreferredFocusComponent(preferedFocusComponent)
|
||||
if (!resizable) {
|
||||
builder.resizable(false)
|
||||
}
|
||||
builder.resizable(resizable)
|
||||
if (!okActionEnabled) {
|
||||
builder.okActionEnabled(false)
|
||||
}
|
||||
|
||||
if (ok != null) {
|
||||
builder.setOkOperation {
|
||||
if (builder.dialogWrapper.okAction.isEnabled) {
|
||||
ok()
|
||||
builder.dialogWrapper.close(DialogWrapper.OK_EXIT_CODE)
|
||||
}
|
||||
}
|
||||
}
|
||||
return builder
|
||||
}
|
||||
@@ -1,18 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.util.net.AuthenticationPanel">
|
||||
<grid id="54d96" binding="myMainPanel" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="54d96" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
<constraints>
|
||||
<xy x="111" y="126" width="254" height="120"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
|
||||
<xy x="111" y="126" width="254" height="131"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="30b8c" class="javax.swing.JLabel" binding="myDescriptionLabel">
|
||||
<constraints>
|
||||
<xy x="10" y="13" width="234" height="14"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="1"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="##"/>
|
||||
@@ -20,8 +18,7 @@
|
||||
</component>
|
||||
<component id="2c164" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<xy x="10" y="65" width="54" height="14"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/CommonBundle" key="editbox.password"/>
|
||||
@@ -29,8 +26,7 @@
|
||||
</component>
|
||||
<component id="5918" class="javax.swing.JPasswordField" binding="myPasswordTextField">
|
||||
<constraints>
|
||||
<xy x="74" y="62" width="170" height="20"/>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -38,8 +34,7 @@
|
||||
</component>
|
||||
<component id="c345b" class="javax.swing.JTextField" binding="myLoginTextField">
|
||||
<constraints>
|
||||
<xy x="74" y="36" width="170" height="20"/>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -47,8 +42,7 @@
|
||||
</component>
|
||||
<component id="537de" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<xy x="10" y="39" width="33" height="14"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/CommonBundle" key="editbox.login"/>
|
||||
@@ -56,8 +50,7 @@
|
||||
</component>
|
||||
<component id="94544" class="javax.swing.JCheckBox" binding="rememberPasswordCheckBox">
|
||||
<constraints>
|
||||
<xy x="10" y="88" width="126" height="22"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/CommonBundle" key="checkbox.remember.password"/>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.diagnostic
|
||||
|
||||
import com.intellij.CommonBundle
|
||||
import com.intellij.credentialStore.hasOnlyUserName
|
||||
import com.intellij.errorreport.bean.ErrorBean
|
||||
import com.intellij.errorreport.error.InternalEAPException
|
||||
import com.intellij.errorreport.error.NoSuchEAPUserException
|
||||
@@ -97,7 +98,7 @@ private fun showYesNoDialog(parentComponent: Component, project: Project?, messa
|
||||
private fun submit(event: IdeaLoggingEvent, parentComponent: Component, callback: Consumer<SubmittedReportInfo>, errorBean: ErrorBean, description: String?): Boolean {
|
||||
var credentials = ErrorReportConfigurable.getCredentials()
|
||||
// ask password only if user name was specified
|
||||
if (credentials?.userName != null && credentials?.password.isNullOrEmpty()) {
|
||||
if (credentials.hasOnlyUserName()) {
|
||||
if (!showJetBrainsAccountDialog(parentComponent).showAndGet()) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene
|
||||
@Override
|
||||
public void hyperlinkUpdate(HyperlinkEvent e) {
|
||||
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
JetBrainsAccountDialogKt.showJetBrainsAccountDialog(getRootPane(), null).show();
|
||||
JetBrainsAccountDialogKt.showJetBrainsAccountDialog(getRootPane()).show();
|
||||
updateCredentialsPane(getSelectedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,97 +15,58 @@
|
||||
*/
|
||||
package com.intellij.diagnostic
|
||||
|
||||
import com.intellij.CommonBundle
|
||||
import com.intellij.credentialStore.CredentialAttributes
|
||||
import com.intellij.credentialStore.Credentials
|
||||
import com.intellij.ide.BrowserUtil
|
||||
import com.intellij.ide.passwordSafe.PasswordSafe
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.DialogBuilder
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
import com.intellij.openapi.ui.dialog
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.ui.ClickListener
|
||||
import com.intellij.openapi.ui.ex.MultiLineLabel
|
||||
import com.intellij.ui.components.JBCheckBox
|
||||
import com.intellij.ui.layout.*
|
||||
import com.intellij.ui.layout.CCFlags.*
|
||||
import com.intellij.ui.layout.LCFlags.*
|
||||
import com.intellij.util.net.HttpConfigurable
|
||||
import java.awt.Component
|
||||
import java.awt.Cursor
|
||||
import java.awt.event.MouseEvent
|
||||
import javax.swing.*
|
||||
import javax.swing.JPasswordField
|
||||
import javax.swing.JTextField
|
||||
|
||||
@JvmOverloads
|
||||
fun showJetBrainsAccountDialog(parent: Component, project: Project? = null): DialogBuilder {
|
||||
val credentials = ErrorReportConfigurable.getCredentials()
|
||||
val userField = JTextField(credentials?.userName)
|
||||
val passwordField = JPasswordField(credentials?.password?.toString())
|
||||
|
||||
// if no user name - never stored and so, defaults to remember. if user name set, but no password, so, previously was stored without password
|
||||
val rememberCheckBox = JBCheckBox(CommonBundle.message("checkbox.remember.password"), credentials?.userName == null || !credentials?.password.isNullOrEmpty())
|
||||
|
||||
val panel = panel(fillX) {
|
||||
label(DiagnosticBundle.message("diagnostic.error.report.description"))
|
||||
link(DiagnosticBundle.message("diagnostic.error.report.proxy.setup")) {
|
||||
MultiLineLabel(DiagnosticBundle.message("diagnostic.error.report.description"))(span, wrap)
|
||||
link(DiagnosticBundle.message("diagnostic.error.report.proxy.setup"), span, wrap) {
|
||||
HttpConfigurable.editConfigurable(this)
|
||||
}
|
||||
|
||||
label("Username:")
|
||||
userField(grow, wrap)
|
||||
|
||||
label("Password:")
|
||||
passwordField(grow, wrap)
|
||||
|
||||
rememberCheckBox(span, wrap)
|
||||
|
||||
link("Create or manage your JetBrains Account", "https://account.jetbrains.com", span, wrap)
|
||||
}
|
||||
|
||||
return dialog(
|
||||
title = DiagnosticBundle.message("error.report.title"),
|
||||
centerPanel = panel,
|
||||
preferedFocusComponent = if (credentials?.userName == null) userField else passwordField,
|
||||
project = project,
|
||||
parent = if (parent.isShowing) parent else null)
|
||||
}
|
||||
|
||||
class JetBrainsAccountDialog : DialogWrapper(null) {
|
||||
private val myItnLoginTextField: JTextField? = null
|
||||
private val myPasswordText: JPasswordField? = null
|
||||
private val myRememberCheckBox: JCheckBox? = null
|
||||
|
||||
var myMainPanel: JPanel? = null
|
||||
var mySendingSettingsLabel: JLabel? = null
|
||||
private val myCreateAccountLabel: JLabel? = null
|
||||
|
||||
override fun getDimensionServiceKey(): String? {
|
||||
return "#com.intellij.diagnostic.AbstractSendErrorDialog"
|
||||
}
|
||||
|
||||
override fun getPreferredFocusedComponent(): JComponent? {
|
||||
return myItnLoginTextField
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
contentPane.add(myMainPanel)
|
||||
|
||||
object : ClickListener() {
|
||||
override fun onClick(e: MouseEvent, clickCount: Int): Boolean {
|
||||
HttpConfigurable.editConfigurable(myMainPanel)
|
||||
return true
|
||||
}
|
||||
}.installOn(mySendingSettingsLabel!!)
|
||||
|
||||
mySendingSettingsLabel!!.cursor = Cursor(Cursor.HAND_CURSOR)
|
||||
|
||||
val credentials = ErrorReportConfigurable.getCredentials()
|
||||
val userName = credentials?.userName
|
||||
myItnLoginTextField!!.text = userName
|
||||
val password = credentials?.getPasswordAsString()
|
||||
myPasswordText!!.text = password
|
||||
// if no user name - never stored and so, defaults to remember. if user name set, but no password, so, previously was stored without password
|
||||
myRememberCheckBox!!.isSelected = StringUtil.isEmpty(userName) || !StringUtil.isEmpty(password)
|
||||
|
||||
object : ClickListener() {
|
||||
override fun onClick(e: MouseEvent, clickCount: Int): Boolean {
|
||||
BrowserUtil.browse("http://account.jetbrains.com")
|
||||
return true
|
||||
}
|
||||
}.installOn(myCreateAccountLabel!!)
|
||||
myCreateAccountLabel.cursor = Cursor(Cursor.HAND_CURSOR)
|
||||
|
||||
super.init()
|
||||
}
|
||||
|
||||
override fun doOKAction() {
|
||||
val userName = myItnLoginTextField!!.text
|
||||
if (!StringUtil.isEmpty(userName)) {
|
||||
PasswordSafe.getInstance().set(CredentialAttributes(ErrorReportConfigurable.SERVICE_NAME, userName),
|
||||
Credentials(userName, if (myRememberCheckBox!!.isSelected) myPasswordText!!.password else null))
|
||||
parent = if (parent.isShowing) parent else null) {
|
||||
val userName = userField.text
|
||||
if (!userName.isNullOrBlank()) {
|
||||
PasswordSafe.getInstance().set(CredentialAttributes(ErrorReportConfigurable.SERVICE_NAME, userName), Credentials(userName, if (rememberCheckBox.isSelected) passwordField.password else null))
|
||||
}
|
||||
super.doOKAction()
|
||||
}
|
||||
|
||||
override fun createCenterPanel(): JComponent? {
|
||||
return myMainPanel
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.diagnostic.JetBrainsAccountDialog">
|
||||
<grid id="92fcd" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="69" y="123" width="372" height="302"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="46178" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="2" left="4" bottom="0" right="4"/>
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="4f69e" class="javax.swing.JCheckBox" binding="myRememberCheckBox">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/DiagnosticBundle" key="diagnostic.error.report.login.remember.password.checkbox"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="2c912" class="javax.swing.JLabel" binding="myCreateAccountLabel">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="<html><a href="#">Create or manage your JetBrains Account</a></html>"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="fbdcc" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="b3002"/>
|
||||
<text resource-bundle="messages/DiagnosticBundle" key="diagnostic.error.report.login.password"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="87071" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="e3ed"/>
|
||||
<text resource-bundle="messages/DiagnosticBundle" key="diagnostic.error.report.login.name"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="e3ed" class="javax.swing.JTextField" binding="myItnLoginTextField">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="b3002" class="javax.swing.JPasswordField" binding="myPasswordText">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="115f0" class="javax.swing.JLabel" binding="mySendingSettingsLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/DiagnosticBundle" key="diagnostic.error.report.proxy.setup"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="cd549" class="javax.swing.JLabel" binding="eee">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/DiagnosticBundle" key="diagnostic.error.report.description"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package com.intellij.ui.layout
|
||||
|
||||
// http://www.migcalendar.com/miglayout/mavensite/docs/cheatsheet.pdf
|
||||
|
||||
enum class CFlags {
|
||||
}
|
||||
|
||||
enum class LCFlags {
|
||||
/**
|
||||
* Puts the layout in a flow-only mode.
|
||||
* All components in the flow direction will be put in the same cell and will thus not be aligned with component in other rows/columns.
|
||||
* For normal horizontal flow this is the same as to say that all component will be put in the first and only column.
|
||||
*/
|
||||
noGrid,
|
||||
|
||||
/**
|
||||
* Puts the layout in vertical flow mode. This means that the next cell is normally below and the next component will be put there instead of to the right. Default is horizontal flow.
|
||||
*/
|
||||
flowY,
|
||||
|
||||
/**
|
||||
* Claims all available space in the container for the columns and/or rows.
|
||||
* At least one component need to have a "grow" constraint for it to fill the container.
|
||||
* The space will be divided equal, though honoring "growPriority".
|
||||
* If no columns/rows has "grow" set the grow weight of the components in the rows/columns will migrate to that row/column.
|
||||
*/
|
||||
fill, fillX, fillY,
|
||||
|
||||
lcWrap,
|
||||
|
||||
debug
|
||||
}
|
||||
|
||||
enum class CCFlags {
|
||||
/**
|
||||
* Wrap to the next line/column **after** the component that this constraint belongs to.
|
||||
*/
|
||||
wrap,
|
||||
|
||||
/**
|
||||
* Span cells in both x and y.
|
||||
*/
|
||||
span, spanX, spanY,
|
||||
|
||||
split,
|
||||
|
||||
grow, push, pushY, pushX, right, skip
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.ui.layout
|
||||
|
||||
import com.intellij.BundleBase
|
||||
import com.intellij.ide.BrowserUtil
|
||||
import com.intellij.ui.IdeBorderFactory
|
||||
import com.intellij.ui.components.JBLabel
|
||||
import com.intellij.ui.components.labels.LinkLabel
|
||||
@@ -29,44 +30,6 @@ import java.awt.LayoutManager
|
||||
import java.awt.event.ActionEvent
|
||||
import javax.swing.*
|
||||
|
||||
// http://www.migcalendar.com/miglayout/mavensite/docs/cheatsheet.pdf
|
||||
|
||||
enum class LCFlags {
|
||||
/**
|
||||
* Puts the layout in a flow-only mode.
|
||||
* All components in the flow direction will be put in the same cell and will thus not be aligned with component in other rows/columns.
|
||||
* For normal horizontal flow this is the same as to say that all component will be put in the first and only column.
|
||||
*/
|
||||
noGrid,
|
||||
|
||||
/**
|
||||
* Puts the layout in vertical flow mode. This means that the next cell is normally below and the next component will be put there instead of to the right. Default is horizontal flow.
|
||||
*/
|
||||
flowY,
|
||||
|
||||
/**
|
||||
* Claims all available space in the container for the columns and/or rows.
|
||||
* At least one component need to have a "grow" constraint for it to fill the container.
|
||||
* The space will be divided equal, though honoring "growPriority".
|
||||
* If no columns/rows has "grow" set the grow weight of the components in the rows/columns will migrate to that row/column.
|
||||
*/
|
||||
fill, fillX, fillY
|
||||
}
|
||||
|
||||
enum class CCFlags {
|
||||
/**
|
||||
* Wrap to the next line/column **after** the component that this constraint belongs to.
|
||||
*/
|
||||
wrap,
|
||||
|
||||
/**
|
||||
* Span cells in both x and y.
|
||||
*/
|
||||
span,
|
||||
|
||||
grow, push, pushY, pushX, right, skip
|
||||
}
|
||||
|
||||
inline fun panel(vararg layoutConstraints: LCFlags, init: Panel.() -> Unit): JPanel {
|
||||
val panel = Panel(MigLayout(c().apply(layoutConstraints)))
|
||||
panel.init()
|
||||
@@ -87,7 +50,15 @@ fun JPanel.titledPanel(title: String, wrappedComponent: Component, vararg constr
|
||||
add(panel, *constraints)
|
||||
}
|
||||
|
||||
fun JPanel.label(text: String, vararg constraints: CCFlags, componentStyle: UIUtil.ComponentStyle? = null, fontColor: UIUtil.FontColor? = null, bold: Boolean = false, gapLeft: Int = 0, gapBottom: Int = 0, gapAfter: Int = 0) {
|
||||
fun JPanel.label(text: String,
|
||||
vararg constraints: CCFlags,
|
||||
componentStyle: UIUtil.ComponentStyle? = null,
|
||||
fontColor: UIUtil.FontColor? = null,
|
||||
bold: Boolean = false,
|
||||
gapLeft: Int = 0,
|
||||
gapBottom: Int = 0,
|
||||
gapAfter: Int = 0,
|
||||
split: Int = -1) {
|
||||
val finalText = BundleBase.replaceMnemonicAmpersand(text)
|
||||
val label = if (componentStyle == null && fontColor == null) {
|
||||
JLabel(finalText)
|
||||
@@ -117,11 +88,18 @@ fun JPanel.label(text: String, vararg constraints: CCFlags, componentStyle: UIUt
|
||||
if (gapBottom != 0) {
|
||||
cc().vertical.gapAfter = gapToBoundSize(gapBottom, false)
|
||||
}
|
||||
if (split != -1) {
|
||||
cc().split = split
|
||||
}
|
||||
add(label, _cc)
|
||||
}
|
||||
|
||||
fun JPanel.link(text: String, action: () -> Unit) {
|
||||
add(LinkLabel.create(text, action))
|
||||
fun JPanel.link(text: String, vararg constraints: CCFlags, action: () -> Unit) {
|
||||
add(LinkLabel.create(text, action), constraints.create())
|
||||
}
|
||||
|
||||
fun JPanel.link(text: String, url: String, vararg constraints: CCFlags) {
|
||||
add(LinkLabel.create(text, { BrowserUtil.browse(url) }), constraints.create())
|
||||
}
|
||||
|
||||
private fun gapToBoundSize(value: Int, isHorizontal: Boolean): BoundSize {
|
||||
@@ -197,6 +175,10 @@ fun LC.apply(flags: Array<out LCFlags>): LC {
|
||||
LCFlags.fill -> fill()
|
||||
LCFlags.fillX -> isFillX = true
|
||||
LCFlags.fillY -> isFillY = true
|
||||
|
||||
LCFlags.lcWrap -> wrapAfter = 0
|
||||
|
||||
LCFlags.debug -> debug()
|
||||
}
|
||||
}
|
||||
return this
|
||||
@@ -214,6 +196,11 @@ fun CC.apply(flags: Array<out CCFlags>): CC {
|
||||
CCFlags.pushY -> pushY()
|
||||
|
||||
CCFlags.span -> span()
|
||||
CCFlags.spanX -> spanX()
|
||||
CCFlags.spanY -> spanY()
|
||||
|
||||
CCFlags.split -> split()
|
||||
|
||||
CCFlags.skip -> skip()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,10 @@ diagnostic.out.of.memory.currentValue.unknown=Unknown
|
||||
diagnostic.out.of.memory.continue=Continue
|
||||
diagnostic.out.of.memory.dump=Memory Dump
|
||||
diagnostic.error.report.send=&Send
|
||||
diagnostic.error.report.description=<html>If you would like to get notified when the exceptions you submit are fixed,<br>please fill in your JetBrains Account login and password.</html>
|
||||
diagnostic.error.report.proxy.setup=<html><a href="#">Set up HTTP proxy settings</a></html>
|
||||
diagnostic.error.report.login.remember.password.checkbox=&Remember password
|
||||
diagnostic.error.report.description=If you would like to get notified when the exceptions you submit are fixed,\nplease fill in your JetBrains Account login and password.
|
||||
diagnostic.error.report.proxy.setup=Set up HTTP proxy settings
|
||||
diagnostic.error.report.login.name=&Username:
|
||||
diagnostic.error.report.login.password=&Password:
|
||||
diagnostic.error.report.prompt=Error description (optional):
|
||||
diagnostic.error.report.use.jetbrains.account.button.label=&Use JetBrains Account...
|
||||
diagnostic.error.report.submit.error.anonymously=<html>Submit report anonymously or use <a>JetBrains Account...</a></html>
|
||||
diagnostic.error.report.submit.report.as=<html>Submit report as <a>{0}</a></html>
|
||||
diagnostic.error.report.additional.info.label=&Additional information (steps to reproduce, what were you doing when the exception occurred):
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.ui.dialog
|
||||
import com.intellij.ui.DocumentAdapter
|
||||
import com.intellij.ui.layout.*
|
||||
import com.intellij.ui.layout.CCFlags.*
|
||||
import com.intellij.ui.layout.CCFlags.wrap
|
||||
import com.intellij.ui.layout.LCFlags.*
|
||||
import com.intellij.ui.noteComponent
|
||||
import com.intellij.util.PathUtilRt
|
||||
@@ -68,7 +69,6 @@ fun showAuthenticationForm(credentials: Credentials?, uri: String, host: String?
|
||||
|
||||
val authenticationForm = dialog(
|
||||
title = "Settings Repository",
|
||||
resizable = false,
|
||||
centerPanel = centerPanel,
|
||||
preferedFocusComponent = if (userField.parent == null) passwordField else userField,
|
||||
okActionEnabled = false)
|
||||
|
||||
Reference in New Issue
Block a user