<commit_before>package osr.adapter;

import de.fau.osr.bl.RequirementsTraceabilityMatrixByImpact;
import de.fau.osr.gui.View.TraceabilityMatrixByImpactViewHandler;
import de.fau.osr.gui.util.SpiceTraceabilityProgressBar;

import javax.swing.*;
import java.awt.event.WindowEvent;

/**
 * @author Gayathery
 * This class uses the backed Traceability Matrix functionality, the calls are adapted in this class.
 */
public class PluginSPICETraceabilityMatrixAdaptor {
    
    public void loadTraceabilityMatrixByImpact(){
        PluginSPICETrackerAdaptor.getInstance(); 
        class TraceabilityMatrixViewerThread implements Runnable {

            @Override
            public void run() {
                showTraceabilityMatrixByImpactProgressBar();
                TraceabilityMatrixByImpactViewHandler trMatrixByImpact = new TraceabilityMatrixByImpactViewHandler();
                trMatrixByImpact.setRequirementsTraceabilityMatrix(PluginSPICETrackerAdaptor.getTracker().generateRequirementsTraceabilityByImpact());
                trMatrixByImpact.initTable();
                trMatrixByImpact.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                trMatrixByImpact.setVisible(true);
                
            }

        }
        Thread tr = new Thread(new TraceabilityMatrixViewerThread());
        tr.start(); 
       
    }
    
    public void showTraceabilityMatrixByImpactProgressBar(){

        final SpiceTraceabilityProgressBar progressBar = new SpiceTraceabilityProgressBar();
        progressBar.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        progressBar.setProgressBarContent("Generating Traceability Matrix (by Impact)");
        progressBar.setVisible(true);

        class showTraceabilityMatrixByImpactProgressBarThread implements Runnable{

            @Override
            public void run() {
                Boolean completion = false;
                while(RequirementsTraceabilityMatrixByImpact.processProgress<=100){
                    progressBar.setProgressBarValue(RequirementsTraceabilityMatrixByImpact.processProgress);
                    try {
                        Thread.sleep(100);

                        if(completion)
                            break;
                        if(RequirementsTraceabilityMatrixByImpact.processProgress == 100){
                            completion = true;
                        }
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }
                progressBar.dispatchEvent(new WindowEvent(progressBar, WindowEvent.WINDOW_CLOSING));

            }

        }
        Thread tr = new Thread(new showTraceabilityMatrixByImpactProgressBarThread());
        tr.start();
    }

}<commit_msg>Issue-88 Enhancement: Reuse functionality for Traceability Matrix progressbar.<commit_after>package osr.adapter;

import de.fau.osr.bl.RequirementsTraceabilityMatrixByImpact;
import de.fau.osr.gui.View.TracabilityMatrix_View;

/**
 * @author Gayathery This class uses the backed Traceability Matrix
 *         functionality, the calls are adapted in this class.
 */
public class PluginSPICETraceabilityMatrixAdaptor {

    TracabilityMatrix_View matrixView = new TracabilityMatrix_View();

    public void loadTraceabilityMatrixByImpact() {
        PluginSPICETrackerAdaptor.getInstance();
        class TraceabilityMatrixViewerThread implements Runnable {

            @Override
            public void run() {
                matrixView.showTraceabilityMatrixByImpactProgressBar();
                RequirementsTraceabilityMatrixByImpact requirementsTraceabilityMatrixByImpact = PluginSPICETrackerAdaptor
                        .getTracker()
                        .generateRequirementsTraceabilityByImpact();
                matrixView
                        .showTraceabilityMatrixByImpact(requirementsTraceabilityMatrixByImpact);

            }

        }
        Thread thread = new Thread(new TraceabilityMatrixViewerThread());
        thread.start();

    }

}
{'fraction_non_alphanumeric': 0.06465726786582401, 'fraction_numerical': 0.00267379679144385, 'mean_word_length': 2.4291666666666667, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, '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': '2659209', 'n_tokens_mistral': 1021, 'n_tokens_neox': 969, 'n_words': 175}