use of edu.cmu.cs.hcii.cogtool.util.ObjectSaver in project cogtool by cogtool.
the class ProjectController method createCopyTaskAction.
// createRenameDesignAction
// Action for CopyTask
protected IListenerAction createCopyTaskAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return TaskSelectionState.class;
}
public boolean performAction(Object prms) {
TaskSelectionState seln = (TaskSelectionState) prms;
AUndertaking[] tasks = seln.getSelectedTasks(TaskSelectionState.PRUNE_SELECTION | TaskSelectionState.ORDER_SELECTION);
// Can only copy to clipboard if one or more tasks are selected
if ((tasks != null) && (tasks.length > 0)) {
try {
ObjectSaver s = CogToolClipboard.startClipboardSave(CogToolClipboard.CopyTasks, CogToolClipboard.SAVE_TO_CLIPBOARD);
for (AUndertaking task : tasks) {
s.saveObject(task);
}
s.finish();
if (tasks.length == 1) {
interaction.setStatusMessage(TASK_COPIED);
} else {
interaction.setStatusMessage(TASKS_COPIED);
}
return true;
} catch (IOException e) {
throw new RcvrClipboardException(e);
} catch (OutOfMemoryError error) {
throw new RcvrOutOfMemoryException("Copying Tasks", error);
}
} else {
interaction.protestNoSelection();
}
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.ObjectSaver in project cogtool by cogtool.
the class ProjectController method createCutDesignAction.
// Action for CutDesign
protected IListenerAction createCutDesignAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return DesignSelectionState.class;
}
public boolean performAction(Object prms) {
DesignSelectionState selection = (DesignSelectionState) prms;
Design selectedDesign = selection.getSelectedDesign();
// Can only cut if a design is currently selected.
if (selectedDesign != null) {
if (interaction.confirmDeleteDesign(selectedDesign)) {
try {
ObjectSaver s = CogToolClipboard.startClipboardDesignSave(project, CogToolClipboard.SAVE_TO_CLIPBOARD);
// Delete selected design, copying to the clipboard
deleteDesign(selectedDesign, s);
s.finish();
return true;
} catch (IOException e) {
throw new RcvrClipboardException(e);
} catch (OutOfMemoryError error) {
throw new RcvrOutOfMemoryException("Cutting Design", error);
}
}
} else {
interaction.protestNoSelection();
}
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.ObjectSaver in project cogtool by cogtool.
the class ProjectController method createCutTaskAction.
// Action for CutTask
protected IListenerAction createCutTaskAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return TaskSelectionState.class;
}
public boolean performAction(Object prms) {
TaskSelectionState selection = (TaskSelectionState) prms;
AUndertaking[] selectedTasks = selection.getSelectedTasks(TaskSelectionState.PRUNE_SELECTION);
// Can only cut if one or more tasks are currently selected.
if ((selectedTasks != null) && (selectedTasks.length > 0)) {
try {
ObjectSaver saver = CogToolClipboard.startClipboardSave(CogToolClipboard.CopyTasks, CogToolClipboard.SAVE_TO_CLIPBOARD);
deleteTasks(selectedTasks, saver, undoMgr);
// flush!
saver.finish();
return true;
} catch (IOException e) {
throw new RcvrClipboardException("Could not execute cut", e);
} catch (OutOfMemoryError error) {
throw new RcvrOutOfMemoryException("Cutting Tasks", error);
}
} else {
interaction.protestNoSelection();
}
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.ObjectSaver in project cogtool by cogtool.
the class ProjectController method createCopyDesignAction.
// Action for CopyDesign
protected IListenerAction createCopyDesignAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return DesignSelectionState.class;
}
public boolean performAction(Object prms) {
DesignSelectionState seln = (DesignSelectionState) prms;
Design design = seln.getSelectedDesign();
// Can only copy if a design is currently selected.
if (design != null) {
try {
ObjectSaver s = CogToolClipboard.startClipboardDesignSave(project, CogToolClipboard.SAVE_TO_CLIPBOARD);
saveDesignToClipboard(design, s);
s.finish();
interaction.setStatusMessage(DESIGN_COPIED);
return true;
} catch (IOException e) {
throw new RcvrClipboardException(e);
} catch (OutOfMemoryError error) {
throw new RcvrOutOfMemoryException("Copying Design", error);
}
} else {
interaction.protestNoSelection();
}
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.ObjectSaver in project cogtool by cogtool.
the class DesignEditorController method copyFrames.
protected void copyFrames(Frame[] frames) {
try {
// Passing the set of frames as part of purpose allows us
// to copy only those transitions that link those frames.
ObjectSaver s = CogToolClipboard.startClipboardSave(CogToolClipboard.CopyFrames, frames, CogToolClipboard.SAVE_TO_CLIPBOARD);
for (Frame frame : frames) {
s.saveObject(frame);
}
s.finish();
} catch (IOException e) {
throw new RcvrClipboardException(e);
} catch (IllegalStateException e) {
throw new RcvrClipboardException(e);
} catch (OutOfMemoryError error) {
throw new RcvrOutOfMemoryException("Copying Frames", error);
}
}
Aggregations