if (model == null) {
MessageDialog.openError(getWindow().getShell(), "Select a Model", "Select a model to reverse engineer into.");
} else {
EODatabaseConfig activeDatabaseConfig = model.getActiveDatabaseConfig();
ClassLoader eomodelClassLoader = IEOClassLoaderFactory.Utility.createClassLoader(model);
IEOSQLReverseEngineer reverseEngineer = IEOSQLReverseEngineerFactory.Utility.reverseEngineerFactory().reverseEngineer(activeDatabaseConfig, eomodelClassLoader);
List<String> tableNames = reverseEngineer.reverseEngineerTableNames();
ListSelectionDialog dlg = new ListSelectionDialog(getWindow().getShell(), tableNames, new StringContentProvider(), new StringLabelProvider(), "Select the tables to reverse engineer:");
dlg.setInitialSelections(tableNames.toArray());
dlg.setTitle("Reverse Engineer");
if (dlg.open() == Window.OK) {
Object[] selectedTableNameObjs = dlg.getResult();
String[] selectedTableNames = new String[selectedTableNameObjs.length];
System.arraycopy(selectedTableNameObjs, 0, selectedTableNames, 0, selectedTableNameObjs.length);
List<String> selectedTableNamesList = Arrays.asList(selectedTableNames);
File reverseEngineeredEOModelFolder = reverseEngineer.reverseEngineerWithTableNamesIntoModel(selectedTableNamesList);
Set<EOModelVerificationFailure> failures = new HashSet<EOModelVerificationFailure>();
model.importEntitiesFromModel(reverseEngineeredEOModelFolder.toURL(), failures);
if (failures.size() > 0) {
EOModelErrorDialog dialog = new EOModelErrorDialog(getWindow().getShell(), failures);
dialog.open();