use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.
the class DesignEditorController method createInitiateFrameRenameAction.
// createEditTransitionAction
protected IListenerAction createInitiateFrameRenameAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return FrameSelectionState.class;
}
public boolean performAction(Object prms) {
FrameSelectionState selection = (FrameSelectionState) prms;
int selectedFrameCount = selection.getSelectedFrameCount();
if (selectedFrameCount == 1) {
ui.initiateFrameRename(selection);
return true;
}
if (selectedFrameCount > 1) {
interaction.protestMultipleFrameSelection();
return false;
}
interaction.protestNoSelection();
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.
the class ZoomableController 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 that all CogTool
* model editing windows support.
*
* @author mlh
*/
@Override
protected void assignActions() {
super.assignActions();
final ZoomableUI ui = getZoomableUI();
if (ui != null) {
ui.setAction(CogToolLID.SetZoom, new IListenerAction() {
public Class<?> getParameterClass() {
return Double.class;
}
public boolean performAction(Object prm) {
double zoom = ((Double) prm).doubleValue();
ui.setZoom(zoom);
return true;
}
});
ui.setAction(CogToolLID.ZoomToFit, new AListenerAction() {
public boolean performAction(Object prms) {
ui.zoomToFit();
return true;
}
});
ui.setAction(CogToolLID.ZoomNormal, new AListenerAction() {
public boolean performAction(Object prms) {
ui.zoomToActual();
return true;
}
});
ui.setAction(CogToolLID.ZoomIn, new AListenerAction() {
public boolean performAction(Object prms) {
ui.zoomIn();
return true;
}
});
ui.setAction(CogToolLID.ZoomOut, new AListenerAction() {
public boolean performAction(Object prms) {
ui.zoomOut();
return true;
}
});
}
}
use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.
the class ProjectController method createEditACTRModelAction.
// TODO it is a crock that we're cloning this stuff; when we have time
// we should design a shared mechanism to be used by all back ends
protected IListenerAction createEditACTRModelAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return ProjectSelectionState.class;
}
public boolean performAction(Object actionParms) {
ProjectSelectionState selState = (ProjectSelectionState) actionParms;
Design design = selState.getSelectedDesign();
AUndertaking[] tasks = selState.getSelectedTasks(TaskSelectionState.PRUNE_SELECTION);
for (AUndertaking task : tasks) {
TaskApplication ta = project.getTaskApplication(task, design);
if (ta == null) {
return false;
}
// find the script
Script script = ta.getScript(KLMCognitiveGenerator.ONLY);
if (script == null) {
return false;
}
// get the resourcePath
String resourcePath = script.getAssociatedPath();
if (resourcePath == null) {
return false;
}
try {
FileUtil.editFile(new File(resourcePath));
} catch (UnsupportedOperationException ex) {
throw new RcvrUnimplementedFnException("Editing a file is not implemented", ex);
} catch (IOException ex) {
throw new RcvrIOException("Problem when trying to edit a file.", ex);
}
}
return true;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.
the class ProjectController method createInitiateTaskRenameAction.
// createCutTaskAction
// Action for InitiateTaskRename
protected IListenerAction createInitiateTaskRenameAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return TaskSelectionState.class;
}
public boolean performAction(Object prms) {
TaskSelectionState selection = (TaskSelectionState) prms;
int selectedTaskCount = selection.getSelectedTaskCount();
// No need, therefore, to prune the task list!
if (selectedTaskCount == 1) {
ui.initiateTaskRename(selection.getSelectedTask());
return true;
}
if (selectedTaskCount == 0) {
interaction.protestNoSelection();
} else {
interaction.protestTooManySelectedTasks();
}
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.
the class ProjectController method createShowNatureAction.
// Action for ShowSum, ShowMean, ShowMin, and ShowMax
protected IListenerAction createShowNatureAction(final GroupNature nature, final CogToolLID lid) {
return new IListenerAction() {
public Class<?> getParameterClass() {
return TaskSelectionState.class;
}
public boolean performAction(Object prms) {
if (prms != null) {
final List<TaskGroup> groups = new ArrayList<TaskGroup>();
final List<GroupNature> oldNatures = new ArrayList<GroupNature>();
TaskSelectionState seln = (TaskSelectionState) prms;
AUndertaking[] tasks = seln.getSelectedTasks(TaskSelectionState.FAST_SELECTION);
// Change applies only to task group instances
for (AUndertaking task : tasks) {
if (task.isTaskGroup()) {
TaskGroup group = (TaskGroup) task;
GroupNature oldNature = group.getNature();
// record old value for undo support
if (oldNature != nature) {
oldNatures.add(oldNature);
groups.add(group);
group.setNature(nature);
}
}
}
// undo/redo step and add to undo manager
if (groups.size() > 0) {
undoMgr.addEdit(new AUndoableEdit(lid) {
@Override
public String getPresentationName() {
return CHANGE_GROUP_TYPE;
}
@Override
public void redo() {
super.redo();
for (int i = 0; i < groups.size(); i++) {
TaskGroup group = groups.get(i);
group.setNature(nature);
}
}
@Override
public void undo() {
super.undo();
for (int i = 0; i < groups.size(); i++) {
TaskGroup group = groups.get(i);
GroupNature oldNat = oldNatures.get(i);
group.setNature(oldNat);
}
}
});
}
}
return true;
}
};
}
Aggregations