PageRenderTime 36ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/bundles/plugins-trunk/JavaInsight/javainsight/JavaInsightPlugin.java

#
Java | 85 lines | 48 code | 9 blank | 28 comment | 15 complexity | bf867adee8dd731a323608226dd4b8c4 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. * jEdit edit mode settings:
  3. * :mode=java:tabSize=4:indentSize=4:noTabs=true:maxLineLen=0:
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. package javainsight;
  20. import org.gjt.sp.jedit.Buffer;
  21. import org.gjt.sp.jedit.EBMessage;
  22. import org.gjt.sp.jedit.EBPlugin;
  23. import org.gjt.sp.jedit.Mode;
  24. import org.gjt.sp.jedit.View;
  25. import org.gjt.sp.jedit.jEdit;
  26. import org.gjt.sp.jedit.io.VFS;
  27. import org.gjt.sp.jedit.io.VFSFile;
  28. import org.gjt.sp.jedit.io.VFSManager;
  29. import org.gjt.sp.jedit.msg.BufferUpdate;
  30. /**
  31. * Main JavaInsight plugin class.
  32. *
  33. * @author Kevin A. Burton
  34. * @version $Id: JavaInsightPlugin.java 9456 2007-04-18 20:09:54Z dmoebius $
  35. */
  36. public class JavaInsightPlugin extends EBPlugin
  37. {
  38. /**
  39. * Handle message for decompile requests.
  40. */
  41. @Override
  42. public void handleMessage(EBMessage message) {
  43. if (message instanceof BufferUpdate) {
  44. BufferUpdate bu = (BufferUpdate) message;
  45. if (bu.getWhat() == BufferUpdate.LOADED) {
  46. Buffer buffer = bu.getBuffer();
  47. VFS vfs = buffer.getVFS();
  48. Mode mode = null;
  49. if (ClassVFS.PROTOCOL.equals(vfs.getName()) || JasminVFS.PROTOCOL.equals(vfs.getName())) {
  50. mode = jEdit.getMode("bcel");
  51. } else if (JodeVFS.PROTOCOL.equals(vfs.getName())) {
  52. mode = jEdit.getMode("java");
  53. }
  54. if (mode != null) {
  55. buffer.setMode(mode);
  56. }
  57. }
  58. }
  59. }
  60. public void handleBrowserAction(View view, VFSFile[] files, String protocol) {
  61. if (files == null) {
  62. // TODO: error message
  63. view.getToolkit().beep();
  64. return;
  65. }
  66. for (VFSFile entry : files) {
  67. if (entry.getType() == VFSFile.FILE) {
  68. VFS vfs = VFSManager.getVFSForPath(entry.getPath());
  69. if(protocol.equals(vfs.getName()))
  70. jEdit.openFile(view, entry.getPath());
  71. else
  72. jEdit.openFile(view, protocol + ':' + entry.getPath());
  73. }
  74. }
  75. }
  76. }