Search in sources :

Example 6 with Transition

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);
    }
}
Also used : DesignEditorTransition(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorTransition) Transition(edu.cmu.cs.hcii.cogtool.model.Transition)

Example 7 with Transition

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);
    }
}
Also used : Transition(edu.cmu.cs.hcii.cogtool.model.Transition)

Example 8 with Transition

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;
        }
    };
}
Also used : TransitionSource(edu.cmu.cs.hcii.cogtool.model.TransitionSource) DesignEditorUI(edu.cmu.cs.hcii.cogtool.ui.DesignEditorUI) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) AAction(edu.cmu.cs.hcii.cogtool.model.AAction)

Example 9 with Transition

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;
        }
    };
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame) InputDevice(edu.cmu.cs.hcii.cogtool.model.InputDevice) AListenerAction(edu.cmu.cs.hcii.cogtool.util.AListenerAction) RcvrClipboardException(edu.cmu.cs.hcii.cogtool.util.RcvrClipboardException) CompoundUndoableEdit(edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit) RcvrIOException(edu.cmu.cs.hcii.cogtool.util.RcvrIOException) IOException(java.io.IOException) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) SAXException(org.xml.sax.SAXException) DeviceType(edu.cmu.cs.hcii.cogtool.model.DeviceType) ClipboardUtil(edu.cmu.cs.hcii.cogtool.util.ClipboardUtil) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) IUndoableEdit(edu.cmu.cs.hcii.cogtool.util.IUndoableEdit) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 10 with Transition

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);
    }
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint)

Aggregations

Transition (edu.cmu.cs.hcii.cogtool.model.Transition)33 AAction (edu.cmu.cs.hcii.cogtool.model.AAction)13 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)11 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)7 TransitionSource (edu.cmu.cs.hcii.cogtool.model.TransitionSource)7 ButtonAction (edu.cmu.cs.hcii.cogtool.model.ButtonAction)6 DeviceType (edu.cmu.cs.hcii.cogtool.model.DeviceType)5 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)5 MousePressType (edu.cmu.cs.hcii.cogtool.model.MousePressType)4 TapAction (edu.cmu.cs.hcii.cogtool.model.TapAction)4 DesignEditorTransition (edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorTransition)4 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)4 InputDevice (edu.cmu.cs.hcii.cogtool.model.InputDevice)3 MouseButtonState (edu.cmu.cs.hcii.cogtool.model.MouseButtonState)3 TapPressType (edu.cmu.cs.hcii.cogtool.model.TapPressType)3 DesignEditorUI (edu.cmu.cs.hcii.cogtool.ui.DesignEditorUI)3 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)3 GraffitiAction (edu.cmu.cs.hcii.cogtool.model.GraffitiAction)2 Widget (edu.cmu.cs.hcii.cogtool.model.Widget)2 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)2