[vcs]: use last typed description for new changelist instead of empty one

This commit is contained in:
Nadya Zabrodina
2016-06-24 15:14:09 +03:00
parent 193e9df1b2
commit 619176bba7
2 changed files with 23 additions and 3 deletions
@@ -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<String> myOkEnabledListener;
private final Project myProject;
private String myLastTypedDescription;
public ChangeListChooserPanel(final Project project, @NotNull final NullableConsumer<String> 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() {
@@ -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;