Přesun TableModelu do GUI balíčku.
1 package cz.frantovo.rozsireneAtributy;
3 import cz.frantovo.rozsireneAtributy.gui.Model;
4 import cz.frantovo.rozsireneAtributy.gui.Panel;
5 import java.awt.BorderLayout;
6 import java.awt.event.ActionEvent;
7 import java.awt.event.ActionListener;
8 import java.awt.event.KeyEvent;
10 import java.io.IOException;
11 import java.util.logging.Level;
12 import java.util.logging.Logger;
13 import javax.swing.JComponent;
14 import javax.swing.JFrame;
15 import javax.swing.JOptionPane;
16 import javax.swing.KeyStroke;
21 * http://freedesktop.org/wiki/CommonExtendedAttributes
22 * http://download.oracle.com/javase/tutorial/essential/io/fileAttr.html#user
23 * http://today.java.net/pub/a/today/2008/07/03/jsr-203-new-file-apis.html#so-what-is-a-path-really
25 * $ setfattr -n "user.fiki.pozdrav" -v 'Dobrý den!' pokus.txt
26 * (v javě pak pracujeme s klíči bez předpony „user.“)
30 public class Startér {
32 private static final Logger log = Logger.getLogger(Startér.class.getSimpleName());
35 * @param args název souboru
36 * @throws IOException TODO: ošetřit výjimku
38 public static void main(String[] args) throws IOException {
40 if (args.length == 1 && args[0].length() > 0) {
41 File soubor = new File(args[0]);
43 if (soubor.exists()) {
44 log.log(Level.INFO, "Pracuji se souborem: {0}", soubor);
46 Model model = new Model(soubor);
48 final JFrame f = new JFrame();
49 Panel p = new Panel(model);
51 f.setLayout(new BorderLayout());
52 f.add(p, BorderLayout.CENTER);
54 /** Ukončení programu klávesou Escape */
55 f.getRootPane().registerKeyboardAction(new ActionListener() {
57 public void actionPerformed(ActionEvent ae) {
60 }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
62 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
63 f.setTitle("Rozšířené stributy souboru: " + soubor);
65 f.setLocationRelativeTo(null);
68 ukončiChybou("Soubor neexistuje: " + soubor);
71 ukončiChybou("Očekávám právě jeden parametr – název souboru.");
75 private static void ukončiChybou(String hláška) {
76 log.log(Level.SEVERE, hláška);
77 JOptionPane.showMessageDialog(null, hláška, "Chyba", JOptionPane.ERROR_MESSAGE);