return;
}
//Load format
((JWatVariableInputTableModel) inputTable.getModel()).clearTable();
try {
FormatFileReader form = new FormatFileReader(nameFile.getAbsolutePath());
for (int i = 0; i < form.getNumVars(); i++) {
String tipo = "";
switch (form.getType()) {
case Parameter.NUMBER:
tipo = "Numeric";
break;
case Parameter.STRING:
tipo = "String";
break;
case Parameter.DATE:
tipo = "Date";
break;
}
((JWatVariableInputTableModel) inputTable.getModel()).addNewRow(form.getName(), tipo, form.getComment(), form
.getDelimiters(), form.getRegExpr(), form.getDefaults(), form.getReplace());
form.next();
}
inputTable.tableChanged(new TableModelEvent(inputTable.getModel()));
numOfVars.setValue(new Integer(form.getNumVars()));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Wrong file format.", "Error", JOptionPane.INFORMATION_MESSAGE);
((JWatVariableInputTableModel) inputTable.getModel()).clearTable();
inputTable.tableChanged(new TableModelEvent(inputTable.getModel()));
numOfVars.setValue(new Integer(0));
fileF.setSelectedFile(new File(""));
fileF.setFileFilter(new FileFilter() {
public boolean accept(File f) {
if (f.isDirectory()) {
return true;
}
if (f.getAbsolutePath().indexOf(".jwatformat") != -1) {
return true;
}
return false;
}
public String getDescription() {
return "Workload analysis format file";
}
});
return;
}
boolean exist = false;
//controllo se esiste gia' la voce selezionata
for (int i = 1; i < formatchooser.getModel().getSize(); i++) {
if (((String) formatchooser.getModel().getElementAt(i)).equals(fileF.getSelectedFile().getAbsolutePath())) {
exist = true;
break;
}
}
if (!exist) {
formatchooser.insertItemAt(fileF.getSelectedFile().getAbsolutePath(), formatchooser.getItemCount());
formatchooser.setSelectedIndex(formatchooser.getItemCount() - 1);
} else {
formatchooser.setSelectedItem(fileF.getSelectedFile().getAbsolutePath());
}
} else {
formatchooser.setSelectedIndex(-1);
}
} else {
if (choice != null) {
if (!choice.equals("")) {
if (choice.indexOf("\\") == -1) {
File nameFile = new File(choice);
//Load format
((JWatVariableInputTableModel) inputTable.getModel()).clearTable();
try {
FormatFileReader form = new FormatFileReader(nameFile.getAbsolutePath());
for (int i = 0; i < form.getNumVars(); i++) {
String tipo = "";
switch (form.getType()) {
case Parameter.NUMBER:
tipo = "Numeric";
break;
case Parameter.STRING:
tipo = "String";
break;
case Parameter.DATE:
tipo = "Date";
break;
}
((JWatVariableInputTableModel) inputTable.getModel()).addNewRow(form.getName(), tipo, form.getComment(), form
.getDelimiters(), form.getRegExpr(), form.getDefaults(), form.getReplace());
form.next();
}
inputTable.tableChanged(new TableModelEvent(inputTable.getModel()));
numOfVars.setValue(new Integer(form.getNumVars()));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Wrong file format.", "Error", JOptionPane.INFORMATION_MESSAGE);
((JWatVariableInputTableModel) inputTable.getModel()).clearTable();
inputTable.tableChanged(new TableModelEvent(inputTable.getModel()));
numOfVars.setValue(new Integer(0));
fileF.setSelectedFile(new File(""));
fileF.setFileFilter(new FileFilter() {
public boolean accept(File f) {
if (f.isDirectory()) {
return true;
}
if (f.getAbsolutePath().indexOf(".jwatformat") != -1) {
return true;
}
return false;
}
public String getDescription() {
return "Workload analysis format file";
}
});
return;
}
} else {
File nameFile = new File(choice);
//Load format
((JWatVariableInputTableModel) inputTable.getModel()).clearTable();
try {
FormatFileReader form = new FormatFileReader(nameFile.getAbsolutePath());
for (int i = 0; i < form.getNumVars(); i++) {
String tipo = "";
switch (form.getType()) {
case Parameter.NUMBER:
tipo = "Numeric";
break;
case Parameter.STRING:
tipo = "String";
break;
case Parameter.DATE:
tipo = "Date";
break;
}
((JWatVariableInputTableModel) inputTable.getModel()).addNewRow(form.getName(), tipo, form.getComment(), form
.getDelimiters(), form.getRegExpr(), form.getDefaults(), form.getReplace());
form.next();
}
inputTable.tableChanged(new TableModelEvent(inputTable.getModel()));
numOfVars.setValue(new Integer(form.getNumVars()));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Wrong file format.", "Error", JOptionPane.INFORMATION_MESSAGE);
((JWatVariableInputTableModel) inputTable.getModel()).clearTable();
inputTable.tableChanged(new TableModelEvent(inputTable.getModel()));
numOfVars.setValue(new Integer(0));