Commit 81a822cb authored by pfreon's avatar pfreon
Browse files

Debugging dat input in new .CLI file

When a new .CLI file is created, if a new line was incomplete it was impossible to save the file.
parent aae6e010
......@@ -30,8 +30,6 @@ public class CreateNewFile extends JDialog{
private String[] title$={"Year/season","Catches","Effort","Environment"};
private Object[][] data$=new String[100][4];
private JTable jTable1 = new JTable();
private int choice;
int NbObservations=0;
final int Ok_Option=1;
......@@ -40,7 +38,6 @@ public class CreateNewFile extends JDialog{
private ModeleDeTableEdition mdt;
private JFrame parent;
public CreateNewFile(JFrame parent) {
super(parent);
this.parent=parent;
......@@ -53,8 +50,6 @@ public class CreateNewFile extends JDialog{
catch(Exception e) {
e.printStackTrace();
}
}
private void initWindow() throws Exception {
jScrollPane1.getViewport().add(jTableData, null);
......@@ -91,14 +86,12 @@ public class CreateNewFile extends JDialog{
}
});
//Initialisation de la table de saisie
for(int i=0;i<MaxObservations;i++)
{
for(int j=0;j<4;j++)
data$[i][j]="";
}
mdt=new ModeleDeTableEdition(data$,title$);
......@@ -110,9 +103,9 @@ public class CreateNewFile extends JDialog{
TableColumn tmcolumn = null;
floatTextField ftf =new floatTextField();
JTextField jt=new JTextField();
int nbc=jTableData.getColumnModel().getColumnCount();
jTableData.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(new integerTextField()));
jTableData.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(new floatTextField())); // Before (new integerTextField() in order to allow inputs of fractions of years. Modif 2021
jTableData.getColumnModel().getColumn(0).setMinWidth(70);
for (int i = 1; i < nbc; i++) {
tmcolumn = jTableData.getColumnModel().getColumn(i);
......@@ -167,8 +160,6 @@ public class CreateNewFile extends JDialog{
//*************************************************************************
d.setFileFilter(new FileFilter() {
public boolean accept(File f){
return f.getName().toLowerCase().endsWith(".cli") || f.isDirectory();
......@@ -208,16 +199,11 @@ public class CreateNewFile extends JDialog{
}
}
}
catch(OnError ex)
{
MsgDialogBox msg=new MsgDialogBox(0,ex.getMessage(),0, this.parent);
}
}
void cmdCancel_actionPerformed(ActionEvent e) {
......@@ -244,10 +230,4 @@ private void saveDataFile(String fileName) throws IOException
out.close();
}
}
}
\ No newline at end of file
......@@ -367,7 +367,8 @@ public class Data {
double minx = Stat1.min(Data.year);
Global.TimeStepData = Data.year[1] - Data.year[0]; // Time step of the row data (default Year, decimal intervals mean seasonal data
if (Global.TimeStepData == 1.0) {
System.out.println("Global.TimeStepData = " + Global.TimeStepData);
if (Global.TimeStepData >= 1.0) {
Global.TimeStepData$ = "Full year or single annual season";
}
else {
......@@ -383,7 +384,7 @@ public class Data {
ps[2] = new PlotSerie("x", Data.year, "y", Data.f);
ps[3] = new PlotSerie("x", Data.year, "y", Data.v);
double RangeYear=Global.RangeYear();
System.out.println("RangeSeason(s) = " + RangeYear);
//System.out.println("RangeSeason(s) = " + RangeYear);
for (int i = 0; i < 4; i++) {
Global.timePlot[i] = new Plot();
ps[i].setFigure(2);
......@@ -391,7 +392,7 @@ public class Data {
Global.timePlot[i].setTitreGraphique(Global.titreG[i]);
Global.timePlot[i].setTitreX(Global.titreSx[i]);
Global.timePlot[i].setTitreY(Global.titreSy[i]);
if (Global.TimeStepData == 1.0) Global.timePlot[i].setDecimalsurX(0); // Time step of the row data (default Year, decimal intervals mean seasonal data
if (Global.TimeStepData >= 1.0) Global.timePlot[i].setDecimalsurX(0); // Time step of the row data (default Year, decimal intervals mean seasonal data
else Global.timePlot[i].setDecimalsurX(1);
Global.timePlot[i].setMinAxeX(minx - 1);
if (RangeYear < 20) Global.timePlot[i].setpasX(1.0d);
......
......@@ -2,7 +2,6 @@ package fr.ird.climprod;
import javax.swing.table.*;
/**
* <p>Titre : </p>
* <p>Description : </p>
......@@ -15,16 +14,13 @@ import javax.swing.table.*;
public class ModeleDeTableEdition extends AbstractTableModel {
/**
* Modle de table grant l'affichage dans jTabData
* Modèle de table gérant l'affichage dans jTabData
*/
public ModeleDeTableEdition(Object[][]dataTable,String[] col) {
columnNames = col;
data = dataTable;
changement=false;
}
public int getColumnCount() {
......@@ -43,7 +39,6 @@ public class ModeleDeTableEdition extends AbstractTableModel {
return true;
}
public String getColumnName(int col) {
return columnNames[col];
}
......@@ -60,17 +55,14 @@ public class ModeleDeTableEdition extends AbstractTableModel {
fireTableCellUpdated(row, col);
changement=true;
}
else{
if (col==0)
message="Only integer values are allowed for \"Years\" column !";
else
message="Only numericals values are allowed !";
/* else{ // Removed because 1)Bug when trying to remove a new row created by mistake; Of littel use because the keyboard only accepts numbers and sing full stop
//if (col==0)
// message="Only integer values are allowed for the\"Years\" column!"; // Not the casse anymore
//else
message="Only numericals values are allowed!";
MsgDialogBox msg=new MsgDialogBox(0,message,0, Global.CadreMain);
}
}*/
}
public boolean isChanged(){
......@@ -83,5 +75,4 @@ public class ModeleDeTableEdition extends AbstractTableModel {
final String[] columnNames ;
final Object[][] data ;
private boolean changement;
}
\ 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