Repository for the HealthTool which enables Apple users to analyse their health data from the Apple health app and prepares the data for contributing it for future studies on wearable data.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

89 lines
1.7 KiB

package application.helpers;
import application.helpers.wrappers.WrappedException;
import javafx.application.Platform;
/**
* This thread is used to enable working in the background while the progress
* view is displayed
*
* @author Bianca
*
*/
public class WorkWhileProgressThread extends Thread
{
/**
* The callback used to change the view after the work is done
*/
private ChangeViewCallback cb;
/**
* There are 2 possible workloads: reading the file for the overview
* ({@code True}) or creating the files for being inspected ({@code False})
*/
private boolean overview;
/**
*
* @param cb The callback
* @param overView {@code True} if the initial file needs to be read or
* {@code False} if the files for being inspected need to be
* created
*/
public WorkWhileProgressThread(ChangeViewCallback cb, boolean overView)
{
this.cb = cb;
this.overview = overView;
}
@Override
public void run()
{
//read the file
if (overview)
{
try
{
this.cb.callFillDataList();
}
catch (WrappedException e)
{
cb.callErrorReadingFile(e.getReason());
}
Platform.runLater(new Runnable()
{
@Override
public void run()
{
cb.callOverview();
}
});
}
else
{ //create the selected files
try
{
this.cb.callCreateTempFiles();
Platform.runLater(new Runnable()
{
@Override
public void run()
{
cb.callInspect();
}
});
}
catch (WrappedException e)
{
this.cb.callErrorWritingTemFiles(e.getReason());
Platform.runLater(new Runnable()
{
@Override
public void run()
{
cb.callInspectWithError();
}
});
}
}
}
}