update copyright
[fedora-idea.git] / plugins / cvs / cvs-plugin / src / com / intellij / cvsSupport2 / cvsoperations / cvsImport / ImportDetails.java
blob60de9d5e744941ba37b33302a4df5892980b144f
1 /*
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.cvsoperations.cvsImport;
18 import com.intellij.cvsSupport2.connections.CvsEnvironment;
19 import com.intellij.cvsSupport2.connections.CvsRootProvider;
20 import com.intellij.cvsSupport2.cvsoperations.common.CvsOperation;
21 import com.intellij.cvsSupport2.ui.experts.importToCvs.FileExtension;
22 import com.intellij.openapi.util.io.FileUtil;
23 import org.jetbrains.annotations.NotNull;
24 import org.netbeans.lib.cvsclient.command.importcmd.ImportCommand;
25 import org.netbeans.lib.cvsclient.util.IIgnoreFileFilter;
27 import java.io.File;
28 import java.util.Collection;
30 /**
31 * author: lesya
34 public class ImportDetails {
35 private final File myBaseImportDirectory;
36 private final String myVendor;
37 private final String myReleaseTag;
38 private final String myLogMessage;
39 private final String myModuleName;
40 private final CvsEnvironment myEnvironment;
41 private final Collection<FileExtension> myWrappers;
42 private final IIgnoreFileFilter myIgnoreFileFilter;
44 public ImportDetails(@NotNull File sourceLocation, String vendor, String releaseTag, String logMessage,
45 String moduleName, CvsEnvironment env,
46 Collection<FileExtension> wrappers,
47 IIgnoreFileFilter ignoreFileFilter) {
48 myBaseImportDirectory = sourceLocation;
49 myVendor = vendor;
50 myReleaseTag = releaseTag;
51 myLogMessage = logMessage;
52 myModuleName = moduleName;
53 myEnvironment = env;
54 myWrappers = wrappers;
55 myIgnoreFileFilter = ignoreFileFilter;
58 public void prepareCommand(ImportCommand result) {
59 result.setVendorTag(myVendor);
60 result.setReleaseTag(myReleaseTag);
61 result.setModule(getModulePath());
62 result.setLogMessage(myLogMessage);
64 for (final FileExtension fileExtension : myWrappers) {
65 result.addWrapper("*." + fileExtension.getExtension(), fileExtension.getKeywordSubstitution().getSubstitution());
69 public int getTotalFilesInSourceDirectory() {
70 return CvsOperation.calculateFilesIn(myBaseImportDirectory);
73 private String getModulePath() {
74 String relativePath = FileUtil.getRelativePath(myBaseImportDirectory.getAbsoluteFile().getParentFile(),
75 myBaseImportDirectory.getAbsoluteFile());
76 return replaceBaseImportDirectoryNameToModuleNameIn(relativePath);
79 public String getModuleName() {
80 return myModuleName;
83 private String replaceBaseImportDirectoryNameToModuleNameIn(String relativePath) {
84 return myModuleName + relativePath.substring(myBaseImportDirectory.getName().length());
87 public File getWorkingDirectory() {
88 return myBaseImportDirectory;
91 public CvsRootProvider getCvsRoot() {
92 return CvsRootProvider.createOn(myBaseImportDirectory, myEnvironment);
95 public IIgnoreFileFilter getIgnoreFileFilter() {
96 return myIgnoreFileFilter;