author | František Kučera <franta-hg@frantovo.cz> |
Wed Dec 15 23:29:14 2010 +0100 (2010-12-15) | |
changeset 10 | ed2b6ebf138d |
parent 7 | 48d5fdb68798 |
child 11 | 9b399cde6a3b |
permissions | -rw-r--r-- |
franta-hg@4 | 1 |
package cz.frantovo.rozsireneAtributy; |
franta-hg@4 | 2 |
|
franta-hg@6 | 3 |
import cz.frantovo.rozsireneAtributy.gui.Panel; |
franta-hg@6 | 4 |
import java.awt.BorderLayout; |
franta-hg@6 | 5 |
import java.io.File; |
franta-hg@6 | 6 |
import java.io.IOException; |
franta-hg@6 | 7 |
import java.util.logging.Level; |
franta-hg@6 | 8 |
import java.util.logging.Logger; |
franta-hg@6 | 9 |
import javax.swing.JFrame; |
franta-hg@7 | 10 |
import javax.swing.JOptionPane; |
franta-hg@6 | 11 |
|
franta-hg@4 | 12 |
/** |
franta-hg@4 | 13 |
* Spouštěč programu |
franta-hg@6 | 14 |
* |
franta-hg@6 | 15 |
* http://freedesktop.org/wiki/CommonExtendedAttributes |
franta-hg@6 | 16 |
* http://download.oracle.com/javase/tutorial/essential/io/fileAttr.html#user |
franta-hg@6 | 17 |
* http://today.java.net/pub/a/today/2008/07/03/jsr-203-new-file-apis.html#so-what-is-a-path-really |
franta-hg@6 | 18 |
* |
franta-hg@6 | 19 |
* $ setfattr -n "user.fiki.pozdrav" -v 'Dobrý den!' pokus.txt |
franta-hg@6 | 20 |
* (v javě pak pracujeme s klíči bez předpony „user.“) |
franta-hg@6 | 21 |
* |
franta-hg@4 | 22 |
* @author fiki |
franta-hg@4 | 23 |
*/ |
franta-hg@5 | 24 |
public class Startér { |
franta-hg@4 | 25 |
|
franta-hg@6 | 26 |
private static final Logger log = Logger.getLogger(Startér.class.getSimpleName()); |
franta-hg@6 | 27 |
|
franta-hg@8 | 28 |
/** |
franta-hg@8 | 29 |
* @param args název souboru |
franta-hg@8 | 30 |
* @throws IOException TODO: ošetřit výjimku |
franta-hg@8 | 31 |
*/ |
franta-hg@6 | 32 |
public static void main(String[] args) throws IOException { |
franta-hg@6 | 33 |
|
franta-hg@7 | 34 |
if (args.length == 1 && args[0].length() > 0) { |
franta-hg@6 | 35 |
File soubor = new File(args[0]); |
franta-hg@6 | 36 |
|
franta-hg@7 | 37 |
if (soubor.exists()) { |
franta-hg@7 | 38 |
log.log(Level.INFO, "Pracuji se souborem: {0}", soubor); |
franta-hg@6 | 39 |
|
franta-hg@7 | 40 |
Model model = new Model(soubor); |
franta-hg@6 | 41 |
|
franta-hg@7 | 42 |
JFrame f = new JFrame(); |
franta-hg@7 | 43 |
Panel p = new Panel(model); |
franta-hg@6 | 44 |
|
franta-hg@7 | 45 |
f.setLayout(new BorderLayout()); |
franta-hg@7 | 46 |
f.add(p, BorderLayout.CENTER); |
franta-hg@6 | 47 |
|
franta-hg@8 | 48 |
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
franta-hg@8 | 49 |
f.setTitle("Rozšířené stributy souboru: " + soubor); |
franta-hg@7 | 50 |
f.setSize(640, 240); |
franta-hg@7 | 51 |
f.setLocationRelativeTo(null); |
franta-hg@7 | 52 |
f.setVisible(true); |
franta-hg@7 | 53 |
} else { |
franta-hg@7 | 54 |
ukončiChybou("Soubor neexistuje: " + soubor); |
franta-hg@7 | 55 |
} |
franta-hg@6 | 56 |
} else { |
franta-hg@7 | 57 |
ukončiChybou("Očekávám právě jeden parametr – název souboru."); |
franta-hg@6 | 58 |
} |
franta-hg@4 | 59 |
} |
franta-hg@7 | 60 |
|
franta-hg@7 | 61 |
private static void ukončiChybou(String hláška) { |
franta-hg@7 | 62 |
log.log(Level.SEVERE, hláška); |
franta-hg@7 | 63 |
JOptionPane.showMessageDialog(null, hláška, "Chyba", JOptionPane.ERROR_MESSAGE); |
franta-hg@7 | 64 |
System.exit(1); |
franta-hg@7 | 65 |
} |
franta-hg@4 | 66 |
} |