use of edu.cmu.cs.hcii.cogtool.model.SimilarityDictionary in project cogtool by cogtool.
the class ProjectController method createImportDictionaryAction.
protected IListenerAction createImportDictionaryAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return ProjectSelectionState.class;
}
public boolean performAction(Object actionParms) {
ProjectSelectionState seln = (ProjectSelectionState) actionParms;
Design design = seln.getSelectedDesign();
if (design == null) {
interaction.reportProblem("Import Dictionary", "No design is selected");
return false;
}
ISimilarityDictionary prevDict = (ISimilarityDictionary) design.getAttribute(WidgetAttributes.DICTIONARY_ATTR);
// Leonghwee says he wants the imported dictionary to replace
// the old one
ISimilarityDictionary dict = new SimilarityDictionary();
design.setAttribute(WidgetAttributes.DICTIONARY_ATTR, dict);
boolean success = DictionaryEditorCmd.importDictionary(design, dict, prevDict, interaction, undoMgr, null);
if (success) {
DictionaryEditorController.openController(dict, design, project);
}
return success;
}
};
}
use of edu.cmu.cs.hcii.cogtool.model.SimilarityDictionary in project cogtool by cogtool.
the class DictEntryGenerator method generateEntries.
// TODO This whole mishmash of different flavors of progress bars, and
// Cancelables/Stoppables/Pausables is a mess. We shouldn't be using
// the type hierarchy to fiddle this stuff. Instead we should have a
// single interface for control of a background operation, subsuming
// all of Cancelable, Stoppable and Pausable, and a single ProgressBar
// type that takes a bunch of flags indicating what buttons it should
// display.
public void generateEntries(String goal, ITermSimilarity alg, Cancelable cancelable, Stoppable stoppable, boolean computeAll, List<String> computeErrors, ProgressCallback progressCallback) {
// TODO figure out how to deal with this for real, long term
// goal = clean(goal);
ISimilarityDictionary dict = (ISimilarityDictionary) design.getAttribute(WidgetAttributes.DICTIONARY_ATTR);
if (NullSafe.equals(dict, WidgetAttributes.NO_DICTIONARY)) {
dict = new SimilarityDictionary();
design.setAttribute(WidgetAttributes.DICTIONARY_ATTR, dict);
}
int initialSize = dict.size();
ITermSimilarity.Continuable cont = new ITermSimilarity.Continuable(cancelable, stoppable);
Iterator<Frame> frames = design.getFrames().iterator();
while (frames.hasNext() && cont.isContinuing()) {
Frame f = frames.next();
generateOneEntry(f.getSpeakerText(), goal, alg, cont, dict, computeAll, computeErrors, progressCallback);
Set<SimpleWidgetGroup> swGrps = new HashSet<SimpleWidgetGroup>();
Iterator<IWidget> widgets = f.getWidgets().iterator();
while (widgets.hasNext() && cont.isContinuing()) {
IWidget w = widgets.next();
generateOneEntry(w.getTitle(), goal, alg, cont, dict, computeAll, computeErrors, progressCallback);
if (!cont.isContinuing()) {
break;
}
generateOneEntry(w.getTextualCue(), goal, alg, cont, dict, computeAll, computeErrors, progressCallback);
SimpleWidgetGroup swg = w.getParentGroup();
if (swg != null) {
swGrps.add(swg);
}
}
Iterator<FrameElementGroup> groups = f.getEltGroups().iterator();
while (groups.hasNext() && cont.isContinuing()) {
generateOneEntry(groups.next().getTextualCue(), goal, alg, cont, dict, computeAll, computeErrors, progressCallback);
}
Iterator<SimpleWidgetGroup> swgIter = swGrps.iterator();
while (swgIter.hasNext() && cont.isContinuing()) {
generateOneEntry(swgIter.next().getTextualCue(), goal, alg, cont, dict, computeAll, computeErrors, progressCallback);
}
}
if (stoppable.isStopped()) {
// Clean out the last entry if we were stopped, as it may not be
// correct. But only if we've added something.
int n = dict.size();
if (n > initialSize) {
dict.removeEntry(n - 1);
}
}
}
use of edu.cmu.cs.hcii.cogtool.model.SimilarityDictionary in project cogtool by cogtool.
the class ProjectController method openDictionaryEditor.
protected void openDictionaryEditor(Design design) {
ISimilarityDictionary dict = (ISimilarityDictionary) design.getAttribute(WidgetAttributes.DICTIONARY_ATTR);
if (NullSafe.equals(dict, WidgetAttributes.NO_DICTIONARY)) {
dict = new SimilarityDictionary();
design.setAttribute(WidgetAttributes.DICTIONARY_ATTR, dict);
}
DictionaryEditorController.openController(dict, design, project);
}
Aggregations