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

# · Java · 103 lines · 62 code · 12 blank · 29 comment · 0 complexity · 6aef6c368b34d5a08239548bee350066 MD5 · raw file

  1. /*
  2. * :tabSize=8:indentSize=8:noTabs=false:
  3. * :folding=explicit:collapseFolds=1:
  4. *
  5. * MacOSMenu.java - Menu providing features for Mac OS
  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.*;
  25. import java.awt.event.*;
  26. import java.io.File;
  27. import javax.swing.*;
  28. import javax.swing.event.*;
  29. import org.gjt.sp.jedit.*;
  30. import org.gjt.sp.jedit.menu.*;
  31. import org.gjt.sp.util.Log;
  32. import macos.*;
  33. //}}}
  34. public class MacOSMenu implements DynamicMenuProvider
  35. {
  36. //{{{ Constructor
  37. public MacOSMenu()
  38. {
  39. //super();
  40. } //}}}
  41. //{{{ updateEveryTime() method
  42. public boolean updateEveryTime()
  43. {
  44. return true;
  45. } //}}}
  46. //{{{ update() method
  47. public void update(JMenu menu)
  48. {
  49. File buff = new File(jEdit.getActiveView().getBuffer().getPath());
  50. JMenuItem showCurrent = new JMenuItem(
  51. jEdit.getProperty("MacOSPlugin.menu.showCurrent"));
  52. showCurrent.addActionListener(new ShowFileAction(buff.getPath()));
  53. showCurrent.setEnabled(buff.exists());
  54. JMenuItem showCurrentDir = new JMenuItem(
  55. jEdit.getProperty("MacOSPlugin.menu.showCurrentDir"));
  56. showCurrentDir.addActionListener(new ShowDirAction(buff.getParent()));
  57. showCurrent.setEnabled(buff.getParentFile().exists());
  58. menu.add(showCurrent);
  59. menu.add(showCurrentDir);
  60. menu.addSeparator();
  61. menu.add(new ShowBufferMenu());
  62. menu.add(new ShowRecentMenu());
  63. menu.add(new ShowRecentDirMenu());
  64. } //}}}
  65. //{{{ ShowFileAction class
  66. class ShowFileAction implements ActionListener
  67. {
  68. private String path;
  69. public ShowFileAction(String path)
  70. {
  71. this.path = path;
  72. }
  73. public void actionPerformed(ActionEvent e)
  74. {
  75. MacOSActions.showInFinder(path);
  76. }
  77. } //}}}
  78. //{{{ ShowDirAction class
  79. class ShowDirAction implements ActionListener
  80. {
  81. private String path;
  82. public ShowDirAction(String path)
  83. {
  84. this.path = path;
  85. }
  86. public void actionPerformed(ActionEvent e)
  87. {
  88. MacOSActions.showInFinder(path);
  89. }
  90. } //}}}
  91. }