minor improvements. Checker framework added as global dependency

This commit is contained in:
Alexander Nozik 2016-05-18 13:12:59 +03:00
parent d344922d3f
commit d65c29cde8
6 changed files with 73 additions and 29 deletions

View File

@ -36,7 +36,6 @@ public class NumassContext extends Context {
public static UnivariateIntegrator defaultIntegrator = new GaussRuleIntegrator(300);
public static UnivariateIntegrator highDensityIntegrator = new GaussRuleIntegrator(500);
public NumassContext(Context parent, Meta config) {
super(parent, "numass", config);
init();

View File

@ -0,0 +1,54 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package inr.numass;
import hep.dataforge.context.GlobalContext;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
/**
*
* @author Alexander Nozik
*/
public class NumassProperties {
private static File getNumassPropertiesFile() throws IOException {
File file = new File(GlobalContext.instance().getUserDirectory(), "numass");
if (!file.exists()) {
file.mkdirs();
}
file = new File(file, "numass.cfg");
if(!file.exists()){
file.createNewFile();
}
return file;
}
public static String getNumassProperty(String key) {
try {
Properties props = new Properties();
props.load(new FileInputStream(getNumassPropertiesFile()));
return props.getProperty(key);
} catch (IOException ex) {
return null;
}
}
public synchronized static void setNumassProperty(String key, String value) {
try {
Properties props = new Properties();
File store = getNumassPropertiesFile();
props.load(new FileInputStream(store));
props.setProperty(key, value);
props.store(new FileOutputStream(store), "");
} catch (IOException ex) {
GlobalContext.instance().getLogger().error("Failed to save numass properties", ex);
}
}
}

View File

@ -20,7 +20,6 @@ import hep.dataforge.fx.ConsoleFragment;
import hep.dataforge.fx.FXProcessManager;
import hep.dataforge.fx.LogOutputPane;
import hep.dataforge.fx.MetaEditor;
import hep.dataforge.fx.MetaTreeItem;
import hep.dataforge.fx.ProcessManagerFragment;
import hep.dataforge.io.IOManager;
import hep.dataforge.io.MetaFileReader;
@ -34,6 +33,7 @@ import hep.dataforge.plots.PlotsPlugin;
import hep.dataforge.utils.MetaFactory;
import hep.dataforge.values.Value;
import inr.numass.NumassIO;
import inr.numass.NumassProperties;
import java.io.File;
import java.io.IOException;
import java.net.URL;
@ -275,8 +275,15 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
statusBar.setText("Loading configuration file...");
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Open Configuration File");
String storageRoot = NumassProperties.getNumassProperty("numass.workbench.root");
if (storageRoot == null) {
fileChooser.setInitialDirectory(new File(".").getAbsoluteFile());
} else {
fileChooser.setInitialDirectory(new File(storageRoot));
}
File cfgFile = fileChooser.showOpenDialog(((Node) event.getTarget()).getScene().getWindow());
if (cfgFile != null) {
NumassProperties.setNumassProperty("numass.workbench.root", cfgFile.getParentFile().getAbsolutePath());
try {
Meta cfg = MetaFileReader.read(cfgFile).build();
this.loadConfig(cfg);

View File

@ -5,7 +5,7 @@ if (!hasProperty('mainClass')) {
}
mainClassName = mainClass
version = "0.3.1"
version = "0.3.2"
description = "The viewer for numass data"

View File

@ -21,6 +21,8 @@ import hep.dataforge.context.ProcessManager;
import hep.dataforge.exceptions.StorageException;
import hep.dataforge.fx.ConsoleFragment;
import hep.dataforge.fx.ProcessManagerFragment;
import inr.numass.NumassContext;
import inr.numass.NumassProperties;
import inr.numass.storage.NumassData;
import inr.numass.storage.NumassStorage;
import java.io.File;
@ -122,11 +124,17 @@ public class MainViewerController implements Initializable {
DirectoryChooser chooser = new DirectoryChooser();
chooser.setTitle("Select numass storage root");
chooser.setInitialDirectory(new File(".").getAbsoluteFile());
String storageRoot = NumassProperties.getNumassProperty("numass.storage.root");
if (storageRoot == null) {
chooser.setInitialDirectory(new File(".").getAbsoluteFile());
} else {
chooser.setInitialDirectory(new File(storageRoot));
}
final File rootDir = chooser.showDialog(((Node) event.getTarget()).getScene().getWindow());
if (rootDir != null) {
NumassProperties.setNumassProperty("numass.storage.root", rootDir.getAbsolutePath());
loadDirectory(rootDir.toURI().toString());
}
}

View File

@ -374,30 +374,6 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
return plottables;
}
@FXML
private void checkAllAction(ActionEvent event) {
detectorPointListView.getCheckModel().checkAll();
}
@FXML
private void uncheckAllAction(ActionEvent event) {
detectorPointListView.getCheckModel().clearChecks();
}
@FXML
private void checkSelectedAction(ActionEvent event) {
for (Integer i : detectorPointListView.getSelectionModel().getSelectedIndices()) {
detectorPointListView.getCheckModel().check(i);
}
}
@FXML
private void uncheckSelectedAction(ActionEvent event) {
for (Integer i : detectorPointListView.getSelectionModel().getSelectedIndices()) {
detectorPointListView.getCheckModel().clearCheck(i);
}
}
@FXML
private void onSpectrumExportClick(ActionEvent event) {
if (points != null && !points.isEmpty()) {