use of edu.cmu.cs.hcii.cogtool.model.Transition in project cogtool by cogtool.
the class DesignEditorController method createNewTransition.
// Return null to indicate cancel
protected IUndoableEdit createNewTransition(final TransitionSource source, Frame target) {
int deviceTypes = DeviceType.buildDeviceSet(design.getDeviceTypes());
// Helps control which options are available for editing the action
int limitMode = ActionProperties.determineChangeActionMode(source);
AAction action = createDefaultAction(source);
if (action == null) {
if (!interaction.determineNewAction(properties, deviceTypes, limitMode, L10N.get("DE.SetActionType", "Set Action Type"))) {
// Indicate that the user canceled
return null;
}
action = EditActionCmd.buildActionFromProperties(properties, deviceTypes, limitMode, interaction);
if (action == null) {
return null;
}
}
// action is not null at this point; no transition yet for this action!
action = EditActionCmd.ensureActionIsUnique(source, action, properties, deviceTypes, limitMode, null, interaction);
if (action == null) {
return null;
}
Transition newTransition = new Transition(source, target, action);
newTransition.setDelayInfo(properties.delayInSecs, properties.delayLabel);
IUndoableEdit edit = DesignEditorCmd.addTransition(demoStateMgr, newTransition);
interaction.setTransitionStatusMessage(newTransition);
return edit;
}
use of edu.cmu.cs.hcii.cogtool.model.Transition in project cogtool by cogtool.
the class BalsamiqButtonAPIConverter method parseTransition.
/** Helper function used by parseWidget
* This method is used to parse the href tag that is a link from a widget
* to another frame
*
* @param destinationFrameName the name of the frame that the transition
* is going to
* @param widget the widget that the transition starts from
*/
protected void parseTransition(String destFrameFileName, Widget widget) {
String frameName = (destFrameFileName.lastIndexOf(".") == -1) ? destFrameFileName : destFrameFileName.substring(0, destFrameFileName.lastIndexOf('.'));
/* getFrame() returns the frame for the specified string. If the string is null then
a null frame is returned. */
Frame destinationFrame = (frameName != null) ? getFrame(frameName) : null;
if (destinationFrame != null) {
//Default Mouse Click Transition
//TODO: MAKE SURE THE MOUSE IS A DEVICE. check which devices are allowed and then make an action from there
AAction action = new ButtonAction(MouseButtonState.Left, MousePressType.Click, AAction.NONE);
//Create the transition and add it to the widget
Transition t = new Transition(widget, destinationFrame, action);
if (t != null) {
widget.addTransition(t);
}
}
}
use of edu.cmu.cs.hcii.cogtool.model.Transition in project cogtool by cogtool.
the class DesignEditorController method createChangeDelayAction.
protected IListenerAction createChangeDelayAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return DesignEditorUI.ChangeDelayParameters.class;
}
public boolean performAction(Object actionParms) {
DesignEditorUI.ChangeDelayParameters prm = (DesignEditorUI.ChangeDelayParameters) actionParms;
int numTransitions = prm.selection.getSelectedTransitionCount();
if (numTransitions == 0) {
interaction.protestNoSelection();
return false;
}
if (numTransitions > 1) {
interaction.protestMultipleTransitionSelection();
return false;
}
final Transition transition = prm.selection.getSelectedTransitions()[0];
final double oldDelayInSecs = transition.getDelayInSecs();
final String oldDelayLabel = transition.getDelayLabel();
if ((oldDelayInSecs != prm.delayInSecs) || !oldDelayLabel.equals(prm.delayLabel)) {
final double newDelayInSecs = prm.delayInSecs;
final String newDelayLabel = prm.delayLabel;
transition.setDelayInfo(newDelayInSecs, newDelayLabel);
DemoStateManager.IDesignUndoableEdit edit = new DemoStateManager.ObsoletingEdit(DesignEditorLID.ChangeDelay, demoStateMgr) {
@Override
public String getPresentationName() {
return changeDelay;
}
@Override
public void redo() {
super.redo();
transition.setDelayInfo(newDelayInSecs, newDelayLabel);
stateMgr.noteTransitionEdit(transition, this);
if (CogToolPref.REGENERATE_AUTOMATICALLY.getBoolean()) {
DemoScriptCmd.regenerateDesignScripts(project, design, interaction);
}
}
@Override
public void undo() {
super.undo();
transition.setDelayInfo(oldDelayInSecs, oldDelayLabel);
stateMgr.noteTransitionEdit(transition, this);
if (CogToolPref.REGENERATE_AUTOMATICALLY.getBoolean()) {
DemoScriptCmd.regenerateDesignScripts(project, design, interaction);
}
}
};
demoStateMgr.noteTransitionEdit(transition, edit);
undoMgr.addEdit(edit);
if (CogToolPref.REGENERATE_AUTOMATICALLY.getBoolean()) {
DemoScriptCmd.regenerateDesignScripts(project, design, interaction);
}
}
return true;
}
};
}
use of edu.cmu.cs.hcii.cogtool.model.Transition in project cogtool by cogtool.
the class DesignEditorController method createDeleteTransitionAction.
// deleteFrames
protected IListenerAction createDeleteTransitionAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return DesignEditorSelectionState.class;
}
public boolean performAction(Object prms) {
DesignEditorSelectionState selection = (DesignEditorSelectionState) prms;
Transition[] transitions = selection.getSelectedTransitions();
if ((transitions != null) && (transitions.length > 0)) {
if (interaction.confirmDeleteTransitions(transitions)) {
deleteTransitions(transitions);
return true;
}
} else {
interaction.protestNoSelection();
}
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.model.Transition in project cogtool by cogtool.
the class AbstractGraphicalSource method dispose.
/**
* Release resources held by the graphical source
*/
public void dispose() {
TransitionSource source = getModel();
Iterator<Transition> modelTransitions = source.getTransitions().values().iterator();
while (modelTransitions.hasNext()) {
Transition t = modelTransitions.next();
t.removeAllHandlers(this);
t.getDestination().removeAllHandlers(this);
}
source.removeAllHandlers(this);
}
Aggregations