Squashed commit of the following:

commit 62b020b320
Author: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com>
Date:   Sat May 14 06:52:20 2022 +0100

    Add a new offlinefileslist function

commit 3a9a5311aa
Author: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com>
Date:   Wed Apr 27 09:43:31 2022 +0100

    Update .gitignore

commit 9f998165ee
Author: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com>
Date:   Mon May 2 19:40:24 2022 +0100

    Updates to support ContactCollator plugin (#33)

    * Change synchronization on RawDataTransforms soit uses the owner data
    holder, not itself for synchronization. Otherwise you get thread locks.

    * fix problem in SummaryComand

    * Update command line options

    * Change synchronization on RawDataTransforms soit uses the owner data
    holder, not itself for synchronization. Otherwise you get thread locks.

    * Update command line options

    * Update DecimatorParams.java

    * couple of updates to support new contact collator plugin

    * Sorting out sample rate info in clip display to support Contact Collator
    plugin

    * FLAC Speed

    Improve flac speed

    * Update .gitignore

    * Update .gitignore

    * Updates to support new features in Contact Collator

    * Small update to RawDatautils to handle null data
This commit is contained in:
Jamie Mac 2022-05-16 15:05:29 +01:00
parent 22c24a0beb
commit d1bfda210b
2 changed files with 90 additions and 2 deletions

View File

@ -99,8 +99,8 @@ public class SummaryPanel extends HidingDialogComponent {
dataEnds[i].setText(" ---No data---");
}
else {
dataStarts[i].setText(PamCalendar.formatDateTime2(dataExtent[0], true));
dataEnds[i].setText(PamCalendar.formatDateTime(dataExtent[1], true));
dataStarts[i].setText(PamCalendar.formatDateTime2(dataExtent[0], true));
dataEnds[i].setText(PamCalendar.formatDateTime(dataExtent[1], true));
}
}
for (int i = offlineDataStores.size(); i < maxDataSources; i++) {

View File

@ -0,0 +1,88 @@
package fileOfflineData;
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
/**
* Make a list of files with the given file filter.
* @author dg50
*
*/
public class OfflineFileList {
private ArrayList<File> files = new ArrayList<>();
private String folder;
private FileFilter fileFilter;
private boolean includeSubFolders;
public OfflineFileList(String folder, FileFilter fileFilter, boolean includeSubFolders) {
this.folder = folder;
this.fileFilter = fileFilter;
this.includeSubFolders = includeSubFolders;
updateCatalog();
}
public int updateCatalog() {
files.clear();
File current = new File(this.folder);
addFiles(current);
return files.size();
}
private void addFiles(File current) {
if (current.exists() == false) {
return;
}
if (current.isFile() && checkFilter(current)) {
/*
* This can only really happen if the root passed in is a file, not a
* folder, since files within the folder structure will get
* added from the loop below.
*/
files.add(current);
}
else if (current.isDirectory()) {
File[] filesList = current.listFiles();
if (filesList == null) {
return;
}
for (int i = 0; i < filesList.length; i++) {
File aFile = filesList[i];
if (aFile.isFile() && checkFilter(aFile)) {
files.add(aFile);
}
else if (aFile.isDirectory() && includeSubFolders) {
addFiles(aFile);
}
}
}
}
/**
* Check that if there is a filter, the file is accepted.
* @param aFile
* @return
*/
private boolean checkFilter(File aFile) {
if (fileFilter == null) {
return true;
}
return fileFilter.accept(aFile);
}
/**
* Get a list of files in the catalog as a simple string list.
* @return files as strings
*/
public String[] asStringList() {
if (files == null) {
return null;
}
String[] str = new String[files.size()];
for (int i = 0; i < files.size(); i++) {
str[i] = files.get(i).getAbsolutePath();
}
return str;
}
}