use of edu.cmu.cs.hcii.cogtool.ui.ProjectSelectionState.ProjectSelectionPredicate in project cogtool by cogtool.
the class ProjectUI method createPredicates.
// setUpDragAndDrop
protected void createPredicates() {
requiresRegenerationPredicate = new ProjectSelectionPredicate(project) {
@Override
protected boolean isSatisfiedBy(Design design, AUndertaking t) {
TaskApplication ta = project.getTaskApplication(t, design);
if (ta != null) {
Demonstration demo = ta.getDemonstration();
return demo.isObsolete();
}
return false;
}
};
hasComputableScriptsPredicate = new ProjectSelectionPredicate(project) {
@Override
protected boolean isSatisfiedBy(Design design, AUndertaking t) {
TaskApplication taskApp = project.getTaskApplication(t, design);
if (taskApp != null) {
IPredictionAlgo activeAlg = taskApp.determineActiveAlgorithm(project);
APredictionResult result = taskApp.getResult(taskApp.getFirstModelGenerator(), activeAlg);
if ((result != null) && !result.canBeRecomputed()) {
return false;
}
return taskApp.hasComputableScript() && !taskApp.getDemonstration().isInvalid();
}
return project.getDefaultAlgo() == SNIFACTPredictionAlgo.ONLY;
}
};
hasComputedResultPredicate = new ProjectSelectionPredicate(project) {
@Override
protected boolean isSatisfiedBy(Design design, AUndertaking t) {
TaskApplication taskApp = project.getTaskApplication(t, design);
return ((taskApp != null) && taskApp.hasComputedResult());
}
};
hasResultStepsPredicate = new ProjectSelectionPredicate(project) {
@Override
protected boolean isSatisfiedBy(Design design, AUndertaking t) {
TaskApplication taskApp = project.getTaskApplication(t, design);
return (taskApp != null) && taskApp.hasResultSteps();
}
};
hasScriptsPredicate = new ProjectSelectionPredicate(project) {
@Override
protected boolean isSatisfiedBy(Design design, AUndertaking t) {
TaskApplication taskApp = project.getTaskApplication(t, design);
return (taskApp != null) && taskApp.hasScript();
}
};
hasTracesPredicate = new ProjectSelectionPredicate(project) {
@Override
protected boolean isSatisfiedBy(Design design, AUndertaking t) {
TaskApplication taskApp = project.getTaskApplication(t, design);
return (taskApp != null) && taskApp.hasResultTraces();
}
};
hasMultipleScriptsPredicate = new ProjectSelectionPredicate(project) {
protected int numScripts = 0;
@Override
protected void resetState() {
numScripts = 0;
}
@Override
protected boolean isSatisfiedBy(Design design, AUndertaking t) {
TaskApplication taskApp = project.getTaskApplication(t, design);
if (taskApp != null) {
Iterator<CognitiveModelGenerator> modelGens = taskApp.getModelGenerators();
while (modelGens.hasNext()) {
CognitiveModelGenerator modelGen = modelGens.next();
Script script = taskApp.getScript(modelGen);
if (script != null) {
if (++numScripts > 1) {
return true;
}
}
}
}
return false;
}
};
}
Aggregations