Object row = this.list.getSelectedValue();
if (row instanceof CodeRow) {
// before selected instruction
CodeRow cr = (CodeRow) row;
int pos = cr.getPosition();
InsertCodeAction ica = new InsertCodeAction(this.classDef
.getClassFile(), cr.getParentCode(), pos, (Code) data);
SystemFacade.getInstance().performAction(ica);
} else if (row instanceof MethodDefRow) {
MethodDefRow mdr = (MethodDefRow) row;
if (mdr.isClosing()) {
// at the end of the code block
CodeAttribute ca = mdr.getMethod().getAttributes()
.getCode();
Code code = ca.getCode();
InsertCodeAction ica = new InsertCodeAction(this.classDef
.getClassFile(), code, code.getMaxPC(), (Code) data);
SystemFacade.getInstance().performAction(ica);
} else {
// at the beginning of the code block
CodeAttribute ca = mdr.getMethod().getAttributes()
.getCode();
Code code = ca.getCode();
InsertCodeAction ica = new InsertCodeAction(this.classDef
.getClassFile(), code, 0, (Code) data);
SystemFacade.getInstance().performAction(ica);
}
}
}