summaryrefslogtreecommitdiff
path: root/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/checkout/CheckoutWizard.java
blob: d807e052f5e46aa156d104e1940dc9e6cfeccfa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 * Copyright 2000-2014 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.cvsSupport2.ui.experts.checkout;

import com.intellij.CvsBundle;
import com.intellij.cvsSupport2.config.CvsApplicationLevelConfiguration;
import com.intellij.cvsSupport2.config.CvsRootConfiguration;
import com.intellij.cvsSupport2.cvsBrowser.CvsElement;
import com.intellij.cvsSupport2.ui.experts.CvsWizard;
import com.intellij.cvsSupport2.ui.experts.SelectCVSConfigurationStep;
import com.intellij.cvsSupport2.ui.experts.SelectCvsElementStep;
import com.intellij.cvsSupport2.ui.experts.SelectLocationStep;
import com.intellij.openapi.project.Project;
import org.netbeans.lib.cvsclient.command.KeywordSubstitution;

import javax.swing.tree.TreeSelectionModel;
import java.io.File;

/**
 * author: lesya
 */
public class CheckoutWizard extends CvsWizard {

  private final SelectCVSConfigurationStep mySelectCVSConfigurationStep;
  private final SelectCvsElementStep mySelectCvsElementStep;
  private final SelectLocationStep mySelectLocationStep;

  private final ChooseCheckoutMode myChooseModeStep;

  public CheckoutWizard(final Project project) {
    super(CvsBundle.message("dialog.tittle.check.out.from.cvs.repository"), project);
    mySelectCVSConfigurationStep = new SelectCVSConfigurationStep(project, this);
    mySelectCvsElementStep = new SelectCvsElementStep(CvsBundle.message("dialog.title.select.cvs.element.to.check.out"),
                                                      this, project, mySelectCVSConfigurationStep, false,
                                                      TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION, true, true);

    mySelectLocationStep = new MySelectLocationStep(project);
    myChooseModeStep = new ChooseCheckoutMode(project, this);

    addStep(mySelectCVSConfigurationStep);
    addStep(mySelectCvsElementStep);
    addStep(mySelectLocationStep);
    addStep(myChooseModeStep);

    init();
  }

  protected void doOKAction() {
    CvsApplicationLevelConfiguration config = CvsApplicationLevelConfiguration.getInstance();

    config.MAKE_CHECKED_OUT_FILES_READONLY = myChooseModeStep.getMakeNewFilesReadOnly();
    config.CHECKOUT_PRUNE_EMPTY_DIRECTORIES = myChooseModeStep.getPruneEmptyDirectories();
    final KeywordSubstitution keywordSubstitution = myChooseModeStep.getKeywordSubstitution();
    if (keywordSubstitution == null) {
      config.CHECKOUT_KEYWORD_SUBSTITUTION = null;
    } else {
      config.CHECKOUT_KEYWORD_SUBSTITUTION = keywordSubstitution.toString();
    }

    super.doOKAction();
  }

  public CvsElement[] getSelectedElements() {
    return mySelectCvsElementStep.getSelectedCvsElements();
  }

  public CvsRootConfiguration getSelectedConfiguration() {
    return mySelectCVSConfigurationStep.getSelectedConfiguration();
  }

  public CvsRootConfiguration getConfigurationWithDateOrRevisionSettings() {
    final CvsRootConfiguration configuration = getSelectedConfiguration().clone();
    myChooseModeStep.saveDateOrRevisionSettings(configuration);
    return configuration;
  }

  public boolean useAlternativeCheckoutLocation() {
    return myChooseModeStep.useAlternativeCheckoutLocation();
  }

  public File getCheckoutDirectory() {
    return myChooseModeStep.getCheckoutDirectory();
  }

  public File getSelectedLocation() {
    return mySelectLocationStep.getSelectedFile();
  }

  private class MySelectLocationStep extends SelectLocationStep {
    public MySelectLocationStep(Project project) {
      super(CvsBundle.message("dialog.title.select.check.out.location"), CheckoutWizard.this, project, false);
      init();
    }
  }

  protected String getHelpID() {
    return "cvs.checkOutPrj";
  }
}