use of edu.cmu.cs.hcii.cogtool.model.LookAtScriptStep in project cogtool by cogtool.
the class SEDemoController method performInsertLookAt.
protected boolean performInsertLookAt(SEDemoSelectionState selection, IWidget lookAtTarget) {
AScriptStep beforeStep = getDemoStep(selection);
AScriptStep lookAtStep = new LookAtScriptStep(lookAtTarget);
return insertStep(lookAtStep, beforeStep, SEDemoLID.InsertLookAt, INSERT_LOOKAT);
}
use of edu.cmu.cs.hcii.cogtool.model.LookAtScriptStep in project cogtool by cogtool.
the class DemoScriptCmd method exportScriptToCSV.
public static boolean exportScriptToCSV(Script script, Project project, Interaction interaction, IUndoableEditSequence editSeq) {
Demonstration demo = script.getDemonstration();
TaskApplication ta = demo.getTaskApplication();
Design design = ta.getDesign();
AUndertaking task = ta.getTask();
String name = project.getName();
name += "_" + design.getName();
name += "_" + task.getName();
File dest = null;
if (interaction != null) {
dest = interaction.selectCSVFileDest(name);
} else {
dest = new File(CogTool.exportCSVKludgeDir, name + ".txt");
}
if (dest == null) {
return false;
}
FileWriter fw = null;
BufferedWriter buffer = null;
try {
fw = new FileWriter(dest);
buffer = new BufferedWriter(fw);
CSVSupport.writeCell("Format version:", buffer);
CSVSupport.addSeparator(buffer);
CSVSupport.writeCell(FORMAT_VERSION, buffer);
CSVSupport.addLineEnding(buffer);
Date now = new Date();
String date = DateFormat.getDateTimeInstance().format(now);
CSVSupport.writeCell("Date and Time:", buffer);
CSVSupport.addSeparator(buffer);
CSVSupport.writeCell(date, buffer);
CSVSupport.addLineEnding(buffer);
CSVSupport.writeCell("Project Name:", buffer);
CSVSupport.addSeparator(buffer);
CSVSupport.writeCell(project.getName(), buffer);
CSVSupport.addLineEnding(buffer);
CSVSupport.writeCell("Design Name:", buffer);
CSVSupport.addSeparator(buffer);
CSVSupport.writeCell(design.getName(), buffer);
CSVSupport.addLineEnding(buffer);
CSVSupport.writeCell("Task Hierarchy:", buffer);
String taskName = task.getFullName();
String[] cells = taskName.split(":");
for (String cell : cells) {
CSVSupport.addSeparator(buffer);
CSVSupport.writeCell(cell, buffer);
}
CSVSupport.addLineEnding(buffer);
CSVSupport.addSeparator(buffer);
CSVSupport.addLineEnding(buffer);
buffer.write("\"Frame\",\"Action\",\"Widget-Name\"," + "\"Displayed-Label\",\"Widget-Type\"");
CSVSupport.addLineEnding(buffer);
IWidget lastMovedToWidget = null;
Iterator<DefaultModelGeneratorState> stepStates = script.getStepStates().iterator();
while (stepStates.hasNext()) {
DefaultModelGeneratorState stepState = stepStates.next();
AScriptStep step = stepState.getScriptStep();
TransitionSource stepFocus = step.getStepFocus();
String frameName = step.getCurrentFrame().getName();
String actionName = KeyDisplayUtil.convertActionToMenuText(step.getLocalizedString());
if ((!(step instanceof LookAtScriptStep)) && (!(step instanceof ThinkScriptStep)) && (!(step instanceof TextActionSegment))) {
actionName = step.getLocalizedActionString(actionName, lastMovedToWidget);
}
lastMovedToWidget = stepState.getLastMovedToWidget();
String widgetName = "";
String widgetType = "";
String widgetTitle = "";
if (stepFocus != null) {
widgetName = stepFocus.getName();
if (stepFocus instanceof IWidget) {
IWidget w = (IWidget) stepFocus;
widgetType = w.getWidgetType().toString();
String s = w.getTitle();
if (s != null) {
widgetTitle = s;
}
}
}
CSVSupport.writeCell(frameName, buffer);
CSVSupport.addSeparator(buffer);
CSVSupport.writeCell(actionName, buffer);
CSVSupport.addSeparator(buffer);
CSVSupport.writeCell(widgetName, buffer);
CSVSupport.addSeparator(buffer);
CSVSupport.writeCell(widgetTitle, buffer);
CSVSupport.addSeparator(buffer);
CSVSupport.writeCell(widgetType, buffer);
CSVSupport.addLineEnding(buffer);
}
Frame resultFrame = demo.getResultFrame();
if (resultFrame != null) {
CSVSupport.writeCell(resultFrame.getName(), buffer);
}
if (interaction != null) {
interaction.setStatusMessage(L10N.get("DSO.ExportCompletedPre", "Export completed to ") + dest + L10N.get("DSO.ExportCompletePost", "."));
}
} catch (IOException e) {
if (interaction != null) {
interaction.reportProblem("File I/O Error", e.getMessage());
} else {
e.printStackTrace();
}
return false;
} finally {
try {
if (buffer != null) {
buffer.close();
}
if (fw != null) {
fw.close();
}
} catch (IOException e) {
if (interaction != null) {
interaction.reportProblem("File I/O Error on Close", e.getMessage());
} else {
e.printStackTrace();
}
return false;
}
}
return true;
}
Aggregations