Search in sources :

Example 1 with ActionPropertySet

use of edu.cmu.cs.hcii.cogtool.view.ActionPropertySet in project cogtool by cogtool.

the class DesignEditorUI method createFrameSelectionHandler.

protected AlertHandler createFrameSelectionHandler() {
    return new AlertHandler() {

        public void handleAlert(EventObject alert) {
            FrameSelectionChange evt = (FrameSelectionChange) alert;
            ActionPropertySet actionProps = view.getActionPropertySet();
            if (evt != null) {
                if (evt.changedFrameFigure != null) {
                    evt.changedFrameFigure.setSelected(evt.selected);
                    // Handle property sheet selection
                    Frame[] selectedFrames = selection.getSelectedFrames();
                    int selectedFrameCount = selectedFrames.length;
                    if (selectedFrameCount > 0) {
                        actionProps.setComposite(ActionPropertySet.FRAME);
                        if (selectedFrameCount == 1) {
                            actionProps.setFrameName(selectedFrames[0]);
                        }
                    } else {
                        actionProps.setComposite(ActionSet.USE_NONE);
                    }
                    actionProps.enableFrameName(selectedFrameCount == 1);
                } else {
                    actionProps.setComposite(ActionSet.USE_NONE);
                    Iterator<DesignEditorFrame> frameFigures = selection.getSelectedFrameFigures();
                    while (frameFigures.hasNext()) {
                        DesignEditorFrame frameFigure = frameFigures.next();
                        frameFigure.setSelected(evt.selected);
                    }
                }
                // Repaint the frame contents
                delayedRepainting.requestRepaint(REPAINT_ALL);
            }
        }
    };
}
Also used : ActionPropertySet(edu.cmu.cs.hcii.cogtool.view.ActionPropertySet) FrameSelectionChange(edu.cmu.cs.hcii.cogtool.ui.DesignEditorSelectionState.FrameSelectionChange) Frame(edu.cmu.cs.hcii.cogtool.model.Frame) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) EventObject(java.util.EventObject) Point(org.eclipse.draw2d.geometry.Point)

Example 2 with ActionPropertySet

use of edu.cmu.cs.hcii.cogtool.view.ActionPropertySet in project cogtool by cogtool.

the class DesignEditorUI method updateView.

protected void updateView(boolean deselectAll) {
    if (view.isDisposed()) {
        return;
    }
    ActionPropertySet actionProps = view.getActionPropertySet();
    int selectedTransitionCount = selection.getSelectedTransitionCount();
    int selectedFrameCount = selection.getSelectedFrameCount();
    if (deselectAll || (selectedFrameCount + selectedTransitionCount == 0)) {
        actionProps.useParameters(ActionSet.USE_NONE);
    } else if (selectedTransitionCount == 1) {
        Transition transition = selection.getSelectedTransitions()[0];
        AAction action = transition.getAction();
        DeviceType type = action.getDefaultDeviceType();
        int device = ActionSet.USE_NONE;
        if (action instanceof GraffitiAction) {
            device = ActionSet.USE_GRAFFITI_WIDGET;
        } else if (type == DeviceType.Mouse) {
            device = ActionSet.USE_MOUSE;
        } else if (type == DeviceType.Touchscreen) {
            device = ActionSet.USE_TOUCHSCREEN;
        } else if (type == DeviceType.Keyboard) {
            device = ActionSet.USE_KEYBOARD;
        } else if (type == DeviceType.Voice) {
            device = ActionSet.USE_VOICE;
        } else if (type == null) {
            // Generally, a hover action; pick whichever is active
            if (actionProps.isMouseSelected()) {
                device = ActionSet.USE_MOUSE;
            } else if (actionProps.isTouchSelected()) {
                device = ActionSet.USE_TOUCHSCREEN;
            }
        }
        actionProps.setComposite(device);
        ActionProperties properties = view.getActionProperties();
        view.getDefaultProperties(properties);
        properties.updateProperties(transition, transition.getAction(), transition.getSource());
        int limitMode = ActionProperties.determineChangeActionMode(transition.getSource());
        actionProps.setLimitMode(limitMode, properties.useWhichParts);
        actionProps.setProperties(properties, properties.useWhichParts);
    } else if (selectedTransitionCount > 1) {
        actionProps.useParameters(ActionPropertySet.MULT_TRANS);
    }
    if (selectedFrameCount == 1) {
        actionProps.updateFrameComposite(selection.getSelectedFrames()[0]);
    } else if ((selectedFrameCount == 0) && (selectedTransitionCount == 0)) {
        actionProps.updateEmptyComposite(design, false);
    }
}
Also used : ActionPropertySet(edu.cmu.cs.hcii.cogtool.view.ActionPropertySet) DeviceType(edu.cmu.cs.hcii.cogtool.model.DeviceType) GraffitiAction(edu.cmu.cs.hcii.cogtool.model.GraffitiAction) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) DesignEditorTransition(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorTransition) Point(org.eclipse.draw2d.geometry.Point) AAction(edu.cmu.cs.hcii.cogtool.model.AAction)

Aggregations

ActionPropertySet (edu.cmu.cs.hcii.cogtool.view.ActionPropertySet)2 Point (org.eclipse.draw2d.geometry.Point)2 AAction (edu.cmu.cs.hcii.cogtool.model.AAction)1 DeviceType (edu.cmu.cs.hcii.cogtool.model.DeviceType)1 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)1 GraffitiAction (edu.cmu.cs.hcii.cogtool.model.GraffitiAction)1 Transition (edu.cmu.cs.hcii.cogtool.model.Transition)1 FrameSelectionChange (edu.cmu.cs.hcii.cogtool.ui.DesignEditorSelectionState.FrameSelectionChange)1 DesignEditorFrame (edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame)1 DesignEditorTransition (edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorTransition)1 AlertHandler (edu.cmu.cs.hcii.cogtool.util.AlertHandler)1 EventObject (java.util.EventObject)1