📄 commandlist.java
字号:
package com.javapatterns.command.drawapplet;
import java.util.Stack;
public class CommandList
{
private Stack executedCommands = new Stack();
private Stack unexecutedCommands = new Stack();
private void _execute( Command command )
{
command.execute();
executedCommands.push( command );
}
public void execute( Command command )
{
unexecutedCommands.removeAllElements();
_execute( command );
}
public void unexecute()
{
Command command = (Command)executedCommands.pop();
command.unexecute();
unexecutedCommands.push( command );
}
public void reexecute()
{
Command command = (Command)unexecutedCommands.pop();
_execute( command );
}
public void reset()
{
executedCommands.removeAllElements();
unexecutedCommands.removeAllElements();
}
public boolean canUnexecuteCommand()
{
return !executedCommands.empty();
}
public boolean canReexecuteCommand()
{
return !unexecutedCommands.empty();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -