}
}
public void pasteRows(Object data) {
if (data instanceof List) {
GroupAction ga = new GroupAction();
// methods or fields involved
@SuppressWarnings("unchecked")
List<Transferrable> transferrables = (List) data;
for (Transferrable transferrable : transferrables) {
if (transferrable instanceof TransferrableField) {
TransferrableField field = (TransferrableField) transferrable;
Undoable insertFieldAction = new InsertFieldAction(
this.classDef.getClassFile(), field.getFieldName(),
field.getDescriptor(), new AccessFlags(field
.getAccessFlags()));
ga.add(insertFieldAction);
} else if (transferrable instanceof TransferrableMethod) {
TransferrableMethod method = (TransferrableMethod) transferrable;
int maxStack = 0;
int maxLocals = 0;
if (method.getMaxStack() != null) {
maxStack = method.getMaxStack();
}
if (method.getMaxLocals() != null) {
maxLocals = method.getMaxLocals();
}
// TODO: Attributes are not being copied
InsertMethodAction insertMethodAction = new InsertMethodAction(
this.classDef.getClassFile(), method
.getMethodName(), method.getDescriptor(),
new AccessFlags(method.getAccessFlags()), maxStack,
maxLocals, method.getExceptions());
ga.add(insertMethodAction);
InsertCodeToNewMethodAction ictnma = new InsertCodeToNewMethodAction(
this.classDef.getClassFile(), insertMethodAction,
method.getCode());
ga.add(ictnma);
} else {
throw new AssertionError(
"Invalid object in List of pasted data.");
}
}
if (!ga.isEmpty()) {
SystemFacade.getInstance().performAction(ga);
}
} else {
if (this.list.getSelectedIndex() == -1) {