PageRenderTime 56ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-5-pre1/org/gjt/sp/jedit/gui/statusbar/ModeWidgetFactory.java

#
Java | 90 lines | 50 code | 9 blank | 31 comment | 3 complexity | aedb949171cdfd2b3444174bba8ebdbc 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. * ModeWidgetFactory.java - The mode widget service
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 2008 Matthieu Casanova
  7. * Portions Copyright (C) 2001, 2004 Slava Pestov
  8. * Portions copyright (C) 2001 Mike Dillon
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version 2
  13. * of the License, or any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  23. */
  24. package org.gjt.sp.jedit.gui.statusbar;
  25. //{{{ Imports
  26. import java.awt.event.MouseAdapter;
  27. import java.awt.event.MouseEvent;
  28. import javax.swing.JComponent;
  29. import javax.swing.JLabel;
  30. import org.gjt.sp.jedit.Buffer;
  31. import org.gjt.sp.jedit.View;
  32. import org.gjt.sp.jedit.gui.BufferOptions;
  33. import org.gjt.sp.jedit.jEdit;
  34. //}}}
  35. /**
  36. * @author Matthieu Casanova
  37. * @since jEdit 4.3pre14
  38. */
  39. public class ModeWidgetFactory implements StatusWidgetFactory
  40. {
  41. //{{{ getWidget() method
  42. public Widget getWidget(View view)
  43. {
  44. ModeWidget mode = new ModeWidget(view);
  45. return mode;
  46. } //}}}
  47. //{{{ ModeWidget class
  48. private static class ModeWidget implements Widget
  49. {
  50. private final JLabel mode;
  51. private final View view;
  52. public ModeWidget(final View view)
  53. {
  54. mode = new ToolTipLabel();
  55. this.view = view;
  56. mode.setToolTipText(jEdit.getProperty("view.status.mode-tooltip"));
  57. mode.addMouseListener(new MouseAdapter()
  58. {
  59. @Override
  60. public void mouseClicked(MouseEvent evt)
  61. {
  62. if(evt.getClickCount() == 2)
  63. new BufferOptions(view,view.getBuffer());
  64. }
  65. });
  66. }
  67. public JComponent getComponent()
  68. {
  69. return mode;
  70. }
  71. public void update()
  72. {
  73. Buffer buffer = view.getBuffer();
  74. if (buffer.isLoaded())
  75. mode.setText(buffer.getMode().toString());
  76. }
  77. public void propertiesChanged()
  78. {
  79. }
  80. } //}}}
  81. }