package edu.drexel.tm.cs338.textacular;

import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.text.JTextComponent;

/**
 * The class ArticlePanel.
 * 
 * Displays inputs for components of a basic article
 *
 * @author Trevor Maglione <tm@cs.drexel.edu>
 */
public class ArticlePanel extends TemplatePanel {
	
	/**
	 * The template name.
	 */
	private static final String TEMPLATE_NAME = "Article";
	
	/**
	 * The template filename.
	 */
	private static final String TEMPLATE_FILENAME = "article.tex";
	
	/**
	 * The title label.
	 */
	private JLabel lblTitle;
	
	/**
	 * The author label.
	 */
	private JLabel lblAuthor;
	
	/**
	 * The date label.
	 */
	private JLabel lblDate;
	
	/**
	 * The content label.
	 */
	private JLabel lblContent;
	
	/**
	 * The title text field.
	 */
	private JTextField txtTitle;
	
	/**
	 * The author text field.
	 */
	private JTextField txtAuthor;
	
	/**
	 * The date text field.
	 */
	private JTextField txtDate;
	
	/**
	 * The content text area.
	 */
	private JTextArea txtContent;
	
	/**
	 * The text components.
	 */
	private JTextComponent[] textComponents;

	/**
	 * Instantiate a new ArticlePanel.
	 */
	public ArticlePanel() {
		super(TEMPLATE_NAME, TEMPLATE_FILENAME);
		
		lblTitle = new JLabel("Title");
		lblAuthor = new JLabel("Author");
		lblDate = new JLabel("Date");
		lblContent = new JLabel("Content");
		
		textComponents = new JTextComponent[] {
				txtTitle = new JTextField(20),
				txtAuthor = new JTextField(20),
				txtDate = new JTextField(20),
				txtContent = new JTextArea(10, 40)
		};
		
		add(lblTitle);
		add(txtTitle, "wrap");
		add(lblAuthor);
		add(txtAuthor, "wrap");
		add(lblDate);
		add(txtDate, "wrap");
		add(lblContent);
		add(new JScrollPane(txtContent), "wrap");
	}

	@Override
	public boolean checkInputs() {
		for (JTextComponent textComponent : textComponents) {
			if (textComponent.getText().length() <= 0) {
				return false;
			}
		}
		
		return true;
	}
	
	@Override
	public void resetInputs() {
		for (JTextComponent textComponent : textComponents) {
			textComponent.setText("");
		}
	}
}

@@ -34,16 +34,47 @@
 cular;%0A%0A
+import javax.swing.JComponent;%0A
 import j
@@ -92,16 +92,16 @@
 JLabel;%0A
-
 import j
@@ -188,48 +188,8 @@
 eld;
-%0Aimport javax.swing.text.JTextComponent;
 %0A%0A/*
@@ -1091,86 +1091,8 @@
 ;%0A%09%0A
-%09/**%0A%09 * The text components.%0A%09 */%0A%09private JTextComponent%5B%5D textComponents;%0A%0A
 %09/**
@@ -1349,28 +1349,20 @@
 );%0A%09%09%0A%09%09
-textComponen
+inpu
 ts = new
@@ -1363,20 +1363,16 @@
  = new J
-Text
 Componen
@@ -1674,16 +1674,16 @@
 ntent);%0A
+
 %09%09add(ne
@@ -1724,338 +1724,7 @@
 ;%0A%09%7D
-%0A%0A%09@Override%0A%09public boolean checkInputs() %7B%0A%09%09for (JTextComponent textComponent : textComponents) %7B%0A%09%09%09if (textComponent.getText().length() %3C= 0) %7B%0A%09%09%09%09return false;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09return true;%0A%09%7D%0A%09%0A%09@Override%0A%09public void resetInputs() %7B%0A%09%09for (JTextComponent textComponent : textComponents) %7B%0A%09%09%09textComponent.setText(%22%22);%0A%09%09%7D%0A%09%7D
 %0A%7D%0A

Remove overridden inputs array and check methods from ArticlePanel