2 * Rozšířené atributy – program na správu rozšířených atributů souborů
3 * Copyright © 2012 František Kučera (frantovo.cz)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package cz.frantovo.rozsireneatributy;
19 import cz.frantovo.rozsireneatributy.gui.Model;
20 import cz.frantovo.rozsireneatributy.gui.Panel;
21 import java.awt.BorderLayout;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24 import java.awt.event.KeyEvent;
26 import java.io.IOException;
27 import java.text.MessageFormat;
28 import java.util.ResourceBundle;
29 import java.util.logging.Level;
30 import java.util.logging.Logger;
31 import javax.swing.JComponent;
32 import javax.swing.JFrame;
33 import javax.swing.JOptionPane;
34 import javax.swing.KeyStroke;
39 * http://freedesktop.org/wiki/CommonExtendedAttributes
40 * http://download.oracle.com/javase/tutorial/essential/io/fileAttr.html#user
41 * http://today.java.net/pub/a/today/2008/07/03/jsr-203-new-file-apis.html
42 * #so-what-is-a-path-really
44 * $ setfattr -n "user.fiki.pozdrav" -v 'Dobrý den!' pokus.txt
45 * (v javě pak pracujeme s klíči bez předpony „user.“)
49 public class Startér {
51 private static final Logger log = Logger
52 .getLogger(Startér.class.getSimpleName());
53 private static final ResourceBundle překlady = ResourceBundle
54 .getBundle(Atribut.class.getPackageName() + ".Překlady");
57 * @param args název souboru
58 * @throws IOException TODO: ošetřit výjimku
60 public static void main(String[] args) throws IOException {
63 if (args.length == 1 && args[0].length() > 0) {
64 File soubor = new File(args[0]);
66 if (soubor.exists()) {
67 log.log(Level.INFO, "Pracuji se souborem: {0}", soubor);
69 Model model = new Model(soubor);
71 final JFrame f = new JFrame();
72 Panel p = new Panel(model);
74 f.setLayout(new BorderLayout());
75 f.add(p, BorderLayout.CENTER);
77 /** Ukončení programu klávesou Escape */
78 f.getRootPane().registerKeyboardAction(new ActionListener() {
80 public void actionPerformed(ActionEvent ae) {
84 KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
85 JComponent.WHEN_IN_FOCUSED_WINDOW);
87 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
88 f.setTitle(MessageFormat
89 .format(překlady.getString("titulek"), soubor));
91 f.setLocationRelativeTo(null);
94 ukončiChybou(MessageFormat.format(překlady
95 .getString("chyba.souborNeexistuje"), soubor));
98 ukončiChybou(překlady.getString("chyba.chybíParametr"));
102 private static void ukončiChybou(String hláška) {
103 log.log(Level.SEVERE, hláška);
104 JOptionPane.showMessageDialog(null, hláška, překlady
105 .getString("chyba.titulek"), JOptionPane.ERROR_MESSAGE);