diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangeListChooserPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangeListChooserPanel.java index 7d4a4c21d50e..1c93f351669a 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangeListChooserPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangeListChooserPanel.java @@ -37,6 +37,8 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -49,6 +51,7 @@ public class ChangeListChooserPanel extends JPanel { private final NewEditChangelistPanel myListPanel; private final NullableConsumer myOkEnabledListener; private final Project myProject; + private String myLastTypedDescription; public ChangeListChooserPanel(final Project project, @NotNull final NullableConsumer okEnabledListener) { super(new BorderLayout()); @@ -107,6 +110,20 @@ public class ChangeListChooserPanel extends JPanel { myOkEnabledListener.consume(errorMessage); } + @Override + public void init(LocalChangeList initial) { + super.init(initial); + myDescriptionTextArea.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + super.focusLost(e); + if (getExistingChangelist() == null) { + myLastTypedDescription = myListPanel.getDescription(); + } + } + }); + } + @Override protected void nameChangedImpl(Project project, LocalChangeList initial) { nameChanged(StringUtil.isEmptyOrSpaces(getChangeListName()) ? "Cannot create new changelist with empty name." : null); @@ -175,7 +192,10 @@ public class ChangeListChooserPanel extends JPanel { private void updateDescription() { LocalChangeList list = getExistingChangelist(); - myListPanel.setDescription(list != null ? list.getComment() : ""); + String newText = list != null ? list.getComment() : myLastTypedDescription; + if (!StringUtil.equals(myListPanel.getDescription(), newText)) { + myListPanel.setDescription(newText); + } } private LocalChangeList getExistingChangelist() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/NewEditChangelistPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/NewEditChangelistPanel.java index c3f502c3e0c9..98260d3f6a08 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/NewEditChangelistPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/NewEditChangelistPanel.java @@ -37,8 +37,8 @@ import java.awt.*; import java.util.Set; public abstract class NewEditChangelistPanel extends JPanel { - private final EditorTextField myNameTextField; - private final EditorTextField myDescriptionTextArea; + protected final EditorTextField myNameTextField; + protected final EditorTextField myDescriptionTextArea; private final JPanel myAdditionalControlsPanel; private final JCheckBox myMakeActiveCheckBox;