mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-10-29 23:30:44 +00:00
Batch processing
Updates to support batch processing control
This commit is contained in:
parent
5f9d29e131
commit
16e8184a23
@ -460,8 +460,6 @@ final public class PamModel implements PamModelInterface, PamSettings {
|
||||
mi.setModulesMenuGroup(utilitiesGroup);
|
||||
mi.setMaxNumber(1);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ************* End Utilities Group *******************
|
||||
*/
|
||||
|
@ -5,6 +5,7 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JMenuItem;
|
||||
@ -49,6 +50,14 @@ public abstract class DataBlockTableView<T extends PamDataUnit> {
|
||||
|
||||
private SwingTableColumnWidths columnWidths;
|
||||
|
||||
/**
|
||||
* Most work will run off a copy of the data.
|
||||
* Makes it easier to include data selectors, etc.
|
||||
*/
|
||||
private ArrayList<T> dataUnitCopy;
|
||||
|
||||
private Object copySynch = new Object();
|
||||
|
||||
public DataBlockTableView(PamDataBlock<T> pamDataBlock, String displayName) {
|
||||
this.pamDataBlock = pamDataBlock;
|
||||
this.displayName = displayName;
|
||||
@ -141,6 +150,9 @@ public abstract class DataBlockTableView<T extends PamDataUnit> {
|
||||
String tip = null;
|
||||
java.awt.Point p = e.getPoint();
|
||||
int rowIndex = rowAtPoint(p);
|
||||
if (rowIndex < 0) {
|
||||
return null;
|
||||
}
|
||||
int colIndex = columnAtPoint(p);
|
||||
int realColumnIndex = convertColumnIndexToModel(colIndex);
|
||||
T dataUnit = getDataUnit(rowIndex);
|
||||
@ -201,10 +213,14 @@ public abstract class DataBlockTableView<T extends PamDataUnit> {
|
||||
* @return data unit for the table row.
|
||||
*/
|
||||
private final T getDataUnit(int tableRow) {
|
||||
synchronized (pamDataBlock.getSynchLock()) {
|
||||
synchronized (copySynch) {
|
||||
int rowIndex = getDataIndexForRow(tableRow);
|
||||
if (rowIndex < 0) return null;
|
||||
return pamDataBlock.getDataUnit(rowIndex, PamDataBlock.REFERENCE_CURRENT);
|
||||
if (dataUnitCopy == null) {
|
||||
return null;
|
||||
}
|
||||
return dataUnitCopy.get(tableRow);
|
||||
// return pamDataBlock.getDataUnit(rowIndex, PamDataBlock.REFERENCE_CURRENT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,10 +228,13 @@ public abstract class DataBlockTableView<T extends PamDataUnit> {
|
||||
* Get the number of rows in the table - default behaviour is the
|
||||
* number of rows in the datablock, but this may be overridded if
|
||||
* data are being selected in a different way.
|
||||
* @return numer of table rows to show.
|
||||
* @return number of table rows to show.
|
||||
*/
|
||||
public int getRowCount() {
|
||||
return pamDataBlock.getUnitsCount();
|
||||
if (dataUnitCopy == null) {
|
||||
return 0;
|
||||
}
|
||||
return dataUnitCopy.size();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,7 +246,10 @@ public abstract class DataBlockTableView<T extends PamDataUnit> {
|
||||
* @return
|
||||
*/
|
||||
public int getDataIndexForRow(int tableRow) {
|
||||
int nRow = pamDataBlock.getUnitsCount();
|
||||
if (dataUnitCopy == null) {
|
||||
return tableRow;
|
||||
}
|
||||
int nRow = dataUnitCopy.size();
|
||||
if (!isViewer) {
|
||||
tableRow = nRow-tableRow-1;
|
||||
}
|
||||
@ -244,12 +266,14 @@ public abstract class DataBlockTableView<T extends PamDataUnit> {
|
||||
|
||||
@Override
|
||||
public void addData(PamObservable o, PamDataUnit arg) {
|
||||
blockTableModel.fireTableDataChanged();
|
||||
DataBlockTableView.this.updatePamData();
|
||||
// blockTableModel.fireTableDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateData(PamObservable observable, PamDataUnit pamDataUnit) {
|
||||
blockTableModel.fireTableDataChanged();
|
||||
DataBlockTableView.this.updatePamData();
|
||||
// blockTableModel.fireTableDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -258,6 +282,15 @@ public abstract class DataBlockTableView<T extends PamDataUnit> {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updatePamData() {
|
||||
synchronized (copySynch) {
|
||||
dataUnitCopy = pamDataBlock.getDataCopy();
|
||||
}
|
||||
blockTableModel.fireTableDataChanged();
|
||||
}
|
||||
|
||||
|
||||
private class MouseAction extends MouseAdapter {
|
||||
|
||||
/* (non-Javadoc)
|
||||
@ -304,7 +337,11 @@ public abstract class DataBlockTableView<T extends PamDataUnit> {
|
||||
* @return Array of multiple rows selected.
|
||||
*/
|
||||
public T[] getMultipleSelectedRows() {
|
||||
synchronized(pamDataBlock.getSynchLock()) {
|
||||
if (dataUnitCopy == null) {
|
||||
return null;
|
||||
}
|
||||
// synchronized(pamDataBlock.getSynchLock()) { // synch not needed with data copy.
|
||||
synchronized (copySynch) {
|
||||
int[] selRows = testTable.getSelectedRows();
|
||||
if (selRows == null) {
|
||||
return null;
|
||||
@ -337,12 +374,14 @@ public abstract class DataBlockTableView<T extends PamDataUnit> {
|
||||
|
||||
@Override
|
||||
public void scrollValueChanged(AbstractPamScroller abstractPamScroller) {
|
||||
blockTableModel.fireTableDataChanged();
|
||||
// blockTableModel.fireTableDataChanged();
|
||||
updatePamData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrollRangeChanged(AbstractPamScroller pamScroller) {
|
||||
blockTableModel.fireTableDataChanged();
|
||||
// blockTableModel.fireTableDataChanged();
|
||||
updatePamData();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import PamUtils.PamCalendar;
|
||||
* tables. Also used to prepare Sql statements for writing and
|
||||
* reading back data.
|
||||
*
|
||||
* I did a bit of redifining what columns are used for on 4 Oct, 2012.
|
||||
* I did a bit of redefining what columns are used for on 4 Oct, 2012.
|
||||
* PCLocalTime was a UTC time from the PC of the time analysis took place.
|
||||
* When running in real time, this would be the same as the data in the UTC column
|
||||
* (give or take the odd second for data to get through the system). I've now defined
|
||||
|
@ -225,7 +225,10 @@ public class PamTableItem implements Cloneable {
|
||||
// }
|
||||
|
||||
public String getDeblankedStringValue() {
|
||||
if (sqlType != Types.CHAR || value == null) {
|
||||
// if (sqlType != Types.CHAR || value == null) {
|
||||
// return null;
|
||||
// }
|
||||
if (value instanceof String == false) {
|
||||
return null;
|
||||
}
|
||||
return ((String) value).trim();
|
||||
|
@ -103,7 +103,10 @@ public class SqliteSystem extends DBSystem implements PamSettings {
|
||||
if (commandName == null) {
|
||||
return;
|
||||
}
|
||||
setDatabaseName(commandName);
|
||||
File commandFile = new File(commandName);
|
||||
// check the file end is of the right type. Some batch systems may not get this right.
|
||||
commandFile = PamFileFilter.checkFileEnd(commandFile, "sqlite3", true);
|
||||
setDatabaseName(commandFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -303,6 +306,30 @@ public class SqliteSystem extends DBSystem implements PamSettings {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkDatabaseExists(String dbName) {
|
||||
String commandName = GlobalArguments.getParam(DBControl.GlobalDatabaseNameArg);
|
||||
if (commandName != null) {
|
||||
return checkCommandLineDatabase();
|
||||
}
|
||||
return super.checkDatabaseExists(dbName);
|
||||
}
|
||||
|
||||
private boolean checkCommandLineDatabase() {
|
||||
String commandName = GlobalArguments.getParam(DBControl.GlobalDatabaseNameArg);
|
||||
if (commandName == null) {
|
||||
return false;
|
||||
}
|
||||
File dbFile = new File(commandName);
|
||||
dbFile = PamFileFilter.checkFileEnd(dbFile, ".sqlite3", true);
|
||||
commandName = dbFile.getAbsolutePath();
|
||||
if (dbFile.exists() == false) {
|
||||
// create a new database without asking.
|
||||
createNewDatabase(commandName);
|
||||
}
|
||||
return dbFile.exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDatabaseName() {
|
||||
/*
|
||||
@ -311,6 +338,9 @@ public class SqliteSystem extends DBSystem implements PamSettings {
|
||||
*/
|
||||
String commandName = GlobalArguments.getParam(DBControl.GlobalDatabaseNameArg);
|
||||
if (commandName != null) {
|
||||
File dbFile = new File(commandName);
|
||||
dbFile = PamFileFilter.checkFileEnd(dbFile, ".sqlite3", true);
|
||||
commandName = dbFile.getAbsolutePath();
|
||||
return commandName;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user