View Javadoc

1   /*
2    *  soapui, copyright (C) 2005 Ole Matzura / eviware.com 
3    *
4    *  SoapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of the GNU Lesser General Public License as published by the Free Software Foundation; 
6    *  either version 2.1 of the License, or (at your option) any later version.
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.soapui.support;
14  
15  import java.awt.Component;
16  
17  import javax.swing.JFrame;
18  import javax.swing.JOptionPane;
19  import javax.swing.JSplitPane;
20  
21  /***
22   * Facade for common UI-related tasks
23   * 
24   * @author Ole.Matzura
25   */
26  
27  public class UISupport
28  {
29  	private static JFrame frame;
30  
31  	public static void setMainFrame( JFrame frame )
32  	{
33  		UISupport.frame = frame;
34  	}
35  	
36  	public static JFrame getMainFrame()
37  	{
38  		return frame;
39  	}
40  	
41  	public static void showErrorMessage(String message)
42  	{
43  		JOptionPane.showMessageDialog( frame, message, "Error", JOptionPane.ERROR_MESSAGE );
44  	}
45  
46  	public static boolean confirm(String question, String title)
47  	{
48  		return JOptionPane.showConfirmDialog( frame, question, title, JOptionPane.OK_CANCEL_OPTION ) == 
49  			JOptionPane.OK_OPTION;
50  	}
51  
52  	public static String prompt(String question, String title, String value)
53  	{
54  		return (String) JOptionPane.showInputDialog( frame, question, title, JOptionPane.QUESTION_MESSAGE, 
55  				null, null, value );
56  	}
57  
58  	public static String prompt(String question, String title)
59  	{
60  		return JOptionPane.showInputDialog(frame, question, title, JOptionPane.QUESTION_MESSAGE );
61  	}
62  
63  	public static JSplitPane createHorizontalSplit()
64  	{
65  		JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
66        splitPane.setUI( new SoapUISpliPaneUI() );
67        splitPane.setDividerSize( 10 );
68        splitPane.setOneTouchExpandable( true );
69        return splitPane;
70  	}
71  	
72  	public static JSplitPane createHorizontalSplit( Component leftComponent, Component rightComponent )
73  	{
74  		JSplitPane splitPane = createHorizontalSplit();
75  		
76  		splitPane.setLeftComponent( leftComponent );
77  		splitPane.setRightComponent( rightComponent );
78        return splitPane;
79  	}
80  	
81  	public static JSplitPane createVerticalSplit()
82  	{
83  		JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
84        splitPane.setUI( new SoapUISpliPaneUI() );
85        splitPane.setDividerSize( 10 );
86        splitPane.setOneTouchExpandable( true );
87        return splitPane;
88  	}
89  	
90  	public static JSplitPane createVerticalSplit( Component topComponent, Component bottomComponent )
91  	{
92  		JSplitPane splitPane = createVerticalSplit();
93  		
94  		splitPane.setLeftComponent( topComponent );
95  		splitPane.setRightComponent( bottomComponent );
96        return splitPane;
97  	}
98  }