View Javadoc

    1   /*
    2    *  soapUI, copyright (C) 2004-2007 eviware.com
    3    *
    4    *  soapUI is free software; you can redistribute it and/or modify it under the
    5    *  terms of version 2.1 of the GNU Lesser General Public License as published by
    6    *  the Free Software Foundation.
    7    *
    8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
    9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    10   *  See the GNU Lesser General Public License for more details at gnu.org.
    11   */
    12
    13  package com.eviware.x.impl.swing;
    14
    15  import com.eviware.soapui.support.types.StringToStringMap;
    16  import com.eviware.x.form.XFormDialog;
    17
    18  public abstract class SwingXFormDialog implements XFormDialog
    19  {
    20  	private int returnValue;
    21
    22  	public int getReturnValue()
    23  	{
    24  		return returnValue;
    25  	}
    26
    27  	public void setReturnValue(int returnValue)
    28  	{
    29  		this.returnValue = returnValue;
    30  	}
    31
    32  	public synchronized StringToStringMap show(final StringToStringMap values)
    33  	{
    34  		setValues( values );
    35  		setVisible( true );
    36  		return getValues();
    37  	}
    38
    39  	public boolean getBooleanValue( String name )
    40  	{
    41  		try
    42  		{
    43  			return Boolean.parseBoolean( getValue( name ));
    44  		}
    45  		catch( NumberFormatException e )
    46  		{
    47  			return false;
    48  		}
    49  	}
    50
    51  	public int getIntValue( String name, int defaultValue )
    52  	{
    53  		try
    54  		{
    55  			return Integer.parseInt( getValue( name ));
    56  		}
    57  		catch( NumberFormatException e )
    58  		{
    59  			return defaultValue;
    60  		}
    61  	}
    62
    63  	public void setBooleanValue( String name, boolean b )
    64  	{
    65  		setValue( name, Boolean.toString( b ));
    66  	}
    67
    68  	public void setIntValue( String name, int value )
    69  	{
    70  		setValue( name, Integer.toString( value ));
    71  	}
    72  }