<commit_before>/*
 * $Id$
 *
 * Copyright (c) 2000-2003 by <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License (LGPL) as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, copies are available
 * at http://www.opensource.org.
 */
package VASSAL.build.module;

import java.io.File;
import java.net.MalformedURLException;
import org.w3c.dom.Element;
import VASSAL.Info;
import VASSAL.build.AbstractConfigurable;
import VASSAL.build.Buildable;
import VASSAL.build.GameModule;
import VASSAL.build.module.documentation.AboutScreen;
import VASSAL.build.module.documentation.BrowserHelpFile;
import VASSAL.build.module.documentation.HelpFile;
import VASSAL.build.module.documentation.Tutorial;
import VASSAL.configure.CompoundValidityChecker;
import VASSAL.configure.Configurer;
import VASSAL.configure.MandatoryComponent;
import VASSAL.configure.SingleChildInstance;
import VASSAL.i18n.Resources;

/**
 * Represents the <code>Help</code> menu of the controls window
 */
public class Documentation extends AbstractConfigurable {
  /** Preferences key for the directory where VASSAL documentation is stored */
  private javax.swing.JMenu controls;

  public Documentation() {
    controls = new javax.swing.JMenu(Resources.getString(Resources.HELP));
  }

  public javax.swing.JMenu getHelpMenu() {
    return controls;
  }

  public void build(Element el) {
    if (el == null) {
      try {
        AboutScreen about = new AboutScreen();
        about.setAttribute(AboutScreen.TITLE, Resources.getString("Documentation.about_vassal")); //$NON-NLS-1$
        about.setAttribute(AboutScreen.FILE, "/images/Splash.png"); //$NON-NLS-1$
        about.addTo(this);
        add(about);
      }
      catch (Exception err) {
        err.printStackTrace();
      }
      HelpFile intro = new HelpFile();
      intro.setAttribute(HelpFile.TITLE, Resources.getString("Documentation.quick_start")); //$NON-NLS-1$
      intro.setAttribute(HelpFile.FILE, "/help/Intro.html"); //$NON-NLS-1$
      intro.setAttribute(HelpFile.TYPE, HelpFile.RESOURCE);
      intro.addTo(this);
      add(intro);
    }
    else {
      super.build(el);
    }
  }

  public static File getDocumentationBaseDir() {
    File dir = new File(Info.getHomeDir(),Info.getMinorVersion());
    return new File(dir,"docs");
  }

  public void addTo(Buildable b) {
    GameModule.getGameModule().getFrame().getJMenuBar().add(controls);
    validator = new CompoundValidityChecker(new MandatoryComponent(this, AboutScreen.class), new SingleChildInstance(GameModule.getGameModule(), getClass()));
  }

  public void removeFrom(Buildable b) {
  }

  public String[] getAttributeDescriptions() {
    return new String[0];
  }

  public Class<?>[] getAttributeTypes() {
    return new Class<?>[0];
  }

  public Configurer getConfigurer() {
    return null;
  }

  public Class[] getAllowableConfigureComponents() {
    return new Class[]{
      BrowserHelpFile.class,<commit_msg>Documentation:  Don't require AboutScreen child component<commit_after>/*
 * $Id$
 *
 * Copyright (c) 2000-2003 by <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License (LGPL) as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, copies are available
 * at http://www.opensource.org.
 */
package VASSAL.build.module;

import java.io.File;
import java.net.MalformedURLException;
import org.w3c.dom.Element;
import VASSAL.Info;
import VASSAL.build.AbstractConfigurable;
import VASSAL.build.Buildable;
import VASSAL.build.GameModule;
import VASSAL.build.module.documentation.AboutScreen;
import VASSAL.build.module.documentation.BrowserHelpFile;
import VASSAL.build.module.documentation.HelpFile;
import VASSAL.build.module.documentation.Tutorial;
import VASSAL.configure.CompoundValidityChecker;
import VASSAL.configure.Configurer;
import VASSAL.configure.MandatoryComponent;
import VASSAL.configure.SingleChildInstance;
import VASSAL.i18n.Resources;

/**
 * Represents the <code>Help</code> menu of the controls window
 */
public class Documentation extends AbstractConfigurable {
  /** Preferences key for the directory where VASSAL documentation is stored */
  private javax.swing.JMenu controls;

  public Documentation() {
    controls = new javax.swing.JMenu(Resources.getString(Resources.HELP));
  }

  public javax.swing.JMenu getHelpMenu() {
    return controls;
  }

  public void build(Element el) {
    if (el == null) {
      try {
        AboutScreen about = new AboutScreen();
        about.setAttribute(AboutScreen.TITLE, Resources.getString("Documentation.about_vassal")); //$NON-NLS-1$
        about.setAttribute(AboutScreen.FILE, "/images/Splash.png"); //$NON-NLS-1$
        about.addTo(this);
        add(about);
      }
      catch (Exception err) {
        err.printStackTrace();
      }
      HelpFile intro = new HelpFile();
      intro.setAttribute(HelpFile.TITLE, Resources.getString("Documentation.quick_start")); //$NON-NLS-1$
      intro.setAttribute(HelpFile.FILE, "/help/Intro.html"); //$NON-NLS-1$
      intro.setAttribute(HelpFile.TYPE, HelpFile.RESOURCE);
      intro.addTo(this);
      add(intro);
    }
    else {
      super.build(el);
    }
  }

  public static File getDocumentationBaseDir() {
    File dir = new File(Info.getHomeDir(),Info.getMinorVersion());
    return new File(dir,"docs");
  }

  public void addTo(Buildable b) {
    GameModule.getGameModule().getFrame().getJMenuBar().add(controls);
    validator = new SingleChildInstance(GameModule.getGameModule(), getClass());
  }

  public void removeFrom(Buildable b) {
  }

  public String[] getAttributeDescriptions() {
    return new String[0];
  }

  public Class<?>[] getAttributeTypes() {
    return new Class<?>[0];
  }

  public Configurer getConfigurer() {
    return null;
  }

  public Class[] getAllowableConfigureComponents() {
    return new Class[]{
      BrowserHelpFile.class,
{'fraction_non_alphanumeric': 0.10911520190023753, 'fraction_numerical': 0.005047505938242281, 'mean_word_length': 3.9175182481751825, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7475880', 'n_tokens_mistral': 1991, 'n_tokens_neox': 1949, 'n_words': 524}