java/rozsirene-atributy-jedit/src/cz/frantovo/rozsireneAtributy/jedit/DokovatelnyPanel.java
changeset 20 bf328b110881
parent 19 c20edbed09c3
child 22 bf06eb899671
     1.1 --- a/java/rozsirene-atributy-jedit/src/cz/frantovo/rozsireneAtributy/jedit/DokovatelnyPanel.java	Sat Aug 18 13:27:00 2012 +0200
     1.2 +++ b/java/rozsirene-atributy-jedit/src/cz/frantovo/rozsireneAtributy/jedit/DokovatelnyPanel.java	Sat Aug 18 13:38:58 2012 +0200
     1.3 @@ -1,26 +1,30 @@
     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 + *
     1.9   * This program is free software: you can redistribute it and/or modify
    1.10   * it under the terms of the GNU General Public License as published by
    1.11   * the Free Software Foundation, either version 3 of the License, or
    1.12   * (at your option) any later version.
    1.13 - * 
    1.14 + *
    1.15   * This program is distributed in the hope that it will be useful,
    1.16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.17 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    1.19   * GNU General Public License for more details.
    1.20 - * 
    1.21 + *
    1.22   * You should have received a copy of the GNU General Public License
    1.23 - * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1.24 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
    1.25   */
    1.26  package cz.frantovo.rozsireneAtributy.jedit;
    1.27  
    1.28 +import cz.frantovo.rozsireneAtributy.gui.Model;
    1.29 +import cz.frantovo.rozsireneAtributy.gui.Panel;
    1.30 +import java.awt.BorderLayout;
    1.31 +import java.io.File;
    1.32 +import java.io.IOException;
    1.33  import java.util.logging.Level;
    1.34  import java.util.logging.Logger;
    1.35  import javax.swing.JPanel;
    1.36 -import javax.swing.JTextArea;
    1.37  import org.gjt.sp.jedit.Buffer;
    1.38  import org.gjt.sp.jedit.EBComponent;
    1.39  import org.gjt.sp.jedit.EBMessage;
    1.40 @@ -35,12 +39,12 @@
    1.41  public class DokovatelnyPanel extends JPanel implements EBComponent {
    1.42  
    1.43  	private static final Logger log = Logger.getLogger(DokovatelnyPanel.class.getName());
    1.44 -	private JTextArea pokus = new JTextArea("...");
    1.45  	private View view;
    1.46  
    1.47  	public DokovatelnyPanel(final View view, final String position) {
    1.48  		this.view = view;
    1.49 -		add(pokus);
    1.50 +		setLayout(new BorderLayout());
    1.51 +		změňSoubor(view.getBuffer());
    1.52  	}
    1.53  
    1.54  	/**
    1.55 @@ -86,6 +90,19 @@
    1.56  	}
    1.57  
    1.58  	private void změňSoubor(Buffer b) {
    1.59 -		pokus.setText(b.getPath());
    1.60 +		try {
    1.61 +			File s = new File(b.getPath());
    1.62 +
    1.63 +			if (s.isFile() && s.canRead()) {
    1.64 +				Model m = new Model(s);
    1.65 +				Panel p = new Panel(m);
    1.66 +				removeAll();
    1.67 +				add(p, BorderLayout.CENTER);
    1.68 +			} else {
    1.69 +				// TODO: zobrazit chybu
    1.70 +			}
    1.71 +		} catch (IOException e) {
    1.72 +			log.log(Level.WARNING, "Chyba při změně souboru.", e);
    1.73 +		}
    1.74  	}
    1.75  }