Package net.sf.rej.gui.action

Examples of net.sf.rej.gui.action.GroupAction


        try {
            UndoManager um = project.getUndoManager(targetFile);
            if (!this.project.isModified(targetFile)) {
              // is the file in question is not modified yet, group the new action
              // with an action that changes the status of the file.
                GroupAction ga = new GroupAction();
                ga.add(action);
              ClassFile cf = getClassFile(targetFile);
                ga.add(new MarkClassFileModifiedAction(this.project, targetFile, cf));
                um.add(ga);
                ga.execute();
            } else {
              um.add(action);
              action.execute();
            }
            this.dispatcher.notifyObservers(new Event(EventType.CLASS_UPDATE));
View Full Code Here


    }
  }

  public void pasteRows(Object data) {
    if (data instanceof List) {
      GroupAction ga = new GroupAction();
      // methods or fields involved
      @SuppressWarnings("unchecked")
      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) {
          TransferrableMethod method = (TransferrableMethod) transferrable;
          int maxStack = 0;
          int maxLocals = 0;
          if (method.getMaxStack() != null) {
            maxStack = method.getMaxStack();
          }
          if (method.getMaxLocals() != null) {
            maxLocals = method.getMaxLocals();
          }
          // TODO: Attributes are not being copied
          InsertMethodAction insertMethodAction = new InsertMethodAction(
              this.classDef.getClassFile(), method
                  .getMethodName(), method.getDescriptor(),
              new AccessFlags(method.getAccessFlags()), maxStack,
              maxLocals, method.getExceptions());
          ga.add(insertMethodAction);
          InsertCodeToNewMethodAction ictnma = new InsertCodeToNewMethodAction(
              this.classDef.getClassFile(), insertMethodAction,
              method.getCode());
          ga.add(ictnma);
        } else {
          throw new AssertionError(
              "Invalid object in List of pasted data.");
        }
      }

      if (!ga.isEmpty()) {
        SystemFacade.getInstance().performAction(ga);
      }

    } else {
      if (this.list.getSelectedIndex() == -1) {
View Full Code Here

        params);
    SystemFacade.getInstance().performAction(mia, this.openFile);
  }

  public void remove(List list) {
    GroupAction ga = new GroupAction();
    for (int i = list.size() - 1; i >= 0; i--) {
      Object obj = list.get(i);
      if (obj instanceof CodeRow) {
        CodeRow cr = (CodeRow) obj;
        RemoveInstructionAction ria = new RemoveInstructionAction(cr
            .getParentCode(), cr.getInstruction());
        ga.add(ria);
      } else if (obj instanceof MethodDefRow) {
        MethodDefRow mdr = (MethodDefRow) obj;
        RemoveMethodAction rma = new RemoveMethodAction(mdr
            .getClassFile(), mdr.getMethod());
        ga.add(rma);
      } else if (obj instanceof FieldDefRow) {
        FieldDefRow fdr = (FieldDefRow) obj;
        RemoveFieldAction rfa = new RemoveFieldAction(fdr
            .getClassFile(), fdr.getField());
        ga.add(rfa);
      } else {
        throw new AssertionError("Object of invalid type in list: " + obj.getClass());
      }

    }
View Full Code Here

    editor.setInstruction(instruction);
    editor.setLocalVariableTable(lvAttr);
    editor.setClassFile(this.cf);
    editor.invokeModify();
    if (!editor.wasCancelled()) {
      GroupAction group = new GroupAction();
      List choosers = editor.getChoosers();
      modifyInstructionParameters(choosers, group, instruction);
            SystemFacade.getInstance().performAction(group);
    }
  }
View Full Code Here

    editor.setClassFile(this.cf);
    editor.setPC(pc);
    editor.setLocalVariableTable(lvAttr);
    editor.invokeInsert();
    if (!editor.wasCancelled()) {
            GroupAction group = new GroupAction();
            if (code == null) {
              group.add(new CreateCodeAttributeAction(mdr.getMethod().getAttributes(), this.cf.getPool()));
            }
            List choosers = editor.getChoosers();
            Instruction instruction = editor.getInstruction();
            try {
              instruction = instruction.createNewInstance();
            } catch(Exception e) {
              SystemFacade.getInstance().handleException(e);
            }

        InsertInstructionAction iia = new InsertInstructionAction(instruction, pc, mdr.getMethod());
            group.add(iia);
            modifyInstructionParameters(choosers, group, instruction);
            SystemFacade.getInstance().performAction(group);
    }
  }
View Full Code Here

TOP

Related Classes of net.sf.rej.gui.action.GroupAction

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.