Package net.sf.rej.gui

Examples of net.sf.rej.gui.ProgressMonitor


        return; // early return
            }
            StopWatch watch = new StopWatch();
      SystemFacade.getInstance().setStatus("Preparing comparison.");           
           
            final ProgressMonitor pm = SystemFacade.getInstance().getProgressMonitor();

      // get a list of all the packages in the fileset
      final Set<String> pkgsAll = new TreeSet<String>();
      Set<String> pkgsA = new TreeSet<String>();
      for (String contentFile : this.listA) {
        int index = contentFile.lastIndexOf('/');
        if (index == -1) {
          pkgsAll.add("");
          pkgsA.add("");
        } else {
          String pkg = contentFile.substring(0, index);
          pkgsAll.add(pkg);
          pkgsA.add(pkg);
        }
       
      }
      Set<String> pkgsB = new TreeSet<String>();
      for (String contentFile : this.listB) {
        int index = contentFile.lastIndexOf('/');
        if (index == -1) {
          pkgsAll.add("");
          pkgsB.add("");
        } else {
          String pkg = contentFile.substring(0, index);
          pkgsAll.add(pkg);
          pkgsB.add(pkg);
        }
       
      }
     
      // associate each package name with a tree node
      Map<String, DefaultMutableTreeNode> map = new HashMap<String, DefaultMutableTreeNode>();
      for (String pkg : pkgsAll) {
        PackageItem pkgItem = new PackageItem(pkg);
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(pkgItem);
        root.add(node);
        map.put(pkg, node);
       
        // style highlighting
        if (!pkgsA.contains(pkg)) {
          // only present in set B
          pkgItem.setStyle(Style.YELLOW);
        } else if (!pkgsB.contains(pkg)) {
          // only present in set A
          pkgItem.setStyle(Style.RED);
        } else {
          // present in both sets
          pkgItem.setStyle(Style.PLAIN);
        }
      }

      // sort
      Set<String> contentFileSet = new TreeSet<String>();
      contentFileSet.addAll(this.listA);
      contentFileSet.addAll(this.listB);
     
      // progress scope
     
      pm.setProgressScope(0, contentFileSet.size());
      int progress = 0;
      // add each file to the corresponding node
      for (String contentFile : contentFileSet) {
        SystemFacade.getInstance().setStatus("Comparing " + contentFile);           
        pm.setProgress(progress++);
        int index = contentFile.lastIndexOf('/');
        String pkg = "";
        if (index != -1) {
          pkg = contentFile.substring(0, index);
        }
        DefaultMutableTreeNode pkgNode = map.get(pkg);
        PackageItem pkgItem = (PackageItem) pkgNode.getUserObject();
        FileItem fileItem = null;
        if (index == -1) {
          fileItem = new FileItem(contentFile, contentFile);         
        } else {
          fileItem = new FileItem(contentFile.substring(pkg.length()+1), contentFile);
        }
        DefaultMutableTreeNode fileNode = new DefaultMutableTreeNode(fileItem);
        pkgNode.add(fileNode);
       
        // style highlighting
        if (!listA.contains(contentFile)) {
          // only in set B
          fileItem.setStyle(Style.YELLOW);
          if (pkgItem.getStyle() == Style.PLAIN) {
            pkgItem.setStyle(Style.RED_AND_YELLOW);
          }
        } else if (!listB.contains(contentFile)) {
          // only in set A
          fileItem.setStyle(Style.RED);
          if (pkgItem.getStyle() == Style.PLAIN) {
            pkgItem.setStyle(Style.RED_AND_YELLOW);
          }
        } else {
          // in both sets, compare (non-'java aware', simple binary compare)
          InputStream isA = this.filesetA.getInputStream(contentFile);
          InputStream isB = this.filesetB.getInputStream(contentFile);
          boolean eq = IOToolkit.areEqual(isA, isB);
          isA.close();
          isB.close();
          if (eq) {
            fileItem.setStyle(Style.PLAIN);
          } else {
            fileItem.setStyle(Style.RED_AND_YELLOW);
            pkgItem.setStyle(Style.RED_AND_YELLOW);
          }
        }
      }
      pm.setProgress(progress);

      // expand the root
      SwingUtilities.invokeLater(new Runnable() {
        public void run() {
          tree.expandPath(tree.getPathForRow(0));       
View Full Code Here

TOP

Related Classes of net.sf.rej.gui.ProgressMonitor

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.