Search in sources :

Example 31 with DoubleRectangle

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

the class FrameEditorUI method getParameters.

/**
     * The get parameters function returns the correct parameters needed for
     * a particular LID.
     */
@Override
public Object getParameters(ListenerIdentifier originalLID, ListenerIdentifier transmutedLID, boolean isContextSelection) {
    // Check the general LID, if it is to restore the parent, then
    // return the super's get parameters
    Object parameters = super.getParameters(originalLID, transmutedLID, isContextSelection);
    if (parameters != UNSET) {
        return parameters;
    }
    setUpPerformAction(transmutedLID);
    FrameEditorSelectionState selnStateToUse = isContextSelection ? contextSelection : selection;
    if (transmutedLID == CogToolLID.PasteBackgroundImage) {
        return new FrameEditorUI.PasteBackgroundImageParms(selnStateToUse, ClipboardUtil.fetchImageData());
    }
    if (transmutedLID == FrameEditorLID.ChangeShapeProperty) {
        return new FrameEditorUI.ShapeChangeParameters(view.getWidgetShape(), selnStateToUse);
    }
    if (transmutedLID == FrameEditorLID.ChangeTypeProperty) {
        return new FrameEditorUI.TypeChangeParameters(view.getWidgetType(), selnStateToUse);
    }
    if (transmutedLID == FrameEditorLID.ChangeTitleProperty) {
        String newTitle = view.getWidgetTitle();
        boolean isSeparator = GraphicalWidgetRenderer.SEPARATOR_STRING.equals(newTitle);
        return new FrameEditorUI.ActionStringParameters(newTitle, selnStateToUse, isSeparator);
    }
    if (transmutedLID == FrameEditorLID.ChangeAuxTextProperty) {
        return new FrameEditorUI.ActionStringParameters(view.getElementAuxText(), selnStateToUse);
    }
    if (transmutedLID == FrameEditorLID.ChangeNameProperty) {
        return new FrameEditorUI.ActionStringParameters(view.getWidgetName(), selnStateToUse);
    }
    if (transmutedLID == FrameEditorLID.SetRenderSkin) {
        boolean renderState = view.getWidgetRendered();
        boolean newRenderState = (originalLID == FrameEditorLID.ToggleRenderSkin) ^ renderState;
        return new FrameEditorUI.SetRenderSkinParameters(newRenderState, selnStateToUse);
    }
    if (transmutedLID == FrameEditorLID.NewWidget) {
        return new FrameEditorUI.NewWidgetParameters(new DoubleRectangle(Widget.DEFAULT_X, Widget.DEFAULT_Y, Widget.DEFAULT_WIDTH, Widget.DEFAULT_HEIGHT), null, getCurrentWidgetType(), view.isAutomaticCreation(), "", null, false);
    }
    if (transmutedLID == CogToolLID.Duplicate) {
        return new FrameEditorUI.DuplicateParameters(16.0, 16.0, selnStateToUse);
    }
    if (transmutedLID == FrameEditorLID.SetRemoteLabelText) {
        return new FrameEditorUI.SetRemoteLabelTextParms(view.getRemoteLabelText(), selnStateToUse.getSelectedIFrameElements()[0]);
    }
    return selnStateToUse;
}
Also used : DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle) EventObject(java.util.EventObject)

Aggregations

DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)31 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)13 SimpleWidgetGroup (edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup)9 GridButton (edu.cmu.cs.hcii.cogtool.model.GridButton)8 Rectangle (org.eclipse.draw2d.geometry.Rectangle)7 GridButtonGroup (edu.cmu.cs.hcii.cogtool.model.GridButtonGroup)6 AParentWidget (edu.cmu.cs.hcii.cogtool.model.AParentWidget)5 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)5 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)5 FrameElement (edu.cmu.cs.hcii.cogtool.model.FrameElement)5 AUndoableEdit (edu.cmu.cs.hcii.cogtool.util.AUndoableEdit)4 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)4 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)4 CogToolLID (edu.cmu.cs.hcii.cogtool.CogToolLID)3 ListItem (edu.cmu.cs.hcii.cogtool.model.ListItem)3 Widget (edu.cmu.cs.hcii.cogtool.model.Widget)3 WidgetType (edu.cmu.cs.hcii.cogtool.model.WidgetType)3 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)3 IDesignUndoableEdit (edu.cmu.cs.hcii.cogtool.controller.DemoStateManager.IDesignUndoableEdit)2 ChildWidget (edu.cmu.cs.hcii.cogtool.model.ChildWidget)2