Skip to content
Snippets Groups Projects
Commit d1e22772 authored by Petr Bainar's avatar Petr Bainar
Browse files

Merge remote-tracking branch 'origin/master' into formatStatistics

parents 666ac61c 474ff59a
No related branches found
No related tags found
1 merge request!3Format statistics
...@@ -6,14 +6,12 @@ import java.io.OutputStream; ...@@ -6,14 +6,12 @@ import java.io.OutputStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.text.NumberFormat;
import java.time.Duration; import java.time.Duration;
import java.time.LocalTime; import java.time.LocalTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
...@@ -110,11 +108,12 @@ public class Extractor { ...@@ -110,11 +108,12 @@ public class Extractor {
} }
private Function<String, String> getConversion(String format) { private Function<String, String> getConversion(String format) {
Locale l =new Locale("cs"); // Locale l =new Locale("cs");
NumberFormat nf = NumberFormat.getNumberInstance(l); // NumberFormat nf = NumberFormat.getNumberInstance(l);
switch(format) { switch(format) {
case "kb": case "kb":
return str->nf.format(Double.parseDouble(str.replace("kb", ""))/1024.); //return str->nf.format(Double.parseDouble(str.replace("kb", ""))/1024.);
return str -> "" + Double.parseDouble(str.replace("kb", ""))/1024.;
case "tm": case "tm":
return str-> Duration.between(LocalTime.of(0, 0, 0), LocalTime.parse(str, DateTimeFormatter.ofPattern("H:m:s"))).getSeconds() + ""; return str-> Duration.between(LocalTime.of(0, 0, 0), LocalTime.parse(str, DateTimeFormatter.ofPattern("H:m:s"))).getSeconds() + "";
} }
......
...@@ -49,10 +49,14 @@ public class ProgressDialog extends JDialog implements Progress { ...@@ -49,10 +49,14 @@ public class ProgressDialog extends JDialog implements Progress {
public ProgressDialog(final Window owner) { public ProgressDialog(final Window owner) {
this(owner, null); this(owner, null);
} }
public ProgressDialog(Window owner, String title) {
this(owner, title, null);
}
public ProgressDialog(final Window owner, final String title) { public ProgressDialog(final Window owner, final String title, Runnable cancelableAction) {
super(owner, title); super(owner, title);
boolean canCancel = cancelableAction != null;
final Container root = getContentPane(); final Container root = getContentPane();
root.setLayout(new BoxLayout(root, BoxLayout.Y_AXIS)); root.setLayout(new BoxLayout(root, BoxLayout.Y_AXIS));
progress = new JProgressBar(); progress = new JProgressBar();
...@@ -77,9 +81,12 @@ public class ProgressDialog extends JDialog implements Progress { ...@@ -77,9 +81,12 @@ public class ProgressDialog extends JDialog implements Progress {
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
canceled = true; canceled = true;
ProgressDialog.this.dispose(); ProgressDialog.this.dispose();
cancelableAction.run();
} }
}); });
// buttons.add(cancel); if(canCancel) {
buttons.add(cancel);
}
buttons.setMaximumSize(buttons.getMinimumSize()); buttons.setMaximumSize(buttons.getMinimumSize());
root.add(buttons); root.add(buttons);
......
...@@ -86,7 +86,7 @@ public class ManageSPIMBenchmark implements Command { ...@@ -86,7 +86,7 @@ public class ManageSPIMBenchmark implements Command {
final ImageJ ij = new ImageJ(); final ImageJ ij = new ImageJ();
ij.launch(args); ij.launch(args);
ij.command().run(ManageSPIMBenchmark.class, true); //ij.command().run(ManageSPIMBenchmark.class, true);
} }
} }
...@@ -91,9 +91,9 @@ public class BenchmarkSPIMController implements FXFrame.Controller { ...@@ -91,9 +91,9 @@ public class BenchmarkSPIMController implements FXFrame.Controller {
private void initMenu() { private void initMenu() {
TableViewContextMenu<Job> menu = new TableViewContextMenu<>(jobs); TableViewContextMenu<Job> menu = new TableViewContextMenu<>(jobs);
menu.addItem("Create job", x -> executeJobActionAsync("Creating job", p -> manager.createJob()), j -> true); menu.addItem("Create job", x -> executeJobActionAsync("Creating job", false, p -> manager.createJob()), j -> true);
menu.addItem("Start job", job -> executeJobActionAsync("Starting job", p -> job.startJob(p)), menu.addItem("Start job", job -> executeJobActionAsync("Starting job", p -> job.startJob(p)),
job -> notNullValue(job, j -> j.getState() == JobState.Configuring)); job -> notNullValue(job, j -> j.getState() == JobState.Configuring || j.getState() == JobState.Finished));
menu.addItem("Download result", job -> executeJobActionAsync("Downloading data", p -> job.downloadData(p)), menu.addItem("Download result", job -> executeJobActionAsync("Downloading data", p -> job.downloadData(p)),
job -> notNullValue(job, job -> notNullValue(job,
j -> EnumSet.of(JobState.Failed, JobState.Finished).contains(j.getState()) && !j.downloaded())); j -> EnumSet.of(JobState.Failed, JobState.Finished).contains(j.getState()) && !j.downloaded()));
...@@ -118,15 +118,21 @@ public class BenchmarkSPIMController implements FXFrame.Controller { ...@@ -118,15 +118,21 @@ public class BenchmarkSPIMController implements FXFrame.Controller {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
}}); }});
} }
private void executeJobActionAsync(String title, P_JobAction action) { private void executeJobActionAsync(String title, P_JobAction action) {
executeJobActionAsync(title, true, action);
}
private void executeJobActionAsync(String title, boolean update, P_JobAction action) {
executorService.execute(() -> { executorService.execute(() -> {
try { try {
ProgressDialog dialog = ModalDialogs.doModal(new ProgressDialog(root, title), ProgressDialog dialog = ModalDialogs.doModal(new ProgressDialog(root, title),
WindowConstants.DO_NOTHING_ON_CLOSE); WindowConstants.DO_NOTHING_ON_CLOSE);
action.doAction(dialog); action.doAction(dialog);
dialog.done(); dialog.done();
updateJobs(); if(update) {
updateJobs();
}
} catch (IOException e) { } catch (IOException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment