package org.atoum.intellij.plugin.atoum.actions;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.jetbrains.php.lang.psi.PhpFile;
import com.jetbrains.php.lang.psi.elements.PhpClass;
import org.atoum.intellij.plugin.atoum.Utils;
import org.atoum.intellij.plugin.atoum.model.RunnerConfiguration;
import org.atoum.intellij.plugin.atoum.run.Runner;
import org.jetbrains.annotations.Nullable;

public class RunAll extends AnAction {

    @Override
    public void update(AnActionEvent event) {
        event.getPresentation().setEnabled(true);
        event.getPresentation().setVisible(true);
        event.getPresentation().setText("atoum - run all tests");
    }

    protected void saveFiles(PhpClass currentTestClass, Project project) {
        Document documentTestClass = FileDocumentManager.getInstance().getDocument(currentTestClass.getContainingFile().getVirtualFile());
        Document documentTestedClass = FileDocumentManager.getInstance().getDocument(Utils.locateTestedClass(project, currentTestClass).getContainingFile().getVirtualFile());
        FileDocumentManager.getInstance().saveDocument(documentTestClass);
        FileDocumentManager.getInstance().saveDocument(documentTestedClass);

    }

    public void actionPerformed(final AnActionEvent e) {
        Project project = e.getProject();
        RunnerConfiguration runConfiguration = new RunnerConfiguration();
        Runner runner = new Runner(project);
        runner.run(runConfiguration);
    }
}

@@ -182,374 +182,23 @@
 api.
-actionSystem.PlatformDataKeys;%0Aimport com.intellij.openapi.editor.Document;%0Aimport com.intellij.openapi.fileEditor.FileDocumentManager;%0Aimport com.intellij.openapi.project.Project;%0Aimport com.intellij.openapi.vfs.VirtualFile;%0Aimport com.jetbrains.php.lang.psi.PhpFile;%0Aimport com.jetbrains.php.lang.psi.elements.PhpClass;%0Aimport org.atoum.intellij.plugin.atoum.Utils
+project.Project
 ;%0Aim
@@ -315,51 +315,8 @@
 ner;
-%0Aimport org.jetbrains.annotations.Nullable;
 %0A%0Apu
@@ -505,32 +505,32 @@
 tVisible(true);%0A
+
         event.ge
@@ -590,557 +590,8 @@
  %7D%0A%0A
-    protected void saveFiles(PhpClass currentTestClass, Project project) %7B%0A        Document documentTestClass = FileDocumentManager.getInstance().getDocument(currentTestClass.getContainingFile().getVirtualFile());%0A        Document documentTestedClass = FileDocumentManager.getInstance().getDocument(Utils.locateTestedClass(project, currentTestClass).getContainingFile().getVirtualFile());%0A        FileDocumentManager.getInstance().saveDocument(documentTestClass);%0A        FileDocumentManager.getInstance().saveDocument(documentTestedClass);%0A%0A    %7D%0A%0A
     

Remove unused method