use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.
the class ProjectController method createShowModelVisualizationAction.
// Action for ShowVisualization
protected IListenerAction createShowModelVisualizationAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return ProjectSelectionState.class;
}
public boolean performAction(Object prms) {
ProjectSelectionState seln = (ProjectSelectionState) prms;
// Must have selected tasks and design
Design design = seln.getSelectedDesign();
AUndertaking[] tasks = seln.getSelectedTasks(TaskSelectionState.PRUNE_SELECTION);
if ((design == null) || (tasks == null) || (tasks.length == 0)) {
return false;
}
boolean visCreated = false;
for (AUndertaking task : tasks) {
if (createVisualization(design, task, -1)) {
visCreated = true;
break;
}
}
if (!visCreated) {
interaction.reportProblem(visualizationNotCreated, noResultsToVisualize);
}
return visCreated;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.
the class ProjectController method createDeleteDesignAction.
// createInitiateTaskRenameAction
// Action for DeleteDesign
protected IListenerAction createDeleteDesignAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return DesignSelectionState.class;
}
public boolean performAction(Object prms) {
DesignSelectionState selection = (DesignSelectionState) prms;
Design selectedDesign = selection.getSelectedDesign();
// Can only delete if a design is currently selected.
if (selectedDesign != null) {
if (interaction.confirmDeleteDesign(selectedDesign)) {
// Delete selected design, without copying
// to the clipboard.
deleteDesign(selectedDesign, null);
return true;
}
} else {
interaction.protestNoSelection();
}
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.
the class DefaultController 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();
UI ui = getUI();
final Interaction interaction = getUI().getStandardInteraction();
if (ui != null) {
// Set "save as" action
ui.setAction(CogToolLID.SaveProjectAs, new AListenerAction() {
public boolean performAction(Object prms) {
return saveAs();
}
});
// Set "save" action
ui.setAction(CogToolLID.SaveProject, new AListenerAction() {
public boolean performAction(Object prms) {
return forceSave();
}
});
ui.setAction(CogToolLID.CloseWindow, createCloseWindowAction());
ui.setAction(CogToolLID.CloseProject, new AListenerAction() {
public boolean performAction(Object prms) {
return closeProject(project, true);
}
});
ui.setAction(CogToolLID.Properties, new AListenerAction() {
public boolean performAction(Object prms) {
return showProperties();
}
});
ui.setAction(CogToolLID.SetAttribute, new IListenerAction() {
public Class<?> getParameterClass() {
return UI.SetAttributeParameters.class;
}
public boolean performAction(Object prms) {
UI.SetAttributeParameters p = (UI.SetAttributeParameters) prms;
return DefaultCmd.setAttribute(p.target, null, p.attrName, p.value, interaction, undoMgr);
}
});
}
}
use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.
the class DesignEditorController method createChangeActionAction.
protected IListenerAction createChangeActionAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return DesignEditorUI.ChangeActionParameters.class;
}
public boolean performAction(Object prms) {
DesignEditorUI.ChangeActionParameters chgPrms = (DesignEditorUI.ChangeActionParameters) prms;
if (chgPrms != null) {
Transition[] transitions = chgPrms.selection.getSelectedTransitions();
if ((transitions != null) && (transitions.length > 0)) {
properties.copyValues(chgPrms.properties);
// TODO: Assume one for the moment; ui enforces it!
TransitionSource source = transitions[0].getSource();
int deviceTypes = DeviceType.buildDeviceSet(design.getDeviceTypes());
int limitMode = ActionProperties.determineChangeActionMode(source);
AAction newAction = EditActionCmd.buildActionFromProperties(properties, deviceTypes, limitMode, interaction);
if (newAction == null) {
return false;
}
newAction = EditActionCmd.ensureActionIsUnique(source, newAction, properties, deviceTypes, limitMode, transitions[0], interaction);
if (newAction == null) {
return false;
}
return changeTransitionsAction(transitions, newAction, NO_DELAY_CHANGE, null);
// TODO: If the given action properties are unusable
// (e.g., not unique from the source or empty string)
// and we should therefore return false so that an
// action that commits property changes can be
// canceled, assign the ensureActionIsUnique result
// to a new variable uniqueAction and return the AND of
// the changeTransitionsAction call (first) with
// (newAction == uniqueAction).
}
}
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.IListenerAction 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.");
}
}
};
}
Aggregations