Package jmt.engine.jwat.workloadAnalysis.utils

Examples of jmt.engine.jwat.workloadAnalysis.utils.FormatFileReader


              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));
View Full Code Here


              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));
View Full Code Here

    loads.addStatusListener(pStatusList);
    loads.start();
  }

  public static Parameter loadParameter(File demoPath, String demoName) throws FileNotFoundException, IOException {
    FormatFileReader form = new FormatFileReader(new File(demoPath, demoName + "Format.jwatformat").getAbsolutePath());
 
    //FormatFileReader form = new FormatFileReader("D:/" + demoName + "Format.jwatformat");
    //System.out.println(absolutePath + "examples/" + demoName + "Format.jwatformat");
    boolean[] varSelected = new boolean[form.getNumVars()];
    String[] varName = new String[form.getNumVars()];
    String[] regularExp = new String[form.getNumVars()];
    String[] tokenExp = new String[form.getNumVars()];
    int[] varType = new int[form.getNumVars()];
   
    int options[] = new int[] { Loader.calcNumOfObs(new File(demoPath, demoName + "Data.jwat").getAbsolutePath()) };
    //int options[] = new int[] { Loader.calcNumOfObs("D:/" + demoName + "Data.jwat") };

    for (int i = 0; i < form.getNumVars(); i++) {
      varSelected[i] = true;
      varType[i] = form.getType();
      varName[i] = form.getName();
      regularExp[i] = form.getRegExpr();
      tokenExp[i] = form.getDelimiters();
      if (tokenExp[i].length() == 0) {
        tokenExp[i] = null;
      }
      form.next();
    }

    return new Parameter(varSelected, varType, regularExp, tokenExp, varName, Parameter.ALL_INPUT, null, options, null, null);
  }
View Full Code Here

              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));
View Full Code Here

TOP

Related Classes of jmt.engine.jwat.workloadAnalysis.utils.FormatFileReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.