Exemplo n.º 1
0
 public void undo() {
   SimpleActivityNode nodeConvert = (SimpleActivityNode) node;
   if (nodeConvert == PetriNet.getNewBegin()) {
     PetriNet.setNewBegin(PetriNet.getOldBegin());
     node.setLabel(oldLabel);
   } else {
     node.setLabel(oldLabel);
   }
 }
Exemplo n.º 2
0
  public void execute() {

    SimpleActivityNode nodeConvert = (SimpleActivityNode) node;
    if (PetriNet.getNewBegin() == null && newLabel.toLowerCase().equals("begin")) {
      this.oldLabel = node.getLabel();
      node.setLabel(newLabel);
      PetriNet.setOldBegin(PetriNet.getNewBegin());
      PetriNet.setNewBegin(nodeConvert);
      Marking initialMarking = Atid.getRoot().getCurrentMarking();
      Atid.getRoot()
          .getUndoManager()
          .executeCommand(new AddTokenCommand(nodeConvert, initialMarking));
    } else if (PetriNet.getNewBegin() != null && newLabel.toLowerCase().equals("begin")) {
      JOptionPane.showMessageDialog(null, "There is already a 'begin 'activity on the network.");
    } else if (node == PetriNet.getNewBegin() && !newLabel.toLowerCase().equals("begin")) {
      PetriNet.setNewBegin(null);
      Marking initialMarking = Atid.getRoot().getCurrentMarking();
      Atid.getRoot()
          .getUndoManager()
          .executeCommand(new RemoveTokenCommand(nodeConvert, initialMarking));
      this.oldLabel = node.getLabel();
      node.setLabel(newLabel);
    } else if (!newLabel.toLowerCase().equals("begin")) {
      this.oldLabel = node.getLabel();
      node.setLabel(newLabel);
    }
  }