/*
* The MIT License
*
* Copyright 2015-2017 Jaafar EL Bakkali & Tarek El Bardouni.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package ersn.openmc;
import static ersn.openmc.ERSNOpenMC_Main.getJarContainingFolder;
import java.awt.Color;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
/**
*
* @author Jaafar EL Bakkali & Tarek El Bardouni
*/
public class ERSNOpenMC_Get_OpenMC extends javax.swing.JFrame {
String str_cmake = " cmake ",
str_gfortran = " gfortran ",
str_git = " git ",
str_eog = " eog ",
str_mutt = " ",
str_mpich2 = " ",
str_openmpi = " ",
str_openmp_status = "NOT_USED",
str_debug_status = "NOT_USED",
str_matplotlib = " ",
str_vtk = " ",
str_paraview = " ",
str_numpy = " ",
str_scipy = " ",
str_gedit = " ",
str_ipython = " ";
Boolean parallel_mode = false;
String bashdir_openmc = "";
String bashdir_hdf5 = "",
str_python_5py = "",
str_python_pandas = "";
private Object _mutt_;
/**
* Creates new form get_libraries
*/
public ERSNOpenMC_Get_OpenMC() {
initComponents();
// getContentPane().setBackground(new Color(0, 0, 128));
buttonGroup1.add(_SEQ_MODE);
buttonGroup1.add(DISTRIB_OpenMPI_MODE);
buttonGroup1.add(DISTRIB_MODE);
buttonGroup1.add(_OPENMP_MODE);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
buttonGroup1 = new javax.swing.ButtonGroup();
buttonGroup2 = new javax.swing.ButtonGroup();
buttonGroup3 = new javax.swing.ButtonGroup();
buttonGroup4 = new javax.swing.ButtonGroup();
buttonGroup5 = new javax.swing.ButtonGroup();
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
btn_get_prerequisites = new javax.swing.JButton();
_gfortran_ = new javax.swing.JCheckBox();
_cmake_ = new javax.swing.JCheckBox();
_mpich2_ = new javax.swing.JCheckBox();
jSeparator1 = new javax.swing.JSeparator();
_openmpi_ = new javax.swing.JCheckBox();
_git_ = new javax.swing.JCheckBox();
_eog_ = new javax.swing.JCheckBox();
_matplotlib_ = new javax.swing.JCheckBox();
_vtk_ = new javax.swing.JCheckBox();
jSeparator2 = new javax.swing.JSeparator();
_paraview_ = new javax.swing.JCheckBox();
_numpy_ = new javax.swing.JCheckBox();
_scipy_ = new javax.swing.JCheckBox();
_ipython_ = new javax.swing.JCheckBox();
_hdf5_ = new javax.swing.JCheckBox();
pandas = new javax.swing.JCheckBox();
_petsc_2 = new javax.swing.JCheckBox();
btn_close2 = new javax.swing.JButton();
_mutt1_ = new javax.swing.JCheckBox();
h5py1 = new javax.swing.JCheckBox();
jLabel2 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
btn_get_openmc = new javax.swing.JButton();
lbl_dir = new javax.swing.JLabel();
btn_dir = new javax.swing.JButton();
install_dir = new javax.swing.JTextField();
jSeparator4 = new javax.swing.JSeparator();
_SEQ_MODE = new javax.swing.JRadioButton();
DISTRIB_OpenMPI_MODE = new javax.swing.JRadioButton();
DISTRIB_MODE = new javax.swing.JRadioButton();
jCheckBox_openmp = new javax.swing.JCheckBox();
jLabel1 = new javax.swing.JLabel();
btn_close1 = new javax.swing.JButton();
jSeparator7 = new javax.swing.JSeparator();
jSeparator8 = new javax.swing.JSeparator();
jCheckBox_Debug = new javax.swing.JCheckBox();
_OPENMP_MODE = new javax.swing.JRadioButton();
jLabel3 = new javax.swing.JLabel();
jSeparator3 = new javax.swing.JSeparator();
setTitle("ERSN-OpenMC_get_OpenMC");
getContentPane().setLayout(new java.awt.GridBagLayout());
jTabbedPane1.setPreferredSize(new java.awt.Dimension(1100, 326));
jTabbedPane1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jTabbedPane1MouseClicked(evt);
}
});
jPanel1.setBackground(java.awt.SystemColor.activeCaption);
jPanel1.setMinimumSize(new java.awt.Dimension(1500, 300));
jPanel1.setPreferredSize(new java.awt.Dimension(1500, 258));
jPanel1.setLayout(null);
btn_get_prerequisites.setFont(new java.awt.Font("Ubuntu", 0, 13)); // NOI18N
btn_get_prerequisites.setForeground(java.awt.Color.black);
btn_get_prerequisites.setText("Get Prerequisites");
btn_get_prerequisites.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
btn_get_prerequisites.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
btn_get_prerequisites.setMaximumSize(new java.awt.Dimension(91, 28));
btn_get_prerequisites.setMinimumSize(new java.awt.Dimension(91, 28));
btn_get_prerequisites.setPreferredSize(new java.awt.Dimension(91, 28));
btn_get_prerequisites.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_get_prerequisitesActionPerformed(evt);
}
});
jPanel1.add(btn_get_prerequisites);
btn_get_prerequisites.setBounds(520, 260, 141, 28);
_gfortran_.setBackground(java.awt.SystemColor.activeCaption);
_gfortran_.setFont(new java.awt.Font("Ubuntu Light", 0, 12)); // NOI18N
_gfortran_.setForeground(java.awt.Color.yellow);
_gfortran_.setSelected(true);
_gfortran_.setText("gfortran: the GNU Fortran compiler.");
_gfortran_.setEnabled(false);
_gfortran_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
_gfortran_ActionPerformed(evt);
}
});
jPanel1.add(_gfortran_);
_gfortran_.setBounds(0, 40, 410, 20);
_cmake_.setBackground(java.awt.SystemColor.activeCaption);
_cmake_.setFont(new java.awt.Font("Ubuntu Light", 0, 12)); // NOI18N
_cmake_.setForeground(java.awt.Color.yellow);
_cmake_.setSelected(true);
_cmake_.setText("cmake: a cross-platform and open-source build system.");
_cmake_.setEnabled(false);
jPanel1.add(_cmake_);
_cmake_.setBounds(0, 20, 390, 20);
_mpich2_.setBackground(java.awt.SystemColor.activeCaption);
_mpich2_.setFont(new java.awt.Font("Ubuntu", 0, 12)); // NOI18N
_mpich2_.setForeground(java.awt.Color.yellow);
_mpich2_.setText("MPICH: a standard for Message-Passing Interface (distributed-memory).");
_mpich2_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
_mpich2_ActionPerformed(evt);
}
});
jPanel1.add(_mpich2_);
_mpich2_.setBounds(0, 210, 490, 25);
jPanel1.add(jSeparator1);
jSeparator1.setBounds(0, 0, 0, 0);
_openmpi_.setBackground(java.awt.SystemColor.activeCaption);
_openmpi_.setFont(new java.awt.Font("Ubuntu", 0, 12)); // NOI18N
_openmpi_.setForeground(java.awt.Color.yellow);
_openmpi_.setText("OPENMPI: Open Source High Performance Computing shared memory (distributed-memory).");
_openmpi_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
_openmpi_ActionPerformed(evt);
}
});
jPanel1.add(_openmpi_);
_openmpi_.setBounds(0, 190, 550, 25);
_git_.setBackground(java.awt.SystemColor.activeCaption);
_git_.setFont(new java.awt.Font("Ubuntu Light", 0, 12)); // NOI18N
_git_.setForeground(java.awt.Color.yellow);
_git_.setSelected(true);
_git_.setText("git : a distributed revision control system.");
_git_.setEnabled(false);
jPanel1.add(_git_);
_git_.setBounds(0, 60, 440, 20);
_eog_.setBackground(java.awt.SystemColor.activeCaption);
_eog_.setFont(new java.awt.Font("Ubuntu Light", 0, 12)); // NOI18N
_eog_.setForeground(java.awt.Color.yellow);
_eog_.setSelected(true);
_eog_.setText("eog: Eye of Gnome, a graphics viewer program.");
_eog_.setEnabled(false);
_eog_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
_eog_ActionPerformed(evt);
}
});
jPanel1.add(_eog_);
_eog_.setBounds(0, 80, 510, 20);
_matplotlib_.setBackground(java.awt.SystemColor.activeCaption);
_matplotlib_.setFont(new java.awt.Font("Ubuntu", 0, 12)); // NOI18N
_matplotlib_.setForeground(new java.awt.Color(255, 255, 0));
_matplotlib_.setText("matplotlib : a python 2D plotting library.");
_matplotlib_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
_matplotlib_ActionPerformed(evt);
}
});
jPanel1.add(_matplotlib_);
_matplotlib_.setBounds(590, 130, 471, 25);
_vtk_.setBackground(java.awt.SystemColor.activeCaption);
_vtk_.setFont(new java.awt.Font("Ubuntu", 0, 12)); // NOI18N
_vtk_.setForeground(new java.awt.Color(255, 255, 0));
_vtk_.setText("VTK : The Visualization Toolkit.");
_vtk_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
_vtk_ActionPerformed(evt);
}
});
jPanel1.add(_vtk_);
_vtk_.setBounds(590, 160, 410, 25);
jPanel1.add(jSeparator2);
jSeparator2.setBounds(0, 250, 1480, 10);
_paraview_.setBackground(java.awt.SystemColor.activeCaption);
_paraview_.setFont(new java.awt.Font("Ubuntu", 0, 12)); // NOI18N
_paraview_.setForeground(new java.awt.Color(255, 255, 0));
_paraview_.setText("ParaView : an open-source data analysis and visualization application.");
_paraview_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
_paraview_ActionPerformed(evt);
}
});
jPanel1.add(_paraview_);
_paraview_.setBounds(590, 10, 642, 25);
_numpy_.setBackground(java.awt.SystemColor.activeCaption);
_numpy_.setFont(new java.awt.Font("Ubuntu", 0, 12)); // NOI18N
_numpy_.setForeground(new java.awt.Color(255, 255, 0));
_numpy_.setText("NumPy : the fundamental package for scientific computing with Python.");
_numpy_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
_numpy_ActionPerformed(evt);
}
});
jPanel1.add(_numpy_);
_numpy_.setBounds(590, 40, 710, 25);
_scipy_.setBackground(java.awt.SystemColor.activeCaption);
_scipy_.setFont(new java.awt.Font("Ubuntu", 0, 12)); // NOI18N
_scipy_.setForeground(new java.awt.Color(255, 255, 0));
_scipy_.setText("SciPy: a package of tools for science and engineering for Python.");
_scipy_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
_scipy_ActionPerformed(evt);
}
});
jPanel1.add(_scipy_);
_scipy_.setBounds(590, 70, 618, 25);
_ipython_.setBackground(java.awt.SystemColor.activeCaption);
_ipython_.setFont(new java.awt.Font("Ubuntu", 0, 12)); // NOI18N
_ipython_.setForeground(new java.awt.Color(255, 255, 0));
_ipython_.setText("IPython: interactive computing in Python.");
_ipython_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
_ipython_ActionPerformed(evt);
}
});
jPanel1.add(_ipython_);
_ipython_.setBounds(590, 100, 477, 25);
_hdf5_.setBackground(java.awt.SystemColor.activeCaption);
_hdf5_.setFont(new java.awt.Font("Ubuntu Light", 0, 12)); // NOI18N
_hdf5_.setForeground(java.awt.Color.yellow);
_hdf5_.setSelected(true);
_hdf5_.setText("hdf5: a file format for storing and managing data.");
_hdf5_.setEnabled(false);
_hdf5_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
_hdf5_ActionPerformed(evt);
}
});
jPanel1.add(_hdf5_);
_hdf5_.setBounds(0, 100, 390, 20);
pandas.setBackground(java.awt.SystemColor.activeCaption);
pandas.setFont(new java.awt.Font("Ubuntu", 0, 12)); // NOI18N
pandas.setForeground(new java.awt.Color(255, 255, 0));
pandas.setText("pandas: Python Data Analysis Library");
pandas.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pandasActionPerformed(evt);
}
});
jPanel1.add(pandas);
pandas.setBounds(590, 220, 581, 25);
_petsc_2.setBackground(java.awt.SystemColor.activeCaption);
_petsc_2.setFont(new java.awt.Font("Ubuntu Light", 0, 12)); // NOI18N
_petsc_2.setForeground(java.awt.Color.yellow);
_petsc_2.setSelected(true);
_petsc_2.setText("gedit : Text Editor.");
_petsc_2.setEnabled(false);
jPanel1.add(_petsc_2);
_petsc_2.setBounds(0, 120, 470, 20);
btn_close2.setFont(new java.awt.Font("Ubuntu", 0, 13)); // NOI18N
btn_close2.setForeground(java.awt.Color.black);
btn_close2.setText("close");
btn_close2.setMaximumSize(new java.awt.Dimension(100, 28));
btn_close2.setMinimumSize(new java.awt.Dimension(80, 30));
btn_close2.setPreferredSize(new java.awt.Dimension(165, 28));
btn_close2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_close2ActionPerformed(evt);
}
});
jPanel1.add(btn_close2);
btn_close2.setBounds(910, 260, 165, 28);
_mutt1_.setBackground(java.awt.SystemColor.activeCaption);
_mutt1_.setFont(new java.awt.Font("Ubuntu Light", 0, 12)); // NOI18N
_mutt1_.setForeground(java.awt.Color.yellow);
_mutt1_.setText("mutt: email sender");
_mutt1_.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
_mutt1_ActionPerformed(evt);
}
});
jPanel1.add(_mutt1_);
_mutt1_.setBounds(0, 140, 460, 20);
h5py1.setBackground(java.awt.SystemColor.activeCaption);
h5py1.setFont(new java.awt.Font("Ubuntu", 0, 12)); // NOI18N
h5py1.setForeground(new java.awt.Color(255, 255, 0));
h5py1.setText("h5py: a Pythonic interface to the HDF5 binary data format.");
h5py1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
h5py1ActionPerformed(evt);
}
});
jPanel1.add(h5py1);
h5py1.setBounds(590, 190, 581, 25);
jLabel2.setFont(new java.awt.Font("Ubuntu", 2, 12)); // NOI18N
jLabel2.setForeground(new java.awt.Color(250, 255, 0));
jLabel2.setText("Check one package at a time !");
jPanel1.add(jLabel2);
jLabel2.setBounds(20, 260, 250, 15);
jTabbedPane1.addTab("Prerequisites", jPanel1);
jPanel2.setBackground(java.awt.SystemColor.activeCaption);
jPanel2.setPreferredSize(new java.awt.Dimension(1200, 290));
btn_get_openmc.setForeground(java.awt.Color.black);
btn_get_openmc.setText("Get OpenMC");
btn_get_openmc.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_get_openmcActionPerformed(evt);
}
});
lbl_dir.setBackground(java.awt.SystemColor.activeCaption);
lbl_dir.setForeground(java.awt.Color.yellow);
lbl_dir.setText("Choose your install dir");
btn_dir.setText("...");
btn_dir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_dirActionPerformed(evt);
}
});
install_dir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
install_dirActionPerformed(evt);
}
});
_SEQ_MODE.setBackground(java.awt.SystemColor.activeCaption);
_SEQ_MODE.setForeground(java.awt.Color.yellow);
_SEQ_MODE.setText("Sequential mode");
_SEQ_MODE.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
_SEQ_MODEActionPerformed(evt);
}
});
DISTRIB_OpenMPI_MODE.setBackground(java.awt.SystemColor.activeCaption);
DISTRIB_OpenMPI_MODE.setForeground(java.awt.Color.yellow);
DISTRIB_OpenMPI_MODE.setText("Distributed memory OPENMPI mode");
DISTRIB_OpenMPI_MODE.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DISTRIB_OpenMPI_MODEActionPerformed(evt);
}
});
DISTRIB_MODE.setBackground(java.awt.SystemColor.activeCaption);
DISTRIB_MODE.setForeground(java.awt.Color.yellow);
DISTRIB_MODE.setText("Distributed memory MPICH mode");
DISTRIB_MODE.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DISTRIB_MODEActionPerformed(evt);
}
});
jCheckBox_openmp.setBackground(java.awt.SystemColor.activeCaption);
jCheckBox_openmp.setForeground(java.awt.Color.yellow);
jCheckBox_openmp.setText("Shared Memory can be used in hybrid mode OPENMP-MPI");
jCheckBox_openmp.setEnabled(false);
jCheckBox_openmp.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jCheckBox_openmpMouseClicked(evt);
}
});
jCheckBox_openmp.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox_openmpActionPerformed(evt);
}
});
jLabel1.setBackground(java.awt.SystemColor.info);
jLabel1.setFont(new java.awt.Font("Ubuntu", 0, 14)); // NOI18N
jLabel1.setForeground(java.awt.Color.white);
jLabel1.setText("The OpenMC Monte Carlo code will be compiled with one of the following four mode :");
btn_close1.setForeground(java.awt.Color.black);
btn_close1.setText("close");
btn_close1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_close1ActionPerformed(evt);
}
});
jCheckBox_Debug.setBackground(java.awt.SystemColor.activeCaption);
jCheckBox_Debug.setForeground(java.awt.Color.yellow);
jCheckBox_Debug.setText("Debug mode");
jCheckBox_Debug.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jCheckBox_DebugMouseClicked(evt);
}
});
jCheckBox_Debug.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox_DebugActionPerformed(evt);
}
});
_OPENMP_MODE.setBackground(java.awt.SystemColor.activeCaption);
_OPENMP_MODE.setForeground(java.awt.Color.yellow);
_OPENMP_MODE.setText("Enable shared-memory parallelism with OpenMP");
_OPENMP_MODE.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
_OPENMP_MODEActionPerformed(evt);
}
});
jLabel3.setFont(new java.awt.Font("Ubuntu", 2, 12)); // NOI18N
jLabel3.setForeground(new java.awt.Color(254, 252, 1));
jLabel3.setText("Check one mode at least !");
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSeparator8, javax.swing.GroupLayout.PREFERRED_SIZE, 1089, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSeparator7, javax.swing.GroupLayout.PREFERRED_SIZE, 1086, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(682, 682, 682)
.addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 1192, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(43, 43, 43)
.addComponent(jLabel3)
.addGap(260, 260, 260)
.addComponent(btn_get_openmc, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(315, 315, 315)
.addComponent(btn_close1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(DISTRIB_MODE)
.addComponent(DISTRIB_OpenMPI_MODE)
.addComponent(_OPENMP_MODE)
.addComponent(_SEQ_MODE)
.addComponent(jLabel1)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(lbl_dir)
.addGap(31, 31, 31)
.addComponent(install_dir, javax.swing.GroupLayout.PREFERRED_SIZE, 701, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30)
.addComponent(btn_dir, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jCheckBox_openmp)
.addGap(191, 191, 191)
.addComponent(jCheckBox_Debug)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addGap(13, 13, 13)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(install_dir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbl_dir)
.addComponent(btn_dir))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(88, 88, 88)
.addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(20, 20, 20))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(_SEQ_MODE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(_OPENMP_MODE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addComponent(DISTRIB_OpenMPI_MODE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(DISTRIB_MODE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator7, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jCheckBox_openmp)
.addComponent(jCheckBox_Debug))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator8, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(8, 8, 8)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btn_get_openmc)
.addComponent(btn_close1)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel3)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jTabbedPane1.addTab("OpenMC", jPanel2);
getContentPane().add(jTabbedPane1, new java.awt.GridBagConstraints());
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
getContentPane().add(jSeparator3, gridBagConstraints);
pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
private void btn_get_openmcActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_get_openmcActionPerformed
System.out.print("ERSN-OPENMC/CONSOLE:-------INSTALLING OPENMC MONTE CARLO CODE.");
try {
Process pb = Runtime.getRuntime().exec("xterm -j -sb -sl 2000 -title ERSN-OpenMC_Console -e "
+ bashdir_openmc + " " + install_dir.getText() + " " + str_debug_status + " " + str_openmp_status );
pb.waitFor();
JOptionPane.showMessageDialog(this, "The OpenMC Monte Carlo code has been installed");
} catch (IOException | InterruptedException ex) {
System.out.print(ex);
}
save_openmcdir_file(install_dir.getText());
save_scriptsdir_file(install_dir.getText());
save_cross_sectiondir_file(install_dir.getText());
}//GEN-LAST:event_btn_get_openmcActionPerformed
public void get_prerequisites() {
try {
bashdir_hdf5 = getJarContainingFolder(ERSNOpenMC_Main.class) + "/scripts/get_hdf5.sh";
} catch (Exception ex) {
System.out.print(ex);
}
try {
Process pb = Runtime.getRuntime().exec("xterm -title ERSN-OpenMC_Console -e sudo apt-get install "
+ str_cmake + str_gfortran + str_git + str_eog + str_mutt + str_gedit
+ str_matplotlib + str_vtk + str_paraview + str_scipy + str_numpy + str_ipython + str_python_5py + str_python_pandas
+ str_mpich2 + str_openmpi);
pb.waitFor();
JOptionPane.showMessageDialog(this, "The checked packages have been installed successfully or already exist ! ");
File f = new File("/opt/hdf5");
if (f.exists() && f.isDirectory()) {
System.out.println(" The HDF5 package is already installed in your OS");
} else {
Process pb3 = Runtime.getRuntime().exec("xterm -title ERSN-OpenMC_Console -e " + bashdir_hdf5);
pb3.waitFor();
JOptionPane.showMessageDialog(this, "The HDF5 package packages has been installed successfully ");
}
} catch (IOException | InterruptedException ex) {
System.out.print(ex);
}
}
public void get_ERSMOpenMC_Config(String openmc_path,String openmc_target, String ersnopenmc_config_file)
{
try {
FileWriter lu = new FileWriter(getJarContainingFolder(ERSNOpenMC_Main.class) + ersnopenmc_config_file);// Créer un objet java.io.FileWriter avec comme argument le mon du fichier dans lequel enregsitrer
try (BufferedWriter fluxS = new BufferedWriter(lu) // Mettre le flux en tampon (en cache)
) {
fluxS.write(openmc_path + openmc_target); //Balancer dans le flux le contenu de la zone de texte
fluxS.close(); // Fermer le flux (c’est toujours mieux de le fermer explicitement)
} //Balancer dans le flux le contenu de la zone de texte
} catch (Exception er) {
}
}
public void save_openmcdir_file(String openmc_path) {
get_ERSMOpenMC_Config(openmc_path, "/openmc/build/bin/openmc", "/config/openmc.dir");
}
public void save_scriptsdir_file(String openmc_path) {
get_ERSMOpenMC_Config(openmc_path, "/openmc/scripts", "/config/scripts.dir");
}
public void save_cross_sectiondir_file(String openmc_path) {
get_ERSMOpenMC_Config(openmc_path,"/openmc/data/nndc/cross_sections.xml", "/config/cross_sections.dir");
}
private void btn_get_prerequisitesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_get_prerequisitesActionPerformed
// Get ALL Prerequisites packages selected by the user.
get_prerequisites();
}//GEN-LAST:event_btn_get_prerequisitesActionPerformed
private void btn_dirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_dirActionPerformed
// Open an existing OpenMC Project
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Open an existing OpenMC project");
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = fc.showOpenDialog(this);
if (returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {
java.io.File file = fc.getSelectedFile();
install_dir.setText(file.toString());
ERSNOpenMC_Singleton singleton = ERSNOpenMC_Singleton.getInstance();
singleton.setOpenMCPath(install_dir.getText());
save_openmcdir_file(file.toString());
}//GEN-LAST:event_btn_dirActionPerformed
}
private void _mpich2_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mpich2_ActionPerformed
if (_mpich2_.isSelected() == true) {
str_mpich2 = " mpich libmpich-dev ";
parallel_mode = true;
} else {
str_mpich2 = " ";
parallel_mode = false;
}
}//GEN-LAST:event__mpich2_ActionPerformed
private void _matplotlib_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__matplotlib_ActionPerformed
if (_matplotlib_.isSelected() == true) {
str_matplotlib = " python-matplotlib ";
} else {
str_matplotlib = " ";
}
}//GEN-LAST:event__matplotlib_ActionPerformed
private void _vtk_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__vtk_ActionPerformed
str_vtk = " python-vtk ";
if (_vtk_.isSelected() == true) {
str_vtk = " python-vtk ";
} else {
str_vtk = " ";
}
}//GEN-LAST:event__vtk_ActionPerformed
private void _paraview_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__paraview_ActionPerformed
if (_paraview_.isSelected() == true) {
str_paraview = " paraview ";
} else {
str_paraview = " ";
}
}//GEN-LAST:event__paraview_ActionPerformed
private void _numpy_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__numpy_ActionPerformed
if (_numpy_.isSelected() == true) {
str_numpy = " python-numpy ";
} else {
str_numpy = " ";
}
}//GEN-LAST:event__numpy_ActionPerformed
private void _scipy_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__scipy_ActionPerformed
if (_scipy_.isSelected() == true) {
str_scipy = " python-scipy ";
} else {
str_scipy = " ";
}
}//GEN-LAST:event__scipy_ActionPerformed
private void _ipython_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__ipython_ActionPerformed
if (_ipython_.isSelected() == true) {
str_ipython = " ipython ";
}
else
{
str_ipython=" " ; }//GEN-LAST:event__ipython_ActionPerformed
}
private void _SEQ_MODEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__SEQ_MODEActionPerformed
jCheckBox_openmp.setEnabled(false);
try {
bashdir_openmc = getJarContainingFolder(ERSNOpenMC_Main.class) + "/scripts/get_openmc.sh"; //load bash file for sequentiel application.
} catch (Exception ex) {
System.out.print(ex);
}
}//GEN-LAST:event__SEQ_MODEActionPerformed
private void DISTRIB_OpenMPI_MODEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DISTRIB_OpenMPI_MODEActionPerformed
jCheckBox_openmp.setEnabled(true);
try {
bashdir_openmc = getJarContainingFolder(ERSNOpenMC_Main.class) + "/scripts/get_openmc-with-openmpi.sh"; // load bash file for shared memory application.
} catch (Exception ex) {
System.out.print(ex);
}
}//GEN-LAST:event_DISTRIB_OpenMPI_MODEActionPerformed
private void DISTRIB_MODEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DISTRIB_MODEActionPerformed
jCheckBox_openmp.setEnabled(true);
try {
bashdir_openmc = getJarContainingFolder(ERSNOpenMC_Main.class) + "/scripts/get_openmc-with-mpich2.sh"; // load bash file for distributed memory application.
} catch (Exception ex) {
System.out.print(ex);
}
}//GEN-LAST:event_DISTRIB_MODEActionPerformed
private void pandasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pandasActionPerformed
str_python_pandas = " python-pandas ";
}//GEN-LAST:event_pandasActionPerformed
private void jCheckBox_openmpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox_openmpActionPerformed
if (jCheckBox_openmp.isSelected() == true) {
str_openmp_status = "USED";
}
else {
str_openmp_status = "NOT-USED";
}
System.out.print("ERSN-OPENMC/CONSOLE " + str_openmp_status);
}//GEN-LAST:event_jCheckBox_openmpActionPerformed
private void jTabbedPane1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPane1MouseClicked
System.out.print("ERSN-OPENMC/CONSOLE:-------OPENMP mode: " + str_openmp_status);
}//GEN-LAST:event_jTabbedPane1MouseClicked
private void jCheckBox_openmpMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jCheckBox_openmpMouseClicked
str_openmp_status = "USED";
}//GEN-LAST:event_jCheckBox_openmpMouseClicked
private void btn_close1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_close1ActionPerformed
this.show(false);
}//GEN-LAST:event_btn_close1ActionPerformed
private void btn_close2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_close2ActionPerformed
this.show(false);
}//GEN-LAST:event_btn_close2ActionPerformed
private void _openmpi_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__openmpi_ActionPerformed
if (_openmpi_.isSelected() == true) {
str_openmpi = " openmpi-bin libopenmpi1.6 libopenmpi-dev";
parallel_mode = true;
} else {
str_openmpi = " ";
parallel_mode = false;
}
}//GEN-LAST:event__openmpi_ActionPerformed
private void _gfortran_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__gfortran_ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event__gfortran_ActionPerformed
private void _eog_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__eog_ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event__eog_ActionPerformed
private void _hdf5_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__hdf5_ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event__hdf5_ActionPerformed
private void jCheckBox_DebugMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jCheckBox_DebugMouseClicked
str_debug_status = "USED";
}//GEN-LAST:event_jCheckBox_DebugMouseClicked
private void jCheckBox_DebugActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox_DebugActionPerformed
if (jCheckBox_Debug.isSelected() == true) {
str_debug_status = "USED";
}
if (jCheckBox_Debug.isSelected() == false) {
str_debug_status = "NOT-USED";
}
System.out.print("ERSN-OPENMC/CONSOLE :-------DEBUG mode:" + str_debug_status);
}//GEN-LAST:event_jCheckBox_DebugActionPerformed
private void install_dirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_install_dirActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_install_dirActionPerformed
private void _mutt1_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mutt1_ActionPerformed
if (_mutt1_.isSelected() == true) {
str_mutt = " mutt ";
} else {
str_mutt = " ";
}
}//GEN-LAST:event__mutt1_ActionPerformed
private void _OPENMP_MODEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__OPENMP_MODEActionPerformed
// jCheckBox_openmp.setEnabled(false);
str_openmp_status = "USED";
try {
bashdir_openmc = getJarContainingFolder(ERSNOpenMC_Main.class) + "/scripts/get_openmc-with-openmp.sh"; //load bash file for sequentiel application.
} catch (Exception ex) {
System.out.print(ex);
}
}//GEN-LAST:event__OPENMP_MODEActionPerformed
private void h5py1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_h5py1ActionPerformed
str_python_5py = " python-h5py ";
}//GEN-LAST:event_h5py1ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ERSNOpenMC_Get_OpenMC.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new ERSNOpenMC_Get_OpenMC().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JRadioButton DISTRIB_MODE;
private javax.swing.JRadioButton DISTRIB_OpenMPI_MODE;
private javax.swing.JRadioButton _OPENMP_MODE;
private javax.swing.JRadioButton _SEQ_MODE;
private javax.swing.JCheckBox _cmake_;
private javax.swing.JCheckBox _eog_;
private javax.swing.JCheckBox _gfortran_;
private javax.swing.JCheckBox _git_;
private javax.swing.JCheckBox _hdf5_;
private javax.swing.JCheckBox _ipython_;
private javax.swing.JCheckBox _matplotlib_;
private javax.swing.JCheckBox _mpich2_;
private javax.swing.JCheckBox _mutt1_;
private javax.swing.JCheckBox _numpy_;
private javax.swing.JCheckBox _openmpi_;
private javax.swing.JCheckBox _paraview_;
private javax.swing.JCheckBox _petsc_2;
private javax.swing.JCheckBox _scipy_;
private javax.swing.JCheckBox _vtk_;
private javax.swing.JButton btn_close1;
private javax.swing.JButton btn_close2;
private javax.swing.JButton btn_dir;
private javax.swing.JButton btn_get_openmc;
private javax.swing.JButton btn_get_prerequisites;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.ButtonGroup buttonGroup2;
private javax.swing.ButtonGroup buttonGroup3;
private javax.swing.ButtonGroup buttonGroup4;
private javax.swing.ButtonGroup buttonGroup5;
private javax.swing.JCheckBox h5py1;
private javax.swing.JTextField install_dir;
private javax.swing.JCheckBox jCheckBox_Debug;
private javax.swing.JCheckBox jCheckBox_openmp;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JSeparator jSeparator3;
private javax.swing.JSeparator jSeparator4;
private javax.swing.JSeparator jSeparator7;
private javax.swing.JSeparator jSeparator8;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JLabel lbl_dir;
private javax.swing.JCheckBox pandas;
// End of variables declaration//GEN-END:variables
}