franta-hg@19: /** franta-hg@19: * Rozšířené atributy – program na správu rozšířených atributů souborů franta-hg@19: * Copyright © 2012 František Kučera (frantovo.cz) franta-hg@28: * franta-hg@19: * This program is free software: you can redistribute it and/or modify franta-hg@19: * it under the terms of the GNU General Public License as published by franta-hg@27: * the Free Software Foundation, either version 3 of the License. franta-hg@28: * franta-hg@19: * This program is distributed in the hope that it will be useful, franta-hg@19: * but WITHOUT ANY WARRANTY; without even the implied warranty of franta-hg@19: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the franta-hg@19: * GNU General Public License for more details. franta-hg@28: * franta-hg@19: * You should have received a copy of the GNU General Public License franta-hg@19: * along with this program. If not, see . franta-hg@19: */ franta-hg@28: package cz.frantovo.rozsireneatributy; franta-hg@4: franta-hg@28: import cz.frantovo.rozsireneatributy.gui.Model; franta-hg@28: import cz.frantovo.rozsireneatributy.gui.Panel; franta-hg@6: import java.awt.BorderLayout; franta-hg@11: import java.awt.event.ActionEvent; franta-hg@11: import java.awt.event.ActionListener; franta-hg@11: import java.awt.event.KeyEvent; franta-hg@6: import java.io.File; franta-hg@6: import java.io.IOException; franta-hg@15: import java.text.MessageFormat; franta-hg@15: import java.util.ResourceBundle; franta-hg@6: import java.util.logging.Level; franta-hg@6: import java.util.logging.Logger; franta-hg@11: import javax.swing.JComponent; franta-hg@6: import javax.swing.JFrame; franta-hg@7: import javax.swing.JOptionPane; franta-hg@11: import javax.swing.KeyStroke; franta-hg@6: franta-hg@4: /** franta-hg@4: * Spouštěč programu franta-hg@6: * franta-hg@6: * http://freedesktop.org/wiki/CommonExtendedAttributes franta-hg@6: * http://download.oracle.com/javase/tutorial/essential/io/fileAttr.html#user franta-hg@29: * http://today.java.net/pub/a/today/2008/07/03/jsr-203-new-file-apis.html franta-hg@29: * #so-what-is-a-path-really franta-hg@6: * franta-hg@30: * $ setfattr -n "user.franta.pozdrav" -v 'Dobrý den!' pokus.txt franta-hg@6: * (v javě pak pracujeme s klíči bez předpony „user.“) franta-hg@30: * franta-hg@30: * @author Ing. František Kučera (frantovo.cz) franta-hg@4: */ franta-hg@5: public class Startér { franta-hg@4: franta-hg@29: private static final Logger log = Logger franta-hg@29: .getLogger(Startér.class.getSimpleName()); franta-hg@29: private static final ResourceBundle překlady = ResourceBundle franta-hg@29: .getBundle(Atribut.class.getPackageName() + ".Překlady"); franta-hg@6: franta-hg@8: /** franta-hg@8: * @param args název souboru franta-hg@8: * @throws IOException TODO: ošetřit výjimku franta-hg@8: */ franta-hg@6: public static void main(String[] args) throws IOException { franta-hg@6: franta-hg@15: franta-hg@7: if (args.length == 1 && args[0].length() > 0) { franta-hg@6: File soubor = new File(args[0]); franta-hg@6: franta-hg@7: if (soubor.exists()) { franta-hg@7: log.log(Level.INFO, "Pracuji se souborem: {0}", soubor); franta-hg@6: franta-hg@7: Model model = new Model(soubor); franta-hg@6: franta-hg@11: final JFrame f = new JFrame(); franta-hg@7: Panel p = new Panel(model); franta-hg@6: franta-hg@7: f.setLayout(new BorderLayout()); franta-hg@7: f.add(p, BorderLayout.CENTER); franta-hg@6: franta-hg@11: /** Ukončení programu klávesou Escape */ franta-hg@11: f.getRootPane().registerKeyboardAction(new ActionListener() { franta-hg@11: franta-hg@11: public void actionPerformed(ActionEvent ae) { franta-hg@11: f.dispose(); franta-hg@11: } franta-hg@29: }, franta-hg@29: KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), franta-hg@29: JComponent.WHEN_IN_FOCUSED_WINDOW); franta-hg@11: franta-hg@8: f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); franta-hg@29: f.setTitle(MessageFormat franta-hg@29: .format(překlady.getString("titulek"), soubor)); franta-hg@7: f.setSize(640, 240); franta-hg@7: f.setLocationRelativeTo(null); franta-hg@7: f.setVisible(true); franta-hg@7: } else { franta-hg@29: ukončiChybou(MessageFormat.format(překlady franta-hg@29: .getString("chyba.souborNeexistuje"), soubor)); franta-hg@7: } franta-hg@6: } else { franta-hg@15: ukončiChybou(překlady.getString("chyba.chybíParametr")); franta-hg@6: } franta-hg@4: } franta-hg@7: franta-hg@7: private static void ukončiChybou(String hláška) { franta-hg@7: log.log(Level.SEVERE, hláška); franta-hg@29: JOptionPane.showMessageDialog(null, hláška, překlady franta-hg@29: .getString("chyba.titulek"), JOptionPane.ERROR_MESSAGE); franta-hg@7: System.exit(1); franta-hg@7: } franta-hg@4: }