use of edu.cmu.cs.hcii.cogtool.util.AListenerAction in project cogtool by cogtool.
the class ProjectController method createExportToHCIPAAction.
protected IListenerAction createExportToHCIPAAction() {
return new AListenerAction() {
public boolean performAction(Object prms) {
ProjectSelectionState sel = (ProjectSelectionState) prms;
Design design = sel.getSelectedDesign();
AUndertaking[] tasks = sel.getSelectedTasks(TaskSelectionState.PRUNE_SELECTION | TaskSelectionState.ORDER_SELECTION);
if (design != null) {
if ((tasks != null) && (tasks.length > 0)) {
for (int i = 0; i < tasks.length; i++) {
if (tasks[i].isTaskGroup() && (tasks[i].getTaskGroup() == null)) {
if (!exportToHCIPA(design, (TaskGroup) tasks[i])) {
return false;
}
}
}
} else {
Iterator<AUndertaking> allTasks = project.getUndertakings().iterator();
while (allTasks.hasNext()) {
AUndertaking topLevelTask = allTasks.next();
if (topLevelTask.isTaskGroup()) {
if (!exportToHCIPA(design, (TaskGroup) topLevelTask)) {
return false;
}
}
}
}
} else if ((tasks != null) && (tasks.length > 0)) {
for (int i = 0; i < tasks.length; i++) {
if (tasks[i].isTaskGroup() && (tasks[i].getTaskGroup() == null)) {
Iterator<Design> allDesigns = project.getDesigns().iterator();
while (allDesigns.hasNext()) {
if (!exportToHCIPA(allDesigns.next(), (TaskGroup) tasks[i])) {
return false;
}
}
}
}
} else {
interaction.protestNoSelection();
return false;
}
return true;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.AListenerAction in project cogtool by cogtool.
the class SEFrameChooserController method createOpenDemonstrationWindowAction.
/**
* Create the window for demonstrating the entire script.
*/
protected IListenerAction createOpenDemonstrationWindowAction() {
return new AListenerAction() {
public boolean performAction(Object prms) {
// Ensure there is a selected start frame.
final Demonstration demo = taskApp.getDemonstration();
final Script script = taskApp.getScript(modelGen);
if (demo.getStartFrame() != null) {
demo.setStartFrameChosen(true);
final Collection<ComputationUndoRedo> scriptsUndoRedos = DemoScriptCmd.regenerateScripts(demo, 0, demo.getStepAt(0), interaction);
// Close the current window.
closeWindow(false);
// Open the new demo view window
try {
SEDemoController.openController(taskApp, modelGen, project);
} catch (GraphicsUtil.ImageException ex) {
interaction.protestInvalidImageFile();
}
IUndoableEdit edit = new AUndoableEdit(SEFrameChooserLID.OpenScriptEditor) {
@Override
public String getPresentationName() {
return startDemonstrating;
}
@Override
public void redo() {
super.redo();
if (demo.getStartFrame() != null) {
demo.setStartFrameChosen(true);
DemoScriptCmd.redoAllChanges(scriptsUndoRedos);
// Close the frame chooser window.
DefaultController frameController = ControllerRegistry.ONLY.findOpenController(taskApp);
if (frameController != null) {
frameController.closeWindow(false);
}
// Open the new demo view window
try {
SEDemoController.openController(taskApp, modelGen, project);
} catch (GraphicsUtil.ImageException ex) {
interaction.protestInvalidImageFile();
}
}
}
@Override
public void undo() {
super.undo();
DefaultController seDemoController = ControllerRegistry.ONLY.findOpenController(script);
if (seDemoController != null) {
seDemoController.closeWindow(false);
}
demo.setStartFrameChosen(false);
DemoScriptCmd.undoAllChanges(scriptsUndoRedos);
SEFrameChooserController.openController(taskApp, modelGen, project);
}
};
UndoManager scriptUndoMgr = UndoManager.getUndoManager(script, project);
scriptUndoMgr.addEdit(edit);
undoMgr.addEdit(edit);
return true;
}
interaction.protestNoSelection();
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.AListenerAction in project cogtool by cogtool.
the class FrameEditorController method createSetSkinAction.
private AListenerAction createSetSkinAction(final SkinType newSkin, final CogToolLID lid) {
return new AListenerAction() {
public boolean performAction(Object prms) {
final SkinType oldSkin = design.getSkin();
design.setSkin(newSkin);
IUndoableEdit edit = new AUndoableEdit(lid) {
@Override
public String getPresentationName() {
return CHANGE_SKIN;
}
@Override
public void redo() {
super.redo();
design.setSkin(newSkin);
}
@Override
public void undo() {
super.undo();
design.setSkin(oldSkin);
}
};
UndoManager designUndoMgr = UndoManager.getUndoManager(design, project);
designUndoMgr.addEdit(edit);
undoMgr.addEdit(edit);
return true;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.AListenerAction in project cogtool by cogtool.
the class FrameEditorController method assignActions.
/**
* Add the listeners for Menu Items, and other LID listeners
*/
@Override
public void assignActions() {
// get the default actions from Default controller
super.assignActions();
// Enable undo & redo
ui.setAction(FrameEditorLID.Undo, new UndoController.UndoAction(undoMgr, interaction));
ui.setAction(FrameEditorLID.Redo, new UndoController.RedoAction(undoMgr, interaction));
// Enable cut copy and paste
ui.setAction(FrameEditorLID.Paste, createPasteAction());
ui.setAction(FrameEditorLID.SetFrameTemplate, createSetFrameTemplateAction());
ui.setAction(FrameEditorLID.ClearFrameTemplate, new AListenerAction() {
public boolean performAction(Object prms) {
FrameTemplateSupport.clearFrameTemplate(design);
return true;
}
});
ui.setAction(FrameEditorLID.Copy, createCopyWidgetAction());
ui.setAction(FrameEditorLID.Cut, createCutWidgetAction());
ui.setAction(CogToolLID.CopyPath, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
FrameEditorSelectionState seln = (FrameEditorSelectionState) prms;
if (seln.getWidgetSelectionCount() != 1) {
return false;
}
IWidget w = seln.getSelectedIWidgets()[0];
Object pathObj = w.getAttribute(WidgetAttributes.IMAGE_PATH_ATTR);
if (!NullSafe.equals(WidgetAttributes.NO_IMAGE, pathObj)) {
ClipboardUtil.copyTextData((String) pathObj);
}
return true;
}
});
ui.setAction(FrameEditorLID.Rename, createInitiateRenameAction());
ui.setAction(FrameEditorLID.Relabel, createInitiateRelabelAction());
// Select all.
ui.setAction(FrameEditorLID.SelectAll, new AListenerAction() {
public boolean performAction(Object prms) {
ui.selectAllWidgets();
return true;
}
});
// Creating a new widget
// May be called from the menu item, or from mouseState
ui.setAction(FrameEditorLID.NewWidget, createNewWidgetAction());
ui.setAction(FrameEditorLID.NewWidgetJustWarn, createNewWidgetExplanationAction());
// Delete an item.
// Requires a selection state
ui.setAction(FrameEditorLID.Delete, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
FrameEditorSelectionState selection = (FrameEditorSelectionState) prms;
// Delete the item / add undo
return deleteElements(selection);
}
});
// Adjust image/color properties
ui.setAction(FrameEditorLID.SetBackgroundImage, createSetBackgroundImageAction());
// Clear the background of an image.
ui.setAction(FrameEditorLID.RemoveBackgroundImage, new AListenerAction() {
public boolean performAction(Object prms) {
// Clear background, by saying use
// "no" image.
setBackgroundImage(null, WidgetAttributes.NO_IMAGE);
return true;
}
});
ui.setAction(FrameEditorLID.CopyImageAsBackground, createCopyImageAsBkgAction());
ui.setAction(FrameEditorLID.PasteBackgroundImage, createPasteBackgroundImageAction());
// Set the color of the widgets.
ui.setAction(FrameEditorLID.SetWidgetColor, newSetWidgetColorAction());
// Skins!
ui.setAction(FrameEditorLID.SkinWireFrame, createSetSkinAction(SkinType.WireFrame, FrameEditorLID.SkinWireFrame));
ui.setAction(FrameEditorLID.SkinMacOSX, createSetSkinAction(SkinType.MacOSX, FrameEditorLID.SkinMacOSX));
ui.setAction(FrameEditorLID.SkinWinXP, createSetSkinAction(SkinType.WinXP, FrameEditorLID.SkinWinXP));
ui.setAction(FrameEditorLID.SkinPalm, createSetSkinAction(SkinType.Palm, FrameEditorLID.SkinPalm));
ui.setAction(CogToolLID.RenderAll, createRenderAllAction(true, CogToolLID.RenderAll));
ui.setAction(CogToolLID.UnRender, createRenderAllAction(false, CogToolLID.UnRender));
// Nudge selected widget(s)
// requires selection
ui.setAction(FrameEditorLID.NudgeLeft, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
FrameEditorSelectionState selection = (FrameEditorSelectionState) prms;
// Displace left by 1 pixel scaled by
// the zoom
double dx = -1.0 / ui.getZoom();
// Move by the point
return moveElements(selection, dx, 0.0);
}
});
ui.setAction(FrameEditorLID.NudgeRight, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
FrameEditorSelectionState selection = (FrameEditorSelectionState) prms;
// Move by 1 pixel scaled by zoom right.
double dx = 1.0 / ui.getZoom();
return moveElements(selection, dx, 0.0);
}
});
ui.setAction(FrameEditorLID.NudgeUp, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
FrameEditorSelectionState selection = (FrameEditorSelectionState) prms;
// Move up 1 pixel scaled by zoom
double dy = -1.0 / ui.getZoom();
return moveElements(selection, 0.0, dy);
}
});
ui.setAction(FrameEditorLID.NudgeDown, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
FrameEditorSelectionState selection = (FrameEditorSelectionState) prms;
// move down by 1 pixel scaled by zoom
double dy = 1.0 / ui.getZoom();
return moveElements(selection, 0.0, dy);
}
});
// Align selected widgets
ui.setAction(FrameEditorLID.AlignTop, new ElementAlignmentAction(AlignmentAction.TOP));
ui.setAction(FrameEditorLID.AlignBottom, new ElementAlignmentAction(AlignmentAction.BOTTOM));
ui.setAction(FrameEditorLID.AlignLeft, new ElementAlignmentAction(AlignmentAction.LEFT));
ui.setAction(FrameEditorLID.AlignRight, new ElementAlignmentAction(AlignmentAction.RIGHT));
ui.setAction(FrameEditorLID.AlignCenter, new ElementAlignmentAction(AlignmentAction.CENTER));
ui.setAction(FrameEditorLID.AlignHorizCenter, new ElementAlignmentAction(AlignmentAction.HORIZ_CENTER));
ui.setAction(FrameEditorLID.AlignVertCenter, new ElementAlignmentAction(AlignmentAction.VERT_CENTER));
// Space selected widgets equally
ui.setAction(FrameEditorLID.SpaceVertically, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
FrameEditorSelectionState selection = (FrameEditorSelectionState) prms;
// Equally space the widgets in the
// vertical axis.
final boolean VERTICAL = true;
return spaceElementsEqually(selection, VERTICAL);
}
});
ui.setAction(FrameEditorLID.SpaceHorizontally, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
FrameEditorSelectionState selection = (FrameEditorSelectionState) prms;
// Equally space the widgets in the
// horizontal axis.
final boolean HORIZONTAL = false;
return spaceElementsEqually(selection, HORIZONTAL);
}
});
// Adjust ordering of selected widget(s)
ui.setAction(FrameEditorLID.BringToFront, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
CompoundUndoableEdit editSequence = new CompoundUndoableEdit(BRING_TO_FRONT, FrameEditorLID.BringToFront);
FrameEditorSelectionState selection = (FrameEditorSelectionState) prms;
// Get the list of selected widgets
// Keep them in the same level ordering
// they started in
IWidget[] selected = getSelectedWidgets(selection, Widget.WidgetLevelComparator.ONLY);
// set the level.
for (IWidget element : selected) {
// use MAX Value here
// adjustWidgetLevel will tell the frame
// and it will change MAX_VALUE to
// be the correct number
adjustWidgetLevel(Integer.MAX_VALUE, element, editSequence, editSequence.getLID());
}
editSequence.end();
// Only add this edit if it is significant
if (editSequence.isSignificant()) {
undoMgr.addEdit(editSequence);
}
return true;
}
});
ui.setAction(FrameEditorLID.BringForward, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
CompoundUndoableEdit editSequence = new CompoundUndoableEdit(BRING_FORWARD, FrameEditorLID.BringForward);
FrameEditorSelectionState selection = (FrameEditorSelectionState) prms;
// Get the list of selected widgets
// Keep them in the same level ordering
// they started in
IWidget[] selected = getSelectedWidgets(selection, Widget.WidgetLevelComparator.ONLY);
// Fix corner case where all the widgets are
// stacked downward from the top
// IE: Prevent the current top most item
// from moving.
int maxLevel = model.getWidgets().size() - 1;
// Traverse the list sorted by level in reverse order
for (int i = selected.length - 1; i >= 0; i--, maxLevel--) {
IWidget w = selected[i];
int widgetLevel = w.getLevel();
// try to increase it one.
if (widgetLevel < maxLevel) {
adjustWidgetLevel(widgetLevel + 1, w, editSequence, editSequence.getLID());
}
}
editSequence.end();
// Only add this edit if it is significant
if (editSequence.isSignificant()) {
undoMgr.addEdit(editSequence);
}
return true;
}
});
ui.setAction(FrameEditorLID.SendBackward, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
CompoundUndoableEdit editSequence = new CompoundUndoableEdit(SEND_BACKWARD, FrameEditorLID.SendBackward);
FrameEditorSelectionState selection = (FrameEditorSelectionState) prms;
// Get the list of selected widgets
// Keep them in the same level ordering
// they started in
IWidget[] selected = getSelectedWidgets(selection, Widget.WidgetLevelComparator.ONLY);
// Fix corner case where all the widgets are
// stacked upward from level 0
int minLevel = 0;
for (int i = 0; i < selected.length; i++, minLevel++) {
IWidget w = selected[i];
int widgetLevel = w.getLevel();
// move the level down by 1
if (widgetLevel > minLevel) {
adjustWidgetLevel(widgetLevel - 1, w, editSequence, editSequence.getLID());
}
}
editSequence.end();
// Only add this edit if it is significant
if (editSequence.isSignificant()) {
undoMgr.addEdit(editSequence);
}
return true;
}
});
ui.setAction(FrameEditorLID.SendToBack, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
CompoundUndoableEdit editSequence = new CompoundUndoableEdit(SEND_TO_BACK, FrameEditorLID.SendToBack);
FrameEditorSelectionState selection = (FrameEditorSelectionState) prms;
// Get the list of selected widgets
// Keep them in the same level ordering
// they started in
IWidget[] selected = getSelectedWidgets(selection, Widget.WidgetLevelComparator.ONLY);
// in the correct order
for (int i = selected.length - 1; i >= 0; i--) {
// try to move all towards 0.
adjustWidgetLevel(0, selected[i], editSequence, editSequence.getLID());
}
editSequence.end();
// Only add this edit if it is significant
if (editSequence.isSignificant()) {
undoMgr.addEdit(editSequence);
}
return true;
}
});
// Mouse operations on widgets
ui.setAction(FrameEditorLID.MoveWidgets, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorUI.MoveParameters.class;
}
public boolean performAction(Object prms) {
// Get the move parameters.
FrameEditorUI.MoveParameters movePrms = (FrameEditorUI.MoveParameters) prms;
if (movePrms != null) {
return moveElements(movePrms.selection, movePrms.moveByX, movePrms.moveByY, movePrms.moveAsGroup);
}
return false;
}
});
ui.setAction(FrameEditorLID.Reorder, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorUI.ReorderWidgetParameters.class;
}
public boolean performAction(Object prms) {
// Get the parameters.
FrameEditorUI.ReorderWidgetParameters rPrms = (FrameEditorUI.ReorderWidgetParameters) prms;
if (rPrms != null) {
if (rPrms.parent == null) {
return reorderWidget(rPrms.reorderWidget, rPrms.widgetGroup, rPrms.insertIndex);
}
return reorderChildWidget((ChildWidget) rPrms.reorderWidget, rPrms.widgetGroup, rPrms.insertIndex, rPrms.parent);
}
return false;
}
});
ui.setAction(FrameEditorLID.InsertDuplicate, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorUI.InsertDuplicateParameters.class;
}
public boolean performAction(Object prms) {
// Get the parameters.
FrameEditorUI.InsertDuplicateParameters iPrms = (FrameEditorUI.InsertDuplicateParameters) prms;
if (iPrms != null) {
return insertDuplicateWidget(iPrms.reorderWidget, iPrms.widgetGroup, iPrms.insertIndex, iPrms.parent, iPrms.moveByX, iPrms.moveByY);
}
return false;
}
});
ui.setAction(FrameEditorLID.ResizeWidgets, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorUI.ResizeParameters.class;
}
public boolean performAction(Object prms) {
FrameEditorUI.ResizeParameters resizePrms = (FrameEditorUI.ResizeParameters) prms;
if (prms != null) {
// Resize the frame elements based on prms
return resizeElements(resizePrms.oldX, resizePrms.oldY, resizePrms.newX, resizePrms.newY, resizePrms.ratioX, resizePrms.ratioY, resizePrms.selection);
}
return false;
}
});
// Change properties of selected widget(s)
ui.setAction(FrameEditorLID.ChangeShapeProperty, createChangeShapeAction());
// Change the widget title.
// The title is non unique.
ui.setAction(FrameEditorLID.ChangeTitleProperty, createChangeTitlePropertyAction());
ui.setAction(FrameEditorLID.ChangeAuxTextProperty, createChangeAuxTextPropertyAction());
// Change the name. This requires a UNIQUE name.
// Only one selected widget is expected.
ui.setAction(DesignEditorLID.RenameFrame, new IListenerAction() {
public Class<?> getParameterClass() {
return DesignEditorUI.FrameRenameParameters.class;
}
public boolean performAction(Object prms) {
DesignEditorUI.FrameRenameParameters p = (DesignEditorUI.FrameRenameParameters) prms;
return updateFrameName(p.frame, p.newName);
}
});
// Change the name. This requires a UNIQUE name.
// Only one selected widget is expected.
ui.setAction(FrameEditorLID.ChangeNameProperty, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorUI.ActionStringParameters.class;
}
public boolean performAction(Object prms) {
FrameEditorUI.ActionStringParameters p = (FrameEditorUI.ActionStringParameters) prms;
// Check selection count
int numWidgets = p.selection.getWidgetSelectionCount();
if (numWidgets == 0) {
interaction.protestNoSelection();
} else if (numWidgets > 1) {
interaction.protestTooManyWidgets();
} else {
IWidget[] selectedWidget = p.selection.getSelectedIWidgets();
// Update widget's name
return updateWidgetName(selectedWidget[0], p.newString);
}
return false;
}
});
// Change the type of the widget.
// TODO: this needs to be extended to invalidate transitions (e.g., if changed to Noninteractive)
ui.setAction(FrameEditorLID.ChangeTypeProperty, createChangeTypeAction());
ui.setAction(FrameEditorLID.SetRenderSkin, createSetRenderSkinAction());
// Set the widget image property.
ui.setAction(FrameEditorLID.SetImageProperty, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
FrameEditorSelectionState selection = (FrameEditorSelectionState) prms;
// Apply to all selected items.
Iterator<IWidget> selected = selection.getSelectedWidgetsIterator();
// Prompt user for the new file
String imageURL = interaction.selectImageFile();
// Check if the user canceled the dialog
if (imageURL != null) {
try {
byte[] imageData = GraphicsUtil.loadImageFromFile(imageURL);
setWidgetImages(selected, imageData, imageURL);
return true;
} catch (IOException e) {
// Tell the user if there was a
// problem reading the file.
interaction.protestUnreadableFile();
}
}
return false;
}
});
// Clear the image stored on a widget.
ui.setAction(FrameEditorLID.RemoveImageProperty, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
FrameEditorSelectionState selection = (FrameEditorSelectionState) prms;
Iterator<IWidget> selected = selection.getSelectedWidgetsIterator();
// Remove all the images
setWidgetImages(selected, null, WidgetAttributes.NO_IMAGE);
return true;
}
});
// capture the image under a widget..
// IE: get its background.
ui.setAction(FrameEditorLID.CaptureImageProperty, captureImageAction());
ui.setAction(FrameEditorLID.Duplicate, duplicateWidgetsAction());
ui.setAction(CogToolLID.SetAttribute, new IListenerAction() {
public Class<?> getParameterClass() {
return UI.SetAttributeParameters.class;
}
public boolean performAction(Object prms) {
UI.SetAttributeParameters saprms = (UI.SetAttributeParameters) prms;
return frameSetAttribute(saprms.target, saprms.attrName, saprms.value, undoMgr);
}
});
ui.setAction(FrameEditorLID.SetSpeakerText, new IListenerAction() {
public Class<?> getParameterClass() {
return String.class;
}
public boolean performAction(Object prms) {
return setSpeakerText((String) prms);
}
});
ui.setAction(FrameEditorLID.SetSpeakerTime, new IListenerAction() {
public Class<?> getParameterClass() {
return Double.class;
}
public boolean performAction(Object prms) {
double newTime = ((Double) prms).doubleValue();
return setSpeakerDuration(newTime);
}
});
ui.setAction(FrameEditorLID.AddDesignDevices, new AListenerAction() {
public boolean performAction(Object prms) {
return DesignCmd.addDevices(project, design, interaction);
}
});
ui.setAction(FrameEditorLID.Group, createGroupElementsAction());
ui.setAction(FrameEditorLID.Ungroup, createUngroupElementsAction());
ui.setAction(FrameEditorLID.RenameEltGroup, new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorUI.EltGroupRenameParameters.class;
}
public boolean performAction(Object prms) {
FrameEditorUI.EltGroupRenameParameters p = (FrameEditorUI.EltGroupRenameParameters) prms;
return renameEltGroup(p.eltGroup, p.newName);
}
});
ui.setAction(FrameEditorLID.SetRemoteLabelText, createSetRemoteLabelTextAction());
ui.setAction(FrameEditorLID.SetRemoteLabelType, createSetRemoteLabelTypeAction());
}
use of edu.cmu.cs.hcii.cogtool.util.AListenerAction 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());
}
Aggregations