package com.onaro.sanscreen.client.view.policy.actions; import java.awt.Component; import javax.swing.JOptionPane; import com.onaro.sanscreen.server.approve.GenericHosts; public class GenericHostDialog { /** * Show a warning or error if there are any generic hosts in the provided list. * An error will be shown if the list consists of only generic hosts. A warning will be * shown if the list contains one or more non-generic hosts. No dialog will be shown if * the list contains only non-generic hosts. * * @param parent parent UI component * @param genericHosts all, some or none of the hosts of the paths are generics. See {@link com.onaro.sanscreen.server.approve.GenericHosts} * @return true if any non-generic hosts were in the list (and a warning was shown) */ public static boolean warnOrErrorGenericHosts(Component parent, int genericHosts) { if(genericHosts == GenericHosts.ALL){ JOptionPane.showMessageDialog(parent, Messages.INSTANCE.getGenericHostErrorMsg(), null, JOptionPane.ERROR_MESSAGE); return false; }else{ if(genericHosts == GenericHosts.SOME){ JOptionPane.showMessageDialog(parent, Messages.INSTANCE.getGenericHostWarningMsg(), null, JOptionPane.WARNING_MESSAGE); } return true; } } }