concept Command in category java

This is an excerpt from Manning's book Swt/Jface in Action: GUI Design with Eclipse 3.0.
It isn’t difficult to see how the Model, View, and Controller classes function individually. The main obstacle to understanding the GEF is dealing with their interactions, both between themselves and with the rest of the application. Even the simplest editing modification requires a complex data exchange involving Tools, Requests, EditPolicys, Commands, and PropertyChangeEvents. We’ll cover these topics in staggering detail to enable you to customize your GEF editor. But since you’re still in the first section, a quick analogy will be helpful.
So far, we’ve created Commands that modify every aspect of the editor’s Model except the appearance of the individual components. Since we want the user to be able to change the size and shape of Activity objects, we need to create a Command that invokes their appropriate mutator methods. This is the purpose of the SetConstraintCommand, which is one of the simplest of the Commands in our project. Its code is presented in listing D.15.
Listing D.15. SetConstraintCommand.java
package com.swtjface.flowchart.commands; import org.eclipse.draw2d.geometry.*; import com.swtjface.flowchart.model.*; public class SetConstraintCommand extends org.eclipse.gef.commands.Command { private Point oldPos, newPos; private Dimension oldSize, newSize; private Activity act; public void execute() { oldSize = act.getSize(); oldPos = act.getLocation(); act.setLocation(newPos); act.setSize(newSize); } public void setLocation(Rectangle r) { setLocation(r.getLocation()); setSize(r.getSize()); } public void setLocation(Point p) {newPos = p;} public void setPart(Activity part) {this.act = part;} public void setSize(Dimension p) {newSize = p;} public void redo() { act.setSize(newSize); act.setLocation(newPos); } public void undo() { act.setSize(oldSize); act.setLocation(oldPos); } }