PageRenderTime 54ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/jEdit/tags/jedit-4-0-pre5/org/gjt/sp/jedit/gui/PanelWindowContainer.java

#
Java | 820 lines | 620 code | 96 blank | 104 comment | 102 complexity | 365881438b1b16b0f3a7c74936569a9f 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. * PanelWindowContainer.java - holds dockable windows
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 2000, 2001 Slava Pestov
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. */
  22. package org.gjt.sp.jedit.gui;
  23. //{{{ Imports
  24. import javax.swing.border.*;
  25. import javax.swing.plaf.metal.*;
  26. import javax.swing.*;
  27. import java.awt.event.*;
  28. import java.awt.font.*;
  29. import java.awt.geom.AffineTransform;
  30. import java.awt.image.*;
  31. import java.awt.*;
  32. import java.util.Vector;
  33. import org.gjt.sp.jedit.*;
  34. //}}}
  35. /**
  36. * A container for dockable windows. This class should never be used
  37. * directly.
  38. * @author Slava Pestov
  39. * @version $Id: PanelWindowContainer.java 4001 2002-01-31 05:35:49Z spestov $
  40. * @since jEdit 4.0pre1
  41. */
  42. public class PanelWindowContainer implements DockableWindowContainer
  43. {
  44. //{{{ PanelWindowContainer constructor
  45. public PanelWindowContainer(DockableWindowManager wm, String position)
  46. {
  47. this.wm = wm;
  48. this.position = position;
  49. //{{{ Button box setup
  50. buttons = new JPanel(new ButtonLayout());
  51. // the close box must be the same size as the other buttons to look good.
  52. // there are two ways to achieve this:
  53. // a) write a custom layout manager
  54. // b) when the first button is added, give the close box the proper size
  55. // I'm lazy so I chose "b". See register() for details.
  56. closeBox = new JButton(GUIUtilities.loadIcon("closebox.gif"));
  57. closeBox.setRequestFocusEnabled(false);
  58. closeBox.setToolTipText(jEdit.getProperty("view.docking.close-tooltip"));
  59. closeBox.setMargin(new Insets(0,0,0,0));
  60. buttons.add(closeBox);
  61. closeBox.addActionListener(new ActionHandler());
  62. popupButton = new JButton(GUIUtilities.loadIcon("ToolbarMenu.gif"));
  63. popupButton.setRequestFocusEnabled(false);
  64. popupButton.setToolTipText(jEdit.getProperty("view.docking.menu-tooltip"));
  65. buttons.add(popupButton);
  66. popupButton.addMouseListener(new MouseHandler());
  67. popup = new JPopupMenu();
  68. buttonGroup = new ButtonGroup();
  69. // JDK 1.4 workaround
  70. buttonGroup.add(nullButton = new JToggleButton());
  71. //}}}
  72. dockables = new Vector();
  73. dockablePanel = new DockablePanel();
  74. dimension = jEdit.getIntegerProperty(
  75. "view.dock." + position + ".dimension",0);
  76. } //}}}
  77. //{{{ register() method
  78. public void register(final DockableWindowManager.Entry entry)
  79. {
  80. dockables.addElement(entry);
  81. //{{{ Create button
  82. int rotation;
  83. if(position.equals(DockableWindowManager.TOP)
  84. || position.equals(DockableWindowManager.BOTTOM))
  85. rotation = RotatedTextIcon.NONE;
  86. else if(position.equals(DockableWindowManager.LEFT))
  87. rotation = RotatedTextIcon.CCW;
  88. else if(position.equals(DockableWindowManager.RIGHT))
  89. rotation = RotatedTextIcon.CW;
  90. else
  91. throw new InternalError("Invalid position: " + position);
  92. JToggleButton button = new JToggleButton();
  93. button.setMargin(new Insets(0,0,0,0));
  94. button.setRequestFocusEnabled(false);
  95. button.setIcon(new RotatedTextIcon(rotation,button.getFont(),
  96. entry.title));
  97. button.addActionListener(new ActionListener()
  98. {
  99. public void actionPerformed(ActionEvent evt)
  100. {
  101. if(current == entry)
  102. show(null);
  103. else
  104. wm.showDockableWindow(entry.name);
  105. }
  106. }); //}}}
  107. buttonGroup.add(button);
  108. buttons.add(button);
  109. //{{{ Create menu items
  110. JMenuItem menuItem = new JMenuItem(entry.title);
  111. menuItem.addActionListener(new ActionListener()
  112. {
  113. public void actionPerformed(ActionEvent evt)
  114. {
  115. wm.showDockableWindow(entry.name);
  116. }
  117. }); //}}}
  118. popup.add(menuItem);
  119. wm.revalidate();
  120. } //}}}
  121. //{{{ add() method
  122. public void add(DockableWindowManager.Entry entry)
  123. {
  124. dockablePanel.add(entry.name,entry.win);
  125. } //}}}
  126. //{{{ remove() method
  127. public void remove(DockableWindowManager.Entry entry)
  128. {
  129. int index = dockables.indexOf(entry);
  130. buttons.remove(index + 2);
  131. dockables.removeElement(entry);
  132. if(entry.win != null)
  133. dockablePanel.remove(entry.win);
  134. if(current == entry)
  135. {
  136. current = null;
  137. show(null);
  138. }
  139. else
  140. wm.revalidate();
  141. } //}}}
  142. //{{{ save() method
  143. public void save(DockableWindowManager.Entry entry) {}
  144. //}}}
  145. //{{{ show() method
  146. public void show(final DockableWindowManager.Entry entry)
  147. {
  148. if(current == entry)
  149. {
  150. if(entry != null)
  151. entry.win.requestDefaultFocus();
  152. return;
  153. }
  154. if(current == null)
  155. {
  156. // we didn't have a component previously, so create a border
  157. dockablePanel.setBorder(new DockBorder(position));
  158. }
  159. if(entry != null)
  160. {
  161. this.current = entry;
  162. dockablePanel.showDockable(entry.name);
  163. int index = dockables.indexOf(entry);
  164. ((JToggleButton)buttons.getComponent(index + 2)).setSelected(true);
  165. SwingUtilities.invokeLater(new Runnable()
  166. {
  167. public void run()
  168. {
  169. entry.win.requestDefaultFocus();
  170. }
  171. });
  172. }
  173. else
  174. {
  175. current = null;
  176. nullButton.setSelected(true);
  177. // removing last component, so remove border
  178. dockablePanel.setBorder(null);
  179. wm.getView().getTextArea().requestFocus();
  180. }
  181. wm.revalidate();
  182. dockablePanel.repaint();
  183. } //}}}
  184. //{{{ isVisible() method
  185. public boolean isVisible(DockableWindowManager.Entry entry)
  186. {
  187. return current == entry;
  188. } //}}}
  189. //{{{ getCurrent() method
  190. public DockableWindowManager.Entry getCurrent()
  191. {
  192. return current;
  193. } //}}}
  194. //{{{ Package-private members
  195. //{{{ save() method
  196. void save()
  197. {
  198. jEdit.setIntegerProperty("view.dock." + position + ".dimension",
  199. dimension);
  200. if(current == null)
  201. jEdit.unsetProperty("view.dock." + position + ".last");
  202. else
  203. {
  204. jEdit.setProperty("view.dock." + position + ".last",
  205. current.name);
  206. }
  207. } //}}}
  208. //{{{ getButtonBox() method
  209. JPanel getButtonBox()
  210. {
  211. return buttons;
  212. } //}}}
  213. //{{{ getDockablePanel() method
  214. DockablePanel getDockablePanel()
  215. {
  216. return dockablePanel;
  217. } //}}}
  218. //}}}
  219. //{{{ Private members
  220. private static final int SPLITTER_WIDTH = 10;
  221. private DockableWindowManager wm;
  222. private String position;
  223. private JPanel buttons;
  224. private JButton closeBox;
  225. private JButton popupButton;
  226. private ButtonGroup buttonGroup;
  227. private JToggleButton nullButton;
  228. private int dimension;
  229. private Vector dockables;
  230. private DockablePanel dockablePanel;
  231. private DockableWindowManager.Entry current;
  232. private JPopupMenu popup;
  233. //}}}
  234. //{{{ Inner classes
  235. //{{{ ActionHandler class
  236. class ActionHandler implements ActionListener
  237. {
  238. public void actionPerformed(ActionEvent evt)
  239. {
  240. show(null);
  241. }
  242. } //}}}
  243. //{{{ MouseHandler class
  244. class MouseHandler extends MouseAdapter
  245. {
  246. public void mousePressed(MouseEvent evt)
  247. {
  248. if(evt.getSource() == popupButton)
  249. {
  250. if(popup.isVisible())
  251. popup.setVisible(false);
  252. else
  253. {
  254. GUIUtilities.showPopupMenu(popup,
  255. popupButton,evt.getX(),evt.getY());
  256. }
  257. }
  258. }
  259. } //}}}
  260. //{{{ DockBorder class
  261. static class DockBorder implements Border
  262. {
  263. String position;
  264. Insets insets;
  265. Color color1;
  266. Color color2;
  267. Color color3;
  268. //{{{ DockBorder constructor
  269. DockBorder(String position)
  270. {
  271. if(UIManager.getLookAndFeel() instanceof MetalLookAndFeel)
  272. {
  273. color1 = MetalLookAndFeel.getControlHighlight();
  274. color2 = MetalLookAndFeel.getControlDarkShadow();
  275. color3 = MetalLookAndFeel.getControl();
  276. }
  277. this.position = position;
  278. insets = new Insets(
  279. position.equals(DockableWindowManager.BOTTOM)
  280. ? SPLITTER_WIDTH : 0,
  281. position.equals(DockableWindowManager.RIGHT)
  282. ? SPLITTER_WIDTH : 0,
  283. position.equals(DockableWindowManager.TOP)
  284. ? SPLITTER_WIDTH : 0,
  285. position.equals(DockableWindowManager.LEFT)
  286. ? SPLITTER_WIDTH : 0);
  287. } //}}}
  288. //{{{ paintBorder() method
  289. public void paintBorder(Component c, Graphics g,
  290. int x, int y, int width, int height)
  291. {
  292. if(color1 == null || color2 == null || color3 == null)
  293. return;
  294. if(position.equals(DockableWindowManager.BOTTOM))
  295. paintHorizBorder(g,x,y,width);
  296. else if(position.equals(DockableWindowManager.RIGHT))
  297. paintVertBorder(g,x,y,height);
  298. else if(position.equals(DockableWindowManager.TOP))
  299. {
  300. paintHorizBorder(g,x,y + height
  301. - SPLITTER_WIDTH,width);
  302. }
  303. else if(position.equals(DockableWindowManager.LEFT))
  304. {
  305. paintVertBorder(g,x + width
  306. - SPLITTER_WIDTH,y,height);
  307. }
  308. } //}}}
  309. //{{{ getBorderInsets() method
  310. public Insets getBorderInsets(Component c)
  311. {
  312. return insets;
  313. } //}}}
  314. //{{{ isBorderOpaque() method
  315. public boolean isBorderOpaque()
  316. {
  317. return false;
  318. } //}}}
  319. //{{{ paintHorizBorder() method
  320. private void paintHorizBorder(Graphics g, int x, int y, int width)
  321. {
  322. g.setColor(color3);
  323. g.fillRect(x,y,width,SPLITTER_WIDTH);
  324. for(int i = 0; i < width / 4 - 1; i++)
  325. {
  326. g.setColor(color1);
  327. g.drawLine(x + i * 4 + 2,y + 3,
  328. x + i * 4 + 2,y + 3);
  329. g.setColor(color2);
  330. g.drawLine(x + i * 4 + 3,y + 4,
  331. x + i * 4 + 3,y + 4);
  332. g.setColor(color1);
  333. g.drawLine(x + i * 4 + 4,y + 5,
  334. x + i * 4 + 4,y + 5);
  335. g.setColor(color2);
  336. g.drawLine(x + i * 4 + 5,y + 6,
  337. x + i * 4 + 5,y + 6);
  338. }
  339. } //}}}
  340. //{{{ paintVertBorder() method
  341. private void paintVertBorder(Graphics g, int x, int y, int height)
  342. {
  343. g.setColor(color3);
  344. g.fillRect(x,y,SPLITTER_WIDTH,height);
  345. for(int i = 0; i < height / 4 - 1; i++)
  346. {
  347. g.setColor(color1);
  348. g.drawLine(x + 3,y + i * 4 + 2,
  349. x + 3,y + i * 4 + 2);
  350. g.setColor(color2);
  351. g.drawLine(x + 4,y + i * 4 + 3,
  352. x + 4,y + i * 4 + 3);
  353. g.setColor(color1);
  354. g.drawLine(x + 5,y + i * 4 + 4,
  355. x + 5,y + i * 4 + 4);
  356. g.setColor(color2);
  357. g.drawLine(x + 6,y + i * 4 + 5,
  358. x + 6,y + i * 4 + 5);
  359. }
  360. } //}}}
  361. } //}}}
  362. //{{{ RotatedTextIcon class
  363. class RotatedTextIcon implements Icon
  364. {
  365. static final int NONE = 0;
  366. static final int CW = 1;
  367. static final int CCW = 2;
  368. int rotate;
  369. Font font;
  370. String text;
  371. int width;
  372. int height;
  373. float ascent;
  374. RenderingHints renderHints;
  375. //{{{ RotatedTextIcon constructor
  376. RotatedTextIcon(int rotate, Font font, String text)
  377. {
  378. this.rotate = rotate;
  379. this.font = font;
  380. this.text = text;
  381. FontRenderContext fontRenderContext
  382. = new FontRenderContext(null,true,
  383. true);
  384. GlyphVector glyphs = font.createGlyphVector(
  385. fontRenderContext,text);
  386. width = (int)glyphs.getLogicalBounds().getWidth();
  387. height = (int)glyphs.getLogicalBounds().getHeight();
  388. LineMetrics lineMetrics = font.getLineMetrics(text,fontRenderContext);
  389. ascent = lineMetrics.getAscent();
  390. renderHints = new RenderingHints(
  391. RenderingHints.KEY_ANTIALIASING,
  392. RenderingHints.VALUE_ANTIALIAS_ON);
  393. renderHints.put(RenderingHints.KEY_FRACTIONALMETRICS,
  394. RenderingHints.VALUE_FRACTIONALMETRICS_ON);
  395. renderHints.put(RenderingHints.KEY_RENDERING,
  396. RenderingHints.VALUE_RENDER_QUALITY);
  397. } //}}}
  398. //{{{ getIconWidth() method
  399. public int getIconWidth()
  400. {
  401. return (rotate == RotatedTextIcon.CW
  402. || rotate == RotatedTextIcon.CCW
  403. ? height : width);
  404. } //}}}
  405. //{{{ getIconHeight() method
  406. public int getIconHeight()
  407. {
  408. return (rotate == RotatedTextIcon.CW
  409. || rotate == RotatedTextIcon.CCW
  410. ? width : height);
  411. } //}}}
  412. //{{{ paintIcon() method
  413. public void paintIcon(Component c, Graphics g, int x, int y)
  414. {
  415. Graphics2D g2d = (Graphics2D)g;
  416. g2d.setFont(font);
  417. AffineTransform oldTransform = g2d.getTransform();
  418. RenderingHints oldHints = g2d.getRenderingHints();
  419. g2d.setRenderingHints(renderHints);
  420. g2d.setColor(c.getForeground());
  421. //{{{ No rotation
  422. if(rotate == RotatedTextIcon.NONE)
  423. {
  424. g2d.drawString(text,x,y + ascent);
  425. } //}}}
  426. //{{{ Clockwise rotation
  427. else if(rotate == RotatedTextIcon.CW)
  428. {
  429. AffineTransform trans = new AffineTransform();
  430. trans.concatenate(oldTransform);
  431. trans.translate(x,y);
  432. trans.rotate(Math.PI / 2,
  433. height / 2, width / 2);
  434. g2d.setTransform(trans);
  435. g2d.drawString(text,(height - width) / 2,
  436. (width - height) / 2
  437. + ascent);
  438. } //}}}
  439. //{{{ Counterclockwise rotation
  440. else if(rotate == RotatedTextIcon.CCW)
  441. {
  442. AffineTransform trans = new AffineTransform();
  443. trans.concatenate(oldTransform);
  444. trans.translate(x,y);
  445. trans.rotate(Math.PI * 3 / 2,
  446. height / 2, width / 2);
  447. g2d.setTransform(trans);
  448. g2d.drawString(text,(height - width) / 2,
  449. (width - height) / 2
  450. + ascent);
  451. } //}}}
  452. g2d.setTransform(oldTransform);
  453. g2d.setRenderingHints(oldHints);
  454. } //}}}
  455. } //}}}
  456. //{{{ ButtonLayout class
  457. class ButtonLayout implements LayoutManager
  458. {
  459. //{{{ addLayoutComponent() method
  460. public void addLayoutComponent(String name, Component comp) {} //}}}
  461. //{{{ removeLayoutComponent() method
  462. public void removeLayoutComponent(Component comp) {} //}}}
  463. //{{{ preferredLayoutSize() method
  464. public Dimension preferredLayoutSize(Container parent)
  465. {
  466. Component[] comp = parent.getComponents();
  467. if(comp.length == 2)
  468. {
  469. // nothing 'cept close box and popup button
  470. return new Dimension(0,0);
  471. }
  472. else
  473. {
  474. if(position.equals(DockableWindowManager.TOP)
  475. || position.equals(DockableWindowManager.BOTTOM))
  476. {
  477. return new Dimension(0,comp[2].getPreferredSize().height);
  478. }
  479. else
  480. {
  481. return new Dimension(comp[2].getPreferredSize().width,0);
  482. }
  483. }
  484. } //}}}
  485. //{{{ minimumLayoutSize() method
  486. public Dimension minimumLayoutSize(Container parent)
  487. {
  488. Component[] comp = parent.getComponents();
  489. if(comp.length == 2)
  490. {
  491. // nothing 'cept close box and popup button
  492. return new Dimension(0,0);
  493. }
  494. else
  495. {
  496. if(position.equals(DockableWindowManager.TOP)
  497. || position.equals(DockableWindowManager.BOTTOM))
  498. {
  499. return new Dimension(0,comp[2].getMinimumSize().height);
  500. }
  501. else
  502. {
  503. return new Dimension(comp[2].getMinimumSize().width,0);
  504. }
  505. }
  506. } //}}}
  507. //{{{ layoutContainer() method
  508. public void layoutContainer(Container parent)
  509. {
  510. Component[] comp = parent.getComponents();
  511. if(comp.length != 2)
  512. {
  513. boolean closeBoxSizeSet = false;
  514. popupButton.setVisible(false);
  515. Dimension parentSize = parent.getSize();
  516. int pos = 0;
  517. for(int i = 2; i < comp.length; i++)
  518. {
  519. Dimension size = comp[i].getPreferredSize();
  520. if(position.equals(DockableWindowManager.TOP)
  521. || position.equals(DockableWindowManager.BOTTOM))
  522. {
  523. if(!closeBoxSizeSet)
  524. {
  525. closeBox.setBounds(0,0,size.height,size.height);
  526. pos += size.height;
  527. closeBoxSizeSet = true;
  528. }
  529. if(pos + size.width > parentSize.width - closeBox.getWidth())
  530. {
  531. popupButton.setBounds(
  532. parentSize.width - size.height,
  533. 0,size.height,size.height);
  534. popupButton.setVisible(true);
  535. comp[i].setVisible(false);
  536. }
  537. else
  538. {
  539. comp[i].setBounds(pos,0,size.width,size.height);
  540. comp[i].setVisible(true);
  541. }
  542. pos += size.width;
  543. }
  544. else
  545. {
  546. if(!closeBoxSizeSet)
  547. {
  548. closeBox.setBounds(0,0,size.width,size.width);
  549. pos += size.width;
  550. closeBoxSizeSet = true;
  551. }
  552. if(pos + size.height > parentSize.height - closeBox.getWidth())
  553. {
  554. popupButton.setBounds(
  555. 0,parentSize.height - size.width,
  556. size.width,size.width);
  557. popupButton.setVisible(true);
  558. comp[i].setVisible(false);
  559. }
  560. else
  561. {
  562. comp[i].setBounds(0,pos,size.width,size.height);
  563. comp[i].setVisible(true);
  564. }
  565. pos += size.height;
  566. }
  567. }
  568. }
  569. } //}}}
  570. } //}}}
  571. //{{{ DockablePanel class
  572. class DockablePanel extends JPanel
  573. {
  574. //{{{ DockablePanel constructor
  575. DockablePanel()
  576. {
  577. super(new CardLayout());
  578. ResizeMouseHandler resizeMouseHandler = new ResizeMouseHandler();
  579. addMouseListener(resizeMouseHandler);
  580. addMouseMotionListener(resizeMouseHandler);
  581. } //}}}
  582. //{{{ showDockable() method
  583. void showDockable(String name)
  584. {
  585. ((CardLayout)getLayout()).show(this,name);
  586. } //}}}
  587. //{{{ getMinimumSize() method
  588. public Dimension getMinimumSize()
  589. {
  590. return new Dimension(0,0);
  591. } //}}}
  592. //{{{ getPreferredSize() method
  593. public Dimension getPreferredSize()
  594. {
  595. if(current == null)
  596. return new Dimension(0,0);
  597. else
  598. {
  599. if(dimension <= 0)
  600. {
  601. int width = super.getPreferredSize().width;
  602. dimension = width - SPLITTER_WIDTH - 3;
  603. }
  604. if(position.equals(DockableWindowManager.TOP)
  605. || position.equals(DockableWindowManager.BOTTOM))
  606. {
  607. return new Dimension(0,
  608. dimension + SPLITTER_WIDTH + 3);
  609. }
  610. else
  611. {
  612. return new Dimension(dimension + SPLITTER_WIDTH + 3,
  613. 0);
  614. }
  615. }
  616. } //}}}
  617. //{{{ ResizeMouseHandler class
  618. class ResizeMouseHandler extends MouseAdapter implements MouseMotionListener
  619. {
  620. boolean canDrag;
  621. int dragStartDimension;
  622. Point dragStart;
  623. //{{{ mousePressed() method
  624. public void mousePressed(MouseEvent evt)
  625. {
  626. dragStartDimension = dimension;
  627. dragStart = evt.getPoint();
  628. } //}}}
  629. //{{{ mouseMoved() method
  630. public void mouseMoved(MouseEvent evt)
  631. {
  632. Border border = getBorder();
  633. if(border == null)
  634. {
  635. // collapsed
  636. return;
  637. }
  638. Insets insets = border.getBorderInsets(DockablePanel.this);
  639. int cursor = Cursor.DEFAULT_CURSOR;
  640. canDrag = false;
  641. //{{{ Top...
  642. if(position.equals(DockableWindowManager.TOP))
  643. {
  644. if(evt.getY() >= getHeight() - insets.bottom)
  645. {
  646. cursor = Cursor.N_RESIZE_CURSOR;
  647. canDrag = true;
  648. }
  649. } //}}}
  650. //{{{ Left...
  651. else if(position.equals(DockableWindowManager.LEFT))
  652. {
  653. if(evt.getX() >= getWidth() - insets.right)
  654. {
  655. cursor = Cursor.W_RESIZE_CURSOR;
  656. canDrag = true;
  657. }
  658. } //}}}
  659. //{{{ Bottom...
  660. else if(position.equals(DockableWindowManager.BOTTOM))
  661. {
  662. if(evt.getY() <= insets.top)
  663. {
  664. cursor = Cursor.S_RESIZE_CURSOR;
  665. canDrag = true;
  666. }
  667. } //}}}
  668. //{{{ Right...
  669. else if(position.equals(DockableWindowManager.RIGHT))
  670. {
  671. if(evt.getX() <= insets.left)
  672. {
  673. cursor = Cursor.E_RESIZE_CURSOR;
  674. canDrag = true;
  675. }
  676. } //}}}
  677. setCursor(Cursor.getPredefinedCursor(cursor));
  678. } //}}}
  679. //{{{ mouseDragged() method
  680. public void mouseDragged(MouseEvent evt)
  681. {
  682. if(!canDrag)
  683. return;
  684. if(dragStart == null) // can't happen?
  685. return;
  686. //{{{ Top...
  687. if(position.equals(DockableWindowManager.TOP))
  688. {
  689. dimension = evt.getY()
  690. + dragStartDimension
  691. - dragStart.y;
  692. } //}}}
  693. //{{{ Left...
  694. else if(position.equals(DockableWindowManager.LEFT))
  695. {
  696. dimension = evt.getX()
  697. + dragStartDimension
  698. - dragStart.x;
  699. } //}}}
  700. //{{{ Bottom...
  701. else if(position.equals(DockableWindowManager.BOTTOM))
  702. {
  703. dimension += (dragStart.y - evt.getY());
  704. } //}}}
  705. //{{{ Right...
  706. else if(position.equals(DockableWindowManager.RIGHT))
  707. {
  708. dimension += (dragStart.x - evt.getX());
  709. } //}}}
  710. if(dimension <= 0)
  711. dimension = dragStartDimension;
  712. wm.invalidate();
  713. wm.validate();
  714. } //}}}
  715. //{{{ mouseExited() method
  716. public void mouseExited(MouseEvent evt)
  717. {
  718. setCursor(Cursor.getPredefinedCursor(
  719. Cursor.DEFAULT_CURSOR));
  720. } //}}}
  721. } //}}}
  722. } //}}}
  723. //}}}
  724. }