git4idea: IDEA-22561: renamed OK buttons to appropriate names in dialogs
[fedora-idea.git] / plugins / git4idea / src / git4idea / rebase / GitRebaseUnstructuredEditor.java
blobec2129bf534ecf28c62c2a86a09f1a1b7751408c
1 package git4idea.rebase;
3 import com.intellij.openapi.project.Project;
4 import com.intellij.openapi.ui.DialogWrapper;
5 import com.intellij.openapi.util.io.FileUtil;
6 import com.intellij.openapi.vfs.VirtualFile;
7 import git4idea.config.GitConfigUtil;
8 import git4idea.i18n.GitBundle;
10 import javax.swing.*;
11 import java.io.File;
12 import java.io.IOException;
14 /**
15 * The dialog used for the unstructured information from git rebase.
17 public class GitRebaseUnstructuredEditor extends DialogWrapper {
18 /**
19 * The text with information from the GIT
21 private JTextArea myTextArea;
22 /**
23 * The root panel of the dialog
25 private JPanel myPanel;
26 /**
27 * The label that contains the git root path
29 private JLabel myGitRootLabel;
30 /**
31 * The file encoding
33 private final String encoding;
34 /**
35 * The file being edited
37 private final File myFile;
39 /**
40 * The constructor
42 * @param project the context project
43 * @param root the Git root
44 * @param path the path to edit
45 * @throws IOException if there is an IO problem
47 protected GitRebaseUnstructuredEditor(Project project, VirtualFile root, String path) throws IOException {
48 super(project, true);
49 setTitle(GitBundle.message("rebase.unstructured.editor.title"));
50 setOKButtonText(GitBundle.message("rebase.unstructured.editor.button"));
51 myGitRootLabel.setText(root.getPresentableUrl());
52 encoding = GitConfigUtil.getCommitEncoding(project, root);
53 myFile = new File(path);
54 myTextArea.setText(new String(FileUtil.loadFileText(myFile, encoding)));
55 init();
58 /**
59 * Save content to the file
61 * @throws IOException if there is an IO problem
63 public void save() throws IOException {
64 FileUtil.writeToFile(myFile, myTextArea.getText().getBytes(encoding));
67 /**
68 * {@inheritDoc}
70 protected JComponent createCenterPanel() {
71 return myPanel;
74 /**
75 * {@inheritDoc}
77 @Override
78 protected String getDimensionServiceKey() {
79 return getClass().getName();