Package net.sf.rej.gui

Examples of net.sf.rej.gui.Undoable


        this.actions.add(action);
    }

    public void execute() {
        for (int i = 0; i < this.actions.size(); i++) {
            Undoable action = this.actions.get(i);
            action.execute();
        }
    }
View Full Code Here


        }
    }

    public void undo() {
        for (int i = this.actions.size() - 1; i >= 0; i--) {
            Undoable action = this.actions.get(i);
            action.undo();
        }
    }
View Full Code Here

  @Override
  public void processAttribute(IterationContext ic, Attribute attr) {
    if (attr instanceof LineNumberTableAttribute) {
      LineNumberTableAttribute lnAttr = (LineNumberTableAttribute) attr;
      Attributes attrs = ic.getCodeAttribute().getAttributes();
      Undoable u = new RemoveAttributeAction(attrs, lnAttr);
      if (batchMode) {
        u.execute();
      } else {
        SystemFacade.getInstance().performAction(u, ic.getFilename());
      }
    }
  }
View Full Code Here

  @Override
  public void processAttribute(IterationContext ic, Attribute attr) {
    if (attr instanceof LocalVariableTableAttribute) {
      LocalVariableTableAttribute lvAttr = (LocalVariableTableAttribute) attr;
      Attributes attrs = ic.getCodeAttribute().getAttributes();
      Undoable u = new RemoveAttributeAction(attrs, lvAttr);
      if (this.batchMode) {
        u.execute();
      } else {
        SystemFacade.getInstance().performAction(u, ic.getFilename());
      }
    }
  }
View Full Code Here

      List<Transferrable> transferrables = (List) data;
      for (Transferrable transferrable : transferrables) {
        if (transferrable instanceof TransferrableField) {
          TransferrableField field = (TransferrableField) transferrable;

          Undoable insertFieldAction = new InsertFieldAction(
              this.classDef.getClassFile(), field.getFieldName(),
              field.getDescriptor(), new AccessFlags(field
                  .getAccessFlags()));
          ga.add(insertFieldAction);
        } else if (transferrable instanceof TransferrableMethod) {
View Full Code Here

    // field should be refactored?   
    String className = ic.getCf().getFullClassName();
    String newFieldName = this.advisor.newFieldNameFor(className, field.getName(), field.getDescriptor());
    if (newFieldName != null) {
      Undoable u = new RenameFieldAction(ic.getCf().getPool(), field, newFieldName);
      if (this.batchMode) {
        u.execute();
      } else {
        SystemFacade.getInstance().performAction(u, ic.getFilename());         
      }
    }
  }
View Full Code Here

    // method should be refactored?
    String className = ic.getCf().getFullClassName();
    String newMethodName = this.advisor.newMethodNameFor(className, method.getName(), method.getDescriptor());
    if (newMethodName != null) {
      Undoable u = new RenameMethodAction(ic.getCf().getPool(), method, newMethodName);
      if (this.batchMode) {
        u.execute();
      } else {
        SystemFacade.getInstance().performAction(u, ic.getFilename());         
      }
    }
  }
View Full Code Here

  public void postProcessFile(IterationContext ic) {
    ClassFile cf = ic.getCf();
    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 {
View Full Code Here

      }
    }
   
    if (match) {
      desc.setParamList(newParams);
      Undoable u = new ModifyDescriptor(ic.getCf().getPool(), desc, descEnabled);
      if (this.batchMode) {
        u.execute();
      } else {
        SystemFacade.getInstance().performAction(u, ic.getFilename());
      }
    }
  }
View Full Code Here

      ClassInfo ci = (ClassInfo)cpi;
      JavaType jt = new JavaType(ci.getName());
      String newClassName = this.advisor.newClassNameFor(jt.getType());
      if(newClassName != null) {
        this.oldClassNames.put(newClassName, jt.getType());
        Undoable u = new ModifyClassInfoAction(ic.getCf().getPool(), ci, newClassName + jt.getDimensions());
        if (this.batchMode) {
          u.execute();
        } else {
          SystemFacade.getInstance().performAction(u, ic.getFilename());
        }
      }
    } if(cpi.getType() == ConstantPoolInfo.NAME_AND_TYPE) {
      NameAndTypeInfo nati = (NameAndTypeInfo)cpi;
      Descriptor desc = nati.getDescriptor();
      JavaType ret = desc.getReturn();
      boolean match = false;
      String newClassName = this.advisor.newClassNameFor(ret.getType());
      if (newClassName != null) {
        this.oldClassNames.put(newClassName, ret.getType());
        match = true;
        desc.setReturn(new JavaType(newClassName, ret.getDimensionCount()));
      }
     
      List params = desc.getParamList();
      List<JavaType> newParams = new ArrayList<JavaType>();
      for (int i=0; i < params.size(); i++) {
        JavaType param = (JavaType)params.get(i);
        newClassName = this.advisor.newClassNameFor(param.getType());
        if (newClassName != null) {
          this.oldClassNames.put(newClassName, param.getType());
          match = true;
          newParams.add(new JavaType(newClassName, param.getDimensionCount()));
        } else {
          newParams.add(param);
        }
      }
     
      if (match) {
        desc.setParamList(newParams);
        Undoable u = new ModifyNameAndTypeInfoAction(ic.getCf().getPool(), nati, desc);
        if (this.batchMode) {
          u.execute();
        } else {
          SystemFacade.getInstance().performAction(u, ic.getFilename());
        }
      }
    } if(cpi.getType() == ConstantPoolInfo.FIELD_REF) {
      RefInfo ri = (RefInfo)cpi;
      String className = ri.getClassName();
      String newFieldName = this.advisor.newFieldNameFor(className, ri.getTargetName(), ri.getDescriptor());
      if (newFieldName != null) {
        NameAndTypeInfo nati = ri.getNameAndTypeInfo();
       
        Undoable u = new ModifyNameAndTypeInfoAction(ic.getCf().getPool(), nati, newFieldName);
        if (this.batchMode) {
          u.execute();
        } else {
          SystemFacade.getInstance().performAction(u, ic.getFilename());         
        }
      }
    } else if(cpi.getType() == ConstantPoolInfo.METHOD_REF || cpi.getType() == ConstantPoolInfo.INTERFACE_METHOD_REF) {
      RefInfo ri = (RefInfo)cpi;
      String className = ri.getClassName();
      String newMethodName = this.advisor.newMethodNameFor(className, ri.getTargetName(), ri.getDescriptor());
      if (newMethodName != null) {
        NameAndTypeInfo nati = ri.getNameAndTypeInfo();
        Undoable u = new ModifyNameAndTypeInfoAction(ic.getCf().getPool(), nati, newMethodName);
        if (this.batchMode) {
          u.execute();
        } else {
          SystemFacade.getInstance().performAction(u, ic.getFilename());         
        }
      }
    }
View Full Code Here

TOP

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

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.