From 695c0ee75ba8b100cbbc9d15a511cbbad9cc2d58 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Thu, 2 Jun 2016 18:41:34 +0300 Subject: [PATCH] [no commit message] --- .../private/cache/retriever/catalog.xml | 4 + .../java/javase/overview/index.html | 1087 +++++++++++++++++ .../src/main/java/inr/numass/Main.java | 4 + .../main/java/inr/numass/NumassContext.java | 8 - .../main/java/inr/numass/NumassPlugin.java | 21 +- .../actions/ReadNumassStorageAction.java | 66 +- .../actions/ShowLossSpectrumAction.java | 2 +- .../inr/numass/models/ModularSpectrum.java | 9 +- .../numass/models/NamedSpectrumCaching.java | 9 +- .../workbench/NumassWorkbenchController.java | 85 +- .../java/inr/numass/workbench/StagePane.java | 35 +- .../inr/numass/workbench/TextOutputTab.java | 4 +- .../main/resources/fxml/NumassWorkbench.fxml | 52 +- .../numass/storage/SetDirectionUtility.java | 17 +- .../numass/viewer/MainViewerController.java | 2 +- 15 files changed, 1261 insertions(+), 144 deletions(-) create mode 100644 numass-main/private/cache/retriever/catalog.xml create mode 100644 numass-main/private/cache/retriever/www.oracle.com/technetwork/java/javase/overview/index.html diff --git a/numass-main/private/cache/retriever/catalog.xml b/numass-main/private/cache/retriever/catalog.xml new file mode 100644 index 00000000..a63b4498 --- /dev/null +++ b/numass-main/private/cache/retriever/catalog.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/numass-main/private/cache/retriever/www.oracle.com/technetwork/java/javase/overview/index.html b/numass-main/private/cache/retriever/www.oracle.com/technetwork/java/javase/overview/index.html new file mode 100644 index 00000000..39ff197c --- /dev/null +++ b/numass-main/private/cache/retriever/www.oracle.com/technetwork/java/javase/overview/index.html @@ -0,0 +1,1087 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Java SE | Oracle Technology Network | Oracle + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + +
+
+ + + + + + +
+ +
+
+ + + + + + + + + + + + + +
+
+
+ + + + + + + + + + +
+
+ +

Java SE at a Glance

 
 

Java Platform, Standard Edition (Java SE) lets you develop and deploy Java applications on desktops and servers, as well as in today's demanding embedded environments. Java offers the rich user interface, performance, versatility, portability, and security that today's applicationsrequire.


Auto-update Notice & End of Public Updates for Oracle JDK 7

Coincident with the January 2015 CPU release users with the auto-update feature enabled were migrated from Oracle JRE 7 to Oracle JRE 8. Also, please note the April 2015 CPU release was the last Oracle JDK 7 publicly available update. For more information, and details on how to receive longer term support for Oracle JDK 7, please see the Oracle Java SE Support Roadmap.
 

 

What's New

Java Platform, Standard Edition 8 Update 91 (Java SE 8u91) and 8 Update 92 (Java SE 8u92) are Now Available
This latest release of the Java Platform includes important security fixes. Oracle strongly recommends that all Java SE 8 users upgrade to this release.
JDK for ARM releases are available on the same page as the downloads for other platforms

arrow Download  arrow  Release Notes

Advanced Management Console 2.3
Provides system administrators an effective control over diverse Java versions running on desktops in the enterprise enabling a more secure environment and enhanced application experience and availability. Documentation

Java SE 8 is Now Available
The Java Platform, Standard Edition 8 (Java SE 8) is a major feature release. It contains new features and enhancements in many functional areas. Java SE 8 delivers enhanced developer productivity and significant application performance increases through reduced boilerplate code, improved collections and annotations, simpler parallel programming models and more efficient use of modern, multi-core processors. See what's new in JDK 8 for more details.
arrow Download  arrow  Release Notes

Security of the Java Platform
A description of security information provided by role. For developers, system administrators, home users, and security professionals.

Java RIA Security Checklist
Recently announced changes scheduled for Java 7 update 51 (January 2014) have established that the default security slider will require code signatures and the Permissions Manifest attribute. This checklist is intended to provide best practices to help development teams track work necessary to accommodate user prompts.

LiveConnect changes in 7u45 
Java 7 update 45 (October 2013) introduces a new warning to users of LiveConnect applications. LiveConnect is a technology for Rich Internet Applications that allows JavaScript on a web page to make calls into an RIA, allowing the two to work together and load content. RIAs that do not use LiveConnect are unaffected by this change. Read More

Oracle Releases New Diagnostic, Monitoring, Security and Deployment Capabilities for Java SE 7 (Press Release)  Video

Java Mission Control 
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis.
Release Notes   Demo   White Paper

Deployment Rule Set 
Deployment rule set allows a desktop administrator to control the level of Java client compatibility and default prompts across an organization. Documentation 

Java API Documentation Updater Tool 

Java Usage Tracking and Visualization with Oracle Fusion Middleware 

Server JRE 
Starting with Java SE 7u21, a Server Java Runtime Environment (Server JRE) package is available for deploying Java applications on servers. Learn More

Java Applet & Web Start - Code Signing 
Starting with Java SE 7u21 all Java Applets and Web Start Applications are encouraged to be signed with a trusted certificate. Learn More

Archive of Technical Articles

 

Updates

Java SE 8u91 and 8u92 Released
Java SE 8u91 is the latest Security Alert releases for JDK 8. Java SE 8u92 is the latest patch-set update with additional features.

arrow Release Notes  arrow  Download


communityProducts and Training
 

Oracle Java SE Advanced & Suite 
Expert monitoring, diagnostics, and centralized management for enterprise and ISV Java-based applications.
Oracle Java SE Support
Access Oracle Premier Support for the components and features included with Java SE.

Training & Certification:

?
Learn More about Java Software

Java can reduce costs, drive innovation, and improve application services.



community Community

JavaOne
JavaOne 2015 has concluded, but the Learning Lives On

Did you miss a JavaOne keynote or session? You can find those here. And 'Save the Date' for Oracle OpenWorld 2016 September 18-22, 2016!

Java 8 Event Kit
Access the "Create the Future with Java 8 Event Kit" - run your own Java 8 event using the resources designed for Java User Groups (JUGs). The kit includes a fully scripted technical presentation, intro video, promotional tools and more. Learn More

Adopt a JSR Program
This program is intended to encourage JUG members to get involved in a Java Specification Request (JSR) and to evangelise that JSR to their JUG and the wider Java community in order to increase grass roots participation. Learn More

Java.net 
- The Source for Java Technology Collaboration

Java Embedded Community

JavaFX Community

NightHacking LogoNighthacking.com
The NightHacking Java 8 Tour is the inaugural leg of the Java 8 Tour event where the evangelism team will be crossing the globe to speak at conferences and Java User Groups to spread the word about the new Java 8 release.


 


Participate
 

Make the Future Java Outreach Program
Together, we can inspire future technologists to learn more about Java and the opportunities it brings. The Make the Future Java program offers resources, tool kits and promotional items you can use for Java outreach within your local community.

Join a Java User Group (JUG)
Java User Groups (JUGs) are volunteer organizations that strive to distribute Java-related knowledge around the world. They provide a meeting place for Java users to get information, share resources and solutions, increase networking, expand Java Technology expertise, and above all, drink beer, eat pizza and have fun. Find a JUG and become a part of the Java community today!

Java ForumsI Code Java
Read about and share ideas and suggestions about Java technology on the discussion forums. Start with the New to Java or the more advanced Java Programming category.

Gimme Java - Show your true colors!
These Java designs are yours to take and use. Post on your Website, put them on t-shirts or coffee mugs—use them just about anywhere except on a Java product—and let the world know about your passion for Java.

 

 

Java SE Site Map

+ +
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + + + + + + + + + + + +
Left Curve +
Java SDKs and Tools
+
Right Curve
+ +
+ + + +
Left Curve
Java Resources
Right Curve
+ + +
+
+ + +
+ + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + diff --git a/numass-main/src/main/java/inr/numass/Main.java b/numass-main/src/main/java/inr/numass/Main.java index ce3d43e3..a1792370 100644 --- a/numass-main/src/main/java/inr/numass/Main.java +++ b/numass-main/src/main/java/inr/numass/Main.java @@ -43,6 +43,10 @@ import org.slf4j.LoggerFactory; import static java.util.Locale.setDefault; import static java.util.Locale.setDefault; import static java.util.Locale.setDefault; +import static java.util.Locale.setDefault; +import static java.util.Locale.setDefault; +import static java.util.Locale.setDefault; +import static java.util.Locale.setDefault; /** * diff --git a/numass-main/src/main/java/inr/numass/NumassContext.java b/numass-main/src/main/java/inr/numass/NumassContext.java index 812a5723..b4a0470a 100644 --- a/numass-main/src/main/java/inr/numass/NumassContext.java +++ b/numass-main/src/main/java/inr/numass/NumassContext.java @@ -58,7 +58,6 @@ public class NumassContext extends Context { loadPlugin("hep.dataforge:actions"); loadPlugin("inr.numass:numass"); setIO(new NumassIO()); - SetDirectionUtility.load(this); } public static void printDescription(Context context, boolean allowANSI) throws DescriptorException { @@ -79,11 +78,4 @@ public class NumassContext extends Context { writer.println("***End of actions list***"); writer.flush(); } - - @Override - public void close() throws Exception { - SetDirectionUtility.save(this); - super.close(); - } - } diff --git a/numass-main/src/main/java/inr/numass/NumassPlugin.java b/numass-main/src/main/java/inr/numass/NumassPlugin.java index f0ba4af7..061d01f0 100644 --- a/numass-main/src/main/java/inr/numass/NumassPlugin.java +++ b/numass-main/src/main/java/inr/numass/NumassPlugin.java @@ -109,7 +109,7 @@ public class NumassPlugin extends BasicPlugin { sp.setCaching(false); NBkgSpectrum spectrum = new NBkgSpectrum(sp); - return new XYModel("tritium", spectrum, getAdapter(an)); + return new XYModel(spectrum, getAdapter(an)); }); manager.addModel("scatter", (context, an) -> { @@ -127,7 +127,7 @@ public class NumassPlugin extends BasicPlugin { NBkgSpectrum spectrum = new NBkgSpectrum(sp); sp.setCaching(false); - return new XYModel("scatter", spectrum, getAdapter(an)); + return new XYModel(spectrum, getAdapter(an)); }); manager.addModel("scatter-empiric", (context, an) -> { @@ -140,7 +140,7 @@ public class NumassPlugin extends BasicPlugin { double weightReductionFactor = an.getDouble("weightReductionFactor", 2.0); - return new WeightedXYModel("scatter-empiric", spectrum, getAdapter(an), (dp) -> weightReductionFactor); + return new WeightedXYModel(spectrum, getAdapter(an), (dp) -> weightReductionFactor); }); manager.addModel("scatter-empiric-variable", (context, an) -> { @@ -162,7 +162,7 @@ public class NumassPlugin extends BasicPlugin { double weightReductionFactor = an.getDouble("weightReductionFactor", 2.0); - WeightedXYModel res = new WeightedXYModel("scatter-variable", spectrum, getAdapter(an), (dp) -> weightReductionFactor); + WeightedXYModel res = new WeightedXYModel(spectrum, getAdapter(an), (dp) -> weightReductionFactor); res.setMeta(an); return res; }); @@ -181,7 +181,7 @@ public class NumassPlugin extends BasicPlugin { spectrum = CustomNBkgSpectrum.tritiumBkgSpectrum(loss, tritiumBackground); } - return new XYModel("scatter-variable", spectrum, getAdapter(an)); + return new XYModel(spectrum, getAdapter(an)); }); manager.addModel("scatter-empiric-experimental", (context, an) -> { @@ -199,7 +199,7 @@ public class NumassPlugin extends BasicPlugin { double weightReductionFactor = an.getDouble("weightReductionFactor", 2.0); WeightedXYModel res - = new WeightedXYModel("scatter-empiric-experimental", spectrum, getAdapter(an), (dp) -> weightReductionFactor); + = new WeightedXYModel(spectrum, getAdapter(an), (dp) -> weightReductionFactor); res.setMeta(an); return res; }); @@ -208,18 +208,21 @@ public class NumassPlugin extends BasicPlugin { double A = an.getDouble("resolution", 8.3e-5);//8.3e-5 double from = an.getDouble("from", 13900d); double to = an.getDouble("to", 18700d); + context.getReport().report("Setting up tritium model with real transmission function"); BivariateFunction resolutionTail = ResolutionFunction.getRealTail(); RangedNamedSetSpectrum beta = new BetaSpectrum(context.io().getFile("FS.txt")); ModularSpectrum sp = new ModularSpectrum(beta, new ResolutionFunction(A, resolutionTail), from, to); if (!an.getBoolean("caching", false)) { + context.getReport().report("Caching turned off"); sp.setCaching(false); } //Adding trapping energy dependence //Intercept = 4.95745, B1 = -0.36879, B2 = 0.00827 sp.setTrappingFunction((Ei,Ef)->LossCalculator.getTrapFunction().value(Ei, Ef)*(4.95745-0.36879*Ei+0.00827*Ei*Ei)); + context.getReport().report("Using folowing trapping energy dependecy^ {}", "4.95745-0.36879*Ei+0.00827*Ei*Ei"); NBkgSpectrum spectrum = new NBkgSpectrum(sp); - return new XYModel("tritium", spectrum, getAdapter(an)); + return new XYModel(spectrum, getAdapter(an)); }); manager.addModel("modularbeta-unadeabatic", (context, an) -> { @@ -240,7 +243,7 @@ public class NumassPlugin extends BasicPlugin { sp.setCaching(false); NBkgSpectrum spectrum = new NBkgSpectrum(sp); - return new XYModel("tritium", spectrum, getAdapter(an)); + return new XYModel(spectrum, getAdapter(an)); }); manager.addModel("gun", (context, an) -> { @@ -255,7 +258,7 @@ public class NumassPlugin extends BasicPlugin { spectrum = CustomNBkgSpectrum.tritiumBkgSpectrum(gsp, tritiumBackground); } - return new XYModel("gun", spectrum, getAdapter(an)); + return new XYModel(spectrum, getAdapter(an)); }); } diff --git a/numass-main/src/main/java/inr/numass/actions/ReadNumassStorageAction.java b/numass-main/src/main/java/inr/numass/actions/ReadNumassStorageAction.java index 04e1b673..4421e8c0 100644 --- a/numass-main/src/main/java/inr/numass/actions/ReadNumassStorageAction.java +++ b/numass-main/src/main/java/inr/numass/actions/ReadNumassStorageAction.java @@ -7,6 +7,8 @@ package inr.numass.actions; import hep.dataforge.actions.GenericAction; import hep.dataforge.context.Context; +import hep.dataforge.context.DFProcess; +import hep.dataforge.context.ProcessManager.Callback; import hep.dataforge.data.Data; import hep.dataforge.data.DataFilter; import hep.dataforge.data.DataNode; @@ -14,13 +16,13 @@ import hep.dataforge.data.DataSet; import hep.dataforge.data.StaticData; import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.ValueDef; -import hep.dataforge.exceptions.StorageException; import hep.dataforge.meta.Meta; import hep.dataforge.storage.api.Loader; import hep.dataforge.storage.commons.StorageUtils; import inr.numass.storage.NumassData; import inr.numass.storage.NumassDataLoader; import inr.numass.storage.NumassStorage; +import inr.numass.storage.SetDirectionUtility; /** * @@ -38,45 +40,51 @@ public class ReadNumassStorageAction extends GenericAction { NumassStorage storage = NumassStorage.buildNumassRoot(actionMeta.getString("uri"), true, false); DataFilter filter = new DataFilter().configure(actionMeta); - DataSet.Builder builder = DataSet.builder(NumassData.class); - boolean forwardOnly = actionMeta.getBoolean("forwardOnly", false); boolean reverseOnly = actionMeta.getBoolean("reverseOnly", false); - StorageUtils.loaderStream(storage).forEach(pair -> { - Loader loader = pair.getValue(); - if (loader instanceof NumassData) { - NumassDataLoader nd = (NumassDataLoader) loader; - boolean reversed = nd.isReversed(); - if ((reverseOnly && reversed) || (forwardOnly && !reversed) || (!forwardOnly && !reverseOnly)) { + DFProcess> process = context.processManager().>post(getName(), (Callback callback) -> { + //FIXME remove in later revisions + SetDirectionUtility.load(context); + + DataSet.Builder builder = DataSet.builder(NumassData.class); + callback.setMaxProgress(StorageUtils.loaderStream(storage).count()); + StorageUtils.loaderStream(storage).forEach(pair -> { + Loader loader = pair.getValue(); + if (loader instanceof NumassData) { + NumassDataLoader nd = (NumassDataLoader) loader; Data datum = new StaticData<>(nd); if (filter.acceptData(pair.getKey(), datum)) { - builder.putData(pair.getKey(), datum); + boolean accept = true; + if (forwardOnly || reverseOnly) { + boolean reversed = nd.isReversed(); + accept = (reverseOnly && reversed) || (forwardOnly && !reversed); + } + if (accept) { + builder.putData(pair.getKey(), datum); + } } } - } - }); -// DataSet.Builder builder = DataSet.builder(NumassData.class); -// -// StorageUtils.loaderStream(storage).forEach(pair -> { -// Loader loader = pair.getValue(); -// if (loader instanceof NumassData) { -// Data datum = new StaticData<>((NumassData) loader); -// if (filter.acceptData(pair.getKey(), datum)) { -// builder.putData(pair.getKey(), datum); -// } -// } -// }); + callback.increaseProgress(1d); + }); - storage.legacyFiles().forEach(nd -> { - Data datum = new StaticData<>(nd); - if (filter.acceptData(nd.getName(), datum)) { - builder.putData("legacy." + nd.getName(), datum); + if (actionMeta.getBoolean("loadLegacy", false)) { + logger().info("Loading legacy files"); + storage.legacyFiles().forEach(nd -> { + Data datum = new StaticData<>(nd); + if (filter.acceptData(nd.getName(), datum)) { + builder.putData("legacy." + nd.getName(), datum); + } + }); } + //FIXME remove in later revisions + SetDirectionUtility.save(context); + + return builder.build(); }); - return builder.build(); - } catch (StorageException ex) { + return process.getTask().get(); + } catch (Exception ex) { throw new RuntimeException("Failed to load storage", ex); } } diff --git a/numass-main/src/main/java/inr/numass/actions/ShowLossSpectrumAction.java b/numass-main/src/main/java/inr/numass/actions/ShowLossSpectrumAction.java index 45a5ad92..61f37e8c 100644 --- a/numass-main/src/main/java/inr/numass/actions/ShowLossSpectrumAction.java +++ b/numass-main/src/main/java/inr/numass/actions/ShowLossSpectrumAction.java @@ -80,7 +80,7 @@ public class ShowLossSpectrumAction extends OneToOneAction { new MetaBuilder("plot") .setValue("plotTitle", "Differential scattering crossection for " + name) ); - switch (input.getModel().getName()) { + switch (input.getModel().meta().getString("name","")) { case "scatter-variable": scatterFunction = LossCalculator.getSingleScatterFunction(pars); calculateRatio = true; diff --git a/numass-main/src/main/java/inr/numass/models/ModularSpectrum.java b/numass-main/src/main/java/inr/numass/models/ModularSpectrum.java index e8463bfa..f9d9c8f4 100644 --- a/numass-main/src/main/java/inr/numass/models/ModularSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/ModularSpectrum.java @@ -215,12 +215,15 @@ public class ModularSpectrum extends AbstractParametricFunction { } } + /** + * Suppress warnings about cache recalculation + * @param suppress + */ public void setSuppressWarnings(boolean suppress) { this.trappingCache.setSuppressWarnings(suppress); - for (NamedSpectrumCaching sp : this.cacheList) { + this.cacheList.stream().forEach((sp) -> { sp.setSuppressWarnings(suppress); - - } + }); } @Override diff --git a/numass-main/src/main/java/inr/numass/models/NamedSpectrumCaching.java b/numass-main/src/main/java/inr/numass/models/NamedSpectrumCaching.java index 72c46e5b..3d1e7480 100644 --- a/numass-main/src/main/java/inr/numass/models/NamedSpectrumCaching.java +++ b/numass-main/src/main/java/inr/numass/models/NamedSpectrumCaching.java @@ -23,7 +23,6 @@ import hep.dataforge.maths.MathUtils; import hep.dataforge.maths.NamedVector; import hep.dataforge.names.AbstractNamedSet; import hep.dataforge.values.NamedValueSet; -import hep.dataforge.values.ValueProvider; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -108,13 +107,7 @@ public class NamedSpectrumCaching extends AbstractParametricFunction { return source.providesDeriv(name); } - protected boolean sameSet(ValueProvider set1, ValueProvider set2) { -// if((set1 instanceof NamedDoubleSet)&&(set2 instanceof NamedDoubleSet)){ -// double[] v1 = ((NamedDoubleSet)set1).getAllValues(); -// double[] v2 = ((NamedDoubleSet)set2).getAllValues(); -// return Arrays.equals(v1, v2); -// } - + protected boolean sameSet(NamedValueSet set1, NamedValueSet set2) { for (String name : this.names()) { if (!Objects.equals(set1.getDouble(name), set2.getDouble(name))) { return false; diff --git a/numass-main/src/main/java/inr/numass/workbench/NumassWorkbenchController.java b/numass-main/src/main/java/inr/numass/workbench/NumassWorkbenchController.java index 13bbfd1c..a029e3a1 100644 --- a/numass-main/src/main/java/inr/numass/workbench/NumassWorkbenchController.java +++ b/numass-main/src/main/java/inr/numass/workbench/NumassWorkbenchController.java @@ -17,10 +17,10 @@ import hep.dataforge.description.ActionDescriptor; import hep.dataforge.description.DescriptorUtils; import hep.dataforge.exceptions.NameNotFoundException; import hep.dataforge.fx.ConsoleFragment; -import hep.dataforge.fx.FXProcessManager; -import hep.dataforge.fx.LogOutputPane; +import hep.dataforge.fx.FXDataOutputPane; +import hep.dataforge.fx.FXReportListener; import hep.dataforge.fx.configuration.MetaEditor; -import hep.dataforge.fx.ProcessManagerFragment; +import hep.dataforge.fx.process.ProcessManagerFragment; import hep.dataforge.io.IOManager; import hep.dataforge.io.MetaFileReader; import hep.dataforge.meta.ConfigChangeListener; @@ -78,27 +78,24 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder Map stages = new ConcurrentHashMap<>(); - ProcessManagerFragment processWindow = new ProcessManagerFragment(new FXProcessManager()); - ConsoleFragment consoleWindow = new ConsoleFragment(); + ProcessManagerFragment processWindow; + + FXDataOutputPane logPane; @FXML private StatusBar statusBar; @FXML private TabPane stagesPane; @FXML - private TitledPane contextPane; - @FXML - private TitledPane dataPane; - @FXML private Accordion metaContainer; @FXML private Tab logTab; - - LogOutputPane logPane; @FXML private Button runButton; @FXML private ToggleButton consoleButton; + @FXML + private ToggleButton processButton; @Override public void clearStage(String stageName) { @@ -116,11 +113,17 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder */ @Override public void initialize(URL url, ResourceBundle rb) { - logPane = new LogOutputPane(); - logTab.setContent(logPane); + logPane = new FXDataOutputPane(); + logTab.setContent(logPane.getRoot()); + + ConsoleFragment consoleWindow = new ConsoleFragment(); consoleWindow.bindTo(consoleButton); consoleWindow.addRootLogHandler(); consoleWindow.hookStd(); + + processWindow = new ProcessManagerFragment(); + processWindow.bindTo(processButton); + } public Context getContext() { @@ -131,7 +134,13 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder } } + /** + * Setup context for current run + * + * @param config + */ private void buildContext(Meta config) { + // close existing context if (this.context != null) { try { this.context.close(); @@ -139,16 +148,19 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder context.getLogger().error("Failed to close context", ex); } } + // building context using provided factory this.context = this.contextFactory.build(parentContext, config); - context.setIO(new WorkbenchIOManager(new NumassIO(), this)); - processWindow = ProcessManagerFragment.attachToContext(context); - processWindow.setOwner(this.logPane.getScene().getWindow()); - buildContextPane(); - this.logPane.listenTo(context); -// this.logPane.listenTo(context); -// this.logPane.listenTo(GlobalContext.instance().getLogger()); - ((PlotsPlugin) context.provide("plots")).setPlotHolderDelegate(this); + // attachig visual process manager + processWindow.setManager(context.processManager()); + + // setting io manager + context.setIO(new WorkbenchIOManager(new NumassIO(), this)); + buildContextPane(); + context.getReport().addReportListener(new FXReportListener(logPane)); + + // display plots iside workbench + PlotsPlugin.buildFrom(context).setPlotHolderDelegate(this); } private Tab findTabWithName(TabPane pane, String name) { @@ -205,7 +217,8 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder MetaEditor contextEditor = MetaEditor.build(contextValues, null); contextEditor.geTable().setShowRoot(false); - contextPane.setContent(contextEditor); + TitledPane contextPane = new TitledPane("Context", contextEditor); + metaContainer.getPanes().add(contextPane); } public void loadConfig(Meta config) { @@ -224,15 +237,13 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder .putValue("path", fileName)); }); } - } else { - dataConfig = new Configuration("data"); + dataEditor = MetaEditor.build(dataConfig, + DescriptorUtils.buildDescriptor( + DescriptorUtils.findAnnotatedElement("class::hep.dataforge.data.FileDataFactory") + )); + dataEditor.geTable().setShowRoot(false); + metaContainer.getPanes().add(new TitledPane("Data", dataEditor)); } - dataEditor = MetaEditor.build(dataConfig, - DescriptorUtils.buildDescriptor( - DescriptorUtils.findAnnotatedElement("class::hep.dataforge.data.FileDataFactory") - )); - dataEditor.geTable().setShowRoot(false); - dataPane.setContent(dataEditor); //loading actions configuration actionsConfig = new Configuration("actionlist"); @@ -270,8 +281,10 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder */ private synchronized void cleanUp() { //clear previus action panes - processWindow.getManager().cleanup(); - metaContainer.getPanes().removeIf((ap) -> ap.getText().startsWith("action")); + if (processWindow.getManager() != null) { + processWindow.getManager().cleanup(); + } + metaContainer.getPanes().clear(); clearAllStages(); actionsConfig = null; dataConfig = null; @@ -315,17 +328,17 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder } public Meta getDataConfiguration() { - return new MetaBuilder(dataConfig).setContext(getContext()).build(); + return dataConfig == null ? Meta.empty() : new MetaBuilder(dataConfig).substituteValues(getContext()).build(); } public Meta getActionConfiguration() { - return new MetaBuilder(actionsConfig).setContext(getContext()).build(); + return actionsConfig == null ? Meta.empty() : new MetaBuilder(actionsConfig).substituteValues(getContext()).build(); } @SuppressWarnings("unchecked") public void runActions() { clearAllStages(); - processWindow.show(); +// processWindow.show(); new Thread(() -> { DataNode data = new FileDataFactory().build(getContext(), getDataConfiguration()); Platform.runLater(() -> statusBar.setProgress(-1)); @@ -335,7 +348,7 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder } catch (Exception ex) { GlobalContext.instance().getLogger().error("Exception while executing action chain", ex); Platform.runLater(() -> { - ex.printStackTrace(); +// ex.printStackTrace(); statusBar.setText("Execution failed"); Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Exception!"); diff --git a/numass-main/src/main/java/inr/numass/workbench/StagePane.java b/numass-main/src/main/java/inr/numass/workbench/StagePane.java index cc121c8c..606ae271 100644 --- a/numass-main/src/main/java/inr/numass/workbench/StagePane.java +++ b/numass-main/src/main/java/inr/numass/workbench/StagePane.java @@ -5,6 +5,7 @@ */ package inr.numass.workbench; +import hep.dataforge.fx.FXUtils; import hep.dataforge.meta.Meta; import hep.dataforge.names.Named; import hep.dataforge.plots.PlotFrame; @@ -37,28 +38,36 @@ public class StagePane extends TabPane implements Named { } public synchronized void closeTab(String name) { - tabs.get(name).close(); - Platform.runLater(() -> getTabs().remove(tabs.get(name))); - tabs.remove(name); + FXUtils.runNow(() -> { + tabs.get(name).close(); + getTabs().remove(tabs.get(name)); + tabs.remove(name); + }); } public synchronized TextOutputTab buildTextOutput(String name) { - if (tabs.containsKey(name)) { - closeTab(name); - } TextOutputTab out = new TextOutputTab(name); - tabs.put(name, out); - Platform.runLater(() -> getTabs().add(out)); + FXUtils.runNow(() -> { + if (tabs.containsKey(name)) { + tabs.get(name).close(); + getTabs().remove(tabs.get(name)); + tabs.replace(name, out); + } + getTabs().add(out); + }); return out; } public synchronized PlotFrame buildPlotOutput(String name, Meta meta) { - if (tabs.containsKey(name)) { - closeTab(name); - } PlotOutputTab out = new PlotOutputTab("plot::" + name, meta); - tabs.put(name, out); - Platform.runLater(() -> getTabs().add(out)); + FXUtils.runNow(() -> { + if (tabs.containsKey(name)) { + tabs.get(name).close(); + getTabs().remove(tabs.get(name)); + tabs.replace(name, out); + } + getTabs().add(out); + }); return out.getFrame(); } diff --git a/numass-main/src/main/java/inr/numass/workbench/TextOutputTab.java b/numass-main/src/main/java/inr/numass/workbench/TextOutputTab.java index eea655bc..f5f26c3a 100644 --- a/numass-main/src/main/java/inr/numass/workbench/TextOutputTab.java +++ b/numass-main/src/main/java/inr/numass/workbench/TextOutputTab.java @@ -29,7 +29,7 @@ public class TextOutputTab extends OutputTab { super(name); // out = new DataOutputPane(); out = new FXDataOutputPane(); - setContent(out.getHolder()); + setContent(out.getRoot()); setOnClosed((Event event) -> close()); } @@ -44,7 +44,7 @@ public class TextOutputTab extends OutputTab { } public OutputStream getStream() { - return out.getOutputStream(); + return out.getStream(); } } diff --git a/numass-main/src/main/resources/fxml/NumassWorkbench.fxml b/numass-main/src/main/resources/fxml/NumassWorkbench.fxml index c9d03e5e..14bb7411 100644 --- a/numass-main/src/main/resources/fxml/NumassWorkbench.fxml +++ b/numass-main/src/main/resources/fxml/NumassWorkbench.fxml @@ -3,16 +3,16 @@ + - + - @@ -30,35 +30,31 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/numass-storage/src/main/java/inr/numass/storage/SetDirectionUtility.java b/numass-storage/src/main/java/inr/numass/storage/SetDirectionUtility.java index 1bf5a212..2b8af3fd 100644 --- a/numass-storage/src/main/java/inr/numass/storage/SetDirectionUtility.java +++ b/numass-storage/src/main/java/inr/numass/storage/SetDirectionUtility.java @@ -26,7 +26,7 @@ public class SetDirectionUtility { private static final String FILE_NAME = "numass_set_direction.map"; - private static Map directionMap = new HashMap<>(); + private static final Map directionMap = new HashMap<>(); private static boolean isLoaded = false; @@ -45,11 +45,16 @@ public class SetDirectionUtility { context.getLogger().info("Loading set direction utility"); File file = cacheFile(context); if (file.exists()) { - try (ObjectInputStream st = new ObjectInputStream(new FileInputStream(file))) { - directionMap = (Map) st.readObject(); - context.getLogger().info("Set directions successfully loaded from file"); - } catch (ClassNotFoundException | IOException ex) { - context.getLogger().error("Failed to load numass direction mapping", ex); + directionMap.clear(); + try (FileInputStream fst = new FileInputStream(file)) { + try (ObjectInputStream st = new ObjectInputStream(fst)) { + directionMap.putAll((Map) st.readObject()); + context.getLogger().info("Set directions successfully loaded from file"); + } catch (ClassNotFoundException | IOException ex) { + context.getLogger().error("Failed to load numass direction mapping", ex); + } + } catch (IOException ex) { + context.getLogger().error("Failed to load numass direction mapping", ex); } } diff --git a/numass-viewer/src/main/java/inr/numass/viewer/MainViewerController.java b/numass-viewer/src/main/java/inr/numass/viewer/MainViewerController.java index 1eefb069..32eb20f6 100644 --- a/numass-viewer/src/main/java/inr/numass/viewer/MainViewerController.java +++ b/numass-viewer/src/main/java/inr/numass/viewer/MainViewerController.java @@ -20,7 +20,7 @@ import hep.dataforge.context.GlobalContext; import hep.dataforge.context.ProcessManager; import hep.dataforge.exceptions.StorageException; import hep.dataforge.fx.ConsoleFragment; -import hep.dataforge.fx.ProcessManagerFragment; +import hep.dataforge.fx.process.ProcessManagerFragment; import inr.numass.NumassProperties; import inr.numass.storage.NumassData; import inr.numass.storage.NumassStorage;