PageRenderTime 125ms CodeModel.GetById 117ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/jEdit/tags/jedit-4-2-pre4/macros/Misc/Cascade_jEdit_Windows.bsh

#
Unknown | 113 lines | 106 code | 7 blank | 0 comment | 0 complexity | 7f3d70ccf8197da032f7d8e5f965e3fc MD5 | raw file
  1/*
  2 * Cascade_jEdit_Windows.bsh - a BeanShell macro script for the
  3 * jEdit text editor - Cascades all view and floating plugin
  4 * windows from the upper-left corner of the desktop
  5 * Copyright (C) 2001 John Gellene
  6 * jgellene@nyc.rr.com
  7 * http://community.jedit.org
  8 *
  9 * This program is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU General Public License
 11 * as published by the Free Software Foundation; either version 2
 12 * of the License, or any later version.
 13 *
 14 * This program is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 17 * GNU General Public License for more details.
 18 *
 19 * You should have received a copy of the GNU General Public License
 20 * along with this program; if not, write to the Free Software
 21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 22 *
 23 * $Id: Cascade_jEdit_Windows.bsh 3873 2001-11-06 17:57:35Z jgellene $
 24 *
 25 * Notes on use:
 26 *
 27 * The macro is suited for use at or immediately after startup if the  screen
 28 * size or resolution has changed since the last editing session.  It will also
 29 * rearrange multiple view and their associated floating plugin windows
 30 * during an editing session.  It will not rearrange modeless dialog windows.
 31 *
 32 * Checked for jEdit 4.0 API
 33 *
 34 */
 35
 36void cascadeJEditWindows(int startOffset, int incrOffset, int maxWindows)
 37{
 38	offsetFromUpperLeft = startOffset;
 39	maxOffset = startOffset + (incrOffset * (maxWindows - 1));
 40	if(startOffset < 0 || incrOffset < 0 || maxOffset < 0)
 41	{
 42		JOptionPane.showMessageDialog(null,
 43			"Macro \"Cascade_jEdit_Windows\" called with illegal values.",
 44			"jEdit", JOptionPane.ERROR_MESSAGE);
 45		return;
 46	}
 47	if(JOptionPane.showConfirmDialog(null,
 48			"Rearrange all jEdit windows?",
 49			"jEdit", JOptionPane.YES_NO_OPTION)
 50			!= JOptionPane.YES_OPTION)
 51		return;
 52	views = jEdit.getViews();
 53	/* 	We have to move all views and floating plugin windows.
 54	 *  Each view only knows about floating windows
 55	 * 	attached to its own DockingWindowManager,
 56 	 * 	and the entry tables for each manager are private,
 57	 * 	so we will repeatedly check against a list of all
 58	 * 	dockable windows.
 59	 */
 60	for(i = 0; i < views.length; ++i)
 61	{
 62		thisView = views[i];
 63		thisView.setLocation(offsetFromUpperLeft, offsetFromUpperLeft);
 64		offsetFromUpperLeft += incrOffset;
 65		// stack windows in groups (in case you've been really busy)
 66		offsetFromUpperLeft %= maxOffset;
 67		manager = thisView.getDockableWindowManager();
 68		dockableWindowNames = EditBus.getNamedList("DOCKABLE_WINDOWS");
 69		for(j = 0; j < dockableWindowNames.length; ++j)
 70		{
 71			win = manager.getDockable(dockableWindowNames[j]);
 72			if(win == null) continue;
 73			c = win.getComponent().getParent();
 74			// check if it's floating
 75			if(c instanceof DockableWindowContainer.TabbedPane) continue;
 76			// find the top-level window
 77			topLevelWindow = null;
 78			while(c != null)
 79			{
 80				topLevelWindow = c;
 81				c = topLevelWindow.getParent();
 82			}
 83			if(topLevelWindow != null)
 84			{
 85				topLevelWindow.setLocation(offsetFromUpperLeft, offsetFromUpperLeft);
 86				offsetFromUpperLeft += incrOffset;
 87				offsetFromUpperLeft %= maxOffset;
 88			}
 89		}
 90	}
 91}
 92
 93// here are some reasonable values for window offsets
 94cascadeJEditWindows(20, 20, 10);
 95
 96/*
 97	Macro index data (in DocBook format)
 98
 99<listitem>
100    <para><filename>Cascade_jEdit_Windows.bsh</filename></para>
101    <abstract><para>
102        Rearranges view and floating plugin windows.
103    </para></abstract>
104    <para>
105        The windows are arranged in an overlapping <quote>cascade</quote>
106        pattern beginning near the upper left corner of the display.
107    </para>
108</listitem>
109
110*/
111
112// end of Cascade_jEdit_Windows.bsh
113