java/rozsirene-atributy/src/cz/frantovo/rozsireneatributy/Startér.java
branchv_0
changeset 39 ec0e970e0830
parent 38 41e91ea94acb
child 40 1978eaf429de
     1.1 --- a/java/rozsirene-atributy/src/cz/frantovo/rozsireneatributy/Startér.java	Sat Dec 16 19:09:35 2023 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,111 +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.text.MessageFormat;
    1.30 -import java.util.ResourceBundle;
    1.31 -import java.util.logging.Level;
    1.32 -import java.util.logging.Logger;
    1.33 -import javax.swing.JComponent;
    1.34 -import javax.swing.JFrame;
    1.35 -import javax.swing.JOptionPane;
    1.36 -import javax.swing.KeyStroke;
    1.37 -
    1.38 -/**
    1.39 - * Spouštěč programu
    1.40 - *
    1.41 - * http://freedesktop.org/wiki/CommonExtendedAttributes
    1.42 - * http://download.oracle.com/javase/tutorial/essential/io/fileAttr.html#user
    1.43 - * http://today.java.net/pub/a/today/2008/07/03/jsr-203-new-file-apis.html
    1.44 - * #so-what-is-a-path-really
    1.45 - *
    1.46 - * $ setfattr -n "user.franta.pozdrav" -v 'Dobrý den!' pokus.txt (v javě pak
    1.47 - * pracujeme s klíči bez předpony „user.“)
    1.48 - *
    1.49 - * @author Ing. František Kučera (frantovo.cz)
    1.50 - */
    1.51 -public class Startér {
    1.52 -
    1.53 -	private static final Logger log = Logger
    1.54 -		.getLogger(Startér.class.getSimpleName());
    1.55 -	private static final ResourceBundle překlady = ResourceBundle
    1.56 -		.getBundle(Atribut.class.getPackageName() + ".Překlady");
    1.57 -
    1.58 -	/**
    1.59 -	 * @param args název souboru
    1.60 -	 */
    1.61 -	public static void main(String[] args) {
    1.62 -
    1.63 -		try {
    1.64 -			// TODO: načítat konfiguraci i z XML souboru
    1.65 -			CLIParser parser = new CLIParser();
    1.66 -			Konfigurace konfigurace = parser.parsujParametry(args);
    1.67 -
    1.68 -			File soubor = konfigurace.getSoubor();
    1.69 -
    1.70 -			if (soubor.exists()) {
    1.71 -				log.log(Level.INFO, "Pracuji se souborem: {0}", soubor);
    1.72 -
    1.73 -				Model model = new Model(konfigurace);
    1.74 -
    1.75 -				final JFrame f = new JFrame();
    1.76 -				Panel p = new Panel(model);
    1.77 -
    1.78 -				f.setLayout(new BorderLayout());
    1.79 -				f.add(p, BorderLayout.CENTER);
    1.80 -
    1.81 -				// Ukončení programu klávesou Escape:
    1.82 -				f.getRootPane().registerKeyboardAction(new ActionListener() {
    1.83 -
    1.84 -					@Override
    1.85 -					public void actionPerformed(ActionEvent ae) {
    1.86 -						f.dispose();
    1.87 -					}
    1.88 -				},
    1.89 -					KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
    1.90 -					JComponent.WHEN_IN_FOCUSED_WINDOW);
    1.91 -
    1.92 -				f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    1.93 -				f.setTitle(MessageFormat
    1.94 -					.format(překlady.getString("titulek"), soubor));
    1.95 -				f.setSize(640, 240);
    1.96 -				f.setLocationRelativeTo(null);
    1.97 -				f.setVisible(true);
    1.98 -			} else {
    1.99 -				ukončiChybou(MessageFormat.format(překlady
   1.100 -					.getString("chyba.souborNeexistuje"), soubor));
   1.101 -			}
   1.102 -		} catch (Exception e) {
   1.103 -			log.log(Level.SEVERE, překlady.getString("chyba"), e);
   1.104 -			ukončiChybou(e.getLocalizedMessage());
   1.105 -		}
   1.106 -	}
   1.107 -
   1.108 -	private static void ukončiChybou(String hláška) {
   1.109 -		log.log(Level.SEVERE, hláška);
   1.110 -		JOptionPane.showMessageDialog(null, hláška, překlady
   1.111 -			.getString("chyba.titulek"), JOptionPane.ERROR_MESSAGE);
   1.112 -		System.exit(1);
   1.113 -	}
   1.114 -}