package gui.dialog;


import javax.swing.*;
import java.awt.*;

/**
 * Created by joseph on 14/05/16.
 */
public class InputStringDialogHelper
{
	public static String showInputNoSpacesDialog(Component parentComponent, String message, String title, int messageType, String defaultInput)
	{
		String str = (String) JOptionPane.showInputDialog(parentComponent, message, title, messageType, null, null, defaultInput);
		if(str != null)
		{
			if(str.endsWith("/"))
			{
				str = str.substring(0, str.length() - 1);
			}
			return str.replaceAll("\\s","");
		}
		return null;
	}
}
@@ -514,63 +514,535 @@
 %09%09%7D%0A
-%09%09%09return str.replaceAll(%22%5C%5Cs%22,%22%22);%0A%09%09%7D%0A%09%09return null;%0A%09%7D
+%0A%09%09%09if(str.isEmpty())%0A%09%09%09%7B%0A%09%09%09%09JOptionPane.showMessageDialog(parentComponent, %22Your input should not be empty.%22, %22Empty input%22, JOptionPane.WARNING_MESSAGE);%0A%09%09%09%09return showInputNoSpacesDialog(parentComponent, message, title, messageType, defaultInput);%0A%09%09%09%7D%0A%0A%09%09%09return str.replaceAll(%22%5C%5Cs%22,%22%22);%0A%09%09%7D%0A%09%09return null;%0A%09%7D%0A%0A%09public static String showInputNoSpacesDialog(Component parentComponent, String message, String title, int messageType)%0A%09%7B%0A%09%09return showInputNoSpacesDialog(parentComponent, message, title, messageType, %22%22);%0A%09%7D%0A
 %0A%7D

update String dialog helper to detect empty input