git4idea: IDEA-22561: renamed OK buttons to appropriate names in dialogs
[fedora-idea.git] / plugins / git4idea / src / git4idea / ui / GitStashDialog.java
blobdd2145cb17ae38ae0f6447299a61db84b24c295d
1 /*
2 * Copyright 2000-2008 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package git4idea.ui;
18 import com.intellij.openapi.project.Project;
19 import com.intellij.openapi.ui.DialogWrapper;
20 import com.intellij.openapi.vfs.VirtualFile;
21 import git4idea.commands.GitHandler;
22 import git4idea.commands.GitLineHandler;
23 import git4idea.i18n.GitBundle;
25 import javax.swing.*;
26 import java.util.List;
28 /**
29 * The git stash dialog.
31 public class GitStashDialog extends DialogWrapper {
32 /**
33 * Git root selector
35 private JComboBox myGitRootComboBox;
36 /**
37 * The root panel for the form
39 private JPanel myPanel;
40 /**
41 * The current branch label
43 private JLabel myCurrentBranch;
44 /**
45 * The text field that contains stash message
47 private JTextField myMessageTextField;
48 /**
49 * The keep index checkbox
51 private JCheckBox myKeepIndexCheckBox;
52 /**
53 * The project
55 private final Project myProject;
57 /**
58 * A constructor
60 * @param project the project
61 * @param roots the list of the roots
62 * @param defaultRoot the default root to select
64 public GitStashDialog(final Project project, final List<VirtualFile> roots, final VirtualFile defaultRoot) {
65 super(project, true);
66 myProject = project;
67 setTitle(GitBundle.getString("stash.title"));
68 setOKButtonText(GitBundle.getString("stash.button"));
69 GitUIUtil.setupRootChooser(project, roots, defaultRoot, myGitRootComboBox, myCurrentBranch);
70 init();
73 /**
74 * @return the handler
76 public GitLineHandler handler() {
77 GitLineHandler handler = new GitLineHandler(myProject, getGitRoot(), GitHandler.STASH);
78 handler.addParameters("save");
79 if (myKeepIndexCheckBox.isSelected()) {
80 handler.addParameters("--keep-index");
82 final String msg = myMessageTextField.getText().trim();
83 if (msg.length() != 0) {
84 handler.addParameters(msg);
86 return handler;
89 /**
90 * @return the selected git root
92 public VirtualFile getGitRoot() {
93 return (VirtualFile)myGitRootComboBox.getSelectedItem();
96 /**
97 * {@inheritDoc}
99 protected JComponent createCenterPanel() {
100 return myPanel;
104 * {@inheritDoc}
106 @Override
107 protected String getDimensionServiceKey() {
108 return getClass().getName();
112 * {@inheritDoc}
114 @Override
115 protected String getHelpId() {
116 return "reference.VersionControl.Git.Stash";