use of edu.cmu.cs.hcii.cogtool.util.AListenerAction in project cogtool by cogtool.
the class DictionaryEditorController method assignActions.
@Override
public void assignActions() {
super.assignActions();
// Enable undo & redo
ui.setAction(FrameEditorLID.Undo, new UndoController.UndoAction(undoMgr, interaction));
ui.setAction(FrameEditorLID.Redo, new UndoController.RedoAction(undoMgr, interaction));
ui.setAction(DictionaryEditorLID.StartNewEntry, createAddNewTermAction());
ui.setAction(DictionaryEditorLID.SetGoalString, createSetStringAction(0));
ui.setAction(DictionaryEditorLID.SetSearchString, createSetStringAction(1));
ui.setAction(DictionaryEditorLID.CreateNewEntry, createAddNewEntryAction());
ui.setAction(DictionaryEditorLID.SetSimilarity, createSetSimilarityAction());
ui.setAction(DictionaryEditorLID.ComputeSimilarity, createComputeSimilarityAction());
ui.setAction(DictionaryEditorLID.SetAlgorithm, createSetAlgorithmAction());
ui.setAction(DictionaryEditorLID.Delete, createDeleteEntryAction());
ui.setAction(ProjectLID.ExportDictToCSV, new AListenerAction() {
public boolean performAction(Object actionParms) {
return DictionaryEditorCmd.exportDictionaryToCSV(dictionary, interaction);
}
});
ui.setAction(ProjectLID.ImportDict, new AListenerAction() {
public boolean performAction(Object actionParms) {
return DictionaryEditorCmd.importDictionary(design, dictionary, WidgetAttributes.NO_DICTIONARY, interaction, undoMgr, null);
}
});
ui.setAction(CogToolLID.SelectAll, new AListenerAction() {
public boolean performAction(Object actionParms) {
ui.selectAll();
return true;
}
});
}
use of edu.cmu.cs.hcii.cogtool.util.AListenerAction in project cogtool by cogtool.
the class FrameEditorController method newSetWidgetColorAction.
/**
* Returns a new anonymous IListenerAction for widget color changes.
* @return
*/
private IListenerAction newSetWidgetColorAction() {
return new AListenerAction() {
public boolean performAction(Object prms) {
final int oldColor = model.getWidgetColor();
// Ask the user to get the color.
Integer newColorChoice = interaction.selectColor(oldColor, SELECT_WIDGET_COLOR);
// if the color is not the flag value, set it and add the undo.
if (newColorChoice != null) {
final int newColor = newColorChoice.intValue();
model.setWidgetColor(newColor);
undoMgr.addEdit(new AUndoableEdit(FrameEditorLID.SetWidgetColor) {
@Override
public String getPresentationName() {
return SET_WIDGET_COLOR;
}
@Override
public void redo() {
super.redo();
model.setWidgetColor(newColor);
}
@Override
public void undo() {
super.undo();
model.setWidgetColor(oldColor);
}
});
return true;
}
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.AListenerAction in project cogtool by cogtool.
the class ProjectController method createCopyResultsAction.
// Action for copying results to clipboard; uses TAB as separator!
protected IListenerAction createCopyResultsAction() {
return new AListenerAction() {
public boolean performAction(Object prms) {
StringBuilder buffer = exportResults(CLIPBOARD_SEPARATOR, new Date());
ClipboardUtil.copyTextData(buffer.toString());
interaction.setStatusMessage(L10N.get("PS.ResultDataCopied", "Result data copied."));
return true;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.AListenerAction in project cogtool by cogtool.
the class DesignEditorController method createImportImageDirectory.
protected IListenerAction createImportImageDirectory() {
return new AListenerAction() {
public boolean performAction(Object actionParms) {
// Ask for a directory of images
String filePath = interaction.askForImageDir();
if (filePath != null) {
File dir = new File(filePath);
if (dir.isDirectory()) {
final File[] files = dir.listFiles(new FileFilter() {
public boolean accept(File pathname) {
String name = pathname.getName();
Matcher imageFileNameMatcher = IMAGE_FILE_NAME.matcher(name);
if (imageFileNameMatcher.matches()) {
// Test for Mac resource forks
if (name.startsWith("._")) {
String realName = name.substring(2);
String fullPath = pathname.getParent() + FileUtil.FILE_SEP + realName;
return !new File(fullPath).exists();
}
return true;
}
return false;
}
});
// Find an unoccupied starting position by cascading.
DoublePoint origin = new DoublePoint(10.0, 10.0);
// Check if only the default frame is present;
// if so, and it hasn't been significantly modified or
// used, indicate that it should be deleted when
// the images are imported.
Frame frameToDelete = design.getFrame(DesignEditorController.INITIAL_FRAME_NAME);
if ((frameToDelete == null) || (design.getFrames().size() > 1) || (frameToDelete.getWidgets().size() > 0) || (frameToDelete.getBackgroundImage() != null)) {
frameToDelete = null;
}
ImportImageDirThread workThread = new ImportImageDirThread(files, origin.x, origin.y, frameToDelete);
ThreadManager.startNewThread(workThread);
}
}
return true;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.AListenerAction 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;
}
});
}
}
Aggregations