Search in sources :

Example 1 with SelectionState

use of edu.cmu.cs.hcii.cogtool.ui.SelectionState 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 2 with SelectionState

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

the class ProjectController method assignActions.

/**
     * Registers the set of <code>IListenerAction</code> instances
     * that implement the semantic actions that are possible.
     * <p>
     * For this class, this consists of the actions for a project editor.
     *
     * @author mlh
     */
@Override
public void assignActions() {
    super.assignActions();
    ui.setAction(ProjectLID.Undo, new UndoController.UndoAction(undoMgr, interaction));
    ui.setAction(ProjectLID.Redo, new UndoController.RedoAction(undoMgr, interaction));
    ui.setAction(ProjectLID.DeselectAll, new IListenerAction() {

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

        public boolean performAction(Object prms) {
            SelectionState selection = (SelectionState) prms;
            selection.deselectAll();
            return true;
        }
    });
    ui.setAction(ProjectLID.CopyResultsToClipboard, createCopyResultsAction());
    ui.setAction(ProjectLID.Paste, createPasteAction());
    ui.setAction(ProjectLID.CaptureBehavior, createCaptureAction());
    ui.setAction(ProjectLID.CopyDesign, createCopyDesignAction());
    ui.setAction(ProjectLID.CopyTask, createCopyTaskAction());
    ui.setAction(ProjectLID.CutDesign, createCutDesignAction());
    ui.setAction(ProjectLID.CutTask, createCutTaskAction());
    ui.setAction(ProjectLID.SelectAll, new AListenerAction() {

        public boolean performAction(Object prms) {
            ui.selectAllTasks();
            return true;
        }
    });
    ui.setAction(ProjectLID.NewDesign, createNewDesignAction());
    ui.setAction(ProjectLID.NewDesignFromImport, createNewDesignForImport());
    ui.setAction(ProjectLID.AddDesignDevices, createAddDesignDevicesAction());
    ui.setAction(ProjectLID.NewProjectNewDesign, createNameProjectNewDesignAction());
    ui.setAction(ProjectLID.EditDesign, createEditDesignAction());
    ui.setAction(ProjectLID.EditTask, new IListenerAction() {

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

        public boolean performAction(Object prms) {
            TaskSelectionState selection = (TaskSelectionState) prms;
            int selectedTaskCount = selection.getSelectedTaskCount();
            if (selectedTaskCount == 1) {
                AUndertaking selectedTask = selection.getSelectedTask();
                ui.initiateTaskRename(selectedTask);
                return true;
            }
            if (selectedTaskCount == 0) {
                interaction.protestNoSelection();
            } else {
                interaction.protestTooManySelectedTasks();
            }
            return false;
        }
    });
    ui.setAction(ProjectLID.RenameDesign, createRenameDesignAction());
    ui.setAction(ProjectLID.InitiateTaskRename, createInitiateTaskRenameAction());
    ui.setAction(ProjectLID.HCIPARenameTask, new IListenerAction() {

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

        public boolean performAction(Object prms) {
            ProjectUI.TaskRenameEvent evt = (ProjectUI.TaskRenameEvent) prms;
            return hcipaRenameTask(evt.task, evt.task.getName(), evt.newName);
        }
    });
    ui.setAction(ProjectLID.RenameTask, new IListenerAction() {

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

        public boolean performAction(Object prms) {
            ProjectUI.TaskRenameEvent evt = (ProjectUI.TaskRenameEvent) prms;
            return renameTask(evt.task, evt.task.getName(), evt.newName, evt.parent);
        }
    });
    ui.setAction(ProjectLID.EditScript, createScriptEditorAction());
    ui.setAction(ProjectLID.ViewGroupScript, createScriptViewerAction());
    ui.setAction(ProjectLID.DeleteDesign, createDeleteDesignAction());
    ui.setAction(ProjectLID.DeleteTask, createDeleteTaskAction());
    ui.setAction(ProjectLID.NewTask, createNewTaskAction());
    ui.setAction(ProjectLID.NewTaskGroup, createNewTaskGroupAction());
    ui.setAction(ProjectLID.ReorderDesigns, createReorderDesignsAction());
    ui.setAction(ProjectLID.ShowSum, createShowNatureAction(GroupNature.SUM, ProjectLID.ShowSum));
    ui.setAction(ProjectLID.ShowMean, createShowNatureAction(GroupNature.MEAN, ProjectLID.ShowMean));
    ui.setAction(ProjectLID.ShowMin, createShowNatureAction(GroupNature.MIN, ProjectLID.ShowMin));
    ui.setAction(ProjectLID.ShowMax, createShowNatureAction(GroupNature.MAX, ProjectLID.ShowMax));
    ui.setAction(ProjectLID.RegenerateScript, createRegenerateScriptAction());
    ui.setAction(ProjectLID.RecomputeScript, createRecomputeScriptAction());
    ui.setAction(ProjectLID.ShowModelVisualization, createShowModelVisualizationAction());
    ui.setAction(ProjectLID.DisplayTraces, createDisplayTraces());
    ui.setAction(ProjectLID.ExportTraces, createExportTraces());
    ui.setAction(ProjectLID.ExportForSanlab, createExportForSanlab());
    ui.setAction(ProjectLID.ExportActrModelFile, createExportActrModelFile());
    ui.setAction(ProjectLID.ExportDesignToHTML, createExportDesignToHTMLAction());
    ui.setAction(ProjectLID.ExportToHCIPA, createExportToHCIPAAction());
    ui.setAction(ProjectLID.ExportResultsToCSV, createExportResultsToCSVAction());
    ui.setAction(ProjectLID.ImportXML, createImportAction());
    /*for(CogToolLID lid : ProjectLID.getCollection())
        {
            this.ui.setAction(lid,
                              createImportAction());
        }*/
    /*this.ui.setAction(ProjectLID.ImportXML,
        new IListenerAction() {

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

<<<<<<< .mine

          public boolean performAction(Object prms)
          {
              Class convClass =  (Class)prms;

              createImportAction(convClass);
              return true;
          }
      });*/
    ui.setAction(ProjectLID.ImportWebCrawl, createImportWebCrawlAction());
    ui.setAction(ProjectLID.ExportScriptToCSV, createExportScriptToCSVAction());
    ui.setAction(ProjectLID.ExportToXML, createExportDesignToXML());
    ui.setAction(ProjectLID.DuplicateDesign, createDuplicateDesignAction());
    ui.setAction(ProjectLID.DuplicateTask, createDuplicateTasksAction());
    ui.setAction(ProjectLID.ImportHumanCSVFile, createImportHumanCSVFileAction());
    ui.setAction(ProjectLID.SetAlgorithmACTR6, createSetAlgorithmAction(ACTR6PredictionAlgo.ONLY, ProjectLID.SetAlgorithmACTR6, SET_ALG_ACTR6));
    ui.setAction(ProjectLID.SetAlgorithmSNIFACT, createSetAlgorithmAction(SNIFACTPredictionAlgo.ONLY, ProjectLID.SetAlgorithmSNIFACT, SET_ALG_SNIFACT));
    ui.setAction(ProjectLID.SetAlgorithmHuman, createSetAlgorithmHumanAction());
    ui.setAction(ProjectLID.EditACTRModelFile, createEditACTRModelAction());
    ui.setAction(ProjectLID.SetBackgroundComputationDefault, createSetBackgroundComputeAction(TaskApplication.USE_PROJECT_DEFAULT, ProjectLID.SetBackgroundComputationDefault, SET_RUN_PROJECT_DEFAULT));
    ui.setAction(ProjectLID.SetBackgroundComputationTrue, createSetBackgroundComputeAction(TaskApplication.RUN_IN_BACKGROUND, ProjectLID.SetBackgroundComputationTrue, SET_RUN_BACKGROUND));
    ui.setAction(ProjectLID.SetBackgroundComputationFalse, createSetBackgroundComputeAction(TaskApplication.RUN_IN_FOREGROUND, ProjectLID.SetBackgroundComputationFalse, SET_RUN_FOREGROUND));
    ui.setAction(ProjectLID.GenerateACTRModelFile, createGenerateACTRModelAction());
    ui.setAction(ProjectLID.SetProjDefaultAlgoACTR, createSetProjDefaultAlg(ProjectLID.SetProjDefaultAlgoACTR, SET_PROJ_DEFAULT_ACTR, ACTR6PredictionAlgo.ONLY));
    ui.setAction(ProjectLID.SetProjDefaultAlgoSNIFACT, createSetProjDefaultAlg(ProjectLID.SetProjDefaultAlgoSNIFACT, SET_PROJ_DEFAULT_SNIFACT, SNIFACTPredictionAlgo.ONLY));
    ui.setAction(ProjectLID.SetProjExecBackground, createSetProjDefaultExecBkg(ProjectLID.SetProjExecBackground, SET_RUN_BKG_DEFAULT, true));
    ui.setAction(ProjectLID.SetProjExecForeground, createSetProjDefaultExecBkg(ProjectLID.SetProjExecForeground, SET_RUN_FG_DEFAULT, false));
    ui.setAction(ProjectLID.ChangeTaskPosition, createChangeTaskPositionAction());
    ui.setAction(ProjectLID.DuplicateTaskFull, createDuplicateTaskFullAction());
    ui.setAction(ProjectLID.Ungroup, createUngroupAction());
    ui.setAction(ProjectLID.PromoteTask, createPromoteTaskAction());
    ui.setAction(ProjectLID.DemoteTask, createDemoteTaskAction());
    ui.setAction(ProjectLID.MoveTaskEarlier, createMoveTaskEarlierAction());
    ui.setAction(ProjectLID.MoveTaskLater, createMoveTaskLaterAction());
    ui.setAction(ProjectLID.GenerateDictionary, createGenerateDictionaryAction());
    ui.setAction(ProjectLID.EditDictionary, createOpenDictionaryAction());
    ui.setAction(ProjectLID.ExportDictToCSV, createExportDictionaryAction());
    ui.setAction(ProjectLID.ImportDict, createImportDictionaryAction());
    ui.setAction(ProjectLID.MoveTaskApplication, createMoveTaskAppAction());
    ui.setAction(ProjectLID.DuplicateTaskApplication, createDuplicateTaskAppAction());
}
Also used : ProjectUI(edu.cmu.cs.hcii.cogtool.ui.ProjectUI) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) AListenerAction(edu.cmu.cs.hcii.cogtool.util.AListenerAction) AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking) TaskSelectionState(edu.cmu.cs.hcii.cogtool.ui.TaskSelectionState) TaskSelectionState(edu.cmu.cs.hcii.cogtool.ui.TaskSelectionState) ProjectSelectionState(edu.cmu.cs.hcii.cogtool.ui.ProjectSelectionState) SelectionState(edu.cmu.cs.hcii.cogtool.ui.SelectionState) DesignSelectionState(edu.cmu.cs.hcii.cogtool.ui.DesignSelectionState) ProjectContextSelectionState(edu.cmu.cs.hcii.cogtool.ui.ProjectContextSelectionState)

Aggregations

SelectionState (edu.cmu.cs.hcii.cogtool.ui.SelectionState)2 AListenerAction (edu.cmu.cs.hcii.cogtool.util.AListenerAction)2 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)2 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)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 DesignEditorUI (edu.cmu.cs.hcii.cogtool.ui.DesignEditorUI)1 DesignSelectionState (edu.cmu.cs.hcii.cogtool.ui.DesignSelectionState)1 FrameSelectionState (edu.cmu.cs.hcii.cogtool.ui.FrameSelectionState)1 ProjectContextSelectionState (edu.cmu.cs.hcii.cogtool.ui.ProjectContextSelectionState)1 ProjectSelectionState (edu.cmu.cs.hcii.cogtool.ui.ProjectSelectionState)1 ProjectUI (edu.cmu.cs.hcii.cogtool.ui.ProjectUI)1 TaskSelectionState (edu.cmu.cs.hcii.cogtool.ui.TaskSelectionState)1 RcvrUIException (edu.cmu.cs.hcii.cogtool.util.RcvrUIException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1