/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
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
- /*
- * Cascade_jEdit_Windows.bsh - a BeanShell macro script for the
- * jEdit text editor - Cascades all view and floating plugin
- * windows from the upper-left corner of the desktop
- * Copyright (C) 2001 John Gellene
- * jgellene@nyc.rr.com
- * http://community.jedit.org
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id: Cascade_jEdit_Windows.bsh 3873 2001-11-06 17:57:35Z jgellene $
- *
- * Notes on use:
- *
- * The macro is suited for use at or immediately after startup if the screen
- * size or resolution has changed since the last editing session. It will also
- * rearrange multiple view and their associated floating plugin windows
- * during an editing session. It will not rearrange modeless dialog windows.
- *
- * Checked for jEdit 4.0 API
- *
- */
- void cascadeJEditWindows(int startOffset, int incrOffset, int maxWindows)
- {
- offsetFromUpperLeft = startOffset;
- maxOffset = startOffset + (incrOffset * (maxWindows - 1));
- if(startOffset < 0 || incrOffset < 0 || maxOffset < 0)
- {
- JOptionPane.showMessageDialog(null,
- "Macro \"Cascade_jEdit_Windows\" called with illegal values.",
- "jEdit", JOptionPane.ERROR_MESSAGE);
- return;
- }
- if(JOptionPane.showConfirmDialog(null,
- "Rearrange all jEdit windows?",
- "jEdit", JOptionPane.YES_NO_OPTION)
- != JOptionPane.YES_OPTION)
- return;
- views = jEdit.getViews();
- /* We have to move all views and floating plugin windows.
- * Each view only knows about floating windows
- * attached to its own DockingWindowManager,
- * and the entry tables for each manager are private,
- * so we will repeatedly check against a list of all
- * dockable windows.
- */
- for(i = 0; i < views.length; ++i)
- {
- thisView = views[i];
- thisView.setLocation(offsetFromUpperLeft, offsetFromUpperLeft);
- offsetFromUpperLeft += incrOffset;
- // stack windows in groups (in case you've been really busy)
- offsetFromUpperLeft %= maxOffset;
- manager = thisView.getDockableWindowManager();
- dockableWindowNames = EditBus.getNamedList("DOCKABLE_WINDOWS");
- for(j = 0; j < dockableWindowNames.length; ++j)
- {
- win = manager.getDockable(dockableWindowNames[j]);
- if(win == null) continue;
- c = win.getComponent().getParent();
- // check if it's floating
- if(c instanceof DockableWindowContainer.TabbedPane) continue;
- // find the top-level window
- topLevelWindow = null;
- while(c != null)
- {
- topLevelWindow = c;
- c = topLevelWindow.getParent();
- }
- if(topLevelWindow != null)
- {
- topLevelWindow.setLocation(offsetFromUpperLeft, offsetFromUpperLeft);
- offsetFromUpperLeft += incrOffset;
- offsetFromUpperLeft %= maxOffset;
- }
- }
- }
- }
- // here are some reasonable values for window offsets
- cascadeJEditWindows(20, 20, 10);
- /*
- Macro index data (in DocBook format)
- <listitem>
- <para><filename>Cascade_jEdit_Windows.bsh</filename></para>
- <abstract><para>
- Rearranges view and floating plugin windows.
- </para></abstract>
- <para>
- The windows are arranged in an overlapping <quote>cascade</quote>
- pattern beginning near the upper left corner of the display.
- </para>
- </listitem>
- */
- // end of Cascade_jEdit_Windows.bsh