use of edu.cmu.cs.hcii.cogtool.util.RcvrOutOfMemoryException 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.RcvrOutOfMemoryException 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.RcvrOutOfMemoryException 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.RcvrOutOfMemoryException 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.RcvrOutOfMemoryException in project cogtool by cogtool.
the class DesignEditorCmd method copyElements.
public static void copyElements(Design design, FrameElement[] selectedElts, Iterator<FrameElement> eltsToCopy, boolean saveToClipboard) {
try {
// Set up a clipboard saver. Indicate that no transitions
// should be copied.
CogToolClipboard.ClipboardClassSaver s = CogToolClipboard.startClipboardSave(CogToolClipboard.CopyWidgets, selectedElts, saveToClipboard);
// Iterate through the widgets and save the selected items.
while (eltsToCopy.hasNext()) {
FrameElement elt = eltsToCopy.next();
// get pasted.
if (!(elt instanceof ChildWidget)) {
s.saveObject(elt);
}
}
s.finish();
if (!saveToClipboard) {
FrameTemplateSupport.setFrameTemplate(design, s.getSavedString());
}
} catch (IOException e) {
throw new RcvrClipboardException(e);
} catch (OutOfMemoryError error) {
throw new RcvrOutOfMemoryException("Copying Widgets", error);
}
}
Aggregations