View Javadoc

1   /***
2    * 
3    */
4   package com.eviware.soapui.actions;
5   
6   import java.awt.Dimension;
7   import java.awt.event.ActionEvent;
8   import java.util.ArrayList;
9   import java.util.Collections;
10  import java.util.List;
11  import java.util.Properties;
12  
13  import javax.swing.AbstractAction;
14  import javax.swing.Action;
15  
16  import com.eviware.soapui.support.UISupport;
17  
18  public class ShowSystemPropertiesAction extends AbstractAction
19  {
20  	public ShowSystemPropertiesAction()
21  	{
22  		super( "System Properties" );
23  		putValue( Action.SHORT_DESCRIPTION, "Shows the current systems properties" );
24  	}
25  
26  	public void actionPerformed( ActionEvent e )
27  	{
28  		StringBuffer buffer = new StringBuffer();
29  		Properties properties = System.getProperties();
30  
31  		List<String> keys = new ArrayList<String>();
32  		for( Object key : properties.keySet() )
33  			keys.add( key.toString() );
34  
35  		Collections.sort( keys );
36  
37  		String lastKey = null;
38  
39  		for( String key : keys )
40  		{
41  			if( lastKey != null )
42  			{
43  				if( !key.startsWith( lastKey ) )
44  					buffer.append( "\r\n" );
45  			}
46  
47  			int ix = key.indexOf( '.' );
48  			lastKey = ix == -1 ? key : key.substring( 0, ix );
49  
50  			buffer.append( key ).append( '=' ).append( properties.get( key ) ).append( "\r\n" );
51  		}
52  
53  		UISupport.showExtendedInfo( "System Properties", "Current system properties",
54  				"<html><body><pre><font size=-1>" + buffer.toString() + "</font></pre></body></html>", new Dimension(
55  						600, 400 ) );
56  	}
57  }