mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-22 07:02:29 +00:00
Menu tide up
This commit is contained in:
parent
3b69341472
commit
94adbe77d0
@ -120,6 +120,7 @@ public class CalibrationsTable extends TethysGUIPanel {
|
||||
});
|
||||
popMenu.add(menuItem);
|
||||
}
|
||||
popMenu.addSeparator();
|
||||
if (n > 1) {
|
||||
menuItem = new JMenuItem("Delete selected documents");
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
|
@ -6,10 +6,11 @@ import tethys.niluswraps.PDeployment;
|
||||
public class DetectionExportProgress {
|
||||
|
||||
public static final int STATE_GATHERING = 1;
|
||||
public static final int STATE_CANCELED = 2;
|
||||
public static final int STATE_COMPLETE = 3;
|
||||
public static final int STATE_WRITING = 4;
|
||||
public static final int STATE_COUNTING = 5;
|
||||
public static final int STATE_COUNTING = 2;
|
||||
public static final int STATE_WRITING = 3;
|
||||
public static final int STATE_CANCELED = 4;
|
||||
public static final int STATE_COMPLETE = 5;
|
||||
|
||||
public PDeployment currentDeployment;
|
||||
public Detections currentDetections;
|
||||
public long lastUnitTime;
|
||||
@ -18,12 +19,17 @@ public class DetectionExportProgress {
|
||||
public int skipCount;
|
||||
public int state;
|
||||
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) {
|
||||
super();
|
||||
this.currentDeployment = currentDeployment;
|
||||
this.currentDetections = currentDetections;
|
||||
this.nMapPoints = nMapPoints;
|
||||
this.doneMapPoints = doneMapPoints;
|
||||
this.lastUnitTime = lastUnitTime;
|
||||
this.totalUnits = totalUnits;
|
||||
this.exportCount = exportCount;
|
||||
|
@ -303,9 +303,11 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
int totalMaps = 0;
|
||||
int totalMappedPoints = 0;
|
||||
int totalLoadedDatas = 0;
|
||||
int totalMapPoints = dataMap.getNumMapPoints();
|
||||
int doneMapPoints = 0;
|
||||
for (PDeployment deployment : deployments) {
|
||||
int documentCount = 0;
|
||||
prog = new DetectionExportProgress(deployment, null,
|
||||
prog = new DetectionExportProgress(deployment, null, totalMapPoints, doneMapPoints,
|
||||
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
|
||||
exportObserver.update(prog);
|
||||
granularityHandler.prepare(deployment.getAudioStart());
|
||||
@ -315,7 +317,7 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
|
||||
for (OfflineDataMapPoint mapPoint : mapPoints) {
|
||||
if (!activeExport) {
|
||||
prog = new DetectionExportProgress(deployment, null,
|
||||
prog = new DetectionExportProgress(deployment, null,totalMapPoints, doneMapPoints,
|
||||
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_CANCELED);
|
||||
exportObserver.update(prog);
|
||||
break;
|
||||
@ -345,7 +347,7 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
documentCount+=dets.length;
|
||||
|
||||
if (exportCount % 100 == 0) {
|
||||
prog = new DetectionExportProgress(deployment, null,
|
||||
prog = new DetectionExportProgress(deployment, null,totalMapPoints, doneMapPoints,
|
||||
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
|
||||
exportObserver.update(prog);
|
||||
}
|
||||
@ -356,8 +358,8 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
// onEffort.getDetection().add(det);
|
||||
lastUnitTime = dataUnit.getTimeMilliseconds();
|
||||
}
|
||||
|
||||
prog = new DetectionExportProgress(deployment, null,
|
||||
doneMapPoints++;
|
||||
prog = new DetectionExportProgress(deployment, null,totalMapPoints, doneMapPoints,
|
||||
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
|
||||
exportObserver.update(prog);
|
||||
|
||||
@ -410,10 +412,12 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
if (viewerLoadPolicy == null) {
|
||||
viewerLoadPolicy = ViewerLoadPolicy.LOAD_UTCNORMAL;
|
||||
}
|
||||
int totalMapPoints = dataMap.getNumMapPoints();
|
||||
int doneMapPoints = 0;
|
||||
GranularityHandler granularityHandler = GranularityHandler.getHandler(streamExportParams.granularity, tethysControl, dataBlock, exportParams, streamExportParams);
|
||||
for (PDeployment deployment : deployments) {
|
||||
int documentCount = 0;
|
||||
prog = new DetectionExportProgress(deployment, null,
|
||||
prog = new DetectionExportProgress(deployment, null,totalMapPoints, doneMapPoints,
|
||||
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
|
||||
exportObserver.update(prog);
|
||||
granularityHandler.prepare(deployment.getAudioStart());
|
||||
@ -423,7 +427,7 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
List<OfflineDataMapPoint> mapPoints = dataMap.getMapPoints();
|
||||
for (OfflineDataMapPoint mapPoint : mapPoints) {
|
||||
if (!activeExport) {
|
||||
prog = new DetectionExportProgress(deployment, currentDetections,
|
||||
prog = new DetectionExportProgress(deployment, currentDetections,totalMapPoints, doneMapPoints,
|
||||
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_CANCELED);
|
||||
exportObserver.update(prog);
|
||||
break;
|
||||
@ -459,19 +463,20 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
}
|
||||
}
|
||||
if (exportCount % 100 == 0) {
|
||||
prog = new DetectionExportProgress(deployment, null,
|
||||
prog = new DetectionExportProgress(deployment, currentDetections, totalMapPoints, doneMapPoints,
|
||||
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_GATHERING);
|
||||
exportObserver.update(prog);
|
||||
}
|
||||
lastUnitTime = dataUnit.getTimeMilliseconds();
|
||||
}
|
||||
|
||||
prog = new DetectionExportProgress(deployment, currentDetections,
|
||||
doneMapPoints ++;
|
||||
prog = new DetectionExportProgress(deployment, currentDetections,totalMapPoints, doneMapPoints,
|
||||
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_GATHERING);
|
||||
exportObserver.update(prog);
|
||||
|
||||
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);
|
||||
exportObserver.update(prog);
|
||||
closeDetectionsDocument(currentDetections, mapPoint.getEndTime());
|
||||
@ -506,7 +511,7 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
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);
|
||||
closeDetectionsDocument(currentDetections, deployment.getAudioEnd());
|
||||
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);
|
||||
exportObserver.update(prog);
|
||||
return DetectionExportProgress.STATE_COMPLETE;
|
||||
@ -690,7 +695,7 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
@Override
|
||||
protected void done() {
|
||||
// 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);
|
||||
exportObserver.update(prog);
|
||||
TethysReporter.getTethysReporter().showReport(tethysControl.getGuiFrame(), true);
|
||||
|
@ -190,15 +190,8 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
|
||||
|
||||
JPopupMenu popMenu = new JPopupMenu();
|
||||
|
||||
JMenuItem menuItem;
|
||||
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.addActionListener(new ActionListener() {
|
||||
@ -217,9 +210,19 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
|
||||
}
|
||||
});
|
||||
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){
|
||||
JMenuItem menuItem = new JMenuItem("Delete multiple Detections documents");
|
||||
menuItem = new JMenuItem("Delete multiple Detections documents");
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
|
@ -163,14 +163,6 @@ private RecordingList masterList;
|
||||
}
|
||||
|
||||
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.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
@ -188,6 +180,16 @@ private RecordingList masterList;
|
||||
});
|
||||
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){
|
||||
|
@ -147,7 +147,7 @@ public class ExportWorkerCard extends ExportWizardCard implements DetectionExpor
|
||||
totExpected *= progress.exportCount/(progress.exportCount+progress.skipCount);
|
||||
}
|
||||
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);
|
||||
}
|
||||
switch (progress.state) {
|
||||
@ -176,6 +176,18 @@ public class ExportWorkerCard extends ExportWizardCard implements DetectionExpor
|
||||
boolean stopped = state == DetectionExportProgress.STATE_CANCELED || state == DetectionExportProgress.STATE_COMPLETE;
|
||||
export.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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user