Class Tools


  • public final class Tools
    extends java.lang.Object
    GUI-related tools.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Tools()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static void addHyperlinkListener​(javax.swing.JTextPane pane)  
      static void centerDialog​(javax.swing.JDialog dialog)
      Set dialog location to the center of the screen
      static void configureFromRules​(org.languagetool.JLanguageTool langTool, Configuration config)  
      private static java.lang.String encodeUrl​(org.languagetool.rules.Rule rule)  
      private static java.lang.String formatURL​(java.net.URL url)  
      private static java.lang.String getExampleSentences​(org.languagetool.rules.Rule rule, java.util.ResourceBundle messages)  
      static java.lang.String getLabel​(java.lang.String label)
      Returns translation of the UI element without the control character &.
      static char getMnemonic​(java.lang.String label)
      Returns mnemonic of a UI element.
      (package private) static java.io.File openDirectoryDialog​(java.awt.Frame frame, java.io.File initialDir)
      Show a directory chooser dialog, starting with a specified directory
      (package private) static java.io.File openFileDialog​(java.awt.Frame frame, javax.swing.filechooser.FileFilter fileFilter)
      Show a file chooser dialog and return the file selected by the user or null.
      (package private) static java.io.File openFileDialog​(java.awt.Frame frame, javax.swing.filechooser.FileFilter fileFilter, java.io.File initialDir)
      Show a file chooser dialog in a specified directory
      private static java.io.File openFileDialog​(java.awt.Frame frame, javax.swing.filechooser.FileFilter fileFilter, java.io.File initialDir, int mode)  
      (package private) static void openURL​(java.lang.String url)
      Launches the default browser to display a URL.
      (package private) static void openURL​(java.net.URL url)
      Launches the default browser to display a URL.
      static java.lang.String shortenComment​(java.lang.String comment)
      LibO shortens menu items with more than ~100 characters by dropping text in the middle.
      (package private) static void showError​(java.lang.Exception e)
      Show the exception (with stacktrace) in a dialog and print it to STDERR.
      (package private) static void showErrorMessage​(java.lang.Exception e)
      Show the exception (message without stacktrace) in a dialog and print the stacktrace to STDERR.
      (package private) static void showErrorMessage​(java.lang.Exception e, java.awt.Component parent)
      Show the exception (message without stacktrace) in a dialog and print the stacktrace to STDERR.
      (package private) static void showRuleInfoDialog​(java.awt.Component parent, java.lang.String title, java.lang.String message, org.languagetool.rules.Rule rule, java.net.URL matchUrl, java.util.ResourceBundle messages, java.lang.String lang)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Tools

        private Tools()
    • Method Detail

      • openFileDialog

        static java.io.File openFileDialog​(java.awt.Frame frame,
                                           javax.swing.filechooser.FileFilter fileFilter)
        Show a file chooser dialog and return the file selected by the user or null.
      • openFileDialog

        static java.io.File openFileDialog​(java.awt.Frame frame,
                                           javax.swing.filechooser.FileFilter fileFilter,
                                           java.io.File initialDir)
        Show a file chooser dialog in a specified directory
        Parameters:
        frame - Owner frame
        fileFilter - The pattern of files to choose from
        initialDir - The initial directory
        Returns:
        the selected file
        Since:
        2.6
      • openDirectoryDialog

        static java.io.File openDirectoryDialog​(java.awt.Frame frame,
                                                java.io.File initialDir)
        Show a directory chooser dialog, starting with a specified directory
        Parameters:
        frame - Owner frame
        initialDir - The initial directory
        Returns:
        the selected file
        Since:
        3.0
      • openFileDialog

        private static java.io.File openFileDialog​(java.awt.Frame frame,
                                                   javax.swing.filechooser.FileFilter fileFilter,
                                                   java.io.File initialDir,
                                                   int mode)
      • showError

        static void showError​(java.lang.Exception e)
        Show the exception (with stacktrace) in a dialog and print it to STDERR.
      • showErrorMessage

        static void showErrorMessage​(java.lang.Exception e,
                                     java.awt.Component parent)
        Show the exception (message without stacktrace) in a dialog and print the stacktrace to STDERR.
      • showErrorMessage

        static void showErrorMessage​(java.lang.Exception e)
        Show the exception (message without stacktrace) in a dialog and print the stacktrace to STDERR.
      • shortenComment

        public static java.lang.String shortenComment​(java.lang.String comment)
        LibO shortens menu items with more than ~100 characters by dropping text in the middle. That isn't really sensible, so we shorten the text here in order to preserve the important parts.
      • getLabel

        public static java.lang.String getLabel​(java.lang.String label)
        Returns translation of the UI element without the control character &. To have & in the UI, use &&.
        Parameters:
        label - Label to convert.
        Returns:
        String UI element string without mnemonics.
      • getMnemonic

        public static char getMnemonic​(java.lang.String label)
        Returns mnemonic of a UI element.
        Parameters:
        label - String Label of the UI element
        Returns:
        Mnemonic of the UI element, or in case of no mnemonic set.
      • centerDialog

        public static void centerDialog​(javax.swing.JDialog dialog)
        Set dialog location to the center of the screen
        Parameters:
        dialog - the dialog which will be centered
        Since:
        2.6
      • configureFromRules

        public static void configureFromRules​(org.languagetool.JLanguageTool langTool,
                                              Configuration config)
        Since:
        3.3
      • addHyperlinkListener

        static void addHyperlinkListener​(javax.swing.JTextPane pane)
      • openURL

        static void openURL​(java.lang.String url)
        Launches the default browser to display a URL.
        Parameters:
        url - the URL to be displayed
        Since:
        4.1
      • openURL

        static void openURL​(java.net.URL url)
        Launches the default browser to display a URL.
        Parameters:
        url - the URL to be displayed
        Since:
        4.1
      • showRuleInfoDialog

        static void showRuleInfoDialog​(java.awt.Component parent,
                                       java.lang.String title,
                                       java.lang.String message,
                                       org.languagetool.rules.Rule rule,
                                       java.net.URL matchUrl,
                                       java.util.ResourceBundle messages,
                                       java.lang.String lang)
      • encodeUrl

        private static java.lang.String encodeUrl​(org.languagetool.rules.Rule rule)
      • getExampleSentences

        private static java.lang.String getExampleSentences​(org.languagetool.rules.Rule rule,
                                                            java.util.ResourceBundle messages)
      • formatURL

        private static java.lang.String formatURL​(java.net.URL url)