PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/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
  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. void cascadeJEditWindows(int startOffset, int incrOffset, int maxWindows)
  36. {
  37. offsetFromUpperLeft = startOffset;
  38. maxOffset = startOffset + (incrOffset * (maxWindows - 1));
  39. if(startOffset < 0 || incrOffset < 0 || maxOffset < 0)
  40. {
  41. JOptionPane.showMessageDialog(null,
  42. "Macro \"Cascade_jEdit_Windows\" called with illegal values.",
  43. "jEdit", JOptionPane.ERROR_MESSAGE);
  44. return;
  45. }
  46. if(JOptionPane.showConfirmDialog(null,
  47. "Rearrange all jEdit windows?",
  48. "jEdit", JOptionPane.YES_NO_OPTION)
  49. != JOptionPane.YES_OPTION)
  50. return;
  51. views = jEdit.getViews();
  52. /* We have to move all views and floating plugin windows.
  53. * Each view only knows about floating windows
  54. * attached to its own DockingWindowManager,
  55. * and the entry tables for each manager are private,
  56. * so we will repeatedly check against a list of all
  57. * dockable windows.
  58. */
  59. for(i = 0; i < views.length; ++i)
  60. {
  61. thisView = views[i];
  62. thisView.setLocation(offsetFromUpperLeft, offsetFromUpperLeft);
  63. offsetFromUpperLeft += incrOffset;
  64. // stack windows in groups (in case you've been really busy)
  65. offsetFromUpperLeft %= maxOffset;
  66. manager = thisView.getDockableWindowManager();
  67. dockableWindowNames = EditBus.getNamedList("DOCKABLE_WINDOWS");
  68. for(j = 0; j < dockableWindowNames.length; ++j)
  69. {
  70. win = manager.getDockable(dockableWindowNames[j]);
  71. if(win == null) continue;
  72. c = win.getComponent().getParent();
  73. // check if it's floating
  74. if(c instanceof DockableWindowContainer.TabbedPane) continue;
  75. // find the top-level window
  76. topLevelWindow = null;
  77. while(c != null)
  78. {
  79. topLevelWindow = c;
  80. c = topLevelWindow.getParent();
  81. }
  82. if(topLevelWindow != null)
  83. {
  84. topLevelWindow.setLocation(offsetFromUpperLeft, offsetFromUpperLeft);
  85. offsetFromUpperLeft += incrOffset;
  86. offsetFromUpperLeft %= maxOffset;
  87. }
  88. }
  89. }
  90. }
  91. // here are some reasonable values for window offsets
  92. cascadeJEditWindows(20, 20, 10);
  93. /*
  94. Macro index data (in DocBook format)
  95. <listitem>
  96. <para><filename>Cascade_jEdit_Windows.bsh</filename></para>
  97. <abstract><para>
  98. Rearranges view and floating plugin windows.
  99. </para></abstract>
  100. <para>
  101. The windows are arranged in an overlapping <quote>cascade</quote>
  102. pattern beginning near the upper left corner of the display.
  103. </para>
  104. </listitem>
  105. */
  106. // end of Cascade_jEdit_Windows.bsh