Class Tools

java.lang.Object
org.languagetool.gui.Tools

public final class Tools extends Object
GUI-related tools.
  • Constructor Details

    • Tools

      private Tools()
  • Method Details

    • openFileDialog

      static File openFileDialog(Frame frame, FileFilter fileFilter)
      Show a file chooser dialog and return the file selected by the user or null.
    • openFileDialog

      static File openFileDialog(Frame frame, FileFilter fileFilter, 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 File openDirectoryDialog(Frame frame, 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 File openFileDialog(Frame frame, FileFilter fileFilter, File initialDir, int mode)
    • showError

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

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

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

      public static String shortenComment(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 String getLabel(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(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(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(JTextPane pane)
    • openURL

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

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

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

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

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

      private static String formatURL(URL url)