use of edu.cmu.cs.hcii.cogtool.controller.DemoStateManager.IDesignUndoableEdit in project cogtool by cogtool.
the class FrameEditorController method addWidget.
/**
* Add a widget to the frame.
* Returns an UndoableEdit which can later be undone.
* @param w
* @return
*/
private IUndoableEdit addWidget(IWidget widget) {
model.addWidget(widget);
IDesignUndoableEdit edit = DesignEditorCmd.addWidgetUndoableEdit(model, widget, demoStateMgr);
demoStateMgr.noteWidgetEdit(widget, edit);
return edit;
}
use of edu.cmu.cs.hcii.cogtool.controller.DemoStateManager.IDesignUndoableEdit in project cogtool by cogtool.
the class DesignEditorCmd method addTransition.
public static IUndoableEdit addTransition(final DemoStateManager demoStateMgr, final Transition transition) {
transition.getSource().addTransition(transition);
IDesignUndoableEdit edit = new DemoStateManager.InvalidatingEdit(DesignEditorLID.NewTransition, demoStateMgr) {
@Override
public String getPresentationName() {
return NEW_TRANSITION;
}
@Override
public void redo() {
super.redo();
transition.getSource().addTransition(transition);
demoStateMgr.noteTransitionEdit(transition, this);
}
@Override
public void undo() {
super.undo();
transition.getSource().removeTransition(transition);
demoStateMgr.noteTransitionEdit(transition, this);
}
};
demoStateMgr.noteTransitionEdit(transition, edit);
return edit;
}
use of edu.cmu.cs.hcii.cogtool.controller.DemoStateManager.IDesignUndoableEdit in project cogtool by cogtool.
the class DesignEditorCmd method pasteWidget.
private static int pasteWidget(IWidget widget, Design design, int currentDeviceTypes, Frame frame, DemoStateManager mgr, IUndoableEditSequence editSequence, Set<FrameElementGroup> groups, Set<IWidget> addedRemoteLabels) {
if (frame.getWidgets().contains(widget)) {
return 0;
}
int requiresOneOf = widget.getWidgetType().requiresOneOf();
if (!DeviceType.intersects(requiresOneOf, currentDeviceTypes)) {
// Missing either Mouse or Touchscreen
if (DeviceType.Touchscreen.isMember(requiresOneOf)) {
DesignCmd.addDevice(design, DeviceType.Touchscreen);
} else if (DeviceType.Mouse.isMember(requiresOneOf)) {
DesignCmd.addDevice(design, DeviceType.Mouse);
}
}
makeWidgetNameUnique(widget, frame);
frame.addWidget(widget);
IDesignUndoableEdit edit = addWidgetUndoableEdit(frame, widget, mgr);
mgr.noteWidgetEdit(widget, edit);
editSequence.addEdit(edit);
if (widget instanceof AParentWidget) {
AParentWidget parent = (AParentWidget) widget;
addChildWidgets(frame, parent.getChildren(), mgr, editSequence);
}
groups.addAll(widget.getEltGroups());
checkForRemoteLabel(widget, addedRemoteLabels);
return 1;
}
Aggregations