PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-2-pre4/jars/MacOS/macos/menu/ShowBufferMenu.java

#
Java | 106 lines | 65 code | 12 blank | 29 comment | 4 complexity | 7a301980168f8aedad069c07ec4224c2 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. * :tabSize=8:indentSize=8:noTabs=false:
  3. * :folding=explicit:collapseFolds=1:
  4. *
  5. * ShowBufferMenu.java
  6. * Copyright (C) 2002 Kris Kopicki
  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 macos.menu;
  23. //{{{ Imports
  24. import java.awt.event.*;
  25. import java.io.File;
  26. import javax.swing.*;
  27. import javax.swing.event.*;
  28. import org.gjt.sp.jedit.*;
  29. import org.gjt.sp.jedit.browser.*;
  30. import macos.*;
  31. //}}}
  32. public class ShowBufferMenu extends JMenu implements MenuListener
  33. {
  34. //{{{ Constructor
  35. public ShowBufferMenu()
  36. {
  37. super(jEdit.getProperty("MacOSPlugin.menu.buffers.label"));
  38. addMenuListener(this);
  39. } //}}}
  40. //{{{ construct() method
  41. private void construct()
  42. {
  43. JMenuItem item;
  44. removeAll();
  45. Buffer[] buffs = jEdit.getBuffers();
  46. for (int i=0; i < buffs.length; i++)
  47. {
  48. if (!buffs[i].isUntitled())
  49. {
  50. item = add(new ShowBufferMenuItem(
  51. buffs[i].getName(),buffs[i].getPath()));
  52. item.setIcon(FileCellRenderer.fileIcon);
  53. add(item);
  54. }
  55. }
  56. if (getItemCount() == 0)
  57. {
  58. item = new JMenuItem(jEdit.getProperty("MacOSPlugin.menu.buffers.none"));
  59. item.setEnabled(false);
  60. add(item);
  61. }
  62. } //}}}
  63. //{{{ menuSelected() method
  64. public void menuSelected(MenuEvent e)
  65. {
  66. construct();
  67. } //}}}
  68. //{{{ menuDeselected() method
  69. public void menuDeselected(MenuEvent e)
  70. {
  71. } //}}}
  72. //{{{ menuCanceled() method
  73. public void menuCanceled(MenuEvent e)
  74. {
  75. } //}}}
  76. //{{{ ShowBufferMenuItem class
  77. class ShowBufferMenuItem extends JMenuItem
  78. {
  79. String path;
  80. public ShowBufferMenuItem(String name, String path)
  81. {
  82. super(name);
  83. this.path = path;
  84. addActionListener(new ShowFileAction());
  85. }
  86. class ShowFileAction implements ActionListener
  87. {
  88. public void actionPerformed(ActionEvent e)
  89. {
  90. MacOSActions.showInFinder(path);
  91. }
  92. }
  93. } //}}}
  94. }