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

/bundles/plugins-trunk/Ancestor/src/gatchan/jedit/ancestor/AncestorButton.java

#
Java | 65 lines | 32 code | 4 blank | 29 comment | 4 complexity | 79dca28acb35f9cff1bea9947b9c2e51 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. * AncestorButton.java - The button representation for an Ancestor
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 2007, 201 Matthieu Casanova
  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. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. package gatchan.jedit.ancestor;
  22. import javax.swing.*;
  23. import java.awt.event.ActionListener;
  24. import java.awt.event.ActionEvent;
  25. import java.awt.*;
  26. /**
  27. * @author Matthieu Casanova
  28. * @version $Id: Server.java,v 1.33 2007/01/05 15:15:17 matthieu Exp $
  29. */
  30. public class AncestorButton extends JButton
  31. {
  32. private Ancestor ancestor;
  33. //{{{ AncestorButton constructor
  34. /**
  35. * Creates a button with no set text or icon.
  36. */
  37. public AncestorButton()
  38. {
  39. addActionListener(new ActionListener()
  40. {
  41. @Override
  42. public void actionPerformed(ActionEvent e)
  43. {
  44. if (ancestor != null)
  45. {
  46. if((e.getModifiers() & ActionEvent.CTRL_MASK) != 0)
  47. ancestor.closeContainedFiles();
  48. else
  49. ancestor.doAction();
  50. }
  51. }
  52. });
  53. setMargin(new Insets(0,0,0,0));
  54. } //}}}
  55. //{{{ setAncestor() method
  56. public void setAncestor(Ancestor ancestor)
  57. {
  58. this.ancestor = ancestor;
  59. setText(ancestor.getName());
  60. } //}}}
  61. }