⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sourcebrowserplugin.java

📁 具有不同语法高亮的编辑器实例
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            addTagTypeNode(root, "Structs", map.get("s"));
            addTagTypeNode(root, "Typedefs", map.get("t"));
            break;
          case SyntaxConstants.FORTRAN_SYNTAX_STYLE:
            addTagTypeNode(root, "Block Data", map.get("b"));
            addTagTypeNode(root, "Common Blocks", map.get("c"));
            addTagTypeNode(root, "Entry Points", map.get("e"));
            addTagTypeNode(root, "Functions", map.get("f"));
            addTagTypeNode(root, "Type and Structure Components", map.get("k"));
            addTagTypeNode(root, "Labels", map.get("l"));
            addTagTypeNode(root, "Modules", map.get("m"));
            addTagTypeNode(root, "Namelists", map.get("n"));
            addTagTypeNode(root, "Programs", map.get("p"));
            addTagTypeNode(root, "Subroutines", map.get("s"));
            addTagTypeNode(root, "Derived Types/Structures", map.get("t"));
            addTagTypeNode(root, "Global and Module Variables", map.get("v"));
            break;
          case SyntaxConstants.HTML_SYNTAX_STYLE:
            addTagTypeNode(root, "Named Anchors", map.get("a"));
            addTagTypeNode(root, "JavaScript functions", map.get("f"));
            break;
          case SyntaxConstants.JAVA_SYNTAX_STYLE:
            addTagTypeNode(root, "Classes", map.get("c"));
            addTagTypeNode(root, "Fields", map.get("f"));
            addTagTypeNode(root, "Interfaces", map.get("i"));
            addTagTypeNode(root, "Methods", map.get("m"));
            addTagTypeNode(root, "Packages", map.get("p"));
            break;
          case SyntaxConstants.JAVASCRIPT_SYNTAX_STYLE:
            addTagTypeNode(root, "Functions", map.get("f"));
            break;
          case SyntaxConstants.PERL_SYNTAX_STYLE:
            addTagTypeNode(root, "Classes", map.get("c"));
            addTagTypeNode(root, "Labels", map.get("l"));
            addTagTypeNode(root, "Subroutines", map.get("s"));
            break;
          case SyntaxConstants.PYTHON_SYNTAX_STYLE:
            addTagTypeNode(root, "Classes", map.get("c"));
            addTagTypeNode(root, "Functions", map.get("f"));
            addTagTypeNode(root, "Class Members", map.get("m"));
            break;
          case SyntaxConstants.SQL_SYNTAX_STYLE:
            addTagTypeNode(root, "Cursors", map.get("c"));
            addTagTypeNode(root, "Functions", map.get("f"));
            addTagTypeNode(root, "Record Fields", map.get("F"));
            addTagTypeNode(root, "Block Label", map.get("L"));
            addTagTypeNode(root, "Packages", map.get("P"));
            addTagTypeNode(root, "Procedures", map.get("p"));
            addTagTypeNode(root, "Records", map.get("r"));
            addTagTypeNode(root, "Subtypes", map.get("s"));
            addTagTypeNode(root, "Tables", map.get("t"));
            addTagTypeNode(root, "Triggers", map.get("T"));
            addTagTypeNode(root, "Variables", map.get("V"));
            break;
          case SyntaxConstants.UNIX_SHELL_SYNTAX_STYLE:
            language = "Sh";
            addTagTypeNode(root, "Functions", map.get("f"));
            break;
        }

        treeModel.setRoot(root);

        // We'll get an IOException from, for example, trying to execute
        // a file that isn't executable.
      }
      catch (Exception exc) {
        exc.printStackTrace();
        setErrorMessage("Error running ctags executable: " + exc);
      }

    }

  }

      /*****************************************************************************/

  /**
   * Returns the author of the plugin.
   *
   * @return The plugin's author.
   */
  public String getAuthor() {
    return "Robert Futrell";
  }

      /*****************************************************************************/

  protected String getLanguageForStyle(int style) {
    String language = null;
    switch (style) {
      case SyntaxConstants.C_SYNTAX_STYLE:
        language = "C";
        break;
      case SyntaxConstants.CPLUSPLUS_SYNTAX_STYLE:
        language = "C++";
        break;
      case SyntaxConstants.CSHARP_SYNTAX_STYLE:
        language = "C#";
        break;
      case SyntaxConstants.FORTRAN_SYNTAX_STYLE:
        language = "Fortran";
        break;
      case SyntaxConstants.HTML_SYNTAX_STYLE:
        language = "HTML";
        break;
      case SyntaxConstants.JAVA_SYNTAX_STYLE:
        language = "Java";
        break;
      case SyntaxConstants.JAVASCRIPT_SYNTAX_STYLE:
        language = "JavaScript";
        break;
      case SyntaxConstants.PERL_SYNTAX_STYLE:
        language = "Perl";
        break;
      case SyntaxConstants.PYTHON_SYNTAX_STYLE:
        language = "Python";
        break;
      case SyntaxConstants.SQL_SYNTAX_STYLE:
        language = "SQL";
        break;
      case SyntaxConstants.UNIX_SHELL_SYNTAX_STYLE:
        language = "Sh";
        break;
      default:
        language = null;
    }
    return language;
  }

      /*****************************************************************************/

  /**
   * Returns the path used to run the ctags executable.
   *
   * @return The path used.
   * @see #setCTagsExecutableLocation
   */
  public String getCTagsExecutableLocation() {
    return ctagsExecutableLocation;
  }

      /*****************************************************************************/

  /**
   * Returns HTML (to use in tooltips) representing the specified line
   * in the current text area.
   *
   * @param line The line.
   * @return An HTML representation of the line.
   */
  protected String getHTMLForLine(int line) {
    RSyntaxTextArea textArea = owner.getMainView().getCurrentTextArea();
    Token t = textArea.getTokenListForLine(line);
    StringBuffer text = new StringBuffer("<html>");
    while (t != null && t.isPaintable()) {
      text.append(t.getHTMLRepresentation(textArea));
      t = t.getNextToken();
    }
    text.append("</html>");
    return text.toString();
  }

      /*****************************************************************************/

  /**
   * Returns the icon for this plugin.
   *
   * @return The icon for this plugin.
   */
  public Icon getIcon() {
    return pluginIcon;
  }

      /*****************************************************************************/

  /**
   * Returns the menu items for this plugin.
   *
   * @return The menu for this plugin.
   */
  public JMenu getMenu() {

    JMenu menu = new JMenu(getName());

    JCheckBoxMenuItem cbMenuItem =
        new JCheckBoxMenuItem(new ViewAction(msg));
    cbMenuItem.setSelected(isActive());
    menu.add(cbMenuItem);

    return menu;

  }

      /*****************************************************************************/

  /**
   * Returns the name of this <code>GUIPlugin</code>.
   *
   * @return This plugin's name.
   */
  public String getName() {
    return name;
  }

      /*****************************************************************************/

  /**
   * Returns the options panel for this source browser.
   *
   * @return The options panel.
   */
  public synchronized PluginOptionsDialogPanel getOptionsDialogPanel() {
    if (optionPanel == null) {
      optionPanel = new SourceBrowserOptionPanel(owner, this);
    }
    return optionPanel;
  }

      /*****************************************************************************/

  /**
   * Returns the text being displayed for the specified row in the ctags
   * tree.
   *
   * @param row The for for which to return text.
   * @return The text.
   */
  private final String getTagTextForRow(int row) {
    TreePath path = sourceTree.getPathForRow(row);
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.
        getLastPathComponent();
    return node.toString();
  }

      /*****************************************************************************/

  /**
   * Return whether HTML tooltips are being used by the source browser.
   *
   * @return Whether HTML tooltips are used.
   * @see #setUseHTMLToolTips
   */
  public boolean getUseHTMLToolTips() {
    return useHTMLToolTips;
  }

      /*****************************************************************************/

  /**
   * Returns the plugin version.
   */
  public String getVersion() {
    return VERSION_STRING;
  }

      /*****************************************************************************/

  /**
   * Called just after a plugin is added to a GUI application.<p>
   *
   * This method adds a listener to RText's main view so that we are
   * notified when the current document changes (so we can update the
   * displayed ctags).
   *
   * @param app The application to which this plugin was just added.
   * @see #uninstall
   */
  public void install(AbstractPluggableGUIApplication app) {
    owner.getMainView().addCurrentTextAreaListener(this);
  }

      /*****************************************************************************/

  /**
   * Decides whether or not to display the popup menu.
   *
   * @param e The mouse event to check.
   */
  public void maybeShowPopup(MouseEvent e) {

    if (e.isPopupTrigger()) {

      ResourceBundle msg = ResourceBundle.getBundle(BUNDLE_NAME);
      mouseX = e.getX();
      mouseY = e.getY();
      int row = sourceTree.getClosestRowForLocation(mouseX, mouseY);
      if (row == -1) {
        return; // If tree isn't visible (e.g. plain text file).
      }

      DefaultMutableTreeNode node = (DefaultMutableTreeNode) sourceTree.
          getPathForRow(row).getLastPathComponent();

      String tagText = node.toString();

      // Ignore the expandable "tag type" nodes. Special care must be
      // taken here because empty tag-type nodes are considered
      // "leaves."
      if (!sourceTree.getModel().isLeaf(node) || tagText.indexOf("(0)") > -1) {
        return;
      }

      // Create the right-click menu if it isn't already done.
      if (rightClickMenu == null) {
        createRightClickMenu();

        // Prepare the "Insert tag" menu item.
      }
      JMenuItem menuItem = (JMenuItem) rightClickMenu.getComponent(0);
      menuItem.setText(msg.getString("InsertTag") + tagText);
      menuItem.setMnemonic(
          msg.getString("InsertTagMnemonic").charAt(0));

      // Prepare the "Jump to tag" menu item.
      menuItem = (JMenuItem) rightClickMenu.getComponent(1);
      menuItem.setText(msg.getString("JumpToTag") + tagText);
      menuItem.setMnemonic(
          msg.getString("JumpToTagMnemonic").charAt(0));
      rightClickMenu.show(sourceTree, mouseX, mouseY);

    }

  }

      /*****************************************************************************/

  /**
   * Called when the user clicks in the ctags tree.
   */
  public void mouseClicked(MouseEvent e) {
    maybeShowPopup(e);
  }

      /*****************************************************************************/

  /**
   * Called when the mouse is dragged in the ctags tree.
   */
  public void mouseDragged(MouseEvent e) {
    mouseMovedImpl(e);
  }

      /*****************************************************************************/

  /**
   * Called when the mouse enters the ctags tree.
   */
  public void mouseEntered(MouseEvent e) {
  }

      /*****************************************************************************/

  /**
   * Called when the mouse exits the ctags tree.
   */
  public void mouseExited(MouseEvent e) {
  }

      /*****************************************************************************/

  /**
   * Called when the mouse is moved in the ctags tree.
   */
  public void mouseMoved(MouseEvent e) {
    mouseMovedImpl(e);
  }

      /*****************************************************************************/

  /**
   * Called when the mouse moves/is dragged over the source browser tree.
   * This method sets the tooltip displayed for the source browser tree.
   */
  private void mouseMovedImpl(MouseEvent e) {

    // Get the item the mouse is pointing at.  It is possible that
    // They are pointing at no item; in that case, just quit now.
    int row = sourceTree.getRowForLocation(e.getX(), e.getY());
    if (row == -1) {
      return;
    }
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) sourceTree.
        getPathForRow(row).getLastPathComponent();
    if (node == null) {
      return;
    }
    Object object = node.getUserObject();
    String text = null;

    // If it's a high-level node (e.g. "Methods (4)").
    if (object instanceof String) {
      text = (String) object;
    }

    // If it's a low-level node (function, variable, etc.).  Note
    // that this should always be a TagEntry, but we're just being
    // safe by checking here.
    else if (object instanceof TagEntry) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -