Search in sources :

Example 1 with HandLocation

use of edu.cmu.cs.hcii.cogtool.model.HandLocation in project cogtool by cogtool.

the class SEDemoController method createSetHandLocationAction.

protected IListenerAction createSetHandLocationAction() {
    return new IListenerAction() {

        public Class<?> getParameterClass() {
            return HandLocation.class;
        }

        public boolean performAction(Object prms) {
            HandLocation handLoc = (HandLocation) prms;
            if (handLoc != null) {
                setHandLocationAction(handLoc);
                return true;
            }
            interaction.protestNoHandLocation();
            return false;
        }
    };
}
Also used : IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) HandLocation(edu.cmu.cs.hcii.cogtool.model.HandLocation)

Example 2 with HandLocation

use of edu.cmu.cs.hcii.cogtool.model.HandLocation in project cogtool by cogtool.

the class SEDemoController method setHandLocationAction.

protected void setHandLocationAction(final HandLocation handLoc) {
    final Demonstration demo = script.getDemonstration();
    final boolean mouseHand = demo.getMouseHand();
    final DefaultModelGeneratorState initialState = demo.getInitialState();
    final HandLocation oldLoc = initialState.getHandLocation(mouseHand);
    final DemoStateManager.IConformanceUndoRedo conformanceUndoRedo = demoStateMgr.restoreConformance(demo);
    initialState.setHandLocation(mouseHand, handLoc);
    demo.alertInitialStateChange();
    final Collection<ComputationUndoRedo> scriptsUndoRedos = DemoScriptCmd.regenerateScripts(demo, 0, demo.getStepAt(0), interaction);
    IUndoableEdit edit = new AUndoableEdit(SEDemoLID.SetHandLocation) {

        @Override
        public String getPresentationName() {
            return SET_HAND_LOCATION;
        }

        @Override
        public void redo() {
            super.redo();
            conformanceUndoRedo.redo();
            initialState.setHandLocation(mouseHand, handLoc);
            demo.alertInitialStateChange();
            DemoScriptCmd.redoAllChanges(scriptsUndoRedos);
        }

        @Override
        public void undo() {
            super.undo();
            conformanceUndoRedo.undo();
            initialState.setHandLocation(mouseHand, oldLoc);
            demo.alertInitialStateChange();
            DemoScriptCmd.undoAllChanges(scriptsUndoRedos);
        }
    };
    undoMgr.addEdit(edit);
}
Also used : HandLocation(edu.cmu.cs.hcii.cogtool.model.HandLocation) ComputationUndoRedo(edu.cmu.cs.hcii.cogtool.controller.DemoScriptCmd.ComputationUndoRedo) AUndoableEdit(edu.cmu.cs.hcii.cogtool.util.AUndoableEdit) IUndoableEdit(edu.cmu.cs.hcii.cogtool.util.IUndoableEdit) Demonstration(edu.cmu.cs.hcii.cogtool.model.Demonstration) DefaultModelGeneratorState(edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState)

Example 3 with HandLocation

use of edu.cmu.cs.hcii.cogtool.model.HandLocation in project cogtool by cogtool.

the class SEFrameChooserController method setHandLocationAction.

protected void setHandLocationAction(final HandLocation handLoc) {
    final Demonstration demo = taskApp.getDemonstration();
    final boolean mouseHand = demo.getMouseHand();
    final DefaultModelGeneratorState initialState = demo.getInitialState();
    final HandLocation oldLoc = initialState.getHandLocation(mouseHand);
    initialState.setHandLocation(mouseHand, handLoc);
    demo.alertInitialStateChange();
    undoMgr.addEdit(new AUndoableEdit(SEFrameChooserLID.SetHandLocation) {

        @Override
        public String getPresentationName() {
            return setHandLocation;
        }

        @Override
        public void redo() {
            super.redo();
            initialState.setHandLocation(mouseHand, handLoc);
            demo.alertInitialStateChange();
        }

        @Override
        public void undo() {
            super.undo();
            initialState.setHandLocation(mouseHand, oldLoc);
            demo.alertInitialStateChange();
        }
    });
}
Also used : HandLocation(edu.cmu.cs.hcii.cogtool.model.HandLocation) AUndoableEdit(edu.cmu.cs.hcii.cogtool.util.AUndoableEdit) Demonstration(edu.cmu.cs.hcii.cogtool.model.Demonstration) DefaultModelGeneratorState(edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState)

Example 4 with HandLocation

use of edu.cmu.cs.hcii.cogtool.model.HandLocation in project cogtool by cogtool.

the class SEFrameChooserController method createSetHandLocationAction.

protected IListenerAction createSetHandLocationAction() {
    return new IListenerAction() {

        public Class<?> getParameterClass() {
            return HandLocation.class;
        }

        public boolean performAction(Object prms) {
            HandLocation handLoc = (HandLocation) prms;
            if (handLoc != null) {
                setHandLocationAction(handLoc);
                return true;
            }
            interaction.protestNoHandLocation();
            return false;
        }
    };
}
Also used : IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) HandLocation(edu.cmu.cs.hcii.cogtool.model.HandLocation)

Example 5 with HandLocation

use of edu.cmu.cs.hcii.cogtool.model.HandLocation in project cogtool by cogtool.

the class SEFrameChooserController method setMouseHandAction.

protected void setMouseHandAction(final boolean mouseHand) {
    final Demonstration demo = taskApp.getDemonstration();
    final boolean oldMouseHand = demo.getMouseHand();
    final DefaultModelGeneratorState initialState = demo.getInitialState();
    final HandLocation mouseHandLoc = initialState.getHandLocation(oldMouseHand);
    demo.setMouseHand(mouseHand);
    initialState.setHandLocation(mouseHand, mouseHandLoc);
    initialState.setHandLocation(!mouseHand, HandLocation.OnKeyboard);
    undoMgr.addEdit(new AUndoableEdit(SEFrameChooserLID.SetMouseHand) {

        @Override
        public String getPresentationName() {
            return setMouseHand;
        }

        @Override
        public void redo() {
            super.redo();
            initialState.setHandLocation(mouseHand, mouseHandLoc);
            initialState.setHandLocation(!mouseHand, HandLocation.OnKeyboard);
            // Do this last as it will alert
            demo.setMouseHand(mouseHand);
        }

        @Override
        public void undo() {
            super.undo();
            initialState.setHandLocation(oldMouseHand, mouseHandLoc);
            initialState.setHandLocation(!oldMouseHand, HandLocation.OnKeyboard);
            // Do this last as it will alert
            demo.setMouseHand(oldMouseHand);
        }
    });
}
Also used : HandLocation(edu.cmu.cs.hcii.cogtool.model.HandLocation) AUndoableEdit(edu.cmu.cs.hcii.cogtool.util.AUndoableEdit) Demonstration(edu.cmu.cs.hcii.cogtool.model.Demonstration) DefaultModelGeneratorState(edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState)

Aggregations

HandLocation (edu.cmu.cs.hcii.cogtool.model.HandLocation)6 DefaultModelGeneratorState (edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState)4 Demonstration (edu.cmu.cs.hcii.cogtool.model.Demonstration)4 AUndoableEdit (edu.cmu.cs.hcii.cogtool.util.AUndoableEdit)4 ComputationUndoRedo (edu.cmu.cs.hcii.cogtool.controller.DemoScriptCmd.ComputationUndoRedo)2 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)2 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)2