Search in sources :

Example 6 with FrameSelectionState

use of edu.cmu.cs.hcii.cogtool.ui.FrameSelectionState in project cogtool by cogtool.

the class DesignEditorController method createEditFrameAction.

protected IListenerAction createEditFrameAction() {
    return new IListenerAction() {

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

        public boolean performAction(Object prms) {
            FrameSelectionState selection = (FrameSelectionState) prms;
            Frame[] frames = selection.getSelectedFrames();
            if ((frames == null) || (frames.length == 0)) {
                interaction.protestNoSelection();
                return false;
            }
            for (Frame frame : frames) {
                try {
                    FrameEditorController.openController(frame, design, project);
                } catch (GraphicsUtil.ImageException ex) {
                    interaction.protestInvalidImageFile();
                }
            }
            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) GraphicsUtil(edu.cmu.cs.hcii.cogtool.util.GraphicsUtil)

Example 7 with FrameSelectionState

use of edu.cmu.cs.hcii.cogtool.ui.FrameSelectionState in project cogtool by cogtool.

the class DesignEditorController method createCopyFrameAction.

protected IListenerAction createCopyFrameAction() {
    return new IListenerAction() {

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

        public boolean performAction(Object prms) {
            FrameSelectionState seln = (FrameSelectionState) prms;
            Frame[] frames = seln.getSelectedFrames();
            if ((frames != null) && (frames.length > 0)) {
                copyFrames(frames);
                if (frames.length == 1) {
                    interaction.setStatusMessage(FRAME_COPIED);
                } else {
                    interaction.setStatusMessage(FRAMES_COPIED);
                }
                return true;
            }
            interaction.protestNoSelection();
            return false;
        }
    };
}
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)

Example 8 with FrameSelectionState

use of edu.cmu.cs.hcii.cogtool.ui.FrameSelectionState in project cogtool by cogtool.

the class DesignEditorController method createSetBackgroundImageAction.

/**
	 * Create a ListenerAction to handle setting frame background image on
	 * multiple frames
	 */
protected IListenerAction createSetBackgroundImageAction() {
    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();
            // this code is from FrameEditorController
            // load image
            // Pull up interaction to select a file
            String imageURL = interaction.selectImageFile();
            // Check if the dialog was cancelled
            if (imageURL != null) {
                byte[] imageData;
                try {
                    // Set the background to new image
                    imageData = GraphicsUtil.loadImageFromFile(imageURL);
                    setBackgroundImageOnFrames(frames, imageData, imageURL, DesignEditorLID.SetBackgroundImage);
                    return true;
                } catch (IOException e) {
                    interaction.protestUnreadableFile();
                    imageData = null;
                }
            }
            return false;
        }
    };
}
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) RcvrIOException(edu.cmu.cs.hcii.cogtool.util.RcvrIOException) IOException(java.io.IOException)

Example 9 with FrameSelectionState

use of edu.cmu.cs.hcii.cogtool.ui.FrameSelectionState in project cogtool by cogtool.

the class DesignEditorController method createDeleteFrameAction.

// createNewTransition
protected IListenerAction createDeleteFrameAction() {
    return new IListenerAction() {

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

        public boolean performAction(Object prms) {
            FrameSelectionState selection = (FrameSelectionState) prms;
            Frame[] frames = selection.getSelectedFrames();
            if ((frames != null) && (frames.length > 0)) {
                if (interaction.confirmDeleteFrames(frames)) {
                    deleteFrames(frames);
                    return true;
                }
            } else {
                interaction.protestNoSelection();
            }
            return false;
        }
    };
}
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

FrameSelectionState (edu.cmu.cs.hcii.cogtool.ui.FrameSelectionState)9 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)9 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)8 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)2 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)1 DesignEditorSelectionState (edu.cmu.cs.hcii.cogtool.ui.DesignEditorSelectionState)1 DesignEditorUI (edu.cmu.cs.hcii.cogtool.ui.DesignEditorUI)1 SelectionState (edu.cmu.cs.hcii.cogtool.ui.SelectionState)1 AListenerAction (edu.cmu.cs.hcii.cogtool.util.AListenerAction)1 GraphicsUtil (edu.cmu.cs.hcii.cogtool.util.GraphicsUtil)1 RcvrIOException (edu.cmu.cs.hcii.cogtool.util.RcvrIOException)1 RcvrUIException (edu.cmu.cs.hcii.cogtool.util.RcvrUIException)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1