author | František Kučera <franta-hg@frantovo.cz> |
Sat, 18 Aug 2012 13:27:00 +0200 | |
branch | v_0 |
changeset 19 | adea235f456a |
parent 18 | 6864cc4e6027 |
child 20 | 346e69619e34 |
permissions | -rw-r--r-- |
franta-hg@19 | 1 |
/** |
franta-hg@19 | 2 |
* Rozšířené atributy – program na správu rozšířených atributů souborů |
franta-hg@19 | 3 |
* Copyright © 2012 František Kučera (frantovo.cz) |
franta-hg@19 | 4 |
* |
franta-hg@19 | 5 |
* This program is free software: you can redistribute it and/or modify |
franta-hg@19 | 6 |
* it under the terms of the GNU General Public License as published by |
franta-hg@19 | 7 |
* the Free Software Foundation, either version 3 of the License, or |
franta-hg@19 | 8 |
* (at your option) any later version. |
franta-hg@19 | 9 |
* |
franta-hg@19 | 10 |
* This program is distributed in the hope that it will be useful, |
franta-hg@19 | 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
franta-hg@19 | 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
franta-hg@19 | 13 |
* GNU General Public License for more details. |
franta-hg@19 | 14 |
* |
franta-hg@19 | 15 |
* You should have received a copy of the GNU General Public License |
franta-hg@19 | 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
franta-hg@19 | 17 |
*/ |
franta-hg@18 | 18 |
package cz.frantovo.rozsireneAtributy.jedit; |
franta-hg@18 | 19 |
|
franta-hg@18 | 20 |
import java.util.logging.Level; |
franta-hg@18 | 21 |
import java.util.logging.Logger; |
franta-hg@18 | 22 |
import javax.swing.JPanel; |
franta-hg@18 | 23 |
import javax.swing.JTextArea; |
franta-hg@18 | 24 |
import org.gjt.sp.jedit.Buffer; |
franta-hg@18 | 25 |
import org.gjt.sp.jedit.EBComponent; |
franta-hg@18 | 26 |
import org.gjt.sp.jedit.EBMessage; |
franta-hg@18 | 27 |
import org.gjt.sp.jedit.EditBus; |
franta-hg@18 | 28 |
import org.gjt.sp.jedit.View; |
franta-hg@18 | 29 |
import org.gjt.sp.jedit.msg.EditPaneUpdate; |
franta-hg@18 | 30 |
|
franta-hg@18 | 31 |
/** |
franta-hg@18 | 32 |
* |
franta-hg@18 | 33 |
* @author Ing. František Kučera (frantovo.cz) |
franta-hg@18 | 34 |
*/ |
franta-hg@18 | 35 |
public class DokovatelnyPanel extends JPanel implements EBComponent { |
franta-hg@18 | 36 |
|
franta-hg@18 | 37 |
private static final Logger log = Logger.getLogger(DokovatelnyPanel.class.getName()); |
franta-hg@18 | 38 |
private JTextArea pokus = new JTextArea("..."); |
franta-hg@18 | 39 |
private View view; |
franta-hg@18 | 40 |
|
franta-hg@18 | 41 |
public DokovatelnyPanel(final View view, final String position) { |
franta-hg@18 | 42 |
this.view = view; |
franta-hg@18 | 43 |
add(pokus); |
franta-hg@18 | 44 |
} |
franta-hg@18 | 45 |
|
franta-hg@18 | 46 |
/** |
franta-hg@18 | 47 |
* Zaregistrujeme se, aby nám chodily události editoru. |
franta-hg@18 | 48 |
*/ |
franta-hg@18 | 49 |
@Override |
franta-hg@18 | 50 |
public void addNotify() { |
franta-hg@18 | 51 |
super.addNotify(); |
franta-hg@18 | 52 |
EditBus.addToBus(this); |
franta-hg@18 | 53 |
} |
franta-hg@18 | 54 |
|
franta-hg@18 | 55 |
/** |
franta-hg@18 | 56 |
* @see #addNotify() |
franta-hg@18 | 57 |
*/ |
franta-hg@18 | 58 |
@Override |
franta-hg@18 | 59 |
public void removeNotify() { |
franta-hg@18 | 60 |
super.removeNotify(); |
franta-hg@18 | 61 |
EditBus.removeFromBus(this); |
franta-hg@18 | 62 |
} |
franta-hg@18 | 63 |
|
franta-hg@18 | 64 |
/** |
franta-hg@18 | 65 |
* Zpracujeme události editoru. |
franta-hg@18 | 66 |
* Zajímá nás přepnutí na jiný soubor – abychom pro něj zobrazili atributy. |
franta-hg@18 | 67 |
* |
franta-hg@18 | 68 |
* @param událost událost editoru |
franta-hg@18 | 69 |
*/ |
franta-hg@18 | 70 |
@Override |
franta-hg@18 | 71 |
public void handleMessage(EBMessage událost) { |
franta-hg@18 | 72 |
try { |
franta-hg@18 | 73 |
if (událost instanceof EditPaneUpdate) { |
franta-hg@18 | 74 |
EditPaneUpdate epu = (EditPaneUpdate) událost; |
franta-hg@18 | 75 |
// Chodí nám všechny události – potřebujeme filtrovat jen ty pro naše okno. |
franta-hg@18 | 76 |
if (view == epu.getEditPane().getView()) { |
franta-hg@18 | 77 |
změňSoubor(view.getBuffer()); |
franta-hg@18 | 78 |
} |
franta-hg@18 | 79 |
} |
franta-hg@18 | 80 |
// událost instanceof BufferUpdate |
franta-hg@18 | 81 |
// událost instanceof PropertiesChanged |
franta-hg@18 | 82 |
} catch (Exception e) { |
franta-hg@18 | 83 |
log.log(Level.WARNING, "Chyba při zpracování události: " + událost, e); |
franta-hg@18 | 84 |
} |
franta-hg@18 | 85 |
|
franta-hg@18 | 86 |
} |
franta-hg@18 | 87 |
|
franta-hg@18 | 88 |
private void změňSoubor(Buffer b) { |
franta-hg@18 | 89 |
pokus.setText(b.getPath()); |
franta-hg@18 | 90 |
} |
franta-hg@18 | 91 |
} |