commit fdb3b2f7d0a16d2cf17507e7d733992d981aaeaf
Author: Marek Sobota <sobotama@students.zcu.cz>
Date:   Fri Apr 26 11:13:27 2019 +0200

    Minimalni rozmery + cesta vystupniho souboru (Re #7318)

diff --git a/src/gui/Window.java b/src/gui/Window.java
index eb20903..29c16f2 100644
--- a/src/gui/Window.java
+++ b/src/gui/Window.java
@@ -1,6 +1,7 @@
 package gui;
 
 import java.awt.BorderLayout;
+import java.awt.Dimension;
 import java.awt.FlowLayout;
 import java.awt.GridLayout;
 import java.awt.event.ActionEvent;
@@ -38,21 +39,27 @@ import org.jdatepicker.impl.UtilDateModel;
  *
  */
 public class Window extends JFrame{
-
+	
 	/**zakladni verze serializace*/
 	private static final long serialVersionUID = 1L;
 	
+	/**Minimalni rozmer vypisoveho okna*/
+	private static final Dimension OUTPUT_WINDOW_MIN_DIM = new Dimension(320, 160);
+	
 	/**konstanta pro oznaceni souboru se spoji*/
 	private static final int SPOJ_FILE = 0;
 	
 	/**konstanta pro oznaceni slozky JDF*/
 	private static final int JDF_DIR = 1;
 	
+	/**konstanta pro oznaceni slozky pro vystup*/
+	private static final int OUTPUT_DIR = 2;
+	
 	/**konstanta pro oznaceni dialogu pro vyber zacinajiciho data*/
-	private static final int DATE_PICKER_FROM = 2;
+	private static final int DATE_PICKER_FROM = 3;
 	
 	/**konstanta pro oznaceni dialogu pro vyber konciciho data*/
-	private static final int DATE_PICKER_TO = 3;
+	private static final int DATE_PICKER_TO = 4;
 	
 	/**spolecna delka pro vsechny {@code JTextField}*/
 	private static final int TEXT_FIELD_LENGTH = 15;
@@ -78,6 +85,9 @@ public class Window extends JFrame{
 	/**atribut se slozkou JDF*/
 	private File jdfDir = null;
 	
+	/**soubor, do ktereho se zapise vystup programu*/
+	private File outputFile = null;;
+	
 	/**den zacatku obdobi*/
 	private Calendar dateFrom = null;
 	
@@ -108,12 +118,19 @@ public class Window extends JFrame{
 	/**TextField pro zobrazeni cesty k slozce JDF*/
 	private JTextField jdfPathTF;
 	
+	/**TextField pro zobrazeni cesty ke slozce s vystupnim souborem*/
+	private JTextField outputPathTF;
+	
+	/**TextField pro zadani nazvu vystupniho souboru*/
+	private JTextField outputNameTF;
+	
 	/**TextArea pro výpis informací o běhu programu*/
 	private JTextArea infoTA;
 
 	/**ScrollPane pro obaleni infoTA*/
 	private JScrollPane scrollPane;
 	
+	
 	/**
 	 * inicializuje okno, jmenovite jeho panely, komponenty, priradi potrebne listenery a prida je do zobrazeni
 	 */
@@ -128,11 +145,13 @@ public class Window extends JFrame{
 		JPanel dateToP = new JPanel();
 		JPanel spojPathP = new JPanel();
 		JPanel jdfPathP = new JPanel();
-		inputP.setLayout(new GridLayout(4, 1));
+		JPanel outputP = new JPanel();
+		inputP.setLayout(new GridLayout(5, 1));
 		dateFromP.setLayout(new FlowLayout());
 		dateToP.setLayout(new FlowLayout());
 		spojPathP.setLayout(new FlowLayout());
 		jdfPathP.setLayout(new FlowLayout());
+		outputP.setLayout(new FlowLayout());
 		
 		//inicializace kompoment
 		JLabel povedLB = new JLabel("POVED", JLabel.CENTER);
@@ -140,12 +159,16 @@ public class Window extends JFrame{
 		JLabel dateToLB = new JLabel ("Obdobi do: ");
 		JLabel spojPathLB = new JLabel("Spoje: ");
 		JLabel jdfPathLB = new JLabel("JDF: ");
+		JLabel outputLB = new JLabel("Vystup: ");
 		confirmBT = new JButton("Potvrdit");
 		endBT = new JButton("Ukoncit");
 		JButton spojBT = new JButton("Vybrat spoj soubor");
 		JButton jdfBT = new JButton("Vybrat JDF slozku");
+		JButton outputBT = new JButton("Vybrat vystupni slozku");
 		spojPathTF = new JTextField(TEXT_FIELD_LENGTH);
 		jdfPathTF = new JTextField(TEXT_FIELD_LENGTH);
+		outputPathTF = new JTextField(TEXT_FIELD_LENGTH);
+		outputNameTF = new JTextField(TEXT_FIELD_LENGTH);
 		fileChooser = new JFileChooser();
 		infoTA = new JTextArea();
 		scrollPane = new JScrollPane(infoTA);
@@ -154,6 +177,8 @@ public class Window extends JFrame{
 		//nastaveni komponent
 		spojPathTF.setEditable(false);
 		jdfPathTF.setEditable(false);
+		outputPathTF.setEditable(false);
+		outputNameTF.setText("Nazev souboru");
 		infoTA.setEditable(false);
 		fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
 		
@@ -174,15 +199,17 @@ public class Window extends JFrame{
 		});
 		spojBT.addActionListener(new FileChooserListener(SPOJ_FILE));
 		jdfBT.addActionListener(new FileChooserListener(JDF_DIR));
+		outputBT.addActionListener(new FileChooserListener(OUTPUT_DIR));
 		
 		//pridani komponent do panelu
 		inputP.add(dateFromP);
 		inputP.add(dateToP);
 		inputP.add(spojPathP);
 		inputP.add(jdfPathP);
+		inputP.add(outputP);
 		dateFromP.add(dateFromLB);
 		dateFromP.add(datePickerFrom);
-		dateToP.add(dateToLB);
+		dateToP.add(dateToLB);	
 		dateToP.add(datePickerTo);
 		spojPathP.add(spojPathLB);
 		spojPathP.add(spojPathTF);
@@ -190,6 +217,10 @@ public class Window extends JFrame{
 		jdfPathP.add(jdfPathLB);
 		jdfPathP.add(jdfPathTF);
 		jdfPathP.add(jdfBT);
+		outputP.add(outputLB);
+		outputP.add(outputNameTF);
+		outputP.add(outputPathTF);
+		outputP.add(outputBT);
 		
 		//pridani panelu do okna
 		this.add(povedLB, BorderLayout.NORTH);
@@ -197,7 +228,7 @@ public class Window extends JFrame{
 		this.add(confirmBT, BorderLayout.SOUTH);
 			
 		this.pack();
-		
+		this.setMinimumSize(this.getSize());
 	}
 	
 	/**
@@ -231,8 +262,10 @@ public class Window extends JFrame{
 		this.remove(inputP);
 		this.remove(confirmBT);
 		
+		this.setMinimumSize(OUTPUT_WINDOW_MIN_DIM);
 		this.add(scrollPane, BorderLayout.CENTER);
 		this.add(endBT, BorderLayout.SOUTH);
+		
 		this.revalidate();
 	}
 	
@@ -265,8 +298,8 @@ public class Window extends JFrame{
 		 */
 		public void actionPerformed(ActionEvent arg0) {
 			//kontrola jestli jsou obdobi zadana a ve spravnem poradi a jestli jsou cesty vyplněny
-			if(spojFile == null || jdfDir == null){
-				JOptionPane.showMessageDialog(null, "Nejsou vybrany potrebne soubory", 
+			if(spojFile == null || jdfDir == null || outputFile == null){
+				JOptionPane.showMessageDialog(null, "Nejsou vybrany potrebne soubory/slozky", 
 						"Varovani", JOptionPane.WARNING_MESSAGE);
 				return;
 			}
@@ -280,7 +313,17 @@ public class Window extends JFrame{
 						"Varovani", JOptionPane.WARNING_MESSAGE);
 				return;
 			}
+			String outputName = outputNameTF.getText();
+			if(outputName.length() < 1){
+				JOptionPane.showMessageDialog(null, "Nezadano jmeno vystupniho souboru", 
+						"Varovani", JOptionPane.WARNING_MESSAGE);
+				return;
+			}
 			
+			if(!outputName.endsWith(".txt")){
+				outputName += ".txt";
+			}
+			//outputFile = new File(outputFile.getAbsolutePath() + File.separator + outputName);
 			changeToInfo();
 		}
 		
@@ -354,6 +397,10 @@ public class Window extends JFrame{
 					jdfDir = selectedFile;
 					jdfPathTF.setText(jdfDir.getAbsolutePath());
 				}
+				else if (selectedFile.isDirectory() && fileType == OUTPUT_DIR){
+					outputFile = new File(selectedFile.getAbsolutePath());
+					outputPathTF.setText(outputFile.getAbsolutePath());
+				}
 				else{
 					JOptionPane.showMessageDialog(null, "Vybran nespravny typ souboru", 
 												"Varovani", JOptionPane.WARNING_MESSAGE);
