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.actions;
14  
15  import java.awt.event.ActionEvent;
16  import java.awt.event.KeyEvent;
17  
18  import javax.swing.AbstractAction;
19  import javax.swing.Action;
20  import javax.swing.JSplitPane;
21  import javax.swing.KeyStroke;
22  
23  import com.eviware.soapui.SoapUI;
24  
25  /***
26   * Changes the orientation of a JSplitPane
27   * 
28   * @author Ole.Matzura
29   */
30  
31  public class ChangeSplitPaneOrientationAction extends AbstractAction
32  {
33  	private final JSplitPane splitPane;
34  
35  	public ChangeSplitPaneOrientationAction(JSplitPane splitPane)
36  	{
37  		super();
38  		this.splitPane = splitPane;
39  
40  		putValue(Action.SMALL_ICON, SoapUI
41  				.createImageIcon("/split_request_pane.gif"));
42  		putValue(Action.SHORT_DESCRIPTION,
43  				"Changes the orientation of the request pane split");
44  		putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke( KeyEvent.VK_O, KeyEvent.ALT_MASK ));
45  	}
46  
47  	public void actionPerformed(ActionEvent e)
48  	{
49  		int orientation = splitPane.getOrientation();
50  		splitPane.setOrientation(orientation == JSplitPane.HORIZONTAL_SPLIT ? JSplitPane.VERTICAL_SPLIT
51  						: JSplitPane.HORIZONTAL_SPLIT);
52  		splitPane.resetToPreferredSizes();
53  	}
54  }