use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.
the class DesignEditorController method createDuplicateFrameAction.
protected IListenerAction createDuplicateFrameAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return DesignEditorUI.DuplicateParameters.class;
}
public boolean performAction(Object prms) {
// From DesignEditorUI
DesignEditorUI.DuplicateParameters parameters = (DesignEditorUI.DuplicateParameters) prms;
Frame[] framesToDuplicate = parameters.selection.getSelectedFrames();
if ((framesToDuplicate != null) && (framesToDuplicate.length > 0)) {
FrameSubsetDuplicator duplicator = new FrameSubsetDuplicator(framesToDuplicate);
Frame[] duplicatedFrames = new Frame[framesToDuplicate.length];
for (int i = 0; i < framesToDuplicate.length; i++) {
Frame duplicatedFrame = duplicator.getOrDuplicate(framesToDuplicate[i]);
duplicatedFrames[i] = duplicatedFrame;
duplicatedFrame.moveFrameOrigin(parameters.dx, parameters.dy);
}
design.addFrames(duplicatedFrames);
undoMgr.addEdit(createDuplicateFramesEdit(duplicatedFrames));
return true;
}
interaction.protestNoSelection();
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.IListenerAction 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;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.
the class DesignEditorController method createEditTransitionAction.
// createEditDesignAction
protected IListenerAction createEditTransitionAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return DesignEditorUI.EditTransitionParameters.class;
}
public boolean performAction(Object prms) {
DesignEditorUI.EditTransitionParameters parms = (DesignEditorUI.EditTransitionParameters) prms;
Transition[] transitions = parms.selection.getSelectedTransitions();
// Probably only one transition selected
if ((transitions != null) && (transitions.length > 0)) {
if (transitions.length == 1) {
TransitionSource source = transitions[0].getSource();
AAction action = transitions[0].getAction();
int limitMode = ActionProperties.determineChangeActionMode(source);
int deviceTypes = DeviceType.buildDeviceSet(design.getDeviceTypes());
if (!interaction.determineNewAction(transitions[0], properties, parms.useWhichParts, deviceTypes, limitMode, L10N.get("DE.ChangeActionType", "Change Action Type"))) {
return false;
}
action = EditActionCmd.buildActionFromProperties(properties, deviceTypes, limitMode, interaction);
if (action == null) {
return false;
}
action = EditActionCmd.ensureActionIsUnique(source, action, properties, deviceTypes, limitMode, transitions[0], interaction);
if (action == null) {
return false;
}
return changeTransitionsAction(transitions, action, properties.delayInSecs, properties.delayLabel);
} else {
interaction.protestMultipleTransitionSelection();
}
} else {
interaction.protestNoSelection();
}
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.
the class Controller 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 windows support.
*
* @author mlh
*/
protected void assignActions() {
UI ui = getUI();
if (ui != null) {
ui.setAction(CogToolLID.About, ui.popAboutBox());
// Set "open" action
ui.setAction(CogToolLID.OpenProject, new AListenerAction() {
public boolean performAction(Object prms) {
// open expects null in that case.
if (!(prms instanceof DoublePoint)) {
prms = null;
}
// Ask the user to select a CogTool project to open
File[] openLocs = getUI().getStandardInteraction().selectFileSources();
return open((DoublePoint) prms, openLocs);
}
});
ui.setAction(CogToolLID.OpenProjectFile, new IListenerAction() {
public Class<?> getParameterClass() {
return String.class;
}
public boolean performAction(Object actionParms) {
File[] openLoc = { new File((String) actionParms) };
return open(null, openLoc);
}
});
// Set "new project" action
ui.setAction(CogToolLID.NewProject, createNewProjectAction());
// Set "quit/exit" action
ui.setAction(CogToolLID.ExitApplication, createExitAction());
ui.setAction(CogToolLID.ClearRecent, new AListenerAction() {
public boolean performAction(Object actionParms) {
CogToolPref.clearRecent();
Interaction interaction = getUI().getStandardInteraction();
interaction.setStatusMessage(L10N.get("AC.RecentClear", "Recent file data cleared."));
return true;
}
});
}
}
use of edu.cmu.cs.hcii.cogtool.util.IListenerAction 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;
}
};
}
Aggregations