Source:
private void onReplaceBrick() { GlusterVolumeEntity volumeEntity = getEntity(); if (volumeEntity == null) { return; } ReplaceBrickModel replaceBrickModel = (ReplaceBrickModel) getWindow(); if (replaceBrickModel == null) { return; } GlusterBrickEntity existingBrick = getSelectedItem(); if (existingBrick == null) { return; } boolean isMultipleBricks = false; String selectedHost = replaceBrickModel.getServers().getSelectedItem().getHostName(); for (String brick : volumeEntity.getBrickDirectories()) { if (brick.contains(selectedHost) && selectedHost != existingBrick.getServerName()) { isMultipleBricks = true; } } if (volumeEntity.getVolumeType().isReplicatedType() && isMultipleBricks) { ConfirmationModel model = new ConfirmationModel(); setConfirmWindow(model); model.setTitle(ConstantsManager.getInstance().getConstants().replaceBrickTitle()); model.setMessage(ConstantsManager.getInstance().getConstants().replaceBrickWarning()); model.setHelpTag(HelpTag.replace_brick); model.setHashName("replace brick"); UICommand yesCommand = new UICommand("OnReplaceConfirmation", VolumeBrickListModel.this); yesCommand.setTitle(ConstantsManager.getInstance().getConstants().yes()); model.getCommands().add(yesCommand); UICommand cancelCommand = new UICommand("CancelConfirmation", this); cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().no()); cancelCommand.setIsCancel(true); getConfirmWindow().getCommands().add(cancelCommand); } else { onReplaceConfirmation(); } }

Target:
private void onReplaceBrick() { GlusterVolumeEntity volumeEntity = getEntity(); if (volumeEntity == null) { return; } ReplaceBrickModel replaceBrickModel = (ReplaceBrickModel) getWindow(); if (replaceBrickModel == null) { return; } GlusterBrickEntity existingBrick = getSelectedItem(); if (existingBrick == null) { return; } String selectedHost = replaceBrickModel.getServers().getSelectedItem().getHostName(); AsyncDataProvider.getInstance().getGlusterBricksForServer(new AsyncQuery<>(bricks -> { List<GlusterBrickEntity> brickDirectories = new ArrayList<>(); for (GlusterBrickEntity brick : bricks) { brickDirectories.add(brick); } boolean isMultipleBricks = false; for (String brick : volumeEntity.getBrickDirectories()) { if (brick.contains(selectedHost) && selectedHost != existingBrick.getServerName() && brickDirectories.size() > 1) { isMultipleBricks = true; } } if (volumeEntity.getVolumeType().isReplicatedType() && isMultipleBricks) { ConfirmationModel model = new ConfirmationModel(); setConfirmWindow(model); model.setTitle(ConstantsManager.getInstance().getConstants().replaceBrickTitle()); model.setMessage(ConstantsManager.getInstance().getConstants().replaceBrickWarning()); model.setHelpTag(HelpTag.replace_brick); model.setHashName("replace brick"); UICommand yesCommand = new UICommand("OnReplaceConfirmation", VolumeBrickListModel.this); yesCommand.setTitle(ConstantsManager.getInstance().getConstants().yes()); model.getCommands().add(yesCommand); UICommand cancelCommand = new UICommand("CancelConfirmation", this); cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().no()); cancelCommand.setIsCancel(true); getConfirmWindow().getCommands().add(cancelCommand); } else { onReplaceConfirmation(); } }), replaceBrickModel.getServers().getSelectedItem().getId()); }