/*
* The MIT License
*
* Copyright 2015 Jaafar EL Bakkali.
*
* 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 java.awt.Color;
import java.io.File;
import java.io.IOException;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;
/**
*
* @author elbakkali
*/
public class ERSNOpenMC_View_hdf5_file extends javax.swing.JFrame {
String project_full_path="",openmcdir="",cross_sectionsdir="";
/**
* Creates new form OpenMC_Options
*/
public ERSNOpenMC_View_hdf5_file() {
initComponents();
getContentPane().setBackground(new Color(0, 0, 128));
}
/**
* 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;
select_cmfd2 = new javax.swing.JCheckBox();
btn_cancel = new javax.swing.JButton();
_file_rpr = new javax.swing.JTextField();
btn_ok1 = new javax.swing.JButton();
jSeparator1 = new javax.swing.JSeparator();
jLabel1 = new javax.swing.JLabel();
btn_ok2 = new javax.swing.JButton();
select_cmfd2.setText(" geometry debugging mode");
select_cmfd2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
select_cmfd2ActionPerformed(evt);
}
});
setTitle("View .H5 file");
setType(java.awt.Window.Type.UTILITY);
getContentPane().setLayout(new java.awt.GridBagLayout());
btn_cancel.setBackground(new java.awt.Color(228, 223, 223));
btn_cancel.setForeground(java.awt.Color.darkGray);
btn_cancel.setText("Cancel");
btn_cancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_cancelActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.ipadx = 30;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(6, 0, 11, 0);
getContentPane().add(btn_cancel, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.ipadx = 389;
gridBagConstraints.ipady = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(9, 0, 2, 0);
getContentPane().add(_file_rpr, gridBagConstraints);
btn_ok1.setBackground(new java.awt.Color(231, 229, 229));
btn_ok1.setFont(new java.awt.Font("Ubuntu", 0, 10)); // NOI18N
btn_ok1.setForeground(new java.awt.Color(17, 17, 8));
btn_ok1.setText("...");
btn_ok1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_ok1ActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.ipadx = 34;
gridBagConstraints.ipady = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
gridBagConstraints.insets = new java.awt.Insets(9, 10, 3, 10);
getContentPane().add(btn_ok1, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = 6;
gridBagConstraints.ipadx = 569;
gridBagConstraints.ipady = -1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(6, 0, 10, 0);
getContentPane().add(jSeparator1, gridBagConstraints);
jLabel1.setBackground(java.awt.SystemColor.activeCaption);
jLabel1.setForeground(java.awt.SystemColor.info);
jLabel1.setText("HDF5 file : ");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.ipadx = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(14, 6, 0, 0);
getContentPane().add(jLabel1, gridBagConstraints);
btn_ok2.setBackground(new java.awt.Color(228, 223, 223));
btn_ok2.setForeground(java.awt.Color.darkGray);
btn_ok2.setText("View");
btn_ok2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_ok2ActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.ipadx = 44;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(5, 214, 0, 0);
getContentPane().add(btn_ok2, gridBagConstraints);
pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
private void select_cmfd2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_select_cmfd2ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_select_cmfd2ActionPerformed
private void btn_cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_cancelActionPerformed
// TODO add your handling code here:
this.show(false);
}//GEN-LAST:event_btn_cancelActionPerformed
private void btn_ok1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_ok1ActionPerformed
String p_file="";
JFileChooser fc = new JFileChooser();
FileNameExtensionFilter ppmfilter = new FileNameExtensionFilter("HDF5 files (*.h5)", "h5");
fc.setFileFilter(ppmfilter);
fc.setDialogTitle("Open an hdf5 file");
ERSNOpenMC_Singleton tmp = ERSNOpenMC_Singleton.getInstance();
project_full_path=tmp.getPath();
java.io.File dir = new File(project_full_path);
fc.setCurrentDirectory(dir);
fc.setFileSelectionMode( JFileChooser.FILES_ONLY);
int returnVal = fc.showOpenDialog(this);
if (returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {
java.io.File file = fc.getSelectedFile( );
p_file= file.toString( );
_file_rpr.setText(p_file);
}
}//GEN-LAST:event_btn_ok1ActionPerformed
private void btn_ok2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_ok2ActionPerformed
try {
Process pb =Runtime.getRuntime().exec("xterm -j -sb -title ERSN-OpenMC_Console -sl 6000 -hold -e /opt/hdf5/bin/h5dump "+_file_rpr.getText().toString());
pb.waitFor();
} catch (IOException ex) {
System.out.print(ex);
}
catch (InterruptedException ex) {System.out.print(ex);}
}//GEN-LAST:event_btn_ok2ActionPerformed
/**
* @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 ex) {
java.util.logging.Logger.getLogger(ERSNOpenMC_View_hdf5_file.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ERSNOpenMC_View_hdf5_file.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ERSNOpenMC_View_hdf5_file.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ERSNOpenMC_View_hdf5_file.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
//</editor-fold>
//</editor-fold>
//</editor-fold>
//</editor-fold>
//</editor-fold>
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ERSNOpenMC_View_hdf5_file().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField _file_rpr;
private javax.swing.JButton btn_cancel;
private javax.swing.JButton btn_ok1;
private javax.swing.JButton btn_ok2;
private javax.swing.JLabel jLabel1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JCheckBox select_cmfd2;
// End of variables declaration//GEN-END:variables
}