package rapanui.ui;

import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;

public class ConclusionProcessView extends JPanel {
	private static final long serialVersionUID = 1L;

	public ConclusionProcessView(/* ConclusionProcess conclusion */) {
		initializeContent();
	}

	private void initializeContent() {
		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		setOpaque(false);
		setBorder(new CompoundBorder(new EmptyBorder(5,0,5,0),
				new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(5,5,5,5))));

		String shortForm = "R = S;T"; // TODO: remove dummy data

		JPanel header = new JPanel();
		header.setBackground(Color.WHITE);
		header.setLayout(new BoxLayout(header, BoxLayout.X_AXIS));

		JPanel longForm = new JPanel(new GridBagLayout());
		longForm.setOpaque(false);

		JSeparator separator = new JSeparator();

		header.add(new CollapseButton(longForm, separator));
		header.add(new JLabel(shortForm));
		header.add(Box.createHorizontalGlue());
		header.add(new SimpleLink("\u2B06", "Nach oben"));
		header.add(new SimpleLink("\u2B07", "Nach unten"));
		header.add(new SimpleLink("\u27F2", "Letzter Schritt rückgängig"));
		header.add(new SimpleLink("\u2718", "Folgerung entfernen"));

		GridBagConstraints constraints = new GridBagConstraints();
		constraints.fill = GridBagConstraints.HORIZONTAL;

		constraints.gridx = 0;
		constraints.gridy = 0;
		longForm.add(ProofEnvironmentPanel.createMathematicalLabel("R ")); // TODO: remove dummy data

		// TODO: remove dummy data
		String[] steps = new String[] { "= R;I", "= R;(S;T)", "= (R;S);T", "= S;T"};
		String[] reasons = new String[] { "Neutralität von I", "nach Voraussetzung", "Assoziativität", "nach Voraussetzung" };

		for (int i = 0; i < steps.length; ++i) {
			constraints.gridx = 1;
			longForm.add(ProofEnvironmentPanel.createMathematicalLabel(steps[i]), constraints);
			constraints.gridx = 2;
			longForm.add(new JLabel("(" + reasons[i] + ")"), constraints);

			constraints.gridy++;
		}

		add(header);
		add(separator);
		add(longForm);
	}
}

@@ -756,27 +756,8 @@
 nel(
-new GridBagLayout()
 );%0A%09
@@ -1210,265 +1210,1007 @@
 %0A%0A%09%09
-GridBagConstraints constraints = new GridBagConstraints(
+JLabel initialTerm = ProofEnvironmentPanel.createMathematicalLabel(%22R %22);%0A%09%09initialTerm.setVerticalAlignment(SwingConstants.TOP);%0A%09%09initialTerm.setHorizontalAlignment(SwingConstants.RIGHT
 );%0A%09%09
-constraints.fill = GridBagConstraints.HORIZONTAL
+longForm.add(initialTerm); // TODO: remove dummy data%0A%0A%09%09JPanel secondColumn = new JPanel();%0A%09%09secondColumn.setLayout(new BoxLayout(secondColumn, BoxLayout.Y_AXIS))
 ;%0A
-%0A
 %09%09
+se
 con
-straints.gridx = 0;%0A%09%09constraints.gridy = 0;%0A%09%09longForm.add(ProofEnvironmentPanel.createMathematicalLabel(%22R %22)); // TODO: remove dummy data
+dColumn.setOpaque(false);%0A%09%09longForm.add(secondColumn);%0A%0A%09%09JPanel thirdColumn = new JPanel();%0A%09%09thirdColumn.setLayout(new BoxLayout(thirdColumn, BoxLayout.Y_AXIS));%0A%09%09thirdColumn.setOpaque(false);%0A%09%09longForm.add(thirdColumn);%0A%0A%09%09initialTerm.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));%0A%09%09secondColumn.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));%0A%09%09thirdColumn.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));%0A%0A%09%09initialTerm.setBorder(new LineBorder(Color.red));%0A%09%09secondColumn.setBorder(new LineBorder(Color.red));%0A%09%09thirdColumn.setBorder(new LineBorder(Color.red));
 %0A%0A%09%09
@@ -2487,42 +2487,20 @@
 %0A%09%09%09
+se
 con
-straints.gridx = 1;%0A%09%09%09longForm
+dColumn
 .add
@@ -2559,139 +2559,65 @@
 %5Bi%5D)
-, constraints);%0A%09%09%09constraints.gridx = 2;%0A%09%09%09longForm.add(new JLabel(%22(%22 + reasons%5Bi%5D + %22)%22), constraints);%0A%0A%09%09%09constraints.gridy++
+);%0A%09%09%09thirdColumn.add(new JLabel(%22(%22 + reasons%5Bi%5D + %22)%22))
 ;%0A%09%09

work on ConclusionProcessView layout