java/rozsirene-atributy/src/cz/frantovo/rozsireneatributy/gui/EditorNázvůAtributů.java
2 * Rozšířené atributy – program na správu rozšířených atributů souborů
3 * Copyright © 2012 František Kučera (frantovo.cz)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package cz.frantovo.rozsireneatributy.gui;
19 import java.awt.Component;
20 import java.awt.event.ActionEvent;
21 import java.awt.event.ActionListener;
22 import java.util.EventObject;
23 import javax.swing.JComboBox;
24 import javax.swing.JTable;
25 import javax.swing.event.CellEditorListener;
26 import javax.swing.event.ChangeEvent;
27 import javax.swing.event.EventListenerList;
28 import javax.swing.table.TableCellEditor;
31 * Umožňuje výběr názvu atributu z předvoleného seznamu (standardizované atributy).
33 * @author Ing. František Kučera (frantovo.cz)
35 public class EditorNázvůAtributů extends JComboBox<String> implements TableCellEditor {
37 protected EventListenerList posluchače = new EventListenerList();
38 protected ChangeEvent událost = new ChangeEvent(this);
40 public EditorNázvůAtributů() {
43 addActionListener(new ActionListener() {
46 public void actionPerformed(ActionEvent e) {
47 fireEditiaceSkončila();
52 protected void fireEditiaceSkončila() {
53 for (Object posluchač : posluchače.getListenerList()) {
54 if (posluchač instanceof CellEditorListener) {
55 ((CellEditorListener) posluchač).editingStopped(událost);
60 protected void fireEditiaceZrušena() {
61 for (Object posluchač : posluchače.getListenerList()) {
62 if (posluchač instanceof CellEditorListener) {
63 ((CellEditorListener) posluchač).editingCanceled(událost);
70 * - další standardní atributy
71 * - konfigurovatelnost
73 * @see http://www.freedesktop.org/wiki/CommonExtendedAttributes
75 private void obnovHodnoty(Object názevAtributu) {
78 if (názevAtributu == null) {
80 } else if (!(názevAtributu instanceof String)) {
81 názevAtributu = String.valueOf(názevAtributu);
83 addItem((String) názevAtributu);
84 setSelectedItem(názevAtributu);
87 // General attributes in current use
92 // Proposed metadata attributes
93 addItem("xdg.comment");
94 addItem("xdg.origin.url");
95 addItem("xdg.origin.email.subject");
96 addItem("xdg.origin.email.from");
97 addItem("xdg.origin.email.message-id");
98 addItem("xdg.language");
99 addItem("xdg.creator");
100 addItem("xdg.publisher");
102 // Proposed control attributes
103 addItem("xdg.robots.index");
104 addItem("xdg.robots.backup");
107 addItem("dublincore.title");
108 addItem("dublincore.creator");
109 addItem("dublincore.subject");
110 addItem("dublincore.description");
111 addItem("dublincore.publisher");
112 addItem("dublincore.contributor");
113 addItem("dublincore.date");
114 addItem("dublincore.type");
115 addItem("dublincore.format");
116 addItem("dublincore.identifier");
117 addItem("dublincore.source");
118 addItem("dublincore.language");
119 addItem("dublincore.relation");
120 addItem("dublincore.coverage");
121 addItem("dublincore.rights");
123 // Application-specific attributes in current use
124 addItem("mime_encoding");
125 addItem("apache_handler");
126 addItem("Beagle.AttrTime");
127 addItem("Beagle.Fingerprint");
128 addItem("Beagle.MTime");
129 addItem("Beagle.Uid");
133 public Component getTableCellEditorComponent(JTable tabulka, Object hodnota, boolean vybraná, int řádek, int sloupec) {
134 obnovHodnoty(hodnota);
139 public Object getCellEditorValue() {
140 return getSelectedItem();
144 public boolean isCellEditable(EventObject anEvent) {
149 public boolean shouldSelectCell(EventObject anEvent) {
154 public boolean stopCellEditing() {
155 fireEditiaceSkončila();
160 public void cancelCellEditing() {
161 fireEditiaceZrušena();
165 public void addCellEditorListener(CellEditorListener l) {
166 posluchače.add(CellEditorListener.class, l);
170 public void removeCellEditorListener(CellEditorListener l) {
171 posluchače.remove(CellEditorListener.class, l);