2 * Copyright 2000-2009 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 com
.intellij
.cvsSupport2
.checkout
;
18 import com
.intellij
.cvsSupport2
.CvsVcs2
;
19 import com
.intellij
.cvsSupport2
.actions
.AbstractAction
;
20 import com
.intellij
.cvsSupport2
.actions
.cvsContext
.CvsContext
;
21 import com
.intellij
.cvsSupport2
.config
.CvsApplicationLevelConfiguration
;
22 import com
.intellij
.cvsSupport2
.cvsBrowser
.CvsElement
;
23 import com
.intellij
.cvsSupport2
.cvshandlers
.CommandCvsHandler
;
24 import com
.intellij
.cvsSupport2
.cvshandlers
.CvsHandler
;
25 import com
.intellij
.cvsSupport2
.ui
.CvsTabbedWindow
;
26 import com
.intellij
.cvsSupport2
.ui
.experts
.checkout
.CheckoutWizard
;
27 import com
.intellij
.openapi
.actionSystem
.AnActionEvent
;
28 import com
.intellij
.openapi
.actionSystem
.Presentation
;
29 import com
.intellij
.openapi
.vcs
.ProjectLevelVcsManager
;
30 import com
.intellij
.openapi
.vcs
.VcsConfiguration
;
31 import com
.intellij
.openapi
.vcs
.actions
.VcsContext
;
32 import com
.intellij
.openapi
.project
.Project
;
36 public class CheckoutAction
extends AbstractAction
{
37 private CvsElement
[] mySelectedElements
;
38 private File myCheckoutDirectory
;
39 private boolean myUseAlternativeCheckoutPath
;
41 public CheckoutAction() {
45 public CheckoutAction(final CvsElement
[] selectedElements
, final File checkoutDirectory
, final boolean useAlternativeCheckoutPath
) {
48 mySelectedElements
= selectedElements
;
49 myCheckoutDirectory
= checkoutDirectory
;
50 myUseAlternativeCheckoutPath
= useAlternativeCheckoutPath
;
53 protected String
getTitle(VcsContext context
) {
54 return com
.intellij
.CvsBundle
.message("operation.name.check.out.project");
57 protected CvsHandler
getCvsHandler(CvsContext context
) {
58 final Project project
= context
.getProject();
59 CheckoutWizard checkoutWizard
= new CheckoutWizard(project
);
60 checkoutWizard
.show();
61 if (!checkoutWizard
.isOK()) return CvsHandler
.NULL
;
62 myUseAlternativeCheckoutPath
= checkoutWizard
.useAlternativeCheckoutLocation();
63 myCheckoutDirectory
= checkoutWizard
.getCheckoutDirectory();
65 mySelectedElements
= checkoutWizard
.getSelectedElements();
66 return CommandCvsHandler
.createCheckoutHandler(
67 checkoutWizard
.getSelectedConfiguration(),
68 collectCheckoutPaths(),
70 myUseAlternativeCheckoutPath
,
71 CvsApplicationLevelConfiguration
.getInstance().MAKE_CHECKED_OUT_FILES_READONLY
,
72 project
== null ?
null : VcsConfiguration
.getInstance(project
).getCheckoutOption());
75 private String
[] collectCheckoutPaths() {
76 String
[] checkoutPaths
= new String
[mySelectedElements
.length
];
77 for (int i
= 0; i
< mySelectedElements
.length
; i
++) {
78 CvsElement selectedElement
= mySelectedElements
[i
];
79 checkoutPaths
[i
] = selectedElement
.getCheckoutPath();
84 protected void onActionPerformed(final CvsContext context
,
85 CvsTabbedWindow tabbedWindow
,
88 super.onActionPerformed(context
, tabbedWindow
, successfully
, handler
);
90 CvsVcs2
.getInstance(context
.getProject()).getCheckoutProvider().refreshAfterCheckout(
91 ProjectLevelVcsManager
.getInstance(context
.getProject()).getCompositeCheckoutListener(), mySelectedElements
,
92 myCheckoutDirectory
, myUseAlternativeCheckoutPath
);
95 public void update(AnActionEvent e
) {
96 Presentation presentation
= e
.getPresentation();
97 presentation
.setVisible(true);
98 presentation
.setEnabled(true);