Commit 455f37d2 authored by pfreon's avatar pfreon
Browse files

Addition of access to csv & txt data files + sub-menu "Getting started"

Addition of a sub-menu "Getting started" in the main menu "Help".
Addition of access to csv & txt data files in the main menu "Files".
parent f8ae80d5
......@@ -27,6 +27,7 @@ public class CadreMain extends JFrame {
JMenu menuHelp = new JMenu();
JMenuItem menuHelpAbout = new JMenuItem();
JMenuItem menuHelpReferences = new JMenuItem();
JMenuItem menuHelpHowTo = new JMenuItem();
JMenuItem menuFileOpen = new JMenuItem();
JMenuItem menuFileCreate = new JMenuItem();
JMenuItem menuFileFolder = new JMenuItem();
......@@ -170,16 +171,17 @@ public class CadreMain extends JFrame {
});
menuHelp.setText("Help");
menuHelp.setMnemonic(KeyEvent.VK_H);
menuHelpAbout.setText("About");
menuHelpAbout.setMnemonic(KeyEvent.VK_A);
menuHelpAbout.addActionListener(new ActionListener() {
menuHelpHowTo.setText("Getting started");
menuHelpHowTo.setMnemonic(KeyEvent.VK_S);
menuHelpHowTo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
helpAbout_actionPerformed(e);
helpHowTo_actionPerformed(e);
}
});
});
menuHelpReferences.setText("References");
menuHelpReferences.setMnemonic(KeyEvent.VK_R);
menuHelpReferences.addActionListener(new ActionListener() {
......@@ -188,9 +190,19 @@ public class CadreMain extends JFrame {
public void actionPerformed(ActionEvent e) {
helpReferences_actionPerformed(e);
}
});
});
menuFileOpen.setText("Open");
menuHelpAbout.setText("About");
menuHelpAbout.setMnemonic(KeyEvent.VK_A);
menuHelpAbout.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
helpAbout_actionPerformed(e);
}
});
menuFileOpen.setText("Open (*.CLI, *.csv, *.txt)");
menuFileOpen.setMnemonic(KeyEvent.VK_O);
menuFileOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,InputEvent.CTRL_DOWN_MASK));
menuFileOpen.addActionListener(new java.awt.event.ActionListener() {
......@@ -403,8 +415,9 @@ public class CadreMain extends JFrame {
menuFile.add(menuFileFolder);
menuFile.add(menuFileOpenFolder);
menuHelp.add(menuHelpAbout);
menuHelp.add(menuHelpHowTo);
menuHelp.add(menuHelpReferences);
menuHelp.add(menuHelpAbout);
menuBar1.add(menuFile);
menuBar1.add(menuModels);
menuBar1.add(menuPlots);
......@@ -484,6 +497,18 @@ public class CadreMain extends JFrame {
dlg.setVisible(true);
}
public void helpHowTo_actionPerformed(ActionEvent e) {
CadreMain_HowToBox dlg = new CadreMain_HowToBox(this);
Dimension dlgSize = dlg.getPreferredSize();
Dimension frmSize = getSize();
Point loc = getLocation();
dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
//System.out.println("Dans CadreMain.java ligne 441 fenêtre Help de Menu principal frmSize.width = " + frmSize.width + " dlgSize.width = " + dlgSize.width + " frmSize.height = " + frmSize.height + " dlgSize.height = " + dlgSize.height);
dlg.setModal(true);
dlg.setVisible(true);
}
public void helpReferences_actionPerformed(ActionEvent e) {
CadreMain_ReferencesBox dlg = new CadreMain_ReferencesBox(this);
......@@ -517,7 +542,29 @@ public class CadreMain extends JFrame {
//Global.nom_fichier=nomFichier;
//this.setData();
//*************************************************************************
d.setFileFilter(new FileFilter() {
@Override
public boolean accept(File f) {
return f.getName().toLowerCase().endsWith(".csv") || f.isDirectory();
}
@Override
public String getDescription() {
return "Data file (*.csv)";
}
});
d.setFileFilter(new FileFilter() {
@Override
public boolean accept(File f) {
return f.getName().toLowerCase().endsWith(".txt") || f.isDirectory();
}
@Override
public String getDescription() {
return "Data file (*.txt)";
}
});
d.setFileFilter(new FileFilter() {
@Override
public boolean accept(File f) {
......@@ -526,7 +573,7 @@ public class CadreMain extends JFrame {
@Override
public String getDescription() {
return "Data file (*.cli)";
return "Data file (*.CLI)";
}
});
d.setSelectedFile(new File(nomFichier));
......@@ -559,7 +606,7 @@ public class CadreMain extends JFrame {
dlg.setTitle("Climprod: Climprod file editor ");
dlg.setModal(true);
dlg.setVisible(true);
// int d=dlg.getResult();
//int d=dlg.getResult();
/* if(d==dlg.Ok_Option)
{
......@@ -571,7 +618,7 @@ public class CadreMain extends JFrame {
/*
* Cration d'un folder
* Création d'un folder html
*/
void menuFileFolder_actionPerformed(ActionEvent e) {
......@@ -579,18 +626,25 @@ public class CadreMain extends JFrame {
dlg.setTitle("Climprod: Build a html & graphs folder ");
dlg.setModal(true);
dlg.setVisible(true);
int d = dlg.getResult();
if (d == dlg.Ok_Option) {
String[] dd = dlg.getFolderName();
existingFolder(dd);
}
int d;
System.out.println("In CadreMain ligne 619 Global.FlagNewHtmlFolder = " + Global.FlagNewHtmlFolder);
if (Global.FlagNewHtmlFolder == true) {
System.out.println("In CadreMain ligne 621 Global.FlagNewHtmlFolder = " + Global.FlagNewHtmlFolder);
d = dlg.getResult();
Global.FlagNewHtmlFolder = false; // (réinitialization)
System.out.println("In CadreMain ligne 622 d = " + d);
if (d == dlg.Ok_Option) {
System.out.println("In CadreMain ligne 625 Flag");
String[] dd = dlg.getFolderName();
System.out.println("In CadreMain ligne 627 dd = " + dd);
existingFolder(dd);
}
}
}
/*
* Ouvre le folder slectionn dans le navigateur par dfault
* Ouvre le folder sélectionné dans le navigateur par défault
*/
void menuItemOpenFolder_actionPerformed(ActionEvent e) {
//JMenuItem jmi= (JMenuItem) e.getSource();
......@@ -1001,7 +1055,7 @@ public class CadreMain extends JFrame {
}
/*
Lecture dernière configuration
Lecture dernière configuration dans fichier .climprod\Climprod*.txt où * = username du système d'opération.
*/
private void readConfig() {
......@@ -1035,12 +1089,12 @@ public class CadreMain extends JFrame {
ht.put(d.nextToken(), " ");
}
}
userDir = (String) ht.get("userDir");
userHome = (String) ht.get("userHome");
workingDirectory = (String) ht.get("workingDirectory");
lastPathSource = (String) ht.get("lastPathSource");
Global.double_click = (String) ht.get("double_click"); // Rajout 2020.
String $key = (String) ht.get("file1");
userDir = (String) ht.get("userDir"); // Adresse climprod.jar ?
userHome = (String) ht.get("userHome"); // Adresse user
workingDirectory = (String) ht.get("workingDirectory"); // Adresse du répertoire .climprod dans C:
lastPathSource = (String) ht.get("lastPathSource"); // Adresse du répertoire exaple_data
Global.double_click = (String) ht.get("double_click"); // Statut du double-click Rajout 2020.
String $key = (String) ht.get("file1"); // Entête adresse et nom derniers fichiers .CLI utilisés
//System.out.println("key " +$key);
int i = 1;
while ($key != null) {
......@@ -1049,7 +1103,7 @@ public class CadreMain extends JFrame {
i = i + 1;
$key = (String) ht.get("file" + (i));
}
$key = (String) ht.get("folder1");
$key = (String) ht.get("folder1"); // Entête adresse et nom derniers répertoires Html&GraphsFolder utilisés
//System.out.println("key " +$key);
i = 1;
Vector<String> vFolder = new Vector<String>();
......@@ -1068,7 +1122,7 @@ public class CadreMain extends JFrame {
} catch (Exception e) {
System.out.println(e.getMessage());
}
} else //n'existe pas on le renseigne et on le cre
} else //n'existe pas on le renseigne et on le crée
{
userDir = System.getProperty("user.dir");
workingDirectory = userHome + fileSep + ".climprod";
......@@ -1086,12 +1140,12 @@ public class CadreMain extends JFrame {
}
/*
Sauvegarde dernière configuration
Sauvegarde dernière configuration dans .climprod\Climprod*.txt où * = username du système d'opération.
*/
private void saveConfig() throws IOException {
//System.out.println("configFile " +configFile);
PrintWriter out = new PrintWriter(new FileWriter(configFile));
out.println("lastPathSource|" + Global.datafilePath);
out.println("lastPathSource|" + Global.datafilePath); // Cf supra pour commentaires sur ces noms.
out.println("double_click|" + Global.double_click); // Rajout 2020.
out.println("workingDirectory|" + workingDirectory);
out.println("userDir|" + userDir);
......@@ -1107,7 +1161,7 @@ public class CadreMain extends JFrame {
out.close();
}
/* Gestion des menus.Permet de mmoriser les
/* Gestion des menus.Permet de mémoriser les
4 derniers fichiers ouverts
*/
private void updateMenu() {
......@@ -1144,7 +1198,7 @@ public class CadreMain extends JFrame {
}
}
/*
* Gestion des �l�ments de menus Folder
* Gestion des éléments de menus Folder
*/
private void existingFolder(String[] dd) {
......
// Fenetre Help ->How to get started du menu principal pour présenter copyright FAO-IRD.
package fr.ird.climprod;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
public class CadreMain_HowToBox extends JDialog implements ActionListener {
JPanel jPanHowTo = new JPanel();
JPanel jPanCmd = new JPanel();
// JPanel jPanImage = new JPanel();
JPanel jPanText = new JPanel();
JButton cmdOK = new JButton();
// JLabel imageIcone = new JLabel();
//ImageIcon imageIcon;
JTextArea jTextAreaCopyRight = new JTextArea();
BorderLayout borderLayout1 = new BorderLayout();
//BorderLayout borderLayout2 = new BorderLayout();
FlowLayout flowLayout1 = new FlowLayout();
FlowLayout flowLayout2 = new FlowLayout();
GridLayout gridLayout1 = new GridLayout();
// String product = "Climprod";
// String version = "1.0";
public CadreMain_HowToBox(Frame parent) {
super(parent);
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
// imageIcone.setIcon(imageIcon);
pack();
}
private void jbInit() throws Exception {
//imageIcon = new ImageIcon(getClass().getResource("Climprod.jpg"));
this.setTitle("How to get started");
setResizable(false);
jPanHowTo.setLayout(borderLayout1);
jPanCmd.setLayout(flowLayout1);
//jPanImage.setLayout(flowLayout1);
// jPanImage.setBorder(new EmptyBorder(10, 10, 10, 10));
// gridLayout1.setRows(4);
// gridLayout1.setColumns(1);
jTextAreaCopyRight.setText(
"HOW TO GET STARTED:\n\n" +
"You need first open a data file containing your data in four columns in a csv format " +
"using semicolons as separators. The heading of the columns are: Years;Catches;Effort;Environment. " +
"Historical files of CLIMPROD had the extension .CLI and the name of the second column was " +
"'Production'. You can still use directly those old files. If you need to create a new data " +
"file you can either do it by using the sub-menu 'Create a new CLIMPROD data file' in the " +
"main menu 'File', or create it using a spreadsheet software (e.g. Excel, OpenOffice Calc) " +
"and save it under the .csv format. You will be able to import directly this .csv file in " +
"CLIMPROD but you can also choose to modify its extension in .CLI.\n\n" +
"After opening a data file, CLIMPROD will spread out your entry data plus the computed CPUE, and " +
"display tables of basic statistics on the four variables. From this point you can proceed in two " +
"different ways:\n\n1) You can make use of the sub-menu 'Select the appropriate model and fit it' in " +
"the 'Modelization' main menu. This is the recommended option. The expert system will ask you a " +
"number of questions, some them based on graphics or statistical results, in order to select " +
"the most appropriate model and try to validate it. You can activate the 'Trace all the procedure' " +
"facility in the main menu 'Option' although this talkative option is not recommended for a first " +
"use of CLIMPROD. \n\n2) You can decide to select yourself a model by using the sub-menu 'Fit a model " +
"directly' in the menu 'Modelization', which supposes that you are familiar with surplus production " +
"models including an environmental variable. Before doing this you can explore yourself your data " +
"set using the first three sub-menus of the 'Plots & graphs' main menu. After fitting a model, you " +
"will be able to display additional graphs related to the validation of the model.\n\n" +
"At the end of any of the two ‘Modelization’ options you will be able to use the ‘Display the results " +
"tables’ related to modelization and validation. If the model was validated, you will also access to " +
"the sub-menu ‘Use the model for prediction’. In any case you will be allowed to build and display a " +
"history html & graphs folder by using the corresponding sub-menu in the 'Files' main menu.\n\n");
jTextAreaCopyRight.setLineWrap(true);
jTextAreaCopyRight.setWrapStyleWord(true);
jTextAreaCopyRight.setPreferredSize(new Dimension(600, 600));
jTextAreaCopyRight.setEditable(false);
jTextAreaCopyRight.setMargin(new Insets(5, 5, 5, 5));
jTextAreaCopyRight.setFont(new java.awt.Font("Serif", 0, 14)); // Fenetre Help ->"How to get started" du menu principal. Avant 0, 11. Modif 2020.
jPanText.setLayout(flowLayout1);
jPanText.setBorder(new EmptyBorder(10, 10, 10, 10));
jPanText.add(jTextAreaCopyRight, null);
cmdOK.setText("Ok");
int condition = JComponent.WHEN_IN_FOCUSED_WINDOW;
KeyStroke keyStrokep = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
InputMap inputMapp = cmdOK.getInputMap(condition);
ActionMap actionMapp = cmdOK.getActionMap();
inputMapp.put(keyStrokep, keyStrokep.toString());
actionMapp.put(keyStrokep.toString(), new AbstractAction() {
@Override
public void actionPerformed(ActionEvent arg0) {
cmdOK.doClick();
}
});
cmdOK.addActionListener(this);
jPanCmd.add(cmdOK, null);
jPanHowTo.add(jPanText, BorderLayout.CENTER);
jPanHowTo.add(jPanCmd, BorderLayout.SOUTH);
this.getContentPane().add(jPanHowTo, null);
}
protected void processWindowEvent(WindowEvent e) {
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
cancel();
}
super.processWindowEvent(e);
}
void cancel() {
dispose();
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == cmdOK) {
cancel();
}
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment