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.
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
;
26 import java
.util
.List
;
29 * The git stash dialog.
31 public class GitStashDialog
extends DialogWrapper
{
35 private JComboBox myGitRootComboBox
;
37 * The root panel for the form
39 private JPanel myPanel
;
41 * The current branch label
43 private JLabel myCurrentBranch
;
45 * The text field that contains stash message
47 private JTextField myMessageTextField
;
49 * The keep index checkbox
51 private JCheckBox myKeepIndexCheckBox
;
55 private final Project myProject
;
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
) {
67 setTitle(GitBundle
.getString("stash.title"));
68 setOKButtonText(GitBundle
.getString("stash.button"));
69 GitUIUtil
.setupRootChooser(project
, roots
, defaultRoot
, myGitRootComboBox
, myCurrentBranch
);
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
);
90 * @return the selected git root
92 public VirtualFile
getGitRoot() {
93 return (VirtualFile
)myGitRootComboBox
.getSelectedItem();
99 protected JComponent
createCenterPanel() {
107 protected String
getDimensionServiceKey() {
108 return getClass().getName();
115 protected String
getHelpId() {
116 return "reference.VersionControl.Git.Stash";