IDEA-86085 MultipleFileMergeDialog: resolve initial focus problem, set the default button.

* Make "Merge" button default.
* Make the table to be preferred component to solve the issue with focus being left in the editor.
This commit is contained in:
Kirill Likhodedov
2012-05-15 16:00:09 +04:00
parent 4fa7cf7819
commit 40a8b3f9a9
2 changed files with 17 additions and 6 deletions
@@ -37,7 +37,7 @@
<text resource-bundle="messages/VcsBundle" key="multiple.file.merge.accept.theirs"/>
</properties>
</component>
<component id="39393" class="javax.swing.JButton" binding="myMergeButton" default-binding="true">
<component id="39393" class="javax.swing.JButton" binding="myMergeButton" custom-create="true" default-binding="true">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
@@ -151,11 +151,6 @@ public class MultipleFileMergeDialog extends DialogWrapper {
acceptRevision(false);
}
});
myMergeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
showMergeDialog();
}
});
myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(final ListSelectionEvent e) {
updateButtonState();
@@ -327,6 +322,22 @@ public class MultipleFileMergeDialog extends DialogWrapper {
MergeVersion.MergeDocumentVersion.reportProjectFileChangeIfNeeded(myProject, file);
}
private void createUIComponents() {
Action mergeAction = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
showMergeDialog();
}
};
mergeAction.putValue(DEFAULT_ACTION, Boolean.TRUE);
myMergeButton = createJButtonForAction(mergeAction);
}
@Override
public JComponent getPreferredFocusedComponent() {
return myTable;
}
private static String decodeContent(final VirtualFile file, final byte[] content) {
return StringUtil.convertLineSeparators(CharsetToolkit.bytesToString(content, file.getCharset()));
}