<commit_before>package gov.nih.nci.caadapter.ui.main;

import gov.nih.nci.caadapter.ui.common.DefaultSettings;
import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.HeadlessException;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;


public class VerifyResourceDialog extends JDialog implements ActionListener {
	private String contextFilePath="";
	public static String DEFAULT_CONTEXT_FILE_PATH="/license/hl7-resource-warning.txt";
	private JButton nextButton;

	public VerifyResourceDialog(JFrame owner, String arg0, ArrayList rsrc) throws HeadlessException {
		this(owner, arg0, null, rsrc);
	}

	public VerifyResourceDialog(JFrame owner, String title, String filePath, ArrayList rsrc) throws HeadlessException {
		super(owner, title);
		// TODO Auto-generated constructor stub
		if (filePath==null
				||filePath.equals(""))
			contextFilePath=DEFAULT_CONTEXT_FILE_PATH;
		else
			contextFilePath=filePath;

		setSize(600, 400);
		enableEvents(AWTEvent.WINDOW_EVENT_MASK);
		
		initUI(rsrc);
		this.setResizable(false);
		DefaultSettings.centerWindow(this);
		this.setVisible(true);
	}
	
	public void licenseAccepted(boolean isAccepted)
	{
		if (isAccepted)
		{
			dispose();
		}
		else
		{
			System.exit(-1);
		}
	}
	
	private void initUI(ArrayList list)
	{
		Container contentPane=getContentPane();
		contentPane.setLayout(new BorderLayout());
		contentPane.add(setContextTextPanel(list), BorderLayout.CENTER);
		contentPane.add(setInputPanel(), BorderLayout.SOUTH);	 
	    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	    
	    addWindowListener(new WindowAdapter(){
	        public void windowClosing(WindowEvent we) {
	            Window w = we.getWindow();
	            int answer = JOptionPane.showConfirmDialog(w,
	                "Do you want to close the warning message ?", "caAdapter: Resources Missing", JOptionPane.YES_NO_OPTION);
	                if (answer == JOptionPane.YES_OPTION)
	                    w.dispose();
	            }
	        });
	}
	
	private JPanel setContextTextPanel(ArrayList list)  
	{
		JPanel rtnPanel=new JPanel();
		StringBuffer licenseBf=new StringBuffer();
		String titleMessage="The following resource/library files are not found :\n\n";
		licenseBf.append(titleMessage);
		
		for(String missingFileNme:(ArrayList<String>)list)
			licenseBf.append("\t"+missingFileNme+"\n");
		licenseBf.append("\n\n");
		
		
		try {
			InputStream input=this.getClass().getResourceAsStream(contextFilePath);
			InputStreamReader reader=new InputStreamReader(input);
			BufferedReader bfReader=new BufferedReader(reader);
			String lineSt;
			lineSt = bfReader.readLine();
			while (lineSt!=null)
			{
				licenseBf.append(lineSt+"\n");
				lineSt = bfReader.readLine();
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.exit(0);
		}
		JEditorPane mainView=new JEditorPane();
		mainView.setText(licenseBf.toString());
		JScrollPane js2 = new JScrollPane(mainView);
		js2.setPreferredSize(new Dimension(this.getWidth()-40, getHeight()-60));
        mainView.setEditable(false);
        		 
		rtnPanel.add(js2);
		rtnPanel.setBorder(BorderFactory.createEtchedBorder());
		return rtnPanel;
	}
	
	private JPanel setInputPanel()
	{
		JPanel rtnPanel=new JPanel();
		rtnPanel.setLayout(new BorderLayout());
		rtnPanel.add(setCommandButtonPanel());
		rtnPanel.setBorder(BorderFactory.createRaisedBevelBorder());//.createEmptyBorder(10, 10, 10, 10));
		return rtnPanel;
	}

	private JPanel setCommandButtonPanel()
	{
		JPanel rtnPanel=new JPanel();
		nextButton=new JButton("Next>");
		nextButton.addActionListener(this);
		JButton cancelButton=new JButton("Cancel");
		cancelButton.addActionListener(this);
		rtnPanel.add(nextButton);
		rtnPanel.add(cancelButton);
		return rtnPanel;
	}

	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		Object evtObj=arg0.getSource();
		if (evtObj instanceof JButton)
		{
			JButton evtButton=(JButton)evtObj;
			if (evtButton==nextButton)
			{
				//launch caAdapter 
//				String msg="caAdapter will not work properly because of the missed resources, \ncontinue ?";
//				
//				int yesNo=JOptionPane.showConfirmDialog(this, 
//						msg,
//						"Resources Missing",
//						JOptionPane.YES_OPTION);
//				if (yesNo==JOptionPane.YES_OPTION)
					licenseAccepted(true);
//				else
//					return;
			}
			else
			{
				System.out.println("AcceptLicenseFrame.actionPerformed()..action source:"+evtButton);
				licenseAccepted(false);
			}
			dispose();
		}
	}

}
<commit_msg>read waring message from warning directory<commit_after>package gov.nih.nci.caadapter.ui.main;

import gov.nih.nci.caadapter.ui.common.DefaultSettings;
import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.HeadlessException;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;


public class VerifyResourceDialog extends JDialog implements ActionListener {
	private String contextFilePath="";
	public static String DEFAULT_CONTEXT_FILE_PATH="/warning/hl7-resource-warning.txt";
	private JButton nextButton;

	public VerifyResourceDialog(JFrame owner, String arg0, ArrayList rsrc) throws HeadlessException {
		this(owner, arg0, null, rsrc);
	}

	public VerifyResourceDialog(JFrame owner, String title, String filePath, ArrayList rsrc) throws HeadlessException {
		super(owner, title);
		// TODO Auto-generated constructor stub
		if (filePath==null
				||filePath.equals(""))
			contextFilePath=DEFAULT_CONTEXT_FILE_PATH;
		else
			contextFilePath=filePath;

		setSize(600, 400);
		enableEvents(AWTEvent.WINDOW_EVENT_MASK);
		
		initUI(rsrc);
		this.setResizable(false);
		DefaultSettings.centerWindow(this);
		this.setVisible(true);
	}
	
	public void licenseAccepted(boolean isAccepted)
	{
		if (isAccepted)
		{
			dispose();
		}
		else
		{
			System.exit(-1);
		}
	}
	
	private void initUI(ArrayList list)
	{
		Container contentPane=getContentPane();
		contentPane.setLayout(new BorderLayout());
		contentPane.add(setContextTextPanel(list), BorderLayout.CENTER);
		contentPane.add(setInputPanel(), BorderLayout.SOUTH);	 
	    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	    
	    addWindowListener(new WindowAdapter(){
	        public void windowClosing(WindowEvent we) {
	            Window w = we.getWindow();
	            int answer = JOptionPane.showConfirmDialog(w,
	                "Do you want to close the warning message ?", "caAdapter: Resources Missing", JOptionPane.YES_NO_OPTION);
	                if (answer == JOptionPane.YES_OPTION)
	                    w.dispose();
	            }
	        });
	}
	
	private JPanel setContextTextPanel(ArrayList list)  
	{
		JPanel rtnPanel=new JPanel();
		StringBuffer licenseBf=new StringBuffer();
		String titleMessage="The following resource/library files are not found :\n\n";
		licenseBf.append(titleMessage);
		
		for(String missingFileNme:(ArrayList<String>)list)
			licenseBf.append("\t"+missingFileNme+"\n");
		licenseBf.append("\n\n");
		
		
		try {
			InputStream input=this.getClass().getResourceAsStream(contextFilePath);
			InputStreamReader reader=new InputStreamReader(input);
			BufferedReader bfReader=new BufferedReader(reader);
			String lineSt;
			lineSt = bfReader.readLine();
			while (lineSt!=null)
			{
				licenseBf.append(lineSt+"\n");
				lineSt = bfReader.readLine();
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.exit(0);
		}
		JEditorPane mainView=new JEditorPane();
		mainView.setText(licenseBf.toString());
		JScrollPane js2 = new JScrollPane(mainView);
		js2.setPreferredSize(new Dimension(this.getWidth()-40, getHeight()-60));
        mainView.setEditable(false);
        		 
		rtnPanel.add(js2);
		rtnPanel.setBorder(BorderFactory.createEtchedBorder());
		return rtnPanel;
	}
	
	private JPanel setInputPanel()
	{
		JPanel rtnPanel=new JPanel();
		rtnPanel.setLayout(new BorderLayout());
		rtnPanel.add(setCommandButtonPanel());
		rtnPanel.setBorder(BorderFactory.createRaisedBevelBorder());//.createEmptyBorder(10, 10, 10, 10));
		return rtnPanel;
	}

	private JPanel setCommandButtonPanel()
	{
		JPanel rtnPanel=new JPanel();
		nextButton=new JButton("Next>");
		nextButton.addActionListener(this);
		JButton cancelButton=new JButton("Cancel");
		cancelButton.addActionListener(this);
		rtnPanel.add(nextButton);
		rtnPanel.add(cancelButton);
		return rtnPanel;
	}

	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		Object evtObj=arg0.getSource();
		if (evtObj instanceof JButton)
		{
			JButton evtButton=(JButton)evtObj;
			if (evtButton==nextButton)
			{
				//launch caAdapter 
//				String msg="caAdapter will not work properly because of the missed resources, \ncontinue ?";
//				
//				int yesNo=JOptionPane.showConfirmDialog(this, 
//						msg,
//						"Resources Missing",
//						JOptionPane.YES_OPTION);
//				if (yesNo==JOptionPane.YES_OPTION)
					licenseAccepted(true);
//				else
//					return;
			}
			else
			{
				System.out.println("AcceptLicenseFrame.actionPerformed()..action source:"+evtButton);
				licenseAccepted(false);
			}
			dispose();
		}
	}

}

{'fraction_non_alphanumeric': 0.11408546675751971, 'fraction_numerical': 0.005451182711963399, 'mean_word_length': 4.225839267548322, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '424470', 'n_tokens_mistral': 3645, 'n_tokens_neox': 3234, 'n_words': 619}