1.1 --- a/java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/Startér.java Mon Dec 11 00:10:33 2023 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,100 +0,0 @@
1.4 -/**
1.5 - * Rozšířené atributy – program na správu rozšířených atributů souborů
1.6 - * Copyright © 2012 František Kučera (frantovo.cz)
1.7 - *
1.8 - * This program is free software: you can redistribute it and/or modify
1.9 - * it under the terms of the GNU General Public License as published by
1.10 - * the Free Software Foundation, either version 3 of the License.
1.11 - *
1.12 - * This program is distributed in the hope that it will be useful,
1.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.15 - * GNU General Public License for more details.
1.16 - *
1.17 - * You should have received a copy of the GNU General Public License
1.18 - * along with this program. If not, see <http://www.gnu.org/licenses/>.
1.19 - */
1.20 -package cz.frantovo.rozsireneAtributy;
1.21 -
1.22 -import cz.frantovo.rozsireneAtributy.gui.Model;
1.23 -import cz.frantovo.rozsireneAtributy.gui.Panel;
1.24 -import java.awt.BorderLayout;
1.25 -import java.awt.event.ActionEvent;
1.26 -import java.awt.event.ActionListener;
1.27 -import java.awt.event.KeyEvent;
1.28 -import java.io.File;
1.29 -import java.io.IOException;
1.30 -import java.text.MessageFormat;
1.31 -import java.util.ResourceBundle;
1.32 -import java.util.logging.Level;
1.33 -import java.util.logging.Logger;
1.34 -import javax.swing.JComponent;
1.35 -import javax.swing.JFrame;
1.36 -import javax.swing.JOptionPane;
1.37 -import javax.swing.KeyStroke;
1.38 -
1.39 -/**
1.40 - * Spouštěč programu
1.41 - *
1.42 - * http://freedesktop.org/wiki/CommonExtendedAttributes
1.43 - * http://download.oracle.com/javase/tutorial/essential/io/fileAttr.html#user
1.44 - * http://today.java.net/pub/a/today/2008/07/03/jsr-203-new-file-apis.html#so-what-is-a-path-really
1.45 - *
1.46 - * $ setfattr -n "user.fiki.pozdrav" -v 'Dobrý den!' pokus.txt
1.47 - * (v javě pak pracujeme s klíči bez předpony „user.“)
1.48 - *
1.49 - * @author fiki
1.50 - */
1.51 -public class Startér {
1.52 -
1.53 - private static final Logger log = Logger.getLogger(Startér.class.getSimpleName());
1.54 - private static final ResourceBundle překlady = ResourceBundle.getBundle("cz.frantovo.rozsireneAtributy.Překlady");
1.55 -
1.56 - /**
1.57 - * @param args název souboru
1.58 - * @throws IOException TODO: ošetřit výjimku
1.59 - */
1.60 - public static void main(String[] args) throws IOException {
1.61 -
1.62 -
1.63 - if (args.length == 1 && args[0].length() > 0) {
1.64 - File soubor = new File(args[0]);
1.65 -
1.66 - if (soubor.exists()) {
1.67 - log.log(Level.INFO, "Pracuji se souborem: {0}", soubor);
1.68 -
1.69 - Model model = new Model(soubor);
1.70 -
1.71 - final JFrame f = new JFrame();
1.72 - Panel p = new Panel(model);
1.73 -
1.74 - f.setLayout(new BorderLayout());
1.75 - f.add(p, BorderLayout.CENTER);
1.76 -
1.77 - /** Ukončení programu klávesou Escape */
1.78 - f.getRootPane().registerKeyboardAction(new ActionListener() {
1.79 -
1.80 - public void actionPerformed(ActionEvent ae) {
1.81 - f.dispose();
1.82 - }
1.83 - }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
1.84 -
1.85 - f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
1.86 - f.setTitle(MessageFormat.format(překlady.getString("titulek"), soubor));
1.87 - f.setSize(640, 240);
1.88 - f.setLocationRelativeTo(null);
1.89 - f.setVisible(true);
1.90 - } else {
1.91 - ukončiChybou(MessageFormat.format(překlady.getString("chyba.souborNeexistuje"), soubor));
1.92 - }
1.93 - } else {
1.94 - ukončiChybou(překlady.getString("chyba.chybíParametr"));
1.95 - }
1.96 - }
1.97 -
1.98 - private static void ukončiChybou(String hláška) {
1.99 - log.log(Level.SEVERE, hláška);
1.100 - JOptionPane.showMessageDialog(null, hláška, překlady.getString("chyba.titulek"), JOptionPane.ERROR_MESSAGE);
1.101 - System.exit(1);
1.102 - }
1.103 -}