return Character.isDigit(tablename.charAt(0)) ? "module" + tablename : tablename ;
}
@Override
public Object apply() throws WizardException {
XmlModule module = getModule();
String name = textName.getText();
String objectName = textObjectName.getText();
checkValue(name, DcResources.getText("lblName"));
checkValue(pic16.getIcon(), DcResources.getText("lblIcon"));
checkValue(pic32.getIcon(), DcResources.getText("lblIcon"));
checkValue(textObjectName.getText(), DcResources.getText("lblItemName"));
checkValue(textObjectNamePlural.getText(), DcResources.getText("lblItemNamePlural"));
String nameNormalized = !(getWizard() instanceof CreateModuleWizard) &&
module.getTableName() != null &&
!module.getTableName().equals("") ?
module.getTableName() : toTablename(objectName);
if (Utilities.isKeyword(nameNormalized))
throw new WizardException(DcResources.getText("msgObjectNameNotAllowed"));
if (getWizard() instanceof CreateModuleWizard && DcModules.get(nameNormalized) != null)
throw new WizardException(DcResources.getText("msgModuleNameNotUnique"));
textName.setText(nameNormalized);
module.setName(nameNormalized);
module.setDescription(textDesc.getText());
module.setEnabled(true);
module.setObjectName(objectName);
module.setObjectNamePlural(textObjectNamePlural.getText());
module.setTableName(nameNormalized);
module.setTableNameShort(nameNormalized);
module.setLabel(name);
module.setCanBeLend(checkCanBeLended.isSelected());
module.setContainerManaged(checkContainerManaged.isSelected());
module.setFileBacked(checkFileBacked.isSelected());
module.setHasInsertView(true);
module.setHasSearchView(true);
ImageIcon icon16 = pic16.getIcon();
ImageIcon icon32 = pic32.getIcon();
try {
if (pic16.isChanged() || getWizard() instanceof CreateModuleWizard) {
module.setIcon16(Utilities.getBytes(icon16.getImage(), DcImageIcon._TYPE_PNG));
module.setIcon16Filename(saveIcon(new DcImageIcon(module.getIcon16()), "_small"));
}
if (pic32.isChanged() || getWizard() instanceof CreateModuleWizard) {
module.setIcon32(Utilities.getBytes(icon32.getImage(), DcImageIcon._TYPE_PNG));
module.setIcon32Filename(saveIcon(new DcImageIcon(module.getIcon32()), ""));
}
} catch (Exception e) {
logger.error("Error while reading the icons", e);
throw new WizardException("Could not store / use the selected icons");
}