public void finish() throws WizardException {
if (!DcSwingUtilities.displayQuestion("msgDeleteModuleConfirmation"))
return;
XmlModule xmlModule = (XmlModule) getCurrent().apply();
DcModule module = DcModules.get(xmlModule.getIndex()) == null ?
DcModules.getPropertyBaseModule(xmlModule.getIndex()) :
DcModules.get(xmlModule.getIndex());
try {
module.delete();
// update the referencing modules; remove fields holding a reference to this module
Collection<XmlField> remove = new ArrayList<XmlField>();
for (DcModule reference : DcModules.getReferencingModules(xmlModule.getIndex())) {
if (reference != null && reference.getXmlModule() != null) {
for (XmlField field : reference.getXmlModule().getFields()){
if (reference.getField(field.getIndex()).getSourceModuleIdx() == xmlModule.getIndex())
remove.add(field);
}
reference.getXmlModule().getFields().removeAll(remove);
new ModuleJar(reference.getXmlModule()).save();
}
}
// parent child relation should be undone
undoParentChildRelation(module.getParent() != null ? module.getParent() : module.getChild());
// make sure the 'hasDependingModules' property is corrected for modules holding
// a referencing to this module
for (DcField field : module.getFields()) {
if (field.getValueType() == DcRepository.ValueTypes._DCOBJECTREFERENCE) {
DcModule reference = DcModules.getReferencedModule(field);
if (reference.getXmlModule() == null) continue;
if (reference.hasDependingModules() && DcModules.getReferencingModules(reference.getIndex()).size() == 1)
reference.getXmlModule().setHasDependingModules(false);
new ModuleJar(reference.getXmlModule()).save();
}
}
// not needed for property base modules
if (DcModules.get(xmlModule.getIndex()) != null) {
DcModules.get(xmlModule.getIndex()).isEnabled(false);
DataCrow.mainFrame.applySettings();
}
close();
} catch (Exception e) {