use of edu.cmu.cs.hcii.cogtool.model.ShapeType in project cogtool by cogtool.
the class FrameEditorController method createChangeShapeAction.
/**
* Create a listener for changing the shape of a widget.
*
* @return
*/
private IListenerAction createChangeShapeAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorUI.ShapeChangeParameters.class;
}
public boolean performAction(Object prms) {
// Get the parameters to change the shape into
final FrameEditorUI.ShapeChangeParameters p = (FrameEditorUI.ShapeChangeParameters) prms;
Iterator<IWidget> selected = p.selection.getSelectedWidgetsIterator();
CompoundUndoableEdit editSequence = new CompoundUndoableEdit(CHG_WIDGET_SHAPE, FrameEditorLID.ChangeShapeProperty);
// Loop through all selected widgets.
while (selected.hasNext()) {
final IWidget w = selected.next();
final ShapeType oldShapeType = w.getShape().getShapeType();
final ShapeType newShapeType = p.newShapeType;
// Don't make a non-changing edit!
if (!oldShapeType.equals(newShapeType)) {
w.setShapeType(newShapeType);
DemoStateManager.ObsoletingEdit edit = new DemoStateManager.ObsoletingEdit(FrameEditorLID.ChangeShapeProperty, demoStateMgr) {
@Override
public String getPresentationName() {
return CHG_WIDGET_SHAPE;
}
@Override
public void redo() {
super.redo();
w.setShapeType(p.newShapeType);
noteEditCheckRegenerate(w, this);
}
@Override
public void undo() {
super.undo();
w.setShapeType(oldShapeType);
noteEditCheckRegenerate(w, this);
}
};
noteEditCheckRegenerate(w, edit);
editSequence.addEdit(edit);
}
}
editSequence.end();
// Don't add empty edits!
if (editSequence.isSignificant()) {
undoMgr.addEdit(editSequence);
}
return true;
}
};
}
Aggregations