/plugins/PHPParser/tags/PHPParser-1.4.1/src/gatchan/phpparser/hyperlink/PHPHyperlink.java

#
Java | 114 lines | 68 code | 11 blank | 35 comment | 0 complexity | 081e28778126c06edd6de1d107eb21d7 MD5 | raw file

✨ Summary
  1. /*
  2. * jEdit - Programmer's Text Editor
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright Š 2011 Matthieu Casanova
  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. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. package gatchan.phpparser.hyperlink;
  22. import gatchan.jedit.hyperlinks.Hyperlink;
  23. import gatchan.phpparser.project.itemfinder.PHPItem;
  24. import org.gjt.sp.jedit.Buffer;
  25. import org.gjt.sp.jedit.View;
  26. import org.gjt.sp.jedit.io.VFSManager;
  27. import org.gjt.sp.jedit.jEdit;
  28. import org.gjt.sp.jedit.textarea.JEditTextArea;
  29. import org.gjt.sp.util.Log;
  30. /**
  31. * @author Matthieu Casanova
  32. */
  33. public class PHPHyperlink implements Hyperlink
  34. {
  35. private final String name;
  36. private final String path;
  37. private final int itemLine;
  38. private final int startOffset;
  39. private final int endOffset;
  40. private final int line;
  41. public PHPHyperlink(String name, String path, int itemLine, int startOffset, int endOffset, int line)
  42. {
  43. this.name = name;
  44. this.path = path;
  45. this.itemLine = itemLine;
  46. this.startOffset = startOffset;
  47. this.endOffset = endOffset;
  48. this.line = line;
  49. }
  50. @Override
  51. public int getStartOffset()
  52. {
  53. return startOffset;
  54. }
  55. @Override
  56. public int getEndOffset()
  57. {
  58. return endOffset;
  59. }
  60. @Override
  61. public int getStartLine()
  62. {
  63. return line;
  64. }
  65. @Override
  66. public int getEndLine()
  67. {
  68. return line;
  69. }
  70. @Override
  71. public String getTooltip()
  72. {
  73. return name;
  74. }
  75. @Override
  76. public void click(View view)
  77. {
  78. final Buffer buffer = jEdit.openFile(view, path);
  79. VFSManager.runInAWTThread(new Runnable()
  80. {
  81. public void run()
  82. {
  83. JEditTextArea textArea = jEdit.getActiveView().getTextArea();
  84. int caretPosition = buffer.getLineStartOffset(itemLine - 1) +
  85. itemLine - 1;
  86. textArea.moveCaretPosition(caretPosition);
  87. Log.log(Log.MESSAGE, this, "Moving to line " + itemLine + ' ' + caretPosition);
  88. /*
  89. Selection[] s = getSelection();
  90. if (s == null)
  91. return;
  92. JEditTextArea textArea = editPane.getTextArea();
  93. if (textArea.isMultipleSelectionEnabled())
  94. textArea.addToSelection(s);
  95. else
  96. textArea.setSelection(s);
  97. textArea.moveCaretPosition(occur.endPos.getOffset());*/
  98. }
  99. });
  100. }
  101. }