package icum.icumGui;


import icum.TAD.*;
import icum.consola.clsCmdExec;


import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JEditorPane;

import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.WindowConstants;



/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class icumGui03 extends JFrame {
	private JPanel jPanel1;
	private JPanel jPanel3;
	private JPanel jPanel2;
	private JPanel jPanel4;
	
	private JScrollPane jScrollPane1;
	
	private JRadioButton[] jRadioButton;
	private JButton jButton1;
	private JCheckBox jCheckBox[][];
	private JPanel[] jPanel;

	public icumGui03(){
		initGUI();
	
		
	}
	
	public icumGui03(icumTAD datos){
		this();
		ButtonGroup group = new ButtonGroup();
		jRadioButton=new JRadioButton[datos.size()];
		jPanel = new JPanel[datos.size()];
		jCheckBox = new JCheckBox[datos.size()][];
		
		for(int i=0;i<datos.size();i++){
			
			jRadioButton[i] = new JRadioButton();
			
		    ActionListener sliceActionListener = new ActionListener() {
		        public void actionPerformed(ActionEvent actionEvent) {
		        	JRadioButton aButton = (JRadioButton) actionEvent.getSource();
		        	for(int in=0;in<jPanel.length;in++){
		        		if(aButton.getText().compareTo(jRadioButton[in].getText())==0){
			        		jPanel[in].setVisible(true);
		        		}
		        		else{
			        		jPanel[in].setVisible(false);
		        		}
		        	}
		        }
		      };
		    jRadioButton[i].addActionListener(sliceActionListener);
			jPanel4.add(jRadioButton[i]);
			jRadioButton[i].setText(datos.getCarrera(i).getNombre());
			jRadioButton[i].setBounds(5, 12+20*i, 200, 18);
			group.add(jRadioButton[i]);
			
			jPanel[i] = new JPanel();
			jPanel3.add(jPanel[i]);
			jPanel[i].setLayout(null);
			jPanel[i].setBounds(5, 19, 183, 184);
			jPanel[i].setVisible(false);
			jCheckBox[i] = new JCheckBox[datos.getCarrera(i).size()];
			
			for(int j=0;j<datos.getCarrera(i).size();j++)
			{
				jCheckBox[i][j]=new JCheckBox();
				jPanel[i].add(jCheckBox[i][j]);
				jCheckBox[i][j].setText(datos.getCarrera(i).getSoft(j).getNombre());
				jCheckBox[i][j].setBounds(5, 12+20*j, 200, 18);
				
			}

		}
		
	}
	
	private void initGUI() {
		try {

			setPreferredSize(new java.awt.Dimension(441, 322));
			setMinimumSize(new java.awt.Dimension(441, 322));
			this.setTitle("ICUM");
			this.setResizable(false);
			this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

			jPanel1 = new JPanel();
			getContentPane().add(jPanel1, BorderLayout.CENTER);
			jPanel1.setLayout(null);
			jPanel1.setPreferredSize(new java.awt.Dimension(375, 208));

			jPanel2 = new JPanel();
			jPanel1.add(jPanel2);
			jPanel2.setLayout(null);
			jPanel2.setBounds(0, 0, 182, 208);
			jPanel2.setBorder(BorderFactory.createTitledBorder("Carrera"));

			jPanel4 = new JPanel();
			jPanel4.setLayout(null);
			// jPanel4.setBounds(0, 0, 300, 300);
			// jPanel4.setBorder(BorderFactory.createTitledBorder("Ca"));
			jPanel4.setPreferredSize(new java.awt.Dimension(167, 304));

			jScrollPane1 = new JScrollPane(jPanel4);
			jPanel2.add(jScrollPane1);
			jScrollPane1.setBounds(6, 15, 170, 185);

			jPanel3 = new JPanel();
			jPanel1.add(jPanel3);
			jPanel3.setLayout(null);
			jPanel3.setBounds(182, 0, 193, 208);
			jPanel3.setBorder(BorderFactory.createTitledBorder("Software"));
			{
				jButton1 = new JButton();
				jPanel1.add(jButton1);
				jButton1.setText("Instalar");
				jButton1.setBounds(275, 247, 129, 21);
				jButton1.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						jButton1ActionPerformed(evt);
					}
				});
			}

			setSize(441, 322);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}


	private void jButton1ActionPerformed(ActionEvent evt) {
		
		clsCmdExec consola=new clsCmdExec();
		consola.ejecutar("dir *.*");
		System.out.println(consola.ultimaSalida());
	}

}
