use of edu.cmu.cs.hcii.cogtool.model.Transition in project cogtool by cogtool.
the class DesignEditorSelectionState method deselectTransition.
public void deselectTransition(DesignEditorTransition singleTransition) {
Transition t = singleTransition.getTransition();
if (selectedTransitions.remove(t) != null) {
transitionChangeAlert.selected = false;
transitionChangeAlert.changedTransitionFigure = singleTransition;
raiseAlert(transitionChangeAlert);
}
}
use of edu.cmu.cs.hcii.cogtool.model.Transition in project cogtool by cogtool.
the class StructureViewUIModel method installSourceTransitions.
/**
* Create the visible representations for all of the transitions
* emanating from a specific source.
* <p>
* The figures for the source object and destination frames
* must be created/installed before attempting to create/install
* the visible representations for transitions.
*
* @param srcFrameFigure the figure for the frame containing the widget
* @param widget the source widget whose transitions to install
* @author mlh
*/
protected void installSourceTransitions(DesignEditorFrame srcFrameFigure, TransitionSource source) {
// Find the figure for the source widget
GraphicalSource<?> sourceFigure = srcFrameFigure.getSourceFigure(source);
Iterator<Transition> transitions = source.getTransitions().values().iterator();
while (transitions.hasNext()) {
Transition transition = transitions.next();
installSourceTransition(transition, sourceFigure);
}
}
use of edu.cmu.cs.hcii.cogtool.model.Transition in project cogtool by cogtool.
the class DesignEditorController method createChangeActionAction.
protected IListenerAction createChangeActionAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return DesignEditorUI.ChangeActionParameters.class;
}
public boolean performAction(Object prms) {
DesignEditorUI.ChangeActionParameters chgPrms = (DesignEditorUI.ChangeActionParameters) prms;
if (chgPrms != null) {
Transition[] transitions = chgPrms.selection.getSelectedTransitions();
if ((transitions != null) && (transitions.length > 0)) {
properties.copyValues(chgPrms.properties);
// TODO: Assume one for the moment; ui enforces it!
TransitionSource source = transitions[0].getSource();
int deviceTypes = DeviceType.buildDeviceSet(design.getDeviceTypes());
int limitMode = ActionProperties.determineChangeActionMode(source);
AAction newAction = EditActionCmd.buildActionFromProperties(properties, deviceTypes, limitMode, interaction);
if (newAction == null) {
return false;
}
newAction = EditActionCmd.ensureActionIsUnique(source, newAction, properties, deviceTypes, limitMode, transitions[0], interaction);
if (newAction == null) {
return false;
}
return changeTransitionsAction(transitions, newAction, NO_DELAY_CHANGE, null);
// TODO: If the given action properties are unusable
// (e.g., not unique from the source or empty string)
// and we should therefore return false so that an
// action that commits property changes can be
// canceled, assign the ensureActionIsUnique result
// to a new variable uniqueAction and return the AND of
// the changeTransitionsAction call (first) with
// (newAction == uniqueAction).
}
}
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.model.Transition in project cogtool by cogtool.
the class DesignEditorController method createPasteAction.
protected IListenerAction createPasteAction() {
return new AListenerAction() {
public boolean performAction(Object prms) {
try {
Collection<Object> objects = CogToolClipboard.fetchCogToolObjects();
if ((objects != null) && (objects.size() > 0)) {
CompoundUndoableEdit editSequence = new CompoundUndoableEdit(L10N.get("UNDO.Paste", "Paste"), DesignEditorLID.Paste);
Set<DeviceType> devTypes = design.getDeviceTypes();
int numPasted = 0;
Iterator<Object> objIt = objects.iterator();
while (objIt.hasNext()) {
Object o = objIt.next();
if (o instanceof Frame) {
Frame frame = (Frame) o;
makeFrameNameUnique(frame);
// Find an unoccupied starting position
// by cascading.
DoublePoint origin = frame.getFrameOrigin();
DesignUtil.findDistinctOrigin(design, origin, 16.0, 16.0);
// Union devices
Iterator<InputDevice> frameDevices = frame.getInputDevices().iterator();
while (frameDevices.hasNext()) {
InputDevice inputDevice = frameDevices.next();
DeviceType devType = inputDevice.getDeviceType();
if (!devTypes.contains(devType)) {
DesignCmd.addDevice(design, devType);
}
}
Iterator<DeviceType> designDevTypes = devTypes.iterator();
while (designDevTypes.hasNext()) {
DeviceType devType = designDevTypes.next();
if (frame.getInputDevice(devType) == null) {
frame.addInputDevice(devType);
}
}
addFrame(frame, editSequence);
numPasted++;
} else if (o instanceof Transition) {
Transition t = (Transition) o;
DeviceType device = t.getAction().getDefaultDeviceType();
if (!devTypes.contains(device)) {
DesignCmd.addDevice(design, device);
}
IUndoableEdit edit = DesignEditorCmd.addTransition(demoStateMgr, t);
editSequence.addEdit(edit);
numPasted++;
}
}
editSequence.end();
undoMgr.addEdit(editSequence);
interaction.setStatusMessage(numPasted + " " + pasteComplete);
} else {
interaction.setStatusMessage(nothingPasted);
}
} catch (IOException e) {
throw new RcvrClipboardException(e);
} catch (ParserConfigurationException e) {
throw new RcvrClipboardException(e);
} catch (SAXException e) {
throw new RcvrClipboardException(e);
} catch (ClipboardUtil.ClipboardException e) {
throw new RcvrClipboardException(e);
}
return true;
}
};
}
use of edu.cmu.cs.hcii.cogtool.model.Transition in project cogtool by cogtool.
the class DesignEditorController method deleteFrames.
// deleteFrame
protected void deleteFrames(final Frame[] frames) {
if ((frames != null) && (frames.length > 0)) {
final Transition[][] incidentTransitions = new Transition[frames.length][];
for (int i = 0; i < frames.length; i++) {
// Remove Transition instances that target this Frame
incidentTransitions[i] = frames[i].removeIncidentTransitions();
}
for (Frame frame : frames) {
design.removeFrame(frame);
}
DemoStateManager.IDesignUndoableEdit edit = new DemoStateManager.InvalidatingEdit(DesignEditorLID.DeleteFrame, demoStateMgr) {
protected boolean recoverMgrs = true;
@Override
public String getPresentationName() {
return (frames.length > 1) ? deleteFrames : deleteFrame;
}
@Override
public void redo() {
super.redo();
recoverMgrs = true;
for (Frame frame : frames) {
frame.removeIncidentTransitions();
}
for (Frame frame : frames) {
design.removeFrame(frame);
}
stateMgr.noteFramesEdit(frames, this);
}
@Override
public void undo() {
super.undo();
recoverMgrs = false;
for (int i = frames.length - 1; i >= 0; i--) {
design.addFrame(frames[i]);
}
for (int i = frames.length - 1; i >= 0; i--) {
DesignEditorCmd.addIncidentTransitions(incidentTransitions[i]);
}
stateMgr.noteFramesEdit(frames, this);
}
@Override
public void die() {
super.die();
if (recoverMgrs) {
for (Frame frame : frames) {
recoverManagers(frame);
}
}
}
};
demoStateMgr.noteFramesEdit(frames, edit);
undoMgr.addEdit(edit);
}
}
Aggregations