update copyright
[fedora-idea.git] / plugins / cvs / cvs-plugin / src / com / intellij / cvsSupport2 / actions / GetFileFromRepositoryAction.java
blobc9c40298bd188b451218867f62c538a2dfb0a7e1
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.actions;
18 import com.intellij.cvsSupport2.actions.actionVisibility.CvsActionVisibility;
19 import com.intellij.cvsSupport2.actions.cvsContext.CvsContext;
20 import com.intellij.cvsSupport2.actions.cvsContext.CvsLightweightFile;
21 import com.intellij.cvsSupport2.actions.update.UpdateSettingsOnCvsConfiguration;
22 import com.intellij.cvsSupport2.config.CvsConfiguration;
23 import com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler;
24 import com.intellij.cvsSupport2.cvshandlers.CvsHandler;
25 import com.intellij.openapi.project.Project;
26 import com.intellij.openapi.vcs.actions.VcsContext;
27 import com.intellij.openapi.vcs.FilePath;
28 import com.intellij.openapi.vcs.update.UpdatedFiles;
29 import com.intellij.CvsBundle;
31 public class GetFileFromRepositoryAction extends ActionOnSelectedElement{
32 public GetFileFromRepositoryAction() {
33 super(true);
34 CvsActionVisibility visibility = getVisibility();
35 visibility.canBePerformedOnSeveralFiles();
36 visibility.canBePerformedOnCvsLightweightFile();
37 visibility.shouldNotBePerformedOnDirectory();
40 protected String getTitle(VcsContext context) {
41 return CvsBundle.message("action.name.get.file.from.repository");
44 protected CvsHandler getCvsHandler(CvsContext context) {
45 CvsLightweightFile[] cvsLightweightFiles = context.getSelectedLightweightFiles();
46 Project project = context.getProject();
47 if (cvsLightweightFiles != null) {
48 boolean makeNewFilesReadOnly = project != null && CvsConfiguration.getInstance(project).MAKE_NEW_FILES_READONLY;
49 return CommandCvsHandler.createGetFileFromRepositoryHandler(cvsLightweightFiles, makeNewFilesReadOnly);
51 final FilePath[] filePaths = context.getSelectedFilePaths();
52 if (filePaths != null) {
53 CvsConfiguration cvsConfiguration = CvsConfiguration.getInstance(project);
54 // do not use -j's
55 final UpdateSettingsOnCvsConfiguration updateSettings = new UpdateSettingsOnCvsConfiguration(cvsConfiguration,
56 cvsConfiguration.CLEAN_COPY,
57 cvsConfiguration.RESET_STICKY);
58 return CommandCvsHandler.createUpdateHandler(filePaths, updateSettings, project, UpdatedFiles.create());
60 return CvsHandler.NULL;