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