diff --git a/platform/credential-store/src/com/intellij/credentialStore/EnterPasswordComponent.java b/platform/credential-store/src/com/intellij/credentialStore/EnterPasswordComponent.java index 785707d0e2f7..5fb91e63e7ac 100644 --- a/platform/credential-store/src/com/intellij/credentialStore/EnterPasswordComponent.java +++ b/platform/credential-store/src/com/intellij/credentialStore/EnterPasswordComponent.java @@ -20,6 +20,7 @@ import com.intellij.icons.AllIcons; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.ui.ValidationInfo; import com.intellij.openapi.util.SystemInfo; +import com.intellij.ui.ComponentsKt; import com.intellij.ui.layout.LayoutKt; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -96,6 +97,6 @@ class EnterPasswordComponent { note = "The passwords will be stored in IDE configuration files with weak protection
(" + subNote + ")."; } - myPromptLabel = LayoutKt.htmlComponent("Master password is required to convert saved passwords.
" + note, UIUtil.getLabelFont(UIUtil.FontSize.SMALL)); + myPromptLabel = ComponentsKt.htmlComponent("Master password is required to convert saved passwords.
" + note, UIUtil.getLabelFont(UIUtil.FontSize.SMALL)); } } diff --git a/platform/platform-api/src/com/intellij/openapi/diagnostic/ErrorReportSubmitter.java b/platform/platform-api/src/com/intellij/openapi/diagnostic/ErrorReportSubmitter.java index c68e45189a95..c9c4fbca6a21 100644 --- a/platform/platform-api/src/com/intellij/openapi/diagnostic/ErrorReportSubmitter.java +++ b/platform/platform-api/src/com/intellij/openapi/diagnostic/ErrorReportSubmitter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * 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. @@ -48,6 +48,7 @@ public abstract class ErrorReportSubmitter implements PluginAware { /** * @return an action text to be used in Error Reporter user interface, e.g. "Report to JetBrains". */ + @NotNull public abstract String getReportActionText(); /** diff --git a/platform/platform-api/src/com/intellij/openapi/ui/dialogBuilder.kt b/platform/platform-api/src/com/intellij/openapi/ui/dialogBuilder.kt index 04f44c205ac6..3c771baaeb96 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/dialogBuilder.kt +++ b/platform/platform-api/src/com/intellij/openapi/ui/dialogBuilder.kt @@ -15,10 +15,18 @@ */ package com.intellij.openapi.ui +import com.intellij.openapi.project.Project +import java.awt.Component import javax.swing.JComponent -fun dialog(title: String, centerPanel: JComponent, resizable: Boolean = true, preferedFocusComponent: JComponent? = null, okActionEnabled: Boolean = true): DialogBuilder { - val builder = DialogBuilder() +fun dialog(title: String, + centerPanel: JComponent, + resizable: Boolean = true, + preferedFocusComponent: JComponent? = null, + okActionEnabled: Boolean = true, + project: Project? = null, + parent: Component? = null): DialogBuilder { + val builder = if (parent == null) DialogBuilder(project) else DialogBuilder(parent) builder .title(title) .centerPanel(centerPanel) diff --git a/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java b/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java index a6960b82d303..8e85f6de64e9 100644 --- a/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java +++ b/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * 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. @@ -25,6 +25,7 @@ import com.intellij.ui.UI; import com.intellij.util.ui.JBRectangle; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.accessibility.ScreenReader; +import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -34,7 +35,6 @@ import javax.accessibility.AccessibleRole; import javax.swing.*; import java.awt.*; import java.awt.event.*; -import java.util.HashSet; import java.util.Set; /** @@ -46,7 +46,7 @@ public class LinkLabel extends JLabel { private LinkListener myLinkListener; private T myLinkData; - private static final Set ourVisitedLinks = new HashSet<>(); + private static final Set ourVisitedLinks = new THashSet<>(); private boolean myIsLinkActive; @@ -69,6 +69,16 @@ public class LinkLabel extends JLabel { this(text, icon, aListener, null, null); } + @NotNull + public static LinkLabel create(@Nullable String text, @Nullable Runnable action) { + return new LinkLabel<>(text, null, action == null ? null : new LinkListener() { + @Override + public void linkSelected(LinkLabel source, Object linkData) { + action.run(); + } + }, null, null); + } + public LinkLabel(String text, @Nullable Icon icon, @Nullable LinkListener aListener, @Nullable T aLinkData) { this(text, icon, aListener, aLinkData, null); } @@ -142,8 +152,12 @@ public class LinkLabel extends JLabel { try { myClickIsBeingProcessed = true; - if (myLinkListener != null) myLinkListener.linkSelected(this, myLinkData); - ourVisitedLinks.add(myVisitedLinksKey); + if (myLinkListener != null) { + myLinkListener.linkSelected(this, myLinkData); + } + if (myVisitedLinksKey != null) { + ourVisitedLinks.add(myVisitedLinksKey); + } repaint(); } finally { @@ -222,7 +236,6 @@ public class LinkLabel extends JLabel { } protected void onSetActive(boolean active) { - } private final JBRectangle iconR = new JBRectangle(); diff --git a/platform/platform-api/src/com/intellij/ui/components/labels/SwingActionLink.java b/platform/platform-api/src/com/intellij/ui/components/labels/SwingActionLink.java index 993cb3d8da7b..90c67984d184 100644 --- a/platform/platform-api/src/com/intellij/ui/components/labels/SwingActionLink.java +++ b/platform/platform-api/src/com/intellij/ui/components/labels/SwingActionLink.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * 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. @@ -17,13 +17,11 @@ package com.intellij.ui.components.labels; import org.jetbrains.annotations.NotNull; -import javax.swing.Action; -import javax.swing.Icon; +import javax.swing.*; import java.awt.event.ActionEvent; +import java.beans.EventHandler; import java.beans.PropertyChangeListener; -import static java.beans.EventHandler.create; - /** * @author Sergey.Malenkov */ @@ -35,7 +33,7 @@ public class SwingActionLink extends LinkLabel implements LinkListener { get() = ServiceManager.getService(ErrorReportConfigurable::class.java) @JvmStatic - val credentials: Credentials? - get() = PasswordSafe.getInstance().get(CredentialAttributes(SERVICE_NAME)) + fun getCredentials() = PasswordSafe.getInstance().get(CredentialAttributes(SERVICE_NAME)) } } diff --git a/platform/platform-impl/src/com/intellij/diagnostic/ITNReporter.kt b/platform/platform-impl/src/com/intellij/diagnostic/ITNReporter.kt index f92a81299bdb..efd64ed10afc 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/ITNReporter.kt +++ b/platform/platform-impl/src/com/intellij/diagnostic/ITNReporter.kt @@ -98,7 +98,7 @@ private fun submit(event: IdeaLoggingEvent, parentComponent: Component, callback var credentials = ErrorReportConfigurable.getCredentials() // ask password only if user name was specified if (credentials?.userName != null && credentials?.password.isNullOrEmpty()) { - if (!JetBrainsAccountDialog(parentComponent).showAndGet()) { + if (!showJetBrainsAccountDialog(parentComponent).showAndGet()) { return false } @@ -145,16 +145,12 @@ private fun submit(event: IdeaLoggingEvent, parentComponent: Component, callback }) { e -> Logger.getInstance(ITNReporter::class.java).info("reporting failed: " + e) ApplicationManager.getApplication().invokeLater { - val msg: String - if (e is NoSuchEAPUserException) { - msg = DiagnosticBundle.message("error.report.authentication.failed") - } - else if (e is InternalEAPException) { - msg = DiagnosticBundle.message("error.report.posting.failed", e.message) - } - else { - msg = DiagnosticBundle.message("error.report.sending.failure") + val msg = when (e) { + is NoSuchEAPUserException -> DiagnosticBundle.message("error.report.authentication.failed") + is InternalEAPException -> DiagnosticBundle.message("error.report.posting.failed", e.message) + else -> DiagnosticBundle.message("error.report.sending.failure") } + if (e is UpdateAvailableException) { val message = DiagnosticBundle.message("error.report.new.eap.build.message", e.message) showMessageDialog(parentComponent, project, message, CommonBundle.getWarningTitle(), Messages.getWarningIcon()) @@ -164,14 +160,7 @@ private fun submit(event: IdeaLoggingEvent, parentComponent: Component, callback callback.consume(SubmittedReportInfo(SubmittedReportInfo.SubmissionStatus.FAILED)) } else if (e is NoSuchEAPUserException) { - val dialog: JetBrainsAccountDialog - if (parentComponent.isShowing) { - dialog = JetBrainsAccountDialog(parentComponent) - } - else { - dialog = JetBrainsAccountDialog(project!!) - } - dialog.show() + showJetBrainsAccountDialog(parentComponent, project).show() } ApplicationManager.getApplication().invokeLater { submit(event, parentComponent, callback, errorBean, description) } } diff --git a/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java b/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java index 739db6876806..e1c4f4394eeb 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java +++ b/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * 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. @@ -347,7 +347,7 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - new JetBrainsAccountDialog(getRootPane()).show(); + JetBrainsAccountDialogKt.showJetBrainsAccountDialog(getRootPane(), null).show(); updateCredentialsPane(getSelectedMessage()); } } diff --git a/platform/platform-impl/src/com/intellij/diagnostic/JetBrainsAccountDialog.kt b/platform/platform-impl/src/com/intellij/diagnostic/JetBrainsAccountDialog.kt index b0736eff2453..656feb7f187a 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/JetBrainsAccountDialog.kt +++ b/platform/platform-impl/src/com/intellij/diagnostic/JetBrainsAccountDialog.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * 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. @@ -19,31 +19,40 @@ import com.intellij.credentialStore.CredentialAttributes import com.intellij.credentialStore.Credentials import com.intellij.ide.BrowserUtil import com.intellij.ide.passwordSafe.PasswordSafe +import com.intellij.layout.* +import com.intellij.layout.LCFlags.* 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.util.net.HttpConfigurable - -import javax.swing.* -import java.awt.* +import java.awt.Component +import java.awt.Cursor import java.awt.event.MouseEvent +import javax.swing.* -class JetBrainsAccountDialog : DialogWrapper { +fun showJetBrainsAccountDialog(parent: Component, project: Project? = null): DialogBuilder { + val panel = panel(fillX) { + label(DiagnosticBundle.message("diagnostic.error.report.description")) + link(DiagnosticBundle.message("diagnostic.error.report.proxy.setup")) { + HttpConfigurable.editConfigurable(this) + } + } + + return dialog( + title = DiagnosticBundle.message("error.report.title"), + centerPanel = panel, + 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 - @Throws(HeadlessException::class) - constructor(parent: Component) : super(parent, false) { - init() - } - - @Throws(HeadlessException::class) - constructor(project: Project) : super(project, false) { - init() - } - var myMainPanel: JPanel? = null var mySendingSettingsLabel: JLabel? = null private val myCreateAccountLabel: JLabel? = null @@ -57,7 +66,6 @@ class JetBrainsAccountDialog : DialogWrapper { } override fun init() { - title = ReportMessages.ERROR_REPORT contentPane.add(myMainPanel) object : ClickListener() { diff --git a/platform/platform-impl/src/com/intellij/diagnostic/JetBrainsAccountForm.form b/platform/platform-impl/src/com/intellij/diagnostic/JetBrainsAccountForm.form index e6fc473ec7d1..8a9f985fc7ba 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/JetBrainsAccountForm.form +++ b/platform/platform-impl/src/com/intellij/diagnostic/JetBrainsAccountForm.form @@ -79,7 +79,7 @@ - + diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/ConfigurableEditor.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/ConfigurableEditor.java index cb09c138c633..cd3991d65b4a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/ConfigurableEditor.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/ConfigurableEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * 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. @@ -291,13 +291,8 @@ class ConfigurableEditor extends AbstractEditor implements AnActionListener, AWT panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); content.add(BorderLayout.CENTER, panel); panel.add(Box.createVerticalStrut(10)); - for (final Configurable current : composite.getConfigurables()) { - LinkLabel label = new LinkLabel(current.getDisplayName(), null) { - @Override - public void doClick() { - openLink(current); - } - }; + for (Configurable current : composite.getConfigurables()) { + LinkLabel label = LinkLabel.create(current.getDisplayName(), () -> openLink(current)); label.setBorder(BorderFactory.createEmptyBorder(1, 17, 3, 1)); panel.add(label); } diff --git a/platform/platform-impl/src/com/intellij/ui/components.kt b/platform/platform-impl/src/com/intellij/ui/components.kt new file mode 100644 index 000000000000..e8c22b59a29c --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ui/components.kt @@ -0,0 +1,65 @@ +/* + * 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 + +import com.intellij.openapi.vcs.changes.issueLinks.LinkMouseListenerBase +import com.intellij.util.ui.SwingHelper +import com.intellij.util.ui.UIUtil +import java.awt.Color +import java.awt.Font +import java.util.regex.Pattern +import javax.swing.JEditorPane + +private val HREF_PATTERN = Pattern.compile("([^<]*)") +private val LINK_TEXT_ATTRIBUTES = SimpleTextAttributes(SimpleTextAttributes.STYLE_SMALLER, JBColor.blue) +private val SMALL_TEXT_ATTRIBUTES = SimpleTextAttributes(SimpleTextAttributes.STYLE_SMALLER, null) + +fun noteComponent(note: String): SimpleColoredComponent { + val noteComponent = SimpleColoredComponent() + + val matcher = HREF_PATTERN.matcher(note) + var prev = 0 + if (matcher.find()) { + do { + if (matcher.start() != prev) { + noteComponent.append(note.substring(prev, matcher.start()), SMALL_TEXT_ATTRIBUTES) + } + noteComponent.append(matcher.group(2), LINK_TEXT_ATTRIBUTES, SimpleColoredComponent.BrowserLauncherTag(matcher.group(1))) + prev = matcher.end() + } + while (matcher.find()) + + LinkMouseListenerBase.installSingleTagOn(noteComponent) + } + + if (prev < note.length) { + noteComponent.append(note.substring(prev), SMALL_TEXT_ATTRIBUTES) + } + + return noteComponent +} + +@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()) { + pane.text = "${UIUtil.getCssFontDeclaration(font, UIUtil.getLabelForeground(), null, null)}$text" + } + pane.border = null + pane.disabledTextColor = UIUtil.getLabelDisabledForeground() + pane.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE) + return pane +} \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/ui/layout/layout.kt b/platform/platform-impl/src/com/intellij/ui/layout/layout.kt index 20b6482c7935..bfa3e75d2599 100644 --- a/platform/platform-impl/src/com/intellij/ui/layout/layout.kt +++ b/platform/platform-impl/src/com/intellij/ui/layout/layout.kt @@ -16,18 +16,17 @@ package com.intellij.ui.layout import com.intellij.BundleBase -import com.intellij.openapi.vcs.changes.issueLinks.LinkMouseListenerBase -import com.intellij.ui.* +import com.intellij.ui.IdeBorderFactory import com.intellij.ui.components.JBLabel -import com.intellij.util.ui.SwingHelper +import com.intellij.ui.components.labels.LinkLabel import com.intellij.util.ui.UIUtil -import com.intellij.util.ui.UIUtil.getCssFontDeclaration -import com.intellij.util.ui.UIUtil.getLabelForeground import net.miginfocom.layout.* import net.miginfocom.swing.MigLayout -import java.awt.* +import java.awt.BorderLayout +import java.awt.Component +import java.awt.Font +import java.awt.LayoutManager import java.awt.event.ActionEvent -import java.util.regex.Pattern import javax.swing.* // http://www.migcalendar.com/miglayout/mavensite/docs/cheatsheet.pdf @@ -121,6 +120,10 @@ fun JPanel.label(text: String, vararg constraints: CCFlags, componentStyle: UIUt add(label, _cc) } +fun JPanel.link(text: String, action: () -> Unit) { + add(LinkLabel.create(text, action)) +} + private fun gapToBoundSize(value: Int, isHorizontal: Boolean): BoundSize { val unitValue = UnitValue(value.toFloat(), "", isHorizontal, UnitValue.STATIC, null) return BoundSize(unitValue, unitValue, null, false, null) @@ -215,45 +218,4 @@ fun CC.apply(flags: Array): CC { } } return this -} - -private val HREF_PATTERN = Pattern.compile("([^<]*)") -private val LINK_TEXT_ATTRIBUTES = SimpleTextAttributes(SimpleTextAttributes.STYLE_SMALLER, JBColor.blue) -private val SMALL_TEXT_ATTRIBUTES = SimpleTextAttributes(SimpleTextAttributes.STYLE_SMALLER, null) - -fun noteComponent(note: String): SimpleColoredComponent { - val noteComponent = SimpleColoredComponent() - - val matcher = HREF_PATTERN.matcher(note) - var prev = 0 - if (matcher.find()) { - do { - if (matcher.start() != prev) { - noteComponent.append(note.substring(prev, matcher.start()), SMALL_TEXT_ATTRIBUTES) - } - noteComponent.append(matcher.group(2), LINK_TEXT_ATTRIBUTES, SimpleColoredComponent.BrowserLauncherTag(matcher.group(1))) - prev = matcher.end() - } - while (matcher.find()) - - LinkMouseListenerBase.installSingleTagOn(noteComponent) - } - - if (prev < note.length) { - noteComponent.append(note.substring(prev), SMALL_TEXT_ATTRIBUTES) - } - - return noteComponent -} - -@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()) { - pane.text = "${getCssFontDeclaration(font, getLabelForeground(), null, null)}$text" - } - pane.border = null - pane.disabledTextColor = UIUtil.getLabelDisabledForeground() - pane.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE) - return pane } \ No newline at end of file diff --git a/platform/platform-resources-en/src/messages/DiagnosticBundle.properties b/platform/platform-resources-en/src/messages/DiagnosticBundle.properties index 7d96421f0b62..6989fc38ec71 100644 --- a/platform/platform-resources-en/src/messages/DiagnosticBundle.properties +++ b/platform/platform-resources-en/src/messages/DiagnosticBundle.properties @@ -11,7 +11,6 @@ diagnostic.out.of.memory.dump=Memory Dump diagnostic.error.report.send=&Send diagnostic.error.report.description=If you would like to get notified when the exceptions you submit are fixed,
please fill in your JetBrains Account login and password. diagnostic.error.report.proxy.setup=Set up HTTP proxy settings -diagnostic.error.report.login.group=JetBrains Account diagnostic.error.report.login.remember.password.checkbox=&Remember password diagnostic.error.report.login.name=&Username: diagnostic.error.report.login.password=&Password: diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsUpdateInfoScopeFilterConfigurable.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsUpdateInfoScopeFilterConfigurable.java index 5c389cab22ed..244e66f2b006 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsUpdateInfoScopeFilterConfigurable.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsUpdateInfoScopeFilterConfigurable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * 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. @@ -28,7 +28,6 @@ import com.intellij.openapi.vcs.VcsConfiguration; import com.intellij.psi.search.scope.packageSet.NamedScope; import com.intellij.psi.search.scope.packageSet.NamedScopesHolder; import com.intellij.ui.components.labels.LinkLabel; -import com.intellij.ui.components.labels.LinkListener; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; @@ -91,13 +90,10 @@ class VcsUpdateInfoScopeFilterConfigurable implements Configurable, NamedScopesH panel.add(myCheckbox); panel.add(myComboBox); panel.add(Box.createHorizontalStrut(UIUtil.DEFAULT_HGAP)); - panel.add(new LinkLabel("Manage Scopes", null, new LinkListener() { - @Override - public void linkSelected(LinkLabel aSource, Object aLinkData) { - Settings settings = Settings.KEY.getData(DataManager.getInstance().getDataContext(panel)); - if (settings != null) { - settings.select(settings.find(ScopeChooserConfigurable.PROJECT_SCOPES)); - } + panel.add(LinkLabel.create("Manage Scopes", () -> { + Settings settings = Settings.KEY.getData(DataManager.getInstance().getDataContext(panel)); + if (settings != null) { + settings.select(settings.find(ScopeChooserConfigurable.PROJECT_SCOPES)); } })); return panel; diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java index 7167e97f0ede..f6847631809c 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * 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. @@ -24,7 +24,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.components.labels.LinkLabel; -import com.intellij.ui.components.labels.LinkListener; import com.intellij.util.ui.UIUtil; import com.intellij.xdebugger.impl.actions.XDebuggerActions; @@ -33,13 +32,6 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -/** - * Created with IntelliJ IDEA. - * User: zajac - * Date: 4/4/12 - * Time: 5:51 PM - * To change this template use File | Settings | File Templates. - */ public class BreakpointEditor { public JPanel getMainPanel() { return myMainPanel; @@ -49,12 +41,9 @@ public class BreakpointEditor { AnAction action = ActionManager.getInstance().getAction(XDebuggerActions.VIEW_BREAKPOINTS); String shortcutText = action != null ? KeymapUtil.getFirstKeyboardShortcutText(action) : null; String text = shortcutText != null ? "More (" + shortcutText + ")" : "More"; - myShowMoreOptionsLink = new LinkLabel(text, null, new LinkListener() { - @Override - public void linkSelected(LinkLabel aSource, Object aLinkData) { - if (myDelegate != null) { - myDelegate.more(); - } + myShowMoreOptionsLink = LinkLabel.create(text, () -> { + if (myDelegate != null) { + myDelegate.more(); } }); } diff --git a/plugins/git4idea/src/git4idea/crlf/GitCrlfDialog.java b/plugins/git4idea/src/git4idea/crlf/GitCrlfDialog.java index 35e5a48d8840..89e7121c7416 100644 --- a/plugins/git4idea/src/git4idea/crlf/GitCrlfDialog.java +++ b/plugins/git4idea/src/git4idea/crlf/GitCrlfDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * 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. @@ -21,7 +21,6 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.labels.LinkLabel; -import com.intellij.ui.components.labels.LinkListener; import com.intellij.util.ui.GridBag; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -76,12 +75,7 @@ public class GitCrlfDialog extends DialogWrapper { "Fix and Commit: git config --global core.autocrlf " + RECOMMENDED_VALUE + " will be called,
" + "Commit as Is: the config value won't be set.", UIUtil.ComponentStyle.SMALL); - JLabel readMore = new LinkLabel("Read more", null, new LinkListener() { - @Override - public void linkSelected(LinkLabel aSource, Object aLinkData) { - BrowserUtil.browse("https://help.github.com/articles/dealing-with-line-endings"); - } - }); + JLabel readMore = LinkLabel.create("Read more", () -> BrowserUtil.browse("https://help.github.com/articles/dealing-with-line-endings")); JLabel icon = new JLabel(UIUtil.getWarningIcon(), SwingConstants.LEFT); myDontWarn = new JBCheckBox("Don't warn again"); diff --git a/plugins/settings-repository/src/authForm.kt b/plugins/settings-repository/src/authForm.kt index e9378b61a5fe..66031432d686 100644 --- a/plugins/settings-repository/src/authForm.kt +++ b/plugins/settings-repository/src/authForm.kt @@ -24,6 +24,7 @@ import com.intellij.ui.DocumentAdapter import com.intellij.ui.layout.* import com.intellij.ui.layout.CCFlags.* import com.intellij.ui.layout.LCFlags.* +import com.intellij.ui.noteComponent import com.intellij.util.PathUtilRt import com.intellij.util.nullize import com.intellij.util.trimMiddle