<commit_before>/*
 * Copyright 2000-2009 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.actions;

import com.intellij.cvsSupport2.CvsUtil;
import com.intellij.cvsSupport2.actions.actionVisibility.CvsActionVisibility;
import com.intellij.cvsSupport2.actions.cvsContext.CvsContext;
import com.intellij.cvsSupport2.application.CvsEntriesManager;
import com.intellij.cvsSupport2.cvsstatuses.CvsStatusProvider;
import com.intellij.cvsSupport2.util.CvsVfsUtil;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.actions.VcsContext;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ContainerUtil;

import javax.swing.*;
import java.io.File;
import java.util.ArrayList;

/**
 * author: lesya
 */

public abstract class ActionOnSelectedElement extends AbstractAction {

  protected static File[] getAllSelectedFiles(VcsContext context) {
    VirtualFile[] selectedFiles = context.getSelectedFiles();
    File[] selectedIOFiles = context.getSelectedIOFiles();
    ArrayList result = new ArrayList();
    if (selectedFiles != null) {
      for (int i = 0; i < selectedFiles.length; i++) {
        result.add(CvsVfsUtil.getFileFor(selectedFiles[i]));
      }
    }
    ;
    if (selectedIOFiles != null) ContainerUtil.addAll(result, selectedIOFiles);
    return (File[])result.toArray(new File[result.size()]);
  }

  protected static CvsActionVisibility.Condition FILES_HAVE_PARENT_UNDER_CVS =
    new CvsActionVisibility.Condition() {
      public boolean isPerformedOn(CvsContext context) {
        return CvsUtil.filesHaveParentUnderCvs(getAllSelectedFiles(context));
      }
    };

  protected static CvsActionVisibility.Condition FILES_ARENT_UNDER_CVS =
    new CvsActionVisibility.Condition() {
      public boolean isPerformedOn(CvsContext context) {
        return CvsUtil.filesArentUnderCvs(getAllSelectedFiles(context));
      }
    };

  public static CvsActionVisibility.Condition FILES_ARE_UNDER_CVS =
    new CvsActionVisibility.Condition() {
      public boolean isPerformedOn(CvsContext context) {
        return CvsUtil.filesAreUnderCvs(getAllSelectedFiles(context));
      }
    };

  public static CvsActionVisibility.Condition FILES_EXIST_IN_CVS =
    new CvsActionVisibility.Condition() {
      public boolean isPerformedOn(CvsContext context) {
        return CvsUtil.filesExistInCvs(getAllSelectedFiles(context));
      }
    };

  public static CvsActionVisibility.Condition FILES_ARE_NOT_DELETED =
    new CvsActionVisibility.Condition() {
      public boolean isPerformedOn(CvsContext context) {
        return CvsUtil.filesAreNotDeleted(getAllSelectedFiles(context));
      }
    };
<commit_msg>make final<commit_after>/*
 * 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.actions;

import com.intellij.cvsSupport2.CvsUtil;
import com.intellij.cvsSupport2.actions.actionVisibility.CvsActionVisibility;
import com.intellij.cvsSupport2.actions.cvsContext.CvsContext;
import com.intellij.cvsSupport2.application.CvsEntriesManager;
import com.intellij.cvsSupport2.cvsstatuses.CvsStatusProvider;
import com.intellij.cvsSupport2.util.CvsVfsUtil;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.actions.VcsContext;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ContainerUtil;

import javax.swing.*;
import java.io.File;
import java.util.ArrayList;

/**
 * author: lesya
 */

public abstract class ActionOnSelectedElement extends AbstractAction {

  protected static File[] getAllSelectedFiles(VcsContext context) {
    VirtualFile[] selectedFiles = context.getSelectedFiles();
    File[] selectedIOFiles = context.getSelectedIOFiles();
    ArrayList result = new ArrayList();
    if (selectedFiles != null) {
      for (int i = 0; i < selectedFiles.length; i++) {
        result.add(CvsVfsUtil.getFileFor(selectedFiles[i]));
      }
    }
    ;
    if (selectedIOFiles != null) ContainerUtil.addAll(result, selectedIOFiles);
    return (File[])result.toArray(new File[result.size()]);
  }

  protected static CvsActionVisibility.Condition FILES_HAVE_PARENT_UNDER_CVS =
    new CvsActionVisibility.Condition() {
      public boolean isPerformedOn(CvsContext context) {
        return CvsUtil.filesHaveParentUnderCvs(getAllSelectedFiles(context));
      }
    };

  protected final static CvsActionVisibility.Condition FILES_ARENT_UNDER_CVS =
    new CvsActionVisibility.Condition() {
      public boolean isPerformedOn(CvsContext context) {
        return CvsUtil.filesArentUnderCvs(getAllSelectedFiles(context));
      }
    };

  public static final CvsActionVisibility.Condition FILES_ARE_UNDER_CVS =
    new CvsActionVisibility.Condition() {
      public boolean isPerformedOn(CvsContext context) {
        return CvsUtil.filesAreUnderCvs(getAllSelectedFiles(context));
      }
    };

  public static final CvsActionVisibility.Condition FILES_EXIST_IN_CVS =
    new CvsActionVisibility.Condition() {
      public boolean isPerformedOn(CvsContext context) {
        return CvsUtil.filesExistInCvs(getAllSelectedFiles(context));
      }
    };

  public static final CvsActionVisibility.Condition FILES_ARE_NOT_DELETED =
    new CvsActionVisibility.Condition() {
      public boolean isPerformedOn(CvsContext context) {
        return CvsUtil.filesAreNotDeleted(getAllSelectedFiles(context));
      }
    };

{'fraction_non_alphanumeric': 0.08780916142250841, 'fraction_numerical': 0.005853944094833894, 'mean_word_length': 4.538087520259319, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4828144', 'n_tokens_mistral': 2034, 'n_tokens_neox': 2001, 'n_words': 443}