コード例 #1
0
  private DbJVPackage importFiles(Controller controller, int startJobDone, int endJobDone)
      throws IOException, DbException {
    controller.checkPoint(startJobDone);
    DbJVPackage topMostPackage = null;

    List<File> filesToImport = m_params.getFilesToImport();
    List<ErrorReport> errorLog = new ArrayList<ErrorReport>();

    int i = 0, nb = filesToImport.size();

    String pattern = LocaleMgr.misc.getString("ThereAreNbFilesToImport");
    String msg = MessageFormat.format(pattern, nb);
    controller.println(msg);
    int span = endJobDone - startJobDone;

    for (File file : filesToImport) {
      String filename = file.toString();
      int idx = filename.lastIndexOf('.');
      String ext = (idx == -1) ? null : filename.substring(idx + 1);
      int jobDone = startJobDone + (i * span) / nb;

      try {
        if ("class".equals(ext)) {
          DbJVClass claz = importClassFile(filename, controller);
          if (claz != null) {
            DbJVPackage pack = (DbJVPackage) claz.getCompositeOfType(DbJVPackage.metaClass);
            topMostPackage = findTopMostPackage(topMostPackage, pack);
            addToImportedPackage(pack);
          } // end if
        } else if ("jar".equals(ext)) {
          int nextJobDone = startJobDone + ((i + 1) * span) / nb;
          topMostPackage = importJarFile(file, topMostPackage, controller, jobDone, nextJobDone);
        } // end if
      } catch (Throwable th) {
        ErrorReport report = new ErrorReport(file, th);
        errorLog.add(report);
        controller.incrementErrorsCounter();
      } // end try

      // check job done
      i++;
      controller.checkPoint(jobDone);

      // stop to reverse engineer if user has cancelled
      boolean finished = controller.isFinalState();
      if (finished) {
        break;
      }
    } // end for

    if (!errorLog.isEmpty()) {
      reportErrors(errorLog, controller);
    } // end if

    controller.checkPoint(endJobDone);
    return topMostPackage;
  } // end importFiles()
コード例 #2
0
  private void createAndRevealDiagram(
      DefaultMainFrame mainFrame,
      DbJVPackage topMostPackage,
      Controller controller,
      int startJobDone,
      int endJobDone)
      throws DbException {

    controller.checkPoint(startJobDone);
    DbOODiagram topMostDiagram = null;

    // create a diagram for each imported package
    int i = 0, nb = m_importedPackages.size();
    int span = endJobDone - startJobDone;
    for (DbJVPackage pack : m_importedPackages) {
      DbOODiagram diagram = new DbOODiagram(pack);
      CreateMissingGraphicsAction.createOOGraphics(diagram, (Point) null);
      new JVDiagramLayout(diagram, (GraphicComponent[]) null);

      if (pack.equals(topMostPackage)) {
        topMostDiagram = diagram;
      }

      int jobDone = startJobDone + (i * span) / nb;
      controller.checkPoint(jobDone);
      i++;
    } // end for

    if (topMostDiagram != null) {
      mainFrame.addDiagramInternalFrame(topMostDiagram);
      mainFrame.findInExplorer(topMostDiagram);
    }

    controller.checkPoint(endJobDone);
  } // end createAndRevealDiagram()
コード例 #3
0
  private void reportErrors(List<ErrorReport> errorLog, Controller controller) {
    String pattern = LocaleMgr.misc.getString("FailedOn0");
    for (ErrorReport report : errorLog) {
      String filename = report.m_file.toString();
      String msg = MessageFormat.format(pattern, filename);
      controller.println(msg);

      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      report.m_th.printStackTrace(pw);
      String s = sw.toString();
      controller.println(s);
    } // end for

    pattern = LocaleMgr.misc.getString("FailedOn0Files");
    int nb = errorLog.size();
    String msg = MessageFormat.format(pattern, nb);
    controller.println(msg);

    for (ErrorReport report : errorLog) {
      String filename = report.m_file.toString();
      msg = MessageFormat.format(pattern, filename);
      controller.println(msg);
    } // end for
  } // end reportErrors()
コード例 #4
0
 private void addToImportedPackage(DbJVPackage pack) {
   if ((pack != null) && (!m_importedPackages.contains(pack))) {
     m_importedPackages.add(pack);
   }
 } // end addToImportedPackage()