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