private boolean validateGeneratedName() { // if Generate button never pressed if (nextNumberInSequence == null) { MessageNotifier.showError( getWindow(), "Error with Cross Code", MessageFormat.format( messageSource.getMessage(Message.ERROR_NEXT_NAME_MUST_BE_GENERATED_FIRST), ""), Notification.POSITION_CENTERED); return false; // if prefix specifications were changed and next name in sequence not generated first } else { String currentPrefixString = buildPrefixString(); if (!currentPrefixString.equals(lastPrefixUsed)) { MessageNotifier.showError( getWindow(), "Error with Cross Code", MessageFormat.format( messageSource.getMessage(Message.ERROR_NEXT_NAME_MUST_BE_GENERATED_FIRST), " (" + currentPrefixString + ")"), Notification.POSITION_CENTERED); return false; } } return true; }
private boolean validateCrossNameFields() { Window window = getWindow(); String prefix = ((String) prefixTextField.getValue()).trim(); if (StringUtils.isEmpty(prefix)) { MessageNotifier.showError( window, "Error with Cross Code", messageSource.getMessage(Message.ERROR_ENTER_PREFIX_FIRST), Notification.POSITION_CENTERED); return false; } else if (prefix.contains(" ")) { MessageNotifier.showError( window, "Error with Cross Code", messageSource.getMessage(Message.ERROR_PREFIX_HAS_WHITESPACE), Notification.POSITION_CENTERED); return false; } return true; }
// Action handler for Generation button public void generateNextNameButtonAction() { if (validateCrossNameFields()) { String suffix = ((String) suffixTextField.getValue()).trim(); try { lastPrefixUsed = buildPrefixString(); String nextSequenceNumberString = this.germplasmManager.getNextSequenceNumberForCrossName(lastPrefixUsed); nextNumberInSequence = Integer.parseInt(nextSequenceNumberString); generatedNameLabel.setCaption( buildNextNameInSequence(lastPrefixUsed, suffix, nextNumberInSequence)); } catch (MiddlewareQueryException e) { LOG.error(e.toString() + "\n" + e.getStackTrace()); e.printStackTrace(); MessageNotifier.showError( getWindow(), messageSource.getMessage(Message.ERROR_DATABASE), messageSource.getMessage(Message.ERROR_IN_GETTING_NEXT_NUMBER_IN_CROSS_NAME_SEQUENCE), Notification.POSITION_CENTERED); } } }