import org.objectstyle.wolips.eomodeler.editors.entity.SubclassEntityDialog;
public class SubclassEntityAction extends EMAction {
public void run(IAction action) {
EOModel model = null;
EOEntity entity = null;
Object selectedObject = getSelectedObject();
if (selectedObject instanceof EOModel) {
model = (EOModel) selectedObject;
} else if (selectedObject instanceof IEOEntityRelative) {
entity = ((IEOEntityRelative) selectedObject).getEntity();
model = entity.getModel();
}
if (model != null) {
SubclassEntityDialog dialog = new SubclassEntityDialog(getWindow().getShell(), model, entity, model.getModelGroup().getEditingModel());
dialog.setBlockOnOpen(true);
int results = dialog.open();
if (results == Window.OK) {
String entityName = dialog.getEntityName();
if (entityName != null && entityName.trim().length() > 0) {
try {
EOEntity parentEntity = dialog.getParentEntity();
InheritanceType inheritanceType = dialog.getInheritanceType();
String restrictingQualifier = dialog.getRestrictingQualifier();
EOModel destinationModel = dialog.getDestinationModel();
SubclassOperation operation = new SubclassOperation(parentEntity, inheritanceType, destinationModel, entityName, restrictingQualifier);
operation.addContext(EOModelUtils.getUndoContext(model));