diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..d988247
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ae3c172
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/.project b/.project
new file mode 100644
index 0000000..43a6c77
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ HELYX-OS
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/README.md b/README.md
index 3c4e70e..e9df699 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,18 @@
# HELYX-OS
-[HELYX-OS](http://engys.com/products/helyx-os) is an open-source Graphical User Interface designed to work natively with OpenFOAM [version 2.4.0](http://www.openfoam.org/archive/2.4.0/download/source.php). The GUI is developed by [ENGYS](http://engys.com/) using Java+[VTK](http://www.vtk.org/) and delivered to the public under the GNU General Public License.
+[HELYX-OS](http://engys.com/products/helyx-os) is an open-source Graphical User Interface designed to work natively with OpenFOAM [version 4.1](http://www.openfoam.org/archive/4.1/download/source.php) and OpenFOAM [v1606+](http://openfoam.com/download/install-binary.php). The GUI is developed by [ENGYS](http://engys.com/) using Java+[VTK](http://www.vtk.org/) and delivered to the public under the GNU General Public License.
HELYX-OS has been created to facilitate the usage of the standard OpenFOAM libraries, by removing the complexity of text based case definition in favour of an intuitive easy-to-use graphical user interface. The GUI is focused on pre-processing tasks, including meshing, case definition and solver execution. Visit the [HELYX-OS Project Page](http://engys.github.io/HELYX-OS/) for more information.
## Installing the latest binary file for 64 bit linux
Visit [http://engys.github.io/HELYX-OS/](http://engys.github.io/HELYX-OS/) to download the latest HELYX-OS binary and view [installation instructions](http://engys.github.io/HELYX-OS/installation/).
+## Configuring HELYX-OS for OpenFOAM v1606+
+To use OpenFOAM v1606+ installed via Docker following the instructions detailed [here](http://openfoam.com/download/install-binary.php) you need to do the following:
+ - Open HELYX-OS
+ - Go to Edit>Preferences
+ - In the "Misc" section check the "Use Docker" tick box and then type "openfoamplus/of_v1606plus_centos66" in the "Docker Image" textbox
+ - Press "OK" to apply settings
+
## Compiling HELYX-OS on your own
### Prerequisites
diff --git a/build_src.xml b/build_src.xml
index b5a4d2d..de4a44f 100644
--- a/build_src.xml
+++ b/build_src.xml
@@ -1,22 +1,20 @@
-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
+
@@ -29,24 +27,27 @@
-
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
@@ -54,7 +55,6 @@
-
@@ -64,7 +64,7 @@
-
+
@@ -73,25 +73,11 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/eu/engys/application/AbstractApplication.java b/src/eu/engys/application/AbstractApplication.java
index b8c087f..a13b01f 100644
--- a/src/eu/engys/application/AbstractApplication.java
+++ b/src/eu/engys/application/AbstractApplication.java
@@ -1,32 +1,30 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.application;
-import static eu.engys.launcher.StartUpMonitor.close;
+import static eu.engys.launcher.StartUpMonitor.closeSplash;
import java.awt.BorderLayout;
import java.awt.Dimension;
@@ -37,6 +35,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Arrays;
+import java.util.Set;
import javax.swing.AbstractAction;
import javax.swing.Icon;
@@ -51,202 +50,205 @@ import org.slf4j.LoggerFactory;
import eu.engys.core.Arguments;
import eu.engys.core.OpenFOAMEnvironment;
import eu.engys.core.controller.Controller;
-import eu.engys.core.presentation.ActionContainer;
+import eu.engys.core.controller.Controller.OpenMode;
+import eu.engys.core.controller.OpenOptions;
+import eu.engys.core.modules.ApplicationModule;
import eu.engys.core.presentation.ActionManager;
import eu.engys.core.project.Model;
import eu.engys.gui.AboutWindow;
import eu.engys.gui.GlassPane;
+import eu.engys.gui.PreferencesBean;
import eu.engys.gui.PreferencesDialog;
import eu.engys.gui.events.EventManager;
import eu.engys.gui.view.View;
import eu.engys.gui.view3D.View3DEventListener;
+import eu.engys.util.ui.ExecUtil;
import eu.engys.util.ui.ResourcesUtil;
import eu.engys.util.ui.UiUtil;
-public abstract class AbstractApplication implements Application, ActionContainer {
+public abstract class AbstractApplication implements Application {
- private static final Logger logger = LoggerFactory.getLogger(AbstractApplication.class);
+ private static final Logger logger = LoggerFactory.getLogger(AbstractApplication.class);
- protected JFrame frame;
- public View view;
- protected Model model;
- public Controller controller;
- protected View3DEventListener view3dListener;
+ protected JFrame frame;
+ public View view;
+ protected Model model;
+ public Controller controller;
+ protected View3DEventListener view3dListener;
- public AbstractApplication(Model model, View view, Controller controller) {
- this.model = model;
- this.view = view;
- this.controller = controller;
- }
+ protected Set modules;
- @Override
- public JFrame getFrame() {
- return frame;
- }
-
- @Override
- public boolean isDemo() {
- return false;
- }
-
- @Override
- public void checkVersion() {
- }
+ public AbstractApplication(Model model, Set modules, View view, Controller controller) {
+ this.model = model;
+ this.modules = modules;
+ this.view = view;
+ this.controller = controller;
+ }
- @Override
- public void run() {
- initFrame();
- frame.setVisible(true);
- trySettingOpenFoamFolder();
+ @Override
+ public JFrame getFrame() {
+ return frame;
+ }
- if (Arguments.stlFiles != null) {
- if (Arguments.baseDir != null) {
- ActionManager.getInstance().invoke("application.open");
- } else {
- ActionManager.getInstance().invoke("application.create");
- }
- } else {
- if (Arguments.baseDir != null) {
- controller.openCase(Arguments.baseDir);
- } else {
- view.showStartupDialog(this);
- }
- }
- close();
- }
+ @Override
+ public void checkVersion() {
+ }
- protected void trySettingOpenFoamFolder() {
- OpenFOAMEnvironment.trySettingOpenFoamFolder(frame);
- }
+ @Override
+ public void start(final Arguments arguments) {
+ ExecUtil.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ initFrame();
+ frame.setVisible(true);
+ trySettingOpenFoamFolder();
- @Override
- public void initFrame() {
- view.layoutComponents();
- frame = new JFrame(getTitle()) {
- @Override
- public void dispose() {
- EventManager.unregisterAllEventSubscriptions();
- super.dispose();
- }
+ executeStartupActions(arguments);
- /**
- * This method fixes the Synthetica laf bug that causes incorrect
- * fullscreen window size on secondary monitor.
- */
- @Override
- public void setMaximizedBounds(Rectangle bounds) {
- GraphicsDevice currentFrame = getGraphicsConfiguration().getDevice();
- if (UiUtil.isSecondaryScreen(currentFrame) && getExtendedState() == JFrame.NORMAL) {
- super.setMaximizedBounds(UiUtil.getCurrentScreenSize(frame));
- } else {
- super.setMaximizedBounds(bounds);
- }
- }
- };
- view.setProgressMonitorParent(frame);
+ closeSplash();
+ }
+ });
+ }
- Dimension preferredDimension = UiUtil.getPreferredScreenSize();
- logger.info("Set dimendions to {}", preferredDimension);
- frame.setSize(preferredDimension);
- frame.setLocationRelativeTo(null);
-
- UiUtil.center(frame);
+ protected void executeStartupActions(Arguments arguments) {
+ if (arguments.baseDir != null) {
+ controller.openCase(OpenOptions.file(arguments.baseDir, OpenMode.CHECK_FOLDER_ASK_USER));
+ } else {
+ view.showStartupDialog(this);
+ }
+ }
- frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+ protected void trySettingOpenFoamFolder() {
+ OpenFOAMEnvironment.trySettingOpenFoamFolder(frame);
+ }
- frame.setIconImages(Arrays.asList(new Image[] { ((ImageIcon) getSmallIcon()).getImage(), ((ImageIcon) getBigIcon()).getImage() }));
+ @Override
+ public void initFrame() {
+ view.layoutComponents();
+ frame = new JFrame(getTitle()) {
+ @Override
+ public void dispose() {
+ EventManager.unregisterAllEventSubscriptions();
+ super.dispose();
+ }
- frame.addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- ActionManager.getInstance().invoke("application.exit");
- }
- });
- frame.setName("MainFrame");
- frame.getRootPane().updateUI();
- frame.setJMenuBar(view.getMenuBar());
+ /**
+ * This method fixes the Synthetica laf bug that causes incorrect fullscreen window size on secondary monitor.
+ */
+ @Override
+ public void setMaximizedBounds(Rectangle bounds) {
+ GraphicsDevice currentFrame = getGraphicsConfiguration().getDevice();
+ if (UiUtil.isSecondaryScreen(currentFrame) && getExtendedState() == JFrame.NORMAL) {
+ super.setMaximizedBounds(UiUtil.getCurrentScreenSize(this));
+ } else {
+ super.setMaximizedBounds(bounds);
+ }
+ }
+ };
+ view.setProgressMonitorParent(frame);
- frame.getContentPane().setLayout(new BorderLayout());
- frame.getContentPane().add(view, BorderLayout.CENTER);
- frame.getContentPane().add(view.getStatusBar(), BorderLayout.SOUTH);
-
- GlassPane glassPane = new GlassPane();
- frame.setGlassPane(glassPane);
- glassPane.setVisible(false);
-
+ Dimension preferredDimension = UiUtil.getPreferredScreenSize();
+ logger.info("Set dimendions to {}", preferredDimension);
+ frame.setSize(preferredDimension);
+ frame.setLocationRelativeTo(null);
- customizeGUIFrame(view);
- }
+ UiUtil.center(frame);
- public View getView() {
- return view;
- }
+ frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
- public Model getModel() {
- return model;
- }
+ frame.setIconImages(Arrays.asList(new Image[] { ((ImageIcon) getSmallIcon()).getImage(), ((ImageIcon) getBigIcon()).getImage() }));
- public abstract String getTitle();
+ frame.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ ActionManager.getInstance().invoke(View.EXIT);
+ }
+ });
+ frame.setName("MainFrame");
+ frame.getRootPane().updateUI();
+ frame.setJMenuBar(view.getMenuBar());
- protected abstract void customizeGUIFrame(View view);
+ frame.getContentPane().setLayout(new BorderLayout());
+ frame.getContentPane().add(view, BorderLayout.CENTER);
+ frame.getContentPane().add(view.getStatusBar(), BorderLayout.SOUTH);
- protected void addPreferencesItem(final View view) {
- JMenuItem preferencesItem = new JMenuItem(new AbstractAction("Preferences", PREFERENCES_ICON) {
- @Override
- public void actionPerformed(ActionEvent e) {
- new PreferencesDialog(isOS(), hasParaview(), hasFieldView(), hasEnsight(), hasSolverPreferences(), model.getDefaults().getDictDataFolder()).show();
- }
- });
- preferencesItem.setName("Application Preferences");
- view.getMenuBar().getEditMenu().add(preferencesItem);
- }
+ GlassPane glassPane = new GlassPane();
+ frame.setGlassPane(glassPane);
+ glassPane.setVisible(false);
- protected abstract boolean hasParaview();
+ customizeGUIFrame(view);
+ }
- protected abstract boolean hasFieldView();
+ public View getView() {
+ return view;
+ }
- protected abstract boolean hasEnsight();
+ public Model getModel() {
+ return model;
+ }
- protected boolean hasSolverPreferences() {
- return true;
- }
+ public abstract String getTitle();
- protected boolean isOS() {
- return false;
- }
+ protected abstract void customizeGUIFrame(View view);
- protected void addHelpItem(final View view) {
- view.getMenuBar().getHelpMenu().add(new AbstractAction("About", INFO_ICON) {
- @Override
- public void actionPerformed(ActionEvent e) {
- new AboutWindow(getMediumIcon(), getBannerIcon());
- }
- });
- }
+ protected void addPreferencesItem(final View view) {
+ JMenuItem preferencesItem = new JMenuItem(new AbstractAction(PREFERENCES_LABEL, PREFERENCES_ICON) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (controller.isDemo()) {
+ UiUtil.showDemoMessage();
+ } else {
+ new PreferencesDialog(getPreferencesBean(), model.getDefaults().getDictDataFolder()).show();
+ }
+ }
+ });
+ preferencesItem.setName("Application Preferences");
+ view.getMenuBar().getEditMenu().add(preferencesItem);
+ }
-
- @Override
- public JPanel createAdPanel() {
- return new JPanel();
- }
+ protected abstract PreferencesBean getPreferencesBean();
- @Override
- public JPanel createVersionPanel() {
- return new JPanel();
- }
-
- /**
- * RESOURCES
- */
+ protected void addHelpItem(final View view) {
+ view.getMenuBar().getHelpMenu().add(new AbstractAction("About", INFO_ICON) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ new AboutWindow(getMediumIcon(), getBannerIcon());
+ }
+ });
+ }
- public static final Icon PREFERENCES_ICON = ResourcesUtil.getIcon("preferences.icon");
- public static final Icon LICENSE_ICON = ResourcesUtil.getIcon("license.icon");
- public static final Icon INFO_ICON = ResourcesUtil.getIcon("info.icon");
- public static final Icon PDF_ICON = ResourcesUtil.getIcon("file.pdf");
- public static final Icon FOLDER_ICON = ResourcesUtil.getIcon("application.open.icon");
+ @Override
+ public JPanel createAdPanel() {
+ return new JPanel();
+ }
- public static final Icon SMALL_LOGO = ResourcesUtil.getIcon("engys.logo");
- public static final Icon BIG_LOGO = ResourcesUtil.getIcon("engys.logo.big");
- public static final Icon MEDIUM_LOGO = ResourcesUtil.getIcon("engys.logo.medium");
- public static final Icon FULL_LOGO = ResourcesUtil.getIcon("engys.logo.full");
+ @Override
+ public JPanel createVersionPanel() {
+ return new JPanel();
+ }
+
+ /*
+ * RESOURCES
+ */
+
+ public static final String PREFERENCES_LABEL = "Preferences";
+ public static final Icon PREFERENCES_ICON = ResourcesUtil.getIcon("preferences.icon");
+
+ public static final String LICENSE_MANAGER_LABEL = "License Manager";
+ public static final Icon LICENSE_MANAGER_ICON = ResourcesUtil.getIcon("license.icon");
+
+ public static final String RELEASE_NOTES_LABEL = "Release Notes";
+ public static final String RELEASE_NOTES_WARNING_MESSAGE = "Release notes not found or not installed";
+
+ public static final String DOCUMENTATION_LABEL = "Documentation";
+ public static final Icon DOCUMENTATION_ICON = ResourcesUtil.getIcon("file.pdf");
+ public static final String DOCUMENTATION_WARNING_MESSAGE = "Documentation not found or not installed";
+
+ public static final Icon INFO_ICON = ResourcesUtil.getIcon("info.icon");
+ public static final Icon FOLDER_ICON = ResourcesUtil.getIcon("application.open.icon");
+
+ public static final Icon SMALL_LOGO = ResourcesUtil.getIcon("engys.logo");
+ public static final Icon BIG_LOGO = ResourcesUtil.getIcon("engys.logo.big");
+ public static final Icon MEDIUM_LOGO = ResourcesUtil.getIcon("engys.logo.medium");
+ public static final Icon FULL_LOGO = ResourcesUtil.getIcon("engys.logo.full");
}
diff --git a/src/eu/engys/application/AdPanel.java b/src/eu/engys/application/AdPanel.java
index ecba263..fc85e94 100644
--- a/src/eu/engys/application/AdPanel.java
+++ b/src/eu/engys/application/AdPanel.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.application;
import java.awt.BorderLayout;
diff --git a/src/eu/engys/application/Application.java b/src/eu/engys/application/Application.java
index 41278b3..733dc48 100644
--- a/src/eu/engys/application/Application.java
+++ b/src/eu/engys/application/Application.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.application;
@@ -30,8 +29,12 @@ import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.JPanel;
-public interface Application extends Runnable {
+import eu.engys.core.Arguments;
+public interface Application {
+
+ public void start(Arguments arguments);
+
public JFrame getFrame();
public void initFrame();
diff --git a/src/eu/engys/application/ApplicationEventListener.java b/src/eu/engys/application/ApplicationEventListener.java
index 21dec04..a0b38a7 100644
--- a/src/eu/engys/application/ApplicationEventListener.java
+++ b/src/eu/engys/application/ApplicationEventListener.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.application;
diff --git a/src/eu/engys/application/Batch.java b/src/eu/engys/application/Batch.java
index 66e8147..5555594 100644
--- a/src/eu/engys/application/Batch.java
+++ b/src/eu/engys/application/Batch.java
@@ -1,35 +1,37 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.application;
+import eu.engys.core.Arguments;
+
+public interface Batch {
-public interface Batch extends Runnable {
-
public abstract String getTitle();
-}
+ public abstract void start(Arguments arguments);
+ public abstract void checkLicense();
+
+}
diff --git a/src/eu/engys/application/HELYXOS.java b/src/eu/engys/application/HELYXOS.java
index 3e70ead..2c15ac7 100644
--- a/src/eu/engys/application/HELYXOS.java
+++ b/src/eu/engys/application/HELYXOS.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.application;
import java.awt.Color;
@@ -31,6 +30,7 @@ import java.awt.Font;
import java.awt.event.ActionEvent;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Set;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
@@ -46,16 +46,17 @@ import com.google.inject.Inject;
import eu.engys.core.OpenFOAMEnvironment;
import eu.engys.core.controller.Controller;
-import eu.engys.core.presentation.Action;
-import eu.engys.core.presentation.ActionManager;
+import eu.engys.core.modules.ApplicationModule;
import eu.engys.core.project.Model;
import eu.engys.core.project.zero.patches.BoundaryType;
+import eu.engys.gui.PreferencesBean;
import eu.engys.gui.view.View;
import eu.engys.util.ApplicationInfo;
import eu.engys.util.Symbols;
import eu.engys.util.Util;
import eu.engys.util.VersionChecker;
import eu.engys.util.VersionChecker.VersionType;
+import eu.engys.util.ui.ExecUtil;
import eu.engys.util.ui.ResourcesUtil;
public class HELYXOS extends AbstractApplication {
@@ -67,9 +68,8 @@ public class HELYXOS extends AbstractApplication {
private JButton versionButton;
@Inject
- public HELYXOS(Model model, View view, Controller controller) {
- super(model, view, controller);
- ActionManager.getInstance().parseActions(this);
+ public HELYXOS(Model model, Set modules, View view, Controller controller) {
+ super(model, modules, view, controller);
BoundaryType.registerBoundaryType(BoundaryType.PATCH);
BoundaryType.registerBoundaryType(BoundaryType.WALL);
@@ -107,7 +107,6 @@ public class HELYXOS extends AbstractApplication {
});
}
- @Action(key = "application.support.window")
public void showSupportWindow() {
new SupportWindow(getMediumIcon(), getBannerIcon(), DISCLAIMER);
}
@@ -117,19 +116,23 @@ public class HELYXOS extends AbstractApplication {
new Thread(new Runnable() {
@Override
public void run() {
- VersionType versionType = VersionChecker.isNewVersionAvailable();
- if (versionType.isUpdated()) {
- versionLabel.setText("Your version is up to date!");
- versionLabel.setForeground(Color.GREEN.darker());
- versionButton.setVisible(false);
- } else if (versionType.isOld()) {
- versionLabel.setText("Version " + VersionChecker.getOnlineVersion() + " is available for download!");
- versionLabel.setForeground(Color.RED);
- versionButton.setVisible(true);
- } else if (versionType.isNotAvailable()) {
- versionLabel.setText("Version not available!");
- versionButton.setVisible(false);
- }
+ final VersionType versionType = VersionChecker.isNewVersionAvailable();
+ ExecUtil.invokeLater(new Runnable() {
+ public void run() {
+ if (versionType.isUpdated()) {
+ versionLabel.setText("Your version is up to date!");
+ versionLabel.setForeground(Color.GREEN.darker());
+ versionButton.setVisible(false);
+ } else if (versionType.isOld()) {
+ versionLabel.setText("Version " + VersionChecker.getOnlineVersion() + " is available for download!");
+ versionLabel.setForeground(Color.RED);
+ versionButton.setVisible(true);
+ } else if (versionType.isNotAvailable()) {
+ versionLabel.setText("Version not available!");
+ versionButton.setVisible(false);
+ }
+ }
+ });
}
}).start();
}
@@ -162,23 +165,18 @@ public class HELYXOS extends AbstractApplication {
}
@Override
- protected boolean isOS() {
- return true;
- }
-
- @Override
- protected boolean hasParaview() {
- return true;
- }
-
- @Override
- protected boolean hasFieldView() {
- return false;
- }
-
- @Override
- protected boolean hasEnsight() {
- return false;
+ protected PreferencesBean getPreferencesBean() {
+ PreferencesBean bean = new PreferencesBean();
+ bean.setPathPreferences(true);
+ bean.setBatchPreferences(false);
+ bean.setVtkPreferences(true);
+ bean.setMiscPreferences(true);
+ bean.setParaview(true);
+ bean.setParaviewBatch(false);
+ bean.setEnsight(false);
+ bean.setFieldview(false);
+ bean.setOS(true);
+ return bean;
}
@Override
diff --git a/src/eu/engys/application/SupportWindow.java b/src/eu/engys/application/SupportWindow.java
index 946395d..9ab8a31 100644
--- a/src/eu/engys/application/SupportWindow.java
+++ b/src/eu/engys/application/SupportWindow.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.application;
diff --git a/src/eu/engys/application/modules/HELYXOSModule.java b/src/eu/engys/application/modules/HELYXOSModule.java
index 68a9b81..414c9df 100644
--- a/src/eu/engys/application/modules/HELYXOSModule.java
+++ b/src/eu/engys/application/modules/HELYXOSModule.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.application.modules;
import com.google.inject.AbstractModule;
@@ -32,7 +31,6 @@ import com.google.inject.name.Names;
import eu.engys.application.Application;
import eu.engys.application.HELYXOS;
-import eu.engys.core.Arguments;
import eu.engys.core.controller.Controller;
import eu.engys.core.controller.HelyxOSController;
import eu.engys.core.controller.ScriptFactory;
@@ -65,12 +63,13 @@ import eu.engys.gui.casesetup.CaseSetup;
import eu.engys.gui.casesetup.CaseSetup3DElement;
import eu.engys.gui.casesetup.CaseSetupElement;
import eu.engys.gui.casesetup.RuntimeControlsPanel;
+import eu.engys.gui.casesetup.StandardSolverSettingsPanel;
import eu.engys.gui.casesetup.actions.StandardCaseSetupActions;
-import eu.engys.gui.casesetup.boundaryconditions.BoundaryConditionsPanel;
-import eu.engys.gui.casesetup.boundaryconditions.panels.CyclicSettingsPanel;
+import eu.engys.gui.casesetup.boundaryconditions.panels.BoundaryConditionsPanel;
import eu.engys.gui.casesetup.boundaryconditions.panels.StandardCyclicAMISettingsPanel;
import eu.engys.gui.casesetup.boundaryconditions.panels.patch.PatchSettingsPanel;
import eu.engys.gui.casesetup.boundaryconditions.panels.wall.StandardWallSettingsPanel;
+import eu.engys.gui.casesetup.boundaryconditions.parameterspanel.CyclicSettingsPanel;
import eu.engys.gui.casesetup.cellzones.CellZonesPanel;
import eu.engys.gui.casesetup.cellzones.StandardCellZonesBuilder;
import eu.engys.gui.casesetup.cellzones.mrf.StandardMRF;
@@ -89,13 +88,12 @@ import eu.engys.gui.casesetup.materials.panels.MaterialsPanel;
import eu.engys.gui.casesetup.run.StandardTable15;
import eu.engys.gui.casesetup.schemes.NumericalSchemesPanel;
import eu.engys.gui.casesetup.solution.StandardSolutionModellingPanel;
-import eu.engys.gui.casesetup.solver.SolverSettingsPanel;
import eu.engys.gui.custom.CustomNodePanel;
import eu.engys.gui.mesh.Mesh;
import eu.engys.gui.mesh.Mesh3DElement;
import eu.engys.gui.mesh.MeshElement;
+import eu.engys.gui.mesh.StandardBoundaryMeshPanel;
import eu.engys.gui.mesh.actions.StandardMeshActions;
-import eu.engys.gui.mesh.panels.DefaultBoundaryMeshPanel;
import eu.engys.gui.mesh.panels.DefaultMeshAdvancedOptionsPanel;
import eu.engys.gui.mesh.panels.MaterialPointsPanel;
import eu.engys.gui.mesh.panels.SolverBoundaryMeshPanel;
@@ -113,26 +111,18 @@ import eu.engys.gui.solver.postprocessing.panels.residuals.ResidualsPanel;
import eu.engys.gui.view.View;
import eu.engys.gui.view.View3DElement;
import eu.engys.gui.view.ViewElement;
-import eu.engys.gui.view3D.CanvasPanel;
import eu.engys.gui.view3D.Controller3D;
import eu.engys.gui.view3D.Geometry3DController;
import eu.engys.gui.view3D.Mesh3DController;
-import eu.engys.gui.view3D.fallback.FallbackGeometry3DController;
-import eu.engys.gui.view3D.fallback.FallbackMesh3DController;
-import eu.engys.gui.view3D.fallback.FallbackView3D;
import eu.engys.gui.view3D.widget.Widget;
import eu.engys.launcher.ApplicationLauncher;
import eu.engys.launcher.HELYXOSLauncher;
+import eu.engys.standardDynamic.StandardDynamicModule;
import eu.engys.standardVOF.StandardVOFModule;
-import eu.engys.util.VTKSettings;
import eu.engys.util.plaf.HelyxOSLookAndFeel;
import eu.engys.util.plaf.ILookAndFeel;
import eu.engys.util.progress.ProgressMonitor;
import eu.engys.util.progress.ProgressMonitorImpl;
-import eu.engys.vtk.VTKEmptyView3D;
-import eu.engys.vtk.VTKGeometry3DController;
-import eu.engys.vtk.VTKMesh3DController;
-import eu.engys.vtk.VTKView3D;
import eu.engys.vtk.WidgetPanel;
public class HELYXOSModule extends AbstractModule {
@@ -184,27 +174,11 @@ public class HELYXOSModule extends AbstractModule {
private void configureModules() {
Multibinder applicationModules = Multibinder.newSetBinder(binder(), ApplicationModule.class);
applicationModules.addBinding().to(StandardVOFModule.class).in(Singleton.class);
+ applicationModules.addBinding().to(StandardDynamicModule.class).in(Singleton.class);
}
protected void configure3D() {
bind(WidgetPanel.class).in(Singleton.class);
- if (!VTKSettings.librariesAreLoaded()) {
- VTKSettings.LoadAllNativeLibraries();
- }
- if (VTKSettings.librariesAreLoaded()) {
- if (Arguments.no3D) {
- bind(CanvasPanel.class).to(VTKEmptyView3D.class).in(Singleton.class);
- } else {
- bind(CanvasPanel.class).to(VTKView3D.class).in(Singleton.class);
- }
- bind(Geometry3DController.class).to(VTKGeometry3DController.class).in(Singleton.class);
- bind(Mesh3DController.class).to(VTKMesh3DController.class).in(Singleton.class);
- } else {
- bind(CanvasPanel.class).to(FallbackView3D.class).in(Singleton.class);
- bind(Geometry3DController.class).to(FallbackGeometry3DController.class).in(Singleton.class);
- bind(Mesh3DController.class).to(FallbackMesh3DController.class).in(Singleton.class);
- }
-
Multibinder controllers = Multibinder.newSetBinder(binder(), Controller3D.class);
controllers.addBinding().to(Geometry3DController.class).in(Singleton.class);
controllers.addBinding().to(Mesh3DController.class).in(Singleton.class);
@@ -242,7 +216,7 @@ public class HELYXOSModule extends AbstractModule {
panelsMesh.addBinding().to(StandardGeometryPanel.class).in(Singleton.class);
panelsMesh.addBinding().to(StandardFeatureLinesPanel.class).in(Singleton.class);
panelsMesh.addBinding().to(MaterialPointsPanel.class).in(Singleton.class);
- panelsMesh.addBinding().to(DefaultBoundaryMeshPanel.class).in(Singleton.class);
+ panelsMesh.addBinding().to(StandardBoundaryMeshPanel.class).in(Singleton.class);
panelsMesh.addBinding().to(CustomNodePanel.class).in(Singleton.class);
Multibinder panelsCaseSetup = Multibinder.newSetBinder(binder(), GUIPanel.class, CaseSetup.class);
@@ -250,8 +224,9 @@ public class HELYXOSModule extends AbstractModule {
panelsCaseSetup.addBinding().to(MaterialsPanel.class).in(Singleton.class);
panelsCaseSetup.addBinding().to(BoundaryConditionsPanel.class).in(Singleton.class);
panelsCaseSetup.addBinding().to(CellZonesPanel.class).in(Singleton.class);
+// panelsCaseSetup.addBinding().to(FaceZonesPanel.class).in(Singleton.class);
panelsCaseSetup.addBinding().to(NumericalSchemesPanel.class).in(Singleton.class);
- panelsCaseSetup.addBinding().to(SolverSettingsPanel.class).in(Singleton.class);
+ panelsCaseSetup.addBinding().to(StandardSolverSettingsPanel.class).in(Singleton.class);
panelsCaseSetup.addBinding().to(RuntimeControlsPanel.class).in(Singleton.class);
panelsCaseSetup.addBinding().to(StandardFieldsInitialisationPanel.class).in(Singleton.class);
panelsCaseSetup.addBinding().to(CustomNodePanel.class).in(Singleton.class);
diff --git a/src/eu/engys/core/Arguments.java b/src/eu/engys/core/Arguments.java
index 90ca5a5..04c418b 100644
--- a/src/eu/engys/core/Arguments.java
+++ b/src/eu/engys/core/Arguments.java
@@ -1,33 +1,33 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core;
import java.io.File;
import java.io.FilenameFilter;
+import java.io.IOException;
+import java.nio.file.Paths;
import org.apache.log4j.Level;
@@ -36,197 +36,237 @@ import eu.engys.util.Util;
public class Arguments {
- private static final String LINE = " ********************************";
- private static final String TAB = " ";
+ private static final String LINE = " ********************************";
+ private static final String TAB = " ";
- public enum CaseType {
- SERIAL, PARALLEL
- }
+ public boolean verbose = false;
+ public boolean no3D = false;
+ public boolean load3Dmesh = true;
+ public boolean load3Dgeometry = true;
+ public Level logLevel = Level.ERROR;
- public static boolean verbose = false;
- public static boolean no3D = false;
- public static boolean load3Dmesh = true;
- public static boolean load3Dgeometry = true;
- public static Level logLevel = Level.ERROR;
+ public File baseDir = null;
+ public File studyDir = null;
- public static File baseDir = null;
+ public boolean mesh = false;
+ public boolean run = false;
+ public boolean setup = false;
+ public boolean all = false;
+ public boolean initialise = false;
+ public boolean post = false;
- public static boolean mesh = false;
- public static boolean run = false;
- public static boolean setup = false;
- public static boolean all = false;
- public static boolean initialise = false;
+ public int concurrentDesigns = 1;
- public static boolean server = false;
- public static CaseType caseType = null;
- public static File[] stlFiles = null;
-// public static long timeout = -1L;
+ public boolean server = false;
+ public File[] importFiles = null;
- private static final String OPTION_V = "-v";
- private static final String OPTION_VV = "-V";
- private static final String OPTION_HELP = "-help";
- private static final String OPTION_NO3D = "-no3D";
- private static final String OPTION_CASE = "-case";
-
- public static final String OPTION_MESH = "-mesh";
- public static final String OPTION_RUN = "-run";
- public static final String OPTION_SETUP = "-setup";
- public static final String OPTION_ALL = "-all";
- public static final String OPTION_INITIALISE = "-initialise";
+ private static final String OPTION_V = "-v";
+ private static final String OPTION_VV = "-V";
+ private static final String OPTION_HELP = "-help";
+ private static final String OPTION_NO3D = "-no3D";
+ private static final String OPTION_CASE = "-case";
+ private static final String OPTION_STUDY = "-study";
- private static final String OPTION_SERVER = "-server"; /* INTERNAL */
- private static final String OPTION_IMPORT = "-import"; /* INTERNAL */
- private static final String OPTION_NOMESH = "-no3Dmesh"; /* INTERNAL */
- private static final String OPTION_NOGEOM = "-no3DGeom"; /* INTERNAL */
-// private static final String OPTION_CORE = "-core"; /* INTERNAL */
-// private static final String OPTION_TIMEOUT = "-timeout"; /* INTERNAL */
+ public static final String OPTION_MESH = "-mesh";
+ public static final String OPTION_RUN = "-run";
+ public static final String OPTION_SETUP = "-setup";
+ public static final String OPTION_ALL = "-all";
+ public static final String OPTION_INITIALISE = "-initialise";
+ public static final String OPTION_POST = "-post";
+ public static final String OPTION_MEMORY = "-memory=";
- public static void init(final String[] argv) {
- for (int i = 0; i < argv.length; i++) {
- final String arg = argv[i];
+ public static final String OPTION_CONCURRENT_DESIGNS = "-concurrent";
- if (arg.charAt(0) == '-') {
- switch (arg) {
+ private static final String OPTION_SERVER = "-server"; /* INTERNAL */
+ private static final String OPTION_IMPORT = "-import"; /* INTERNAL */
+ private static final String OPTION_NOMESH = "-no3Dmesh"; /* INTERNAL */
+ private static final String OPTION_NOGEOM = "-no3DGeom"; /* INTERNAL */
+
+ // private static final String OPTION_CORE = "-core"; /* INTERNAL */
+ // private static final String OPTION_TIMEOUT = "-timeout"; /* INTERNAL */
+
+ public void parse(final String[] argv) {
+ for (int i = 0; i < argv.length; i++) {
+ final String arg = argv[i];
+
+ if (arg.charAt(0) == '-') {
+ switch (arg) {
case OPTION_V: logLevel = Level.INFO; verbose = true; break;
case OPTION_VV: logLevel = Level.DEBUG; verbose = true; break;
case OPTION_NO3D: no3D = true; break;
-
- case OPTION_CASE:
- if (i == argv.length - 1) {
- fatal("Missing case folder");
- printUsage();
- exit(-1);
- }
- String baseDirPath = argv[++i];
- final File baseDir = new File(baseDirPath);
- if (!baseDir.exists()) {
- warning("Case Folder \"" + baseDir.getAbsolutePath() + "\" Does Not Exist!");
- } else {
- Arguments.baseDir = baseDir;
- }
- break;
-
- case OPTION_MESH: mesh = true; break;
- case OPTION_RUN: run = true; break;
- case OPTION_SETUP: setup = true; break;
- case OPTION_ALL: all = true; break;
- case OPTION_INITIALISE: initialise = true; break;
- case OPTION_SERVER: server = true; break;
-
+
+ case OPTION_CASE:
+ if (i == argv.length - 1) {
+ fatal("Missing case folder");
+ printUsage();
+ exit(-1);
+ }
+ String baseDirPath = argv[++i];
+ try {
+ /*
+ * Use toRealPath to avoid bad path display when using "." and ".."
+ */
+ File baseDir = Paths.get(baseDirPath).toRealPath().toFile();
+ if (!baseDir.exists()) {
+ warning("Case Folder \"" + baseDir.getAbsolutePath() + "\" Does Not Exist!");
+ } else {
+ this.baseDir = baseDir;
+ }
+ } catch (IOException e) {
+ warning(e.getMessage());
+ }
+
+ break;
+ case OPTION_STUDY:
+ if (i == argv.length - 1) {
+ fatal("Missing study folder");
+ printUsage();
+ exit(-1);
+ }
+ String studyDirPath = argv[++i];
+ final File studyDir = new File(studyDirPath);
+ if (!studyDir.exists()) {
+ warning("Case Folder \"" + studyDir.getAbsolutePath() + "\" Does Not Exist!");
+ } else {
+ this.studyDir = studyDir;
+ }
+ break;
+
+ case OPTION_MESH: this.mesh = true; break;
+ case OPTION_RUN: this.run = true; break;
+ case OPTION_SETUP: this.setup = true; break;
+ case OPTION_ALL: this.all = true; break;
+ case OPTION_INITIALISE: this.initialise = true; break;
+ case OPTION_POST: this.post = true; break;
+ case OPTION_SERVER: this.server = true; break;
+
+ case OPTION_CONCURRENT_DESIGNS:
+ if (i == argv.length - 1) {
+ fatal("Missing number of concurrent designs folder");
+ printUsage();
+ exit(-1);
+ }
+ String designs = argv[++i];
+ try {
+ int nDesigns = Integer.parseInt(designs);
+ this.concurrentDesigns = nDesigns;
+ } catch (NumberFormatException nfe) {
+ warning("Invalid number of concurrent designs");
+ }
+ break;
case OPTION_NOGEOM: load3Dgeometry = false; break;
case OPTION_NOMESH: load3Dmesh = false; break;
-
- case OPTION_IMPORT:
- if (i == argv.length - 1) {
- fatal("Missing import folder");
- printUsage();
- exit(-1);
- }
- String importPath = argv[++i];
- final File importFolder = new File(importPath);
- if (!importFolder.exists()) {
- fatal("Import Folder Does Not Exist!");
- exit(-1);
- } else if (importFolder.isFile()) {
- String name = importFolder.getName();
- if (name.endsWith("stl") || name.endsWith("STL")) {
- Arguments.stlFiles = new File[]{importFolder};
- } else {
- fatal("Import Folder Does Not Exist!");
- exit(-1);
- }
- } else {
- File[] stls = importFolder.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.endsWith("stl") || name.endsWith("STL");
- }
- });
- if (stls.length == 0) {
- fatal("No files to import!");
- exit(-1);
- } else {
- Arguments.stlFiles = stls;
- }
- }
- break;
- case OPTION_HELP:
- printUsage();
- exit(0);
- break;
- default:
- fatal("Unknown Option " + arg);
- printUsage();
- exit(0);
- break;
- }
- }
- }
- checkCase();
- }
- private static void checkCase() {
- if (hasCommand()) {
- if (Arguments.baseDir == null) {
- fatal("Missing case folder");
- printUsage();
- exit(-1);
- }
- }
- }
+ case OPTION_IMPORT:
+ if (i == argv.length - 1) {
+ fatal("Missing import file/folder");
+ printUsage();
+ exit(-1);
+ }
+ String importPath = argv[++i];
+ final File importFolder = new File(importPath);
+ if (!importFolder.exists()) {
+ fatal("Import Folder Does Not Exist!");
+ exit(-1);
+ } else if (importFolder.isFile()) {
+ this.importFiles = new File[] { importFolder };
+ } else {
+ File[] stls = importFolder.listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.endsWith("stl") || name.endsWith("STL");
+ }
+ });
+ if (stls.length == 0) {
+ fatal("No files to import!");
+ exit(-1);
+ } else {
+ this.importFiles = stls;
+ }
+ }
+ break;
+ case OPTION_HELP:
+ printUsage();
+ exit(0);
+ break;
+ default:
+ fatal("Unknown Option " + arg);
+ printUsage();
+ exit(0);
+ break;
+ }
+ }
+ }
+ checkCaseOrStudy();
+ }
- private static void fatal(String msg) {
- System.err.println();
- System.err.println(LINE);
- System.err.println(" " + TAB + "FATAL ERROR:");
- System.err.println(" " + TAB + TAB + msg);
- System.err.println(LINE);
- }
+ private void checkCaseOrStudy() {
+ if (hasCommand()) {
+ if (baseDir == null && studyDir == null) {
+ fatal("Missing case (or study) folder");
+ printUsage();
+ exit(-1);
+ }
+ }
+ }
- private static void warning(String msg) {
- System.err.println();
- System.err.println(LINE);
- System.err.println(" " + TAB+"WARNING:");
- System.err.println(" " + TAB + TAB + msg);
- System.err.println(TAB+LINE);
- }
-
- private static void exit(int status) {
- System.exit(status);
- }
+ private static void fatal(String msg) {
+ System.err.println();
+ System.err.println(LINE);
+ System.err.println(" " + TAB + "FATAL ERROR:");
+ System.err.println(" " + TAB + TAB + msg);
+ System.err.println(LINE);
+ }
- private static void printUsage() {
-
- System.err.println(" USAGE");
- System.err.println(" -----------------------------------------------------");
- if (Util.isWindows())
- System.err.println(" "+ApplicationInfo.getName()+".bat ["+OPTION_V+"] ["+OPTION_VV+"] [-case ] [command] ");
- else
- System.err.println(" "+ApplicationInfo.getName()+".sh ["+OPTION_V+"] ["+OPTION_VV+"] [-case ] [command] ");
-
- System.err.println();
- System.err.println(" Options:");
- System.err.println(" " + Util.padWithSpaces(OPTION_HELP, 12) + " Print this help screen.");
- System.err.println(" " + Util.padWithSpaces(OPTION_V, 12) + " The verbose output.");
- System.err.println(" " + Util.padWithSpaces(OPTION_VV, 12) + " The very verbose output.");
- System.err.println(" " + Util.padWithSpaces(OPTION_CASE, 12) + " Specify the case directory for the application.");
- System.err.println(" " + Util.padWithSpaces(OPTION_NO3D, 12) + " Does not display 3D window.");
- System.err.println();
- System.err.println(" Commands:");
- System.err.println(" " + Util.padWithSpaces(OPTION_MESH, 12) + " Launch mesh creation according to system/snappyHexMeshDict.");
- System.err.println(" " + Util.padWithSpaces(OPTION_SETUP, 12) + " Setup the cfd case according to system/caseSetupDict.");
- System.err.println(" " + Util.padWithSpaces(OPTION_INITIALISE, 12) + " Initialise the fields according to system/caseSetupDict.");
- System.err.println(" " + Util.padWithSpaces(OPTION_RUN, 12) + " Launch the solver.");
- System.err.println(" " + Util.padWithSpaces(OPTION_ALL, 12) + " Launch mesh + setup + run.");
- System.err.println(" -----------------------------------------------------");
- }
+ private static void warning(String msg) {
+ System.err.println();
+ System.err.println(LINE);
+ System.err.println(" " + TAB + "WARNING:");
+ System.err.println(" " + TAB + TAB + msg);
+ System.err.println(TAB + LINE);
+ }
- public static boolean isBatch() {
- return Arguments.server || hasCommand();
- }
+ private static void exit(int status) {
+ System.exit(status);
+ }
- private static boolean hasCommand() {
- return Arguments.mesh || Arguments.setup || Arguments.run || Arguments.all || Arguments.initialise;
- }
+ private static void printUsage() {
+
+ System.err.println(" USAGE");
+ System.err.println(" -----------------------------------------------------");
+ if (Util.isWindows())
+ System.err.println(" " + ApplicationInfo.getName() + ".bat [" + OPTION_V + "] [" + OPTION_VV + "] [-case ] [command] ");
+ else
+ System.err.println(" " + ApplicationInfo.getName() + ".sh [" + OPTION_V + "] [" + OPTION_VV + "] [-case ] [command] ");
+
+ System.err.println();
+ System.err.println(" Options:");
+ System.err.println(" " + Util.padWithSpaces(OPTION_HELP, 12) + " Print this help screen.");
+ System.err.println(" " + Util.padWithSpaces(OPTION_V, 12) + " The verbose output.");
+ System.err.println(" " + Util.padWithSpaces(OPTION_VV, 12) + " The very verbose output.");
+ System.err.println(" " + Util.padWithSpaces(OPTION_NO3D, 12) + " Does not display 3D window.");
+ System.err.println(" " + Util.padWithSpaces(OPTION_CASE, 12) + " Specify the case directory for the application.");
+ System.err.println(" " + Util.padWithSpaces(OPTION_STUDY, 12) + " Specify the study directory for the application (case manager only).");
+ System.err.println(" " + Util.padWithSpaces(OPTION_CONCURRENT_DESIGNS, 12) + " Specify the number of cases to run in parallel (case manager only).");
+ System.err.println();
+ System.err.println(" " + Util.padWithSpaces(OPTION_MEMORY, 12) + " Set the maximum memory size. Size is expressed as '1234m' or '1g' ");
+ System.err.println();
+ System.err.println(" Commands:");
+ System.err.println(" " + Util.padWithSpaces(OPTION_MESH, 12) + " Launch mesh creation according to system/snappyHexMeshDict.");
+ System.err.println(" " + Util.padWithSpaces(OPTION_SETUP, 12) + " Setup the cfd case according to system/caseSetupDict.");
+ System.err.println(" " + Util.padWithSpaces(OPTION_INITIALISE, 12) + " Initialise the fields according to system/caseSetupDict.");
+ System.err.println(" " + Util.padWithSpaces(OPTION_RUN, 12) + " Launch the solver.");
+ System.err.println(" " + Util.padWithSpaces(OPTION_ALL, 12) + " Launch mesh + setup + run.");
+ System.err.println(" " + Util.padWithSpaces(OPTION_POST, 12) + " Extract post-processing results.");
+ System.err.println(" -----------------------------------------------------");
+ }
+
+ public boolean isBatch() {
+ return server || hasCommand();
+ }
+
+ private boolean hasCommand() {
+ return mesh || setup || run || all || initialise || post;
+ }
}
diff --git a/src/eu/engys/core/DockerUtil.java b/src/eu/engys/core/DockerUtil.java
new file mode 100644
index 0000000..e6eaa24
--- /dev/null
+++ b/src/eu/engys/core/DockerUtil.java
@@ -0,0 +1,239 @@
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
+package eu.engys.core;
+
+import static eu.engys.util.OpenFOAMCommands.PARA_FOAM;
+import static eu.engys.util.PrefUtil.DOCKER_IMAGE;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.io.FileUtils;
+
+import eu.engys.util.PrefUtil;
+import eu.engys.util.Util;
+
+public class DockerUtil {
+
+ private static final String USER = PrefUtil.USER_NAME;
+ private static final String HOME = PrefUtil.USER_HOME;
+ private static final String USER_UID = Util.getUID();
+ private static final String DISPLAY = PrefUtil.DISPLAY;
+ private static final String SHARE = "/share";
+
+ private static final String ENGYS_22_BETA_VENDOR_HOME = "/opt";
+ private static final String ENGYS_22_BETA_ENV_LOADER = "/opt/OpenFOAM-2.2_engysEdition-beta/etc/bashrc";
+
+ private static final String OF_PLUS_VENDOR_HOME = "/opt/OpenFOAM";
+ private static final String OF_PLUS_ENV_LOADER = "/opt/OpenFOAM/OpenFOAM-v1606+/etc/bashrc";
+
+ private static final String PV_VERSION = "4.1.0";
+ private static final String MACHINEFILE = "";
+
+ private static final String WINDOWS_DOCKER_ENV = "FOR /f \"tokens=*\" %%i IN ('\"C:\\Program Files\\Docker Toolbox\\docker-machine\" env default --shell=cmd') DO %%i";
+
+ public static CommandLine getCommandLine(Map environment, String script) {
+ String dockerImage = PrefUtil.getString(DOCKER_IMAGE);
+
+ String casePath = ensureLinuxPath(environment.get("CASE"));
+ String scriptPath = ensureLinuxPath(casePath + "/" + script);
+
+ List arguments = new LinkedList<>();
+
+ addRunCommand(arguments, false, false);
+ addScriptVariables(arguments, environment);
+ addDisplayVariables(arguments);
+ addUserVariables(arguments);
+ addWorkDir(arguments, Util.isWindows() ? SHARE : HOME);
+
+ arguments.add(dockerImage);
+
+ // the actual command
+ arguments.add(scriptPath);
+
+ CommandLine commandLine = new CommandLine("docker");
+ commandLine.addArguments(arguments.toArray(new String[0]), false);
+ return Util.isWindows() ? windowsWrapper(environment.get("CASE"), commandLine) : commandLine;
+ }
+
+ public static String terminal(File baseDir) {
+ String dockerImage = PrefUtil.getString(DOCKER_IMAGE);
+ boolean isOFPlus = dockerImage.contains("openfoamplus");
+
+ String ENV_LOADER = isOFPlus ? OF_PLUS_ENV_LOADER : ENGYS_22_BETA_ENV_LOADER;
+
+ List arguments = new LinkedList<>();
+
+ addRunCommand(arguments, true, true);
+ addDisplayVariables(arguments);
+ addUserVariables(arguments);
+ addWorkDir(arguments, baseDir.getAbsolutePath());
+
+ arguments.add(dockerImage);
+
+ // the actual command
+ arguments.add("/bin/bash");
+ arguments.add("--rcfile");
+ arguments.add(ENV_LOADER);
+
+ CommandLine commandLine = new CommandLine("docker");
+ commandLine.addArguments(arguments.toArray(new String[0]), false);
+ return Util.isWindows() ? windowsWrapper(baseDir.getAbsolutePath(), commandLine).toString() : commandLine.toString();
+ }
+
+ public static String paraview(File baseDir) {
+ String dockerImage = PrefUtil.getString(DOCKER_IMAGE);
+ boolean isOFPlus = dockerImage.contains("openfoamplus");
+
+ String ENV_LOADER = isOFPlus ? OF_PLUS_ENV_LOADER : ENGYS_22_BETA_ENV_LOADER;
+
+ List arguments = new LinkedList<>();
+
+ addRunCommand(arguments, true, false);
+ addDisplayVariables(arguments);
+ addUserVariables(arguments);
+ addWorkDir(arguments, baseDir.getAbsolutePath());
+
+ arguments.add(dockerImage);
+
+ // the actual command
+ arguments.add("/bin/bash");
+ arguments.add("--rcfile");
+ arguments.add(ENV_LOADER);
+ arguments.add("-ci");
+ arguments.add(PARA_FOAM);
+
+ CommandLine commandLine = new CommandLine("docker");
+ commandLine.addArguments(arguments.toArray(new String[0]), false);
+ return Util.isWindows() ? windowsWrapper(baseDir.getAbsolutePath(), commandLine).toString() : commandLine.toString();
+ }
+
+ /*
+ * Utils
+ */
+ private static String ensureLinuxPath(String winPath) {
+ if (Util.isWindows()) {
+ String linuxPath = winPath;
+ linuxPath = linuxPath.replace(HOME, SHARE);
+ if (linuxPath.endsWith("bat")) {
+ linuxPath = linuxPath.replace("bat", "run");
+ }
+ return linuxPath.replace("\\", "/");
+ } else {
+ return winPath;
+ }
+ }
+
+ private static void addWorkDir(List arguments, String workDir) {
+ arguments.add("-w");
+ arguments.add(ensureLinuxPath(workDir));
+ }
+
+ private static void addScriptVariables(List arguments, Map environment) {
+ String dockerImage = PrefUtil.getString(DOCKER_IMAGE);
+ boolean isOFPlus = dockerImage.contains("openfoamplus");
+
+ String NP = environment.get("NP");
+ String SOLVER = environment.get("SOLVER");
+
+ String VENDOR_HOME = isOFPlus ? OF_PLUS_VENDOR_HOME : ENGYS_22_BETA_VENDOR_HOME;
+ String ENV_LOADER = isOFPlus ? OF_PLUS_ENV_LOADER : ENGYS_22_BETA_ENV_LOADER;
+
+ String CASE = ensureLinuxPath(environment.get("CASE"));
+ String LOG = ensureLinuxPath(environment.get("LOG"));
+
+ arguments.add("-e");
+ arguments.add("CASE=" + CASE);
+ arguments.add("-e");
+ arguments.add("NP=" + NP);
+ arguments.add("-e");
+ arguments.add("LOG=" + LOG);
+ arguments.add("-e");
+ arguments.add("ENV_LOADER=" + ENV_LOADER);
+ arguments.add("-e");
+ arguments.add("VENDOR_HOME=" + VENDOR_HOME);
+ arguments.add("-e");
+ arguments.add("SOLVER=" + SOLVER);
+ arguments.add("-e");
+ arguments.add("PV_VERSION=" + PV_VERSION);
+ arguments.add("-e");
+ arguments.add("MACHINEFILE=" + MACHINEFILE);
+ }
+
+ private static void addDisplayVariables(List arguments) {
+ arguments.add("-e");
+ arguments.add("QT_X11_NO_MITSHM=1");
+ arguments.add("-e");
+ arguments.add("DISPLAY=" + DISPLAY);
+ }
+
+ private static void addUserVariables(List arguments) {
+ arguments.add("-e");
+ arguments.add("USER=" + USER);
+ arguments.add("-v");
+ arguments.add(Util.isWindows() ? (SHARE + ":" + SHARE) : (HOME + ":" + HOME));
+ arguments.add("-v");
+ arguments.add("/etc/group:/etc/group:ro");
+ arguments.add("-v");
+ arguments.add("/etc/passwd:/etc/passwd:ro");
+ arguments.add("-v");
+ arguments.add("/etc/shadow:/etc/shadow:ro");
+ arguments.add("-v");
+ arguments.add("/etc/sudoers.d:/etc");
+ arguments.add("-v");
+ arguments.add("/tmp:/tmp");
+ }
+
+ private static void addRunCommand(List arguments, boolean interactive, boolean tty) {
+ arguments.add("run");
+ arguments.add("--rm");
+ if (interactive && tty) {
+ arguments.add("-it");
+ } else if (interactive) {
+ arguments.add("-i");
+ }
+ arguments.add("-u");
+ arguments.add(USER_UID);
+ }
+
+ private static CommandLine windowsWrapper(String baseDir, CommandLine commandLine) {
+ File f = new File(baseDir, "dockerWrapper.bat");
+ List lines = new LinkedList<>();
+ lines.add("@echo off");
+ lines.add(WINDOWS_DOCKER_ENV);
+ lines.add(commandLine.toString());
+ try {
+ FileUtils.writeLines(f, lines, false);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return new CommandLine(f.getAbsolutePath());
+ }
+
+}
diff --git a/src/eu/engys/core/OpenFOAMEnvironment.java b/src/eu/engys/core/OpenFOAMEnvironment.java
index ca14fd9..4b7bd3d 100644
--- a/src/eu/engys/core/OpenFOAMEnvironment.java
+++ b/src/eu/engys/core/OpenFOAMEnvironment.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core;
import static eu.engys.core.project.openFOAMProject.LOG;
@@ -38,6 +37,7 @@ import java.util.Map;
import javax.swing.JFrame;
import org.apache.commons.exec.CommandLine;
+import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -106,10 +106,6 @@ public class OpenFOAMEnvironment {
return getEnvironment(model, "");
}
-// public static Map getEnvironment(Model model, File baseDir) {
-// return getEnvironment(model, baseDir, null, null);
-// }
-
public static Map getEnvironment(Model model, String logFileName) {
return getEnvironment(model, model.getProject().getBaseDir(), logFileName, null);
}
@@ -137,11 +133,11 @@ public class OpenFOAMEnvironment {
map.put("LOG", Paths.get(model.getProject().getBaseDir().getAbsolutePath(), LOG, logFileName).toString());
}
- map.put("VENDOR_HOME", getVendorHome().getAbsolutePath());
+ map.put("VENDOR_HOME", getVendorHome() != null ? getVendorHome().getAbsolutePath() : "");
map.put("PV_VERSION", getParaviewVersion());
- map.put("ENV_LOADER", getEnvLoader().getAbsolutePath());
+ map.put("ENV_LOADER", getEnvLoader() != null ? getEnvLoader().getAbsolutePath() : "");
if (option != null) {
JavaExecutor executor = Executor.jvm("eu.engys.launcher.Launcher", option, "-V");
@@ -219,6 +215,8 @@ public class OpenFOAMEnvironment {
} else {
UiUtil.showCoreEnvironmentNotLoadedWarning(frame);
}
+ } else {
+ logger.info("Environment set to {}. Version {} ({})", PrefUtil.getOpenFoamEntry(), getOpenFoamVersion(), getOpenFoamSubVersion());
}
}
@@ -239,7 +237,7 @@ public class OpenFOAMEnvironment {
}
}
- public static void trySettingParaviewExecutable() {
+ public static void trySettingParaviewExecutables() {
if (!OpenFOAMEnvironment.isParaviewPathSet() && OpenFOAMEnvironment.isEnvironementLoaded()) {
File paraviewExecutable = getParaViewExecutablePath();
if (paraviewExecutable != null) {
@@ -249,6 +247,15 @@ public class OpenFOAMEnvironment {
logger.warn("ParaView path NOT set");
}
}
+ if (!OpenFOAMEnvironment.isParaviewBatchPathSet() && OpenFOAMEnvironment.isEnvironementLoaded()) {
+ File paraviewBatchExecutable = getParaViewBatchExecutablePath();
+ if (paraviewBatchExecutable != null) {
+ PrefUtil.setParaViewBatchEntry(paraviewBatchExecutable);
+ logger.info("ParaView BATCH path set to {}", PrefUtil.getParaViewEntry());
+ } else {
+ logger.warn("ParaView BATCH path NOT set");
+ }
+ }
}
public static File[] getOpenFoamDir() {
@@ -259,7 +266,6 @@ public class OpenFOAMEnvironment {
File vendorHome = Paths.get(jarPath).getParent().getParent().getParent().getParent().toFile();
logger.info("Check for valid OpenFOAM folder in {}", vendorHome);
openFoamFolders = vendorHome.listFiles(new FileFilter() {
-
@Override
public boolean accept(File file) {
return file.isDirectory() && file.getName().startsWith("OpenFOAM");
@@ -271,16 +277,40 @@ public class OpenFOAMEnvironment {
return openFoamFolders;
}
- private static File getParaViewExecutablePath() {
- File[] paraviewFolders = new File[0];
- File[] thirdPartyDirs = getThirdPartyDir();
+ private static File getParaViewBatchExecutablePath() {
+ File[] paraview_OSMESA_Folders = new File[0];
+ File[] thirdPartyDirs = getThirdPartyDir(getOpenFoamVersion());
if (Util.isVarArgsNotNullAndOfSize(1, thirdPartyDirs)) {
File thirdPartyDir = thirdPartyDirs[0];
logger.info("Check for valid ParaView folder in {}", thirdPartyDir);
+ paraview_OSMESA_Folders = thirdPartyDir.listFiles(new FileFilter() {
+ @Override
+ public boolean accept(File file) {
+ return file.isDirectory() && file.getName().startsWith("ParaView-") && file.getName().endsWith("osmesa");
+ }
+ });
+ }
+ if (Util.isVarArgsNotNull(paraview_OSMESA_Folders)) {
+ for (File pvFolder : paraview_OSMESA_Folders) {
+ File pvBatchExecutable = Paths.get(pvFolder.getAbsolutePath(), "platforms", "linux64Gcc", "bin", "pvbatch").toFile();
+ if (pvBatchExecutable.exists()) {
+ return pvBatchExecutable;
+ }
+ }
+ }
+ return null;
+ }
+
+ private static File getParaViewExecutablePath() {
+ File[] paraviewFolders = new File[0];
+ File[] thirdPartyDirs = getThirdPartyDir(getOpenFoamVersion());
+ if (Util.isVarArgsNotNullAndOfSize(1, thirdPartyDirs)) {
+ File thirdPartyDir = thirdPartyDirs[0];
+ logger.info("Check for valid ParaView BATCH folder in {}", thirdPartyDir);
paraviewFolders = thirdPartyDir.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
- return file.isDirectory() && file.getName().startsWith("ParaView");
+ return file.isDirectory() && file.getName().startsWith("ParaView-");
}
});
}
@@ -295,28 +325,31 @@ public class OpenFOAMEnvironment {
return null;
}
- private static File[] getThirdPartyDir() {
- File[] openFoamFolders = getOpenFoamDir();
+ private static File[] getThirdPartyDir(final String version) {
File[] thirdPartyFolders = new File[0];
- if (Util.isVarArgsNotNullAndOfSize(1, openFoamFolders)) {
- File vendorHome = getOpenFoamDir()[0].getParentFile();
- logger.info("Check for valid ThirdParty folder in {}", vendorHome);
+ if (OpenFOAMEnvironment.isEnvironementLoaded()) {
+ File openFoamDir = PrefUtil.getOpenFoamEntry();
+ File vendorHome = openFoamDir.getParentFile();
+ logger.info("Check for valid ThirdParty folder in {} for version {}", vendorHome, version);
thirdPartyFolders = vendorHome.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
- return file.isDirectory() && file.getName().startsWith("ThirdParty");
+ String name = file.getName();
+ return file.isDirectory() && name.startsWith("ThirdParty") && name.endsWith(version);
}
});
+ } else {
+ logger.warn("ThirdParty folder not found: missing ");
}
return thirdPartyFolders;
+
}
- private static File[] getOpenFoamDirOS_onUnix() {
+ public static File[] getOpenFoamDirOS_onUnix() {
File[] openFoamFolders = new File[0];
File optFolder = new File("/opt");
logger.info("Check for valid OpenFOAM folder in {}", optFolder);
openFoamFolders = optFolder.listFiles(new FileFilter() {
-
@Override
public boolean accept(File file) {
boolean isDir = file.isDirectory();
@@ -351,6 +384,9 @@ public class OpenFOAMEnvironment {
}
public static boolean isEnvironementLoaded() {
+ if(PrefUtil.isUsingDocker()){
+ return true;
+ }
File openFoamDir = PrefUtil.getOpenFoamEntry();
if (openFoamDir == null || !openFoamDir.exists() || !openFoamDir.isDirectory()) {
return false;
@@ -366,6 +402,14 @@ public class OpenFOAMEnvironment {
return true;
}
+ public static boolean isParaviewBatchPathSet() {
+ File paraViewBatch = PrefUtil.getParaViewBatchEntry();
+ if (paraViewBatch == null || !paraViewBatch.exists() || !paraViewBatch.isFile() || !paraViewBatch.canExecute()) {
+ return false;
+ }
+ return true;
+ }
+
public static boolean isFieldViewPathSet() {
File fieldView = PrefUtil.getFieldViewEntry();
if (fieldView == null || !fieldView.exists() || !fieldView.isFile() || !fieldView.canExecute()) {
@@ -402,9 +446,35 @@ public class OpenFOAMEnvironment {
return new File("");
}
- public static String getParaviewVersion() {
- File pvHome = PrefUtil.getParaViewEntry();
- if (pvHome != null && pvHome.exists()) {
+ private static String getOpenFoamVersion() {
+ File openFoamEntry = PrefUtil.getOpenFoamEntry();
+ if (openFoamEntry != null) {
+ String name = openFoamEntry.getName();
+ String[] split = StringUtils.split(name, "-");
+ if (split.length > 1) {
+ return split[1];
+ }
+ }
+ return "";
+ }
+
+ private static String getOpenFoamSubVersion() {
+ File openFoamEntry = PrefUtil.getOpenFoamEntry();
+ if (openFoamEntry != null) {
+ String name = openFoamEntry.getName();
+ String[] split = StringUtils.split(name, "-");
+ if (split.length > 2) {
+ return split[2];
+ }
+ }
+ return "";
+ }
+
+ private static String getParaviewVersion() {
+// File pvHome = PrefUtil.getParaViewEntry();
+ File pvExe = PrefUtil.getParaViewBatchEntry();
+ if (pvExe != null && pvExe.exists()) {
+ File pvHome = pvExe.toPath().getParent().getParent().getParent().getParent().toFile();
String name = pvHome.getName();
if (name.startsWith("ParaView-")) {
String version = name.substring("ParaView-".length());
diff --git a/src/eu/engys/core/controller/AbstractController.java b/src/eu/engys/core/controller/AbstractController.java
index 9c322da..ef8946d 100644
--- a/src/eu/engys/core/controller/AbstractController.java
+++ b/src/eu/engys/core/controller/AbstractController.java
@@ -1,32 +1,35 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
+import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
+import static javax.swing.JOptionPane.OK_CANCEL_OPTION;
+import static javax.swing.JOptionPane.QUESTION_MESSAGE;
+import static javax.swing.JOptionPane.YES_NO_CANCEL_OPTION;
+
import java.io.File;
-import java.rmi.RemoteException;
import java.util.Set;
import javax.swing.Icon;
@@ -35,22 +38,28 @@ import javax.swing.JOptionPane;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import eu.engys.core.Arguments;
import eu.engys.core.controller.actions.CommandException;
import eu.engys.core.controller.actions.DeleteMesh;
+import eu.engys.core.executor.ExecutorTerminal;
+import eu.engys.core.executor.TerminalManager;
import eu.engys.core.modules.ApplicationModule;
import eu.engys.core.presentation.Action;
import eu.engys.core.presentation.ActionContainer;
import eu.engys.core.presentation.ActionManager;
import eu.engys.core.project.CaseParameters;
-import eu.engys.core.project.InvalidProjectException;
+import eu.engys.core.project.CreateCaseDialog;
import eu.engys.core.project.Model;
import eu.engys.core.project.Project200To210Converter;
+import eu.engys.core.project.Project210To240Converter;
import eu.engys.core.project.ProjectFolderAnalyzer;
+import eu.engys.core.project.ProjectFolderAnalyzer.WhenInDoubt;
+import eu.engys.core.project.ProjectFolderStructure;
import eu.engys.core.project.ProjectReader;
import eu.engys.core.project.ProjectWriter;
import eu.engys.core.project.SolverState;
import eu.engys.core.project.openFOAMProject;
+import eu.engys.core.project.mesh.MeshInfo;
+import eu.engys.core.project.mesh.MeshInfoWriter;
import eu.engys.core.project.system.monitoringfunctionobjects.ParserView;
import eu.engys.core.project.zero.cellzones.CellZonesBuilder;
import eu.engys.util.ApplicationInfo;
@@ -65,20 +74,42 @@ import eu.engys.util.ui.UiUtil;
public abstract class AbstractController implements Controller, ActionContainer {
- public static final String STOP_SOLVER = "Stop Solver";
- public static final String KILL_SOLVER = "Kill Solver";
+ public static final String SOLVER_RUN = "solver.run";
+ public static final String SOLVER_RUN_EDIT = "solver.run.edit";
+
+ public static final String SOLVER_STOP = "solver.stop";
+ public static final String REFRESH_ONCE = "solver.refresh.once";
+ public static final String RUN_ALL = "solver.run.all";
+
+ public static final String INITIALISE_SCRIPT = "initialise.fields";
+ public static final String INITIALISE_SCRIPT_EDIT = "initialise.fields.edit";
+
+ public static final String MESH_CREATE = "mesh.create";
+ public static final String MESH_CREATE_EDIT = "mesh.create.edit";
+ public static final String MESH_CHECK = "mesh.check";
+ public static final String MESH_CHECK_EDIT = "mesh.check.edit";
+ public static final String MESH_DELETE = "mesh.delete";
+ public static final String MESH_STRETCH = "mesh.stretch";
+ public static final String DECOMPOSE = "decompose";
+
+ public static final String OPEN_RUN_MODE = "application.connection.window";
+ public static final String OPEN_PARAMETERS_MANAGER = "application.parameters.manager";
+ public static final String SAVE_SCREENSHOT = "save.screenshot";
+
+ public static final String STOP_SOLVER_LABEL = "Stop Solver";
+ public static final String KILL_SOLVER_LABEL = "Kill Solver";
public static final String STOP_EXECUTION = "Stop Execution";
public static final String KILL_PROCESS = "Kill Process";
-
- public static final String STOP_FIELDS_INITIALISATION = "Stop Fields Initialisation";
- public static final String STOP_MESH_GENERATOR = "Stop Mesh Generator";
-
+
public static final String CANCEL = "Cancel";
public static final String CONTINUE_IN_BATCH = "Continue in Batch";
- private static final Icon EXIT_BIG_ICON = ResourcesUtil.getIcon("application.exit.big.icon");
- private static final String EXIT_LABEL = ResourcesUtil.getString("application.exit.label");
+ public static final String PARALLEL_WORKS = "application.parallel.works";
+
+ protected static final Icon EXIT_BIG_ICON = ResourcesUtil.getIcon("application.exit.big.icon");
+ protected static final String EXIT_LABEL = ResourcesUtil.getString("application.exit.label");
+
private static final Logger logger = LoggerFactory.getLogger(Controller.class);
protected final Model model;
@@ -90,6 +121,8 @@ public abstract class AbstractController implements Controller, ActionContainer
protected ControllerListener listener;
protected CellZonesBuilder cellZonesBuilder;
+ public static boolean isServer = false;
+
public AbstractController(Model model, Set modules, ProjectReader reader, ProjectWriter writer, CellZonesBuilder cellZonesBuilder, ProgressMonitor monitor, ScriptFactory scriptFactory) {
this.cellZonesBuilder = cellZonesBuilder;
logger.info("Loading {}", getClass().getSimpleName());
@@ -106,33 +139,61 @@ public abstract class AbstractController implements Controller, ActionContainer
*/
@Override
- public void createCase(CaseParameters params) {
- if (params != null) {
- newCaseInAThread(params);
+ public void createCase(CaseParameters params, OpenOptions oo) {
+ if (params == null) {
+ params = caseParametersOrNull();
+ }
+
+ if (params.getBaseDir() != null) {
+ newCaseInAThread(params, oo);
}
}
- private void newCaseInAThread(final CaseParameters params) {
+ private CaseParameters caseParametersOrNull() {
+ final CaseParameters p = new CaseParameters();
+
+ ExecUtil.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ final CreateCaseDialog createCaseDialog = new CreateCaseDialog();
+ createCaseDialog.showDialog();
+ if (createCaseDialog.isOK()) {
+ ActionManager.getInstance().invoke("application.startup.hide");
+ p.setBaseDir(createCaseDialog.getParameters().getBaseDir());
+ p.setnHierarchy(createCaseDialog.getParameters().getnHierarchy());
+ p.setnProcessors(createCaseDialog.getParameters().getnProcessors());
+ p.setParallel(createCaseDialog.getParameters().isParallel());
+ }
+ }
+ });
+
+ return p;
+ }
+
+ private void newCaseInAThread(final CaseParameters params, final OpenOptions oo) {
monitor.setTotal(10);
monitor.start(String.format("Creating %s", params), false, new Runnable() {
@Override
public void run() {
- create(params);
+ create(params, oo);
PrefUtil.putFile(PrefUtil.WORK_DIR, model.getProject().getBaseDir().getParentFile());
+ if (oo != null && oo.getFilesToImport() != null) {
+ importFiles(oo.getFilesToImport());
+ }
monitor.end();
}
});
}
@Override
- public void create(final CaseParameters params) {
+ public void create(final CaseParameters params, final OpenOptions oo) {
if (listener != null) {
listener.beforeNewCase();
}
clearModel();
writer.create(params);
if (listener != null) {
- listener.afterNewCase();
+ listener.afterNewCase(oo != null ? oo.isLoadMesh() : true);
}
}
@@ -141,94 +202,124 @@ public abstract class AbstractController implements Controller, ActionContainer
*/
@Override
- public void openCase(File file) {
- if (file == null) {
- file = fileToOpenOrNull();
+ public void openCase(OpenOptions oo) {
+ if (oo == null) {
+ oo = fileToOpenOrNull();
}
- if (file != null) {
- ActionManager.getInstance().invoke("application.startup.hide");
- openInAThread(file);
+ if (oo != null && oo.getFile() != null) {
+ openInAThread(oo);
}
- Arguments.load3Dgeometry = true;
- Arguments.load3Dmesh = true;
}
- private File fileToOpenOrNull() {
- final File[] openFile = new File[1];
- Runnable r = new Runnable() {
- @Override
- public void run() {
- File workDir = PrefUtil.getWorkDir(PrefUtil.WORK_DIR);
- HelyxFileChooser fileChooser = new HelyxFileChooser(workDir.getAbsolutePath());
- fileChooser.setTitle("Open");
- fileChooser.setSelectionMode(SelectionMode.DIRS_AND_ARCHIVES);
-
- View3DOptions options = new View3DOptions();
- ReturnValue returnValue = fileChooser.showOpenDialog(options);
- if (returnValue.isApprove()) {
- File selectedCase = fileChooser.getSelectedFile();
- if (isSuitable(selectedCase)) {
- PrefUtil.putFile(PrefUtil.WORK_DIR, selectedCase.getParentFile());
- Arguments.load3Dgeometry = true;
- Arguments.load3Dmesh = options.loadMesh();
- openFile[0] = selectedCase;
- return;
- }
- JOptionPane.showMessageDialog(UiUtil.getActiveWindow(), selectedCase + "\n appears not to be a valid case folder", "File System Error", JOptionPane.ERROR_MESSAGE);
- }
- openFile[0] = null;
- return;
- }
- };
+ private OpenOptions fileToOpenOrNull() {
+ OpenFile r = new OpenFile();
ExecUtil.invokeAndWait(r);
- return openFile[0];
+ return r.getOpenOptions();
}
- private void openInAThread(final File file) {
+ class OpenFile implements Runnable {
+
+ private OpenOptions openOptions;
+
+ @Override
+ public void run() {
+ File workDir = PrefUtil.getWorkDir(PrefUtil.WORK_DIR);
+ HelyxFileChooser fileChooser = new HelyxFileChooser(workDir.getAbsolutePath());
+ fileChooser.setTitle("Open");
+ fileChooser.setSelectionMode(SelectionMode.DIRS_AND_ARCHIVES);
+
+ View3DOptions options = new View3DOptions();
+ ReturnValue returnValue = fileChooser.showOpenDialog(options);
+ if (returnValue.isApprove()) {
+ File selectedCase = fileChooser.getSelectedFile();
+ if (isSuitable(selectedCase)) {
+ PrefUtil.putFile(PrefUtil.WORK_DIR, selectedCase.getParentFile());
+ openOptions = OpenOptions.file(selectedCase, OpenMode.CHECK_FOLDER_ASK_USER).loadMesh(options.loadMesh());
+ ActionManager.getInstance().invoke("application.startup.hide");
+ return;
+ }
+ JOptionPane.showMessageDialog(UiUtil.getActiveWindow(), selectedCase + "\n appears not to be a valid case folder", "File System Error", JOptionPane.ERROR_MESSAGE);
+ }
+ return;
+ }
+
+ public OpenOptions getOpenOptions() {
+ return openOptions;
+ }
+ }
+
+ private void openInAThread(final OpenOptions oo) {
monitor.setTotal(10);
- monitor.start("Open " + file.getName(), false, new Runnable() {
+ monitor.start("Open " + oo.getFile().getName(), false, new Runnable() {
@Override
public void run() {
- open(file);
+ open(oo);
monitor.end();
}
});
}
@Override
- public void open(File file) {
+ public void open(OpenOptions oo) {
+ File file = oo.getFile();
+ OpenMode mode = oo.getMode();
+
final File baseDir = file.isAbsolute() ? file : file.getAbsoluteFile();
logger.debug("OPEN file {}", baseDir.getAbsolutePath());
+
if (listener != null) {
listener.beforeLoadCase();
}
clearModel();
- model.setProject(openFOAMProject.createProject(baseDir, monitor));
+ switch (mode) {
+ case SERIAL:
+ model.setProject(openFOAMProject.newSerialProject(baseDir));
+ break;
+ case PARALLEL:
+ model.setProject(openFOAMProject.newParallelProject(baseDir));
+ break;
+ case CURRENT_SETTINGS:
+ case CHECK_FOLDER_ASK_USER:
+ ProjectFolderStructure structure1 = new ProjectFolderAnalyzer(baseDir, monitor).checkAll(WhenInDoubt.ASK_USER);
+ model.setProject(structure1.isParallel() ? openFOAMProject.newParallelProject(baseDir, structure1.getProcessors()) : openFOAMProject.newSerialProject(baseDir));
+ break;
+ case CHECK_FOLDER_PARALLEL:
+ ProjectFolderStructure structure2 = new ProjectFolderAnalyzer(baseDir, monitor).checkAll(WhenInDoubt.READ_PARALLEL);
+ model.setProject(structure2.isParallel() ? openFOAMProject.newParallelProject(baseDir, structure2.getProcessors()) : openFOAMProject.newSerialProject(baseDir));
+ break;
+ case MESH_ONLY:
+ break;
+ default:
+ break;
+ }
new Project200To210Converter(model.getProject(), cellZonesBuilder).convert();
+ new Project210To240Converter(model.getProject()).convert();
- _read();
+ reader.read();
if (listener != null) {
- listener.afterLoadCase();
+ listener.afterLoadCase(oo.isLoadMesh());
}
logger.debug("OPEN file {} done.", baseDir.getName());
}
+ protected abstract void importFiles(final File[] stlFiles);
+
@Override
- public void reopen(OpenOptions options) {
+ public void reopen(OpenMode mode) {
File baseDir = model.getProject().getBaseDir();
int np = model.getProject().getProcessors();
boolean parallel = model.getProject().isParallel();
- logger.debug("REOPEN file {} with option {}", baseDir.getAbsolutePath(), options);
+ logger.debug("REOPEN file {} in {} mode", baseDir.getAbsolutePath(), mode);
if (listener != null) {
listener.beforeReopenCase();
}
- if (options == OpenOptions.MESH_ONLY) {
+ if (mode == OpenMode.MESH_ONLY) {
reader.readMesh();
if (listener != null) {
listener.afterReopenCase();
@@ -237,23 +328,28 @@ public abstract class AbstractController implements Controller, ActionContainer
}
clearModel();
- switch (options) {
- case SERIAL:
- model.setProject(openFOAMProject.newSerialProject(baseDir));
- break;
- case PARALLEL:
- model.setProject(openFOAMProject.newParallelProject(baseDir));
- break;
- case CHECK_FOLDER:
- model.setProject(openFOAMProject.createProject(baseDir, monitor));
- break;
- case CURRENT_SETTINGS:
- model.setProject(parallel ? openFOAMProject.newParallelProject(baseDir, np) : openFOAMProject.newSerialProject(baseDir));
- break;
- case MESH_ONLY:
- break;
- default:
- break;
+ switch (mode) {
+ case SERIAL:
+ model.setProject(openFOAMProject.newSerialProject(baseDir));
+ break;
+ case PARALLEL:
+ model.setProject(openFOAMProject.newParallelProject(baseDir));
+ break;
+ case CHECK_FOLDER_ASK_USER:
+ ProjectFolderStructure structure1 = new ProjectFolderAnalyzer(baseDir, monitor).checkAll(WhenInDoubt.ASK_USER);
+ model.setProject(structure1.isParallel() ? openFOAMProject.newParallelProject(baseDir, structure1.getProcessors()) : openFOAMProject.newSerialProject(baseDir));
+ break;
+ case CHECK_FOLDER_PARALLEL:
+ ProjectFolderStructure structure2 = new ProjectFolderAnalyzer(baseDir, monitor).checkAll(WhenInDoubt.READ_PARALLEL);
+ model.setProject(structure2.isParallel() ? openFOAMProject.newParallelProject(baseDir, structure2.getProcessors()) : openFOAMProject.newSerialProject(baseDir));
+ break;
+ case CURRENT_SETTINGS:
+ model.setProject(parallel ? openFOAMProject.newParallelProject(baseDir, np) : openFOAMProject.newSerialProject(baseDir));
+ break;
+ case MESH_ONLY:
+ break;
+ default:
+ break;
}
reader.read();
@@ -264,18 +360,8 @@ public abstract class AbstractController implements Controller, ActionContainer
logger.debug("Open file {} done.", baseDir.getName());
}
- private void _read() {
- try {
- reader.read();
- } catch (InvalidProjectException e) {
- logger.error(e.getMessage());
- JOptionPane.showMessageDialog(UiUtil.getActiveWindow(), e.getMessage(), "Project error", JOptionPane.ERROR_MESSAGE);
- clearModel();
- }
- }
-
@Override
- public void reopenCase(final OpenOptions options) {
+ public void reopenCase(final OpenMode options) {
monitor.start("Reopen " + model.getProject().getBaseDir(), false, new Runnable() {
@Override
public void run() {
@@ -299,7 +385,7 @@ public abstract class AbstractController implements Controller, ActionContainer
}
}
- protected void saveInAThread(final File baseDir) {
+ private void saveInAThread(final File baseDir) {
monitor.info("");
monitor.start("Save: " + baseDir.getAbsolutePath(), false, new Runnable() {
@Override
@@ -308,6 +394,9 @@ public abstract class AbstractController implements Controller, ActionContainer
monitor.end();
}
});
+ if (ActionManager.getInstance().contains(SAVE_SCREENSHOT)) {
+ ActionManager.getInstance().get(SAVE_SCREENSHOT).actionPerformed(null);
+ }
}
@Override
@@ -316,8 +405,9 @@ public abstract class AbstractController implements Controller, ActionContainer
baseDir = model.getProject().getBaseDir();
}
logger.debug("Save file {}", baseDir.getAbsolutePath());
- if (listener != null)
+ if (listener != null) {
listener.beforeSaveCase();
+ }
writer.write(baseDir);
writeScripts();
if (listener != null) {
@@ -368,13 +458,16 @@ public abstract class AbstractController implements Controller, ActionContainer
* MESH
*/
- @Action(key = "mesh.delete")
+ @Action(key = MESH_DELETE)
public void deleteMesh() {
int retVal = JOptionPane.showConfirmDialog(UiUtil.getActiveWindow(), "This action will delete the existing mesh.\nContinue?", "Delete Mesh", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
if (retVal == JOptionPane.YES_OPTION) {
saveInAThread(model.getProject().getBaseDir());
new DeleteMesh(model, this).executeClient();
- reopenCase(OpenOptions.CURRENT_SETTINGS);
+ model.getMesh().setMeshInfo(new MeshInfo());
+ new MeshInfoWriter(model).write();
+ model.getProject().getSystemFolder().writeProjectDict(null);
+ reopenCase(OpenMode.CURRENT_SETTINGS);
}
}
@@ -393,10 +486,11 @@ public abstract class AbstractController implements Controller, ActionContainer
*/
@Override
- public void createReport() {
+ public void createReport(ExecutorTerminal terminal) {
}
- protected void clearModel() {
+ @Override
+ public void clearModel() {
logger.info("--- CLEAR MODEL ---");
model.init();
model.setProject(null);
@@ -418,31 +512,24 @@ public abstract class AbstractController implements Controller, ActionContainer
}
@Override
- public boolean allowActionsOnRunning(boolean exit) {
- if (model != null && model.getSolverModel() != null) {
+ public boolean allowActionsOnRunning(boolean shouldAskConfirmation) {
+ String exitMessage = EXIT_LABEL + " " + ApplicationInfo.getName() + "?";
+
+ boolean thereIsACaseLoaded = model != null && model.getSolverModel() != null;
+ if (thereIsACaseLoaded) {
SolverState solverState = model.getSolverModel().getServerState().getSolverState();
- if (solverState.isMeshing()) {
- return handleExitOnMeshRunning();
- } else if (solverState.isInitialising()) {
- return handleExitOnFieldsInitialising();
- } else if (solverState.isRunning()) {
- return handleExitOnSolverRunning();
- } else if (exit) {
- int option = JOptionPane.showConfirmDialog(UiUtil.getActiveWindow(), EXIT_LABEL + " " + ApplicationInfo.getName() + "?", EXIT_LABEL, JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, EXIT_BIG_ICON);
- if (option == JOptionPane.CANCEL_OPTION) {
- return false;
- } else {
- if (getClient() != null && getClient().getServer() != null) {
- shutdownServer();
+ if (solverState.isDoingSomething()) {
+ return handleExitOnRunning();
+ } else {// server not running
+ if (shouldAskConfirmation) {
+ int option = JOptionPane.showConfirmDialog(UiUtil.getActiveWindow(), exitMessage, EXIT_LABEL, OK_CANCEL_OPTION, INFORMATION_MESSAGE, EXIT_BIG_ICON);
+ if (option == JOptionPane.CANCEL_OPTION) {
+ return false;
}
- return true;
}
- } else if (getClient() != null && getClient().getServer() != null) {
- shutdownServer();
- return true;
}
- } else if (exit) {// If no case has been loaded yet
- int option = JOptionPane.showConfirmDialog(UiUtil.getActiveWindow(), EXIT_LABEL + " " + ApplicationInfo.getName() + "?", EXIT_LABEL, JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, EXIT_BIG_ICON);
+ } else if (shouldAskConfirmation) {
+ int option = JOptionPane.showConfirmDialog(UiUtil.getActiveWindow(), exitMessage, EXIT_LABEL, OK_CANCEL_OPTION, INFORMATION_MESSAGE, EXIT_BIG_ICON);
if (option == JOptionPane.CANCEL_OPTION) {
return false;
}
@@ -450,52 +537,15 @@ public abstract class AbstractController implements Controller, ActionContainer
return true;
}
- private void shutdownServer() {
- try {
- getClient().getServer().shutdown();
- } catch (RemoteException e) {
- logger.error("Error shutting down server: {}" + e.getMessage());
- } catch (Exception e) {
- logger.error("Error shutting down server: {}" + e.getMessage());
- }
- }
+ protected boolean handleExitOnRunning() {
+ Object[] options = new Object[] { KILL_PROCESS, CONTINUE_IN_BATCH, CANCEL };
+ String message = ApplicationInfo.getName() + " is running. Select an action to perform.";
+ String title = ApplicationInfo.getName();
- protected boolean handleExitOnMeshRunning() {
- Object[] options = new Object[] { STOP_MESH_GENERATOR, CONTINUE_IN_BATCH, CANCEL };
- int option = JOptionPane.showOptionDialog(UiUtil.getActiveWindow(), "Mesh Generator is Running. Select an action to perform.", "Mesh Generator Running", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
+ int option = JOptionPane.showOptionDialog(UiUtil.getActiveWindow(), message, title, YES_NO_CANCEL_OPTION, QUESTION_MESSAGE, null, options, options[0]);
if (getClient() != null && option == JOptionPane.YES_OPTION) {
- kill();
- return true;
- } else if (getClient() != null && option == JOptionPane.NO_OPTION) {
- getClient().goToBatch();
- return true;
- } else {
- return false;
- }
- }
-
- protected boolean handleExitOnFieldsInitialising() {
- Object[] options = new Object[] { STOP_FIELDS_INITIALISATION, CONTINUE_IN_BATCH, CANCEL };
- int option = JOptionPane.showOptionDialog(UiUtil.getActiveWindow(), "Fields Initialisation is Running. Select an action to perform.", "Fields Initialisation Running", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
-
- if (getClient() != null && option == JOptionPane.YES_OPTION) {
- kill();
- return true;
- } else if (getClient() != null && option == JOptionPane.NO_OPTION) {
- getClient().goToBatch();
- return true;
- } else {
- return false;
- }
- }
-
- protected boolean handleExitOnSolverRunning() {
- Object[] options = new Object[] { STOP_SOLVER, CONTINUE_IN_BATCH, CANCEL };
- int option = JOptionPane.showOptionDialog(UiUtil.getActiveWindow(), "Solver is Running. Select an action to perform.", "Solver Running", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
-
- if (getClient() != null && option == JOptionPane.YES_OPTION) {
- getClient().stopCommand(Command.ANY);
+ getClient().killCommand(Command.ANY);
return true;
} else if (getClient() != null && option == JOptionPane.NO_OPTION) {
getClient().goToBatch();
@@ -533,6 +583,11 @@ public abstract class AbstractController implements Controller, ActionContainer
return null;
}
+ @Override
+ public TerminalManager getTerminalManager() {
+ return null;
+ }
+
@Override
public ParserView getResidualView() {
return null;
diff --git a/src/eu/engys/core/controller/AbstractScriptFactory.java b/src/eu/engys/core/controller/AbstractScriptFactory.java
index f38e7c3..19557c5 100644
--- a/src/eu/engys/core/controller/AbstractScriptFactory.java
+++ b/src/eu/engys/core/controller/AbstractScriptFactory.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import java.io.File;
@@ -35,10 +34,12 @@ import eu.engys.util.Util;
public abstract class AbstractScriptFactory implements ScriptFactory {
protected static final String RUN_MESH = "Run Mesh";
- public static final String MESH_SERIAL_RUN = "mesh_serial.run";
- public static final String MESH_SERIAL_BAT = "mesh_serial.bat";
- public static final String MESH_PARALLEL_RUN = "mesh_parallel.run";
- public static final String MESH_PARALLEL_BAT = "mesh_parallel.bat";
+ public static final String MESH_SERIAL = "mesh_serial";
+ public static final String MESH_SERIAL_RUN = MESH_SERIAL + ".run";
+ public static final String MESH_SERIAL_BAT = MESH_SERIAL + ".bat";
+ public static final String MESH_PARALLEL = "mesh_parallel";
+ public static final String MESH_PARALLEL_RUN = MESH_PARALLEL + ".run";
+ public static final String MESH_PARALLEL_BAT = MESH_PARALLEL + ".bat";
protected static final String CHECK_MESH = "Check Mesh";
public static final String CHECK_MESH_SERIAL_RUN = "check_mesh_serial.run";
@@ -46,15 +47,25 @@ public abstract class AbstractScriptFactory implements ScriptFactory {
public static final String CHECK_MESH_PARALLEL_RUN = "check_mesh_parallel.run";
public static final String CHECK_MESH_PARALLEL_BAT = "check_mesh_parallel.bat";
+ protected static final String SNAPPY_CHECK_MESH = "Snappy Check Mesh";
+ public static final String SNAPPY_CHECK_MESH_SERIAL_RUN = "snappy_check_mesh_serial.run";
+ public static final String SNAPPY_CHECK_MESH_SERIAL_BAT = "snappy_check_mesh_serial.bat";
+ public static final String SNAPPY_CHECK_MESH_PARALLEL_RUN = "snappy_check_mesh_parallel.run";
+ public static final String SNAPPY_CHECK_MESH_PARALLEL_BAT = "snappy_check_mesh_parallel.bat";
+
protected static final String RUN_CASE = "Run Case";
+ public static final String SOLVER_SERIAL = "solver_serial";
public static final String SOLVER_SERIAL_RUN = "solver_serial.run";
public static final String SOLVER_SERIAL_BAT = "solver_serial.bat";
+ public static final String SOLVER_PARALLEL = "solver_parallel";
public static final String SOLVER_PARALLEL_RUN = "solver_parallel.run";
public static final String SOLVER_PARALLEL_BAT = "solver_parallel.bat";
protected static final String INITIALISE_FIELDS = "Initialise Fields";
+ public static final String INITIALISE_FIELDS_SERIAL = "initialiseFields_serial";
public static final String INITIALISE_FIELDS_SERIAL_RUN = "initialiseFields_serial.run";
public static final String INITIALISE_FIELDS_SERIAL_BAT = "initialiseFields_serial.bat";
+ public static final String INITIALISE_FIELDS_PARALLEL = "initialiseFields_parallel";
public static final String INITIALISE_FIELDS_PARALLEL_RUN = "initialiseFields_parallel.run";
public static final String INITIALISE_FIELDS_PARALLEL_BAT = "initialiseFields_parallel.bat";
@@ -64,6 +75,12 @@ public abstract class AbstractScriptFactory implements ScriptFactory {
private static final String EXTRUDEMESH_PARALLEL_RUN = "extrudeMesh_parallel.run";
private static final String EXTRUDEMESH_PARALLEL_BAT = "extrudeMesh_parallel.bat";
+ protected static final String EXPORT = "Export Results";
+ private static final String EXPORT_SERIAL_RUN = "exportResults_serial.run";
+ private static final String EXPORT_SERIAL_BAT = "exportResults_serial.bat";
+ private static final String EXPORT_PARALLEL_RUN = "exportResults_parallel.run";
+ private static final String EXPORT_PARALLEL_BAT = "exportResults_parallel.bat";
+
/*
* MESH
*/
@@ -102,14 +119,14 @@ public abstract class AbstractScriptFactory implements ScriptFactory {
return script;
}
- private File getMeshParallelScript(Model model) {
+ protected File getMeshParallelScript(Model model) {
File file = new File(model.getProject().getBaseDir(), Util.isWindowsScriptStyle() ? MESH_PARALLEL_BAT : MESH_PARALLEL_RUN);
writeFileIfNeeded(file, getParallelMeshScript());
file.setExecutable(true);
return file;
}
- private File getMeshSerialScript(Model model) {
+ protected File getMeshSerialScript(Model model) {
File file = new File(model.getProject().getBaseDir(), Util.isWindowsScriptStyle() ? MESH_SERIAL_BAT : MESH_SERIAL_RUN);
writeFileIfNeeded(file, getSerialMeshScript());
file.setExecutable(true);
@@ -136,9 +153,9 @@ public abstract class AbstractScriptFactory implements ScriptFactory {
public List getDefaultCheckMeshScript(Model model) {
List script = null;
if (model.getProject().isParallel()) {
- script = getParallelMeshScript();
+ script = getParallelCheckMeshScript();
} else {
- script = getSerialMeshScript();
+ script = getSerialCheckMeshScript();
}
return script;
}
@@ -161,6 +178,47 @@ public abstract class AbstractScriptFactory implements ScriptFactory {
protected abstract List getSerialCheckMeshScript();
+ @Override
+ public File getSnappyCheckMeshScript(Model model) {
+ File parallelScript = getSnappyCheckMeshParallelScript(model);
+ File serialScript = getSnappyCheckMeshSerialScript(model);
+
+ if (model.getProject().isParallel()) {
+ return parallelScript;
+ } else {
+ return serialScript;
+ }
+ }
+
+ @Override
+ public List getDefaultSnappyCheckMeshScript(Model model) {
+ List script = null;
+ if (model.getProject().isParallel()) {
+ script = getParallelSnappyCheckMeshScript();
+ } else {
+ script = getSerialSnappyCheckMeshScript();
+ }
+ return script;
+ }
+
+ private File getSnappyCheckMeshParallelScript(Model model) {
+ File file = new File(model.getProject().getBaseDir(), Util.isWindowsScriptStyle() ? CHECK_MESH_PARALLEL_BAT : CHECK_MESH_PARALLEL_RUN);
+ writeFileIfNeeded(file, getParallelSnappyCheckMeshScript());
+ file.setExecutable(true);
+ return file;
+ }
+
+ private File getSnappyCheckMeshSerialScript(Model model) {
+ File file = new File(model.getProject().getBaseDir(), Util.isWindowsScriptStyle() ? CHECK_MESH_SERIAL_BAT : CHECK_MESH_SERIAL_RUN);
+ writeFileIfNeeded(file, getSerialSnappyCheckMeshScript());
+ file.setExecutable(true);
+ return file;
+ }
+
+ protected abstract List getParallelSnappyCheckMeshScript();
+
+ protected abstract List getSerialSnappyCheckMeshScript();
+
/*
* SOLVER
*/
@@ -315,18 +373,57 @@ public abstract class AbstractScriptFactory implements ScriptFactory {
protected abstract List getLinuxSetupCaseScript();
@Override
- public File getExportScript(Model model) {
+ public File getReportScript(Model model) {
File file = new File(model.getProject().getBaseDir(), "export.py");
- writeFileIfNeeded(file, getExportScript());
+ writeFileIfNeeded(file, getReportScript());
return file;
}
@Override
- public List getDefaultExportScript(Model model) {
- return getExportScript();
+ public List getDefaultReportScript(Model model) {
+ return getReportScript();
}
- protected abstract List getExportScript();
+ public abstract List getReportScript();
+
+ @Override
+ public File getExportScript(Model model) {
+ File parallelScript = getExportParallelScript(model);
+ File serialScript = getExporteSerialScript(model);
+
+ if (model.getProject().isParallel()) {
+ return parallelScript;
+ } else {
+ return serialScript;
+ }
+ }
+
+ @Override
+ public List getDefaultExportScript(Model model) {
+ List script = null;
+ if (model.getProject().isParallel()) {
+ script = getParallelExportScript();
+ } else {
+ script = getSerialExportScript();
+ }
+ return script;
+ }
+
+ protected File getExportParallelScript(Model model) {
+ File file = new File(model.getProject().getBaseDir(), Util.isWindowsScriptStyle() ? EXPORT_PARALLEL_BAT : EXPORT_PARALLEL_RUN);
+ writeFileIfNeeded(file, getParallelExportScript());
+ return file;
+ }
+
+ protected File getExporteSerialScript(Model model) {
+ File file = new File(model.getProject().getBaseDir(), Util.isWindowsScriptStyle() ? EXPORT_SERIAL_BAT : EXPORT_SERIAL_RUN);
+ writeFileIfNeeded(file, getSerialExportScript());
+ return file;
+ }
+
+ protected abstract List getParallelExportScript();
+
+ protected abstract List getSerialExportScript();
protected void writeFileIfNeeded(File file, List script) {
if (!file.exists()) {
diff --git a/src/eu/engys/core/controller/ApplicationActions.java b/src/eu/engys/core/controller/ApplicationActions.java
index 6c5f5ef..cab0777 100644
--- a/src/eu/engys/core/controller/ApplicationActions.java
+++ b/src/eu/engys/core/controller/ApplicationActions.java
@@ -1,43 +1,42 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import java.io.File;
-import eu.engys.core.controller.Controller.OpenOptions;
+import eu.engys.core.controller.Controller.OpenMode;
import eu.engys.core.project.CaseParameters;
public interface ApplicationActions {
- void createCase(CaseParameters params);
+ void createCase(CaseParameters params, OpenOptions oo);
- void openCase(File file);
+ void openCase(OpenOptions oo);
- void reopenCase(OpenOptions options);
+ void reopenCase(OpenMode mode);
void saveCase(File file);
diff --git a/src/eu/engys/core/controller/BatchActions.java b/src/eu/engys/core/controller/BatchActions.java
index 1dccc86..fc4c164 100644
--- a/src/eu/engys/core/controller/BatchActions.java
+++ b/src/eu/engys/core/controller/BatchActions.java
@@ -1,46 +1,48 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import java.io.File;
-import eu.engys.core.controller.Controller.OpenOptions;
-import eu.engys.core.controller.actions.TimeoutException;
+import eu.engys.core.controller.Controller.OpenMode;
import eu.engys.core.project.CaseParameters;
public interface BatchActions {
- void create(CaseParameters params);
- void open(File file);
- void reopen(OpenOptions options);
- void save(File file);
+ void create(CaseParameters params, OpenOptions oo);
+
+ void open(OpenOptions oo);
+
+ void reopen(OpenMode options);
+
+ void save(File file);
void setupCase();
- void stopCase() throws TimeoutException;
+
+ void stopCase() throws Exception;
+
void kill();
-
+
}
diff --git a/src/eu/engys/core/controller/Client.java b/src/eu/engys/core/controller/Client.java
index a5aa530..499e7c1 100644
--- a/src/eu/engys/core/controller/Client.java
+++ b/src/eu/engys/core/controller/Client.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import javax.swing.JComponent;
@@ -35,12 +34,10 @@ public interface Client {
void executeCommands(Command... command);
- ParserView getResidualView();
+ ParserView getResidualsView();
void refreshOnce();
- void loadState();
-
void stopCommand(Command command);
void killCommand(Command command);
@@ -59,4 +56,6 @@ public interface Client {
void waitForFinished();
+ void justConnect();
+
}
diff --git a/src/eu/engys/core/controller/ClientInfo.java b/src/eu/engys/core/controller/ClientInfo.java
index 719c8b3..983b9a5 100644
--- a/src/eu/engys/core/controller/ClientInfo.java
+++ b/src/eu/engys/core/controller/ClientInfo.java
@@ -1,50 +1,56 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import java.io.Serializable;
+import eu.engys.util.Util;
+
public class ClientInfo implements Serializable {
+ private String clientID;
private boolean connected;
- private ClientInfo(boolean connected) {
+ private ClientInfo(String clientID, boolean connected) {
+ this.clientID = clientID;
this.connected = connected;
}
public boolean isConnected() {
return connected;
}
+ public String getClientID() {
+ return clientID;
+ }
public static ClientInfo clientConnected() {
- return new ClientInfo(true);
+ return new ClientInfo(Util.generateID(), true);
}
- public static ClientInfo clientDisconnected() {
- return new ClientInfo(false);
+ public static ClientInfo clientDisconnected(String clientID) {
+ return new ClientInfo(clientID, false);
}
-}
+}
\ No newline at end of file
diff --git a/src/eu/engys/core/controller/ClientServerCommand.java b/src/eu/engys/core/controller/ClientServerCommand.java
index 4ecee38..096d298 100644
--- a/src/eu/engys/core/controller/ClientServerCommand.java
+++ b/src/eu/engys/core/controller/ClientServerCommand.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import java.io.Serializable;
@@ -41,13 +40,6 @@ public class ClientServerCommand implements Serializable {
this.parallel = false;
this.startParsers = false;
}
-
- public ClientServerCommand(Command command, String open, boolean parallel, boolean startParsers) {
- this.commands = new Command[]{command};
- this.open = open;
- this.parallel = parallel;
- this.startParsers = startParsers;
- }
public Command getCommand() {
return commands[0];
diff --git a/src/eu/engys/core/controller/Command.java b/src/eu/engys/core/controller/Command.java
index fbbc050..e8938f1 100644
--- a/src/eu/engys/core/controller/Command.java
+++ b/src/eu/engys/core/controller/Command.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
public enum Command {
@@ -32,6 +31,7 @@ public enum Command {
INITIALISE_FIELDS("", ""),
RUN_ALL("", ""),
EXTRUDE_TO_REGION("", ""),
+ EXPORT_RESULTS("", ""),
ANY("any", "Any"),
NONE("none", "None");
diff --git a/src/eu/engys/core/controller/CommandInfo.java b/src/eu/engys/core/controller/CommandInfo.java
index 81afbf7..22aaca6 100644
--- a/src/eu/engys/core/controller/CommandInfo.java
+++ b/src/eu/engys/core/controller/CommandInfo.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import java.io.Serializable;
@@ -66,6 +65,15 @@ public class CommandInfo implements Serializable {
ci.success = false;
return ci;
}
+
+ public static CommandInfo error(String message, Exception e) {
+ logger.warn(">>> SERVER WARNING: {}", message);
+ CommandInfo ci = new CommandInfo();
+ ci.message = message;
+ ci.exception = e;
+ ci.success = false;
+ return ci;
+ }
public static CommandInfo notConnected() {
CommandInfo ci = new CommandInfo();
@@ -88,4 +96,9 @@ public class CommandInfo implements Serializable {
return ci;
}
-}
+ @Override
+ public String toString() {
+ return "CommandInfo - msg: " + message + ", job ID: " + jobID + ", succes: " + success + ", exception: " + exception;
+ }
+
+}
\ No newline at end of file
diff --git a/src/eu/engys/core/controller/Controller.java b/src/eu/engys/core/controller/Controller.java
index a8aedc9..3c6c9b7 100644
--- a/src/eu/engys/core/controller/Controller.java
+++ b/src/eu/engys/core/controller/Controller.java
@@ -1,32 +1,33 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import eu.engys.core.controller.actions.CommandException;
+import eu.engys.core.executor.ExecutorTerminal;
+import eu.engys.core.executor.TerminalManager;
+import eu.engys.core.parameters.Parameters;
import eu.engys.core.project.ProjectReader;
import eu.engys.core.project.ProjectWriter;
import eu.engys.core.project.system.monitoringfunctionobjects.ParserView;
@@ -37,8 +38,8 @@ public interface Controller extends ApplicationActions, BatchActions {
EXIT, CONTINUE, NONE
}
- public enum OpenOptions {
- SERIAL, PARALLEL, CURRENT_SETTINGS, CHECK_FOLDER, MESH_ONLY
+ public enum OpenMode {
+ SERIAL, PARALLEL, CURRENT_SETTINGS, CHECK_FOLDER_ASK_USER, CHECK_FOLDER_PARALLEL, MESH_ONLY
}
boolean isDemo();
@@ -53,9 +54,9 @@ public interface Controller extends ApplicationActions, BatchActions {
public Server getServer();
public ParserView getResidualView();
- boolean allowActionsOnRunning(boolean exit);
+ boolean allowActionsOnRunning(boolean shouldAskConfirmation);
- void createReport();
+ void createReport(ExecutorTerminal terminal);
void executeCommand(Command command) throws CommandException;
@@ -65,4 +66,10 @@ public interface Controller extends ApplicationActions, BatchActions {
boolean isRunningCommand();
+ void applyParameters(Parameters parameters);
+
+ TerminalManager getTerminalManager();
+
+ void clearModel();
+
}
diff --git a/src/eu/engys/core/controller/ControllerListener.java b/src/eu/engys/core/controller/ControllerListener.java
index 6225c74..5ab1cc4 100644
--- a/src/eu/engys/core/controller/ControllerListener.java
+++ b/src/eu/engys/core/controller/ControllerListener.java
@@ -1,39 +1,36 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
-
public interface ControllerListener {
void beforeNewCase();
- void afterNewCase();
+ void afterNewCase(boolean loadMesh);
void beforeLoadCase();
- void afterLoadCase();
+ void afterLoadCase(boolean loadMesh);
void beforeReopenCase();
void afterReopenCase();
@@ -57,4 +54,5 @@ public interface ControllerListener {
void afterBlockMesh();
+ void afterSetupCase();
}
diff --git a/src/eu/engys/core/controller/DefaultNamingConvention.java b/src/eu/engys/core/controller/DefaultNamingConvention.java
index b8a8bdd..8b34ea3 100644
--- a/src/eu/engys/core/controller/DefaultNamingConvention.java
+++ b/src/eu/engys/core/controller/DefaultNamingConvention.java
@@ -1,41 +1,46 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import eu.engys.core.controller.actions.NamingConvention;
import eu.engys.core.project.geometry.Surface;
public class DefaultNamingConvention implements NamingConvention {
- @Override
- public String getCellZoneName(Surface surface) {
- return surface.getZoneName();
- }
@Override
public String getPatchName(Surface surface) {
return surface.getPatchName();
}
-}
+
+ @Override
+ public String getCellZoneName(Surface surface) {
+ return surface.getCellZoneName();
+ }
+
+ @Override
+ public String getFaceZoneName(Surface surface) {
+ return surface.getFaceZoneName();
+ }
+}
\ No newline at end of file
diff --git a/src/eu/engys/core/controller/DefaultScriptFactory.java b/src/eu/engys/core/controller/DefaultScriptFactory.java
index 03fb1d2..d4aa62a 100644
--- a/src/eu/engys/core/controller/DefaultScriptFactory.java
+++ b/src/eu/engys/core/controller/DefaultScriptFactory.java
@@ -1,35 +1,37 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import static eu.engys.core.OpenFOAMEnvironment.loadEnvironment;
import static eu.engys.core.OpenFOAMEnvironment.printHeader;
import static eu.engys.core.OpenFOAMEnvironment.printVariables;
import static eu.engys.util.OpenFOAMCommands.BLOCK_MESH;
+import static eu.engys.util.OpenFOAMCommands.CHECK_MESH_PARALLEL;
+import static eu.engys.util.OpenFOAMCommands.CHECK_MESH_PARALLEL_CONSTANT;
+import static eu.engys.util.OpenFOAMCommands.CHECK_MESH_SERIAL;
+import static eu.engys.util.OpenFOAMCommands.CHECK_MESH_SERIAL_CONSTANT;
import static eu.engys.util.OpenFOAMCommands.DECOMPOSE_PAR;
import static eu.engys.util.OpenFOAMCommands.DECOMPOSE_PAR_ALLREGIONS;
import static eu.engys.util.OpenFOAMCommands.DECOMPOSE_PAR_CONSTANT_ALLREGIONS;
@@ -42,8 +44,6 @@ import static eu.engys.util.OpenFOAMCommands.RUN_CASE_PARALLEL;
import static eu.engys.util.OpenFOAMCommands.RUN_CASE_SERIAL;
import static eu.engys.util.OpenFOAMCommands.RUN_MESH_PARALLEL;
import static eu.engys.util.OpenFOAMCommands.RUN_MESH_SERIAL;
-//import static eu.engys.util.OpenFOAMCommands.CHECK_MESH_PARALLEL;
-//import static eu.engys.util.OpenFOAMCommands.CHECK_MESH_SERIAL;
import static eu.engys.util.OpenFOAMCommands.SNAPPY_CHECK_MESH_PARALLEL;
import static eu.engys.util.OpenFOAMCommands.SNAPPY_CHECK_MESH_SERIAL;
@@ -102,7 +102,7 @@ public class DefaultScriptFactory extends AbstractScriptFactory {
sb.newLine();
sb.appendIf(performBlockMesh(), BLOCK_MESH());
sb.newLine();
- sb.appendIf(performBlockMesh(), DECOMPOSE_PAR());
+ sb.appendIf(performBlockMesh(), DECOMPOSE_PAR(Collections. emptySet()));
sb.newLine();
sb.append(RUN_MESH_PARALLEL());
sb.newLine();
@@ -118,7 +118,7 @@ public class DefaultScriptFactory extends AbstractScriptFactory {
printVariables(sb);
loadEnvironment(sb);
sb.newLine();
- sb.append(SNAPPY_CHECK_MESH_SERIAL());
+ sb.append(meshOnZero() ? CHECK_MESH_SERIAL() : CHECK_MESH_SERIAL_CONSTANT());
sb.newLine();
return sb.getLines();
}
@@ -130,6 +130,30 @@ public class DefaultScriptFactory extends AbstractScriptFactory {
printVariables(sb);
loadEnvironment(sb);
sb.newLine();
+ sb.append(meshOnZero() ? CHECK_MESH_PARALLEL() : CHECK_MESH_PARALLEL_CONSTANT());
+ sb.newLine();
+ return sb.getLines();
+ }
+
+ @Override
+ protected List getSerialSnappyCheckMeshScript() {
+ ScriptBuilder sb = new ScriptBuilder();
+ printHeader(sb, SNAPPY_CHECK_MESH);
+ printVariables(sb);
+ loadEnvironment(sb);
+ sb.newLine();
+ sb.append(SNAPPY_CHECK_MESH_SERIAL());
+ sb.newLine();
+ return sb.getLines();
+ }
+
+ @Override
+ protected List getParallelSnappyCheckMeshScript() {
+ ScriptBuilder sb = new ScriptBuilder();
+ printHeader(sb, SNAPPY_CHECK_MESH);
+ printVariables(sb);
+ loadEnvironment(sb);
+ sb.newLine();
sb.append(SNAPPY_CHECK_MESH_PARALLEL());
sb.newLine();
return sb.getLines();
@@ -216,7 +240,7 @@ public class DefaultScriptFactory extends AbstractScriptFactory {
sb.newLine();
sb.appendIf(meshOnZero(), RECONSTRUCT_PAR_MESH(), RECONSTRUCT_PAR_MESH_CONSTANT());
sb.append(EXTRUDE_REGION_TO_MESH());
- sb.appendIf(meshOnZero(), DECOMPOSE_PAR_ALLREGIONS(), DECOMPOSE_PAR_CONSTANT_ALLREGIONS());
+ sb.appendIf(meshOnZero(), DECOMPOSE_PAR_ALLREGIONS(Collections. emptySet()), DECOMPOSE_PAR_CONSTANT_ALLREGIONS(Collections. emptySet()));
sb.newLine();
return sb.getLines();
}
@@ -263,13 +287,13 @@ public class DefaultScriptFactory extends AbstractScriptFactory {
boolean copy = false;
for (String l : lines) {
- if(l.startsWith(end)){
+ if (l.startsWith(end)) {
break;
}
- if(copy){
+ if (copy) {
support.add(l);
}
- if(l.startsWith(start)){
+ if (l.startsWith(start)) {
copy = true;
}
}
@@ -280,17 +304,13 @@ public class DefaultScriptFactory extends AbstractScriptFactory {
InputStream inputStream = DefaultScriptFactory.class.getClassLoader().getResourceAsStream("eu/engys/resources/driver.pbs");
try {
String body = IOUtils.readStringFromStream(inputStream);
- return Arrays.asList(body.split(IOUtils.EOL));
+ return Arrays.asList(body.split(IOUtils.LNX_EOL));
} catch (IOException e) {
e.printStackTrace();
return Collections.emptyList();
}
}
- private List getWindowsQueueDriver() {
- throw new RuntimeException("NOT IMPLEMENTED");
- }
-
private List getLinuxQueueDriver(List body) {
String name = model.getProject().getBaseDir().getName();
@@ -366,7 +386,17 @@ public class DefaultScriptFactory extends AbstractScriptFactory {
}
@Override
- protected List getExportScript() {
+ protected List getSerialExportScript() {
+ throw new RuntimeException("NOT IMPLEMENTED");
+ }
+
+ @Override
+ protected List getParallelExportScript() {
+ throw new RuntimeException("NOT IMPLEMENTED");
+ }
+
+ @Override
+ public List getReportScript() {
throw new RuntimeException("NOT IMPLEMENTED");
}
@@ -380,7 +410,7 @@ public class DefaultScriptFactory extends AbstractScriptFactory {
e.printStackTrace();
}
- return Arrays.asList(driverString.split(IOUtils.EOL));
+ return Arrays.asList(driverString.split(IOUtils.LNX_EOL));
}
@Override
diff --git a/src/eu/engys/core/controller/GeometryToMesh.java b/src/eu/engys/core/controller/GeometryToMesh.java
index be0d799..014c2a6 100644
--- a/src/eu/engys/core/controller/GeometryToMesh.java
+++ b/src/eu/engys/core/controller/GeometryToMesh.java
@@ -1,35 +1,36 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import static eu.engys.core.project.system.SnappyHexMeshDict.BAFFLE_KEY;
import static eu.engys.core.project.system.SnappyHexMeshDict.BOUNDARY_KEY;
+import static eu.engys.core.project.system.SnappyHexMeshDict.CELL_ZONE_KEY;
import static eu.engys.core.project.system.SnappyHexMeshDict.FACE_TYPE_KEY;
import static eu.engys.core.project.system.SnappyHexMeshDict.FACE_ZONE_KEY;
import static eu.engys.core.project.system.SnappyHexMeshDict.INSIDE;
+import static eu.engys.core.project.system.SnappyHexMeshDict.IS_CELL_ZONE_KEY;
import static eu.engys.core.project.system.SnappyHexMeshDict.LEVELS_KEY;
import static eu.engys.core.project.system.SnappyHexMeshDict.MODE_KEY;
import static eu.engys.core.project.system.SnappyHexMeshDict.NONE_KEY;
@@ -48,20 +49,25 @@ import eu.engys.core.project.geometry.Surface;
import eu.engys.core.project.geometry.surface.Region;
import eu.engys.core.project.geometry.surface.Solid;
import eu.engys.core.project.zero.cellzones.CellZone;
+import eu.engys.core.project.zero.facezones.FaceZone;
import eu.engys.core.project.zero.patches.BoundaryConditions;
import eu.engys.core.project.zero.patches.BoundaryType;
import eu.engys.core.project.zero.patches.Patch;
public class GeometryToMesh {
+ public static final String SLAVE_SUFFIX = "_slave";
+
private static final Logger logger = LoggerFactory.getLogger(GeometryToMesh.class);
private Model model;
private List patches = new ArrayList<>();
private List cellZones = new ArrayList<>();
+ private List faceZones = new ArrayList<>();
private List willBePatches = new ArrayList<>();
private List willBeCellZones = new ArrayList<>();
+ private List willBeFaceZones = new ArrayList<>();
private NamingConvention naming;
@@ -84,26 +90,27 @@ public class GeometryToMesh {
public void execute() {
model.getPatches().clear();
model.getCellZones().clear();
+ model.getFaceZones().clear();
extractPatchesFromGeometry();
model.getPatches().addPatches(patches);
model.getCellZones().addZones(cellZones);
- }
-
- public List getWillBePatches() {
- return willBePatches;
- }
-
- public List getWillBeCellZones() {
- return willBeCellZones;
+ model.getFaceZones().addZones(faceZones);
}
private void extractPatchesFromGeometry() {
for (Surface surface : model.getGeometry().getSurfaces()) {
logger.debug("Surface {}: {} {} {}", surface.getName(), surface.getSurfaceDictionary(), surface.getVolumeDictionary(), surface.getZoneDictionary());
+
surfaceToPatch(surface);
surfaceToCellZone(surface);
+ surfaceToFaceZone(surface);
+ if (willCreatePatches(surface)) {
+ zoneToPatches(surface);
+ } else {
+ logger.debug("'{}' does NOT become a PATCH+SLAVE", surface.getName());
+ }
}
if (model.getGeometry().hasBlock()) {
@@ -111,25 +118,49 @@ public class GeometryToMesh {
}
}
+ private void surfaceToPatch(Surface surface) {
+ if (surface.isSingleton()) {
+ addPatch(surface);
+ } else if (surface.hasRegions()) {
+ for (Region region : surface.getRegions()) {
+ addPatch(region);
+ }
+ } else {
+ addPatch(surface);
+ }
+ }
+
private void surfaceToCellZone(Surface surface) {
if (willBeACellZone(surface)) {
- if (willCreatePatches(surface)) {
- zoneToPatches(surface);
- } else {
- logger.debug("'{}' does NOT become a PATCH+SLAVE", surface.getName());
- }
String zoneName = naming.getCellZoneName(surface);
CellZone zone = new CellZone(zoneName);
zone.setName(zoneName);
zone.setVisible(true);
zone.setLoaded(true);
- logger.debug("'{}' becomes a ZONE with name {}", surface.getName(), zoneName);
+ logger.debug("'{}' becomes a CELLZONE with name {}", surface.getName(), zoneName);
cellZones.add(zone);
willBeCellZones.add(surface);
} else {
- logger.debug("'{}' does NOT become a ZONE", surface.getName());
+ logger.debug("'{}' does NOT become a CELLZONE", surface.getName());
+ }
+ }
+
+ private void surfaceToFaceZone(Surface surface) {
+ if (willBeAFaceZone(surface)) {
+ String zoneName = naming.getFaceZoneName(surface);
+ FaceZone zone = new FaceZone(zoneName);
+ zone.setName(zoneName);
+ zone.setVisible(true);
+ zone.setLoaded(true);
+
+ logger.debug("'{}' becomes a FACEZONE with name {}", surface.getName(), zoneName);
+
+ faceZones.add(zone);
+ willBeFaceZones.add(surface);
+ } else {
+ logger.debug("'{}' does NOT become a FACEZONE", surface.getName());
}
}
@@ -148,15 +179,48 @@ public class GeometryToMesh {
addPatchAndSlave(surface);
}
}
+
+ private boolean willBeAPatch(Surface surface) {
+ boolean typePlane = surface.getType().isPlane();
+ boolean singletonSTLRefinementOnly = surface.getType().isStl() && surface.isSingleton() && isSurfaceRefinementOnly(surface);
+ boolean typeSolidAndParentOK = surface.getType().isSolid() && willBeAPatch(((Solid) surface).getParent());
+ boolean notSolidButRefinementOnly = !surface.getType().isSolid() && isSurfaceRefinementOnly(surface);
+ return typePlane || singletonSTLRefinementOnly || typeSolidAndParentOK || notSolidButRefinementOnly;
+ }
private boolean willBeACellZone(Surface surface) {
Dictionary zoneDictionary = surface.getZoneDictionary();
- return zoneDictionary != null && !zoneDictionary.isEmpty() && zoneDictionary.isField(FACE_ZONE_KEY) && zoneDictionary.found(FACE_TYPE_KEY) && !zoneDictionary.lookup(FACE_TYPE_KEY).equals(NONE_KEY);
+ if (zoneDictionary == null) {
+ return false;
+ } else {
+ boolean hasCellZoneField = zoneDictionary.isField(CELL_ZONE_KEY);
+ boolean isCellZoneTrue = zoneDictionary.found(IS_CELL_ZONE_KEY) && zoneDictionary.lookupBoolean(IS_CELL_ZONE_KEY);
+ boolean faceTypeIsNotNone = zoneDictionary.found(FACE_TYPE_KEY) && !zoneDictionary.lookup(FACE_TYPE_KEY).equals(NONE_KEY);
+ return hasCellZoneField && isCellZoneTrue && faceTypeIsNotNone;
+ }
+ }
+
+ private boolean willBeAFaceZone(Surface surface) {
+ Dictionary zoneDictionary = surface.getZoneDictionary();
+ if (zoneDictionary == null) {
+ return false;
+ } else {
+ boolean hasFaceZoneField = zoneDictionary.isField(FACE_ZONE_KEY);
+ boolean faceTypeIsNotNone = zoneDictionary.found(FACE_TYPE_KEY) && !zoneDictionary.lookup(FACE_TYPE_KEY).equals(NONE_KEY);
+ return hasFaceZoneField && faceTypeIsNotNone;
+ }
}
private boolean willCreatePatches(Surface surface) {
Dictionary zoneDictionary = surface.getZoneDictionary();
- return zoneDictionary.found(FACE_TYPE_KEY) && (zoneDictionary.lookup(FACE_TYPE_KEY).equals(BOUNDARY_KEY) || zoneDictionary.lookup(FACE_TYPE_KEY).equals(BAFFLE_KEY));
+ if (zoneDictionary == null) {
+ return false;
+ } else {
+ boolean faceTypeIsBoundary = zoneDictionary.found(FACE_TYPE_KEY) && (zoneDictionary.lookup(FACE_TYPE_KEY).equals(BOUNDARY_KEY));
+ boolean faceTypeIsBaffle = zoneDictionary.found(FACE_TYPE_KEY) && (zoneDictionary.lookup(FACE_TYPE_KEY).equals(BAFFLE_KEY));
+
+ return faceTypeIsBoundary || faceTypeIsBaffle;
+ }
}
private boolean isBoundary(Surface surface) {
@@ -169,18 +233,6 @@ public class GeometryToMesh {
return zoneDictionary.lookup(FACE_TYPE_KEY).equals(BAFFLE_KEY);
}
- private void surfaceToPatch(Surface surface) {
- if (surface.isSingleton()) {
- addPatch(surface);
- } else if (surface.hasRegions()) {
- for (Region region : surface.getRegions()) {
- addPatch(region);
- }
- } else {
- addPatch(surface);
- }
- }
-
private void addPatch(Surface surface) {
if (willBeAPatch(surface)) {
String patchName = naming.getPatchName(surface);
@@ -194,7 +246,7 @@ public class GeometryToMesh {
private void addPatchAndSlave(Surface surface) {
String patchName = naming.getPatchName(surface);
- String slaveName = patchName + "_slave";
+ String slaveName = patchName + SLAVE_SUFFIX;
logger.debug("'{}' becomes 2 PATCHES with name {} and {}", surface.getName(), patchName, slaveName);
patches.add(newPatch(patchName));
willBePatches.add(surface);
@@ -209,25 +261,19 @@ public class GeometryToMesh {
patch.setVisible(true);
patch.setLoaded(true);
patch.setEmpty(false);
- patch.setPhisicalType(BoundaryType.getDefaultType());
+ patch.setPhysicalType(BoundaryType.getDefaultType());
patch.setBoundaryConditions(new BoundaryConditions());
return patch;
}
- private boolean willBeAPatch(Surface surface) {
- return surface.getType().isPlane()
- || (surface.getType().isStl() && surface.isSingleton() && isSurfaceRefinementOnly(surface))
- || (surface.getType().isSolid() && willBeAPatch(((Solid)surface).getParent()) )
- || (!surface.getType().isSolid() && isSurfaceRefinementOnly(surface));
- }
-
private boolean isSurfaceRefinementOnly(Surface surface) {
boolean surfaceRefinement = isSurfaceRefinement(surface);
boolean volumeRefinement = isVolumeRefinement(surface);
boolean willBeACellZone = willBeACellZone(surface);
+ boolean willBeAFaceZone = willBeAFaceZone(surface);
// System.err.println("GeometryToMesh.isSurfaceRefinementOnly() surfaceRefinement: "+surfaceRefinement+", volumeRefinement: "+volumeRefinement+", willBeACellZone: "+willBeACellZone);
- return surfaceRefinement && !volumeRefinement && !willBeACellZone;
+ return surfaceRefinement && !volumeRefinement && !willBeACellZone && !willBeAFaceZone;
}
private boolean isVolumeRefinement(Surface surface) {
@@ -248,4 +294,20 @@ public class GeometryToMesh {
return naming.getCellZoneName(surface);
}
+ public String getFaceZoneName(Surface surface) {
+ return naming.getFaceZoneName(surface);
+ }
+
+ public List getWillBePatches() {
+ return willBePatches;
+ }
+
+ public List getWillBeCellZones() {
+ return willBeCellZones;
+ }
+
+ public List getWillBeFaceZones() {
+ return willBeFaceZones;
+ }
+
}
diff --git a/src/eu/engys/core/controller/HelyxOSController.java b/src/eu/engys/core/controller/HelyxOSController.java
index 26c3443..e617dd4 100644
--- a/src/eu/engys/core/controller/HelyxOSController.java
+++ b/src/eu/engys/core/controller/HelyxOSController.java
@@ -1,31 +1,30 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
-import static eu.engys.core.project.system.SetFieldsDict.CELL_SET_KEY;
+import static javax.swing.JOptionPane.ERROR_MESSAGE;
import java.io.File;
import java.util.List;
@@ -42,24 +41,27 @@ import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
import eu.engys.core.controller.actions.CheckMesh;
+import eu.engys.core.controller.actions.DecomposeCaseAction;
import eu.engys.core.controller.actions.InitialiseFields;
import eu.engys.core.controller.actions.RunCommand;
import eu.engys.core.controller.actions.StandardInitialiseFields;
import eu.engys.core.controller.actions.StandardRunCase;
import eu.engys.core.controller.actions.StandardRunMesh;
-import eu.engys.core.controller.actions.TimeoutException;
import eu.engys.core.executor.Executor;
+import eu.engys.core.executor.TerminalManager;
import eu.engys.core.modules.ApplicationModule;
+import eu.engys.core.parameters.Parameters;
import eu.engys.core.presentation.Action;
import eu.engys.core.presentation.ActionManager;
import eu.engys.core.project.Model;
import eu.engys.core.project.ProjectReader;
import eu.engys.core.project.ProjectWriter;
+import eu.engys.core.project.geometry.surface.Stl;
import eu.engys.core.project.state.ServerState;
import eu.engys.core.project.system.monitoringfunctionobjects.ParserView;
import eu.engys.core.project.system.monitoringfunctionobjects.TimeBlocks;
+import eu.engys.core.project.zero.ZeroFileManager;
import eu.engys.core.project.zero.cellzones.CellZonesBuilder;
-import eu.engys.core.project.zero.fields.Field;
import eu.engys.gui.casesetup.fields.StandardInitialisations;
import eu.engys.gui.events.EventManager;
import eu.engys.gui.events.EventManager.Event;
@@ -67,33 +69,53 @@ import eu.engys.gui.events.EventManager.GenericEventListener;
import eu.engys.gui.events.application.ApplicationEvent;
import eu.engys.gui.events.application.BaseMeshTypeChangedEvent;
import eu.engys.gui.events.application.OpenMonitorEvent;
+import eu.engys.gui.events.view3D.AddSurfaceEvent;
import eu.engys.gui.solver.postprocessing.ParsersHandler;
import eu.engys.gui.solver.postprocessing.ParsersViewHandler;
import eu.engys.gui.solver.postprocessing.panels.residuals.ResidualsView;
+import eu.engys.parallelworks.CloudPanel;
+import eu.engys.parallelworks.ParallelWorksClient;
+import eu.engys.parallelworks.ParallelWorksData;
+import eu.engys.parallelworks.actions.ParallelWorksInitialiseFields;
+import eu.engys.parallelworks.actions.ParallelWorksRunCase;
+import eu.engys.parallelworks.actions.ParallelWorksRunMesh;
+import eu.engys.util.ApplicationInfo;
+import eu.engys.util.PrefUtil;
import eu.engys.util.progress.ProgressMonitor;
+import eu.engys.util.progress.SilentMonitor;
import eu.engys.util.ui.ScriptEditor;
import eu.engys.util.ui.UiUtil;
public class HelyxOSController extends AbstractController implements GenericEventListener, ParsersManager {
+ private static final String PARALLEL_WORKS_RESOURCES_ERROR_TITLE = "Remote Error";
+ private static final String PARALLEL_WORKS_RESOURCES_ERROR_MESSAGE = "No Compute Resources Available - Please Start your Resources on Parallel Works";
+
private static final long TIMER_INITIAL_DELAY = 500L;
private static final long TIMER_REFRESH_RATE = 1000L;
private static final Logger logger = LoggerFactory.getLogger(HelyxOSController.class);
- private ResidualsView residualsView;
+ private ParserView residualsView;
private RunCommand command;
private Timer timer;
private ParsersHandler parsersHandler;
private ParsersViewHandler viewHandler;
private ThreadPoolExecutor executor;
+ private TerminalManager terminalManager;
@Inject
public HelyxOSController(Model model, CellZonesBuilder cellZonesBuilder, Set modules, ProjectReader reader, ProjectWriter writer, CellZonesBuilder zonesBuilder, ProgressMonitor monitor, ScriptFactory scriptFactory) {
super(model, modules, reader, writer, zonesBuilder, monitor, scriptFactory);
- this.residualsView = new ResidualsView(model, monitor);
+ this.residualsView = new ResidualsView(model, modules, monitor);
EventManager.registerEventListener(this, ApplicationEvent.class);
ActionManager.getInstance().parseActions(this);
+ this.terminalManager = new TerminalManager();
+ }
+
+ @Override
+ public TerminalManager getTerminalManager() {
+ return terminalManager;
}
@Override
@@ -110,16 +132,25 @@ public class HelyxOSController extends AbstractController implements GenericEven
* MESH
*/
- @Action(key = "mesh.create", checkEnv = true)
+ @Action(key = MESH_CREATE, checkEnv = true)
public void runMesh() {
save(model.getProject().getBaseDir());
- command = new StandardRunMesh(model, this, scriptFactory);
+ if (PrefUtil.isRunningOnCloud()) {
+ if (ParallelWorksClient.getInstance().isPoolOn()) {
+ command = new ParallelWorksRunMesh(model, this, scriptFactory, monitor);
+ } else {
+ JOptionPane.showMessageDialog(UiUtil.getActiveWindow(), PARALLEL_WORKS_RESOURCES_ERROR_MESSAGE, PARALLEL_WORKS_RESOURCES_ERROR_TITLE, JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+ } else {
+ command = new StandardRunMesh(model, this, scriptFactory);
+ }
command.beforeExecute();
command.executeClient();
}
- @Action(key = "mesh.check", checkEnv = true)
+ @Action(key = MESH_CHECK, checkEnv = true)
public void checkMesh() {
model.getProject().getSystemFolder().write(model, null);
RunCommand checkMesh = new CheckMesh(model, this, scriptFactory);
@@ -136,13 +167,13 @@ public class HelyxOSController extends AbstractController implements GenericEven
monitor.start("Open " + model.getProject().getBaseDir(), false, new Runnable() {
@Override
public void run() {
- reopen(OpenOptions.CURRENT_SETTINGS);
+ reopen(OpenMode.CURRENT_SETTINGS);
monitor.end();
}
});
}
- @Action(key = "initialise.fields", checkEnv = true)
+ @Action(key = INITIALISE_SCRIPT, checkEnv = true)
public void initialiseFields() {
if (model.getProject().getZeroFolder().hasNonZeroTimeFolders()) {
int retVal = JOptionPane.showConfirmDialog(UiUtil.getActiveWindow(), "This action will DELETE all the time folders. Continue?", "Initialise Fields", JOptionPane.YES_NO_OPTION);
@@ -161,23 +192,46 @@ public class HelyxOSController extends AbstractController implements GenericEven
}
});
- new StandardInitialisations(model, cellZonesBuilder, modules).initializeFields();
- if (cellSetFieldPresent()) {
+ StandardInitialisations initialisations = new StandardInitialisations(model, monitor);
+ initialisations.initializeFields();
+
+ model.getProject().getZeroFolder().write(model, cellZonesBuilder, modules, initialisations, new SilentMonitor());
+ if (model.getFields().hasCellSetInitialisationField() || model.getFields().hasPotentialFlowInitialisationField()) {
save(model.getProject().getBaseDir());
- command = new StandardInitialiseFields(model, this, scriptFactory);
+ if (PrefUtil.isRunningOnCloud()) {
+ if (ParallelWorksClient.getInstance().isPoolOn()) {
+ JOptionPane.showMessageDialog(UiUtil.getActiveWindow(), PARALLEL_WORKS_RESOURCES_ERROR_MESSAGE, PARALLEL_WORKS_RESOURCES_ERROR_TITLE, ERROR_MESSAGE);
+ command = new ParallelWorksInitialiseFields(model, this, scriptFactory, monitor);
+ } else {
+ return;
+ }
+ } else {
+ command = new StandardInitialiseFields(model, this, scriptFactory);
+ }
command.beforeExecute();
command.executeClient();
+ } else {
+ // just clear polymesh
+ ((ZeroFileManager) model.getProject().getZeroFolder().getFileManager()).removeNonZeroDirs("0");
}
}
- public boolean cellSetFieldPresent() {
- for (Field f : model.getFields().values()) {
- if (f.getInitialisationType().equals(CELL_SET_KEY)) {
- return true;
- }
- }
- return false;
+ /*
+ * DECOMPOSE
+ */
+ @Action(key = DECOMPOSE)
+ public void decomposeCase() {
+ new DecomposeCaseAction(model, this, true).executeClient();
+ }
+
+ /*
+ * Parallel Works
+ */
+ @Action(key = PARALLEL_WORKS)
+ public void openCloud() {
+ new CloudPanel(model, this, monitor).showDialog(ParallelWorksData.fromPrefences());
+
}
/*
@@ -186,7 +240,7 @@ public class HelyxOSController extends AbstractController implements GenericEven
private void startTimer() {
startParsers();
- viewHandler = new ParsersViewHandler(model, this, residualsView);
+ viewHandler = new ParsersViewHandler(model, modules, this, residualsView);
executor = Executor.newExecutor("ServerStateMonitor");
if (timer == null) {
@@ -243,7 +297,18 @@ public class HelyxOSController extends AbstractController implements GenericEven
save(model.getProject().getBaseDir());
listener.beforeRunCase();
- command = new StandardRunCase(model, this, scriptFactory);
+
+ if (PrefUtil.isRunningOnCloud()) {
+ if (ParallelWorksClient.getInstance().isPoolOn()) {
+ command = new ParallelWorksRunCase(model, this, scriptFactory, monitor);
+ } else {
+ JOptionPane.showMessageDialog(UiUtil.getActiveWindow(), PARALLEL_WORKS_RESOURCES_ERROR_MESSAGE, PARALLEL_WORKS_RESOURCES_ERROR_TITLE, JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+ } else {
+ command = new StandardRunCase(model, this, scriptFactory);
+ }
+
command.beforeExecute();
command.executeClient();
@@ -252,7 +317,7 @@ public class HelyxOSController extends AbstractController implements GenericEven
@Action(key = "solver.refresh.once")
public void refreshOnce() {
- ParsersViewHandler viewHandler = new ParsersViewHandler(model, this, residualsView);
+ ParsersViewHandler viewHandler = new ParsersViewHandler(model, modules, this, residualsView);
viewHandler.refreshOnce();
}
@@ -274,7 +339,7 @@ public class HelyxOSController extends AbstractController implements GenericEven
private void _stopCase() {
try {
command.stop();
- } catch (TimeoutException e) {
+ } catch (Exception e) {
Object[] options = new Object[] { "Wait", "Kill Process" };
int option = JOptionPane.showOptionDialog(monitor.getDialog(), "Solver has not finished yet.\nSelect an action to perform.", "Stop Execution", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
if (timer != null) {
@@ -306,26 +371,49 @@ public class HelyxOSController extends AbstractController implements GenericEven
command.kill();
}
+ /*
+ * IMPORT FILES
+ */
+ @Override
+ protected void importFiles(final File[] stlFiles) {
+ if (stlFiles != null) {
+ monitor.setIndeterminate(false);
+ monitor.start("Loading STL Files", false, new Runnable() {
+ @Override
+ public void run() {
+ for (File file : stlFiles) {
+ Stl stl = model.getGeometry().getFactory().readSTL(file, monitor);
+ model.getGeometry().addSurface(stl);
+ model.geometryChanged(stl);
+
+ EventManager.triggerEvent(this, new AddSurfaceEvent(stl));
+ }
+ monitor.end();
+ }
+ });
+ }
+ }
+
/*
* EDIT SCRIPTS
*/
- @Action(key = "solver.run.edit")
+ @Action(key = SOLVER_RUN_EDIT)
public void editRunCaseScript() {
ScriptEditor.getInstance().show(scriptFactory.getSolverScript(model).toPath(), scriptFactory.getDefaultSolverScript(model));
}
- @Action(key = "mesh.create.edit")
+ @Action(key = MESH_CREATE_EDIT)
public void editRunMeshScript() {
ScriptEditor.getInstance().show(scriptFactory.getMeshScript(model).toPath(), scriptFactory.getDefaultMeshScript(model));
}
- @Action(key = "mesh.check.edit")
+ @Action(key = MESH_CHECK_EDIT)
public void editCheckMeshScript() {
ScriptEditor.getInstance().show(scriptFactory.getCheckMeshScript(model).toPath(), scriptFactory.getDefaultCheckMeshScript(model));
}
- @Action(key = "initialise.fields.edit")
+ @Action(key = INITIALISE_SCRIPT_EDIT)
public void editInitialiseScript() {
ScriptEditor.getInstance().show(scriptFactory.getInitialiseScript(model).toPath(), scriptFactory.getDefaultInitialiseScript(model));
}
@@ -336,7 +424,7 @@ public class HelyxOSController extends AbstractController implements GenericEven
@Override
public void startParsers() {
logger.info("[SERVER] START PARSERS");
- parsersHandler = new ParsersHandler(model);
+ parsersHandler = new ParsersHandler(model, modules);
parsersHandler.deleteUselessLogFiles();
}
@@ -358,7 +446,7 @@ public class HelyxOSController extends AbstractController implements GenericEven
@Override
public List updateParserOnce(String foName) {
logger.info("[SERVER] UPDATE PARSERS ONCE");
- ParsersHandler ph = new ParsersHandler(model);
+ ParsersHandler ph = new ParsersHandler(model, modules);
return ph.refreshOnceForFunctionObject(foName);
}
@@ -372,8 +460,8 @@ public class HelyxOSController extends AbstractController implements GenericEven
}
@Override
- public void open(File baseDir) {
- super.open(baseDir);
+ public void open(OpenOptions oo) {
+ super.open(oo);
if (listener != null) {
// client.loadState();
listener.selectDestinationAndGo();
@@ -381,7 +469,7 @@ public class HelyxOSController extends AbstractController implements GenericEven
}
@Override
- public void reopen(OpenOptions options) {
+ public void reopen(OpenMode options) {
if (listener != null) {
listener.saveLocation();
}
@@ -411,18 +499,21 @@ public class HelyxOSController extends AbstractController implements GenericEven
}
@Override
- protected boolean handleExitOnSolverRunning() {
- Object[] options = new Object[] { STOP_SOLVER, KILL_SOLVER, CANCEL };
- int option = JOptionPane.showOptionDialog(UiUtil.getActiveWindow(), "Solver is Running. Select an action to perform.", STOP_SOLVER, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
+ protected boolean handleExitOnRunning() {
+ Object[] options = new Object[] { KILL_PROCESS, CANCEL };
+ String message = ApplicationInfo.getName() + " is running. Select an action to perform.";
+ String title = ApplicationInfo.getName();
+ int option = JOptionPane.showOptionDialog(UiUtil.getActiveWindow(), message, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
if (option == JOptionPane.YES_OPTION) {
- stopCase();
- return true;
- } else if (option == JOptionPane.NO_OPTION) {
kill();
return true;
- } else {
- return false;
}
+ return false;
}
+
+ @Override
+ public void applyParameters(Parameters parameters) {
+ }
+
}
diff --git a/src/eu/engys/core/controller/ILogServer.java b/src/eu/engys/core/controller/ILogServer.java
index 0f5708d..de3747f 100644
--- a/src/eu/engys/core/controller/ILogServer.java
+++ b/src/eu/engys/core/controller/ILogServer.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import java.io.Serializable;
diff --git a/src/eu/engys/core/controller/KillCommandOS.java b/src/eu/engys/core/controller/KillCommandOS.java
new file mode 100644
index 0000000..d3d52ec
--- /dev/null
+++ b/src/eu/engys/core/controller/KillCommandOS.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
+package eu.engys.core.controller;
+
+import javax.swing.JOptionPane;
+
+import eu.engys.util.ui.UiUtil;
+
+public class KillCommandOS implements Runnable {
+
+ private Controller controller;
+
+ public KillCommandOS(Controller controller) {
+ this.controller = controller;
+ }
+
+ @Override
+ public void run() {
+ int retVal = JOptionPane.showConfirmDialog(UiUtil.getActiveWindow(), "Stop execution?", "Close Monitor", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
+ if (retVal == JOptionPane.YES_OPTION) {
+ controller.kill();
+ }
+ }
+}
diff --git a/src/eu/engys/core/controller/LogClient.java b/src/eu/engys/core/controller/LogClient.java
index 97ea61f..1353c17 100644
--- a/src/eu/engys/core/controller/LogClient.java
+++ b/src/eu/engys/core/controller/LogClient.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import java.io.OutputStream;
@@ -32,10 +31,6 @@ public interface LogClient extends Serializable {
void start(String key, OutputStream out, OutputStream err);
- void pump(String key, String lines);
-
- void close();
-
void stop(String key);
}
diff --git a/src/eu/engys/core/controller/OpenOptions.java b/src/eu/engys/core/controller/OpenOptions.java
new file mode 100644
index 0000000..d55ef39
--- /dev/null
+++ b/src/eu/engys/core/controller/OpenOptions.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
+package eu.engys.core.controller;
+
+import java.io.File;
+
+import eu.engys.core.controller.Controller.OpenMode;
+
+public class OpenOptions {
+ private File file;
+ private File[] filesToImport;
+ private boolean loadMesh;
+ private OpenMode mode;
+
+ public OpenOptions() {
+ }
+
+ private OpenOptions(File file, File[] files, boolean loadMesh, OpenMode mode) {
+ this.file = file;
+ this.filesToImport = files;
+ this.loadMesh = loadMesh;
+ this.mode = mode;
+ }
+
+ public static OpenOptions file(File file, OpenMode mode) {
+ return new OpenOptions(file, null, true, mode);
+ }
+
+ public OpenOptions importFiles(File[] filesToImport) {
+ this.filesToImport = filesToImport;
+ return this;
+ }
+ public OpenOptions loadMesh(boolean loadMesh) {
+ this.loadMesh = loadMesh;
+ return this;
+ }
+
+ public File getFile() {
+ return file;
+ }
+ public OpenMode getMode() {
+ return mode;
+ }
+ public File[] getFilesToImport() {
+ return filesToImport;
+ }
+ public boolean isLoadMesh() {
+ return loadMesh;
+ }
+
+}
diff --git a/src/eu/engys/core/controller/ParsersManager.java b/src/eu/engys/core/controller/ParsersManager.java
index eaefad8..d515096 100644
--- a/src/eu/engys/core/controller/ParsersManager.java
+++ b/src/eu/engys/core/controller/ParsersManager.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import java.rmi.RemoteException;
diff --git a/src/eu/engys/core/controller/QueueConnector.java b/src/eu/engys/core/controller/QueueConnector.java
index 0ecf225..915e9a2 100644
--- a/src/eu/engys/core/controller/QueueConnector.java
+++ b/src/eu/engys/core/controller/QueueConnector.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import java.util.Map;
diff --git a/src/eu/engys/core/controller/QueueInfo.java b/src/eu/engys/core/controller/QueueInfo.java
index c18d168..7e88b35 100644
--- a/src/eu/engys/core/controller/QueueInfo.java
+++ b/src/eu/engys/core/controller/QueueInfo.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import java.io.Serializable;
diff --git a/src/eu/engys/core/controller/ScriptBuilder.java b/src/eu/engys/core/controller/ScriptBuilder.java
index 4195303..e6a2932 100644
--- a/src/eu/engys/core/controller/ScriptBuilder.java
+++ b/src/eu/engys/core/controller/ScriptBuilder.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import java.util.LinkedList;
@@ -33,7 +32,7 @@ public class ScriptBuilder {
private List lines;
public ScriptBuilder() {
- lines = new LinkedList();
+ lines = new LinkedList<>();
}
public void append(String s) {
@@ -62,4 +61,4 @@ public class ScriptBuilder {
return lines;
}
-}
+}
\ No newline at end of file
diff --git a/src/eu/engys/core/controller/ScriptFactory.java b/src/eu/engys/core/controller/ScriptFactory.java
index 511cf80..11479ae 100644
--- a/src/eu/engys/core/controller/ScriptFactory.java
+++ b/src/eu/engys/core/controller/ScriptFactory.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
@@ -39,6 +38,9 @@ public interface ScriptFactory {
File getCheckMeshScript(Model model);
List getDefaultCheckMeshScript(Model model);
+ File getSnappyCheckMeshScript(Model model);
+ List getDefaultSnappyCheckMeshScript(Model model);
+
File getSolverScript(Model model);
List getDefaultSolverScript(Model model);
@@ -59,4 +61,7 @@ public interface ScriptFactory {
File getExportScript(Model model);
List getDefaultExportScript(Model model);
+ File getReportScript(Model model);
+ List getDefaultReportScript(Model model);
+
}
diff --git a/src/eu/engys/core/controller/Server.java b/src/eu/engys/core/controller/Server.java
index 8dfbff2..3d83b5e 100644
--- a/src/eu/engys/core/controller/Server.java
+++ b/src/eu/engys/core/controller/Server.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import java.rmi.Remote;
@@ -58,12 +57,17 @@ public interface Server extends Remote, ParsersManager {
String test() throws RemoteException;
- void disconnect() throws RemoteException;
+ void clientDisconnect() throws RemoteException;
QueueInfo getQueueInfo() throws RemoteException;
- void goToBatch() throws RemoteException;
+ CommandInfo goToBatch() throws RemoteException;
- void connect(ClientInfo clientInfo) throws RemoteException;
+ CommandInfo connect(ClientInfo clientInfo) throws RemoteException;
+ String getServerID() throws RemoteException;
+
+ boolean isRunningCommand() throws RemoteException;
+
+ ClientInfo getClientInfo() throws RemoteException;
}
diff --git a/src/eu/engys/core/controller/ServerInfo.java b/src/eu/engys/core/controller/ServerInfo.java
index f5ffb23..7cf91ee 100644
--- a/src/eu/engys/core/controller/ServerInfo.java
+++ b/src/eu/engys/core/controller/ServerInfo.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import java.util.Scanner;
@@ -39,7 +38,7 @@ public class ServerInfo {
public void decodePorts(String payload) {
if (payload != null && !payload.isEmpty()) {
Scanner scanner = new Scanner(payload);
- String date = scanner.hasNextLine() ? scanner.nextLine() : "";
+ this.date = scanner.hasNextLine() ? scanner.nextLine() : "";
this.port1 = scanner.hasNextInt() ? scanner.nextInt() : 0;
this.port2 = scanner.hasNextInt() ? scanner.nextInt() : 0;
scanner.close();
@@ -48,6 +47,6 @@ public class ServerInfo {
@Override
public String toString() {
- return "ServerInfo - ID: " + id + ", msg: " + message + ", port1: " + port1 + ", port2: " + port2 + ", succes: " + success + "date: " + date;
+ return "ServerInfo - ID: " + id + ", msg: " + message + ", port1: " + port1 + ", port2: " + port2 + ", succes: " + success + ", date: " + date;
}
-}
+}
\ No newline at end of file
diff --git a/src/eu/engys/core/controller/StateConnector.java b/src/eu/engys/core/controller/StateConnector.java
index 59d1d29..d9d9a5c 100644
--- a/src/eu/engys/core/controller/StateConnector.java
+++ b/src/eu/engys/core/controller/StateConnector.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import java.io.Serializable;
diff --git a/src/eu/engys/core/controller/StopOrKillCommandOS.java b/src/eu/engys/core/controller/StopOrKillCommandOS.java
index 7110cdb..dab3198 100644
--- a/src/eu/engys/core/controller/StopOrKillCommandOS.java
+++ b/src/eu/engys/core/controller/StopOrKillCommandOS.java
@@ -1,37 +1,35 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import static eu.engys.core.controller.AbstractController.CANCEL;
-import static eu.engys.core.controller.AbstractController.KILL_SOLVER;
-import static eu.engys.core.controller.AbstractController.STOP_SOLVER;
+import static eu.engys.core.controller.AbstractController.KILL_SOLVER_LABEL;
+import static eu.engys.core.controller.AbstractController.STOP_SOLVER_LABEL;
import javax.swing.JOptionPane;
-import eu.engys.core.controller.actions.TimeoutException;
import eu.engys.util.ui.UiUtil;
public class StopOrKillCommandOS implements Runnable {
@@ -44,12 +42,12 @@ public class StopOrKillCommandOS implements Runnable {
@Override
public void run() {
- Object[] options = new Object[] { STOP_SOLVER, KILL_SOLVER, CANCEL };
- int option = JOptionPane.showOptionDialog(UiUtil.getActiveWindow(), "Select an action to perform.", STOP_SOLVER, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
+ Object[] options = new Object[] { STOP_SOLVER_LABEL, KILL_SOLVER_LABEL, CANCEL };
+ int option = JOptionPane.showOptionDialog(UiUtil.getActiveWindow(), "Select an action to perform.", STOP_SOLVER_LABEL, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
if (option == JOptionPane.YES_OPTION) {
try {
controller.stopCase();
- } catch (TimeoutException e) {
+ } catch (Exception e) {
// should never pass here
}
} else if (option == JOptionPane.NO_OPTION) {
diff --git a/src/eu/engys/core/controller/View3DOptions.java b/src/eu/engys/core/controller/View3DOptions.java
index f1e380a..3aeaf49 100644
--- a/src/eu/engys/core/controller/View3DOptions.java
+++ b/src/eu/engys/core/controller/View3DOptions.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller;
import javax.swing.BorderFactory;
diff --git a/src/eu/engys/core/controller/actions/AbstractRunCommand.java b/src/eu/engys/core/controller/actions/AbstractRunCommand.java
index 7f7e23f..6f4e5d6 100644
--- a/src/eu/engys/core/controller/actions/AbstractRunCommand.java
+++ b/src/eu/engys/core/controller/actions/AbstractRunCommand.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller.actions;
import java.util.concurrent.ExecutorService;
@@ -36,11 +35,14 @@ import eu.engys.core.project.Model;
public abstract class AbstractRunCommand implements RunCommand {
protected Model model;
- protected Executor executor;
protected Controller controller;
+ protected Executor executor;
+
protected ExecutorService service;
protected ExecutorTerminal terminal;
+ protected String jobID = null;
+
public AbstractRunCommand(Model model, Controller controller) {
this.model = model;
this.controller = controller;
@@ -71,7 +73,7 @@ public abstract class AbstractRunCommand implements RunCommand {
}
@Override
- public void stop() throws TimeoutException {
+ public void stop() throws Exception {
}
@Override
@@ -83,12 +85,16 @@ public abstract class AbstractRunCommand implements RunCommand {
}
@Override
- public String executeQueue(Server server) throws CommandException {
- return null;
+ public void executeQueue(Server server) throws CommandException {
}
@Override
public void executeBatch() {
}
+ @Override
+ public String getJobID() {
+ return jobID;
+ }
+
}
diff --git a/src/eu/engys/core/controller/actions/CheckMesh.java b/src/eu/engys/core/controller/actions/CheckMesh.java
index c844f55..9982745 100644
--- a/src/eu/engys/core/controller/actions/CheckMesh.java
+++ b/src/eu/engys/core/controller/actions/CheckMesh.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller.actions;
import static eu.engys.core.OpenFOAMEnvironment.getEnvironment;
@@ -30,17 +29,18 @@ import static eu.engys.core.project.openFOAMProject.LOG;
import java.io.File;
import java.nio.file.Paths;
+import java.util.concurrent.Executors;
import eu.engys.core.controller.Controller;
-import eu.engys.core.controller.Controller.OpenOptions;
import eu.engys.core.controller.ScriptFactory;
import eu.engys.core.executor.Executor;
import eu.engys.core.executor.ExecutorHook;
import eu.engys.core.executor.ExecutorListener.ExecutorState;
import eu.engys.core.executor.ExecutorMonitor;
-import eu.engys.core.executor.ExecutorTerminal;
import eu.engys.core.executor.TerminalExecutorMonitor;
import eu.engys.core.project.Model;
+import eu.engys.core.project.mesh.MeshInfoReader;
+import eu.engys.core.project.mesh.MeshInfoWriter;
import eu.engys.util.IOUtils;
public class CheckMesh extends AbstractRunCommand {
@@ -48,39 +48,51 @@ public class CheckMesh extends AbstractRunCommand {
public static final String ACTION_NAME = "Check Mesh";
public static final String LOG_NAME = "checkMesh.log";
- private File logFile;
private ScriptFactory scriptFactory;
+ private String logName;
+ private String actionName;
+ private File logFile;
public CheckMesh(Model model, Controller controller, ScriptFactory scriptFactory) {
+ this(model, controller, scriptFactory, LOG_NAME, ACTION_NAME);
+ }
+
+ public CheckMesh(Model model, Controller controller, ScriptFactory scriptFactory, String logName, String actionName) {
super(model, controller);
this.scriptFactory = scriptFactory;
- this.logFile = Paths.get(model.getProject().getBaseDir().getAbsolutePath(), LOG, LOG_NAME).toFile();
+ this.logName = logName;
+ this.actionName = actionName;
+ this.logFile = Paths.get(model.getProject().getBaseDir().getAbsolutePath(), LOG, logName).toFile();
}
@Override
public void beforeExecute() {
IOUtils.clearFile(logFile);
- if (controller.getListener() != null) {
- controller.getListener().beforeCheckMesh();
- }
}
@Override
public void executeClient() {
- ExecutorTerminal terminal = new TerminalExecutorMonitor(logFile);
+ if (terminal == null) {
+ this.terminal = new TerminalExecutorMonitor(controller.getTerminalManager(), logFile);
+ }
+ if (service == null) {
+ this.service = Executors.newSingleThreadExecutor();
+ }
+
ExecutorMonitor monitor = new ExecutorMonitor();
monitor.addHook(ExecutorState.FINISH, new FinishHook());
- this.executor = Executor.script(scriptFactory.getCheckMeshScript(model)).description(ACTION_NAME).inFolder(model.getProject().getBaseDir()).inTerminal(terminal).withMonitors(monitor).env(getEnvironment(model, LOG_NAME)).keepFileOnEnd();
+ this.executor = Executor.script(scriptFactory.getCheckMeshScript(model)).description(actionName).inFolder(model.getProject().getBaseDir()).inTerminal(terminal).withMonitors(monitor).inService(service).env(getEnvironment(model, logName)).keepFileOnEnd();
executor.exec();
}
private class FinishHook implements ExecutorHook {
-
@Override
public void run(ExecutorMonitor monitor) {
if (controller.getListener() != null) {
- controller.reopenCase(OpenOptions.MESH_ONLY);
+ new MeshInfoReader(model).read(logFile);
+ new MeshInfoWriter(model).write();
+ model.getProject().getSystemFolder().writeProjectDict(null);
controller.getListener().afterCheckMesh();
}
}
diff --git a/src/eu/engys/core/controller/actions/CommandException.java b/src/eu/engys/core/controller/actions/CommandException.java
index 707ea9b..b8e4839 100644
--- a/src/eu/engys/core/controller/actions/CommandException.java
+++ b/src/eu/engys/core/controller/actions/CommandException.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller.actions;
public class CommandException extends Exception {
@@ -31,4 +30,8 @@ public class CommandException extends Exception {
super(message);
}
+ public CommandException(String message, Exception e) {
+ super(message, e);
+ }
+
}
diff --git a/src/eu/engys/gui/casesetup/actions/DecomposeCase.java b/src/eu/engys/core/controller/actions/DecomposeCase.java
similarity index 56%
rename from src/eu/engys/gui/casesetup/actions/DecomposeCase.java
rename to src/eu/engys/core/controller/actions/DecomposeCase.java
index ebbab68..55c5e00 100644
--- a/src/eu/engys/gui/casesetup/actions/DecomposeCase.java
+++ b/src/eu/engys/core/controller/actions/DecomposeCase.java
@@ -1,29 +1,28 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-package eu.engys.gui.casesetup.actions;
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
+package eu.engys.core.controller.actions;
import static eu.engys.core.OpenFOAMEnvironment.getEnvironment;
import static eu.engys.core.OpenFOAMEnvironment.loadEnvironment;
@@ -37,12 +36,12 @@ import static eu.engys.util.OpenFOAMCommands.DECOMPOSE_PAR_CONSTANT_ALLREGIONS;
import java.io.File;
import java.nio.file.Paths;
+import java.util.Set;
import java.util.concurrent.Executors;
import eu.engys.core.controller.Controller;
-import eu.engys.core.controller.Controller.OpenOptions;
+import eu.engys.core.controller.Controller.OpenMode;
import eu.engys.core.controller.ScriptBuilder;
-import eu.engys.core.controller.actions.AbstractRunCommand;
import eu.engys.core.executor.Executor;
import eu.engys.core.executor.ExecutorHook;
import eu.engys.core.executor.ExecutorListener.ExecutorState;
@@ -54,19 +53,23 @@ import eu.engys.util.Util;
public class DecomposeCase extends AbstractRunCommand {
+ public static final String ACTION_NAME = "Decompose";
private static final String DECOMPOSE_RUN = "decomposeCase.run";
private static final String DECOMPOSE_BAT = "decomposeCase.bat";
private File logFile;
private String actionName;
private String logName;
+ private Set timeSteps;
- public DecomposeCase(Model model, Controller controller, String actionName, String logName) {
+ public DecomposeCase(Model model, Controller controller, String logName, String actionName, Set timeSteps) {
super(model, controller);
this.actionName = actionName;
this.logName = logName;
+ this.timeSteps = timeSteps;
this.logFile = Paths.get(model.getProject().getBaseDir().getAbsolutePath(), LOG, logName).toFile();
}
+
@Override
public void beforeExecute() {
@@ -79,7 +82,7 @@ public class DecomposeCase extends AbstractRunCommand {
File baseDir = model.getProject().getBaseDir();
if (terminal == null) {
- this.terminal = new TerminalExecutorMonitor(logFile);
+ this.terminal = new TerminalExecutorMonitor(controller.getTerminalManager(), logFile);
}
if (service == null) {
this.service = Executors.newSingleThreadExecutor();
@@ -104,7 +107,7 @@ public class DecomposeCase extends AbstractRunCommand {
}
private void writeScript(ScriptBuilder sb) {
- printHeader(sb, actionName.toUpperCase());
+ printHeader(sb, ACTION_NAME);
printVariables(sb);
loadEnvironment(sb);
writeCommand(sb);
@@ -113,15 +116,15 @@ public class DecomposeCase extends AbstractRunCommand {
private void writeCommand(ScriptBuilder sb) {
if (model.getProject().isMeshOnZero() || model.getProject().isSerial()) {
if (model.getProject().getZeroFolder().hasRegions()) {
- sb.append(DECOMPOSE_PAR_ALLREGIONS());
+ sb.append(DECOMPOSE_PAR_ALLREGIONS(timeSteps));
} else {
- sb.append(DECOMPOSE_PAR());
+ sb.append(DECOMPOSE_PAR(timeSteps));
}
} else {
if (model.getProject().getZeroFolder().hasRegions()) {
- sb.append(DECOMPOSE_PAR_CONSTANT_ALLREGIONS());
+ sb.append(DECOMPOSE_PAR_CONSTANT_ALLREGIONS(timeSteps));
} else {
- sb.append(DECOMPOSE_PAR_CONSTANT());
+ sb.append(DECOMPOSE_PAR_CONSTANT(timeSteps));
}
}
}
@@ -131,7 +134,7 @@ public class DecomposeCase extends AbstractRunCommand {
@Override
public void run(ExecutorMonitor monitor) {
if (controller.getListener() != null) {
- controller.reopenCase(OpenOptions.PARALLEL);
+ controller.reopenCase(OpenMode.PARALLEL);
}
}
}
diff --git a/src/eu/engys/core/controller/actions/DecomposeCaseAction.java b/src/eu/engys/core/controller/actions/DecomposeCaseAction.java
new file mode 100644
index 0000000..67d0d4b
--- /dev/null
+++ b/src/eu/engys/core/controller/actions/DecomposeCaseAction.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
+package eu.engys.core.controller.actions;
+
+import static eu.engys.core.controller.actions.DecomposeCase.ACTION_NAME;
+import static eu.engys.core.project.openFOAMProject.LOG;
+
+import java.io.File;
+import java.nio.file.Paths;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import eu.engys.core.controller.Controller;
+import eu.engys.core.executor.TerminalExecutorMonitor;
+import eu.engys.core.project.Model;
+import eu.engys.util.IOUtils;
+
+public class DecomposeCaseAction extends AbstractRunCommand {
+
+ public static final String LOG_NAME = "decomposeCase.log";
+
+ private Model model;
+ private Controller controller;
+
+ private boolean shouldUseWithZeroFlag;
+
+ public DecomposeCaseAction(Model model, Controller controller, boolean shouldUseWithZeroFlag) {
+ super(model, controller);
+ this.model = model;
+ this.controller = controller;
+ this.shouldUseWithZeroFlag = shouldUseWithZeroFlag;
+ }
+
+ @Override
+ public void executeClient() {
+ DecomposeCasePanel panel = new DecomposeCasePanel(model);
+ panel.showDialog();
+ if (panel.getStatus().isOK()) {
+ controller.saveCase(model.getProject().getBaseDir());
+ decompose(panel.getTimeSteps());
+ }
+ }
+
+ private void decompose(Set timeSteps) {
+ if (model.getProject().isParallel()) {
+ decomposeParallelCase(timeSteps);
+ } else {
+ decomposeSerialCase(timeSteps);
+ }
+ }
+
+ private void decomposeSerialCase(Set timeSteps) {
+ RunCommand command = new DecomposeCase(model, controller, LOG_NAME, ACTION_NAME, timeSteps);
+ command.beforeExecute();
+ command.executeClient();
+ }
+
+ private void decomposeParallelCase(Set timeSteps) {
+ File logFile = Paths.get(model.getProject().getBaseDir().getAbsolutePath(), LOG, LOG_NAME).toFile();
+
+ IOUtils.clearFile(logFile);
+
+ TerminalExecutorMonitor terminal = new TerminalExecutorMonitor(controller.getTerminalManager(), logFile);
+ ExecutorService service = Executors.newSingleThreadExecutor();
+
+ RunCommand reconstructMesh = new ReconstructMesh(model, controller, ACTION_NAME, LOG_NAME);
+ reconstructMesh.inService(service);
+ reconstructMesh.inTerminal(terminal);
+ reconstructMesh.executeClient();
+
+ RunCommand reconstructCase = new ReconstructCase(model, controller, shouldUseWithZeroFlag, ACTION_NAME, LOG_NAME);
+ reconstructCase.inService(service);
+ reconstructCase.inTerminal(terminal);
+ reconstructCase.executeClient();
+
+ RunCommand decomposeCase = new DecomposeCase(model, controller, LOG_NAME, ACTION_NAME, timeSteps);
+ decomposeCase.inService(service);
+ decomposeCase.inTerminal(terminal);
+ decomposeCase.executeClient();
+ }
+
+}
diff --git a/src/eu/engys/gui/casesetup/actions/DecomposeCasePanel.java b/src/eu/engys/core/controller/actions/DecomposeCasePanel.java
similarity index 60%
rename from src/eu/engys/gui/casesetup/actions/DecomposeCasePanel.java
rename to src/eu/engys/core/controller/actions/DecomposeCasePanel.java
index 3566091..5e3f2ef 100644
--- a/src/eu/engys/gui/casesetup/actions/DecomposeCasePanel.java
+++ b/src/eu/engys/core/controller/actions/DecomposeCasePanel.java
@@ -1,29 +1,28 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-package eu.engys.gui.casesetup.actions;
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
+package eu.engys.core.controller.actions;
import static eu.engys.core.project.system.DecomposeParDict.DELTA_KEY;
import static eu.engys.core.project.system.DecomposeParDict.HIERARCHICAL_COEFFS_KEY;
@@ -36,21 +35,34 @@ import static eu.engys.core.project.system.DecomposeParDict.SCOTCH_KEY;
import static eu.engys.core.project.system.DecomposeParDict.TYPE_KEYS;
import static eu.engys.core.project.system.DecomposeParDict.YXZ_KEY;
import static eu.engys.util.ui.ComponentsFactory.labelArrayField;
+import static eu.engys.util.ui.UiUtil.DIALOG_CANCEL_LABEL;
+import static eu.engys.util.ui.UiUtil.DIALOG_OK_LABEL;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
+import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
import javax.swing.AbstractAction;
+import javax.swing.BorderFactory;
import javax.swing.JButton;
+import javax.swing.JCheckBox;
import javax.swing.JComboBox;
+import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
+import javax.swing.JScrollPane;
import eu.engys.core.dictionary.Dictionary;
import eu.engys.core.dictionary.model.DictionaryModel;
@@ -67,10 +79,16 @@ public class DecomposeCasePanel extends JPanel {
public static final String HIERARCHY_LABEL = "Hierarchy";
public static final String PROCESSORS_LABEL = "Processors";
public static final String DECOMPOSITION_TYPE_LABEL = "Decomposition Type";
+ public static final String TIME_STEP = "Time Steps";
public static final String HIERARCHICAL_LABEL = "Hierarchical";
public static final String SCOTCH_LABEL = "Scotch";
private static final String[] TYPE_LABELS = { HIERARCHICAL_LABEL, SCOTCH_LABEL };
+ private static final String SELECT_ALL = "Select All";
+ private static final String DESELECT_ALL = "Deselect All";
+ public static final String DECOMPOSE_PANEL = "decompose.panel";
+
+ private Map timeStepMap;
public enum Status {
OK, CANCEL;
@@ -103,10 +121,11 @@ public class DecomposeCasePanel extends JPanel {
public DecomposeCasePanel(Model model) {
super(new BorderLayout());
- setName("decompose.panel");
+ setName(DECOMPOSE_PANEL);
this.model = model;
this.mainModel = new DictionaryModel();
this.hierarchicalDictionaryModel = new DictionaryModel();
+ this.timeStepMap = new HashMap<>();
layoutComponents();
}
@@ -146,7 +165,49 @@ public class DecomposeCasePanel extends JPanel {
nProcessorsField.addPropertyChangeListener(new RecalculateFactorsOnChange());
nProcessorsField.setIntValue(1);
- add(builder.getPanel());
+ add(builder.getPanel(), BorderLayout.CENTER);
+ add(createTimeStepsPanel(), BorderLayout.SOUTH);
+ }
+
+ private JComponent createTimeStepsPanel() {
+ JPanel panel = new JPanel(new GridLayout(0, 4));
+
+ File[] zeroDirs = model.getProject().getZeroFolder().getFileManager().getZeroDirs("0");
+ File[] nonZeroDirs = model.getProject().getZeroFolder().getFileManager().getNonZeroDirs("0");
+
+ Set timeSteps = new TreeSet<>(new Comparator() {
+ @Override
+ public int compare(String o1, String o2) {
+ return Double.valueOf(o1).compareTo(Double.valueOf(o2));
+ }
+ });
+ for (File zeroDir : zeroDirs) {
+ timeSteps.add(zeroDir.getName());
+ }
+ for (File nonZeroDir : nonZeroDirs) {
+ timeSteps.add(nonZeroDir.getName());
+ }
+
+ for (String timeStep : timeSteps) {
+ JCheckBox chk = new JCheckBox(timeStep, true);
+ timeStepMap.put(chk, timeStep);
+ chk.setName(timeStep);
+ panel.add(chk);
+ }
+
+ panel.setBorder(BorderFactory.createTitledBorder(TIME_STEP));
+ panel.setName(TIME_STEP);
+ return panel;
+ }
+
+ public Set getTimeSteps() {
+ Set timeSteps = new TreeSet<>();
+ for (JCheckBox check : timeStepMap.keySet()){
+ if(check.isSelected()){
+ timeSteps.add(timeStepMap.get(check));
+ }
+ }
+ return timeSteps;
}
public void showDialog() {
@@ -158,9 +219,9 @@ public class DecomposeCasePanel extends JPanel {
private void createDialog() {
if (dialog == null) {
dialog = new JDialog(UiUtil.getActiveWindow(), DECOMPOSE_CASE_LABEL);
- dialog.setName("create.case.dialog");
+ dialog.setName(DECOMPOSE_PANEL);
- AbstractAction saveAndCloseDialogAction = new AbstractAction("OK") {
+ AbstractAction saveAndCloseDialogAction = new AbstractAction(DIALOG_OK_LABEL) {
@Override
public void actionPerformed(ActionEvent e) {
if (TYPE_KEYS[0].equals(decompositionType.getSelectedItem()) && !productEqualsToNumberOfSubdomain()) {
@@ -173,7 +234,7 @@ public class DecomposeCasePanel extends JPanel {
}
};
- final AbstractAction cancelAction = new AbstractAction("Cancel") {
+ final AbstractAction cancelAction = new AbstractAction(DIALOG_CANCEL_LABEL) {
@Override
public void actionPerformed(ActionEvent e) {
status = Status.CANCEL;
@@ -182,26 +243,20 @@ public class DecomposeCasePanel extends JPanel {
dialog = null;
}
};
-
- JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
-
- JButton okButton = new JButton(saveAndCloseDialogAction);
- okButton.setName("OK");
- buttonsPanel.add(okButton);
-
- JButton cancelButton = new JButton(cancelAction);
- cancelButton.setName("Cancel");
- buttonsPanel.add(cancelButton);
-
+
+ JPanel buttonsPanel = createButtonsPanel(saveAndCloseDialogAction, cancelAction);
+
+ JScrollPane pane = new JScrollPane(this);
+ pane.setBorder(BorderFactory.createEmptyBorder());
+
JPanel mainPanel = new JPanel(new BorderLayout());
- mainPanel.add(this, BorderLayout.CENTER);
+ mainPanel.add(pane, BorderLayout.CENTER);
mainPanel.add(buttonsPanel, BorderLayout.SOUTH);
dialog.add(mainPanel);
- dialog.setSize(350, 200);
+ dialog.setSize(400, 300);
dialog.setLocationRelativeTo(null);
dialog.setModal(true);
- dialog.getRootPane().setDefaultButton(okButton);
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
dialog.addWindowListener(new WindowAdapter() {
@@ -213,6 +268,44 @@ public class DecomposeCasePanel extends JPanel {
}
}
+ private JPanel createButtonsPanel(AbstractAction saveAndCloseDialogAction, AbstractAction cancelAction) {
+ JPanel rightButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
+ JButton okButton = new JButton(saveAndCloseDialogAction);
+ okButton.setName(DIALOG_OK_LABEL);
+ JButton cancelButton = new JButton(cancelAction);
+ cancelButton.setName(DIALOG_CANCEL_LABEL);
+ rightButtonsPanel.add(okButton);
+ rightButtonsPanel.add(cancelButton);
+
+ JPanel leftButtonsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ JButton selectAll = new JButton(new AbstractAction(SELECT_ALL) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ for (JCheckBox chk : timeStepMap.keySet()) {
+ chk.setSelected(true);
+ }
+ }
+ });
+
+ JButton deselectAll = new JButton(new AbstractAction(DESELECT_ALL) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ for (JCheckBox chk : timeStepMap.keySet()) {
+ chk.setSelected(false);
+ }
+ }
+ });
+
+ leftButtonsPanel.add(selectAll);
+ leftButtonsPanel.add(deselectAll);
+
+ JPanel buttonsPanel = new JPanel(new GridLayout(1, 2));
+ buttonsPanel.add(leftButtonsPanel);
+ buttonsPanel.add(rightButtonsPanel);
+
+ return buttonsPanel;
+ }
+
private boolean productEqualsToNumberOfSubdomain() {
int nOfSubdomains = nProcessorsField.getIntValue();
int x = nHierarchyField[X].getIntValue();
diff --git a/src/eu/engys/core/controller/actions/DeleteMesh.java b/src/eu/engys/core/controller/actions/DeleteMesh.java
index e2b0c31..e9369e6 100644
--- a/src/eu/engys/core/controller/actions/DeleteMesh.java
+++ b/src/eu/engys/core/controller/actions/DeleteMesh.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller.actions;
import eu.engys.core.controller.Controller;
diff --git a/src/eu/engys/core/controller/actions/InitialiseFields.java b/src/eu/engys/core/controller/actions/InitialiseFields.java
index 94f32cf..f339280 100644
--- a/src/eu/engys/core/controller/actions/InitialiseFields.java
+++ b/src/eu/engys/core/controller/actions/InitialiseFields.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller.actions;
import static eu.engys.core.project.openFOAMProject.LOG;
diff --git a/src/eu/engys/core/controller/actions/NamingConvention.java b/src/eu/engys/core/controller/actions/NamingConvention.java
index baf8d0d..3bf5c28 100644
--- a/src/eu/engys/core/controller/actions/NamingConvention.java
+++ b/src/eu/engys/core/controller/actions/NamingConvention.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller.actions;
import eu.engys.core.project.geometry.Surface;
@@ -32,4 +31,6 @@ public interface NamingConvention {
String getPatchName(Surface surface);
String getCellZoneName(Surface surface);
+
+ String getFaceZoneName(Surface surface);
}
diff --git a/src/eu/engys/core/controller/actions/ReconstructCase.java b/src/eu/engys/core/controller/actions/ReconstructCase.java
new file mode 100644
index 0000000..8378cb7
--- /dev/null
+++ b/src/eu/engys/core/controller/actions/ReconstructCase.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
+package eu.engys.core.controller.actions;
+
+import static eu.engys.core.OpenFOAMEnvironment.getEnvironment;
+import static eu.engys.core.OpenFOAMEnvironment.loadEnvironment;
+import static eu.engys.core.OpenFOAMEnvironment.printHeader;
+import static eu.engys.core.OpenFOAMEnvironment.printVariables;
+import static eu.engys.core.project.openFOAMProject.LOG;
+import static eu.engys.util.OpenFOAMCommands.RECONSTRUCT_PAR;
+import static eu.engys.util.OpenFOAMCommands.RECONSTRUCT_PAR_ALLREGIONS;
+
+import java.io.File;
+import java.nio.file.Paths;
+import java.util.concurrent.Executors;
+
+import eu.engys.core.controller.Controller;
+import eu.engys.core.controller.ScriptBuilder;
+import eu.engys.core.executor.Executor;
+import eu.engys.core.executor.TerminalExecutorMonitor;
+import eu.engys.core.project.Model;
+import eu.engys.util.IOUtils;
+import eu.engys.util.Util;
+
+public class ReconstructCase extends AbstractRunCommand {
+
+ public static final String ACTION_NAME = "Reconstruct Par";
+ private static final String RECONSTRUCT_CASE_RUN = "reconstructCase.run";
+ private static final String RECONSTRUCT_CASE_BAT = "reconstructCase.bat";
+
+ private String actionName;
+ private String logName;
+ private File logFile;
+ private boolean shouldUseWithZeroFlag;
+
+ public ReconstructCase(Model model, Controller controller, boolean shouldUseWithZeroFlag, String actionName, String logName) {
+ super(model, controller);
+ this.shouldUseWithZeroFlag = shouldUseWithZeroFlag;
+ this.actionName = actionName;
+ this.logName = logName;
+ this.logFile = Paths.get(model.getProject().getBaseDir().getAbsolutePath(), LOG, logName).toFile();
+ }
+
+ @Override
+ public void executeClient() {
+ File script = getScript();
+ File baseDir = model.getProject().getBaseDir();
+
+ if (terminal == null) {
+ this.terminal = new TerminalExecutorMonitor(controller.getTerminalManager(), logFile);
+ }
+ if (service == null) {
+ this.service = Executors.newSingleThreadExecutor();
+ }
+
+ this.executor = Executor.script(script).description(actionName).inFolder(baseDir).inTerminal(terminal).inService(service).env(getEnvironment(model, logName));
+ executor.exec();
+ }
+
+ private File getScript() {
+ File file = new File(model.getProject().getBaseDir(), Util.isWindows() ? RECONSTRUCT_CASE_BAT : RECONSTRUCT_CASE_RUN);
+ ScriptBuilder sb = new ScriptBuilder();
+ writeScript(sb);
+ IOUtils.writeLinesToFile(file, sb.getLines());
+ file.setExecutable(true);
+ return file;
+ }
+
+ private void writeScript(ScriptBuilder sb) {
+ printHeader(sb, ACTION_NAME);
+ printVariables(sb);
+ loadEnvironment(sb);
+ writeCommand(sb);
+ }
+
+ private void writeCommand(ScriptBuilder sb) {
+ if (model.getProject().getZeroFolder().hasRegions()) {
+ sb.append(RECONSTRUCT_PAR_ALLREGIONS(shouldUseWithZeroFlag));
+ } else {
+ sb.append(RECONSTRUCT_PAR(shouldUseWithZeroFlag));
+ }
+
+ }
+
+}
diff --git a/src/eu/engys/core/controller/actions/ReconstructMesh.java b/src/eu/engys/core/controller/actions/ReconstructMesh.java
new file mode 100644
index 0000000..ab805d8
--- /dev/null
+++ b/src/eu/engys/core/controller/actions/ReconstructMesh.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
+package eu.engys.core.controller.actions;
+
+import static eu.engys.core.OpenFOAMEnvironment.getEnvironment;
+import static eu.engys.core.OpenFOAMEnvironment.loadEnvironment;
+import static eu.engys.core.OpenFOAMEnvironment.printHeader;
+import static eu.engys.core.OpenFOAMEnvironment.printVariables;
+import static eu.engys.core.project.openFOAMProject.LOG;
+import static eu.engys.util.OpenFOAMCommands.RECONSTRUCT_PAR_MESH;
+import static eu.engys.util.OpenFOAMCommands.RECONSTRUCT_PAR_MESH_ALLREGIONS;
+import static eu.engys.util.OpenFOAMCommands.RECONSTRUCT_PAR_MESH_CONSTANT;
+import static eu.engys.util.OpenFOAMCommands.RECONSTRUCT_PAR_MESH_CONSTANT_ALLREGIONS;
+
+import java.io.File;
+import java.nio.file.Paths;
+import java.util.concurrent.Executors;
+
+import eu.engys.core.controller.Controller;
+import eu.engys.core.controller.ScriptBuilder;
+import eu.engys.core.executor.Executor;
+import eu.engys.core.executor.TerminalExecutorMonitor;
+import eu.engys.core.project.Model;
+import eu.engys.util.IOUtils;
+import eu.engys.util.Util;
+
+public class ReconstructMesh extends AbstractRunCommand {
+
+ public static final String ACTION_NAME = "Reconstruct Par Mesh";
+ private static final String RECONSTRUCT_MESH_RUN = "reconstructMesh.run";
+ private static final String RECONSTRUCT_MESH_BAT = "reconstructMesh.bat";
+
+ private String actionName;
+ private String logName;
+ private File logFile;
+
+ public ReconstructMesh(Model model, Controller controller, String actionName, String logName) {
+ super(model, controller);
+ this.actionName = actionName;
+ this.logName = logName;
+ this.logFile = Paths.get(model.getProject().getBaseDir().getAbsolutePath(), LOG, logName).toFile();
+ }
+
+ @Override
+ public void executeClient() {
+ File script = getScript();
+ File baseDir = model.getProject().getBaseDir();
+
+ if (terminal == null) {
+ this.terminal = new TerminalExecutorMonitor(controller.getTerminalManager(), logFile);
+ }
+ if (service == null) {
+ this.service = Executors.newSingleThreadExecutor();
+ }
+
+ this.executor = Executor.script(script).description(actionName).inFolder(baseDir).inTerminal(terminal).inService(service).env(getEnvironment(model, logName));
+ executor.exec();
+ }
+
+ private File getScript() {
+ File file = new File(model.getProject().getBaseDir(), Util.isWindows() ? RECONSTRUCT_MESH_BAT : RECONSTRUCT_MESH_RUN);
+ ScriptBuilder sb = new ScriptBuilder();
+ writeScript(sb);
+ IOUtils.writeLinesToFile(file, sb.getLines());
+ file.setExecutable(true);
+ return file;
+ }
+
+ private void writeScript(ScriptBuilder sb) {
+ printHeader(sb, ACTION_NAME);
+ printVariables(sb);
+ loadEnvironment(sb);
+ writeCommand(sb);
+ }
+
+ private void writeCommand(ScriptBuilder sb) {
+ boolean meshOnZero = model.getProject().isMeshOnZero();
+
+ if (meshOnZero) {
+ if (model.getProject().getZeroFolder().hasRegions()) {
+ sb.append(RECONSTRUCT_PAR_MESH_ALLREGIONS());
+ } else {
+ sb.append(RECONSTRUCT_PAR_MESH());
+ }
+ } else {
+ if (model.getProject().getZeroFolder().hasRegions()) {
+ sb.append(RECONSTRUCT_PAR_MESH_CONSTANT_ALLREGIONS());
+ } else {
+ sb.append(RECONSTRUCT_PAR_MESH_CONSTANT());
+ }
+ }
+ }
+
+}
diff --git a/src/eu/engys/core/controller/actions/RunCase.java b/src/eu/engys/core/controller/actions/RunCase.java
index 05bbd68..7104e7e 100644
--- a/src/eu/engys/core/controller/actions/RunCase.java
+++ b/src/eu/engys/core/controller/actions/RunCase.java
@@ -1,57 +1,43 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller.actions;
-import static eu.engys.core.project.system.ControlDict.CONTROL_DICT;
-import static eu.engys.core.project.system.ControlDict.END_TIME_KEY;
-import static eu.engys.core.project.system.ControlDict.STOP_AT_KEY;
-import static eu.engys.core.project.system.ControlDict.WRITE_NOW_KEY;
-
import java.io.File;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import eu.engys.core.controller.Command;
import eu.engys.core.controller.Controller;
import eu.engys.core.controller.ScriptFactory;
-import eu.engys.core.dictionary.DictionaryUtils;
import eu.engys.core.executor.ExecutorHook;
import eu.engys.core.executor.ExecutorMonitor;
import eu.engys.core.project.Model;
import eu.engys.core.project.SolverState;
import eu.engys.core.project.openFOAMProject;
import eu.engys.core.project.state.ServerState;
-import eu.engys.core.project.system.ControlDict;
-import eu.engys.util.PrefUtil;
public class RunCase extends AbstractRunCommand {
- private static final Logger logger = LoggerFactory.getLogger(RunCase.class);
-
public static final String ACTION_NAME = "Run Case";
public static final String RUNNING_LABEL = "Running: ";
@@ -67,7 +53,8 @@ public class RunCase extends AbstractRunCommand {
setupLogFolder();
setupPostProcFolder();
clearPolyMesh();
- setStopAtVariableToEndTime();
+
+ new Stopper(model, executor).setStopAtVariableToEndTime();
}
private void setupLogFolder() {
@@ -87,41 +74,8 @@ public class RunCase extends AbstractRunCommand {
}
@Override
- public void stop() throws TimeoutException {
- int stop_refresh_time = PrefUtil.getInt(PrefUtil.SERVER_CONNECTION_REFRESH_TIME, 1000);
- int stop_max_tries = PrefUtil.getInt(PrefUtil.SERVER_CONNECTION_MAX_TRIES, 60);
-
- int tryIndex = 0;
- while (this.executor.getState().isDoingSomething() && (tryIndex < stop_max_tries)) {
- try {
- Thread.sleep(stop_refresh_time);
- } catch (Exception e) {
- }
- setStopAtVariableToWriteNow();
- tryIndex++;
- }
- if (tryIndex >= stop_max_tries) {
- throw new TimeoutException("Timeout stopping solver");
- }
- setStopAtVariableToEndTime();
- }
-
- private void setStopAtVariableToWriteNow() {
- File systemFolder = model.getProject().getSystemFolder().getFileManager().getFile();
- ControlDict controlDict = new ControlDict(new File(systemFolder, CONTROL_DICT));
- controlDict.add(STOP_AT_KEY, WRITE_NOW_KEY);
- controlDict.functionObjectsToList();
- DictionaryUtils.writeDictionary(systemFolder, controlDict, null);
- }
-
- private void setStopAtVariableToEndTime() {
- File systemFolder = model.getProject().getSystemFolder().getFileManager().getFile();
- ControlDict controlDict = new ControlDict(new File(systemFolder, CONTROL_DICT));
- if (controlDict.found(STOP_AT_KEY) && controlDict.lookup(STOP_AT_KEY).equals(WRITE_NOW_KEY)) {
- controlDict.add(STOP_AT_KEY, END_TIME_KEY);
- controlDict.functionObjectsToList();
- DictionaryUtils.writeDictionary(systemFolder, controlDict, null);
- }
+ public void stop() throws Exception {
+ new Stopper(model, executor).stop();
}
protected class StartHook implements ExecutorHook {
diff --git a/src/eu/engys/core/controller/actions/RunCommand.java b/src/eu/engys/core/controller/actions/RunCommand.java
index 7e45ed2..056747d 100644
--- a/src/eu/engys/core/controller/actions/RunCommand.java
+++ b/src/eu/engys/core/controller/actions/RunCommand.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller.actions;
import java.util.concurrent.ExecutorService;
@@ -40,9 +39,9 @@ public interface RunCommand {
public void executeServer(Server server) throws CommandException;
- public String executeQueue(Server server) throws CommandException;
+ public void executeQueue(Server server) throws CommandException;
- public void stop() throws TimeoutException;
+ public void stop() throws Exception;
public void kill();
@@ -52,4 +51,5 @@ public interface RunCommand {
public boolean isRunning();
+ public String getJobID();
}
diff --git a/src/eu/engys/core/controller/actions/RunMesh.java b/src/eu/engys/core/controller/actions/RunMesh.java
index cbfebd9..65764b8 100644
--- a/src/eu/engys/core/controller/actions/RunMesh.java
+++ b/src/eu/engys/core/controller/actions/RunMesh.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller.actions;
import static eu.engys.core.project.openFOAMProject.LOG;
@@ -42,6 +41,7 @@ public class RunMesh extends AbstractRunCommand {
public static final String LOG_NAME = "snappyHexMesh.log";
protected final ScriptFactory scriptFactory;
+ protected File logFile;
public RunMesh(Model model, Controller controller, ScriptFactory scriptFactory) {
super(model, controller);
@@ -50,7 +50,8 @@ public class RunMesh extends AbstractRunCommand {
@Override
public void beforeExecute() {
- IOUtils.clearFile(Paths.get(model.getProject().getBaseDir().getAbsolutePath(), LOG, LOG_NAME).toFile());
+ this.logFile = Paths.get(model.getProject().getBaseDir().getAbsolutePath(), LOG, LOG_NAME).toFile();
+ IOUtils.clearFile(logFile);
clearPolyMesh();
setupLogFolder();
fixDecomposeParDict(model);
diff --git a/src/eu/engys/core/controller/actions/StandardInitialiseFields.java b/src/eu/engys/core/controller/actions/StandardInitialiseFields.java
index 0cb18c8..7849f88 100644
--- a/src/eu/engys/core/controller/actions/StandardInitialiseFields.java
+++ b/src/eu/engys/core/controller/actions/StandardInitialiseFields.java
@@ -1,50 +1,55 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller.actions;
import static eu.engys.core.OpenFOAMEnvironment.getEnvironment;
+import static eu.engys.core.controller.AbstractScriptFactory.INITIALISE_FIELDS_PARALLEL_BAT;
+import static eu.engys.core.controller.AbstractScriptFactory.INITIALISE_FIELDS_PARALLEL_RUN;
+import static eu.engys.core.controller.AbstractScriptFactory.INITIALISE_FIELDS_SERIAL_BAT;
+import static eu.engys.core.controller.AbstractScriptFactory.INITIALISE_FIELDS_SERIAL_RUN;
import java.io.File;
import java.nio.file.Paths;
import java.util.concurrent.ExecutorService;
+import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import eu.engys.core.controller.Controller;
-import eu.engys.core.controller.Controller.OpenOptions;
+import eu.engys.core.controller.Controller.OpenMode;
+import eu.engys.core.controller.KillCommandOS;
import eu.engys.core.controller.ScriptFactory;
import eu.engys.core.executor.Executor;
import eu.engys.core.executor.ExecutorHook;
import eu.engys.core.executor.ExecutorListener.ExecutorState;
import eu.engys.core.executor.ExecutorMonitor;
-import eu.engys.core.executor.ExecutorTerminal;
import eu.engys.core.executor.TerminalExecutorMonitor;
import eu.engys.core.project.Model;
import eu.engys.core.project.openFOAMProject;
+import eu.engys.util.Util;
public class StandardInitialiseFields extends InitialiseFields {
@@ -53,27 +58,36 @@ public class StandardInitialiseFields extends InitialiseFields {
public StandardInitialiseFields(Model model, Controller controller, ScriptFactory scriptFactory) {
super(model, controller, scriptFactory);
}
+
+ @Override
+ public void beforeExecute() {
+ super.beforeExecute();
+ FileUtils.deleteQuietly(new File(model.getProject().getBaseDir(), Util.isWindowsScriptStyle() ? INITIALISE_FIELDS_SERIAL_BAT : INITIALISE_FIELDS_SERIAL_RUN));
+ FileUtils.deleteQuietly(new File(model.getProject().getBaseDir(), Util.isWindowsScriptStyle() ? INITIALISE_FIELDS_PARALLEL_BAT : INITIALISE_FIELDS_PARALLEL_RUN));
+ }
@Override
public void executeClient() {
logger.debug("EXECUTE IN CLIENT");
- File script = scriptFactory.getInitialiseScript(model);
File baseDir = model.getProject().getBaseDir();
File logFile = Paths.get(baseDir.getAbsolutePath(), openFOAMProject.LOG, LOG_NAME).toFile();
-
- ExecutorTerminal terminal = new TerminalExecutorMonitor(logFile);
+
ExecutorMonitor monitor = new ExecutorMonitor();
- ExecutorService service = Executor.newExecutor(ACTION_NAME);
monitor.addHook(ExecutorState.FINISH, new FinishHook());
+
+ ExecutorService service = Executor.newExecutor(ACTION_NAME);
- this.executor = Executor.script(script).description(ACTION_NAME).inFolder(baseDir).inTerminal(terminal).withMonitors(monitor).inService(service).env(getEnvironment(model, LOG_NAME)).keepFileOnEnd();
+ TerminalExecutorMonitor terminal = new TerminalExecutorMonitor(controller.getTerminalManager(), logFile);
+ terminal.setStopCommand(new KillCommandOS(controller));
+
+ this.executor = Executor.script(scriptFactory.getInitialiseScript(model)).description(ACTION_NAME).inFolder(baseDir).inTerminal(terminal).withMonitors(monitor).inService(service).env(getEnvironment(model, LOG_NAME));
executor.exec();
}
private class FinishHook implements ExecutorHook {
@Override
public void run(ExecutorMonitor m) {
- controller.reopenCase(OpenOptions.CURRENT_SETTINGS);
+ controller.reopenCase(OpenMode.CURRENT_SETTINGS);
}
}
diff --git a/src/eu/engys/core/controller/actions/StandardRunCase.java b/src/eu/engys/core/controller/actions/StandardRunCase.java
index fb18cca..289d683 100644
--- a/src/eu/engys/core/controller/actions/StandardRunCase.java
+++ b/src/eu/engys/core/controller/actions/StandardRunCase.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller.actions;
import static eu.engys.core.OpenFOAMEnvironment.getEnvironment;
@@ -59,19 +58,19 @@ public class StandardRunCase extends RunCase {
@Override
public void executeClient() {
logger.debug("EXECUTE IN CLIENT");
- File logFile = Paths.get(model.getProject().getBaseDir().getAbsolutePath(), openFOAMProject.LOG, model.getSolverModel().getLogFile()).toFile();
- TerminalExecutorMonitor terminal = new TerminalExecutorMonitor(logFile);
- terminal.setStopCommand(new StopOrKillCommandOS(controller));
-
+ File baseDir = model.getProject().getBaseDir();
+ File logFile = Paths.get(baseDir.getAbsolutePath(), openFOAMProject.LOG, model.getSolverModel().getLogFile()).toFile();
+
ExecutorMonitor monitor = new ExecutorMonitor();
monitor.addHook(ExecutorState.START, new StartHook());
monitor.addHook(ExecutorState.RUNNING, new RunningHook());
- monitor.addHook(ExecutorState.FINISH, new FinishHook());
monitor.addHook(ExecutorState.ERROR, new ErrorHook());
+ monitor.addHook(ExecutorState.FINISH, new FinishHook());
ExecutorService service = Executor.newExecutor(ACTION_NAME);
- File baseDir = model.getProject().getBaseDir();
+ TerminalExecutorMonitor terminal = new TerminalExecutorMonitor(controller.getTerminalManager(), logFile);
+ terminal.setStopCommand(new StopOrKillCommandOS(controller));
this.executor = Executor.script(scriptFactory.getSolverScript(model)).description(ACTION_NAME).inFolder(baseDir).inTerminal(terminal).withMonitors(monitor).inService(service).env(getEnvironment(model, model.getSolverModel().getLogFile())).keepFileOnEnd();
executor.exec();
@@ -91,14 +90,14 @@ public class StandardRunCase extends RunCase {
}
}
- protected class FinishHook implements ExecutorHook {
+ private class FinishHook implements ExecutorHook {
@Override
public void run(ExecutorMonitor m) {
model.getSolverModel().setServerState(new ServerState(Command.RUN_CASE, SolverState.FINISHED));
}
}
- protected class ErrorHook implements ExecutorHook {
+ private class ErrorHook implements ExecutorHook {
@Override
public void run(ExecutorMonitor m) {
model.getSolverModel().setServerState(new ServerState(Command.RUN_CASE, SolverState.ERROR));
diff --git a/src/eu/engys/core/controller/actions/StandardRunMesh.java b/src/eu/engys/core/controller/actions/StandardRunMesh.java
index 498ce38..b3d8fd9 100644
--- a/src/eu/engys/core/controller/actions/StandardRunMesh.java
+++ b/src/eu/engys/core/controller/actions/StandardRunMesh.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller.actions;
import static eu.engys.core.OpenFOAMEnvironment.getEnvironment;
@@ -35,6 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import eu.engys.core.controller.Controller;
+import eu.engys.core.controller.KillCommandOS;
import eu.engys.core.controller.ScriptFactory;
import eu.engys.core.executor.Executor;
import eu.engys.core.executor.ExecutorHook;
@@ -63,7 +63,10 @@ public class StandardRunMesh extends RunMesh {
ExecutorService service = Executor.newExecutor(ACTION_NAME);
- this.executor = Executor.script(scriptFactory.getMeshScript(model)).description(ACTION_NAME).inFolder(baseDir).inService(service).inTerminal(new TerminalExecutorMonitor(logFile)).withMonitors(monitor).env(getEnvironment(model, LOG_NAME)).keepFileOnEnd();
+ TerminalExecutorMonitor terminal = new TerminalExecutorMonitor(controller.getTerminalManager(), logFile);
+ terminal.setStopCommand(new KillCommandOS(controller));
+
+ this.executor = Executor.script(scriptFactory.getMeshScript(model)).description(ACTION_NAME).inFolder(baseDir).inService(service).inTerminal(terminal).withMonitors(monitor).env(getEnvironment(model, LOG_NAME)).keepFileOnEnd();
executor.exec();
}
diff --git a/src/eu/engys/core/controller/actions/StopCommandInfo.java b/src/eu/engys/core/controller/actions/StopCommandInfo.java
index 76a1664..c8f6f7b 100644
--- a/src/eu/engys/core/controller/actions/StopCommandInfo.java
+++ b/src/eu/engys/core/controller/actions/StopCommandInfo.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller.actions;
import org.slf4j.Logger;
@@ -34,6 +33,8 @@ public class StopCommandInfo extends CommandInfo {
private static final Logger logger = LoggerFactory.getLogger(StopCommandInfo.class);
+ public static final String TIMEOUT = "Timeout";
+
public boolean timeout;
public static StopCommandInfo wrap(CommandInfo info) {
@@ -48,7 +49,7 @@ public class StopCommandInfo extends CommandInfo {
public static StopCommandInfo timeoutException(Exception e) {
logger.error(">>> SERVER STOP ERROR", e);
StopCommandInfo ci = new StopCommandInfo();
- ci.message = "Timeout";
+ ci.message = TIMEOUT;
ci.exception = e;
ci.success = false;
ci.timeout = true;
diff --git a/src/eu/engys/core/controller/actions/Stopper.java b/src/eu/engys/core/controller/actions/Stopper.java
new file mode 100644
index 0000000..bd84f9a
--- /dev/null
+++ b/src/eu/engys/core/controller/actions/Stopper.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
+package eu.engys.core.controller.actions;
+
+import static eu.engys.core.project.system.ControlDict.CONTROL_DICT;
+import static eu.engys.core.project.system.ControlDict.END_TIME_KEY;
+import static eu.engys.core.project.system.ControlDict.STOP_AT_KEY;
+import static eu.engys.core.project.system.ControlDict.WRITE_NOW_KEY;
+
+import java.io.File;
+
+import eu.engys.core.dictionary.DictionaryUtils;
+import eu.engys.core.executor.Executor;
+import eu.engys.core.project.Model;
+import eu.engys.core.project.system.ControlDict;
+import eu.engys.util.PrefUtil;
+
+public class Stopper {
+
+ protected Executor executor;
+ protected Model model;
+
+ public Stopper(Model model, Executor executor) {
+ this.model = model;
+ this.executor = executor;
+ }
+
+ public void stop() throws Exception {
+ setStopAtVariableToWriteNow();
+
+ waitForExecutorToStop();
+
+ setStopAtVariableToEndTime();
+ }
+
+ protected void waitForExecutorToStop() throws Exception {
+ int stop_refresh_time = PrefUtil.getInt(PrefUtil.SERVER_CONNECTION_REFRESH_TIME, 1000);
+ int stop_max_tries = PrefUtil.getInt(PrefUtil.SERVER_CONNECTION_MAX_TRIES, 60);
+
+ int tryIndex = 0;
+ while (this.executor.getState().isDoingSomething() && (tryIndex < stop_max_tries)) {
+ try {
+ Thread.sleep(stop_refresh_time);
+ } catch (Exception e) {
+ }
+ tryIndex++;
+ }
+ if (tryIndex >= stop_max_tries) {
+ throw new TimeoutException("Timeout stopping solver");
+ }
+ }
+
+ private void setStopAtVariableToWriteNow() {
+ File systemFolder = model.getProject().getSystemFolder().getFileManager().getFile();
+ ControlDict controlDict = new ControlDict(new File(systemFolder, CONTROL_DICT));
+ controlDict.add(STOP_AT_KEY, WRITE_NOW_KEY);
+ DictionaryUtils.writeDictionary(systemFolder, controlDict, null);
+
+ ControlDict readControlDict = new ControlDict(new File(systemFolder, CONTROL_DICT));
+ if(!readControlDict.found(STOP_AT_KEY) || !readControlDict.lookup(STOP_AT_KEY).equals(WRITE_NOW_KEY)){
+ try {
+ Thread.sleep(500L);
+ } catch (Exception e) {
+ }
+ setStopAtVariableToWriteNow();
+ }
+ }
+
+ void setStopAtVariableToEndTime() {
+ File systemFolder = model.getProject().getSystemFolder().getFileManager().getFile();
+ ControlDict controlDict = new ControlDict(new File(systemFolder, CONTROL_DICT));
+ if (controlDict.found(STOP_AT_KEY) && controlDict.lookup(STOP_AT_KEY).equals(WRITE_NOW_KEY)) {
+ controlDict.add(STOP_AT_KEY, END_TIME_KEY);
+ DictionaryUtils.writeDictionary(systemFolder, controlDict, null);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/eu/engys/core/controller/actions/TimeoutException.java b/src/eu/engys/core/controller/actions/TimeoutException.java
index 66a8ae3..2ba956f 100644
--- a/src/eu/engys/core/controller/actions/TimeoutException.java
+++ b/src/eu/engys/core/controller/actions/TimeoutException.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.controller.actions;
public class TimeoutException extends Exception {
diff --git a/src/eu/engys/core/dictionary/BeanToDict.java b/src/eu/engys/core/dictionary/BeanToDict.java
index c27988a..159a628 100644
--- a/src/eu/engys/core/dictionary/BeanToDict.java
+++ b/src/eu/engys/core/dictionary/BeanToDict.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
import java.io.File;
@@ -130,7 +129,7 @@ public class BeanToDict {
for (Method m : methods) {
String fieldName = "";
- if (m.getName().startsWith("get") && !m.getName().startsWith("getClass")) {
+ if (m.getName().startsWith("get") && !m.getName().startsWith("getClass") && m.getParameterTypes().length == 0) {
fieldName = getFieldNameFromGetter(m);
} else if (m.getName().startsWith("is")) {
fieldName = getFieldNameFromBooleanGetter(m);
@@ -143,7 +142,7 @@ public class BeanToDict {
addToDictionary(dictionary, fieldName, value);
}
} catch (Exception ex) {
- ex.printStackTrace();
+ logger.error("Error invoking method {}", m, ex);
}
}
return dictionary;
@@ -225,6 +224,10 @@ public class BeanToDict {
return dict;
}
+// public static Map dictToMap(Dictionary dictionary, B bean) {
+//
+// }
+
private static String toArray(Object array) throws Exception {
return toBracketedArrayOfStrings(array);
}
diff --git a/src/eu/engys/core/dictionary/BlockMeshWriter.java b/src/eu/engys/core/dictionary/BlockMeshWriter.java
index 6670671..11908a0 100644
--- a/src/eu/engys/core/dictionary/BlockMeshWriter.java
+++ b/src/eu/engys/core/dictionary/BlockMeshWriter.java
@@ -1,39 +1,37 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
import static eu.engys.core.dictionary.Dictionary.SPACER;
import static eu.engys.core.dictionary.Dictionary.TAB;
import static eu.engys.core.dictionary.Dictionary.VERBOSE;
+
import eu.engys.core.dictionary.parser.ListField2;
public class BlockMeshWriter extends DictionaryWriter {
-
public BlockMeshWriter(Dictionary dictionary) {
super(dictionary);
}
@@ -50,10 +48,10 @@ public class BlockMeshWriter extends DictionaryWriter {
BlockMeshWriter writer = new BlockMeshWriter(dictionary.getFoamFile());
writer.writeDictionary(sb, "");
-// if (dictionary.isList("")) {
-// ListField.class.cast(dictionary.getList()).writeListDict(sb, rowHeader);
-// return;
-// }
+ // if (dictionary.isList("")) {
+ // ListField.class.cast(dictionary.getList()).writeListDict(sb, rowHeader);
+ // return;
+ // }
} else {
sb.append("\n");
sb.append(rowHeader);
@@ -66,7 +64,7 @@ public class BlockMeshWriter extends DictionaryWriter {
DefaultElement ele = dictionary.getElement(key);
write(sb, rowHeader, ele);
}
-
+
for (String includeFile : dictionary.getIncludeFiles()) {
writeInclude(sb, includeFile, rowHeader);
}
@@ -105,16 +103,18 @@ public class BlockMeshWriter extends DictionaryWriter {
private static void writeDimensionedScalar(StringBuffer sb, DimensionedScalar ds, String rowHeader) {
if (VERBOSE)
System.out.println("Dictionary.writeDimensionedScalar() " + (ds != null ? ds.getName() : "NULL!!!"));
- sb.append("\n");
- sb.append(rowHeader);
- sb.append(TAB);
- sb.append(ds.getName());
- sb.append(SPACER);
- sb.append(ds.getName());
- sb.append(SPACER);
- sb.append(ds.getDimensions());
- sb.append(SPACER);
- sb.append(ds.getValue());
- sb.append(";");
+ if (ds != null) {
+ sb.append("\n");
+ sb.append(rowHeader);
+ sb.append(TAB);
+ sb.append(ds.getName());
+ sb.append(SPACER);
+ sb.append(ds.getName());
+ sb.append(SPACER);
+ sb.append(ds.getDimensions());
+ sb.append(SPACER);
+ sb.append(ds.getValue());
+ sb.append(";");
+ }
}
}
diff --git a/src/eu/engys/core/dictionary/DefaultElement.java b/src/eu/engys/core/dictionary/DefaultElement.java
index 0fb3d97..da4885e 100644
--- a/src/eu/engys/core/dictionary/DefaultElement.java
+++ b/src/eu/engys/core/dictionary/DefaultElement.java
@@ -1,39 +1,40 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
-public class DefaultElement {
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
+public abstract class DefaultElement {
private String name;
-
+
public DefaultElement(String name) {
this.name = name;
}
-
+
public String getName() {
return name;
}
@@ -41,12 +42,21 @@ public class DefaultElement {
public void setName(String name) {
this.name = name;
}
-
+
@Override
public boolean equals(Object obj) {
- if (obj instanceof DefaultElement) {
- return ((DefaultElement) obj).name.equals(name);
- }
- return super.equals(obj);
+ if (!(obj instanceof DefaultElement)) {
+ return false;
+ }
+ if (obj == this) {
+ return true;
+ }
+ DefaultElement fz = (DefaultElement) obj;
+ return new EqualsBuilder().append(name, fz.name).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 31).append(name).toHashCode();
}
}
diff --git a/src/eu/engys/core/dictionary/Dictionary.java b/src/eu/engys/core/dictionary/Dictionary.java
index 3511d55..e6e13db 100644
--- a/src/eu/engys/core/dictionary/Dictionary.java
+++ b/src/eu/engys/core/dictionary/Dictionary.java
@@ -1,807 +1,971 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.LinkedHashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import javax.vecmath.Point3d;
+
import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
import eu.engys.core.dictionary.parser.ListField2;
import eu.engys.core.dictionary.parser.ThetaListField2;
public class Dictionary extends DefaultElement {
- public static boolean VERBOSE = false;
+ public static boolean VERBOSE = false;
- public static final String SPACER = " ";
- public static final String TAB = " ";
+ public static final String SPACER = " ";
+ public static final String TAB = " ";
- public static final String DICTIONARY_LINK = "DICTIONARY_LINK";
- public static final String VALUE_LINK = "VALUE_LINK";
- public static final String VALUE_UNIFORM_LINK = "VALUE_UNIFORM_LINK";
+ public static final String DICTIONARY_LINK = "DICTIONARY_LINK";
+ public static final String VALUE_LINK = "VALUE_LINK";
+ public static final String VALUE_UNIFORM_LINK = "VALUE_UNIFORM_LINK";
- public static final String TYPE = "type";
- public static final String VALUE = "value";
+ public static final String TYPE = "type";
+ public static final String VALUE = "value";
+ public static final String CONSTANT = "constant";
+ public static final String NONUNIFORM = "nonuniform";
+ public static final String UNIFORM = "uniform";
- private FoamFile foamFile;
+ private FoamFile foamFile;
- private Map elements = new LinkedHashMap();
- private List keys = new ArrayList();
- private List genericKeys = new ArrayList();
- private List includeFiles = new ArrayList();
+ private Map elements = new LinkedHashMap();
+ private List keys = new ArrayList();
+ private List genericKeys = new ArrayList();
+ private List includeFiles = new ArrayList();
- public Dictionary(String name, File file) {
- super(name);
- readDictionary(file);
- }
-
- public Dictionary(File file) {
- this(file.getName(), file);
- }
-
-
- public Dictionary(String name, InputStream input, DictionaryLinkResolver resolver) {
- super(name);
- readDictionary(input, resolver);
- }
-
- public Dictionary(String name, InputStream input) {
- super(name);
- readDictionary(input);
- }
-
- public Dictionary(String name) {
- super(name);
- }
-
- public Dictionary(Dictionary d) {
- this(d.getName(), d);
- }
-
- public Dictionary(String name, Dictionary d) {
- super(name);
- setFoamFile(d.getFoamFile());
- for (String key : d.keys) {
- DefaultElement el = d.elements.get(key);
- if (el instanceof Dictionary) {
- add(new Dictionary((Dictionary) el));
- } else if (el instanceof DimensionedScalar) {
- DimensionedScalar ds = (DimensionedScalar) el;
- add(new DimensionedScalar(ds));
- } else if (el instanceof FieldElement) {
- FieldElement f = (FieldElement) el;
- add(f.getName(), f.getValue());
- } else if (el instanceof ListField) {
- ListField lf = (ListField) el;
- add(lf.getName(), new ListField(lf));
- } else if (el instanceof ThetaListField2) {
- ThetaListField2 tf = (ThetaListField2) el;
- add(tf.getName(), new ThetaListField2(tf));
- } else if (el instanceof ListField2) {
- ListField2 lf = (ListField2) el;
- add(lf.getName(), new ListField2(lf));
- }
- }
- genericKeys.addAll(d.genericKeys);
- }
-
- public void setFoamFile(FoamFile file) {
- if (found("FoamFile"))
- remove("FoamFile");
- this.foamFile = file;
- }
-
- public FoamFile getFoamFile() {
- return foamFile;
- }
-
- public void check() throws DictionaryException {
- }
-
- public void include(String includeFile) {
- includeFiles.add(includeFile);
- }
-
- private void put(String key, DefaultElement value) {
- elements.put(key, value);
- if (!keys.contains(key))
- keys.add(key);
- }
-
- public void add(DefaultElement el) {
- put(el.getName(), el);
- }
-
- public void addGeneric(DefaultElement el) {
- String name = el.getName();
- if (!genericKeys.contains(name)) {
- genericKeys.add(name);
- }
- put(name, el);
- }
-
- public void add(Dictionary dictionary) {
- put(dictionary.getName(), dictionary);
- }
-
- public void addToList(Dictionary dictionary) {
- addToList("", dictionary);
- }
-
- public void addToList(String listName, Dictionary dictionary) {
- ListField list = getList(listName);
- if (list == null) {
- list = new ListField(listName);
- add(list);
- }
- list.add(dictionary);
- }
-
- public void addToList(String listName, FieldElement fe) {
- ListField list = getList(listName);
- if (list == null) {
- list = new ListField(listName);
- add(list);
- }
- list.add(fe);
- }
-
- public void add(String name, String value) {
- put(name, new FieldElement(name, value));
- }
-
-// public void add(Finder finder, String value) {
-// String key = findKey(finder);
-// put(key, new FieldElement(key, value));
-// }
-
- public void addGeneric(String name, String value) {
- if (!genericKeys.contains(name)) {
- genericKeys.add(name);
- }
- put(name, new FieldElement(name, value));
- }
-
- public void add(String name, double[] values) {
- StringBuffer sb = new StringBuffer("(");
- for (double d : values) {
- sb.append(String.valueOf(d) + " ");
- }
- sb.append(")");
- this.add(name, sb.toString());
- }
-
- public void add(String name, int[] values) {
- StringBuffer sb = new StringBuffer("(");
- for (int d : values) {
- sb.append(String.valueOf(d) + " ");
- }
- sb.append(")");
- this.add(name, sb.toString());
- }
-
- public void add(String name, String[] values) {
- StringBuffer sb = new StringBuffer("(");
- for (String p : values) {
- sb.append(p + " ");
- }
- sb.append(")");
- this.add(name, sb.toString());
- }
-
- public void add(String name, List values) {
- this.add(name, values.toArray(new String[0]));
- }
-
- public void add(DimensionedScalar ds) {
- put(ds.getName(), ds);
- }
-
- public void add(String name, ListField list) {
- put(name, list);
- }
-
- public void add(String name, ListField2 list) {
- put(name, list);
- }
-
- public void add(ListField list) {
- put(list.getName(), list);
- }
-
- private String findKey(Finder finder) {
- for (String key : keys) {
- if (finder.accept(key)) {
- return key;
- }
- }
- return null;
- }
-
- public boolean found(Finder finder) {
- String key = findKey(finder);
- return key != null;
- }
-
- public boolean found(String name) {
- if (foundGeneric(name))
- return true;
- else
- return keys.contains(name);
- }
-
- private boolean foundGeneric(String name) {
- if (!genericKeys.isEmpty()) {
- for (String genericKey : genericKeys) {
- if (("\"" + name + "\"").matches(genericKey)) {
- return true;
- }
- }
- }
- return false;
- }
-
- DefaultElement getElement(String name) {
- if (elements.containsKey(name))
- return elements.get(name);
-
- if (!genericKeys.isEmpty()) {
- for (String genericKey : genericKeys) {
- if (("\"" + name + "\"").matches(genericKey)) {
- return elements.get(genericKey);
- }
- }
- }
- return null;
- }
-
- public boolean isDictionary(String name) {
- DefaultElement el = getElement(name);
- return (el != null && el instanceof Dictionary);
- }
-
- public boolean isField(String name) {
- DefaultElement el = getElement(name);
- return (el != null && el instanceof FieldElement);
- }
-
- public boolean isList(String name) {
- DefaultElement el = getElement(name);
- return (el != null && el instanceof ListField);
- }
-
- public boolean isList2(String name) {
- DefaultElement el = getElement(name);
- return (el != null && el instanceof ListField2);
- }
-
- public boolean isThetaList2(String name) {
- DefaultElement el = getElement(name);
- return (el != null && el instanceof ThetaListField2);
- }
-
- public Dictionary subDict(String name) {
- DefaultElement el = getElement(name);
- if (isDictionary(name)) {
- return (Dictionary) el;
- } else if (el != null)
- throw new DictionaryException(name + " not a dictionary");
- else
- return null;
- }
-
-// public ListField getList() {
-// return getList("");
-// }
-//
-// public ListField2 getList2() {
-// return getList2("");
-// }
-
- public ListField getList(String name) {
- DefaultElement el = getElement(name);
- if (isList(name)) {
- return (ListField) el;
- } else if (el != null)
- throw new DictionaryException(name + " not a list");
- else
- return null;
- }
-
- public ListField2 getList2(String name) {
- DefaultElement el = getElement(name);
- if (isList2(name)) {
- return (ListField2) el;
- } else if (el != null)
- throw new DictionaryException(name + " not a list");
- else
- return null;
- }
-
- public ThetaListField2 getThetaList2(String name) {
- DefaultElement el = getElement(name);
- if (isThetaList2(name)) {
- return (ThetaListField2) el;
- } else if (el != null)
- throw new DictionaryException(name + " not a theta list");
- else
- return null;
- }
-
- public DefaultElement lookup(Finder finder) {
- String key = findKey(finder);
- if (key == null) {
- throw new DictionaryException("Key " + key + " is NULL");
- }
-
- return getElement(key);
- }
-
- public String lookup(String key) {
- return lookupString(key);
- }
-
- public String lookupString(String key) {
- if (key == null) {
- throw new DictionaryException("Key " + key + " is NULL");
- }
- DefaultElement el = getElement(key);
- if (isField(key)) {
- return ((FieldElement) el).getValue();
- } else if (el != null)
- throw new DictionaryException(key + " not a field");
- else
- return null;
- }
-
- public int lookupInt(String name) {
- String value = lookupString(name);
- try {
- return Integer.parseInt(value);
- } catch (NumberFormatException e) {
- return -1;
- }
- }
-
- public double lookupDouble(String name) {
- String value = lookupString(name);
- try {
- return Double.parseDouble(value);
- } catch (NumberFormatException e) {
- return Double.NaN;
- }
- }
-
- public DimensionedScalar lookupScalar(String name) {
- DefaultElement el = getElement(name);
- if (el != null && el instanceof DimensionedScalar) {
- return (DimensionedScalar) el;
- } else if (el != null)
- throw new DictionaryException(name + " not a dimensioned scalar");
- else
- return null;
- }
-
- public String[] lookupArray(String name) {
- DefaultElement el = getElement(name);
- if (el != null && el instanceof FieldElement) {
- String value = ((FieldElement) el).getValue();
- if (value.startsWith("uniform")) {
- value = value.replace("uniform", "").trim();
- }
- if (value.startsWith("nonuniform")) {
- return new String[] { "Infinity", "Infinity", "Infinity" };
- }
- if (value.startsWith("(") && value.endsWith(")")) {
- value = value.replace("(", "").replace(")", "").trim();
- // value = value.substring(1, value.length()-1);
- if (value.isEmpty()) {
- return new String[0];
- }
- String[] values = value.split(SPACER);
- // System.out.println("Dictionary.lookupArray() "+Arrays.toString(values));
- return values;
- } else
- throw new DictionaryException(name + " not an array");
- } else if (el != null)
- throw new DictionaryException(name + " not a field");
- else
- return null;
- }
-
- public String[][] lookupMatrix(String name) {
- DefaultElement el = getElement(name);
- if (el != null && el instanceof FieldElement) {
- String value = ((FieldElement) el).getValue();
- if (value.startsWith("uniform")) {
- value = value.replace("uniform", "").trim();
- }
- if (value.startsWith("(") && value.endsWith(")")) {
- value = value.replaceAll("\\(\\s*\\(", "");
- value = value.replaceAll("\\)\\s*\\)", "");
-
- String[] values = value.split("\\)\\s*\\(");
- String[][] matrix = new String[values.length][];
- for (int r = 0; r < values.length; r++) {
- String[] row = values[r].trim().split("\\s+");
- matrix[r] = row;
- }
- return matrix;
- } else
- throw new DictionaryException(name + " not an array");
- } else if (el != null)
- throw new DictionaryException(name + " not a field");
- else
- return null;
- }
-
- public String[] lookupArray2(String name) {
- DefaultElement el = getElement(name);
- if (el != null && el instanceof ListField2) {
- ListField2 list = (ListField2) el;
- return listToArray(list);
- } else if (el != null)
- throw new DictionaryException(name + " not a field");
- else
- return null;
- }
-
- private String[] listToArray(ListField2 list) {
- List elements = list.getListElements();
-
- String[] values = new String[elements.size()];
-
- for (int i = 0; i < elements.size(); i++) {
- DefaultElement element = elements.get(i);
- if (element instanceof FieldElement) {
- String value = ((FieldElement) element).getValue();
- values[i] = value;
- } else if (element instanceof ListField2) {
- String[] listField = listToArray((ListField2) element);
- values[i] = "(";
- for (int j = 0; j < listField.length; j++) {
- values[i] += listField[j] + " ";
- }
- values[i] += ")";
- }
- }
- return values;
- }
-
- public String[][] lookupMatrix2(String name) {
- DefaultElement el = getElement(name);
- if (el != null && el instanceof ListField2) {
- ListField2 list = (ListField2) el;
- return listToMatrix(list);
- } else if (el != null) {
- throw new DictionaryException(name + " not a field");
- } else {
- return null;
- }
- }
-
- private String[][] listToMatrix(ListField2 list) {
- List rows = list.getListElements();
- if (rows.size() > 0 && rows.get(0) instanceof ListField2) {
- ListField2 firstRow = (ListField2) rows.get(0);
- String[][] values = new String[rows.size()][firstRow.getListElements().size()];
-
- for (int i = 0; i < rows.size(); i++) {
- if (rows.get(i) instanceof ListField2) {
- ListField2 row = (ListField2) rows.get(i);
- values[i] = listToArray(row);
- }
- }
- return values;
- } else {
- return new String[0][0];
- }
- }
-
- public double[] lookupDoubleArray(String name) {
- String[] array = lookupArray(name);
- double[] doubleArray = new double[array.length];
- for (int i = 0; i < doubleArray.length; i++) {
- try {
- doubleArray[i] = Double.valueOf(array[i]);
- } catch (NumberFormatException e) {
- }
- }
- return doubleArray;
- }
-
- public double[] lookupDoubleArray2(String name) {
- String[] array = lookupArray2(name);
- double[] doubleArray = new double[array.length];
- for (int i = 0; i < doubleArray.length; i++) {
- try {
- doubleArray[i] = Double.valueOf(array[i]);
- } catch (NumberFormatException e) {
- }
- }
- return doubleArray;
- }
-
- public double[][] lookupDoubleMatrix(String name) {
- String[][] matrix = lookupMatrix(name);
- double[][] doubleMatrix = new double[matrix.length][matrix[0].length];
- for (int i = 0; i < doubleMatrix.length; i++) {
- for (int j = 0; j < doubleMatrix[i].length; j++) {
- try {
- doubleMatrix[i][j] = Double.valueOf(matrix[i][j]);
- } catch (NumberFormatException e) {
- }
- }
- }
- return doubleMatrix;
- }
-
- public double[][] lookupDoubleMatrix2(String name) {
- String[][] matrix = lookupMatrix2(name);
- double[][] doubleMatrix = new double[matrix.length][matrix[0].length];
- for (int i = 0; i < doubleMatrix.length; i++) {
- for (int j = 0; j < doubleMatrix[i].length; j++) {
- try {
- doubleMatrix[i][j] = Double.valueOf(matrix[i][j]);
- } catch (NumberFormatException e) {
- e.printStackTrace();
- }
- }
- }
- return doubleMatrix;
- }
-
- public int[] lookupIntArray(String name) {
- String[] array = lookupArray(name);
- int[] intArray = new int[array.length];
- for (int i = 0; i < intArray.length; i++) {
- try {
- intArray[i] = Integer.valueOf(array[i]);
- } catch (NumberFormatException e) {
- }
- }
- return intArray;
- }
-
- public Dictionary removeDict(String name) {
- keys.remove(name);
- return (Dictionary) elements.remove(name);
- }
-
- public DefaultElement remove(String name) {
- keys.remove(name);
- return elements.remove(name);
- }
-
- public DefaultElement remove(Finder finder) {
- String key = findKey(finder);
- return remove(key);
- }
-
- List getGenericKeys() {
- return genericKeys;
- }
-
- List getKeys() {
- return keys;
- }
-
- List getIncludeFiles() {
- return includeFiles;
- }
-
- public boolean isEmpty() {
- return keys.isEmpty();
- }
-
- @Override
- public String toString() {
- return new DictionaryWriter(this).write();
- }
-
- public List getDictionaries() {
- List list = new ArrayList();
- for (String key : keys) {
- DefaultElement el = elements.get(key);
- if (el instanceof Dictionary) {
- list.add((Dictionary) el);
- }
- }
- return list;
- }
-
- public Map getDictionariesMap() {
- Map map = new LinkedHashMap();
- for (String key : keys) {
- DefaultElement el = elements.get(key);
- if (el instanceof Dictionary) {
- map.put(el.getName(), (Dictionary) el);
- }
- }
- return map;
- }
-
- public List getFields() {
- List list = new ArrayList();
- for (DefaultElement el : elements.values()) {
- if (el instanceof FieldElement) {
- list.add((FieldElement) el);
- }
- }
- return list;
- }
-
- public List getListFields() {
- List list = new ArrayList<>();
- for (DefaultElement el : elements.values()) {
- if (el instanceof ListField) {
- list.add((ListField) el);
- }
- }
- return list;
- }
-
- public boolean hasOnlyList(){
- return !getListFields().isEmpty() && getDictionaries().isEmpty() && getFieldsMap().isEmpty();
- }
-
- public boolean hasOnlyList2(){
- return !getListFields2().isEmpty() && getDictionaries().isEmpty() && getFieldsMap().isEmpty();
- }
-
- public List getListFields2() {
- List list = new ArrayList<>();
- for (DefaultElement el : elements.values()) {
- if (el instanceof ListField2) {
- list.add((ListField2) el);
- }
- }
- return list;
- }
-
- public Map getFieldsMap() {
- Map map = new LinkedHashMap();
- for (DefaultElement el : elements.values()) {
- if (el instanceof FieldElement) {
- FieldElement field = (FieldElement) el;
- map.put(field.getName(), field.getValue());
- }
- }
- return map;
- }
-
- public void merge(Dictionary dict) {
- merge(dict, new String[0]);
- }
-
- public void merge(Dictionary dict, String[] keysToExclude) {
- if (dict == null)
- return;
- // System.out.println("Dictionary.merge(): "+dict);
- for (String key : dict.getKeys()) {
- if(ArrayUtils.contains(keysToExclude, key)){
- continue;
- }
-
- DefaultElement ele = dict.getElement(key);
- if (ele instanceof Dictionary) {
- Dictionary d = (Dictionary) ele;
- if (found(d.getName()) && isDictionary(d.getName())) {
- subDict(d.getName()).merge(d);
- } else {
- add(new Dictionary(d.getName()));
- subDict(d.getName()).merge(d);
- }
- } else if (ele instanceof ListField) {
- ListField l = (ListField) ele;
- if (found(l.getName()) && isList(l.getName())) {
- getList(l.getName()).merge(l);
- } else {
- add(new ListField(l.getName()));
- getList(l.getName()).merge(l);
- }
- } else if (ele instanceof ThetaListField2) {
- ThetaListField2 t = (ThetaListField2) ele;
- if (found(t.getName()) && isThetaList2(t.getName())) {
- getThetaList2(t.getName()).merge(t);
- } else {
- add(new ThetaListField2(t));
- }
- } else if (ele instanceof ListField2) {
- ListField2 l = (ListField2) ele;
- if (found(l.getName()) && isList2(l.getName())) {
- getList2(l.getName()).merge(l);
- } else {
- add(new ListField2(l));
- }
- } else if (ele instanceof FieldElement) {
- FieldElement f = (FieldElement) ele;
- if (f instanceof DimensionedScalar) {
- add(new DimensionedScalar((DimensionedScalar) f));
- } else {
- add(f.getName(), f.getValue());
- }
- }
- }
- genericKeys.addAll(dict.genericKeys);
+ public Dictionary(String name, File file) {
+ super(name);
+ readDictionary(file);
}
- public void clear() {
- elements.clear();
- keys.clear();
- }
+ public Dictionary(File file) {
+ this(file.getName(), file);
+ }
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Dictionary) {
- Dictionary d = (Dictionary) obj;
- if (elements.size() != d.elements.size())
- return false;
- for (String key : elements.keySet()) {
- if (!elements.get(key).equals(d.elements.get(key)))
- return false;
- }
- return true;
- }
- return false;
- }
+ public Dictionary(String name, InputStream input, DictionaryLinkResolver resolver) {
+ super(name);
+ readDictionary(input, resolver);
+ }
- /* * * * * * * * * * * * *
- * READ/WRITE STUFF * * * * * * * * * * * *
- */
+ public Dictionary(String name, InputStream input) {
+ super(name);
+ readDictionary(input);
+ }
- public void readDictionary(File file) {
- DictionaryReader reader = new DictionaryReader(this);
- reader.read(file);
- }
+ public Dictionary(String name) {
+ super(name);
+ }
- protected void readDictionary(InputStream input, DictionaryLinkResolver resolver) {
- DictionaryReader reader = new DictionaryReader(this, resolver);
- reader.read(input);
- }
+ public Dictionary(Dictionary d) {
+ this(d.getName(), d);
+ }
- protected void readDictionary(InputStream input) {
- DictionaryReader reader = new DictionaryReader(this);
- reader.read(input);
- }
+ public Dictionary(String name, Dictionary d) {
+ super(name);
+ setFoamFile(d.getFoamFile());
+ for (String key : d.keys) {
+ DefaultElement el = d.elements.get(key);
+ if (el instanceof Dictionary) {
+ add(new Dictionary((Dictionary) el));
+ } else if (el instanceof DimensionedScalar) {
+ DimensionedScalar ds = (DimensionedScalar) el;
+ add(new DimensionedScalar(ds));
+ } else if (el instanceof FieldElement) {
+ FieldElement f = (FieldElement) el;
+ add(f.getName(), f.getValue());
+ } else if (el instanceof ListField) {
+ ListField lf = (ListField) el;
+ add(lf.getName(), new ListField(lf));
+ } else if (el instanceof ThetaListField2) {
+ ThetaListField2 tf = (ThetaListField2) el;
+ add(tf.getName(), new ThetaListField2(tf));
+ } else if (el instanceof ListField2) {
+ ListField2 lf = (ListField2) el;
+ add(lf.getName(), new ListField2(lf));
+ }
+ }
+ genericKeys.addAll(d.genericKeys);
+ }
- protected void readDictionaryFromString(String text) {
- DictionaryReader reader = new DictionaryReader(this);
- reader.read(text);
- }
+ public void setFoamFile(FoamFile file) {
+ if (found("FoamFile"))
+ remove("FoamFile");
+ this.foamFile = file;
+ }
- protected String write() {
- DictionaryWriter writer = new DictionaryWriter(this);
- return writer.write();
- }
+ public FoamFile getFoamFile() {
+ return foamFile;
+ }
+
+ public void check() throws DictionaryException {
+ }
+
+ public void include(String includeFile) {
+ includeFiles.add(includeFile);
+ }
+
+ private void put(String key, DefaultElement value) {
+ elements.put(key, value);
+ if (!keys.contains(key))
+ keys.add(key);
+ }
+
+ public void add(DefaultElement el) {
+ put(el.getName(), el);
+ }
+
+ public void addGeneric(DefaultElement el) {
+ String name = el.getName();
+ if (!genericKeys.contains(name)) {
+ genericKeys.add(name);
+ }
+ put(name, el);
+ }
+
+ public void add(Dictionary dictionary) {
+ put(dictionary.getName(), dictionary);
+ }
+
+ public void addToList(Dictionary dictionary) {
+ addToList("", dictionary);
+ }
+
+ public void addToList(String listName, Dictionary dictionary) {
+ ListField list = getList(listName);
+ if (list == null) {
+ list = new ListField(listName);
+ add(list);
+ }
+ list.add(dictionary);
+ }
+
+ public void addToList(String listName, FieldElement fe) {
+ ListField list = getList(listName);
+ if (list == null) {
+ list = new ListField(listName);
+ add(list);
+ }
+ list.add(fe);
+ }
+
+ public void add(String name, String value) {
+ put(name, new FieldElement(name, value));
+ }
+
+ public void add(String name, Boolean value) {
+ put(name, new FieldElement(name, String.valueOf(value)));
+ }
+
+ public void add(String name, Double value) {
+ put(name, new FieldElement(name, String.valueOf(value)));
+ }
+
+ public void add(String name, Integer value) {
+ put(name, new FieldElement(name, String.valueOf(value)));
+ }
+
+ public void addUniform(String name, Double value) {
+ put(name, new FieldElement(name, UNIFORM + " " + String.valueOf(value)));
+ }
+
+ public void addUniform(String name, Integer value) {
+ put(name, new FieldElement(name, UNIFORM + " " + String.valueOf(value)));
+ }
+
+ public void addConstant(String name, Double value) {
+ put(name, new FieldElement(name, CONSTANT + " " + String.valueOf(value)));
+ }
+
+ public void addConstant(String name, Integer value) {
+ put(name, new FieldElement(name, CONSTANT + " " + String.valueOf(value)));
+ }
+
+ public void addGeneric(String name, String value) {
+ if (!genericKeys.contains(name)) {
+ genericKeys.add(name);
+ }
+ put(name, new FieldElement(name, value));
+ }
+
+ public void addUniform(String name, double[] values) {
+ StringBuffer sb = new StringBuffer(UNIFORM + " ( ");
+ for (Double d : values) {
+ sb.append(String.valueOf(d) + " ");
+ }
+ sb.append(")");
+ this.add(name, sb.toString());
+ }
+
+ public static String toString(double[] values) {
+ StringBuffer sb = new StringBuffer("( ");
+ for (Double d : values) {
+ sb.append(String.valueOf(d) + " ");
+ }
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public static String toString(double[][] values) {
+ StringBuffer sb = new StringBuffer("( ");
+ for (int i = 0; i < values.length; i++) {
+ sb.append(toString(values[i]) + " ");
+ }
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void add(String name, double[] values) {
+ this.add(name, toString(values));
+ }
+
+ public void add(String name, double[][] values) {
+ this.add(name, toString(values));
+ }
+
+ public void add(String name, String[][] values) {
+ StringBuffer sb = new StringBuffer("( ");
+ for (int i = 0; i < values.length; i++) {
+ sb.append("( ");
+ for (int j = 0; j < values[i].length; j++) {
+ String d = values[i][j];
+ sb.append(d + " ");
+ }
+ sb.append(") ");
+ }
+ sb.append(")");
+ this.add(name, sb.toString());
+ }
+
+ public void add(String name, int[] values) {
+ StringBuffer sb = new StringBuffer("( ");
+ for (int d : values) {
+ sb.append(String.valueOf(d) + " ");
+ }
+ sb.append(")");
+ this.add(name, sb.toString());
+ }
+
+ public void add(String name, String[] values) {
+ StringBuffer sb = new StringBuffer("( ");
+ for (String p : values) {
+ sb.append(p + " ");
+ }
+ sb.append(")");
+ this.add(name, sb.toString());
+ }
+
+ public void add(String name, List values) {
+ this.add(name, values.toArray(new String[0]));
+ }
+
+ public void add(DimensionedScalar ds) {
+ put(ds.getName(), ds);
+ }
+
+ public void add(String name, ListField list) {
+ put(name, list);
+ }
+
+ public void add(String name, ListField2 list) {
+ put(name, list);
+ }
+
+ public void add(ListField list) {
+ put(list.getName(), list);
+ }
+
+ public String findKey(Finder finder) {
+ for (String key : keys) {
+ if (finder.accept(key)) {
+ return key;
+ }
+ }
+ return null;
+ }
+
+ public boolean found(Finder finder) {
+ String key = findKey(finder);
+ return key != null;
+ }
+
+ public boolean found(String name) {
+ if (foundGeneric(name))
+ return true;
+ else
+ return keys.contains(name);
+ }
+
+ private boolean foundGeneric(String name) {
+ if (!genericKeys.isEmpty()) {
+ for (String genericKey : genericKeys) {
+ if (("\"" + name + "\"").matches(genericKey)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ DefaultElement getElement(String name) {
+ if (elements.containsKey(name))
+ return elements.get(name);
+
+ if (!genericKeys.isEmpty()) {
+ for (String genericKey : genericKeys) {
+ if (("\"" + name + "\"").matches(genericKey)) {
+ return elements.get(genericKey);
+ }
+ }
+ }
+ return null;
+ }
+
+ public boolean isDictionary(String name) {
+ DefaultElement el = getElement(name);
+ return (el != null && el instanceof Dictionary);
+ }
+
+ public boolean isScalar(String name) {
+ DefaultElement el = getElement(name);
+ return (el != null && el instanceof DimensionedScalar);
+ }
+
+ public boolean isField(String name) {
+ DefaultElement el = getElement(name);
+ return (el != null && el instanceof FieldElement);
+ }
+
+ public boolean isList(String name) {
+ DefaultElement el = getElement(name);
+ return (el != null && el instanceof ListField);
+ }
+
+ public boolean isList2(String name) {
+ DefaultElement el = getElement(name);
+ return (el != null && el instanceof ListField2);
+ }
+
+ public boolean isThetaList2(String name) {
+ DefaultElement el = getElement(name);
+ return (el != null && el instanceof ThetaListField2);
+ }
+
+ public Dictionary subDict(String name) {
+ DefaultElement el = getElement(name);
+ if (isDictionary(name)) {
+ return (Dictionary) el;
+ } else if (el != null)
+ throw new DictionaryException(name + " not a dictionary");
+ else
+ return null;
+ }
+
+ // public ListField getList() {
+ // return getList("");
+ // }
+ //
+ // public ListField2 getList2() {
+ // return getList2("");
+ // }
+
+ public ListField getList(String name) {
+ DefaultElement el = getElement(name);
+ if (isList(name)) {
+ return (ListField) el;
+ } else if (el != null)
+ throw new DictionaryException(name + " not a list");
+ else
+ return null;
+ }
+
+ public ListField2 getList2(String name) {
+ DefaultElement el = getElement(name);
+ if (isList2(name)) {
+ return (ListField2) el;
+ } else if (el != null)
+ throw new DictionaryException(name + " not a list");
+ else
+ return null;
+ }
+
+ public ThetaListField2 getThetaList2(String name) {
+ DefaultElement el = getElement(name);
+ if (isThetaList2(name)) {
+ return (ThetaListField2) el;
+ } else if (el != null)
+ throw new DictionaryException(name + " not a theta list");
+ else
+ return null;
+ }
+
+ public DefaultElement lookup(Finder finder) {
+ String key = findKey(finder);
+ if (key == null) {
+ throw new DictionaryException("Key " + key + " is NULL");
+ }
+
+ return getElement(key);
+ }
+
+ public String lookup(String key) {
+ return lookupString(key);
+ }
+
+ public String lookupString(String key) {
+ if (key == null) {
+ throw new DictionaryException("Key " + key + " is NULL");
+ }
+ DefaultElement el = getElement(key);
+ if (isField(key)) {
+ return ((FieldElement) el).getValue();
+ } else if (el != null)
+ throw new DictionaryException(key + " not a field");
+ else
+ return null;
+ }
+
+ public boolean lookupBoolean(String name) {
+ String value = lookupString(name);
+ if (value != null) {
+ return value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes") || value.equalsIgnoreCase("on");
+ } else {
+ return false;
+ }
+ }
+
+ public int lookupInt(String name) {
+ String value = lookupString(name);
+ try {
+ return Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ return -1;
+ }
+ }
+
+ public int lookupIntConstant(String name) {
+ String value = lookupString(name).replace(CONSTANT, "").trim();
+ try {
+ return Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ return -1;
+ }
+ }
+
+ public double lookupDouble(String name) {
+ String value = lookupString(name);
+ try {
+ return Double.parseDouble(value);
+ } catch (NumberFormatException e) {
+ return Double.NaN;
+ }
+ }
+
+ public double lookupDoubleUniform(String name) {
+ String value = lookupString(name).replace(UNIFORM, "").trim();
+ try {
+ return Double.parseDouble(value);
+ } catch (NumberFormatException e) {
+ return Double.NaN;
+ }
+ }
+
+ public double lookupDoubleConstant(String name) {
+ String value = lookupString(name).replace(CONSTANT, "").trim();
+ try {
+ return Double.parseDouble(value);
+ } catch (NumberFormatException e) {
+ return Double.NaN;
+ }
+ }
+
+ public DimensionedScalar lookupScalar(String name) {
+ DefaultElement el = getElement(name);
+ if (el != null && el instanceof DimensionedScalar) {
+ return (DimensionedScalar) el;
+ } else if (el != null)
+ throw new DictionaryException(name + " not a dimensioned scalar");
+ else
+ return null;
+ }
+
+ public static String[] toArray(String value) {
+ if (value.startsWith("(") && value.endsWith(")")) {
+ value = value.replace("(", "").replace(")", "").trim();
+ // value = value.substring(1, value.length()-1);
+ if (value.isEmpty()) {
+ return new String[0];
+ }
+ String[] values = value.split(SPACER);
+ // System.out.println("Dictionary.lookupArray() "+Arrays.toString(values));
+ return values;
+ } else
+ throw new DictionaryException("'" + value + "' not an array");
+ }
+
+ public String[] lookupArray(String name) {
+ DefaultElement el = getElement(name);
+ if (el != null && el instanceof FieldElement) {
+ String value = ((FieldElement) el).getValue();
+ if (value.startsWith(UNIFORM)) {
+ value = value.replace(UNIFORM, "").trim();
+ }
+ if (value.startsWith(NONUNIFORM)) {
+ return new String[] { "Infinity", "Infinity", "Infinity" };
+ }
+
+ return toArray(value);
+
+ } else if (el != null) {
+ throw new DictionaryException(name + " not a field [ " + el.getClass() + "]");
+ } else {
+ return null;
+ }
+ }
+
+ public String[][] lookupMatrix(String name) {
+ DefaultElement el = getElement(name);
+ if (el != null && el instanceof FieldElement) {
+ String value = ((FieldElement) el).getValue();
+ if (value.startsWith(UNIFORM)) {
+ value = value.replace(UNIFORM, "").trim();
+ }
+ if (value.startsWith("(") && value.endsWith(")")) {
+ value = value.replaceAll("\\(\\s*\\(", "");
+ value = value.replaceAll("\\)\\s*\\)", "");
+
+ // is empty matrix
+ if (value.trim().matches("\\(\\s*\\)")) {
+ return new String[0][0];
+ }
+
+ String[] values = value.split("\\)\\s*\\(");
+ String[][] matrix = new String[values.length][];
+ for (int r = 0; r < values.length; r++) {
+ String[] row = values[r].trim().split("\\s+");
+ matrix[r] = row;
+ }
+ return matrix;
+ } else
+ throw new DictionaryException(name + " not an array");
+ } else if (el != null)
+ throw new DictionaryException(name + " not a field");
+ else
+ return null;
+ }
+
+ public String[] lookupArray2(String name) {
+ DefaultElement el = getElement(name);
+ if (el != null && el instanceof ListField2) {
+ ListField2 list = (ListField2) el;
+ return listToArray(list);
+ } else if (el != null)
+ throw new DictionaryException(name + " not a field");
+ else
+ return null;
+ }
+
+ private String[] listToArray(ListField2 list) {
+ List elements = list.getListElements();
+
+ String[] values = new String[elements.size()];
+
+ for (int i = 0; i < elements.size(); i++) {
+ DefaultElement element = elements.get(i);
+ if (element instanceof FieldElement) {
+ String value = ((FieldElement) element).getValue();
+ values[i] = value;
+ } else if (element instanceof ListField2) {
+ String[] listField = listToArray((ListField2) element);
+ values[i] = "(";
+ for (int j = 0; j < listField.length; j++) {
+ values[i] += listField[j] + " ";
+ }
+ values[i] += ")";
+ }
+ }
+ return values;
+ }
+
+ public String[][] lookupMatrix2(String name) {
+ DefaultElement el = getElement(name);
+ if (el != null && el instanceof ListField2) {
+ ListField2 list = (ListField2) el;
+ return listToMatrix(list);
+ } else if (el != null) {
+ throw new DictionaryException(name + " not a field");
+ } else {
+ return null;
+ }
+ }
+
+ private String[][] listToMatrix(ListField2 list) {
+ List rows = list.getListElements();
+ if (rows.size() > 0 && rows.get(0) instanceof ListField2) {
+ ListField2 firstRow = (ListField2) rows.get(0);
+ String[][] values = new String[rows.size()][firstRow.getListElements().size()];
+
+ for (int i = 0; i < rows.size(); i++) {
+ if (rows.get(i) instanceof ListField2) {
+ ListField2 row = (ListField2) rows.get(i);
+ values[i] = listToArray(row);
+ }
+ }
+ return values;
+ } else {
+ return new String[0][0];
+ }
+ }
+
+ public static double[] toDouble(String[] array) {
+ double[] doubleArray = new double[array.length];
+ for (int i = 0; i < doubleArray.length; i++) {
+ try {
+ doubleArray[i] = Double.valueOf(array[i]);
+ } catch (NumberFormatException e) {
+ }
+ }
+ return doubleArray;
+ }
+
+ public double[] lookupDoubleArray(String key) {
+ String[] array = lookupArray(key);
+ double[] doubleArray = new double[array.length];
+ for (int i = 0; i < doubleArray.length; i++) {
+ try {
+ doubleArray[i] = Double.valueOf(array[i]);
+ } catch (NumberFormatException e) {
+ }
+ }
+ return doubleArray;
+ }
+
+ public double[] lookupDoubleArray(Finder finder) {
+ String key = findKey(finder);
+ if (key != null) {
+ String[] array = lookupArray(key);
+ double[] doubleArray = new double[array.length];
+ for (int i = 0; i < doubleArray.length; i++) {
+ try {
+ doubleArray[i] = Double.valueOf(array[i]);
+ } catch (NumberFormatException e) {
+ }
+ }
+ return doubleArray;
+ } else {
+ throw new DictionaryException(key + " not a field");
+ }
+ }
+
+ public double[] lookupDoubleArray2(String name) {
+ String[] array = lookupArray2(name);
+ double[] doubleArray = new double[array.length];
+ for (int i = 0; i < doubleArray.length; i++) {
+ try {
+ doubleArray[i] = Double.valueOf(array[i]);
+ } catch (NumberFormatException e) {
+ }
+ }
+ return doubleArray;
+ }
+
+ public double[][] lookupDoubleMatrix(String name) {
+ String[][] matrix = lookupMatrix(name);
+ double[][] doubleMatrix = new double[matrix.length][matrix.length == 0 ? 0 : matrix[0].length];
+ for (int i = 0; i < doubleMatrix.length; i++) {
+ for (int j = 0; j < doubleMatrix[i].length; j++) {
+ try {
+ doubleMatrix[i][j] = Double.valueOf(matrix[i][j]);
+ } catch (NumberFormatException e) {
+ }
+ }
+ }
+ return doubleMatrix;
+ }
+
+ public List lookupPointList(String name) {
+ double[][] matrix = lookupDoubleMatrix(name);
+ List doubleMatrixList = new LinkedList<>();
+ for (double[] ds : matrix) {
+ if (ds.length == 3) {
+ doubleMatrixList.add(new Point3d(ds[0], ds[1], ds[2]));
+ } else {
+ doubleMatrixList.add(new Point3d());
+ }
+ }
+ return doubleMatrixList;
+ }
+
+ public double[][] lookupDoubleMatrix2(String name) {
+ String[][] matrix = lookupMatrix2(name);
+ double[][] doubleMatrix = new double[matrix.length][matrix[0].length];
+ for (int i = 0; i < doubleMatrix.length; i++) {
+ for (int j = 0; j < doubleMatrix[i].length; j++) {
+ try {
+ doubleMatrix[i][j] = Double.valueOf(matrix[i][j]);
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ return doubleMatrix;
+ }
+
+ public int[] lookupIntArray(String name) {
+ String[] array = lookupArray(name);
+ int[] intArray = new int[array.length];
+ for (int i = 0; i < intArray.length; i++) {
+ try {
+ intArray[i] = Integer.valueOf(array[i]);
+ } catch (NumberFormatException e) {
+ }
+ }
+ return intArray;
+ }
+
+ public Dictionary removeDict(String name) {
+ keys.remove(name);
+ return (Dictionary) elements.remove(name);
+ }
+
+ public DefaultElement remove(String name) {
+ keys.remove(name);
+ return elements.remove(name);
+ }
+
+ public DefaultElement remove(Finder finder) {
+ String key = findKey(finder);
+ return remove(key);
+ }
+
+ List getGenericKeys() {
+ return genericKeys;
+ }
+
+ public List getKeys() {
+ return keys;
+ }
+
+ List getIncludeFiles() {
+ return includeFiles;
+ }
+
+ public boolean isEmpty() {
+ return keys.isEmpty();
+ }
+
+ @Override
+ public String toString() {
+ return new DictionaryWriter(this).write();
+ }
+
+ public List getDictionaries() {
+ List list = new ArrayList();
+ for (String key : keys) {
+ DefaultElement el = elements.get(key);
+ if (el instanceof Dictionary) {
+ list.add((Dictionary) el);
+ }
+ }
+ return list;
+ }
+
+ public Map getDictionariesMap() {
+ Map map = new LinkedHashMap();
+ for (String key : keys) {
+ DefaultElement el = elements.get(key);
+ if (el instanceof Dictionary) {
+ map.put(el.getName(), (Dictionary) el);
+ }
+ }
+ return map;
+ }
+
+ public List getFields() {
+ List list = new ArrayList();
+ for (DefaultElement el : elements.values()) {
+ if (el instanceof FieldElement) {
+ list.add((FieldElement) el);
+ }
+ }
+ return list;
+ }
+
+ public List getListFields() {
+ List list = new ArrayList<>();
+ for (DefaultElement el : elements.values()) {
+ if (el instanceof ListField) {
+ list.add((ListField) el);
+ }
+ }
+ return list;
+ }
+
+ public boolean hasOnlyList() {
+ return !getListFields().isEmpty() && getDictionaries().isEmpty() && getFieldsMap().isEmpty();
+ }
+
+ public boolean hasOnlyList2() {
+ return !getListFields2().isEmpty() && getDictionaries().isEmpty() && getFieldsMap().isEmpty();
+ }
+
+ public List getListFields2() {
+ List list = new ArrayList<>();
+ for (DefaultElement el : elements.values()) {
+ if (el instanceof ListField2) {
+ list.add((ListField2) el);
+ }
+ }
+ return list;
+ }
+
+ public Map getFieldsMap() {
+ Map map = new LinkedHashMap();
+ for (DefaultElement el : elements.values()) {
+ if (el instanceof FieldElement) {
+ FieldElement field = (FieldElement) el;
+ map.put(field.getName(), field.getValue());
+ }
+ }
+ return map;
+ }
+
+ public void merge(Dictionary dict) {
+ merge(dict, new String[0]);
+ }
+
+ public void merge(Dictionary dict, String[] keysToExclude) {
+ if (dict == null)
+ return;
+ // System.out.println("Dictionary.merge(): "+dict);
+ for (String key : dict.getKeys()) {
+ if (ArrayUtils.contains(keysToExclude, key)) {
+ continue;
+ }
+
+ DefaultElement ele = dict.getElement(key);
+ if (ele instanceof Dictionary) {
+ Dictionary d = (Dictionary) ele;
+ if (found(d.getName()) && isDictionary(d.getName())) {
+ subDict(d.getName()).merge(d);
+ } else {
+ add(new Dictionary(d.getName()));
+ subDict(d.getName()).merge(d);
+ }
+ } else if (ele instanceof ListField) {
+ ListField l = (ListField) ele;
+ if (found(l.getName()) && isList(l.getName())) {
+ getList(l.getName()).merge(l);
+ } else {
+ add(new ListField(l.getName()));
+ getList(l.getName()).merge(l);
+ }
+ } else if (ele instanceof ThetaListField2) {
+ ThetaListField2 t = (ThetaListField2) ele;
+ if (found(t.getName()) && isThetaList2(t.getName())) {
+ getThetaList2(t.getName()).merge(t);
+ } else {
+ add(new ThetaListField2(t));
+ }
+ } else if (ele instanceof ListField2) {
+ ListField2 l = (ListField2) ele;
+ if (found(l.getName()) && isList2(l.getName())) {
+ getList2(l.getName()).merge(l);
+ } else {
+ add(new ListField2(l));
+ }
+ } else if (ele instanceof FieldElement) {
+ FieldElement f = (FieldElement) ele;
+ if (f instanceof DimensionedScalar) {
+ add(new DimensionedScalar((DimensionedScalar) f));
+ } else {
+ add(f.getName(), f.getValue());
+ }
+ }
+ }
+ genericKeys.addAll(dict.genericKeys);
+ }
+
+ public void clear() {
+ elements.clear();
+ keys.clear();
+ }
+
+ /* * * * * * * * * * * * *
+ * READ/WRITE STUFF * * * * * * * * * * * *
+ */
+
+ public void readDictionary(File file) {
+ DictionaryReader reader = new DictionaryReader(this);
+ reader.read(file);
+ }
+
+ protected void readDictionary(InputStream input, DictionaryLinkResolver resolver) {
+ DictionaryReader reader = new DictionaryReader(this, resolver);
+ reader.read(input);
+ }
+
+ protected void readDictionary(InputStream input) {
+ DictionaryReader reader = new DictionaryReader(this);
+ reader.read(input);
+ }
+
+ protected void readDictionaryFromString(String text) {
+ DictionaryReader reader = new DictionaryReader(this);
+ reader.read(text);
+ }
+
+ protected String write() {
+ DictionaryWriter writer = new DictionaryWriter(this);
+ return writer.write();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof Dictionary)) {
+ return false;
+ }
+ if (obj == this) {
+ return true;
+ }
+ Dictionary dict = (Dictionary) obj;
+ return new EqualsBuilder().appendSuper(super.equals(obj)).append(elements, dict.elements).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 31).appendSuper(super.hashCode()).append(elements).toHashCode();
+ }
}
diff --git a/src/eu/engys/core/dictionary/DictionaryBuilder.java b/src/eu/engys/core/dictionary/DictionaryBuilder.java
index 1bce27d..b40354f 100644
--- a/src/eu/engys/core/dictionary/DictionaryBuilder.java
+++ b/src/eu/engys/core/dictionary/DictionaryBuilder.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
@@ -45,6 +44,36 @@ public class DictionaryBuilder {
dictionary.add(k, v);
return this;
}
+
+ public DictionaryBuilder field(String k, Double v) {
+ dictionary.add(k, v);
+ return this;
+ }
+
+ public DictionaryBuilder field(String k, Integer v) {
+ dictionary.add(k, v);
+ return this;
+ }
+
+ public DictionaryBuilder fieldUniform(String k, Double v) {
+ dictionary.addUniform(k, v);
+ return this;
+ }
+
+ public DictionaryBuilder field(String k, boolean v) {
+ dictionary.add(k, v);
+ return this;
+ }
+
+ public DictionaryBuilder field(String k, double[] d) {
+ dictionary.add(k, d);
+ return this;
+ }
+
+ public DictionaryBuilder fieldUniform(String k, double[] d) {
+ dictionary.addUniform(k, d);
+ return this;
+ }
public DictionaryBuilder dimensionedScalar(String k, String v, String d) {
dictionary.add(new DimensionedScalar(k, v, d));
diff --git a/src/eu/engys/core/dictionary/DictionaryException.java b/src/eu/engys/core/dictionary/DictionaryException.java
index 51119be..63296a2 100644
--- a/src/eu/engys/core/dictionary/DictionaryException.java
+++ b/src/eu/engys/core/dictionary/DictionaryException.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
diff --git a/src/eu/engys/core/dictionary/DictionaryLinkResolver.java b/src/eu/engys/core/dictionary/DictionaryLinkResolver.java
index 98f3411..5a329d5 100644
--- a/src/eu/engys/core/dictionary/DictionaryLinkResolver.java
+++ b/src/eu/engys/core/dictionary/DictionaryLinkResolver.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
diff --git a/src/eu/engys/core/dictionary/DictionaryReader.java b/src/eu/engys/core/dictionary/DictionaryReader.java
index 34fdc18..84f5688 100644
--- a/src/eu/engys/core/dictionary/DictionaryReader.java
+++ b/src/eu/engys/core/dictionary/DictionaryReader.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
diff --git a/src/eu/engys/core/dictionary/DictionaryUtils.java b/src/eu/engys/core/dictionary/DictionaryUtils.java
index 1493183..e1515c0 100644
--- a/src/eu/engys/core/dictionary/DictionaryUtils.java
+++ b/src/eu/engys/core/dictionary/DictionaryUtils.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
diff --git a/src/eu/engys/core/dictionary/DictionaryWriter.java b/src/eu/engys/core/dictionary/DictionaryWriter.java
index 6eefff9..ff4f240 100644
--- a/src/eu/engys/core/dictionary/DictionaryWriter.java
+++ b/src/eu/engys/core/dictionary/DictionaryWriter.java
@@ -1,36 +1,45 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
import static eu.engys.core.dictionary.Dictionary.SPACER;
import static eu.engys.core.dictionary.Dictionary.TAB;
import static eu.engys.core.dictionary.Dictionary.VERBOSE;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import eu.engys.core.dictionary.parser.ListField2;
public class DictionaryWriter {
+
+ private static final Logger logger = LoggerFactory.getLogger(DictionaryWriter.class);
+
+ private static final String SCALAR_TAG = "";
+ private static final String VECTOR_TAG = "";
+ private static final String LIST = "List";
protected Dictionary dictionary;
@@ -87,7 +96,7 @@ public class DictionaryWriter {
if (ele != null) {
writeElement(sb, rowHeader, ele);
} else {
- System.out.println("DictionaryWriter.writeDictionary() ------------------------------>> " + key + " is NUUULLLLL in " + dictionary.getKeys() + " and " + dictionary.getDictionaries());
+ logger.error("Dictionary \"{}\" does not contain key {}. Keys are {}", dictionary.getName(), key, dictionary.getKeys());
}
}
for (String includeFile : dictionary.getIncludeFiles()) {
@@ -99,7 +108,9 @@ public class DictionaryWriter {
}
public static void writeElement(StringBuffer sb, String rowHeader, DefaultElement ele) {
- if (ele instanceof Dictionary) {
+ if (ele == null) {
+ logger.error("A NULL element has not been written in \n{}", sb.toString());
+ } else if (ele instanceof Dictionary) {
DictionaryWriter writer = new DictionaryWriter((Dictionary) ele);
writer.writeDictionary(sb, rowHeader + TAB);
} else if (ele instanceof DimensionedScalar) {
@@ -120,7 +131,7 @@ public class DictionaryWriter {
private static boolean hasParenthesis(DefaultElement ele) {
FieldElement fieldElement = (FieldElement) ele;
String value = fieldElement.getValue();
- return value != null && value.contains("(") && value.contains("List");
+ return value != null && value.contains("(") && value.contains(LIST);
}
protected static void writeField(StringBuffer sb, FieldElement field, String rowHeader) {
@@ -146,9 +157,9 @@ public class DictionaryWriter {
sb.append(SPACER);
String value = field.getValue();
if (value.contains("vector")) {
- sb.append(value.replace("(", "\n(").replace("))", ")\n)").replace("", "\n"));
+ sb.append(value.replace("(", "\n(").replace("))", ")\n)").replace(VECTOR_TAG, VECTOR_TAG+"\n"));
} else {
- sb.append(value.replace("(", "\n(").replace("", "\n").replaceAll("\\s+", "\n"));
+ sb.append(value.replace("(", "\n(").replace(SCALAR_TAG, SCALAR_TAG+"\n").replaceAll("\\s+", "\n"));
}
sb.append(";");
}
@@ -167,16 +178,18 @@ public class DictionaryWriter {
private static void writeDimensionedScalar(StringBuffer sb, DimensionedScalar ds, String rowHeader) {
if (VERBOSE)
System.out.println("Dictionary.writeDimensionedScalar() " + (ds != null ? ds.getName() : "NULL!!!"));
- sb.append("\n");
- sb.append(rowHeader);
- sb.append(TAB);
- sb.append(ds.getName());
- sb.append(SPACER);
- sb.append(ds.getName());
- sb.append(SPACER);
- sb.append(ds.getDimensions());
- sb.append(SPACER);
- sb.append(ds.getValue());
- sb.append(";");
+ if (ds != null) {
+ sb.append("\n");
+ sb.append(rowHeader);
+ sb.append(TAB);
+ sb.append(ds.getName());
+ sb.append(SPACER);
+ sb.append(ds.getName());
+ sb.append(SPACER);
+ sb.append(ds.getDimensions());
+ sb.append(SPACER);
+ sb.append(ds.getValue());
+ sb.append(";");
+ }
}
}
diff --git a/src/eu/engys/core/dictionary/DimensionedScalar.java b/src/eu/engys/core/dictionary/DimensionedScalar.java
index 9d43777..ae60241 100644
--- a/src/eu/engys/core/dictionary/DimensionedScalar.java
+++ b/src/eu/engys/core/dictionary/DimensionedScalar.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
diff --git a/src/eu/engys/core/dictionary/FieldChangeListener.java b/src/eu/engys/core/dictionary/FieldChangeListener.java
deleted file mode 100644
index f95afad..0000000
--- a/src/eu/engys/core/dictionary/FieldChangeListener.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
-package eu.engys.core.dictionary;
-
-import java.awt.event.ActionListener;
-
-public interface FieldChangeListener extends ActionListener {
-
- public void fieldChanged();
- public boolean isAdjusting();
- public void setAdjusting(boolean b);
-}
diff --git a/src/eu/engys/core/dictionary/FieldElement.java b/src/eu/engys/core/dictionary/FieldElement.java
index dcc3763..f3772fe 100644
--- a/src/eu/engys/core/dictionary/FieldElement.java
+++ b/src/eu/engys/core/dictionary/FieldElement.java
@@ -1,62 +1,79 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
public class FieldElement extends DefaultElement {
private String value;
-
+
public FieldElement(String name, String value) {
super(name);
this.value = value;
}
public FieldElement(FieldElement el) {
- this(el.getName(), el.getValue());
- }
+ this(el.getName(), el.getValue());
+ }
- public void setValue(String value) {
+ public void setValue(String value) {
this.value = value;
}
public String getValue() {
return value;
}
-
+
@Override
public String toString() {
return getName() + "[" + value + "]";
}
-
+
@Override
public boolean equals(Object obj) {
- if (obj instanceof FieldElement) {
- return ((FieldElement) obj).getName().equals(getName()) && ((FieldElement) obj).value.equals(value) ;
- }
- return false;
+ if (!(obj instanceof FieldElement)) {
+ return false;
+ }
+ if (obj == this) {
+ return true;
+ }
+ FieldElement fe = (FieldElement) obj;
+ return new EqualsBuilder()
+ .appendSuper(super.equals(obj))
+ .append(value, fe.value)
+ .isEquals();
}
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 31)
+ .appendSuper(super.hashCode())
+ .append(value)
+ .toHashCode();
+ }
+
}
diff --git a/src/eu/engys/core/dictionary/FieldListener.java b/src/eu/engys/core/dictionary/FieldListener.java
index 072aa20..e38686f 100644
--- a/src/eu/engys/core/dictionary/FieldListener.java
+++ b/src/eu/engys/core/dictionary/FieldListener.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
diff --git a/src/eu/engys/core/dictionary/Finder.java b/src/eu/engys/core/dictionary/Finder.java
index 6f5547b..57e2607 100644
--- a/src/eu/engys/core/dictionary/Finder.java
+++ b/src/eu/engys/core/dictionary/Finder.java
@@ -1,32 +1,31 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
public interface Finder {
boolean accept(String key);
-}
+}
\ No newline at end of file
diff --git a/src/eu/engys/core/dictionary/FoamFile.java b/src/eu/engys/core/dictionary/FoamFile.java
index fcf8f70..b0fc6ca 100644
--- a/src/eu/engys/core/dictionary/FoamFile.java
+++ b/src/eu/engys/core/dictionary/FoamFile.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
diff --git a/src/eu/engys/core/dictionary/ListField.java b/src/eu/engys/core/dictionary/ListField.java
index 7ce63b9..3390883 100644
--- a/src/eu/engys/core/dictionary/ListField.java
+++ b/src/eu/engys/core/dictionary/ListField.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
@@ -185,4 +184,14 @@ public class ListField extends DefaultElement {
return null;
}
+ public List getDictionaries() {
+ List dicts = new ArrayList<>();
+ for (DefaultElement e : list) {
+ if (e instanceof Dictionary) {
+ dicts.add((Dictionary) e);
+ }
+ }
+ return dicts;
+ }
+
}
diff --git a/src/eu/engys/core/dictionary/ListReader.java b/src/eu/engys/core/dictionary/ListReader.java
index f83cdfd..7dc2e1e 100644
--- a/src/eu/engys/core/dictionary/ListReader.java
+++ b/src/eu/engys/core/dictionary/ListReader.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
diff --git a/src/eu/engys/core/dictionary/MatrixReader.java b/src/eu/engys/core/dictionary/MatrixReader.java
index 1282a35..f832834 100644
--- a/src/eu/engys/core/dictionary/MatrixReader.java
+++ b/src/eu/engys/core/dictionary/MatrixReader.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
diff --git a/src/eu/engys/core/dictionary/StartWithFinder.java b/src/eu/engys/core/dictionary/StartWithFinder.java
index 861483a..fb67876 100644
--- a/src/eu/engys/core/dictionary/StartWithFinder.java
+++ b/src/eu/engys/core/dictionary/StartWithFinder.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
public class StartWithFinder implements Finder {
@@ -37,4 +36,4 @@ public class StartWithFinder implements Finder {
public boolean accept(String key) {
return key.startsWith(keyToFind);
}
-}
+}
\ No newline at end of file
diff --git a/src/eu/engys/core/dictionary/TableRowElement.java b/src/eu/engys/core/dictionary/TableRowElement.java
index 6eee171..eb1ee9e 100644
--- a/src/eu/engys/core/dictionary/TableRowElement.java
+++ b/src/eu/engys/core/dictionary/TableRowElement.java
@@ -1,32 +1,35 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary;
import static eu.engys.core.dictionary.Dictionary.SPACER;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
import eu.engys.core.dictionary.parser.ListField2;
public class TableRowElement extends DefaultElement {
@@ -73,28 +76,30 @@ public class TableRowElement extends DefaultElement {
return values;
}
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof TableRowElement) {
- TableRowElement t = ((TableRowElement) obj);
- return key.equals(t.key) /*&& valuesAreEquals(t.values)*/;
- }
- return super.equals(obj);
- }
-
- private boolean valuesAreEquals(FieldElement[] values) {
- if (this.values.length != values.length) {
- return false;
- }
- for (int i = 0; i < values.length; i++) {
- if (!this.values[i].equals(values[i])) {
- return false;
- }
- }
- return true;
- }
-
public void merge(TableRowElement el) {
this.values = el.values;
}
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof TableRowElement)) {
+ return false;
+ }
+ if (obj == this) {
+ return true;
+ }
+ TableRowElement el = (TableRowElement) obj;
+ return new EqualsBuilder()
+ .appendSuper(super.equals(obj))
+ .append(key, el.key)
+ .isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 31)
+ .appendSuper(super.hashCode())
+ .append(key)
+ .toHashCode();
+ }
}
diff --git a/src/eu/engys/core/dictionary/model/AbstractTableAdapter.java b/src/eu/engys/core/dictionary/model/AbstractTableAdapter.java
index d8ea2e8..0db466e 100644
--- a/src/eu/engys/core/dictionary/model/AbstractTableAdapter.java
+++ b/src/eu/engys/core/dictionary/model/AbstractTableAdapter.java
@@ -1,31 +1,33 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.model;
+import static eu.engys.util.ui.UiUtil.ADD_ROW_BUTTON_NAME;
+import static eu.engys.util.ui.UiUtil.REM_ROW_BUTTON_NAME;
+
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
@@ -87,11 +89,11 @@ public abstract class AbstractTableAdapter extends JPanel {
buttonsPanel.setOpaque(false);
JButton addButton = new JButton(new AddRowAction());
- addButton.setName("add.row.button");
+ addButton.setName(ADD_ROW_BUTTON_NAME);
buttonsPanel.add(addButton);
JButton remButton = new JButton(new RemRowAction());
- remButton.setName("rem.row.button");
+ remButton.setName(REM_ROW_BUTTON_NAME);
buttonsPanel.add(remButton);
return buttonsPanel;
}
diff --git a/src/eu/engys/core/dictionary/model/AxisInfo.java b/src/eu/engys/core/dictionary/model/AxisInfo.java
index 70da1e8..690ff00 100644
--- a/src/eu/engys/core/dictionary/model/AxisInfo.java
+++ b/src/eu/engys/core/dictionary/model/AxisInfo.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.model;
import eu.engys.util.ui.textfields.DoubleField;
@@ -33,24 +32,54 @@ public class AxisInfo {
public static final String LABEL = "Point ";
private DoubleField[] center;
private EventActionType action;
- private DoubleField[] axis;
+ private double magnitude;
+ private DoubleField toe;
+ private DoubleField camber;
+ private DoubleField[] axis;
+ private int sign;
- public AxisInfo(DoubleField[] axis, DoubleField[] center, EventActionType action) {
- this.axis = axis;
- this.center = center;
+ public AxisInfo(DoubleField toe, DoubleField camber, DoubleField[] center, double magnitude, int sign, EventActionType action) {
+ this.toe = toe;
+ this.camber = camber;
+ this.center = center;
+ this.sign = sign;
this.action = action;
+ this.magnitude = magnitude;
}
- public DoubleField[] getAxis() {
- return axis;
+ public AxisInfo(DoubleField[] axis, DoubleField[] center, int magnitude, EventActionType action) {
+ this.axis = axis;
+ this.center = center;
+ this.magnitude = magnitude;
+ this.action = action;
+ }
+
+ public DoubleField getToe() {
+ return toe;
}
+
+ public DoubleField getCamber() {
+ return camber;
+ }
+
+ public int getSign() {
+ return sign;
+ }
public DoubleField[] getCenter() {
return center;
}
+ public DoubleField[] getAxis() {
+ return axis;
+ }
+
public EventActionType getAction() {
return action;
}
-}
+ public double getMagnitude() {
+ return magnitude;
+ }
+
+}
\ No newline at end of file
diff --git a/src/eu/engys/core/dictionary/model/DictionaryModel.java b/src/eu/engys/core/dictionary/model/DictionaryModel.java
index dc35441..b70553d 100644
--- a/src/eu/engys/core/dictionary/model/DictionaryModel.java
+++ b/src/eu/engys/core/dictionary/model/DictionaryModel.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.model;
import static eu.engys.util.ui.ComponentsFactory.checkBoxControllerField;
@@ -39,6 +38,7 @@ import static eu.engys.util.ui.ComponentsFactory.selectField;
import static eu.engys.util.ui.ComponentsFactory.spinnerField;
import static eu.engys.util.ui.ComponentsFactory.stringField;
+import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -54,7 +54,9 @@ import java.util.concurrent.CopyOnWriteArrayList;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
+import javax.swing.JComponent;
import javax.swing.JPanel;
+import javax.swing.ListModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,10 +64,10 @@ import org.slf4j.LoggerFactory;
import eu.engys.core.dictionary.Dictionary;
import eu.engys.core.dictionary.DictionaryUtils;
import eu.engys.core.dictionary.DimensionedScalar;
-import eu.engys.core.dictionary.FieldChangeListener;
import eu.engys.core.project.zero.patches.Patches;
import eu.engys.util.filechooser.util.SelectionMode;
import eu.engys.util.ui.ComponentsFactory;
+import eu.engys.util.ui.FieldChangeListener;
import eu.engys.util.ui.FileFieldPanel;
import eu.engys.util.ui.ListBuilder;
import eu.engys.util.ui.ListFieldPanel;
@@ -91,8 +93,8 @@ public class DictionaryModel {
public void dictionaryChanged() throws DictionaryError;
}
- private List listeners = new CopyOnWriteArrayList();
- private Map subModels = new HashMap();
+ private List listeners = new CopyOnWriteArrayList<>();
+ private Map subModels = new HashMap<>();
public static class DictionaryError extends Exception {
private String[] messages;
@@ -222,26 +224,34 @@ public class DictionaryModel {
}
public JCheckBox bindBoolean(String key) {
- JCheckBox field = checkField();
- field.addActionListener(new BooleanFieldHandler(key, field, false));
- return field;
+ return bindBoolean(key, false);
}
public JCheckBox bindBoolean(String key, boolean def) {
- JCheckBox field = checkField(def);
- field.addActionListener(new BooleanFieldHandler(key, field, def));
- return field;
+ return bindBoolean(key, def, true);
+ }
+
+ public JCheckBox bindBoolean(String key, boolean def, boolean fireEvent) {
+ JCheckBox field = checkField(def);
+ field.addActionListener(new BooleanFieldHandler(key, field, def, fireEvent));
+ return field;
}
public JCheckBox bindBoolean(String key, String trueValue, String falseValue) {
JCheckBox field = checkField();
- field.addActionListener(new BooleanValuesFieldHandler(key, field, trueValue, falseValue));
+ field.addActionListener(new BooleanValuesFieldHandler(key, field, trueValue, falseValue, false));
return field;
}
public JCheckBox bindBoolean(String key, String trueValue, String falseValue, boolean def) {
JCheckBox field = checkField(def);
- field.addActionListener(new BooleanValuesFieldHandler(key, field, trueValue, falseValue));
+ field.addActionListener(new BooleanValuesFieldHandler(key, field, trueValue, falseValue, false));
+ return field;
+ }
+
+ public JCheckBox bindBoolean(String key, String trueValue, String falseValue, boolean def, boolean lightEvent) {
+ JCheckBox field = checkField(def);
+ field.addActionListener(new BooleanValuesFieldHandler(key, field, trueValue, falseValue, lightEvent));
return field;
}
@@ -291,7 +301,6 @@ public class DictionaryModel {
// public IntegerField bindInteger(String key, String name) {
// IntegerField field = bindInteger(key);
- // field.setName(name);
// return field;
// }
@@ -334,7 +343,6 @@ public class DictionaryModel {
// public DoubleField bindUniformDoubleWithName(String key, String name) {
// DoubleField field = doubleField();
- // field.setName(name);
// field.addPropertyChangeListener(new DoubleUniformFieldHandler(key,
// field));
// return field;
@@ -377,6 +385,13 @@ public class DictionaryModel {
return field;
}
+ public DoubleField bindDoubleAndUniformDouble(String key1, String key2) {
+ DoubleField field = doubleField();
+ field.addPropertyChangeListener(new DoubleFieldHandler(key1, field, null));
+ field.addPropertyChangeListener(new DoubleUniformFieldHandler(key2, field));
+ return field;
+ }
+
public DoubleField bindDouble(String key) {
return bindDouble(key, (FieldChangeListener) null);
}
@@ -393,6 +408,42 @@ public class DictionaryModel {
return field;
}
+ public JComponent bindCheckAndDouble(final String key, Double def) {
+ final JCheckBox checkBox = checkField();
+ final DoubleField field = doubleField(def);
+ field.addPropertyChangeListener(new DoubleFieldHandler(key, field, null));
+ field.setEnabled(false);
+ checkBox.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (checkBox.isSelected()) {
+ field.setEnabled(true);
+ } else {
+ field.setValue(null);
+ field.setEnabled(false);
+ }
+ }
+ });
+ DictionaryModel.this.addDictionaryListener(new DictionaryListener() {
+ @Override
+ public void dictionaryChanged() throws DictionaryError {
+ checkBox.setSelected(dictionary.found(key));
+ field.setEnabled(checkBox.isSelected());
+ }
+ });
+ JPanel panel = new JPanel(new BorderLayout()) {
+ @Override
+ public void setName(String name) {
+ super.setName(name);
+ checkBox.setName(name);
+ field.setName(name);
+ }
+ };
+ panel.add(checkBox, BorderLayout.WEST);
+ panel.add(field, BorderLayout.CENTER);
+ return panel;
+ }
+
public DoubleField bindDouble(String key, Double def) {
DoubleField field = doubleField(def);
field.addPropertyChangeListener(new DoubleFieldHandler(key, field, null));
@@ -435,7 +486,6 @@ public class DictionaryModel {
DoubleField[] field = doublePointField();
for (int i = 0; i < field.length; i++) {
DoubleField f = field[i];
- f.setName(key + "." + i);
f.addPropertyChangeListener(new PointFieldHandler(key, field, listener));
}
return field;
@@ -445,12 +495,21 @@ public class DictionaryModel {
DoubleField[] field = doublePointField(places);
for (int i = 0; i < field.length; i++) {
DoubleField f = field[i];
- f.setName(key + "." + i);
f.addPropertyChangeListener(new PointFieldHandler(key, field, listener));
}
return field;
}
+ public DoubleField[] bindPointAndUniformPoint(String key1, String key2) {
+ DoubleField[] field = doublePointField();
+ for (int i = 0; i < field.length; i++) {
+ DoubleField f = field[i];
+ f.addPropertyChangeListener(new PointFieldHandler(key1, field, null));
+ f.addPropertyChangeListener(new PointUniformFieldHandler(key2, field));
+ }
+ return field;
+ }
+
public DoubleField[] bindPoint(String key) {
return bindPoint(key, null);
}
@@ -479,16 +538,6 @@ public class DictionaryModel {
return field;
}
- // public DoubleField[] bindUniformPointWithName(String key, String name) {
- // DoubleField[] field = doublePointField();
- // for (int i = 0; i < field.length; i++) {
- // DoubleField f = field[i];
- // f.setName(name + "." + i);
- // f.addPropertyChangeListener(new PointUniformFieldHandler(key, field));
- // }
- // return field;
- // }
-
public DoubleField[] bindUniformPoint(String key1, String key2) {
DoubleField[] field = doublePointField();
for (int i = 0; i < field.length; i++) {
@@ -513,7 +562,6 @@ public class DictionaryModel {
for (int i = 0; i < field.length; i++) {
DoubleField f = field[i];
f.setColumns(1);
- f.setName(key + "." + i);
f.addPropertyChangeListener(new PointFieldHandler(key, field, null));
}
return field;
@@ -543,6 +591,12 @@ public class DictionaryModel {
return combo;
}
+ public JComboBox bindSelection(String key, ListModel listModel) {
+ JComboBox combo = selectField(listModel);
+ combo.addActionListener(new SelectFieldHandler(key, combo, null));
+ return combo;
+ }
+
public JComboBox bindSelection(String key, String... keys) {
JComboBox combo = selectField(keys, keys);
combo.addActionListener(new SelectFieldHandler(key, combo, null));
@@ -567,7 +621,7 @@ public class DictionaryModel {
public JCheckBoxController bindCheckBoxController(String key, String name) {
JCheckBoxController combo = checkBoxControllerField(name);
- combo.addActionListener(new BooleanFieldHandler(key, combo, false));
+ combo.addActionListener(new BooleanFieldHandler(key, combo, false, true));
return combo;
}
@@ -647,7 +701,7 @@ public class DictionaryModel {
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("value")) {
StringBuilder sb = new StringBuilder();
- sb.append("(");
+ sb.append("( ");
for (int i = 0; i < field.length; i++) {
sb.append(field[i].getDoubleValue());
sb.append(" ");
@@ -767,19 +821,15 @@ public class DictionaryModel {
class SpinnerFieldHandler implements PropertyChangeListener, DictionaryListener {
public SpinnerFieldHandler(String key, SpinnerField field) {
- // TODO Auto-generated constructor stub
}
@Override
public void dictionaryChanged() throws DictionaryError {
- // TODO Auto-generated method stub
}
@Override
public void propertyChange(PropertyChangeEvent evt) {
- // TODO Auto-generated method stub
-
}
}
@@ -899,7 +949,7 @@ public class DictionaryModel {
dictionary.add(key, sb.toString());
logger.trace("PointFieldHandler -> value: {}", dictionary.lookup(key));
if (listener != null) {
- listener.fieldChanged();
+ listener.fieldChanged(evt.getSource());
}
}
}
@@ -949,7 +999,7 @@ public class DictionaryModel {
dictionary.add(key, Double.toString(field.getDoubleValue()));
logger.trace("DoubleFieldHandler -> value: {}", dictionary.lookup(key));
if (listener != null) {
- listener.fieldChanged();
+ listener.fieldChanged(evt.getSource());
}
}
}
@@ -986,7 +1036,7 @@ public class DictionaryModel {
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("value")) {
if (!Double.isInfinite(field.getDoubleValue())) {
- dictionary.add(key, "uniform " + Double.toString(field.getDoubleValue()));
+ dictionary.addUniform(key, field.getDoubleValue());
logger.trace("DoubleUniformFieldHandler -> value: {}", dictionary.lookup(key));
}
}
@@ -1022,7 +1072,7 @@ public class DictionaryModel {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("value")) {
- dictionary.add(key, "uniform " + Double.toString(-Math.abs(field.getDoubleValue())));
+ dictionary.addUniform(key, -Math.abs(field.getDoubleValue()));
logger.trace("DoubleUniformFieldHandler -> " + dictionary.toString());
}
}
@@ -1053,7 +1103,7 @@ public class DictionaryModel {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("value")) {
- dictionary.add(key, "uniform " + Double.toString(Math.abs(field.getDoubleValue())));
+ dictionary.addUniform(key, Math.abs(field.getDoubleValue()));
logger.trace("DoubleUniformFieldHandler -> " + dictionary.toString());
}
}
@@ -1084,7 +1134,7 @@ public class DictionaryModel {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("value")) {
- dictionary.add(key, "constant " + Double.toString(field.getDoubleValue()));
+ dictionary.addConstant(key, field.getDoubleValue());
logger.trace("DoubleUniformFieldHandler -> value: {}", dictionary.lookup(key));
}
}
@@ -1107,11 +1157,13 @@ public class DictionaryModel {
private JCheckBox check;
private String key;
private final boolean def;
+ private boolean fireEvent;
- public BooleanFieldHandler(String key, JCheckBox check, boolean def) {
+ public BooleanFieldHandler(String key, JCheckBox check, boolean def, boolean fireEvent) {
this.check = check;
this.key = key;
this.def = def;
+ this.fireEvent = fireEvent;
DictionaryModel.this.addDictionaryListener(this);
}
@@ -1128,7 +1180,9 @@ public class DictionaryModel {
String correctedForYesNo = value == null ? String.valueOf(def) : value.equals("yes") ? "true" : value.equals("no") ? "false" : value;
boolean b = Boolean.parseBoolean(correctedForYesNo);
if (b != check.isSelected()) {
- check.doClick();
+ if(fireEvent){
+ check.doClick();
+ }
check.setSelected(b);
}
logger.trace("BooleanFieldHandler -> value: {}", value);
@@ -1141,12 +1195,14 @@ public class DictionaryModel {
private String key;
private final String trueValue;
private final String falseValue;
+ private boolean lightEvent;
- public BooleanValuesFieldHandler(String key, JCheckBox check, String trueValue, String falseValue) {
+ public BooleanValuesFieldHandler(String key, JCheckBox check, String trueValue, String falseValue, boolean lightEvent) {
this.check = check;
this.key = key;
this.trueValue = trueValue;
this.falseValue = falseValue;
+ this.lightEvent = lightEvent;
DictionaryModel.this.addDictionaryListener(this);
}
@@ -1162,7 +1218,11 @@ public class DictionaryModel {
String value = dictionary.lookup(key);
boolean selected = value != null && value.equals(trueValue);
if (shouldClick(selected, check.isSelected())) {
- check.doClick();
+ if(lightEvent){
+ check.setSelected(!check.isSelected());
+ } else {
+ check.doClick();
+ }
}
logger.trace("BooleanValuesFieldHandler -> value: {}", value);
}
@@ -1232,11 +1292,10 @@ public class DictionaryModel {
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("value")) {
StringBuilder sb = new StringBuilder();
- sb.append("(");
+ sb.append("( ");
for (int i = 0; i < field.length; i++) {
if (field[i].getValue() != null) {
- sb.append(field[i].getDoubleValue());
- sb.append(" ");
+ sb.append(field[i].getDoubleValue() + " ");
} else {
sb.append("0 ");
}
@@ -1245,7 +1304,7 @@ public class DictionaryModel {
dictionary.add(key, sb.toString());
logger.trace("PointFieldHandler -> value: {}", dictionary.lookup(key));
if (listener != null) {
- listener.fieldChanged();
+ listener.fieldChanged(evt.getSource());
}
}
}
@@ -1292,14 +1351,7 @@ public class DictionaryModel {
return;
}
}
- StringBuilder sb = new StringBuilder();
- sb.append("uniform (");
- for (int i = 0; i < field.length; i++) {
- sb.append(field[i].getDoubleValue());
- sb.append(" ");
- }
- sb.append(")");
- dictionary.add(key, sb.toString());
+ dictionary.addUniform(key, DoubleField.toArray(field));
logger.trace("PointFieldHandler -> value: {}", dictionary.lookup(key));
}
}
diff --git a/src/eu/engys/core/dictionary/model/DictionaryPanelBuilder.java b/src/eu/engys/core/dictionary/model/DictionaryPanelBuilder.java
index eb695b8..26fed16 100644
--- a/src/eu/engys/core/dictionary/model/DictionaryPanelBuilder.java
+++ b/src/eu/engys/core/dictionary/model/DictionaryPanelBuilder.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.model;
import static eu.engys.core.dictionary.Dictionary.TYPE;
@@ -85,9 +84,13 @@ public class DictionaryPanelBuilder extends PanelBuilder {
}
public void selectDictionaries(Dictionary newDictionary, Dictionary newCompanion) {
+ selectDictionaries(newDictionary, newCompanion, TYPE);
+ }
+
+ public void selectDictionaries(Dictionary newDictionary, Dictionary newCompanion, String selector) {
String newName = newDictionary.getName();
- String newType = newDictionary.lookup(TYPE);
- String newCompanionType = newCompanion.lookup(TYPE);
+ String newType = newDictionary.lookup(selector);
+ String newCompanionType = newCompanion.lookup(selector);
// System.out.println("ChoicePanelBuilder.selectDictionary() NEW TYPE: "+newType+" NEW NAME: "+newName+" NEW COMPANION TYPE: "+newCompanionType);
// System.out.println("-------------------");
for (String key : modelsByKey.keySet()) {
@@ -96,8 +99,8 @@ public class DictionaryPanelBuilder extends PanelBuilder {
if (model.getCompanions().size() > 0) {
Dictionary oldCompanion = model.getCompanions().get(0).getDictionary();
String oldName = oldDictionary.getName();
- String oldType = oldDictionary.lookup(TYPE);
- String oldCompanionType = oldCompanion.lookup(TYPE);
+ String oldType = oldDictionary.lookup(selector);
+ String oldCompanionType = oldCompanion.lookup(selector);
// System.out.println("DictionaryPanelBuilder.selectDictionaries() OLD TYPE: "+oldType+" OLD NAME: "+oldName+" OLD COMPANION TYPE: "+oldCompanionType);
if (newName.equals(oldName) && newType.equals(oldType) && newCompanionType.equals(oldCompanionType)) {
@@ -117,9 +120,13 @@ public class DictionaryPanelBuilder extends PanelBuilder {
}
public void selectDictionary(Dictionary newDictionary) {
+ selectDictionary(newDictionary, TYPE);
+ }
+
+ public void selectDictionary(Dictionary newDictionary, String selector) {
if (newDictionary != null /* && newDictionary.found(TYPE) */) {
String newName = newDictionary.getName();
- String newType = newDictionary.lookup(TYPE);
+ String newType = newDictionary.lookup(selector);
// System.out.println("DictionaryPanelBuilder.selectDictionary() NEW TYPE: "+newType+" NEW NAME: "+newName);
if (newName != null && newType != null) {
@@ -128,7 +135,7 @@ public class DictionaryPanelBuilder extends PanelBuilder {
if (model.getCompanions().size() == 0) {
Dictionary oldDictionary = model.getDictionary();
String oldName = oldDictionary.getName();
- String oldType = oldDictionary.lookup(TYPE);
+ String oldType = oldDictionary.lookup(selector);
// System.out.println("DictionaryPanelBuilder.selectDictionary() OLD TYPE: "+oldType+" OLD NAME: "+oldName);
diff --git a/src/eu/engys/core/dictionary/model/DictionaryTableAdapter.java b/src/eu/engys/core/dictionary/model/DictionaryTableAdapter.java
index dfbea5a..feea6b1 100644
--- a/src/eu/engys/core/dictionary/model/DictionaryTableAdapter.java
+++ b/src/eu/engys/core/dictionary/model/DictionaryTableAdapter.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.model;
import eu.engys.core.dictionary.model.DictionaryModel.DictionaryListener;
diff --git a/src/eu/engys/core/dictionary/model/EventActionType.java b/src/eu/engys/core/dictionary/model/EventActionType.java
index 086d797..00f863a 100644
--- a/src/eu/engys/core/dictionary/model/EventActionType.java
+++ b/src/eu/engys/core/dictionary/model/EventActionType.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.model;
public enum EventActionType {
@@ -39,4 +38,4 @@ public enum EventActionType {
public void isRemove() {
this.equals(REMOVE);
}
-}
+}
\ No newline at end of file
diff --git a/src/eu/engys/core/dictionary/model/LevelsTableAdapter.java b/src/eu/engys/core/dictionary/model/LevelsTableAdapter.java
index 4adb732..ab4605a 100644
--- a/src/eu/engys/core/dictionary/model/LevelsTableAdapter.java
+++ b/src/eu/engys/core/dictionary/model/LevelsTableAdapter.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.model;
@@ -123,7 +122,7 @@ public class LevelsTableAdapter extends DictionaryTableAdapter {
for (JComponent[] row : getRowsMap().values()) {
map.put(((IntegerField) row[1]).getIntValue(), ((DoubleField) row[0]).getDoubleValue());
}
- return new TreeMap(map);
+ return new TreeMap<>(map);
}
}
diff --git a/src/eu/engys/core/dictionary/model/LinesTableAdapter.java b/src/eu/engys/core/dictionary/model/LinesTableAdapter.java
index 1dfa915..e2e97a6 100644
--- a/src/eu/engys/core/dictionary/model/LinesTableAdapter.java
+++ b/src/eu/engys/core/dictionary/model/LinesTableAdapter.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.model;
diff --git a/src/eu/engys/core/dictionary/model/OneDictionaryPerRowTableAdapter.java b/src/eu/engys/core/dictionary/model/OneDictionaryPerRowTableAdapter.java
index c049afa..cad1894 100644
--- a/src/eu/engys/core/dictionary/model/OneDictionaryPerRowTableAdapter.java
+++ b/src/eu/engys/core/dictionary/model/OneDictionaryPerRowTableAdapter.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.model;
@@ -42,6 +41,8 @@ import eu.engys.util.ui.textfields.StringField;
public class OneDictionaryPerRowTableAdapter extends DictionaryTableAdapter {
+ public static final String ROW_NAME = "one.dict.row";
+
private final int NAME_COL = 0;
protected final String[] columnNames;
protected final String[] columnKeys;
@@ -71,7 +72,7 @@ public class OneDictionaryPerRowTableAdapter extends DictionaryTableAdapter {
this.dictKey = key;
this.type = type;
- setName("one.dict.row");
+ setName(ROW_NAME);
if (isStaticTable()) {
setRowHeader();
@@ -136,7 +137,7 @@ public class OneDictionaryPerRowTableAdapter extends DictionaryTableAdapter {
for (Dictionary d : dict.getDictionaries()) {
JComponent[] row = new JComponent[columnKeys.length + 1];
if (isStaticTable())
- row[0] = new JLabel(rowKeys[rowIndex]);
+ row[0] = new JLabel(rowNames[rowIndex]);
else
row[0] = new StringField(d.getName());
diff --git a/src/eu/engys/core/dictionary/model/PatchesMapTableAdapter.java b/src/eu/engys/core/dictionary/model/PatchesMapTableAdapter.java
index 0d1eb13..072d0a4 100644
--- a/src/eu/engys/core/dictionary/model/PatchesMapTableAdapter.java
+++ b/src/eu/engys/core/dictionary/model/PatchesMapTableAdapter.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.model;
diff --git a/src/eu/engys/core/dictionary/model/PointInfo.java b/src/eu/engys/core/dictionary/model/PointInfo.java
index 89c0dd8..5ab6c2b 100644
--- a/src/eu/engys/core/dictionary/model/PointInfo.java
+++ b/src/eu/engys/core/dictionary/model/PointInfo.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.model;
import java.awt.Color;
@@ -61,4 +60,4 @@ public class PointInfo {
return color;
}
-}
+}
\ No newline at end of file
diff --git a/src/eu/engys/core/dictionary/model/PointTableAdapter.java b/src/eu/engys/core/dictionary/model/PointTableAdapter.java
index aa8c7e2..327733c 100644
--- a/src/eu/engys/core/dictionary/model/PointTableAdapter.java
+++ b/src/eu/engys/core/dictionary/model/PointTableAdapter.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.model;
diff --git a/src/eu/engys/core/dictionary/model/ShowAxisAdapter.java b/src/eu/engys/core/dictionary/model/ShowAxisAdapter.java
index f556783..81eace7 100644
--- a/src/eu/engys/core/dictionary/model/ShowAxisAdapter.java
+++ b/src/eu/engys/core/dictionary/model/ShowAxisAdapter.java
@@ -1,29 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.model;
import java.awt.BorderLayout;
@@ -33,80 +31,81 @@ import java.beans.PropertyChangeListener;
import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
-import javax.swing.ImageIcon;
+import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
-import net.java.dev.designgridlayout.Componentizer;
+import eu.engys.util.ui.ResourcesUtil;
import eu.engys.util.ui.textfields.DoubleField;
+import net.java.dev.designgridlayout.Componentizer;
public class ShowAxisAdapter extends JPanel {
- private static final ImageIcon ICON_ON = new ImageIcon(AbstractTableAdapter.class.getClassLoader().getResource("eu/engys/resources/images/lightbulb16.png"));
- private static final ImageIcon ICON_OFF = new ImageIcon(AbstractTableAdapter.class.getClassLoader().getResource("eu/engys/resources/images/lightbulb_off16.png"));
+ private static final Icon ICON_ON = ResourcesUtil.getIcon("light.on.icon");
+ private static final Icon ICON_OFF = ResourcesUtil.getIcon("light.off.icon");
- private JToggleButton button;
- private DoubleField[] axis;
- private DoubleField[] centre;
+ private JToggleButton button;
+ private DoubleField[] axis;
+ private DoubleField[] centre;
- public ShowAxisAdapter(DoubleField[] axis, DoubleField[] centre) {
- super(new BorderLayout());
- this.axis = axis;
- this.centre = centre;
- this.button = newShowAxisButton(false);
- JComponent component = Componentizer.create().minAndMore(centre).minToPref(button).component();
- add(component, BorderLayout.CENTER);
- }
+ public ShowAxisAdapter(DoubleField[] axis, DoubleField[] centre) {
+ super(new BorderLayout());
+ this.axis = axis;
+ this.centre = centre;
+ this.button = newShowAxisButton(false);
+ JComponent component = Componentizer.create().minAndMore(centre).minToPref(button).component();
+ add(component, BorderLayout.CENTER);
+ }
- @Override
- public void setName(String name) {
- super.setName(name);
- button.setName(getName()+".button");
- axis[0].setName(getName()+".axis.0");
- axis[1].setName(getName()+".axis.1");
- axis[2].setName(getName()+".axis.2");
- centre[0].setName(getName()+".centre.0");
- centre[1].setName(getName()+".centre.1");
- centre[2].setName(getName()+".centre.2");
- }
-
- @Override
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- super.addPropertyChangeListener(propertyName, listener);
- if (propertyName.equals("point.location")) {
- button.getAction().addPropertyChangeListener(listener);
- }
- }
+ @Override
+ public void setName(String name) {
+ super.setName(name);
+ button.setName(getName() + ".button");
+ axis[0].setName(getName() + ".axis.0");
+ axis[1].setName(getName() + ".axis.1");
+ axis[2].setName(getName() + ".axis.2");
+ centre[0].setName(getName() + ".centre.0");
+ centre[1].setName(getName() + ".centre.1");
+ centre[2].setName(getName() + ".centre.2");
+ }
- public void turnOff() {
- if (button.isSelected()) {
- button.doClick();
- }
- }
+ @Override
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ super.addPropertyChangeListener(propertyName, listener);
+ if (propertyName.equals("point.location")) {
+ button.getAction().addPropertyChangeListener(listener);
+ }
+ }
- public JToggleButton newShowAxisButton(boolean selected) {
- final JToggleButton button = new JToggleButton(new AbstractAction() {
- // private Border originalBorder;
+ public void turnOff() {
+ if (button.isSelected()) {
+ button.doClick();
+ }
+ }
- @Override
- public void actionPerformed(ActionEvent e) {
- AbstractButton b = ((AbstractButton) e.getSource());
- if (b.isSelected()) {
- firePropertyChange(PointInfo.PROPERTY_NAME, null, new AxisInfo(axis, centre, EventActionType.SHOW));
- } else {
- firePropertyChange(PointInfo.PROPERTY_NAME, null, new AxisInfo(axis, centre, EventActionType.HIDE));
- }
- }
- });
- if (selected && !button.isSelected() || (!selected && button.isSelected())) {
- button.doClick();
- }
- button.setPreferredSize(new Dimension(22, 22));
- button.setIcon(ICON_OFF);
- button.setSelectedIcon(ICON_ON);
- button.setToolTipText("Click to display this point in the 3D canvas");
- return button;
- }
+ public JToggleButton newShowAxisButton(boolean selected) {
+ final JToggleButton button = new JToggleButton(new AbstractAction() {
+ // private Border originalBorder;
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ AbstractButton b = ((AbstractButton) e.getSource());
+ if (b.isSelected()) {
+ firePropertyChange(PointInfo.PROPERTY_NAME, null, new AxisInfo(axis, centre, 1, EventActionType.SHOW));
+ } else {
+ firePropertyChange(PointInfo.PROPERTY_NAME, null, new AxisInfo(axis, centre, 1, EventActionType.HIDE));
+ }
+ }
+ });
+ if (selected && !button.isSelected() || (!selected && button.isSelected())) {
+ button.doClick();
+ }
+ button.setPreferredSize(new Dimension(22, 22));
+ button.setIcon(ICON_OFF);
+ button.setSelectedIcon(ICON_ON);
+ button.setToolTipText("Click to display this point in the 3D canvas");
+ return button;
+ }
}
diff --git a/src/eu/engys/core/dictionary/model/ShowLocationAdapter.java b/src/eu/engys/core/dictionary/model/ShowLocationAdapter.java
index 72f99f0..be0a9cc 100644
--- a/src/eu/engys/core/dictionary/model/ShowLocationAdapter.java
+++ b/src/eu/engys/core/dictionary/model/ShowLocationAdapter.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.model;
import java.awt.BorderLayout;
@@ -33,22 +32,24 @@ import java.beans.PropertyChangeListener;
import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
-import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
-import javax.swing.border.Border;
-import net.java.dev.designgridlayout.Componentizer;
import eu.engys.util.ColorUtil;
import eu.engys.util.ui.ResourcesUtil;
import eu.engys.util.ui.textfields.DoubleField;
+import net.java.dev.designgridlayout.Componentizer;
public class ShowLocationAdapter extends JPanel {
- private static final Icon ICON_ON = ResourcesUtil.getResourceIcon("eu/engys/resources/images/lightbulb16.png");
- private static final Icon ICON_OFF = ResourcesUtil.getResourceIcon("eu/engys/resources/images/lightbulb_off16.png");
+ private static final Icon ICON_ON = ResourcesUtil.getIcon("light.on.icon");
+ private static final Icon ICON_OFF = ResourcesUtil.getIcon("light.off.icon");
+
+ public static final String X = "x";
+ public static final String Y = "y";
+ public static final String Z = "z";
private JToggleButton button;
private DoubleField[] fields;
@@ -57,50 +58,35 @@ public class ShowLocationAdapter extends JPanel {
super(new BorderLayout());
this.fields = fields;
this.button = newShowPointButton(fields, key, false);
+
+ fields[0].setName(X);
+ fields[1].setName(Y);
+ fields[2].setName(Z);
+
JComponent component = Componentizer.create().minAndMore(fields).minToPref(button).component();
add(component, BorderLayout.CENTER);
}
- @Override
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- super.addPropertyChangeListener(propertyName, listener);
- if (propertyName.equals(PointInfo.PROPERTY_NAME)) {
- button.getAction().addPropertyChangeListener(listener);
- }
- }
-
- public void turnMaterialPointsOn() {
- if (!button.isSelected()) {
- button.doClick();
- }
- }
-
- public void turnMaterialPointsOff() {
- if (button.isSelected()) {
- button.doClick();
- }
- }
-
public static JToggleButton newShowPointButton(final DoubleField[] locationInMesh, int index, boolean selected) {
return newShowPointButton(locationInMesh, ColorUtil.getColor(index), selected);
}
- public static JToggleButton newShowPointButton(final DoubleField[] locationInMesh, final Color color, boolean selected) {
+ private static JToggleButton newShowPointButton(final DoubleField[] locationInMesh, final Color color, boolean selected) {
final JToggleButton button = new JToggleButton(new AbstractAction() {
- private Border originalBorder;
+ Object originalColorProperty = new JToggleButton().getClientProperty("Synthetica.background");
+ Object originalColorAlphaProperty = new JToggleButton().getClientProperty("Synthetica.background.alpha");
@Override
public void actionPerformed(ActionEvent e) {
AbstractButton b = ((AbstractButton) e.getSource());
if (b.isSelected()) {
firePropertyChange(PointInfo.PROPERTY_NAME, null, new PointInfo(locationInMesh, color.toString(), EventActionType.SHOW, color));
- originalBorder = b.getBorder();
- b.setBorder(BorderFactory.createLineBorder(color, 2));
+ b.putClientProperty("Synthetica.background", color);
+ b.putClientProperty("Synthetica.background.alpha", 0.50f);
} else {
firePropertyChange(PointInfo.PROPERTY_NAME, null, new PointInfo(locationInMesh, color.toString(), EventActionType.HIDE, color));
- if (originalBorder != null) {
- b.setBorder(originalBorder);
- }
+ b.putClientProperty("Synthetica.background", originalColorProperty);
+ b.putClientProperty("Synthetica.background.alpha", originalColorAlphaProperty);
}
}
});
@@ -114,6 +100,34 @@ public class ShowLocationAdapter extends JPanel {
return button;
}
+ @Override
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ super.addPropertyChangeListener(propertyName, listener);
+ if (propertyName.equals(PointInfo.PROPERTY_NAME)) {
+ button.getAction().addPropertyChangeListener(listener);
+ }
+ }
+
+ public DoubleField[] getFields() {
+ return fields;
+ }
+
+ public JToggleButton getButton() {
+ return button;
+ }
+
+ public void turnMaterialPointsOn() {
+ if (!button.isSelected()) {
+ button.doClick();
+ }
+ }
+
+ public void turnMaterialPointsOff() {
+ if (button.isSelected()) {
+ button.doClick();
+ }
+ }
+
@Override
public void setToolTipText(String text) {
super.setToolTipText(text);
diff --git a/src/eu/engys/core/dictionary/parser/DictionaryReader2.java b/src/eu/engys/core/dictionary/parser/DictionaryReader2.java
index b02e5b7..0e930c6 100644
--- a/src/eu/engys/core/dictionary/parser/DictionaryReader2.java
+++ b/src/eu/engys/core/dictionary/parser/DictionaryReader2.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.parser;
diff --git a/src/eu/engys/core/dictionary/parser/ListField2.java b/src/eu/engys/core/dictionary/parser/ListField2.java
index 52a04c1..9335e13 100644
--- a/src/eu/engys/core/dictionary/parser/ListField2.java
+++ b/src/eu/engys/core/dictionary/parser/ListField2.java
@@ -1,29 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.parser;
import static eu.engys.core.dictionary.Dictionary.SPACER;
@@ -32,9 +30,12 @@ import static eu.engys.core.dictionary.Dictionary.TAB;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.math.NumberUtils;
import com.google.common.primitives.Doubles;
@@ -83,7 +84,7 @@ public class ListField2 extends DefaultElement {
StringTokenizer tokenizer = new StringTokenizer(name, SPACER);
if (tokenizer.countTokens() == 1) { // internalField (...); oppure
// 10 (...);
-// System.out.println("ListField2.decodeName() 1");
+ // System.out.println("ListField2.decodeName() 1");
String token = tokenizer.nextToken();
try {
this.size = Integer.parseInt(token);
@@ -97,29 +98,29 @@ public class ListField2 extends DefaultElement {
} else if (tokenizer.countTokens() == 2) {// internalField 10 (...);
String token1 = tokenizer.nextToken();
String token2 = tokenizer.nextToken();
-// System.out.println("ListField2.decodeName() token1: [" + token1 + "], token2: [" + token2 + "]");
-
+ // System.out.println("ListField2.decodeName() token1: [" + token1 + "], token2: [" + token2 + "]");
+
try {
this.size = Integer.parseInt(token2);
} catch (NumberFormatException ex) {
this.size = -1;
}
- if(size < 0){
- setName(token1 + " " + token2);
+ if (size < 0) {
+ setName(token1 + " " + token2);
} else {
- setName(token1);
+ setName(token1);
}
this.uniformity = "";
this.identifier = "";
} else if (tokenizer.countTokens() == 3) {// internalField
// nonuniform 0()
-// System.out.println("ListField2.decodeName() 3");
+ // System.out.println("ListField2.decodeName() 3");
String token1 = tokenizer.nextToken();
String token2 = tokenizer.nextToken();
String token3 = tokenizer.nextToken();
-// System.out.println("ListField2.decodeName() token1 = '" + token1 + "'");
-// System.out.println("ListField2.decodeName() token2 = '" + token2 + "'");
-// System.out.println("ListField2.decodeName() token3 = '" + token3 + "'");
+ // System.out.println("ListField2.decodeName() token1 = '" + token1 + "'");
+ // System.out.println("ListField2.decodeName() token2 = '" + token2 + "'");
+ // System.out.println("ListField2.decodeName() token3 = '" + token3 + "'");
try {
this.size = Integer.parseInt(token3);
} catch (NumberFormatException ex) {
@@ -131,7 +132,7 @@ public class ListField2 extends DefaultElement {
} else if (tokenizer.countTokens() == 4) { // internalField
// nonuniform
// List 10
-// System.out.println("ListField2.decodeName() 4");
+ // System.out.println("ListField2.decodeName() 4");
String token1 = tokenizer.nextToken();
String token2 = tokenizer.nextToken();
String token3 = tokenizer.nextToken();
@@ -148,7 +149,9 @@ public class ListField2 extends DefaultElement {
} else {
try {
this.size = Integer.parseInt(name);
- setName(Integer.toString(hashCode()));
+ // Need to call hashcode method from Object class because we can have to ListFields
+ // With all the parameters equals (like in a eMesh file)
+ setName(Integer.toString(System.identityHashCode(this)));
} catch (NumberFormatException ex) {
this.size = -1;
setName(name);
@@ -174,12 +177,22 @@ public class ListField2 extends DefaultElement {
return Collections.unmodifiableList(listElements);
}
+ public List getListFields2() {
+ List l = new LinkedList<>();
+ for (DefaultElement e : listElements) {
+ if(e instanceof ListField2){
+ l.add((ListField2) e);
+ }
+ }
+ return Collections.unmodifiableList(l);
+ }
+
public void removeTopElements(int n) {
for (int i = 0; i < n; i++) {
listElements.remove(0);
}
}
-
+
public void merge(ListField2 l) {
for (DefaultElement el : l.getListElements()) {
if (!containsElement(el)) {
@@ -201,24 +214,8 @@ public class ListField2 extends DefaultElement {
return false;
}
- protected boolean haveSameName(DefaultElement element, DefaultElement e) {
- return e.getName().equals(element.getName());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof ListField2) {
- ListField2 list = (ListField2) obj;
- boolean haveSameName = haveSameName(this, list);
-// boolean equalCollection = CollectionUtils.isEqualCollection(list.getListElements(), listElements);
- boolean equalCollection = list.getListElements().containsAll(listElements) && listElements.containsAll(list.getListElements());
- return haveSameName && equalCollection;
- }
- return false;
- }
-
public void writeListField(StringBuffer sb, String rowHeader) {
-// System.out.println("ListField2.writeListField() name: "+getName()+", size: "+size+", uniformity: "+uniformity+", identifier: "+identifier);
+ // System.out.println("ListField2.writeListField() name: "+getName()+", size: "+size+", uniformity: "+uniformity+", identifier: "+identifier);
sb.append("\n");
sb.append(rowHeader);
sb.append(TAB);
@@ -258,7 +255,7 @@ public class ListField2 extends DefaultElement {
String name = getName();
return NumberUtils.isNumber(name);
}
-
+
private void writeName(StringBuffer sb) {
String name = getName();
if (NumberUtils.isNumber(name)) {
@@ -313,25 +310,25 @@ public class ListField2 extends DefaultElement {
public boolean isNonuniform() {
return uniformity.equals("nonuniform");
}
-
+
public static String convertToString(ListField2 listField) {
- StringBuilder sb = new StringBuilder();
- convertToString(listField, sb);
- return sb.toString();
+ StringBuilder sb = new StringBuilder();
+ convertToString(listField, sb);
+ return sb.toString();
}
-
+
private static void convertToString(ListField2 listField, StringBuilder sb) {
- sb.append("(");
- for (DefaultElement el : listField.getListElements()) {
- if(el instanceof FieldElement){
- sb.append(((FieldElement) el).getValue());
- sb.append(" ");
- } else if(el instanceof ListField2){
- convertToString((ListField2)el, sb);
- }
- }
- sb.append(")");
- }
+ sb.append("(");
+ for (DefaultElement el : listField.getListElements()) {
+ if (el instanceof FieldElement) {
+ sb.append(((FieldElement) el).getValue());
+ sb.append(" ");
+ } else if (el instanceof ListField2) {
+ convertToString((ListField2) el, sb);
+ }
+ }
+ sb.append(")");
+ }
public List getElementsAsScalarList() {
List list = new ArrayList<>();
@@ -357,5 +354,44 @@ public class ListField2 extends DefaultElement {
}
return list;
}
+
+// @Override
+// public boolean equals(Object obj) {
+// if (obj instanceof ListField2) {
+// ListField2 list = (ListField2) obj;
+// boolean haveSameName = haveSameName(this, list);
+//// boolean equalCollection = CollectionUtils.isEqualCollection(list.getListElements(), listElements);
+// boolean equalCollection = list.getListElements().containsAll(listElements) && listElements.containsAll(list.getListElements());
+// return haveSameName && equalCollection;
+// }
+// return false;
+// }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof ListField2)) {
+ return false;
+ }
+ if (obj == this) {
+ return true;
+ }
+ ListField2 lf = (ListField2) obj;
+ return new EqualsBuilder()
+ .appendSuper(super.equals(obj))
+ .append(getListElements(), lf.getListElements())
+ .isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 31)
+ .appendSuper(super.hashCode())
+ .append(getListElements())
+ .toHashCode();
+ }
+
+ protected boolean haveSameName(DefaultElement element, DefaultElement e) {
+ return e.getName().equals(element.getName());
+ }
}
diff --git a/src/eu/engys/core/dictionary/parser/ListReader2.java b/src/eu/engys/core/dictionary/parser/ListReader2.java
index 132f7c7..90ea9d8 100644
--- a/src/eu/engys/core/dictionary/parser/ListReader2.java
+++ b/src/eu/engys/core/dictionary/parser/ListReader2.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.parser;
diff --git a/src/eu/engys/core/dictionary/parser/ThetaListField2.java b/src/eu/engys/core/dictionary/parser/ThetaListField2.java
index 3bd9e08..fb251fd 100644
--- a/src/eu/engys/core/dictionary/parser/ThetaListField2.java
+++ b/src/eu/engys/core/dictionary/parser/ThetaListField2.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.parser;
import java.util.ArrayList;
diff --git a/src/eu/engys/core/dictionary/parser/ThetaListReader2.java b/src/eu/engys/core/dictionary/parser/ThetaListReader2.java
index 27479a6..22f2a59 100644
--- a/src/eu/engys/core/dictionary/parser/ThetaListReader2.java
+++ b/src/eu/engys/core/dictionary/parser/ThetaListReader2.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.dictionary.parser;
import static eu.engys.core.dictionary.Dictionary.VERBOSE;
diff --git a/src/eu/engys/core/executor/AbstractExecutor.java b/src/eu/engys/core/executor/AbstractExecutor.java
index 2b8972f..c0fdf95 100644
--- a/src/eu/engys/core/executor/AbstractExecutor.java
+++ b/src/eu/engys/core/executor/AbstractExecutor.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
import java.io.File;
@@ -169,6 +168,11 @@ public abstract class AbstractExecutor extends Executor {
return error;
}
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
protected void notifyStart() {
this.state = ExecutorState.START;
if (terminal != null) {
diff --git a/src/eu/engys/core/executor/AbstractScriptExecutor.java b/src/eu/engys/core/executor/AbstractScriptExecutor.java
index 0fd6f47..c99c66f 100644
--- a/src/eu/engys/core/executor/AbstractScriptExecutor.java
+++ b/src/eu/engys/core/executor/AbstractScriptExecutor.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
import java.io.File;
@@ -49,6 +48,7 @@ public abstract class AbstractScriptExecutor extends AbstractExecutor {
protected int _exec() {
int returnValue = 0;
CommandLine cmdLine = getCommandLine();
+ logger.debug("[EXECUTOR] {}", cmdLine);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
ExecuteWatchdog watchdog = new ScriptExecuteWatchdog();
diff --git a/src/eu/engys/core/executor/CollapseManager.java b/src/eu/engys/core/executor/CollapseManager.java
deleted file mode 100644
index 1ab312b..0000000
--- a/src/eu/engys/core/executor/CollapseManager.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-package eu.engys.core.executor;
-
-import javax.swing.JSplitPane;
-import javax.swing.JTabbedPane;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-public class CollapseManager {
-
- private JTabbedPane tabbedPane;
-
- public CollapseManager(JTabbedPane tabbedPane) {
- this.tabbedPane = tabbedPane;
- tabbedPane.getModel().addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- collapsePanelIfEmpty();
- }
- });
- }
-
- private void collapsePanelIfEmpty() {
- boolean isEmpty = tabbedPane.getTabCount() == 0;
- if (isEmpty) {
- collapse();
- } else if (canExpand()) {
- expand();
- }
- }
-
- public boolean canExpand() {
- boolean hasOne = tabbedPane.getTabCount() >= 1;
- boolean isCollapsed = getSplitPane().getResizeWeight() == 1;
- return hasOne && isCollapsed;
- }
-
- public void collapse() {
- getSplitPane().setDividerLocation(getSplitPane().getHeight());
- getSplitPane().setResizeWeight(1);
- }
-
- public void expand() {
- getSplitPane().setDividerLocation(getSplitPane().getHeight() - 300);
- getSplitPane().setResizeWeight(0.7);
- }
-
- public void toggle() {
- if (canExpand()) {
- expand();
- } else {
- collapse();
- }
- }
-
- private JSplitPane getSplitPane() {
- return (JSplitPane) tabbedPane.getParent();
- }
-}
diff --git a/src/eu/engys/core/executor/CommandExecutor.java b/src/eu/engys/core/executor/CommandExecutor.java
index 9cf7e3d..c808aca 100644
--- a/src/eu/engys/core/executor/CommandExecutor.java
+++ b/src/eu/engys/core/executor/CommandExecutor.java
@@ -1,33 +1,33 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
import static eu.engys.core.OpenFOAMEnvironment.cleanEnvironment;
import static eu.engys.core.OpenFOAMEnvironment.loadEnvironment;
import static eu.engys.core.OpenFOAMEnvironment.printHeader;
+import static eu.engys.core.OpenFOAMEnvironment.printVariables;
import java.io.File;
import java.util.List;
@@ -58,7 +58,11 @@ public class CommandExecutor extends AbstractScriptExecutor {
@Override
protected void internalDeleteOnEnd() {
- FileUtils.deleteQuietly(supportFile);
+ if(keepFileOnEnd){
+ //do nothing
+ } else {
+ FileUtils.deleteQuietly(supportFile);
+ }
}
private void writeCommandInSupportFile(File supportFile) {
@@ -69,6 +73,7 @@ public class CommandExecutor extends AbstractScriptExecutor {
private List getCommand() {
ScriptBuilder sb = new ScriptBuilder();
printHeader(sb, description);
+ printVariables(sb);
if (Util.isWindows()) {
if (loadOpenFoamEnv) {
loadEnvironment(sb);
diff --git a/src/eu/engys/core/executor/ConsoleExecutorMonitor.java b/src/eu/engys/core/executor/ConsoleExecutorMonitor.java
index b92fade..f17779f 100644
--- a/src/eu/engys/core/executor/ConsoleExecutorMonitor.java
+++ b/src/eu/engys/core/executor/ConsoleExecutorMonitor.java
@@ -1,37 +1,49 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
public class ConsoleExecutorMonitor extends ExecutorTerminal {
- @Override
+ private boolean useHeader;
+ private boolean flushErrors;
+
+ public ConsoleExecutorMonitor() {
+ this(false, false);
+ }
+
+ public ConsoleExecutorMonitor(boolean useHeader, boolean flushErrors) {
+ this.useHeader = useHeader;
+ this.flushErrors = flushErrors;
+ }
+
+ @Override
public void start() {
}
+
@Override
public void finish(int returnValue) {
super.finish(returnValue);
@@ -46,7 +58,12 @@ public class ConsoleExecutorMonitor extends ExecutorTerminal {
@Override
public void refresh() {
- System.out.print(getOutputStream().flushLinesBuffer());
+ String outputLines = getOutputStream().flushLinesBuffer();
+ System.out.print(useHeader? outputLines.replace("\n", "\n[OUT] ") : outputLines);
+ if (flushErrors) {
+ String errorLines = getErrorStream().flushLinesBuffer();
+ System.err.print(useHeader ? errorLines.replace("\n", "\n[ERR] ") : errorLines);
+ }
}
}
diff --git a/src/eu/engys/core/executor/Executor.java b/src/eu/engys/core/executor/Executor.java
index c9c4d8d..1ca2f2a 100644
--- a/src/eu/engys/core/executor/Executor.java
+++ b/src/eu/engys/core/executor/Executor.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
@@ -94,6 +93,7 @@ public abstract class Executor {
public abstract ExecutorService getService();
public abstract ExecutorState getState();
public abstract ExecutorError getError();
+ public abstract String getDescription();
public void notify(ExecutorState state) {
}
diff --git a/src/eu/engys/core/executor/ExecutorError.java b/src/eu/engys/core/executor/ExecutorError.java
index 085bf0f..4f80260 100644
--- a/src/eu/engys/core/executor/ExecutorError.java
+++ b/src/eu/engys/core/executor/ExecutorError.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
import java.io.Serializable;
diff --git a/src/eu/engys/core/executor/ExecutorHook.java b/src/eu/engys/core/executor/ExecutorHook.java
index 3bbe5a4..4a45f3b 100644
--- a/src/eu/engys/core/executor/ExecutorHook.java
+++ b/src/eu/engys/core/executor/ExecutorHook.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
public interface ExecutorHook {
diff --git a/src/eu/engys/core/executor/ExecutorListener.java b/src/eu/engys/core/executor/ExecutorListener.java
index f138d14..5526914 100644
--- a/src/eu/engys/core/executor/ExecutorListener.java
+++ b/src/eu/engys/core/executor/ExecutorListener.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
diff --git a/src/eu/engys/core/executor/ExecutorMonitor.java b/src/eu/engys/core/executor/ExecutorMonitor.java
index 7ffc3f1..23ea2a1 100644
--- a/src/eu/engys/core/executor/ExecutorMonitor.java
+++ b/src/eu/engys/core/executor/ExecutorMonitor.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
import java.util.ArrayList;
diff --git a/src/eu/engys/core/executor/ExecutorTerminal.java b/src/eu/engys/core/executor/ExecutorTerminal.java
index f22ab4d..063e630 100644
--- a/src/eu/engys/core/executor/ExecutorTerminal.java
+++ b/src/eu/engys/core/executor/ExecutorTerminal.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
import java.util.concurrent.ExecutorService;
diff --git a/src/eu/engys/core/executor/FileManagerSupport.java b/src/eu/engys/core/executor/FileManagerSupport.java
index 4216049..22648b5 100644
--- a/src/eu/engys/core/executor/FileManagerSupport.java
+++ b/src/eu/engys/core/executor/FileManagerSupport.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
import java.awt.Desktop;
@@ -40,6 +39,7 @@ import org.slf4j.LoggerFactory;
import eu.engys.util.PDFFileFilter;
import eu.engys.util.PrefUtil;
+import eu.engys.util.TempFolder;
import eu.engys.util.Util;
import eu.engys.util.ui.UiUtil;
@@ -63,7 +63,7 @@ public class FileManagerSupport {
public static void open(File file) {
if (Util.isWindows()) {
// Desktop.getDesktop().open(file) on windows may hang
- _open(file, "Open action not supported");
+ _openWindows(file);
} else {
openOnLinux(file);
}
@@ -76,18 +76,28 @@ public class FileManagerSupport {
try {
Desktop.getDesktop().open(file);
} catch (IOException e) {
- _open(file, e.getMessage());
+ _openLinux(file);
}
} else {
- _open(file, "Open action not supported");
+ _openLinux(file);
}
} else {
- _open(file, "Desktop class not supported by this platform");
+ _openLinux(file);
}
}
- private static void _open(File file, String logInfo) {
- Executor.command(getOpenCommand(file), getOpenCommandArguments(file)).description(ACTION_NAME).exec();
+ private static void _openLinux(File file) {
+ File inFolder = TempFolder.get();
+ Executor.command(getOpenCommand(file), getOpenCommandArguments(file)).inFolder(inFolder).description(ACTION_NAME).exec();
+ }
+
+ /*
+ * If you try to open multiple files (e.g. parser log files) just one of the files is opened.
+ * The command rundll32.exe is not blocking therefore I can call execAndWait
+ */
+ private static void _openWindows(File file) {
+ File inFolder = TempFolder.get();
+ Executor.command(getOpenCommand(file), getOpenCommandArguments(file)).inFolder(inFolder).description(ACTION_NAME).execAndWait();
}
private static String getOpenCommand(File file) {
diff --git a/src/eu/engys/core/executor/JavaExecutor.java b/src/eu/engys/core/executor/JavaExecutor.java
index 753d5cc..b62f1b6 100644
--- a/src/eu/engys/core/executor/JavaExecutor.java
+++ b/src/eu/engys/core/executor/JavaExecutor.java
@@ -1,29 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
import java.nio.file.Path;
@@ -44,17 +42,13 @@ public class JavaExecutor extends AbstractScriptExecutor {
@Override
public CommandLine getCommandLine() {
- return buildCommandLineScript();
- }
-
- private CommandLine buildCommandLineScript() {
String separator = System.getProperty("file.separator");
String classpath = System.getProperty("java.class.path");
String java = System.getProperty("java.home") + separator + "bin" + separator + "java";
final CommandLine cmdLine = new CommandLine(java);
cmdLine.addArgument("-classpath");
- cmdLine.addArgument(reletivize(classpath));
+ cmdLine.addArgument(relativize(classpath));
addSystemProperties(cmdLine);
cmdLine.addArgument(className);
cmdLine.addArguments(args);
@@ -62,28 +56,39 @@ public class JavaExecutor extends AbstractScriptExecutor {
return cmdLine;
}
- private String reletivize(String classpath) {
+ private String relativize(String classpath) {
if (currentDir != null) {
- String relative = "";
- String[] paths = classpath.split(System.getProperty("path.separator"));
- for (String path : paths) {
+ String relativizedClassPath = "";
+ for (String path : classpath.split(System.getProperty("path.separator"))) {
Path p = Paths.get(path);
- if(!p.isAbsolute()){
+ if (!p.isAbsolute()) {
p = p.toAbsolutePath();
}
- Path relativize = currentDir.getAbsoluteFile().toPath().relativize(p);
- relative += (relativize + System.getProperty("path.separator"));
+
+ Path relativize;
+ if (canRelativize(currentDir.getAbsoluteFile().toPath(), p)) {
+ relativize = p;
+ } else {
+ relativize = currentDir.getAbsoluteFile().toPath().relativize(p);
+ }
+
+ relativizedClassPath += (relativize + System.getProperty("path.separator"));
}
- return relative;
+ return relativizedClassPath;
} else {
return classpath;
}
}
+ private boolean canRelativize(Path p1, Path p2) {
+ // windows case where you have C:\ and D:\
+ return p1.getRoot() != p2.getRoot();
+ }
+
private void addSystemProperties(CommandLine cmdLine) {
if (properties != null) {
for (String key : properties.stringPropertyNames()) {
- cmdLine.addArgument("-D"+key+"="+properties.getProperty(key));
+ cmdLine.addArgument("-D" + key + "=" + properties.getProperty(key));
}
}
}
diff --git a/src/eu/engys/core/executor/MailManagerSupport.java b/src/eu/engys/core/executor/MailManagerSupport.java
index d414568..9b181fe 100644
--- a/src/eu/engys/core/executor/MailManagerSupport.java
+++ b/src/eu/engys/core/executor/MailManagerSupport.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
diff --git a/src/eu/engys/core/executor/ProgressExecutorMonitor.java b/src/eu/engys/core/executor/ProgressExecutorMonitor.java
index cf1585f..453724c 100644
--- a/src/eu/engys/core/executor/ProgressExecutorMonitor.java
+++ b/src/eu/engys/core/executor/ProgressExecutorMonitor.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
diff --git a/src/eu/engys/core/executor/QueueExecutorMonitor.java b/src/eu/engys/core/executor/QueueExecutorMonitor.java
deleted file mode 100644
index 9600bce..0000000
--- a/src/eu/engys/core/executor/QueueExecutorMonitor.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
-package eu.engys.core.executor;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.io.input.Tailer;
-import org.apache.commons.io.input.TailerListenerAdapter;
-
-public class QueueExecutorMonitor extends ExecutorTerminal {
-
- private File[] outputFiles;
- private List tailers;
-
- public QueueExecutorMonitor(File... outputFile) {
- this.outputFiles = outputFile;
- this.tailers = new ArrayList<>();
- }
-
- @Override
- public void start() {
- super.start();
- for (File outputFile : outputFiles) {
- tailers.add(Tailer.create(outputFile, new MyListener(), 500L));
- }
- }
-
- @Override
- public void finish(int returnValue) {
- super.finish(returnValue);
- for (Tailer tailer : tailers) {
- tailer.stop();
- }
- }
-
- @Override
- public void error(int returnValue, String msg) {
- super.error(returnValue, msg);
- for (Tailer tailer : tailers) {
- tailer.stop();
- }
- System.err.println(msg);
- }
-
- @Override
- public void refresh() {
- super.refresh();
- System.out.print(getOutputStream().flushLinesBuffer());
- System.err.print(getErrorStream().flushLinesBuffer());
- }
-
- class MyListener extends TailerListenerAdapter {
-
- @Override
- public void handle(String line) {
- System.out.println("[out] "+line);
- }
-
- @Override
- public void handle(Exception exception) {
- System.err.println("[err] "+exception.getMessage());
- }
-
- }
-}
diff --git a/src/eu/engys/core/executor/QueueTerminalExecutorMonitor.java b/src/eu/engys/core/executor/QueueTerminalExecutorMonitor.java
deleted file mode 100644
index 9e55c84..0000000
--- a/src/eu/engys/core/executor/QueueTerminalExecutorMonitor.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-package eu.engys.core.executor;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.io.input.Tailer;
-import org.apache.commons.io.input.TailerListenerAdapter;
-
-public class QueueTerminalExecutorMonitor extends TerminalExecutorMonitor {
-
- private File[] outputFiles;
- private List tailers;
-
- public QueueTerminalExecutorMonitor(File... outputFile) {
- this.outputFiles = outputFile;
- this.tailers = new ArrayList<>();
- }
-
- @Override
- public void start() {
- for (File outputFile : outputFiles) {
- tailers.add(Tailer.create(outputFile, new MyListener(), 500L));
- }
- super.start();
- }
-
- @Override
- public void finish(int returnValue) {
- super.finish(returnValue);
- for (Tailer tailer : tailers) {
- tailer.stop();
- }
- }
-
- @Override
- public void error(int returnValue, String msg) {
- super.error(returnValue, msg);
- for (Tailer tailer : tailers) {
- tailer.stop();
- }
- // System.err.println(msg);
- }
-
- @Override
- public void refresh() {
- super.refresh();
- // System.out.print(flushLinesBuffer());
- }
-
- class MyListener extends TailerListenerAdapter {
-
- @Override
- public void handle(String line) {
- area.append("[out] " + line + "\n");
- }
-
- @Override
- public void handle(Exception exception) {
- area.append("[err] " + exception.getMessage() + "\n");
- }
-
- }
-}
diff --git a/src/eu/engys/core/executor/ScriptExecutor.java b/src/eu/engys/core/executor/ScriptExecutor.java
index db08d71..c2097f3 100644
--- a/src/eu/engys/core/executor/ScriptExecutor.java
+++ b/src/eu/engys/core/executor/ScriptExecutor.java
@@ -1,35 +1,36 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
import java.io.File;
import org.apache.commons.exec.CommandLine;
+import eu.engys.core.DockerUtil;
+import eu.engys.util.PrefUtil;
+
public class ScriptExecutor extends AbstractScriptExecutor {
private File file;
@@ -43,11 +44,15 @@ public class ScriptExecutor extends AbstractScriptExecutor {
@Override
protected CommandLine getCommandLine() {
- CommandLine commandLine = new CommandLine(file.getAbsolutePath());
- if (args != null && args.length > 0) {
- commandLine.addArguments(args);
+ if (PrefUtil.isUsingDocker()) {
+ return DockerUtil.getCommandLine(environment, file.getName());
+ } else {
+ CommandLine commandLine = new CommandLine(file.getAbsolutePath());
+ if (args != null && args.length > 0) {
+ commandLine.addArguments(args);
+ }
+ return commandLine;
}
- return commandLine;
}
@Override
diff --git a/src/eu/engys/core/executor/StateMapperHook.java b/src/eu/engys/core/executor/StateMapperHook.java
index 8ad94da..b418349 100644
--- a/src/eu/engys/core/executor/StateMapperHook.java
+++ b/src/eu/engys/core/executor/StateMapperHook.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
import eu.engys.core.controller.Command;
@@ -46,4 +45,4 @@ public class StateMapperHook implements ExecutorHook {
public void run(ExecutorMonitor m) {
connector.offer(new ServerState(command, solverState, new ExecutorError(m.getReturnValue(), m.getErrorMessage())));
}
-}
+}
\ No newline at end of file
diff --git a/src/eu/engys/core/executor/TerminalExecutorMonitor.java b/src/eu/engys/core/executor/TerminalExecutorMonitor.java
index d948431..43a5e78 100644
--- a/src/eu/engys/core/executor/TerminalExecutorMonitor.java
+++ b/src/eu/engys/core/executor/TerminalExecutorMonitor.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
import static eu.engys.util.ui.UiUtil.createToolBarButton;
@@ -68,9 +67,9 @@ public class TerminalExecutorMonitor extends ExecutorTerminal {
private static final String RUNNING_LABEL = "Running...";
public static final String TERMINAL_PANEL_AREA = "terminal.panel.area";
+ public static final String TERMINAL_TOOLBAR = "terminal.toolbar";
protected JTextArea area;
- private JScrollPane scroll;
private JToolBar toolbar;
private JPanel panel;
@@ -94,13 +93,16 @@ public class TerminalExecutorMonitor extends ExecutorTerminal {
}
};
- public TerminalExecutorMonitor() {
+ private TerminalManager terminalManager;
+
+ public TerminalExecutorMonitor(TerminalManager terminalManager) {
super();
+ this.terminalManager = terminalManager;
layoutComponents();
}
- public TerminalExecutorMonitor(File logFile) {
- this();
+ public TerminalExecutorMonitor(TerminalManager terminalManager, File logFile) {
+ this(terminalManager);
setLogFile(logFile);
}
@@ -109,8 +111,9 @@ public class TerminalExecutorMonitor extends ExecutorTerminal {
@Override
public void run() {
area = new JTextArea();
- scroll = new JScrollPane(area);
+ JScrollPane scroll = new JScrollPane(area);
toolbar = new JToolBar();
+ toolbar.setName(TERMINAL_TOOLBAR);
panel = new JPanel(new BorderLayout());
scroll.setName("terminal.panel.scroll");
@@ -155,9 +158,9 @@ public class TerminalExecutorMonitor extends ExecutorTerminal {
});
}
- protected void configureFrameActions(JToolBar toolbar) {
- maxAction = new MaximiseMonitorAction(panel);
- closeAction = new CloseMonitorAction(panel);
+ private void configureFrameActions(JToolBar toolbar) {
+ maxAction = new MaximiseMonitorAction(terminalManager, panel);
+ closeAction = new CloseMonitorAction(terminalManager, panel);
closeAction.setEnabled(false);
toolbar.add(createToolBarToggleButton(maxAction));
toolbar.add(createToolBarButton(closeAction));
@@ -191,8 +194,10 @@ public class TerminalExecutorMonitor extends ExecutorTerminal {
});
}
- public void show() {
- TerminalManager.getInstance().addTerminal(panel, TerminalExecutorMonitor.this);
+ private void show() {
+ if (terminalManager != null) {
+ terminalManager.addTerminal(panel, TerminalExecutorMonitor.this);
+ }
}
@Override
@@ -201,7 +206,7 @@ public class TerminalExecutorMonitor extends ExecutorTerminal {
}
private String getTime() {
- return new SimpleDateFormat("'['HH:mm:ss']'").format(startTime);
+ return startTime == null ? "" : new SimpleDateFormat("'['HH:mm:ss']'").format(startTime);
}
private void setupFont() {
@@ -214,10 +219,10 @@ public class TerminalExecutorMonitor extends ExecutorTerminal {
@Override
public void error(final int returnValue, final String msg) {
super.error(returnValue, msg);
- refresh();
ExecUtil.invokeLater(new Runnable() {
@Override
public void run() {
+ _refresh();
stateLabel.setText("");
stopAction.setEnabled(false);
if (closeAction != null) {
@@ -253,15 +258,19 @@ public class TerminalExecutorMonitor extends ExecutorTerminal {
});
}
- protected void _refresh() {
+ private void _refresh() {
+ String lines = getOutputStream().flushLinesBuffer();
+ String errors = getErrorStream().flushLinesBuffer();
+ _refresh(lines, errors);
+ }
+
+ protected void _refresh(String lines, String errors) {
int maxLines = PrefUtil.getInt(PrefUtil.BATCH_MONITOR_DIALOG_MAX_ROW, 10000);
- String lines = getOutputStream().flushLinesBuffer();
if (!lines.isEmpty()) {
area.append(lines);
}
- String errors = getErrorStream().flushLinesBuffer();
if (!errors.isEmpty()) {
area.append(errors);
}
@@ -281,7 +290,6 @@ public class TerminalExecutorMonitor extends ExecutorTerminal {
}
private boolean stopExecutor() {
- // if (getState() == ExecutorState.START || getState() == ExecutorState.RUNNING) {
if (executor != null) {
int retVal = JOptionPane.showConfirmDialog(UiUtil.getActiveWindow(), "Stop execution?", "Close Monitor", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
if (retVal == JOptionPane.YES_OPTION) {
@@ -292,15 +300,12 @@ public class TerminalExecutorMonitor extends ExecutorTerminal {
} else {
return true;
}
- // } else {
- // return true;
- // }
}
public JPopupMenu createMenu(Component component) {
JPopupMenu pMenu = new JPopupMenu();
pMenu.add(UiUtil.createMenuItem(new StopCommandAction(true)));
- pMenu.add(UiUtil.createMenuItem(new CloseMonitorAction(panel, true)));
+ pMenu.add(UiUtil.createMenuItem(new CloseMonitorAction(terminalManager, panel, true)));
return pMenu;
}
diff --git a/src/eu/engys/core/executor/TerminalManager.java b/src/eu/engys/core/executor/TerminalManager.java
index 9209a39..08f31cd 100644
--- a/src/eu/engys/core/executor/TerminalManager.java
+++ b/src/eu/engys/core/executor/TerminalManager.java
@@ -1,29 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
import java.awt.BorderLayout;
@@ -40,12 +38,16 @@ import java.util.Map;
import javax.swing.AbstractButton;
import javax.swing.ImageIcon;
+import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
+import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import eu.engys.util.ApplicationInfo;
import eu.engys.util.ui.ExecUtil;
@@ -53,32 +55,28 @@ import eu.engys.util.ui.ResourcesUtil;
import eu.engys.util.ui.UiUtil;
import eu.engys.util.ui.ViewAction;
-public class TerminalManager {
+public class TerminalManager implements ChangeListener {
- private static TerminalManager instance = null;
private Map frames = new HashMap<>();
private Map monitors = new HashMap<>();
public static final String TERMINAL_MANAGER = "terminal.manager";
- private CollapseManager collapseManager;
+ private JSplitPane parent;
private JTabbedPane tabbedPane;
- public static TerminalManager getInstance() {
- if (instance == null) {
- instance = new TerminalManager();
- }
- return instance;
- }
-
- private TerminalManager() {
+ public TerminalManager() {
this.tabbedPane = new JTabbedPane();
this.tabbedPane.setName(TERMINAL_MANAGER);
- this.collapseManager = new CollapseManager(tabbedPane);
+ this.tabbedPane.addChangeListener(this);
}
- public void toggleVisibility() {
- collapseManager.toggle();
+ public void setParent(JSplitPane parent) {
+ this.parent = parent;
+ }
+
+ public JComponent getComponent() {
+ return tabbedPane;
}
public void addTerminal(Component component, TerminalExecutorMonitor monitor) {
@@ -188,7 +186,7 @@ public class TerminalManager {
}
}
}
-
+
public static JFrame createTerminalFrame(final Component component, final String title, boolean removeMinMax) {
final JFrame frame = new JFrame(title) {
/**
@@ -205,11 +203,11 @@ public class TerminalManager {
}
};
-
+
if (removeMinMax) {
removeMinMaxClose(frame);
}
-
+
frame.setIconImage(((ImageIcon) ResourcesUtil.getIcon(ApplicationInfo.getVendor().toLowerCase() + ".logo")).getImage());
frame.setAlwaysOnTop(false);
frame.getContentPane().setLayout(new BorderLayout());
@@ -234,6 +232,42 @@ public class TerminalManager {
}
}
+ @Override
+ public void stateChanged(ChangeEvent e) {
+ ExecUtil.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ if (tabbedPane.getTabCount() == 0) {
+ collapse();
+ } else if (tabbedPane.getTabCount() >= 1) {
+ expand();
+ }
+ }
+ });
+ }
+
+ public void toggleVisibility() {
+ if (parent != null) {
+ if (UiUtil.isCollapsed(parent) && tabbedPane.getTabCount() > 0) {
+ expand();
+ } else {
+ collapse();
+ }
+ }
+ }
+
+ public void collapse() {
+ if (parent != null) {
+ UiUtil.collapseSplitPane(parent);
+ }
+ }
+
+ public void expand() {
+ if (parent != null) {
+ UiUtil.expandSplitPane(parent, tabbedPane, 0.7, 300);
+ }
+ }
+
class CloseAllAction extends ViewAction {
public CloseAllAction() {
@@ -250,7 +284,4 @@ public class TerminalManager {
}
}
- public Component getComponent() {
- return tabbedPane;
- }
}
diff --git a/src/eu/engys/core/executor/TerminalOutputStream.java b/src/eu/engys/core/executor/TerminalOutputStream.java
index 5c8433e..e1101b9 100644
--- a/src/eu/engys/core/executor/TerminalOutputStream.java
+++ b/src/eu/engys/core/executor/TerminalOutputStream.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
import java.io.IOException;
@@ -61,8 +60,4 @@ public class TerminalOutputStream extends OutputStream {
linesBuffer.setLength(0);
return s;
}
-
- public String peekLines() {
- return linesBuffer.toString();
- }
}
diff --git a/src/eu/engys/core/executor/TerminalSupport.java b/src/eu/engys/core/executor/TerminalSupport.java
index 445a956..29a1b25 100644
--- a/src/eu/engys/core/executor/TerminalSupport.java
+++ b/src/eu/engys/core/executor/TerminalSupport.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
@@ -32,27 +31,39 @@ import static eu.engys.core.OpenFOAMEnvironment.getTestEnvironment;
import java.io.File;
import java.io.IOException;
+import eu.engys.core.DockerUtil;
import eu.engys.core.project.Model;
import eu.engys.util.PrefUtil;
import eu.engys.util.Util;
public class TerminalSupport {
+ public static final String SHELL = "$SHELL";
private static final String ACTION_NAME = "Open Terminal";
public static void openTerminal(Model model) {
+ File baseDir = model.getProject().getBaseDir();
if (Util.isWindows()) {
- Executor.command("start", "cmd", "/K").inFolder(model.getProject().getBaseDir()).withOpenFoamEnv().env(getEnvironment(model)).description(ACTION_NAME).exec();
+ if(PrefUtil.isUsingDocker()){
+ Executor.command("start", "cmd", "/K", DockerUtil.terminal(baseDir)).inFolder(baseDir).description(ACTION_NAME).exec();
+ } else {
+ Executor.command("start", "cmd", "/K").inFolder(baseDir).withOpenFoamEnv().env(getEnvironment(model)).description(ACTION_NAME).exec();
+ }
} else {
- Executor.command(getTerminal() + "$SHELL").inFolder(model.getProject().getBaseDir()).withOpenFoamEnv().env(getEnvironment(model)).description(ACTION_NAME).exec();
+ if(PrefUtil.isUsingDocker()){
+ Executor.command(getTerminal(), DockerUtil.terminal(baseDir)).inFolder(baseDir).description(ACTION_NAME).exec();
+ } else {
+ Executor.command(getTerminal(), SHELL).inFolder(baseDir).withOpenFoamEnv().env(getEnvironment(model)).description(ACTION_NAME).exec();
+ }
}
}
+
public static void openTerminal(File baseDir) {
if (Util.isWindows()) {
Executor.command("start", "cmd", "/K").inFolder(baseDir).withOpenFoamEnv().env(getTestEnvironment()).description(ACTION_NAME).exec();
} else {
- Executor.command(getTerminal() + "$SHELL").inFolder(baseDir).withOpenFoamEnv().env(getTestEnvironment()).description(ACTION_NAME).exec();
+ Executor.command(getTerminal(), SHELL).inFolder(baseDir).withOpenFoamEnv().env(getTestEnvironment()).description(ACTION_NAME).exec();
}
}
@@ -60,16 +71,16 @@ public class TerminalSupport {
String preferredTerminal = PrefUtil.getString(PrefUtil.HELYX_DEFAULT_TERMINAL);
if (preferredTerminal.isEmpty()) {
if (checkTerminal("gnome-terminal")) {
- return "gnome-terminal --disable-factory --geometry 80x40 -e ";
+ return "gnome-terminal --disable-factory --geometry 80x40 -e";
} else if (checkTerminal("konsole")) {
- return "konsole --geometry 80x40 -e ";
+ return "konsole --geometry 80x40 -e";
} else if (checkTerminal("xterm")) {
- return "xterm -sb -font -*-fixed-medium-r-*-*-18-*-*-*-*-*-iso8859-* -geometry 80x40 -hold -e ";
+ return "xterm -sb -font -*-fixed-medium-r-*-*-18-*-*-*-*-*-iso8859-* -geometry 80x40 -hold -e";
} else {
System.err.println("No terminal found");
}
} else {
- return preferredTerminal + " -e ";
+ return preferredTerminal + " -e";
}
return "";
diff --git a/src/eu/engys/core/executor/TerminalTabComponent.java b/src/eu/engys/core/executor/TerminalTabComponent.java
index af3ea61..80a7ee5 100644
--- a/src/eu/engys/core/executor/TerminalTabComponent.java
+++ b/src/eu/engys/core/executor/TerminalTabComponent.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor;
diff --git a/src/eu/engys/core/executor/actions/CloseMonitorAction.java b/src/eu/engys/core/executor/actions/CloseMonitorAction.java
index 1f50e97..ae61798 100644
--- a/src/eu/engys/core/executor/actions/CloseMonitorAction.java
+++ b/src/eu/engys/core/executor/actions/CloseMonitorAction.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor.actions;
import java.awt.event.ActionEvent;
@@ -36,18 +35,20 @@ import eu.engys.util.ui.ViewAction;
public class CloseMonitorAction extends ViewAction {
private JPanel panel;
+ private TerminalManager terminalManager;
- public CloseMonitorAction(JPanel panel) {
- this(panel, false);
+ public CloseMonitorAction(TerminalManager terminalManager, JPanel panel) {
+ this(terminalManager, panel, false);
}
-
- public CloseMonitorAction(JPanel panel, boolean label) {
- super(label ? "Close Current Monitor" : null, ResourcesUtil.getIcon("console.tab.close.icon"), "Close Current Monitor");
- this.panel = panel;
+
+ public CloseMonitorAction(TerminalManager terminalManager, JPanel panel, boolean label) {
+ super(label ? "Close Current Monitor" : null, ResourcesUtil.getIcon("console.tab.close.icon"), "Close Current Monitor");
+ this.terminalManager = terminalManager;
+ this.panel = panel;
}
@Override
public void actionPerformed(ActionEvent e) {
- TerminalManager.getInstance().close(panel, false);
+ terminalManager.close(panel, false);
}
}
diff --git a/src/eu/engys/core/executor/actions/CopyMonitorToClipboardAction.java b/src/eu/engys/core/executor/actions/CopyMonitorToClipboardAction.java
index b6ca06f..609629b 100644
--- a/src/eu/engys/core/executor/actions/CopyMonitorToClipboardAction.java
+++ b/src/eu/engys/core/executor/actions/CopyMonitorToClipboardAction.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor.actions;
import java.awt.Toolkit;
diff --git a/src/eu/engys/core/executor/actions/MaximiseMonitorAction.java b/src/eu/engys/core/executor/actions/MaximiseMonitorAction.java
index ed50ec0..9695345 100644
--- a/src/eu/engys/core/executor/actions/MaximiseMonitorAction.java
+++ b/src/eu/engys/core/executor/actions/MaximiseMonitorAction.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor.actions;
import java.awt.event.ActionEvent;
@@ -36,9 +35,11 @@ import eu.engys.util.ui.ViewAction;
public class MaximiseMonitorAction extends ViewAction {
private JPanel panel;
+ private TerminalManager terminalManager;
- public MaximiseMonitorAction(JPanel panel) {
+ public MaximiseMonitorAction(TerminalManager terminalManager, JPanel panel) {
this(panel, false);
+ this.terminalManager = terminalManager;
}
public MaximiseMonitorAction(JPanel panel, boolean label) {
@@ -51,9 +52,9 @@ public class MaximiseMonitorAction extends ViewAction {
@Override
public void actionPerformed(ActionEvent e) {
if (isSelected()) {
- TerminalManager.getInstance().toDialog(panel);
+ terminalManager.toDialog(panel);
} else {
- TerminalManager.getInstance().toTab(panel);
+ terminalManager.toTab(panel);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/eu/engys/core/executor/actions/SaveLogFileAction.java b/src/eu/engys/core/executor/actions/SaveLogFileAction.java
index e8ee606..bc08ee0 100644
--- a/src/eu/engys/core/executor/actions/SaveLogFileAction.java
+++ b/src/eu/engys/core/executor/actions/SaveLogFileAction.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor.actions;
import java.awt.event.ActionEvent;
@@ -94,4 +93,4 @@ public class SaveLogFileAction extends ViewAction {
e1.printStackTrace();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/eu/engys/core/executor/actions/ScrollLockAction.java b/src/eu/engys/core/executor/actions/ScrollLockAction.java
index ab68c32..c5a1f55 100644
--- a/src/eu/engys/core/executor/actions/ScrollLockAction.java
+++ b/src/eu/engys/core/executor/actions/ScrollLockAction.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor.actions;
import java.awt.event.ActionEvent;
diff --git a/src/eu/engys/core/executor/actions/ShowLogAction.java b/src/eu/engys/core/executor/actions/ShowLogAction.java
index a291460..88a5f7c 100644
--- a/src/eu/engys/core/executor/actions/ShowLogAction.java
+++ b/src/eu/engys/core/executor/actions/ShowLogAction.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor.actions;
import java.awt.event.ActionEvent;
diff --git a/src/eu/engys/core/executor/actions/StopCommandAction.java b/src/eu/engys/core/executor/actions/StopCommandAction.java
index 4272fe5..4bc32d2 100644
--- a/src/eu/engys/core/executor/actions/StopCommandAction.java
+++ b/src/eu/engys/core/executor/actions/StopCommandAction.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.executor.actions;
import java.awt.event.ActionEvent;
diff --git a/src/eu/engys/core/modules/AbstractChart.java b/src/eu/engys/core/modules/AbstractChart.java
new file mode 100644
index 0000000..3256593
--- /dev/null
+++ b/src/eu/engys/core/modules/AbstractChart.java
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
+package eu.engys.core.modules;
+
+import static org.jfree.chart.ChartPanel.DEFAULT_HEIGHT;
+import static org.jfree.chart.ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT;
+import static org.jfree.chart.ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH;
+import static org.jfree.chart.ChartPanel.DEFAULT_MINIMUM_DRAW_HEIGHT;
+import static org.jfree.chart.ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH;
+import static org.jfree.chart.ChartPanel.DEFAULT_WIDTH;
+
+import java.awt.Color;
+
+import javax.swing.JComponent;
+
+import org.jfree.chart.ChartPanel;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.block.BlockBorder;
+import org.jfree.chart.plot.CategoryPlot;
+import org.jfree.chart.plot.XYPlot;
+import org.jfree.chart.title.LegendTitle;
+import org.jfree.data.category.CategoryDataset;
+import org.jfree.data.xy.XYDataset;
+import org.jfree.ui.RectangleEdge;
+
+import eu.engys.core.project.state.State;
+import eu.engys.core.project.system.monitoringfunctionobjects.TimeBlocks;
+import eu.engys.util.ui.ExecUtil;
+
+public abstract class AbstractChart {
+
+ public static final int DATASET_INDEX = 0;
+ public static final int MOVING_AVERAGE_DATASET_INDEX = 1;
+ public static final int WEIGHTING_DATASET_INDEX = 2;
+
+ private ChartPanel chartPanel;
+
+ public AbstractChart() {
+ }
+
+ public void layoutComponents() {
+ boolean useBuffer = true;
+ boolean showPropertiesMenu = true;
+ boolean showCopyMenu = true;
+ boolean showSaveMenu = false;
+ boolean showPrintMenu = true;
+ boolean showZoomMenu = true;
+ boolean showTooltipsMenu = true;
+
+ JFreeChart chart = createChart();
+ LegendTitle legend = chart.getLegend();
+ if (legend != null) {
+ legend.setFrame(BlockBorder.NONE);
+ legend.setBackgroundPaint(null);
+ legend.setPosition(RectangleEdge.RIGHT);
+ legend.setVisible(false);
+ }
+ chart.setBackgroundPaint(new Color(0, 0, 0, 0));
+ this.chartPanel = new ChartPanel(chart, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_MINIMUM_DRAW_WIDTH, DEFAULT_MINIMUM_DRAW_HEIGHT, DEFAULT_MAXIMUM_DRAW_WIDTH, DEFAULT_MAXIMUM_DRAW_HEIGHT, useBuffer, showPropertiesMenu, showCopyMenu, showSaveMenu, showPrintMenu, showZoomMenu, showTooltipsMenu);
+ this.chartPanel.setName(getClass().getCanonicalName());
+ }
+
+ public abstract JComponent getPanel();
+
+ protected abstract JFreeChart createChart();
+
+ public abstract void stop();
+
+ public void addToDataSet(final TimeBlocks list) {
+ synchronized (list) {
+ if (list.size() > 0) {
+ ExecUtil.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ notifySeries(false);
+ _addToDataSet(list);
+ notifySeries(true);
+ postAddToDataSet();
+ }
+ });
+ }
+ }
+ }
+
+ public abstract void postAddToDataSet();
+
+ public void clear() {
+ ExecUtil.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ notifySeries(false);
+ _clearData();
+ notifySeries(true);
+ chartPanel.restoreAutoDomainBounds();
+ }
+ });
+ }
+
+ protected abstract void notifySeries(boolean notify);
+
+ public abstract void _addToDataSet(TimeBlocks list);
+
+ public abstract void _clearData();
+
+ public abstract void handleStateChanged(State state);
+
+ public ChartPanel getChartPanel() {
+ return chartPanel;
+ }
+
+ public JFreeChart getChart() {
+ return chartPanel.getChart();
+ }
+
+ public XYPlot getXYPlot() {
+ return chartPanel.getChart().getXYPlot();
+ }
+
+ public CategoryPlot getCategoryPlot() {
+ return chartPanel.getChart().getCategoryPlot();
+ }
+
+ public CategoryDataset getCategoryDataset(int index) {
+ return chartPanel.getChart().getCategoryPlot().getDataset(index);
+ }
+
+ public XYDataset getXYDataset(int index) {
+ return chartPanel.getChart().getXYPlot().getDataset(index);
+ }
+
+}
diff --git a/src/eu/engys/core/modules/ApplicationModule.java b/src/eu/engys/core/modules/ApplicationModule.java
index 16d5ac6..de87d11 100644
--- a/src/eu/engys/core/modules/ApplicationModule.java
+++ b/src/eu/engys/core/modules/ApplicationModule.java
@@ -1,49 +1,59 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.modules;
+import java.util.List;
import java.util.Set;
+import javax.swing.JTabbedPane;
+
import eu.engys.core.modules.boundaryconditions.BoundaryConditionsView;
import eu.engys.core.modules.cellzones.CellZonesView;
import eu.engys.core.modules.materials.MaterialsView;
+import eu.engys.core.modules.residuals.ResidualsViewConfigurator;
import eu.engys.core.modules.solutionmodelling.SolutionView;
import eu.engys.core.modules.tree.TreeView;
-import eu.engys.core.project.InvalidProjectException;
import eu.engys.core.project.state.SolverFamily;
import eu.engys.core.project.state.State;
+import eu.engys.core.project.system.monitoringfunctionobjects.Parser;
+import eu.engys.core.project.system.monitoringfunctionobjects.ParserView;
import eu.engys.core.project.zero.fields.Field;
import eu.engys.core.project.zero.fields.Fields;
+import eu.engys.core.project.zero.patches.BoundaryConditions;
public interface ApplicationModule {
+ void checkLicense();
+ void checkIfCanOpenCase();
+
TreeView getTreeView();
Set getCaseSetupPanels();
+ Set getSolverPanels();
+
SolutionView getSolutionView();
MaterialsView getMaterialsView();
@@ -53,16 +63,20 @@ public interface ApplicationModule {
CellZonesView getCellZonesView();
FieldsInitialisationView getFieldsInitialisationView();
-
- String getName();
- void loadState() throws InvalidProjectException;
+ String getName();
- void loadMaterials();
+ void read();
+
+ void write();
+
+ void loadState();
void save();
+
+ void loadMaterials();
- void write();
+ void saveMaterials();
void saveDefaultsToProject();
@@ -86,6 +100,18 @@ public interface ApplicationModule {
void updateSolverFamilies(State state, Set families);
- boolean checkLicense();
+ ResidualsViewConfigurator createResidualsViewConfigurator(JTabbedPane pane);
+
+ Parser createResidualsParser();
+
+ List createParsers();
+
+ List getParserViews();
+
+ void deleteUselessLogFiles();
+
+ Set getFieldsToBeMonitored();
+
+ void saveToBoundaryConditions(BoundaryConditions bc);
}
diff --git a/src/eu/engys/core/modules/ApplicationModuleAdapter.java b/src/eu/engys/core/modules/ApplicationModuleAdapter.java
index 95d49f4..818300e 100644
--- a/src/eu/engys/core/modules/ApplicationModuleAdapter.java
+++ b/src/eu/engys/core/modules/ApplicationModuleAdapter.java
@@ -1,74 +1,55 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.modules;
import java.util.Collections;
+import java.util.List;
import java.util.Set;
+import javax.swing.JTabbedPane;
+
import eu.engys.core.modules.boundaryconditions.BoundaryConditionsView;
import eu.engys.core.modules.cellzones.CellZonesView;
import eu.engys.core.modules.materials.MaterialsView;
+import eu.engys.core.modules.residuals.ResidualsViewConfigurator;
import eu.engys.core.modules.tree.TreeView;
import eu.engys.core.project.state.SolverFamily;
import eu.engys.core.project.state.State;
+import eu.engys.core.project.system.monitoringfunctionobjects.Parser;
+import eu.engys.core.project.system.monitoringfunctionobjects.ParserView;
import eu.engys.core.project.zero.fields.Field;
+import eu.engys.core.project.zero.patches.BoundaryConditions;
public abstract class ApplicationModuleAdapter implements ApplicationModule {
+
+ @Override
+ public void checkLicense() {
+ }
@Override
- public boolean checkLicense() {
- return true;
- }
-
- @Override
- public void loadMaterials() {
- }
-
- @Override
- public void saveDefaultsToProject() {
- }
-
- @Override
- public void saveDefaultsTurbulenceModelsToProject() {
- }
-
- @Override
- public void saveMaterialsToProject() {
- }
-
-// @Override
-// public void initialiseFields(Controller controller, ExecutorService service, Server server) {
-// }
-
- @Override
- public void updateSolver(State state) {
- }
-
- @Override
- public void updateSolverFamilies(State state, Set families) {
+ public void checkIfCanOpenCase() {
}
@Override
@@ -76,6 +57,30 @@ public abstract class ApplicationModuleAdapter implements ApplicationModule {
return null;
}
+ @Override
+ public void deleteUselessLogFiles() {
+ }
+
+ @Override
+ public Parser createResidualsParser() {
+ return null;
+ }
+
+ @Override
+ public List createParsers() {
+ return Collections. emptyList();
+ }
+
+ @Override
+ public List getParserViews() {
+ return Collections. emptyList();
+ }
+
+ @Override
+ public ResidualsViewConfigurator createResidualsViewConfigurator(JTabbedPane pane) {
+ return null;
+ }
+
@Override
public MaterialsView getMaterialsView() {
return null;
@@ -106,11 +111,57 @@ public abstract class ApplicationModuleAdapter implements ApplicationModule {
return null;
}
+ @Override
+ public void read() {
+ }
+
+ @Override
+ public void write() {
+ }
+
+ @Override
+ public void loadMaterials() {
+ }
+
+ @Override
+ public void saveMaterials() {
+ }
+
+ @Override
+ public void saveDefaultsToProject() {
+ }
+
+ @Override
+ public void saveDefaultsTurbulenceModelsToProject() {
+ }
+
+ @Override
+ public void saveMaterialsToProject() {
+ }
+
+ @Override
+ public void updateSolver(State state) {
+ }
+
+ @Override
+ public void updateSolverFamilies(State state, Set families) {
+ }
+
@Override
public Set getCaseSetupPanels() {
return Collections. emptySet();
}
+ @Override
+ public Set getSolverPanels() {
+ return Collections. emptySet();
+ }
+
+ @Override
+ public Set getFieldsToBeMonitored() {
+ return Collections. emptySet();
+ }
+
@Override
public boolean isFieldInitialisationVetoed(Field field) {
return false;
@@ -120,5 +171,9 @@ public abstract class ApplicationModuleAdapter implements ApplicationModule {
public boolean isNonNewtonianViscosityModelVetoed() {
return false;
}
+
+ @Override
+ public void saveToBoundaryConditions(BoundaryConditions bc) {
+ }
}
diff --git a/src/eu/engys/core/modules/CaseSetupReader.java b/src/eu/engys/core/modules/CaseSetupReader.java
index 0299813..36bdf52 100644
--- a/src/eu/engys/core/modules/CaseSetupReader.java
+++ b/src/eu/engys/core/modules/CaseSetupReader.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.modules;
import eu.engys.core.dictionary.Dictionary;
diff --git a/src/eu/engys/core/modules/CaseSetupWriter.java b/src/eu/engys/core/modules/CaseSetupWriter.java
index 5adf001..d3bf98f 100644
--- a/src/eu/engys/core/modules/CaseSetupWriter.java
+++ b/src/eu/engys/core/modules/CaseSetupWriter.java
@@ -1,39 +1,41 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.modules;
import eu.engys.core.dictionary.Dictionary;
-import eu.engys.core.project.Model;
+import eu.engys.core.project.materials.Materials;
+import eu.engys.core.project.state.State;
public interface CaseSetupWriter {
- void addState(StringBuffer sb);
+ void addState(State state, StringBuffer sb);
- void addToMaterials(Model model, Dictionary materialProperties);
- void addToConstant(Dictionary constantFolder);
- void addToSystem(Dictionary constantFolder);
+ void addToMaterials(Materials materials, Dictionary materialProperties);
+
+ void addToConstant(State state, Dictionary constantFolder);
+
+ void addToSystem(State state, Dictionary constantFolder);
}
diff --git a/src/eu/engys/core/modules/FieldsInitialisationView.java b/src/eu/engys/core/modules/FieldsInitialisationView.java
index 5211ba9..0204363 100644
--- a/src/eu/engys/core/modules/FieldsInitialisationView.java
+++ b/src/eu/engys/core/modules/FieldsInitialisationView.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.modules;
diff --git a/src/eu/engys/core/modules/ModuleDefaults.java b/src/eu/engys/core/modules/ModuleDefaults.java
index 40dbfae..e37409f 100644
--- a/src/eu/engys/core/modules/ModuleDefaults.java
+++ b/src/eu/engys/core/modules/ModuleDefaults.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.modules;
import eu.engys.core.dictionary.Dictionary;
@@ -69,4 +68,4 @@ public class ModuleDefaults extends AbstractDefaultsProvider {
public Dictionary getStates() {
return stateData.found("states") ? stateData.subDict("states") : parent.getStates();
}
-}
+}
\ No newline at end of file
diff --git a/src/eu/engys/core/modules/ModulePanel.java b/src/eu/engys/core/modules/ModulePanel.java
index 2e0e850..1f7cbca 100644
--- a/src/eu/engys/core/modules/ModulePanel.java
+++ b/src/eu/engys/core/modules/ModulePanel.java
@@ -1,40 +1,39 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.modules;
import javax.swing.JComponent;
-
public interface ModulePanel {
- String getTitle();
- String getKey();
+ String getTitle();
- JComponent getPanel();
+ String getKey();
- int getIndex();
+ JComponent getPanel();
+
+ int getIndex();
}
diff --git a/src/eu/engys/core/modules/ModulesUtil.java b/src/eu/engys/core/modules/ModulesUtil.java
index c24148e..c93a72f 100644
--- a/src/eu/engys/core/modules/ModulesUtil.java
+++ b/src/eu/engys/core/modules/ModulesUtil.java
@@ -1,30 +1,30 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.modules;
+import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashSet;
@@ -46,13 +46,16 @@ import eu.engys.core.modules.cellzones.CellZonesView;
import eu.engys.core.modules.materials.MaterialsView;
import eu.engys.core.modules.tree.ModuleElementPanel;
import eu.engys.core.modules.tree.TreeView;
-import eu.engys.core.project.InvalidProjectException;
+import eu.engys.core.project.materials.Material;
import eu.engys.core.project.state.SolverFamily;
import eu.engys.core.project.state.State;
+import eu.engys.core.project.system.monitoringfunctionobjects.Parser;
+import eu.engys.core.project.system.monitoringfunctionobjects.ParserView;
import eu.engys.core.project.zero.cellzones.CellZoneType;
import eu.engys.core.project.zero.cellzones.CellZones;
import eu.engys.core.project.zero.fields.Field;
import eu.engys.core.project.zero.fields.Fields;
+import eu.engys.core.project.zero.patches.BoundaryConditions;
import eu.engys.util.ui.builder.PanelBuilder;
public class ModulesUtil {
@@ -91,31 +94,54 @@ public class ModulesUtil {
}
}
- public static Dictionary extractRelativeToStateSettings(String encodedPrimalState, Dictionary mDict) {
- if (mDict.found("requirements")) {
- Dictionary requirements = (Dictionary) mDict.remove("requirements");
- if (requirements.found("conditional")) {
- if (requirements.subDict("conditional").found(encodedPrimalState)) {
- Dictionary conditional = requirements.subDict("conditional").subDict(encodedPrimalState);
- return conditional;
- }
- }
- }
- return null;
- }
-
- public static void updateStateFromGUI(Set modules) {
+ public static void read(Set modules) {
for (ApplicationModule module : modules) {
- module.getSolutionView().updateStateFromGUI();
+ module.read();
}
}
- public static void loadState(Set modules) throws InvalidProjectException {
+ public static void write(Set modules) {
+ for (ApplicationModule module : modules) {
+ module.write();
+ }
+ }
+
+ public static void loadState(Set modules) {
for (ApplicationModule module : modules) {
module.loadState();
}
}
+ public static void checkIfCanOpenCase(Set modules) {
+ for (ApplicationModule module : modules) {
+ module.checkIfCanOpenCase();
+ }
+ }
+
+ public static void save(Set modules) {
+ for (ApplicationModule module : modules) {
+ module.save();
+ }
+ }
+
+ public static void loadMaterials(Set modules) {
+ for (ApplicationModule module : modules) {
+ module.loadMaterials();
+ }
+ }
+
+ public static void saveMaterials(Set modules) {
+ for (ApplicationModule module : modules) {
+ module.saveMaterials();
+ }
+ }
+
+ public static void updateStateFromGUI(Set modules, State state) {
+ for (ApplicationModule module : modules) {
+ module.getSolutionView().updateStateFromGUI(state);
+ }
+ }
+
public static void updateSolver(Set modules, State state) {
for (ApplicationModule module : modules) {
module.updateSolver(state);
@@ -128,12 +154,6 @@ public class ModulesUtil {
}
}
- public static void loadMaterials(Set modules) {
- for (ApplicationModule module : modules) {
- module.loadMaterials();
- }
- }
-
public static void saveDefaultsToProject(Set modules) {
for (ApplicationModule module : modules) {
module.saveDefaultsToProject();
@@ -152,18 +172,6 @@ public class ModulesUtil {
}
}
- public static void save(Set modules) {
- for (ApplicationModule module : modules) {
- module.save();
- }
- }
-
-// public static void initaliseFields(Set modules, Controller controller, ExecutorService service, Server server) {
-// for (ApplicationModule module : modules) {
-// module.initialiseFields(controller, service, server);
-// }
-// }
-
public static Fields loadFieldsFromDefaults(Set modules, String region) {
Fields fields = new Fields();
for (ApplicationModule module : modules) {
@@ -182,6 +190,36 @@ public class ModulesUtil {
}
}
+ public static void updateMaterialFromDefaults(Set modules, Material material) {
+ for (ApplicationModule module : modules) {
+ MaterialsView materialsView = module.getMaterialsView();
+ if (materialsView == null) {
+ continue;
+ }
+ materialsView.updateMaterialFromDefaults(material);
+ }
+ }
+
+ public static void updateGUIFromMaterial(Set modules, Material material) {
+ for (ApplicationModule module : modules) {
+ MaterialsView materialsView = module.getMaterialsView();
+ if (materialsView == null) {
+ continue;
+ }
+ materialsView.updateGUIFromMaterial(material);
+ }
+ }
+
+ public static void updateMaterialFromGUI(Set modules, Material material) {
+ for (ApplicationModule module : modules) {
+ MaterialsView materialsView = module.getMaterialsView();
+ if (materialsView == null) {
+ continue;
+ }
+ materialsView.updateMaterialFromGUI(material);
+ }
+ }
+
public static void configureFieldsInitialization(Set modules, List actions) {
for (ApplicationModule module : modules) {
FieldsInitialisationView fieldsView = module.getFieldsInitialisationView();
@@ -210,11 +248,53 @@ public class ModulesUtil {
}
}
+ public static Parser createResidualsParser(Set modules, File fileToParse) {
+ for (ApplicationModule module : modules) {
+ Parser parser = module.createResidualsParser();
+ if (parser != null) {
+ return parser;
+ }
+ }
+ return null;
+ }
+
+ public static List createParsers(Set modules) {
+ List parsers = new ArrayList<>();
+ for (ApplicationModule module : modules) {
+ List moduleParsers = module.createParsers();
+ parsers.addAll(moduleParsers);
+ }
+ return parsers;
+ }
+
+ public static List createParserViews(Set modules) {
+ List parsers = new ArrayList<>();
+ for (ApplicationModule module : modules) {
+ List moduleParsers = module.getParserViews();
+ parsers.addAll(moduleParsers);
+ }
+ return parsers;
+ }
+
+ public static void deleteUselessLogFiles(Set modules) {
+ for (ApplicationModule module : modules) {
+ module.deleteUselessLogFiles();
+ }
+ }
+
+ public static List getFieldsToBeMonitored(Set modules) {
+ List moduleFields = new ArrayList<>();
+ for (ApplicationModule module : modules) {
+ moduleFields.addAll(module.getFieldsToBeMonitored());
+ }
+ return moduleFields;
+ }
+
public static List getCellZoneTypes(Set modules) {
List moduleCellZoneTypes = new ArrayList();
for (ApplicationModule module : modules) {
CellZonesView cellZonesView = module.getCellZonesView();
- if (cellZonesView != null){
+ if (cellZonesView != null) {
moduleCellZoneTypes.addAll(cellZonesView.getCellZoneTypes());
}
}
@@ -263,13 +343,35 @@ public class ModulesUtil {
return panels;
}
- public static void updateTree(Set modules, ModuleElementPanel viewElementPanel) {
+ public static Set getSolverPanels(Set modules) {
+ Set panels = new HashSet<>();
+ for (ApplicationModule module : modules) {
+ panels.addAll(module.getSolverPanels());
+ }
+ return panels;
+ }
+
+ public static void updateCaseSetupTree(Set modules, ModuleElementPanel viewElementPanel) {
for (ApplicationModule module : modules) {
TreeView treeView = module.getTreeView();
if (treeView == null)
continue;
- treeView.updateTree(viewElementPanel);
+ treeView.updateCaseSetupTree(viewElementPanel);
}
}
+ public static void updateSolverTree(Set modules, ModuleElementPanel viewElementPanel) {
+ for (ApplicationModule module : modules) {
+ TreeView treeView = module.getTreeView();
+ if (treeView == null)
+ continue;
+ treeView.updateSolverTree(viewElementPanel);
+ }
+ }
+
+ public static void saveToBoundaryConditions(Set modules, BoundaryConditions bc) {
+ for (ApplicationModule module : modules) {
+ module.saveToBoundaryConditions(bc);
+ }
+ }
}
diff --git a/src/eu/engys/core/modules/boundaryconditions/BoundaryConditionsView.java b/src/eu/engys/core/modules/boundaryconditions/BoundaryConditionsView.java
index 4233824..13249ef 100644
--- a/src/eu/engys/core/modules/boundaryconditions/BoundaryConditionsView.java
+++ b/src/eu/engys/core/modules/boundaryconditions/BoundaryConditionsView.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.modules.boundaryconditions;
public interface BoundaryConditionsView {
diff --git a/src/eu/engys/core/modules/boundaryconditions/BoundaryTypePanel.java b/src/eu/engys/core/modules/boundaryconditions/BoundaryTypePanel.java
index cb6ea78..5bcd133 100644
--- a/src/eu/engys/core/modules/boundaryconditions/BoundaryTypePanel.java
+++ b/src/eu/engys/core/modules/boundaryconditions/BoundaryTypePanel.java
@@ -1,29 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.modules.boundaryconditions;
import java.awt.Component;
@@ -33,35 +31,36 @@ import eu.engys.core.project.zero.patches.Patch;
public interface BoundaryTypePanel {
- public static final String MOMENTUM = "Momentum";
-
- public static final String TURBULENCE = "Turbulence";
- public static final String THERMAL = "Thermal";
- public static final String PASSIVE_SCALARS = "Passive Scalars";
- public static final String PHASE_FRACTION = "Phase Fraction";
-
void layoutPanel();
-
+
void loadFromPatches(Patch... patches);
void saveToPatch(Patch patch);
BoundaryType getType();
+
Component getPanel();
ParametersPanel getMomentumPanel();
+
ParametersPanel getTurbulencePanel();
+
ParametersPanel getThermalPanel();
+
ParametersPanel getPanel(String name);
-
+
void stateChanged();
+
void materialsChanged();
void addMomentumPanel(ParametersPanel momentumPanel);
+
void addTurbulencePanel(ParametersPanel momentumPanel);
+
void addThermalPanel(ParametersPanel momentumPanel);
void addPanel(String name, ParametersPanel pPanel);
+
void addPanel(String name, ParametersPanel pPanel, int index);
void resetToDefault();
diff --git a/src/eu/engys/core/modules/boundaryconditions/IBoundaryConditionsPanel.java b/src/eu/engys/core/modules/boundaryconditions/IBoundaryConditionsPanel.java
index 81978c3..aec6c8f 100644
--- a/src/eu/engys/core/modules/boundaryconditions/IBoundaryConditionsPanel.java
+++ b/src/eu/engys/core/modules/boundaryconditions/IBoundaryConditionsPanel.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.modules.boundaryconditions;
diff --git a/src/eu/engys/core/modules/boundaryconditions/ParametersPanel.java b/src/eu/engys/core/modules/boundaryconditions/ParametersPanel.java
index bebd08b..5670611 100644
--- a/src/eu/engys/core/modules/boundaryconditions/ParametersPanel.java
+++ b/src/eu/engys/core/modules/boundaryconditions/ParametersPanel.java
@@ -1,29 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.modules.boundaryconditions;
import javax.swing.JPanel;
@@ -35,17 +33,26 @@ import eu.engys.core.project.zero.patches.BoundaryConditions;
public interface ParametersPanel {
public String getTitle();
+
public JPanel getComponent();
- public void tabChanged(Model model);
+
public void stateChanged(Model model);
+
public void materialsChanged(Model model);
+
public DictionaryModel getDictionaryModel();
-
- public void loadFromBoundaryConditions(String patchName, BoundaryConditions bc);
- public void saveToBoundaryConditions(String patchName, BoundaryConditions bc);
-
- public void setMultipleEditing(boolean multipleSelection);
- public boolean canEdit();
- public boolean isEnabled(Model model);
- public void resetToDefault(Model model);
+
+ public void loadFromBoundaryConditions(BoundaryConditions bc);
+
+ public void saveToBoundaryConditions(BoundaryConditions bc);
+
+ public void setMultipleEditing(boolean multipleSelection);
+
+ public void setPatchName(String patchName);
+
+ public boolean canEdit();
+
+ public boolean isEnabled(Model model);
+
+ public void resetToDefault(Model model);
}
diff --git a/src/eu/engys/core/modules/cellzones/CellZonePanel.java b/src/eu/engys/core/modules/cellzones/CellZonePanel.java
index 138231b..5116b16 100644
--- a/src/eu/engys/core/modules/cellzones/CellZonePanel.java
+++ b/src/eu/engys/core/modules/cellzones/CellZonePanel.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.modules.cellzones;
@@ -43,6 +42,7 @@ public interface CellZonePanel {
public static final String ORIGIN_LABEL = "Origin";
public static final String AXIS_LABEL = "Axis";
public static final String OMEGA_RAD_S_LABEL = "Omega [rad/s]";
+ public static final String NON_ROTATING_PATCHES_INSIDE_MRF_ZONE_LABEL = "Non-rotating patches inside MRF zone";
/*
* Porous
@@ -68,9 +68,9 @@ public interface CellZonePanel {
void stateChanged();
- void loadFromDictionary(Dictionary cellZoneDictionary);
+ void loadFromDictionary(String cellZoneName, Dictionary cellZoneDictionary);
- Dictionary saveToDictionary();
+ Dictionary saveToDictionary(String czName);
// Dictionary getDefault();
diff --git a/src/eu/engys/core/modules/cellzones/CellZonesView.java b/src/eu/engys/core/modules/cellzones/CellZonesView.java
index 2669ecb..aace418 100644
--- a/src/eu/engys/core/modules/cellzones/CellZonesView.java
+++ b/src/eu/engys/core/modules/cellzones/CellZonesView.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.modules.cellzones;
import java.util.List;
diff --git a/src/eu/engys/core/modules/materials/MaterialsBuilder.java b/src/eu/engys/core/modules/materials/MaterialsBuilder.java
index cd710c0..7a4d9ae 100644
--- a/src/eu/engys/core/modules/materials/MaterialsBuilder.java
+++ b/src/eu/engys/core/modules/materials/MaterialsBuilder.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.modules.materials;
@@ -31,9 +30,9 @@ import eu.engys.core.project.Model;
public interface MaterialsBuilder {
- Dictionary saveCompressible(Model model, Dictionary materialGUIDict);
+// Dictionary saveCompressible(Model model, Dictionary materialGUIDict);
- Dictionary saveIncompressible(Model model, Dictionary materialDict);
+// Dictionary saveIncompressible(Model model, Dictionary materialDict);
Dictionary toGUIFormat(Dictionary defaultMaterialDict);
diff --git a/src/eu/engys/core/modules/materials/MaterialsDatabase.java b/src/eu/engys/core/modules/materials/MaterialsDatabase.java
index 1e9dac8..105545d 100644
--- a/src/eu/engys/core/modules/materials/MaterialsDatabase.java
+++ b/src/eu/engys/core/modules/materials/MaterialsDatabase.java
@@ -1,28 +1,27 @@
-/*--------------------------------*- Java -*---------------------------------*\
- | o |
- | o o | HelyxOS: The Open Source GUI for OpenFOAM |
- | o O o | Copyright (C) 2012-2016 ENGYS |
- | o o | http://www.engys.com |
- | o | |
- |---------------------------------------------------------------------------|
- | License |
- | This file is part of HelyxOS. |
- | |
- | HelyxOS is free software; you can redistribute it and/or modify it |
- | under the terms of the GNU General Public License as published by the |
- | Free Software Foundation; either version 2 of the License, or (at your |
- | option) any later version. |
- | |
- | HelyxOS is distributed in the hope that it will be useful, but WITHOUT |
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
- | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
- | for more details. |
- | |
- | You should have received a copy of the GNU General Public License |
- | along with HelyxOS; if not, write to the Free Software Foundation, |
- | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
-\*---------------------------------------------------------------------------*/
-
+/*******************************************************************************
+ * | o |
+ * | o o | HELYX-OS: The Open Source GUI for OpenFOAM |
+ * | o O o | Copyright (C) 2012-2016 ENGYS |
+ * | o o | http://www.engys.com |
+ * | o | |
+ * |---------------------------------------------------------------------------|
+ * | License |
+ * | This file is part of HELYX-OS. |
+ * | |
+ * | HELYX-OS is free software; you can redistribute it and/or modify it |
+ * | under the terms of the GNU General Public License as published by the |
+ * | Free Software Foundation; either version 2 of the License, or (at your |
+ * | option) any later version. |
+ * | |
+ * | HELYX-OS is distributed in the hope that it will be useful, but WITHOUT |
+ * | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+ * | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
+ * | for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with HELYX-OS; if not, write to the Free Software Foundation, |
+ * | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
+ *******************************************************************************/
package eu.engys.core.modules.materials;
import java.util.Collection;
@@ -34,22 +33,25 @@ import javax.inject.Inject;
import eu.engys.core.dictionary.Dictionary;
import eu.engys.core.project.defaults.Defaults;
+import eu.engys.core.project.materials.MaterialsReader;
+import eu.engys.core.project.materials.compressible.CompressibleMaterial;
+import eu.engys.core.project.materials.incompressible.IncompressibleMaterial;
public class MaterialsDatabase {
- private Map compressibleMaterialsMap = new HashMap<>();
- private Map incompressibleMaterialsMap = new HashMap<>();
+ private Map compressibleMaterialsMap = new HashMap<>();
+ private Map incompressibleMaterialsMap = new HashMap<>();
public static final String AIR = "air";
public static final String MERCURY = "mercury";
public static final String WATER = "water";
public static final String OIL = "oil";
@Inject
- public MaterialsDatabase(Defaults defaults) {
- load(defaults);
+ public MaterialsDatabase(Defaults defaults, MaterialsReader reader) {
+ load(defaults, reader);
}
- private void load(Defaults defaults) {
+ private void load(Defaults defaults, MaterialsReader reader) {
compressibleMaterialsMap.clear();
incompressibleMaterialsMap.clear();
@@ -57,37 +59,39 @@ public class MaterialsDatabase {
Dictionary incompressibleMaterials = defaults.getIncompressibleMaterials();
for (Dictionary matDict : compressibleMaterials.getDictionaries()) {
- matDict.add("materialName", matDict.getName());
- compressibleMaterialsMap.put(matDict.getName(), matDict);
+ String name = matDict.getName();
+ matDict.add("materialName", name);
+ compressibleMaterialsMap.put(name, reader.readCompressibleMaterial(matDict));
}
for (Dictionary matDict : incompressibleMaterials.getDictionaries()) {
- matDict.add("materialName", matDict.getName());
- incompressibleMaterialsMap.put(matDict.getName(), matDict);
+ String name = matDict.getName();
+ matDict.add("materialName", name);
+ incompressibleMaterialsMap.put(name, reader.readIncompressibleMaterial(matDict));
}
}
- public Map getCompressibleMaterialsMap() {
+ public Map