Menu tide up

This commit is contained in:
Douglas Gillespie 2024-03-27 16:55:33 +00:00
parent 3b69341472
commit 94adbe77d0
6 changed files with 66 additions and 37 deletions

View File

@ -120,6 +120,7 @@ public class CalibrationsTable extends TethysGUIPanel {
}); });
popMenu.add(menuItem); popMenu.add(menuItem);
} }
popMenu.addSeparator();
if (n > 1) { if (n > 1) {
menuItem = new JMenuItem("Delete selected documents"); menuItem = new JMenuItem("Delete selected documents");
menuItem.addActionListener(new ActionListener() { menuItem.addActionListener(new ActionListener() {

View File

@ -6,10 +6,11 @@ import tethys.niluswraps.PDeployment;
public class DetectionExportProgress { public class DetectionExportProgress {
public static final int STATE_GATHERING = 1; public static final int STATE_GATHERING = 1;
public static final int STATE_CANCELED = 2; public static final int STATE_COUNTING = 2;
public static final int STATE_COMPLETE = 3; public static final int STATE_WRITING = 3;
public static final int STATE_WRITING = 4; public static final int STATE_CANCELED = 4;
public static final int STATE_COUNTING = 5; public static final int STATE_COMPLETE = 5;
public PDeployment currentDeployment; public PDeployment currentDeployment;
public Detections currentDetections; public Detections currentDetections;
public long lastUnitTime; public long lastUnitTime;
@ -18,12 +19,17 @@ public class DetectionExportProgress {
public int skipCount; public int skipCount;
public int state; public int state;
public int totalDeployments, deploymentsDone; public int totalDeployments, deploymentsDone;
public int nMapPoints;
public int doneMapPoints;
public DetectionExportProgress(PDeployment currentDeployment, Detections currentDetections, long lastUnitTime, public DetectionExportProgress(PDeployment currentDeployment, Detections currentDetections, int nMapPoints, int doneMapPoints,
long lastUnitTime,
long totalUnits, int exportCount, int skipCount, int state) { long totalUnits, int exportCount, int skipCount, int state) {
super(); super();
this.currentDeployment = currentDeployment; this.currentDeployment = currentDeployment;
this.currentDetections = currentDetections; this.currentDetections = currentDetections;
this.nMapPoints = nMapPoints;
this.doneMapPoints = doneMapPoints;
this.lastUnitTime = lastUnitTime; this.lastUnitTime = lastUnitTime;
this.totalUnits = totalUnits; this.totalUnits = totalUnits;
this.exportCount = exportCount; this.exportCount = exportCount;

View File

@ -303,9 +303,11 @@ public class DetectionsHandler extends CollectionHandler {
int totalMaps = 0; int totalMaps = 0;
int totalMappedPoints = 0; int totalMappedPoints = 0;
int totalLoadedDatas = 0; int totalLoadedDatas = 0;
int totalMapPoints = dataMap.getNumMapPoints();
int doneMapPoints = 0;
for (PDeployment deployment : deployments) { for (PDeployment deployment : deployments) {
int documentCount = 0; int documentCount = 0;
prog = new DetectionExportProgress(deployment, null, prog = new DetectionExportProgress(deployment, null, totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING); lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
exportObserver.update(prog); exportObserver.update(prog);
granularityHandler.prepare(deployment.getAudioStart()); granularityHandler.prepare(deployment.getAudioStart());
@ -315,7 +317,7 @@ public class DetectionsHandler extends CollectionHandler {
for (OfflineDataMapPoint mapPoint : mapPoints) { for (OfflineDataMapPoint mapPoint : mapPoints) {
if (!activeExport) { if (!activeExport) {
prog = new DetectionExportProgress(deployment, null, prog = new DetectionExportProgress(deployment, null,totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_CANCELED); lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_CANCELED);
exportObserver.update(prog); exportObserver.update(prog);
break; break;
@ -345,7 +347,7 @@ public class DetectionsHandler extends CollectionHandler {
documentCount+=dets.length; documentCount+=dets.length;
if (exportCount % 100 == 0) { if (exportCount % 100 == 0) {
prog = new DetectionExportProgress(deployment, null, prog = new DetectionExportProgress(deployment, null,totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING); lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
exportObserver.update(prog); exportObserver.update(prog);
} }
@ -356,8 +358,8 @@ public class DetectionsHandler extends CollectionHandler {
// onEffort.getDetection().add(det); // onEffort.getDetection().add(det);
lastUnitTime = dataUnit.getTimeMilliseconds(); lastUnitTime = dataUnit.getTimeMilliseconds();
} }
doneMapPoints++;
prog = new DetectionExportProgress(deployment, null, prog = new DetectionExportProgress(deployment, null,totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING); lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
exportObserver.update(prog); exportObserver.update(prog);
@ -410,10 +412,12 @@ public class DetectionsHandler extends CollectionHandler {
if (viewerLoadPolicy == null) { if (viewerLoadPolicy == null) {
viewerLoadPolicy = ViewerLoadPolicy.LOAD_UTCNORMAL; viewerLoadPolicy = ViewerLoadPolicy.LOAD_UTCNORMAL;
} }
int totalMapPoints = dataMap.getNumMapPoints();
int doneMapPoints = 0;
GranularityHandler granularityHandler = GranularityHandler.getHandler(streamExportParams.granularity, tethysControl, dataBlock, exportParams, streamExportParams); GranularityHandler granularityHandler = GranularityHandler.getHandler(streamExportParams.granularity, tethysControl, dataBlock, exportParams, streamExportParams);
for (PDeployment deployment : deployments) { for (PDeployment deployment : deployments) {
int documentCount = 0; int documentCount = 0;
prog = new DetectionExportProgress(deployment, null, prog = new DetectionExportProgress(deployment, null,totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING); lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
exportObserver.update(prog); exportObserver.update(prog);
granularityHandler.prepare(deployment.getAudioStart()); granularityHandler.prepare(deployment.getAudioStart());
@ -423,7 +427,7 @@ public class DetectionsHandler extends CollectionHandler {
List<OfflineDataMapPoint> mapPoints = dataMap.getMapPoints(); List<OfflineDataMapPoint> mapPoints = dataMap.getMapPoints();
for (OfflineDataMapPoint mapPoint : mapPoints) { for (OfflineDataMapPoint mapPoint : mapPoints) {
if (!activeExport) { if (!activeExport) {
prog = new DetectionExportProgress(deployment, currentDetections, prog = new DetectionExportProgress(deployment, currentDetections,totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_CANCELED); lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_CANCELED);
exportObserver.update(prog); exportObserver.update(prog);
break; break;
@ -459,19 +463,20 @@ public class DetectionsHandler extends CollectionHandler {
} }
} }
if (exportCount % 100 == 0) { if (exportCount % 100 == 0) {
prog = new DetectionExportProgress(deployment, null, prog = new DetectionExportProgress(deployment, currentDetections, totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_GATHERING); lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_GATHERING);
exportObserver.update(prog); exportObserver.update(prog);
} }
lastUnitTime = dataUnit.getTimeMilliseconds(); lastUnitTime = dataUnit.getTimeMilliseconds();
} }
prog = new DetectionExportProgress(deployment, currentDetections, doneMapPoints ++;
prog = new DetectionExportProgress(deployment, currentDetections,totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_GATHERING); lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_GATHERING);
exportObserver.update(prog); exportObserver.update(prog);
if (documentCount > 50000000 && mapPoint != dataMap.getLastMapPoint()) { if (documentCount > 50000000 && mapPoint != dataMap.getLastMapPoint()) {
prog = new DetectionExportProgress(deployment, currentDetections, prog = new DetectionExportProgress(deployment, currentDetections,totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_WRITING); lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_WRITING);
exportObserver.update(prog); exportObserver.update(prog);
closeDetectionsDocument(currentDetections, mapPoint.getEndTime()); closeDetectionsDocument(currentDetections, mapPoint.getEndTime());
@ -506,7 +511,7 @@ public class DetectionsHandler extends CollectionHandler {
currentDetections.getOnEffort().getDetection().add(dets[dd]); currentDetections.getOnEffort().getDetection().add(dets[dd]);
} }
} }
prog = new DetectionExportProgress(deployment, currentDetections, prog = new DetectionExportProgress(deployment, currentDetections,totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_WRITING); lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_WRITING);
closeDetectionsDocument(currentDetections, deployment.getAudioEnd()); closeDetectionsDocument(currentDetections, deployment.getAudioEnd());
try { try {
@ -520,7 +525,7 @@ public class DetectionsHandler extends CollectionHandler {
} }
} }
prog = new DetectionExportProgress(null, null, prog = new DetectionExportProgress(null, null,totalMapPoints, totalMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COMPLETE); lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COMPLETE);
exportObserver.update(prog); exportObserver.update(prog);
return DetectionExportProgress.STATE_COMPLETE; return DetectionExportProgress.STATE_COMPLETE;
@ -690,7 +695,7 @@ public class DetectionsHandler extends CollectionHandler {
@Override @Override
protected void done() { protected void done() {
// this. // this.
DetectionExportProgress prog = new DetectionExportProgress(null, null, 0, 0, 0, 0, DetectionExportProgress.STATE_COMPLETE); DetectionExportProgress prog = new DetectionExportProgress(null, null, 0, 0, 0, 0, 0, 0, DetectionExportProgress.STATE_COMPLETE);
tethysControl.exportedDetections(dataBlock); tethysControl.exportedDetections(dataBlock);
exportObserver.update(prog); exportObserver.update(prog);
TethysReporter.getTethysReporter().showReport(tethysControl.getGuiFrame(), true); TethysReporter.getTethysReporter().showReport(tethysControl.getGuiFrame(), true);

View File

@ -190,15 +190,8 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
JPopupMenu popMenu = new JPopupMenu(); JPopupMenu popMenu = new JPopupMenu();
JMenuItem menuItem;
if (rows.length == 1) { if (rows.length == 1) {
JMenuItem menuItem = new JMenuItem("Delete document " + pDets.detections.getId());
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deleteDocument(pDets);
}
});
popMenu.add(menuItem);
menuItem = new JMenuItem("Display document " + pDets.detections.getId()); menuItem = new JMenuItem("Display document " + pDets.detections.getId());
menuItem.addActionListener(new ActionListener() { menuItem.addActionListener(new ActionListener() {
@ -217,9 +210,19 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
} }
}); });
popMenu.add(menuItem); popMenu.add(menuItem);
popMenu.addSeparator();
menuItem = new JMenuItem("Delete document " + pDets.detections.getId());
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deleteDocument(pDets);
}
});
popMenu.add(menuItem);
} }
else if (rows.length > 0){ else if (rows.length > 0){
JMenuItem menuItem = new JMenuItem("Delete multiple Detections documents"); menuItem = new JMenuItem("Delete multiple Detections documents");
menuItem.addActionListener(new ActionListener() { menuItem.addActionListener(new ActionListener() {
@Override @Override

View File

@ -163,14 +163,6 @@ private RecordingList masterList;
} }
if (matchedDeployments.size() == 1) { if (matchedDeployments.size() == 1) {
menuItem = new JMenuItem("Delete deployment document " + matchedDeployments.get(0));
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deleteDeployment(matchedDeployments.get(0));
}
});
popMenu.add(menuItem);
menuItem = new JMenuItem("Display deployment document " + matchedDeployments.get(0)); menuItem = new JMenuItem("Display deployment document " + matchedDeployments.get(0));
menuItem.addActionListener(new ActionListener() { menuItem.addActionListener(new ActionListener() {
@Override @Override
@ -188,6 +180,16 @@ private RecordingList masterList;
}); });
popMenu.add(menuItem); popMenu.add(menuItem);
popMenu.addSeparator();
menuItem = new JMenuItem("Delete deployment document " + matchedDeployments.get(0));
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deleteDeployment(matchedDeployments.get(0));
}
});
popMenu.add(menuItem);
} }
else if (matchedDeployments.size() > 1){ else if (matchedDeployments.size() > 1){

View File

@ -147,7 +147,7 @@ public class ExportWorkerCard extends ExportWizardCard implements DetectionExpor
totExpected *= progress.exportCount/(progress.exportCount+progress.skipCount); totExpected *= progress.exportCount/(progress.exportCount+progress.skipCount);
} }
projectedCount.setText(String.format("%d", totExpected)); projectedCount.setText(String.format("%d", totExpected));
long perc = (progress.exportCount+progress.skipCount) * 100 / progress.totalUnits; long perc = (progress.doneMapPoints) * 100 / progress.nMapPoints;
progressBar.setValue((int) perc); progressBar.setValue((int) perc);
} }
switch (progress.state) { switch (progress.state) {
@ -176,6 +176,18 @@ public class ExportWorkerCard extends ExportWizardCard implements DetectionExpor
boolean stopped = state == DetectionExportProgress.STATE_CANCELED || state == DetectionExportProgress.STATE_COMPLETE; boolean stopped = state == DetectionExportProgress.STATE_CANCELED || state == DetectionExportProgress.STATE_COMPLETE;
export.setEnabled(stopped); export.setEnabled(stopped);
cancel.setEnabled(!stopped); cancel.setEnabled(!stopped);
detectionsExportWizard.getCancelButton().setEnabled(stopped);
detectionsExportWizard.getPreviousButton().setEnabled(stopped);
}
@Override
public void setVisible(boolean visible) {
/**
* setVisible is called by the wizard for each component, so
* we can see here if we're on this or not.
*/
super.setVisible(visible);
detectionsExportWizard.getOkButton().setEnabled(!visible);
} }
} }