Search in sources :

Example 41 with IListenerAction

use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.

the class FrameEditorController method createInitiateRelabelAction.

private IListenerAction createInitiateRelabelAction() {
    return new IListenerAction() {

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

        public boolean performAction(Object prms) {
            FrameEditorSelectionState selection = (FrameEditorSelectionState) prms;
            int selectedWidgetCount = selection.getWidgetSelectionCount();
            if (selectedWidgetCount == 1) {
                IWidget w = selection.getSelectedIWidgets()[0];
                ui.initiateWidgetRetitle(w);
                return true;
            }
            interaction.protestNoSelection();
            return false;
        }
    };
}
Also used : IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) FrameEditorSelectionState(edu.cmu.cs.hcii.cogtool.ui.FrameEditorSelectionState) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 42 with IListenerAction

use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.

the class FrameEditorController method createSetRenderSkinAction.

private IListenerAction createSetRenderSkinAction() {
    return new IListenerAction() {

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

        public boolean performAction(Object prms) {
            FrameEditorUI.SetRenderSkinParameters p = (FrameEditorUI.SetRenderSkinParameters) prms;
            // Iterate through selected objects.
            Iterator<IWidget> selected = p.selection.getSelectedWidgetsIterator();
            CompoundUndoableEdit editSeq = new CompoundUndoableEdit(CHG_WIDGET_RENDERED, FrameEditorLID.SetRenderSkin);
            while (selected.hasNext()) {
                IWidget w = selected.next();
                if (w instanceof TraversableWidget) {
                    AParentWidget parent = null;
                    if (w instanceof MenuItem) {
                        parent = ((MenuItem) w).getTopHeader();
                        if (parent == null) {
                            // parent is a context menu
                            parent = ((MenuItem) w).getParent();
                        }
                    } else if (w instanceof ChildWidget) {
                        parent = ((ChildWidget) w).getParent();
                    } else if (w instanceof AParentWidget) {
                        parent = (AParentWidget) w;
                    }
                    if (parent != null) {
                        SimpleWidgetGroup group = parent.getParentGroup();
                        if (group != null) {
                            //menu header
                            renderGroup(group, p.rendered, parent.isRendered(), editSeq);
                        } else {
                            //pull down header
                            renderWidget(parent, p.rendered, parent.isRendered(), editSeq);
                            renderChildren(parent, p.rendered, parent.isRendered(), editSeq);
                        }
                    } else if (w.getParentGroup() != null) {
                        //list box item or radio button
                        renderGroup(w.getParentGroup(), p.rendered, w.isRendered(), editSeq);
                    }
                } else {
                    renderWidget(w, p.rendered, w.isRendered(), editSeq);
                }
            }
            editSeq.end();
            // Only add this edit if it is significant
            if (editSeq.isSignificant()) {
                undoMgr.addEdit(editSeq);
            }
            return true;
        }
    };
}
Also used : SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) CompoundUndoableEdit(edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit) MenuItem(edu.cmu.cs.hcii.cogtool.model.MenuItem) AParentWidget(edu.cmu.cs.hcii.cogtool.model.AParentWidget) FrameEditorUI(edu.cmu.cs.hcii.cogtool.ui.FrameEditorUI) TraversableWidget(edu.cmu.cs.hcii.cogtool.model.TraversableWidget) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) ChildWidget(edu.cmu.cs.hcii.cogtool.model.ChildWidget) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 43 with IListenerAction

use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.

the class FrameEditorController method createChangeTitlePropertyAction.

// changeTitleProperty
private IListenerAction createChangeTitlePropertyAction() {
    return new IListenerAction() {

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

        public boolean performAction(Object prms) {
            FrameEditorUI.ActionStringParameters p = (FrameEditorUI.ActionStringParameters) prms;
            // While the UI should suppress
            // multiple selection for setting
            // titles, the selection supports it
            Iterator<IWidget> selected = p.selection.getSelectedWidgetsIterator();
            CompoundUndoableEdit editSequence = new CompoundUndoableEdit(CHG_DISPLAYED_LABEL, FrameEditorLID.ChangeTitleProperty);
            String newTitle = p.newString;
            // Loop through each item and set the title
            while (selected.hasNext()) {
                IWidget widget = selected.next();
                changeTitleProperty(FrameEditorLID.ChangeTitleProperty, CHG_DISPLAYED_LABEL, widget, newTitle, p.isSeparator, editSequence);
            }
            editSequence.end();
            // Don't add empty edits!
            if (editSequence.isSignificant()) {
                undoMgr.addEdit(editSequence);
            }
            return true;
        }
    };
}
Also used : IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) CompoundUndoableEdit(edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit) FrameEditorUI(edu.cmu.cs.hcii.cogtool.ui.FrameEditorUI) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 44 with IListenerAction

use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.

the class FrameEditorController method createCutWidgetAction.

/**
     * Set up cut action, tests to ensure a cut is valid, and then
     * calls cut method.
     * @return
     */
private IListenerAction createCutWidgetAction() {
    return new IListenerAction() {

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

        public boolean performAction(Object prms) {
            FrameEditorSelectionState seln = (FrameEditorSelectionState) prms;
            // if non zero selected items copy them, then delete.
            if (seln.getElementSelectionCount() > 0) {
                // Copy the widgets, then delete them to perform a cut
                copyElements(seln, DesignEditorCmd.SAVE_TO_CLIPBOARD);
                return deleteElements(seln);
            }
            // Tell the user nothing was selected
            interaction.protestNoSelection();
            return false;
        }
    };
}
Also used : IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) FrameEditorSelectionState(edu.cmu.cs.hcii.cogtool.ui.FrameEditorSelectionState)

Example 45 with IListenerAction

use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.

the class DesignEditorController method createRemoveBackgroundImageAction.

/**
	 * Create a ListenerAction to handle removing frame background image on
	 * multiple frames
	 */
protected IListenerAction createRemoveBackgroundImageAction() {
    return new IListenerAction() {

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

        public boolean performAction(Object prms) {
            // Get selected frames from parameters
            FrameSelectionState seln = (FrameSelectionState) prms;
            Frame[] frames = seln.getSelectedFrames();
            setBackgroundImageOnFrames(frames, null, WidgetAttributes.NO_IMAGE, DesignEditorLID.RemoveBackgroundImage);
            return true;
        }
    };
}
Also used : FrameSelectionState(edu.cmu.cs.hcii.cogtool.ui.FrameSelectionState) Frame(edu.cmu.cs.hcii.cogtool.model.Frame) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction)

Aggregations

IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)94 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)30 Design (edu.cmu.cs.hcii.cogtool.model.Design)29 ITaskDesign (edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign)29 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)23 ProjectSelectionState (edu.cmu.cs.hcii.cogtool.ui.ProjectSelectionState)23 AUndoableEdit (edu.cmu.cs.hcii.cogtool.util.AUndoableEdit)21 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)19 TaskApplication (edu.cmu.cs.hcii.cogtool.model.TaskApplication)17 IOException (java.io.IOException)14 RcvrIOException (edu.cmu.cs.hcii.cogtool.util.RcvrIOException)13 TaskSelectionState (edu.cmu.cs.hcii.cogtool.ui.TaskSelectionState)12 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)10 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)10 DesignSelectionState (edu.cmu.cs.hcii.cogtool.ui.DesignSelectionState)10 FrameEditorSelectionState (edu.cmu.cs.hcii.cogtool.ui.FrameEditorSelectionState)9 FrameSelectionState (edu.cmu.cs.hcii.cogtool.ui.FrameSelectionState)9 TaskGroup (edu.cmu.cs.hcii.cogtool.model.TaskGroup)8 FrameEditorUI (edu.cmu.cs.hcii.cogtool.ui.FrameEditorUI)8 File (java.io.File)8