Search in sources :

Example 1 with RcvrUIException

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

the class View method setVisible.

/**
     * Set whether the associated window (and view) is visible.
     *
     * @param visible true iff the associated window/view should be visible
     * @author mlh
     */
public void setVisible(boolean visible) {
    Shell window = getShell();
    if (window != null) {
        if (visible) {
            // Suppress drawing until everything is done.
            //                setDrawingOK(false);
            WindowUtil.display(window, false);
            // Recompute layout of the shell contents.
            // Should not be called too often, but since SetVisible should
            // only be called on window creation it should be done here.
            window.layout(true, true);
        //                setDrawingOK(true);
        } else {
            window.setVisible(false);
        }
    } else {
        throw new RcvrUIException("No window available for setting window visibility.");
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) RcvrUIException(edu.cmu.cs.hcii.cogtool.util.RcvrUIException)

Example 2 with RcvrUIException

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

the class View method takeFocus.

/**
     * Bring the associated window to the front and make active by
     * making the window have the focus and "un-minimize" it.
     *
     * @author mlh
     */
public void takeFocus() {
    Shell window = getShell();
    if (window != null) {
        window.setActive();
        window.setMinimized(false);
    } else {
        throw new RcvrUIException("No window available for taking the focus.");
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) RcvrUIException(edu.cmu.cs.hcii.cogtool.util.RcvrUIException)

Example 3 with RcvrUIException

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

the class DesignEditorController method createNewTransitionAction.

// renameFrame
protected IListenerAction createNewTransitionAction() {
    return new IListenerAction() {

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

        public boolean performAction(Object prms) {
            DesignEditorUI.NewTransitionParameters newPrms = (DesignEditorUI.NewTransitionParameters) prms;
            if (newPrms != null) {
                CompoundUndoableEdit editSequence = null;
                if (newPrms.target == null) {
                    editSequence = new CompoundUndoableEdit(DesignEditorCmd.NEW_TRANSITION, DesignEditorLID.NewTransition);
                    newPrms.target = createNewFrame(newPrms.x, newPrms.y, editSequence);
                }
                IUndoableEdit edit = createNewTransition(newPrms.source, newPrms.target);
                // null is returned if the operation is canceled.
                if (edit != null) {
                    if (editSequence != null) {
                        editSequence.addEdit(edit);
                        editSequence.end();
                        edit = editSequence;
                    }
                    undoMgr.addEdit(edit);
                    if (editSequence != null) {
                        ui.initiateFrameRename(newPrms.target);
                    }
                    return true;
                } else if (editSequence != null) {
                    editSequence.end();
                    editSequence.undo();
                }
                return false;
            } else {
                throw new RcvrUIException("Cannot create transition without parameters.");
            }
        }
    };
}
Also used : DesignEditorUI(edu.cmu.cs.hcii.cogtool.ui.DesignEditorUI) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) CompoundUndoableEdit(edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit) IUndoableEdit(edu.cmu.cs.hcii.cogtool.util.IUndoableEdit) RcvrUIException(edu.cmu.cs.hcii.cogtool.util.RcvrUIException)

Example 4 with RcvrUIException

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

the class DesignEditorController method assignActions.

@Override
public void assignActions() {
    super.assignActions();
    ui.setAction(DesignEditorLID.ExportDesignToHTML, createExportDesignToHTMLAction());
    ui.setAction(DesignEditorLID.ExportToXML, createExportDesignToXMLAction());
    ui.setAction(DesignEditorLID.Undo, new UndoController.UndoAction(undoMgr, interaction));
    ui.setAction(DesignEditorLID.Redo, new UndoController.RedoAction(undoMgr, interaction));
    ui.setAction(DesignEditorLID.Paste, createPasteAction());
    ui.setAction(DesignEditorLID.CopyFrame, createCopyFrameAction());
    ui.setAction(DesignEditorLID.CutFrame, createCutFrameAction());
    ui.setAction(DesignEditorLID.ClearFrameTemplate, new AListenerAction() {

        public boolean performAction(Object prms) {
            FrameTemplateSupport.clearFrameTemplate(design);
            return true;
        }
    });
    ui.setAction(DesignEditorLID.DeselectAll, new IListenerAction() {

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

        public boolean performAction(Object prms) {
            SelectionState selection = (SelectionState) prms;
            selection.deselectAll();
            return true;
        }
    });
    ui.setAction(DesignEditorLID.MoveFrames, new IListenerAction() {

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

        public boolean performAction(Object prms) {
            DesignEditorUI.MoveParameters movePrms = (DesignEditorUI.MoveParameters) prms;
            if (movePrms != null) {
                return moveFrames(movePrms.dx, movePrms.dy, movePrms.selection);
            } else {
                throw new RcvrUIException("Cannot move frames without parameters.");
            }
        }
    });
    ui.setAction(DesignEditorLID.AddDesignDevices, createAddDevicesAction());
    ui.setAction(DesignEditorLID.NewFrame, createNewFrameAction());
    // Align selected frames
    ui.setAction(DesignEditorLID.AlignTop, new FrameAlignmentAction(AlignmentAction.TOP));
    ui.setAction(DesignEditorLID.AlignBottom, new FrameAlignmentAction(AlignmentAction.BOTTOM));
    ui.setAction(DesignEditorLID.AlignLeft, new FrameAlignmentAction(AlignmentAction.LEFT));
    ui.setAction(DesignEditorLID.AlignRight, new FrameAlignmentAction(AlignmentAction.RIGHT));
    ui.setAction(DesignEditorLID.AlignCenter, new FrameAlignmentAction(AlignmentAction.CENTER));
    ui.setAction(DesignEditorLID.AlignHorizCenter, new FrameAlignmentAction(AlignmentAction.HORIZ_CENTER));
    ui.setAction(DesignEditorLID.AlignVertCenter, new FrameAlignmentAction(AlignmentAction.VERT_CENTER));
    // Space selected frames equally
    ui.setAction(DesignEditorLID.SpaceVertically, new IListenerAction() {

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

        @SuppressWarnings("unchecked")
        public boolean performAction(Object prms) {
            Map<Frame, DoubleRectangle> frameMap = (Map<Frame, DoubleRectangle>) prms;
            // Equally space the widgets in the
            // vertical axis.
            final boolean VERTICAL = true;
            return spaceFramesEqually(frameMap, VERTICAL);
        }
    });
    ui.setAction(DesignEditorLID.SpaceHorizontally, new IListenerAction() {

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

        @SuppressWarnings("unchecked")
        public boolean performAction(Object prms) {
            Map<Frame, DoubleRectangle> frameMap = (Map<Frame, DoubleRectangle>) prms;
            // Equally space the widgets in the
            // horizontal axis.
            final boolean HORIZONTAL = false;
            return spaceFramesEqually(frameMap, HORIZONTAL);
        }
    });
    ui.setAction(DesignEditorLID.InitiateFrameRename, createInitiateFrameRenameAction());
    ui.setAction(DesignEditorLID.RenameFrame, new IListenerAction() {

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

        public boolean performAction(Object prms) {
            DesignEditorUI.FrameRenameParameters evt = (DesignEditorUI.FrameRenameParameters) prms;
            return renameFrame(evt.frame, evt.newName);
        }
    });
    ui.setAction(ProjectLID.RenameDesign, new IListenerAction() {

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

        public boolean performAction(Object prms) {
            DesignEditorUI.DesignRenameParameters evt = (DesignEditorUI.DesignRenameParameters) prms;
            return renameDesign(evt.design, evt.newText);
        }
    });
    ui.setAction(DesignEditorLID.NewTransition, createNewTransitionAction());
    ui.setAction(DesignEditorLID.EditFrame, createEditFrameAction());
    ui.setAction(DesignEditorLID.EditTransition, createEditTransitionAction());
    ui.setAction(DesignEditorLID.DeleteFrame, createDeleteFrameAction());
    ui.setAction(DesignEditorLID.DeleteTransition, createDeleteTransitionAction());
    // Nudge selected frame(s)
    ui.setAction(DesignEditorLID.NudgeLeft, new IListenerAction() {

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

        public boolean performAction(Object prms) {
            FrameSelectionState selection = (FrameSelectionState) prms;
            double dx = -1.0 / ui.getZoom();
            return moveFrames(dx, 0.0, selection);
        }
    });
    ui.setAction(DesignEditorLID.NudgeRight, new IListenerAction() {

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

        public boolean performAction(Object prms) {
            FrameSelectionState selection = (FrameSelectionState) prms;
            double dx = 1.0 / ui.getZoom();
            return moveFrames(dx, 0.0, selection);
        }
    });
    ui.setAction(DesignEditorLID.NudgeUp, new IListenerAction() {

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

        public boolean performAction(Object prms) {
            FrameSelectionState selection = (FrameSelectionState) prms;
            double dy = -1.0 / ui.getZoom();
            return moveFrames(0.0, dy, selection);
        }
    });
    ui.setAction(DesignEditorLID.NudgeDown, new IListenerAction() {

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

        public boolean performAction(Object prms) {
            FrameSelectionState selection = (FrameSelectionState) prms;
            double dy = 1.0 / ui.getZoom();
            return moveFrames(0.0, dy, selection);
        }
    });
    ui.setAction(DesignEditorLID.SelectAll, new AListenerAction() {

        public boolean performAction(Object prms) {
            ui.selectAllFrames();
            return true;
        }
    });
    ui.setAction(DesignEditorLID.ChangeTarget, createChangeTargetAction());
    ui.setAction(DesignEditorLID.ChangeSource, createChangeSourceAction());
    // The following 6 are also functionality in FrameEditorController
    ui.setAction(DesignEditorLID.SetBackgroundImage, createSetBackgroundImageAction());
    ui.setAction(DesignEditorLID.RemoveBackgroundImage, createRemoveBackgroundImageAction());
    ui.setAction(DesignEditorLID.CopyImageAsBackground, createCopyImageAsBkgAction());
    ui.setAction(DesignEditorLID.PasteBackgroundImage, createPasteBackgroundImageAction());
    ui.setAction(DesignEditorLID.SetWidgetColor, createSetWidgetColorAction());
    // Skins!
    ui.setAction(DesignEditorLID.SkinWireFrame, createSetSkinAction(SkinType.WireFrame, DesignEditorLID.SkinWireFrame));
    ui.setAction(DesignEditorLID.SkinMacOSX, createSetSkinAction(SkinType.MacOSX, DesignEditorLID.SkinMacOSX));
    ui.setAction(DesignEditorLID.SkinWinXP, createSetSkinAction(SkinType.WinXP, DesignEditorLID.SkinWinXP));
    ui.setAction(DesignEditorLID.SkinPalm, createSetSkinAction(SkinType.Palm, DesignEditorLID.SkinPalm));
    ui.setAction(CogToolLID.RenderAll, createRenderAllAction(true, CogToolLID.RenderAll));
    ui.setAction(CogToolLID.UnRender, createRenderAllAction(false, CogToolLID.UnRender));
    ui.setAction(DesignEditorLID.ImportImageDirectory, createImportImageDirectory());
    IListenerAction action = createChangeActionAction();
    ui.setAction(DesignEditorLID.ChangeWidgetAction, action);
    ui.setAction(DesignEditorLID.ChangeDeviceAction, action);
    ui.setAction(DesignEditorLID.DuplicateFrame, createDuplicateFrameAction());
    ui.setAction(DesignEditorLID.ChangeDelay, createChangeDelayAction());
}
Also used : FrameSelectionState(edu.cmu.cs.hcii.cogtool.ui.FrameSelectionState) Frame(edu.cmu.cs.hcii.cogtool.model.Frame) AListenerAction(edu.cmu.cs.hcii.cogtool.util.AListenerAction) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle) DesignEditorUI(edu.cmu.cs.hcii.cogtool.ui.DesignEditorUI) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) Map(java.util.Map) HashMap(java.util.HashMap) DesignEditorSelectionState(edu.cmu.cs.hcii.cogtool.ui.DesignEditorSelectionState) SelectionState(edu.cmu.cs.hcii.cogtool.ui.SelectionState) FrameSelectionState(edu.cmu.cs.hcii.cogtool.ui.FrameSelectionState) RcvrUIException(edu.cmu.cs.hcii.cogtool.util.RcvrUIException)

Example 5 with RcvrUIException

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

the class StandardDrawingEditor method setZoomFromUserInput.

protected void setZoomFromUserInput(String userInput) {
    // TODO: this still really isn't the right UI. Instead of validating
    //       the value entered and then fussing at the user if it's not
    //       right, we should really be looking after every key press
    //       or paste operation and only allowing legal values to be
    //       entered at all.
    // TODO: deal with localization here. Number formats are also locale
    //       specific. When we deal with that in general, it needs to be
    //       dealt with here. The major issue is the symbol used as a
    //       radix point. As of right now ZOOM_VALUE_PATTERN can be
    //       localized, but the call to parseDouble below is not locale-
    //       sensitive, and needs eventually to be replaced by something
    //       that is.
    Matcher zoomMatcher = ZOOM_VALUE_PATTERN.matcher(userInput);
    if (zoomMatcher.matches()) {
        try {
            double newZoom = Double.parseDouble(zoomMatcher.group(1)) / 100.0;
            if (newZoom < MINIMUM_ZOOM) {
                // TODO: interact with the user, indicating that the
                //       value is too small (see comment at top of this
                //       file regarding likely need for an Interaction).
                newZoom = MINIMUM_ZOOM;
            } else if (newZoom > MAXIMUM_ZOOM) {
                // TODO: interact with the user, indicating that the
                //       value is too large (see comment at top of this
                //       file regarding likely need for an Interaction).
                newZoom = MAXIMUM_ZOOM;
            }
            zoomable.performZoom(newZoom);
        } catch (NumberFormatException e) {
            throw new RcvrUIException("Number format mismatch in zoom value.");
        }
    } else {
    // TODO: interact with the user, indicating that the value is
    //       not of the expected format; throw exception when
    //       exception architecture is "completed"
    }
}
Also used : Matcher(java.util.regex.Matcher) RcvrUIException(edu.cmu.cs.hcii.cogtool.util.RcvrUIException)

Aggregations

RcvrUIException (edu.cmu.cs.hcii.cogtool.util.RcvrUIException)9 Shell (org.eclipse.swt.widgets.Shell)3 DesignEditorUI (edu.cmu.cs.hcii.cogtool.ui.DesignEditorUI)2 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)2 ListenerIdentifier (edu.cmu.cs.hcii.cogtool.util.ListenerIdentifier)2 MenuItem (org.eclipse.swt.widgets.MenuItem)2 Design (edu.cmu.cs.hcii.cogtool.model.Design)1 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)1 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)1 DesignEditorSelectionState (edu.cmu.cs.hcii.cogtool.ui.DesignEditorSelectionState)1 FrameSelectionState (edu.cmu.cs.hcii.cogtool.ui.FrameSelectionState)1 SelectionState (edu.cmu.cs.hcii.cogtool.ui.SelectionState)1 AListenerAction (edu.cmu.cs.hcii.cogtool.util.AListenerAction)1 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)1 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)1 RcvrIOTempException (edu.cmu.cs.hcii.cogtool.util.RcvrIOTempException)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1