Package net.sf.rej.files

Examples of net.sf.rej.files.FileSet


         
            // update class index
            List list = this.preferences.getClassPathList();
            for (int i = 0; i < list.size(); i++) {
                File file = (File) list.get(i);
                FileSet fs = getFileSet(file);
                this.classIndex.addElement(fs);
            }

            updateClassIndex();
        } catch (Exception e) {
View Full Code Here


        removedItems.addAll(prevList);
        removedItems.removeAll(curList);

        for (int i=0; i < removedItems.size(); i++) {
          File file = removedItems.get(i);
          FileSet fs = getFileSet(file);
          this.classIndex.removeElement(fs);
        }

        for (int i=0; i < newItems.size(); i++){
          File file = newItems.get(i);
          FileSet fs = getFileSet(file);
          this.classIndex.addElement(fs);
        }

        updateClassIndex();
      } catch(Exception e) {
View Full Code Here

        Project project = new Project();

        project.setFile(f);
        try {
            FileSet set = getFileSet(f);
            this.classIndex.addElement(set);
            updateClassIndex();
            project.setFileSet(set);

            openProject(project);
View Full Code Here

        return this.project.getClassFile(filename);
    }

    public ClassFile getClassFile(ClassLocator classLocator)
            throws IOException, ClassParsingException {
        FileSet projectFileSet = this.project.getFileSet();
        if (projectFileSet.equals(classLocator.getFileSet())) {
            return getClassFile(classLocator.getFile());
        } else {
            // TODO: should these be cached as well? that is, ClassFile objects
            // of classes that are not in the open project(but are in the
            // classpath)
View Full Code Here

  }
 
  private void iterateOneAgent(IteratorAgent agent) {
    IterationContext ic = new IterationContext();
    ic.setProject(this.project);
    FileSet fs = this.project.getFileSet();
    List<String> contents = fs.getContentsList();
    agent.scopeChanged(0, contents.size());
    int progress = 0;
    for (String filename : contents) {
      agent.progressed(progress++);
      ic.setFilename(filename);
View Full Code Here

    }


    void obfuscate() throws Exception {
        final boolean batch = this.batchCheck.isSelected();
      final FileSet originalFileSet = project.getFileSet();
      List<String> classNames = SystemFacade.getInstance().getClassIndex().getClassNames(originalFileSet);       
        if (batch && project.isModified()) {
          JOptionPane.showMessageDialog(this, "The batch mode requires that you save all your unsaved changes first.");
          return; // early return
        }
       
       
        File temp = File.createTempFile("rejava", "folder");
        boolean deleteSuccess = temp.delete();
        if (!deleteSuccess) {
          JOptionPane.showMessageDialog(this, "Could not remove temporary file (" + temp.getAbsolutePath() + ") needed for batch operation.");
          return; // early return
        }
        boolean mkdirSuccess = temp.mkdirs();
        if (!mkdirSuccess) {
          JOptionPane.showMessageDialog(this, "Could not create temporary folder (" + temp.getAbsolutePath() + ") needed for batch operation.");
          return; // early return
        }

        if (batch) {
          final Folder tempFileSet = new Folder(temp);
          tempFileSet.getContentsFrom(originalFileSet);
          project.setFileSet(tempFileSet);
        }

        List<IteratorAgent> obfuscators = new ArrayList<IteratorAgent>();
        if (this.stripLineInfo.isSelected()) {
            obfuscators.add(new LineNumberStripper(batch) {
            @Override
                public void processException(Exception ex) {
                    SystemFacade.getInstance().handleException(ex);
                }
               
                @Override
                public void postProcessFile(IterationContext ic) {
                  super.postProcessFile(ic);
                    if (batch) {
                      save(ic);
                    }
                }
            });
        }

        if (this.stripVarsCheck.isSelected()) {
            obfuscators.add(new LocalVarStripper(batch) {
            @Override
                public void processException(Exception ex) {
                    SystemFacade.getInstance().handleException(ex);
                }
               
                @Override
                public void postProcessFile(IterationContext ic) {
                  super.postProcessFile(ic);
                    if (batch) {
                      save(ic);
                    }
                }
            });
        }
       
        if (this.renameClassesCheck.isSelected()) {
          ClassNameObfuscatingAdvisor nameObfuscatorAdvisor = new ClassNameObfuscatingAdvisor(classNames);
          AbstractIteratorAgent agent = new RefactoringIterator(nameObfuscatorAdvisor, batch) {
            @Override
                public void processException(Exception ex) {
                    SystemFacade.getInstance().handleException(ex);
                }
               
                @Override
                public void postProcessFile(IterationContext ic) {
                  super.postProcessFile(ic);
                    if (batch) {
                      save(ic);
                    }
                }
          };
          obfuscators.add(agent);
        }

        /*
        if (this.renameFieldsCheck.isSelected()) {
          List<String> classNames = SystemFacade.getInstance().getClassIndex().getClassNames(project.getFileSet());
          FieldNameObfuscatingAdvisor nameObfuscatorAdvisor = new FieldNameObfuscatingAdvisor(classNames);
          AbstractIteratorAgent agent = new RefactoringIterator(nameObfuscatorAdvisor);
          obfuscators.add(agent);
        }*/

        if (this.legalizeClassesCheck.isSelected()) {
          ClassNameLegalizingAdvisor nameLegalizingAdvisor = new ClassNameLegalizingAdvisor(classNames);
          AbstractIteratorAgent agent = new RefactoringIterator(nameLegalizingAdvisor, batch) {
            @Override
                public void processException(Exception ex) {
                    SystemFacade.getInstance().handleException(ex);
                }
               
                @Override
                public void postProcessFile(IterationContext ic) {
                  super.postProcessFile(ic);
                    if (batch) {
                      save(ic);
                    }
                }

          };
          obfuscators.add(agent);
        }

        if (this.legalizeMethodsCheck.isSelected()) {
          MethodNameLegalizingAdvisor nameLegalizingAdvisor = new MethodNameLegalizingAdvisor(classNames);
          AbstractIteratorAgent agent = new RefactoringIterator(nameLegalizingAdvisor, batch) {
            @Override
                public void processException(Exception ex) {
                    SystemFacade.getInstance().handleException(ex);
                }
               
                @Override
                public void postProcessFile(IterationContext ic) {
                  super.postProcessFile(ic);
                    if (batch) {
                      save(ic);
                    }
                }
          };
          obfuscators.add(agent);
        }

        if (this.legalizeFieldsCheck.isSelected()) {
          FieldNameLegalizingAdvisor nameLegalizingAdvisor = new FieldNameLegalizingAdvisor(classNames);
          AbstractIteratorAgent agent = new RefactoringIterator(nameLegalizingAdvisor, batch) {
            @Override
                public void processException(Exception ex) {
                    SystemFacade.getInstance().handleException(ex);
                }
               
                @Override
                public void postProcessFile(IterationContext ic) {
                  super.postProcessFile(ic);
                    if (batch) {
                      save(ic);
                    }
                }
          };
          obfuscators.add(agent);
        }

        for (int i = 0; i < obfuscators.size(); i++) {
            AbstractIteratorAgent obf = (AbstractIteratorAgent)obfuscators.get(i);
            obf.setProgressMonitor(SystemFacade.getInstance().
                                   getProgressMonitor());
        }
        ProjectIterator.iterate(project, obfuscators, new IterationNotificationListener() {

      public void finished() {
        if (batch) {
          try {
            FileSet temp = project.getFileSet();
            originalFileSet.getContentsFrom(temp);
            project.setFileSet(originalFileSet);
            temp.removeAllFiles();
            dispatcher.notifyObservers(new Event(EventType.PROJECT_UPDATE));
          } catch (IOException ioe) {
            SystemFacade.getInstance().handleException(ioe);
          }
        }
View Full Code Here

    String oldClassName = this.oldClassNames.get(ic.getCf().getFullClassName());
    if (oldClassName != null) {
      String newFileName = getNewFileName(ic.getFilename(), oldClassName, cf.getFullClassName());
      Undoable u = new RenameFileAction(ic.getProject(), ic.getFilename(), newFileName, ic.getCf());
      if (this.batchMode) {
        FileSet fs = ic.getProject().getFileSet();
        fs.removeFile(ic.getFilename());
        fs.addFile(newFileName);
      } else {
        SystemFacade.getInstance().performProjectAction(u);
      }
      ic.setFilename(newFileName);
    }
View Full Code Here

TOP

Related Classes of net.sf.rej.files.FileSet

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.