<commit_before>package de.tudresden.slr.questionnaire;

import java.util.LinkedList;
import java.util.List;
import java.util.function.Supplier;

import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbenchPartSite;

import de.tudresden.slr.model.bibtex.Document;
import de.tudresden.slr.questionnaire.model.Question;
import de.tudresden.slr.questionnaire.util.BibtexExplorer;

public class UnansweredDocumentsView {
	private Label incompleteDocumentsLabel;
	private ListViewer incompleteDocumentsList;

	private Supplier<Questionnaire> questionnaireSupplier;
	private Supplier<IProject> projectSupplier;

	private List<Document> incompleteDocuments = new LinkedList<>();

	public UnansweredDocumentsView(Composite parent, IWorkbenchPartSite site,
			Supplier<Questionnaire> questionnaireSupplier, Supplier<IProject> projectSupplier) {
		this.questionnaireSupplier = questionnaireSupplier;
		this.projectSupplier = projectSupplier;

		incompleteDocumentsLabel = new Label(parent, 0);
		incompleteDocumentsLabel.setText("Answers missing for following documents:");
		incompleteDocumentsLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1));

		incompleteDocumentsList = new ListViewer(parent, SWT.V_SCROLL);
		GridData gd = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1);
		gd.heightHint = (int) (((org.eclipse.swt.widgets.List) incompleteDocumentsList.getControl()).getItemHeight()
				* 4);
		gd.widthHint = 300;
		incompleteDocumentsList.getControl()
				.setLayoutData(gd);
		incompleteDocumentsList.setSorter(new ViewerSorter());
		incompleteDocumentsList.setContentProvider(ArrayContentProvider.getInstance());
		incompleteDocumentsList.setLabelProvider(new LabelProvider() {
			@Override
			public String getText(Object element) {
				return ((Document) element).getKey();
			}
		});
		site.setSelectionProvider(incompleteDocumentsList);
	}

	public List<Document> findDocuments() {
		List<Document> badDocuments = new LinkedList<>();
		IProject project = projectSupplier.get();
		Questionnaire questionnaire = questionnaireSupplier.get();
		if (questionnaire != null && project != null) {
			BibtexExplorer be = new BibtexExplorer(project);
			List<Question<?>> questions = questionnaire.getQuestions();
			List<Document> documents = be.getDocuments();
			for (Document doc : documents) {
				for (Question<?> question : questions) {
					if (!question.hasAnswerFor(doc.getKey())) {
						badDocuments.add(doc);
						break;
					}
				}
			}
		}
		if (!badDocuments.equals(incompleteDocuments)) {
			incompleteDocumentsList.setInput(badDocuments);
			incompleteDocuments = badDocuments;
		}
		return badDocuments;
	}

}<commit_msg>change text of UnansweredDocumentsView depending on how many documents are missing<commit_after>package de.tudresden.slr.questionnaire;

import java.util.LinkedList;
import java.util.List;
import java.util.function.Supplier;

import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbenchPartSite;

import de.tudresden.slr.model.bibtex.Document;
import de.tudresden.slr.questionnaire.model.Question;
import de.tudresden.slr.questionnaire.util.BibtexExplorer;

public class UnansweredDocumentsView {
    private Label incompleteDocumentsLabel;
    private ListViewer incompleteDocumentsList;

    private Supplier<Questionnaire> questionnaireSupplier;
    private Supplier<IProject> projectSupplier;

    private List<Document> incompleteDocuments = new LinkedList<>();

    private static String TEMPLATE_ANSWERS_MISSING = "Questionnaire is missing answers for %d documents.";
    private static String TEMPLATE_ANSWERS_COMPLETE = "Questionnaire is fully answered.";

    public UnansweredDocumentsView(Composite parent, IWorkbenchPartSite site,
            Supplier<Questionnaire> questionnaireSupplier, Supplier<IProject> projectSupplier) {
        this.questionnaireSupplier = questionnaireSupplier;
        this.projectSupplier = projectSupplier;

        incompleteDocumentsLabel = new Label(parent, 0);
        incompleteDocumentsLabel.setText(TEMPLATE_ANSWERS_COMPLETE);
        incompleteDocumentsLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1));

        incompleteDocumentsList = new ListViewer(parent, SWT.V_SCROLL);
        GridData gd = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1);
        gd.heightHint = (int) (((org.eclipse.swt.widgets.List) incompleteDocumentsList.getControl()).getItemHeight()
                * 4);
        gd.widthHint = 300;
        incompleteDocumentsList.getControl().setLayoutData(gd);
        incompleteDocumentsList.getControl().setVisible(false);
        incompleteDocumentsList.setSorter(new ViewerSorter());
        incompleteDocumentsList.setContentProvider(ArrayContentProvider.getInstance());
        incompleteDocumentsList.setLabelProvider(new LabelProvider() {
            @Override
            public String getText(Object element) {
                return ((Document) element).getKey();
            }
        });
        site.setSelectionProvider(incompleteDocumentsList);
    }

    public List<Document> findDocuments() {
        List<Document> badDocuments = new LinkedList<>();
        IProject project = projectSupplier.get();
        Questionnaire questionnaire = questionnaireSupplier.get();
        if (questionnaire != null && project != null) {
            BibtexExplorer be = new BibtexExplorer(project);
            List<Question<?>> questions = questionnaire.getQuestions();
            List<Document> documents = be.getDocuments();
            for (Document doc : documents) {
                for (Question<?> question : questions) {
                    if (!question.hasAnswerFor(doc.getKey())) {
                        badDocuments.add(doc);
                        break;
                    }
                }
            }
        }
        if (!badDocuments.equals(incompleteDocuments)) {
            incompleteDocumentsList.setInput(badDocuments);
            incompleteDocuments = badDocuments;

            String newDisplayText = TEMPLATE_ANSWERS_COMPLETE;
            if (!incompleteDocuments.isEmpty())
                newDisplayText = String.format(TEMPLATE_ANSWERS_MISSING, incompleteDocuments.size());
            incompleteDocumentsLabel.setText(newDisplayText);
            incompleteDocumentsList.getControl().setVisible(!incompleteDocuments.isEmpty());
        }
        return badDocuments;
    }

}
{'fraction_non_alphanumeric': 0.09871184542145058, 'fraction_numerical': 0.002520302436292355, 'mean_word_length': 4.120430107526881, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7326460', 'n_tokens_mistral': 2194, 'n_tokens_neox': 1960, 'n_words': 367}