<commit_before>package org.atdl4j.ui.swing.app.impl;

import java.awt.BorderLayout;
import java.awt.Window;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.border.TitledBorder;

import org.atdl4j.config.Atdl4jOptions;
import org.atdl4j.ui.app.impl.AbstractStrategyDescriptionPanel;

/**
 * Represents the Swing-specific Strategy Description GUI component.
 * 
 * @author <NAME>
 * @version October 5, 2010
 */
public class SwingStrategyDescriptionPanel 
	extends AbstractStrategyDescriptionPanel
{	
// JPanel as we need TitledBorder	private Container container;
	private JPanel container;
	private JTextArea strategyDescription;

	private int DEFAULT_STRATEGY_DESCRIPTION_ROWS = 4;

	public Object buildStrategyDescriptionPanel(Object parentOrShell, Atdl4jOptions atdl4jOptions)
	{
		return buildStrategyDescriptionPanel( (Window) parentOrShell, atdl4jOptions );
	}
	
	public JPanel buildStrategyDescriptionPanel(Window aParentContainer, Atdl4jOptions atdl4jOptions)
	{
		setAtdl4jOptions( atdl4jOptions );
	
		container = new JPanel(new BorderLayout());
		container.setBorder( new TitledBorder( "Strategy Description" ) );
		
 		strategyDescription = new JTextArea( DEFAULT_STRATEGY_DESCRIPTION_ROWS, 1);
 		strategyDescription.setLineWrap( true );
 		strategyDescription.setWrapStyleWord( true );
 		strategyDescription.setEditable( false );
 		strategyDescription.setFont(new JLabel().getFont());
  		
		JScrollPane tempScrollPane = new JScrollPane( strategyDescription );
		container.add( tempScrollPane, BorderLayout.CENTER );
	
		return container;
	}


	/* (non-Javadoc)
	 * @see org.atdl4j.ui.app.AbstractStrategyDescriptionPanel#setStrategyDescriptionText(java.lang.String)
	 */
	protected void setStrategyDescriptionText(String aText)
	{
		if ( strategyDescription != null )
		{
			strategyDescription.setText( aText );
			
			// Scroll to the top of the scroll pane
			strategyDescription.setSelectionStart(0);
			strategyDescription.setSelectionEnd(0);
		}
	}

	/* (non-Javadoc)
	 * @see org.atdl4j.ui.app.StrategyDescriptionPanel#setVisible(boolean)
	 */
	@Override
	public void setVisible(boolean aVisible)
	{
		if ( container != null )
		{
			container.setVisible( aVisible );
		}
	}
}<commit_msg>- Allow HTML content in the Strategy description panel. - Specifically support &apos; character.<commit_after>package org.atdl4j.ui.swing.app.impl;

import java.awt.BorderLayout;
import java.awt.Window;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.border.TitledBorder;

import org.atdl4j.config.Atdl4jOptions;
import org.atdl4j.ui.app.impl.AbstractStrategyDescriptionPanel;

/**
 * Represents the Swing-specific Strategy Description GUI component.
 * @author <NAME>
 * @version October 5, 2010
 */
public class SwingStrategyDescriptionPanel
    extends AbstractStrategyDescriptionPanel
{
  // JPanel as we need TitledBorder private Container container;
  private JPanel container;

  private JTextPane strategyDescription;

  public Object buildStrategyDescriptionPanel(Object parentOrShell,
                                              Atdl4jOptions atdl4jOptions)
  {
    return buildStrategyDescriptionPanel((Window) parentOrShell, atdl4jOptions);
  }

  public JPanel buildStrategyDescriptionPanel(Window aParentContainer,
                                              Atdl4jOptions atdl4jOptions)
  {
    setAtdl4jOptions(atdl4jOptions);

    container = new JPanel(new BorderLayout());
    container.setBorder(new TitledBorder("Strategy Description"));

    strategyDescription = new JTextPane();
    strategyDescription.setContentType("text/html");
    strategyDescription.setFont(new JLabel().getFont());
    strategyDescription.setEditable(false);
    strategyDescription.setFont(new JLabel().getFont());

    JScrollPane tempScrollPane = new JScrollPane(strategyDescription);
    container.add(tempScrollPane, BorderLayout.CENTER);

    return container;
  }

  /*
   * (non-Javadoc)
   * @see
   * org.atdl4j.ui.app.AbstractStrategyDescriptionPanel#setStrategyDescriptionText
   * (java.lang.String)
   */
  protected void setStrategyDescriptionText(String aText) {
    if (strategyDescription != null) {
      String newText = aText.replaceAll("&apos;", "&#39;");
      String htmlText = "<html>" + newText + "</html>";
      strategyDescription.setText(htmlText);
      strategyDescription.setSelectionStart(0);
      strategyDescription.setSelectionEnd(0);
    }
  }

  /*
   * (non-Javadoc)
   * @see org.atdl4j.ui.app.StrategyDescriptionPanel#setVisible(boolean)
   */
  @Override
  public void setVisible(boolean aVisible) {
    if (container != null) {
      container.setVisible(aVisible);
    }
  }
}
{'fraction_non_alphanumeric': 0.09519850342964041, 'fraction_numerical': 0.00914570775306589, 'mean_word_length': 4.4006734006734005, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7490382', 'n_tokens_mistral': 1489, 'n_tokens_neox': 1408, 'n_words': 282}