První fungující verze doplňku pro jEdit. v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sat, 18 Aug 2012 13:38:58 +0200
branchv_0
changeset 20346e69619e34
parent 19 adea235f456a
child 21 fbf3e38d1dc7
První fungující verze doplňku pro jEdit.
java/rozsirene-atributy-jedit/nbproject/project.properties
java/rozsirene-atributy-jedit/src/cz/frantovo/rozsireneAtributy/jedit/DokovatelnyPanel.java
     1.1 --- a/java/rozsirene-atributy-jedit/nbproject/project.properties	Sat Aug 18 13:27:00 2012 +0200
     1.2 +++ b/java/rozsirene-atributy-jedit/nbproject/project.properties	Sat Aug 18 13:38:58 2012 +0200
     1.3 @@ -33,7 +33,8 @@
     1.4  jar.compress=false
     1.5  jar.index=${jnlp.enabled}
     1.6  javac.classpath=\
     1.7 -    ${file.reference.jedit.jar}
     1.8 +    ${file.reference.jedit.jar}:\
     1.9 +    ${reference.rozsirene-atributy.jar}
    1.10  # Space-separated list of extra javac options
    1.11  javac.compilerargs=
    1.12  javac.deprecation=false
    1.13 @@ -73,8 +74,7 @@
    1.14  reference.rozsirene-atributy.jar=${project.rozsirene-atributy}/dist/rozsirene-atributy.jar
    1.15  run.classpath=\
    1.16      ${javac.classpath}:\
    1.17 -    ${build.classes.dir}:\
    1.18 -    ${reference.rozsirene-atributy.jar}
    1.19 +    ${build.classes.dir}
    1.20  # Space-separated list of JVM arguments used when running the project
    1.21  # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
    1.22  # or test-sys-prop.name=value to set system properties for unit tests):
     2.1 --- a/java/rozsirene-atributy-jedit/src/cz/frantovo/rozsireneAtributy/jedit/DokovatelnyPanel.java	Sat Aug 18 13:27:00 2012 +0200
     2.2 +++ b/java/rozsirene-atributy-jedit/src/cz/frantovo/rozsireneAtributy/jedit/DokovatelnyPanel.java	Sat Aug 18 13:38:58 2012 +0200
     2.3 @@ -1,26 +1,30 @@
     2.4  /**
     2.5   * Rozšířené atributy – program na správu rozšířených atributů souborů
     2.6   * Copyright © 2012 František Kučera (frantovo.cz)
     2.7 - * 
     2.8 + *
     2.9   * This program is free software: you can redistribute it and/or modify
    2.10   * it under the terms of the GNU General Public License as published by
    2.11   * the Free Software Foundation, either version 3 of the License, or
    2.12   * (at your option) any later version.
    2.13 - * 
    2.14 + *
    2.15   * This program is distributed in the hope that it will be useful,
    2.16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.17 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    2.19   * GNU General Public License for more details.
    2.20 - * 
    2.21 + *
    2.22   * You should have received a copy of the GNU General Public License
    2.23 - * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    2.24 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
    2.25   */
    2.26  package cz.frantovo.rozsireneAtributy.jedit;
    2.27  
    2.28 +import cz.frantovo.rozsireneAtributy.gui.Model;
    2.29 +import cz.frantovo.rozsireneAtributy.gui.Panel;
    2.30 +import java.awt.BorderLayout;
    2.31 +import java.io.File;
    2.32 +import java.io.IOException;
    2.33  import java.util.logging.Level;
    2.34  import java.util.logging.Logger;
    2.35  import javax.swing.JPanel;
    2.36 -import javax.swing.JTextArea;
    2.37  import org.gjt.sp.jedit.Buffer;
    2.38  import org.gjt.sp.jedit.EBComponent;
    2.39  import org.gjt.sp.jedit.EBMessage;
    2.40 @@ -35,12 +39,12 @@
    2.41  public class DokovatelnyPanel extends JPanel implements EBComponent {
    2.42  
    2.43  	private static final Logger log = Logger.getLogger(DokovatelnyPanel.class.getName());
    2.44 -	private JTextArea pokus = new JTextArea("...");
    2.45  	private View view;
    2.46  
    2.47  	public DokovatelnyPanel(final View view, final String position) {
    2.48  		this.view = view;
    2.49 -		add(pokus);
    2.50 +		setLayout(new BorderLayout());
    2.51 +		změňSoubor(view.getBuffer());
    2.52  	}
    2.53  
    2.54  	/**
    2.55 @@ -86,6 +90,19 @@
    2.56  	}
    2.57  
    2.58  	private void změňSoubor(Buffer b) {
    2.59 -		pokus.setText(b.getPath());
    2.60 +		try {
    2.61 +			File s = new File(b.getPath());
    2.62 +
    2.63 +			if (s.isFile() && s.canRead()) {
    2.64 +				Model m = new Model(s);
    2.65 +				Panel p = new Panel(m);
    2.66 +				removeAll();
    2.67 +				add(p, BorderLayout.CENTER);
    2.68 +			} else {
    2.69 +				// TODO: zobrazit chybu
    2.70 +			}
    2.71 +		} catch (IOException e) {
    2.72 +			log.log(Level.WARNING, "Chyba při změně souboru.", e);
    2.73 +		}
    2.74  	}
    2.75  }