Search in sources :

Example 11 with SimpleWidgetGroup

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

the class FrameEditorMouseState method dynamicResizeGroup.

protected void dynamicResizeGroup(Association<?> group, double ratioX, double ratioY, double newLeft, double newTop, boolean childrenToo) {
    Iterator<? extends FrameElement> groupElts = group.iterator();
    while (groupElts.hasNext()) {
        FrameElement elt = groupElts.next();
        if (elt instanceof IWidget) {
            IWidget w = (IWidget) elt;
            GraphicalWidget<?> gw = ui.frameUI.getWidgetFigure(w);
            dynamicResizeWidget(w, gw, ratioX, ratioY, newLeft, newTop);
            if (childrenToo && (w instanceof AParentWidget)) {
                AParentWidget pw = (AParentWidget) w;
                SimpleWidgetGroup children = pw.getChildren();
                if (children != null) {
                    dynamicResizeGroup(children, ratioX, ratioY, newLeft, newTop, childrenToo);
                }
            }
        } else if (elt instanceof Association<?>) {
            dynamicResizeGroup((Association<?>) elt, ratioX, ratioY, newLeft, newTop, childrenToo);
        }
    }
}
Also used : SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) Association(edu.cmu.cs.hcii.cogtool.model.Association) FrameElement(edu.cmu.cs.hcii.cogtool.model.FrameElement) AParentWidget(edu.cmu.cs.hcii.cogtool.model.AParentWidget) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 12 with SimpleWidgetGroup

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

the class FrameEditorMouseState method dealWithMouseReleased.

/**
     * A mouse up event was called.
     * Checks for context selection, then performs actions as dictated
     * by the FSM.
     */
@Override
protected boolean dealWithMouseReleased(IFigure figure, int button, int x, int y, int state) {
    boolean goForward = super.dealWithMouseReleased(figure, button, x, y, state);
    // Clear any mouse drag timer, that may be running
    stopMouseDragTimer = true;
    if (goForward && isMouseDownValid) {
        // Record the mouse down position
        double zoom = ui.getZoom();
        // The current mouse down position (scaled)
        double currentScaledX = x / zoom;
        double currentScaledY = y / zoom;
        switch(getMouseState()) {
            case PotentialCreatingWidget:
            case PotentialMovingWidget:
            case PotentialResizingWidget:
                {
                    // Nothing to do; any action necessary was taken on "down".
                    break;
                }
            case PotentialReorderWidget:
            case PotentialMovingSelection:
                {
                    // Get whatever graphical widget under original down x,y
                    GraphicalWidget<?> wf = ui.widgetLocatedAtXY(mouseDownX, mouseDownY);
                    MoveHalo halo = null;
                    FrameElement data = null;
                    if (wf == null) {
                        halo = ui.moveHaloUnderXY(mouseDownX, mouseDownY);
                        if (halo != null) {
                            data = halo.getData();
                            if (data instanceof SimpleWidgetGroup) {
                                IWidget[] widgets = selection.getSelectedIWidgets();
                                SimpleWidgetGroup group = (SimpleWidgetGroup) data;
                                for (IWidget widget : widgets) {
                                    if (widget.getParentGroup() != group) {
                                        selection.deselectElement(widget);
                                    }
                                }
                                break;
                            }
                            if (data instanceof IWidget) {
                                wf = ui.frameUI.getWidgetFigure((IWidget) data);
                            }
                        }
                    }
                    if (wf != null) {
                        selection.setSelectedSelnFig(wf);
                    } else {
                        if (halo == null) {
                            halo = ui.moveHaloUnderXY(mouseDownX, mouseDownY);
                            if (halo != null) {
                                data = halo.getData();
                            }
                        }
                        if ((data != null) && (data instanceof FrameElementGroup)) {
                            selection.setSelectedSelnFig((FrameEltGroupHalo) halo);
                        }
                    }
                    break;
                }
            case PotentialTogglingSelection:
                {
                    // If mouse down on a widget, toggle selection.
                    GraphicalWidget<?> wf = ui.widgetLocatedAtXY(mouseDownX, mouseDownY);
                    MoveHalo halo = ui.moveHaloUnderXY(mouseDownX, mouseDownY);
                    FrameElement data = null;
                    if (halo != null) {
                        data = halo.getData();
                    }
                    if (wf == null) {
                        if (data instanceof IWidget) {
                            wf = ui.frameUI.getWidgetFigure((IWidget) data);
                        }
                    }
                    if (wf != null) {
                        // If the widget is already selected, unselect it.
                        if (selection.isSelectionFigureSelected(wf)) {
                            selection.deselectSelnFig(wf);
                        } else {
                            selection.selectSelnFig(wf);
                        }
                    } else if (data instanceof SimpleWidgetGroup) {
                        Iterator<IWidget> widgets = ((SimpleWidgetGroup) data).iterator();
                        while (widgets.hasNext()) {
                            IWidget w = widgets.next();
                            selection.deselectElement(w);
                        }
                    } else if ((halo instanceof FrameEltGroupHalo) && (data instanceof FrameElementGroup)) {
                        FrameEltGroupHalo groupHalo = (FrameEltGroupHalo) halo;
                        if (selection.isElementSelected(data)) {
                            selection.deselectSelnFig(groupHalo);
                        } else {
                            selection.selectSelnFig(groupHalo);
                        }
                    } else {
                        selection.deselectAll();
                    }
                    break;
                }
            // Move is complete, so apply changes to the model.
            case MovingWidgets:
                {
                    // Get selection, and use the difference between current
                    // and start location.
                    double moveByX = currentScaledX - scaledMouseDownX;
                    double moveByY = currentScaledY - scaledMouseDownY;
                    FrameEditorUI.MoveParameters prms = new FrameEditorUI.MoveParameters(moveByX, moveByY, selection);
                    ui.performAction(CogToolLID.MoveWidgets, prms);
                    break;
                }
            case ReorderWidget:
                {
                    boolean reorder = reorderWidget(x, y, reorderParms);
                    ui.clearUISupport(true);
                    isReordering = false;
                    if (reorder) {
                        ui.performAction(FrameEditorLID.Reorder, reorderParms);
                    } else {
                        selection.deselectElement(lastClickedWidget);
                    }
                    InteractionDrawingEditor editor = ui.getViewEditor();
                    editor.removeInteractionFigure(reorderFigure);
                    editor.removeInteractionFigure(dividerLine);
                    break;
                }
            // since the user may have flipped the orientation.
            case ResizingWidget:
                {
                    // Switch to quality mode rendering for graphical widgets
                    setWidgetFastRenderMode(false);
                    if (currentScaledX < 0.0) {
                        currentScaledX = 0.0;
                    }
                    if (currentScaledY < 0.0) {
                        currentScaledY = 0.0;
                    }
                    // Deal with any anchoring issues
                    if (ui.resizeHandlesUIFig.isTopLeftAnchored()) {
                        switch(currentResizeHandleType) {
                            case FrameEditorUI.TOP_RIGHT:
                                {
                                    // Cannot change Y position
                                    currentScaledY = initialResizeArea.y;
                                    break;
                                }
                            case FrameEditorUI.BOTTOM_LEFT:
                                {
                                    // Cannot change X position
                                    currentScaledX = initialResizeArea.x;
                                    break;
                                }
                            default:
                                {
                                    break;
                                }
                        }
                        // Cannot move left of top-left
                        if (currentScaledX < initialResizeArea.x) {
                            currentScaledX = initialResizeArea.x;
                        }
                        // Cannot move above of top-left
                        if (currentScaledY < initialResizeArea.y) {
                            currentScaledY = initialResizeArea.y;
                        }
                    }
                    double width = Math.abs(currentScaledX - mouseFixedResizeX);
                    double height = Math.abs(currentScaledY - mouseFixedResizeY);
                    FrameEditorUI.ResizeParameters prms = new FrameEditorUI.ResizeParameters(initialResizeArea.x, initialResizeArea.y, Math.min(currentScaledX, mouseFixedResizeX), Math.min(currentScaledY, mouseFixedResizeY), width / initialResizeArea.width, height / initialResizeArea.height, selection);
                    ui.performAction(CogToolLID.ResizeWidgets, prms);
                    break;
                }
            // Finished a mouse drag operation to create a new widget
            case CreatingWidget:
                {
                    if (currentScaledX < 0.0) {
                        currentScaledX = 0.0;
                    }
                    if (currentScaledY < 0.0) {
                        currentScaledY = 0.0;
                    }
                    double width = Math.abs(scaledMouseDownX - currentScaledX);
                    double height = Math.abs(scaledMouseDownY - currentScaledY);
                    double leftX = (scaledMouseDownX > currentScaledX) ? currentScaledX : scaledMouseDownX;
                    double topY = (scaledMouseDownY > currentScaledY) ? currentScaledY : scaledMouseDownY;
                    // Turn off the bounding box drawn.
                    ui.stopDrawingTemporaryFigure();
                    // Create a rectangle for the new region.
                    DoubleRectangle region = new DoubleRectangle(leftX, topY, width, height);
                    // width of 0. Probably this should be less then 2.
                    if ((region.width != 0.0) && (region.height != 0.0)) {
                        ui.performAction(CogToolLID.NewWidget, new FrameEditorUI.NewWidgetParameters(region, ui.getCurrentWidgetType(), ui.view.isAutomaticCreation()));
                    }
                    break;
                }
            // Finished a mouse drag operation to select a set of widgets
            case TogglingSelection:
                {
                    // Get the total area selected
                    double width = Math.abs(scaledMouseDownX - currentScaledX);
                    double height = Math.abs(scaledMouseDownY - currentScaledY);
                    // Get top left point.
                    double leftX = (scaledMouseDownX > currentScaledX) ? currentScaledX : scaledMouseDownX;
                    double topY = (scaledMouseDownY > currentScaledY) ? currentScaledY : scaledMouseDownY;
                    // Turn off the bounding box drawn.
                    ui.stopDrawingTemporaryFigure();
                    // Create the final region's area
                    DoubleRectangle region = new DoubleRectangle(leftX, topY, width, height);
                    // Loop through all figures and check for intersections
                    Iterator<GraphicalWidget<?>> gwFigures = ui.getFrameUI().getFigureListIterator();
                    while (gwFigures.hasNext()) {
                        GraphicalWidget<?> gw = gwFigures.next();
                        if (!(gw instanceof GraphicalChildWidget<?, ?>)) {
                            Rectangle bounds = gw.getBounds();
                            if (region.intersects(bounds.x, bounds.y, bounds.width, bounds.height)) {
                                // If the widget is already selected, deselect it.
                                if (selection.isSelectionFigureSelected(gw)) {
                                    selection.deselectSelnFig(gw);
                                } else {
                                    selection.selectSelnFig(gw);
                                }
                            }
                        }
                    }
                    break;
                }
            case PotentialInsertDuplicateWidget:
            case PotentialDuplicatingWidget:
                {
                    GraphicalWidget<?> widgetFig = ui.widgetLocatedAtXY(mouseDownX, mouseDownY);
                    selection.setSelectedSelnFig(widgetFig);
                    break;
                }
            case DuplicatingWidgets:
                {
                    double dx = currentScaledX - scaledMouseDownX;
                    double dy = currentScaledY - scaledMouseDownY;
                    // Remove all the rectangle figures from the display, clear the list
                    clearRectFigures();
                    ui.performAction(FrameEditorLID.Duplicate, new FrameEditorUI.DuplicateParameters(dx, dy, selection));
                    break;
                }
            case InsertDuplicateWidget:
                {
                    double dx = currentScaledX - scaledMouseDownX;
                    double dy = currentScaledY - scaledMouseDownY;
                    isReordering = false;
                    if (reorderWidget(x, y, insertDuplicateParms)) {
                        insertDuplicateParms.moveByX = dx;
                        insertDuplicateParms.moveByY = dy;
                        ui.performAction(FrameEditorLID.InsertDuplicate, insertDuplicateParms);
                    } else {
                        selection.deselectElement(lastClickedWidget);
                    }
                    InteractionDrawingEditor editor = ui.getViewEditor();
                    editor.removeInteractionFigure(reorderFigure);
                    editor.removeInteractionFigure(dividerLine);
                    break;
                }
            case PotentialMovingGridButtons:
                {
                    if (movedGridButtons != null) {
                        movedGridButtons = NO_GRID_BUTTONS;
                    }
                    break;
                }
            case MovingGridButtons:
                {
                    // Get selection, and use the difference between current
                    // and start location.
                    double moveByX;
                    double moveByY;
                    GraphicalWidget<?> gw = ui.getPotentialFigureOwner();
                    GridButton gb = (GridButton) gw.getModel();
                    DoublePoint start = gb.getShape().getOrigin();
                    if (moveIsVertical) {
                        moveByX = 0.0;
                        if (currentScaledY < minY) {
                            moveByY = (minY - start.y);
                        } else {
                            moveByY = currentScaledY - scaledMouseDownY;
                        }
                    } else {
                        moveByY = 0.0;
                        if (currentScaledX < minX) {
                            moveByX = (minX - start.x);
                        } else {
                            moveByX = currentScaledX - scaledMouseDownX;
                        }
                    }
                    if ((moveByX != 0.0) || (moveByY != 0.0)) {
                        FrameEditorUI.MoveParameters prms = new FrameEditorUI.MoveParameters(moveByX, moveByY, selection, false);
                        ui.performAction(CogToolLID.MoveWidgets, prms);
                    }
                    break;
                }
        }
        // Clear the values used.
        lastClickedWidget = null;
        isMouseDownValid = false;
        setMouseState(MouseUp);
    }
    cleanup();
    return goForward;
}
Also used : SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) FrameElementGroup(edu.cmu.cs.hcii.cogtool.model.FrameElementGroup) FrameEltGroupHalo(edu.cmu.cs.hcii.cogtool.uimodel.FrameEltGroupHalo) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle) GraphicalWidget(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalWidget) InteractionDrawingEditor(edu.cmu.cs.hcii.cogtool.view.InteractionDrawingEditor) GridButton(edu.cmu.cs.hcii.cogtool.model.GridButton) MoveHalo(edu.cmu.cs.hcii.cogtool.view.MoveHalo) Iterator(java.util.Iterator) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) FrameElement(edu.cmu.cs.hcii.cogtool.model.FrameElement) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 13 with SimpleWidgetGroup

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

the class FrameEditorController method createWidget.

private Widget createWidget(WidgetType defaultType, DoubleRectangle bounds, String widgetTitle, boolean isStandard) {
    Widget widget;
    // the user specified actual bounds interactively
    if (isStandard) {
        if (defaultType == WidgetType.Menu) {
            SimpleWidgetGroup newMenuHeaderGroup = new SimpleWidgetGroup(SimpleWidgetGroup.HORIZONTAL);
            widget = new MenuHeader(newMenuHeaderGroup, bounds, widgetTitle);
        } else if (defaultType == WidgetType.PullDownList) {
            widget = new PullDownHeader(bounds, widgetTitle);
        } else if (defaultType == WidgetType.ContextMenu) {
            widget = new ContextMenu(bounds, widgetTitle);
            // The default value for CONTEXT_MENU_ACTION_ATTR
            // is RIGHT_CLICK; must change to TAP_HOLD if the devices
            // contain a Touchscreen but not a Mouse
            Set<DeviceType> deviceTypes = design.getDeviceTypes();
            if (deviceTypes.contains(DeviceType.Touchscreen) && !deviceTypes.contains(DeviceType.Mouse)) {
                widget.setAttribute(WidgetAttributes.CONTEXT_MENU_ACTION_ATTR, WidgetAttributes.TAP_HOLD);
            }
        } else if (defaultType == WidgetType.ListBoxItem) {
            SimpleWidgetGroup newListItemGroup = new SimpleWidgetGroup(SimpleWidgetGroup.VERTICAL);
            widget = new ListItem(newListItemGroup, bounds, widgetTitle);
            newListItemGroup.setAttribute(WidgetAttributes.FIRST_VISIBLE_ATTR, widget);
        } else if (defaultType == WidgetType.Radio) {
            RadioButtonGroup newRadioGroup = new RadioButtonGroup();
            widget = new RadioButton(newRadioGroup, bounds, widgetTitle);
        } else if (defaultType == WidgetType.Check) {
            GridButtonGroup newCheckGroup = new GridButtonGroup();
            widget = new CheckBox(newCheckGroup, bounds, widgetTitle);
        } else {
            // Create new widget in specified location
            // Note: could be a child widget;
            //       if so, the user is managing the hierarchy!
            widget = new Widget(bounds, defaultType);
        }
        widget.setAttribute(WidgetAttributes.IS_STANDARD_ATTR, WidgetAttributes.IS_STANDARD);
    } else {
        // Create new widget in specified location
        // Note: could be a child widget;
        //       if so, the user is managing the hierarchy!
        widget = new Widget(bounds, defaultType);
        widget.setAttribute(WidgetAttributes.IS_STANDARD_ATTR, WidgetAttributes.IS_CUSTOM);
    }
    return widget;
}
Also used : DeviceType(edu.cmu.cs.hcii.cogtool.model.DeviceType) SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) MenuHeader(edu.cmu.cs.hcii.cogtool.model.MenuHeader) CheckBox(edu.cmu.cs.hcii.cogtool.model.CheckBox) ChildWidget(edu.cmu.cs.hcii.cogtool.model.ChildWidget) AParentWidget(edu.cmu.cs.hcii.cogtool.model.AParentWidget) TraversableWidget(edu.cmu.cs.hcii.cogtool.model.TraversableWidget) AMenuWidget(edu.cmu.cs.hcii.cogtool.model.AMenuWidget) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget) Widget(edu.cmu.cs.hcii.cogtool.model.Widget) RadioButtonGroup(edu.cmu.cs.hcii.cogtool.model.RadioButtonGroup) ContextMenu(edu.cmu.cs.hcii.cogtool.model.ContextMenu) PullDownHeader(edu.cmu.cs.hcii.cogtool.model.PullDownHeader) ListItem(edu.cmu.cs.hcii.cogtool.model.ListItem) RadioButton(edu.cmu.cs.hcii.cogtool.model.RadioButton) GridButtonGroup(edu.cmu.cs.hcii.cogtool.model.GridButtonGroup)

Example 14 with SimpleWidgetGroup

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

the class DictEntryGenerator method generateEntries.

// TODO This whole mishmash of different flavors of progress bars, and
//      Cancelables/Stoppables/Pausables is a mess. We shouldn't be using
//      the type hierarchy to fiddle this stuff. Instead we should have a
//      single interface for control of a background operation, subsuming
//      all of Cancelable, Stoppable and Pausable, and a single ProgressBar
//      type that takes a bunch of flags indicating what buttons it should
//      display.
public void generateEntries(String goal, ITermSimilarity alg, Cancelable cancelable, Stoppable stoppable, boolean computeAll, List<String> computeErrors, ProgressCallback progressCallback) {
    // TODO figure out how to deal with this for real, long term
    // goal = clean(goal);
    ISimilarityDictionary dict = (ISimilarityDictionary) design.getAttribute(WidgetAttributes.DICTIONARY_ATTR);
    if (NullSafe.equals(dict, WidgetAttributes.NO_DICTIONARY)) {
        dict = new SimilarityDictionary();
        design.setAttribute(WidgetAttributes.DICTIONARY_ATTR, dict);
    }
    int initialSize = dict.size();
    ITermSimilarity.Continuable cont = new ITermSimilarity.Continuable(cancelable, stoppable);
    Iterator<Frame> frames = design.getFrames().iterator();
    while (frames.hasNext() && cont.isContinuing()) {
        Frame f = frames.next();
        generateOneEntry(f.getSpeakerText(), goal, alg, cont, dict, computeAll, computeErrors, progressCallback);
        Set<SimpleWidgetGroup> swGrps = new HashSet<SimpleWidgetGroup>();
        Iterator<IWidget> widgets = f.getWidgets().iterator();
        while (widgets.hasNext() && cont.isContinuing()) {
            IWidget w = widgets.next();
            generateOneEntry(w.getTitle(), goal, alg, cont, dict, computeAll, computeErrors, progressCallback);
            if (!cont.isContinuing()) {
                break;
            }
            generateOneEntry(w.getTextualCue(), goal, alg, cont, dict, computeAll, computeErrors, progressCallback);
            SimpleWidgetGroup swg = w.getParentGroup();
            if (swg != null) {
                swGrps.add(swg);
            }
        }
        Iterator<FrameElementGroup> groups = f.getEltGroups().iterator();
        while (groups.hasNext() && cont.isContinuing()) {
            generateOneEntry(groups.next().getTextualCue(), goal, alg, cont, dict, computeAll, computeErrors, progressCallback);
        }
        Iterator<SimpleWidgetGroup> swgIter = swGrps.iterator();
        while (swgIter.hasNext() && cont.isContinuing()) {
            generateOneEntry(swgIter.next().getTextualCue(), goal, alg, cont, dict, computeAll, computeErrors, progressCallback);
        }
    }
    if (stoppable.isStopped()) {
        // Clean out the last entry if we were stopped, as it may not be
        // correct. But only if we've added something.
        int n = dict.size();
        if (n > initialSize) {
            dict.removeEntry(n - 1);
        }
    }
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame) SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) FrameElementGroup(edu.cmu.cs.hcii.cogtool.model.FrameElementGroup) ITermSimilarity(edu.cmu.cs.hcii.cogtool.model.ITermSimilarity) ISimilarityDictionary(edu.cmu.cs.hcii.cogtool.model.ISimilarityDictionary) SimilarityDictionary(edu.cmu.cs.hcii.cogtool.model.SimilarityDictionary) ISimilarityDictionary(edu.cmu.cs.hcii.cogtool.model.ISimilarityDictionary) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget) HashSet(java.util.HashSet)

Example 15 with SimpleWidgetGroup

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

the class FrameEditorController method setAsSeparator.

// assignActions
private boolean setAsSeparator(final IWidget widget, final Object value, final ChildWidget oldSelectedItem, IUndoableEditSequence editSeq) {
    final String IS_SEP_ATTR = WidgetAttributes.IS_SEPARATOR_ATTR;
    final Object oldValue = widget.getAttribute(IS_SEP_ATTR);
    final DoubleRectangle bounds = widget.getEltBounds();
    final double oldHeight = bounds.height;
    final double newHeight = WidgetAttributes.IS_SEPARATOR.equals(value) ? (oldHeight / FrameEditorUI.SEPARATOR_RATIO) : (oldHeight * FrameEditorUI.SEPARATOR_RATIO);
    final boolean isAuto = widget.isStandard();
    final SimpleWidgetGroup group = widget.getParentGroup();
    final AParentWidget pullDown = (oldSelectedItem != null) ? oldSelectedItem.getParent() : null;
    if (widget.equals(oldSelectedItem)) {
        // the currently selected widget in the pull down
        // has changed to a separator; deselect it
        pullDown.setAttribute(WidgetAttributes.SELECTION_ATTR, WidgetAttributes.NONE_SELECTED);
    }
    widget.setAttribute(IS_SEP_ATTR, value);
    if (isAuto) {
        widget.setWidgetSize(bounds.width, newHeight);
        DesignEditorCmd.repositionChildren(widget.getParentGroup());
    }
    if (editSeq != null) {
        DemoStateManager.IDesignUndoableEdit edit = new DemoStateManager.InvalidatingEdit(CogToolLID.SetAttribute, demoStateMgr) {

            @Override
            public String getPresentationName() {
                return DefaultCmd.SET_ATTRIBUTE;
            }

            @Override
            public void redo() {
                super.redo();
                if (widget.equals(oldSelectedItem)) {
                    pullDown.setAttribute(WidgetAttributes.SELECTION_ATTR, WidgetAttributes.NONE_SELECTED);
                }
                widget.setAttribute(IS_SEP_ATTR, value);
                if (isAuto) {
                    widget.setWidgetSize(bounds.width, newHeight);
                    DesignEditorCmd.repositionChildren(group);
                }
                stateMgr.noteWidgetEdit(widget, this);
            }

            @Override
            public void undo() {
                super.undo();
                if (widget.equals(oldSelectedItem)) {
                    pullDown.setAttribute(WidgetAttributes.SELECTION_ATTR, oldSelectedItem);
                }
                widget.setAttribute(IS_SEP_ATTR, oldValue);
                if (isAuto) {
                    widget.setWidgetSize(bounds.width, oldHeight);
                    DesignEditorCmd.repositionChildren(group);
                }
                stateMgr.noteWidgetEdit(widget, this);
            }
        };
        demoStateMgr.noteWidgetEdit(widget, edit);
        editSeq.addEdit(edit);
    }
    return true;
}
Also used : SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) IDesignUndoableEdit(edu.cmu.cs.hcii.cogtool.controller.DemoStateManager.IDesignUndoableEdit) AParentWidget(edu.cmu.cs.hcii.cogtool.model.AParentWidget) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)

Aggregations

SimpleWidgetGroup (edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup)45 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)32 FrameElement (edu.cmu.cs.hcii.cogtool.model.FrameElement)16 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)14 AParentWidget (edu.cmu.cs.hcii.cogtool.model.AParentWidget)13 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)10 FrameElementGroup (edu.cmu.cs.hcii.cogtool.model.FrameElementGroup)10 ChildWidget (edu.cmu.cs.hcii.cogtool.model.ChildWidget)9 HashSet (java.util.HashSet)8 TraversableWidget (edu.cmu.cs.hcii.cogtool.model.TraversableWidget)7 Point (org.eclipse.draw2d.geometry.Point)7 GridButtonGroup (edu.cmu.cs.hcii.cogtool.model.GridButtonGroup)6 ListItem (edu.cmu.cs.hcii.cogtool.model.ListItem)6 MenuHeader (edu.cmu.cs.hcii.cogtool.model.MenuHeader)6 Iterator (java.util.Iterator)6 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)5 ContextMenu (edu.cmu.cs.hcii.cogtool.model.ContextMenu)4 GridButton (edu.cmu.cs.hcii.cogtool.model.GridButton)4 Widget (edu.cmu.cs.hcii.cogtool.model.Widget)4 WidgetType (edu.cmu.cs.hcii.cogtool.model.WidgetType)4