PageRenderTime 50ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-2-pre14/jars/MacOS/macos/menu/ShowRecentDirMenu.java

#
Java | 108 lines | 67 code | 12 blank | 29 comment | 3 complexity | d470e39892e904fbaa7db73fce5bd22f 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. * ShowRecentDirMenu.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 java.util.Vector;
  27. import javax.swing.*;
  28. import javax.swing.event.*;
  29. import org.gjt.sp.jedit.*;
  30. import org.gjt.sp.jedit.browser.*;
  31. import org.gjt.sp.jedit.gui.*;
  32. import macos.*;
  33. //}}}
  34. public class ShowRecentDirMenu extends JMenu implements MenuListener
  35. {
  36. //{{{ Constructor
  37. public ShowRecentDirMenu()
  38. {
  39. super(jEdit.getProperty("MacOSPlugin.menu.recentDir.label"));
  40. addMenuListener(this);
  41. } //}}}
  42. //{{{ construct() method
  43. private void construct()
  44. {
  45. HistoryModel model = HistoryModel.getModel("vfs.browser.path");
  46. JMenuItem item;
  47. File file;
  48. int max = model.getSize();
  49. if (max == 0)
  50. {
  51. item = new JMenuItem(jEdit.getProperty("MacOSPlugin.menu.recentDir.none"));
  52. item.setEnabled(false);
  53. add(item);
  54. return;
  55. }
  56. for (int i=0; i < max ; i++)
  57. {
  58. file = new File(model.getItem(i));
  59. item = new ShowRecentDirMenuItem(file.getName(),file.getPath());
  60. item.setIcon(FileCellRenderer.dirIcon);
  61. add(item);
  62. }
  63. } //}}}
  64. //{{{ menuSelected() method
  65. public void menuSelected(MenuEvent e)
  66. {
  67. construct();
  68. } //}}}
  69. //{{{ menuDeselected() method
  70. public void menuDeselected(MenuEvent e)
  71. {
  72. removeAll();
  73. } //}}}
  74. //{{{ menuCanceled() method
  75. public void menuCanceled(MenuEvent e)
  76. {
  77. } //}}}
  78. //{{{ ShowRecentDirMenuItem class
  79. class ShowRecentDirMenuItem extends JMenuItem
  80. {
  81. String path;
  82. public ShowRecentDirMenuItem(String name, String path)
  83. {
  84. super(name);
  85. this.path = path;
  86. addActionListener(new ShowFileAction());
  87. }
  88. class ShowFileAction implements ActionListener
  89. {
  90. public void actionPerformed(ActionEvent e)
  91. {
  92. MacOSActions.showInFinder(path);
  93. }
  94. }
  95. } //}}}
  96. }