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

📄 rtext.java~2~

📁 具有不同语法高亮的编辑器实例
💻 JAVA~2~
📖 第 1 页 / 共 4 页
字号:

    RTextPreferences properties = (RTextPreferences) prefs;
    ResourceBundle msg = getResourceBundle();

    StatusBar statusBar = (StatusBar) getStatusBar();

    //splashScreen.updateStatus(msg.getString("CreatingMenuBar"), 75);

    // Create the menu bar.
    menuBar = new RTextMenuBar(this, statusBar,
                               UIManager.getLookAndFeel().getName(),
                               properties);
    mainView.addPropertyChangeListener(menuBar);

    menuBar.setWindowMenuVisible(properties.mainView == MDI_VIEW);

    return menuBar;

  }

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

  /**
       * Returns the splash screen to display while this GUI application is loading.
   *
   * @return The splash screen.  If <code>null</code> is returned, no splash
   * screen is displayed.
   */
  protected SplashScreen createSplashScreen() {
    ResourceBundle msg = getResourceBundle();
    return new SplashScreen("org/fife/rtext/graphics/aboutdialogimage.jpg",
                            msg.getString("Initializing"));
  }

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

  /**
   * Returns the status bar to be used by this application.
   *
   * @param prefs This GUI application's preferences.
   * @return The status bar.
   */
  protected org.fife.ui.StatusBar createStatusBar(
      GUIApplicationPreferences prefs) {
    RTextPreferences properties = (RTextPreferences) prefs;
    ResourceBundle msg = getResourceBundle();
    StatusBar sb = new StatusBar(this, msg.getString("Ready"),
                                 !properties.wordWrap, 1, 1,
                                 properties.textMode ==
                                 RTextEditorPane.OVERWRITE_MODE);
    sb.setStyle(properties.statusBarStyle);
    return sb;
  }

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

  /**
   * Creates and returns the toolbar to be used by this application.
   *
   * @param prefs This GUI application's preferences.
   * @return The toolbar.
   */
  protected CustomizableToolBar createToolBar(
      GUIApplicationPreferences prefs) {

    RTextPreferences properties = (RTextPreferences) prefs;
    ResourceBundle msg = getResourceBundle();

    StandardToolBar toolBar = new StandardToolBar("rtext - Toolbar", this,
                                                  (StatusBar) getStatusBar());

    // Make the toolbar use the large versions of the icons if available.
    // FIXME:  Make toggle-able.
    toolBar.checkForLargeIcons();

    return toolBar;

  }

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

  /**
   * Overridden so we can syntax highlight the Java exception displayed.
   *
   * @param owner The dialog that threw the Exception.
   * @param t The exception/throwable that occured.
   */
  public void displayException(Dialog owner, Throwable t) {
    ExceptionDialog ed = new ExceptionDialog(owner, t);
    ed.setLocationRelativeTo(owner);
    ed.setVisible(true);
  }

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

  /**
   * Overridden so we can syntax highlight the Java exception displayed.
   *
   * @param owner The child frame that threw the Exception.
   * @param t The exception/throwable that occured.
   */
  public void displayException(Frame owner, Throwable t) {
    ExceptionDialog ed = new ExceptionDialog(owner, t);
    ed.setLocationRelativeTo(owner);
    ed.setVisible(true);
  }

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

  /**
   * Called when the user attempts to close the application, whether from
   * an "Exit" menu item, closing the main application window, or any other
   * means.  The user is prompted to save any dirty documents, and this
   * RText instance is closed.
   */
  public void doExit() {

    // Attempt to close all open documents.
    boolean allDocumentsClosed = getMainView().closeAllDocuments();

    // Assuming all documents closed okay (ie, the user
    // didn't click "Cancel")...
    if (allDocumentsClosed == true) {

      // If there will be no more rtext's running, stop the JVM.
      if (StoreKeeper.getInstanceCount() == 1) {
        saveRTextPreferences(); // Try to save the user's running preferences.
        boolean saved = RTextEditorPane.saveTemplates();
        if (!saved) {
          ResourceBundle msg = getResourceBundle();
          String title = msg.getString("ErrorDialogTitle");
          String text = msg.getString("TemplateSaveError");
          JOptionPane.showMessageDialog(this, text, title,
                                        JOptionPane.ERROR_MESSAGE);
        }
        System.exit(0); // And quit.
      }

      // If there will still be some RText instances running, just
      // stop this instance.
      else {
        setVisible(false);
        StoreKeeper.removeRTextInstance(this);
        this.dispose();
      }

    }

  }

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

  /**
   * Returns the filename used for newly created, empty text files.  This
   * value is locale-specific.
   *
   * @return The new text file name.
   */
  public String getNewFileName() {
    return newFileName;
  }

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

  /**
   * Returns the file chooser being used by this RText instance.
   *
   * @return The file chooser.
   */
  public RTextFileChooser getFileChooser() {
    if (chooser == null) {
      chooser = RTextUtilities.createFileChooser(this);
    }
    return chooser;
  }

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

  /**
   * Returns the Help dialog for RText.
   *
   * @return The Help dialog.
   * @see org.fife.ui.app.GUIApplication#getHelpDialog
   */
  public HelpDialog getHelpDialog() {
    // Create the help dialog if it hasn't already been.
    if (helpDialog == null) {
      String contentsPath = getInstallLocation() + "/doc/";
      String helpPath = contentsPath + getLanguage() + "/";
      // If localized help does not exist, default to English.
      File test = new File(helpPath);
      if (!test.isDirectory()) {
        helpPath = contentsPath + "en/";
      }
      helpDialog = new HelpDialog(this,
                                  contentsPath + "HelpDialogContents.xml",
                                  helpPath);
      helpDialog.setBackButtonIcon(iconGroup.getIcon("back"));
      helpDialog.setForwardButtonIcon(iconGroup.getIcon("forward"));
    }
    helpDialog.setLocationRelativeTo(this);
    return helpDialog;
  }

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

  /**
   * Returns the icon group being used for icons for actions.
   *
   * @return The icon group.
   */
  public IconGroup getIconGroup() {
    return iconGroup;
  }

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

  /**
   * Returns the icon groups available to RText.
   *
   * @return The icon groups.
   */
  Map getIconGroupMap() {
    return iconGroupMap;
  }

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

  /**
   * Returns an array of information on JAR files containing 3rd party Look
   * and Feels.  These JAR files will be added to the
   * <code>UIManager</code>'s classpath so that these LnFs can be used in
   * this GUI application.<p>
   *
   * RText reads all 3rd party Look and Feels from an XML file, so this stuff
   * is done dynamically and can be configured by the user.
   *
   * @return An array of URLs for JAR files containing Look and Feels.
   */
  protected ExtendedLookAndFeelInfo[] get3rdPartyLookAndFeelInfo() {
    try {
      return ThirdPartyLookAndFeelManager.get3rdPartyLookAndFeelInfo(
          this, "lnfs/lookandfeels.xml");
    }
    catch (IOException ioe) {
      return null;
    }
  }

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

  /**
   * Returns the actual main view.
   *
   * @return The main view.
   * @see #getMainViewStyle
   * @see #setMainViewStyle
   */
  public AbstractMainView getMainView() {
    return mainView;
  }

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

  /**
   * Returns the main view style.
   *
   * @return The main view style, one of <code>TABBED_VIEW</code>,
   *         <code>SPLIT_PANE_VIEW</code>, or <code>MDI_VIEW</code>.
   * @see #setMainViewStyle
   * @see #getMainView
   */
  public int getMainViewStyle() {
    return mainViewStyle;
  }

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

  /**
   * Returns the name of the preferences class for this application.  This
   * class must be a subclass of <code>GUIApplicationPreferences</code>.
   *
   * @return The class name, or <code>null</code> if this GUI application
   *         does not save preferences.
   */
  protected String getPreferencesClassName() {
    return "org.fife.rtext.RTextPreferences";
  }

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

  /**
   * Returns the fully-qualified class name of the resource bundle for this
   * application.  This is used by <code>getResourceBundle</code> to locate
   * the class.
   *
   * @return The fully-qualified class name of the resource bundle.
   * @see #getResourceBundle
   */
  public String getResourceBundleClassName() {
    return "org.fife.rtext.RText";
  }

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

  /**
   * Returns the QuickSearch toolbar.
   *
   * @return The QuickSearch toolbar.
   * @see #isSearchToolBarVisible
   */
  public SearchToolBar getSearchToolBar() {
    if (searchBar == null) {
      searchBar = new SearchToolBar("Search", this,
                                    (org.fife.rtext.StatusBar) getStatusBar());
      searchBar.setVisible(false);
      addToolBar(searchBar, BorderLayout.SOUTH);
    }
    return searchBar;
  }

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

  /**
   * Returns the syntax highlighting color scheme being used.
   *
   * @return The syntax highlighting color scheme.
   */
  public SyntaxHighlightingColorScheme getSyntaxHighlightingColorScheme() {
    return colorScheme;
  }

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

  /**
   * Returns the tab size (in spaces) currently being used.
   *
   * @return The tab size (in spaces) currently being used.
   * @see #setTabSize
   */
  public int getTabSize() {
    return mainView.getTabSize();
  }

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

  /**
   * Returns the version string for this application.
   *
   * @return The version string.
   */
  public String getVersionString() {
    return VERSION_STRING;
  }

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

  /**
   * Returns the "working directory;" that is, the directory that new, empty
   * files are created in.
   *
   * @return The working directory.  There will be no trailing '/' or '\'.
   * @see #setWorkingDirectory
   */
  public String getWorkingDirectory() {
    return workingDirectory;
  }

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

  /**
   * Does the dirty work of actually installing a plugin.  This method
   * does nothing.
   *
   * @param plugin The plugin to install.
   */
  protected void handleInstallPlugin(Plugin plugin) {
  }

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

  /**
   * This function is called whenever text is inserted into the document
   * AFTER the fact.
   */
  public void insertUpdate(DocumentEvent e) {

    RTextEditorPane textArea = mainView.currentTextArea;

⌨️ 快捷键说明

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