java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/Startér.java
changeset 6 734f104f2869
parent 5 8171c6c30613
child 7 48d5fdb68798
     1.1 --- a/java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/Startér.java	Wed Dec 15 19:18:08 2010 +0100
     1.2 +++ b/java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/Startér.java	Wed Dec 15 20:07:14 2010 +0100
     1.3 @@ -1,13 +1,52 @@
     1.4  package cz.frantovo.rozsireneAtributy;
     1.5  
     1.6 +import cz.frantovo.rozsireneAtributy.gui.Panel;
     1.7 +import java.awt.BorderLayout;
     1.8 +import java.io.File;
     1.9 +import java.io.IOException;
    1.10 +import java.util.logging.Level;
    1.11 +import java.util.logging.Logger;
    1.12 +import javax.swing.JFrame;
    1.13 +
    1.14  /**
    1.15   * Spouštěč programu
    1.16 + *
    1.17 + * http://freedesktop.org/wiki/CommonExtendedAttributes
    1.18 + * http://download.oracle.com/javase/tutorial/essential/io/fileAttr.html#user
    1.19 + * http://today.java.net/pub/a/today/2008/07/03/jsr-203-new-file-apis.html#so-what-is-a-path-really
    1.20 + *
    1.21 + * $ setfattr -n "user.fiki.pozdrav" -v 'Dobrý den!' pokus.txt
    1.22 + * (v javě pak pracujeme s klíči bez předpony „user.“)
    1.23 + *
    1.24   * @author fiki
    1.25   */
    1.26  public class Startér {
    1.27  
    1.28 -	public static void main(String[] args) {
    1.29 -		System.err.println("ještě není implementované…");
    1.30 -		System.exit(1);
    1.31 +	private static final Logger log = Logger.getLogger(Startér.class.getSimpleName());
    1.32 +
    1.33 +	public static void main(String[] args) throws IOException {
    1.34 +
    1.35 +		if (args.length == 1) {
    1.36 +			File soubor = new File(args[0]);
    1.37 +
    1.38 +			log.log(Level.INFO, "Pracuji se souborem: {0}", soubor);
    1.39 +
    1.40 +			Model model = new Model(soubor);
    1.41 +
    1.42 +			JFrame f = new JFrame();
    1.43 +			Panel p = new Panel(model);
    1.44 +
    1.45 +			f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    1.46 +			f.setTitle("Rozšířené stributy souboru: " + soubor);
    1.47 +			f.setLayout(new BorderLayout());
    1.48 +			f.add(p, BorderLayout.CENTER);
    1.49 +
    1.50 +			f.setSize(640, 240);
    1.51 +			f.setLocationRelativeTo(null);
    1.52 +			f.setVisible(true);
    1.53 +		} else {
    1.54 +			log.log(Level.SEVERE, "Chyba: Očekávám právě jeden parametr – název souboru.");
    1.55 +			System.exit(1);
    1.56 +		}
    1.57  	}
    1.58  }