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, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package cz.frantovo.rozsireneAtributy.gui;
20 import java.awt.Component;
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.util.EventObject;
24 import javax.swing.JComboBox;
25 import javax.swing.JTable;
26 import javax.swing.event.CellEditorListener;
27 import javax.swing.event.ChangeEvent;
28 import javax.swing.event.EventListenerList;
29 import javax.swing.table.TableCellEditor;
32 * Umožňuje výběr názvu atributu z předvoleného seznamu (standardizované atributy).
34 * @author Ing. František Kučera (frantovo.cz)
36 public class EditorNázvůAtributů extends JComboBox<String> implements TableCellEditor {
38 protected EventListenerList posluchače = new EventListenerList();
39 protected ChangeEvent událost = new ChangeEvent(this);
41 public EditorNázvůAtributů() {
44 addActionListener(new ActionListener() {
47 public void actionPerformed(ActionEvent e) {
48 fireEditiaceSkončila();
53 protected void fireEditiaceSkončila() {
54 for (Object posluchač : posluchače.getListenerList()) {
55 if (posluchač instanceof CellEditorListener) {
56 ((CellEditorListener) posluchač).editingStopped(událost);
61 protected void fireEditiaceZrušena() {
62 for (Object posluchač : posluchače.getListenerList()) {
63 if (posluchač instanceof CellEditorListener) {
64 ((CellEditorListener) posluchač).editingCanceled(událost);
71 * - další standardní atributy
72 * - konfigurovatelnost
74 * @see http://www.freedesktop.org/wiki/CommonExtendedAttributes
76 private void obnovHodnoty(Object názevAtributu) {
79 if (názevAtributu == null) {
81 } else if (!(názevAtributu instanceof String)) {
82 názevAtributu = String.valueOf(názevAtributu);
84 addItem((String) názevAtributu);
85 setSelectedItem(názevAtributu);
88 // General attributes in current use
93 // Proposed metadata attributes
94 addItem("xdg.comment");
95 addItem("xdg.origin.url");
96 addItem("xdg.origin.email.subject");
97 addItem("xdg.origin.email.from");
98 addItem("xdg.origin.email.message-id");
99 addItem("xdg.language");
100 addItem("xdg.creator");
101 addItem("xdg.publisher");
103 // Proposed control attributes
104 addItem("xdg.robots.index");
105 addItem("xdg.robots.backup");
108 addItem("dublincore.title");
109 addItem("dublincore.creator");
110 addItem("dublincore.subject");
111 addItem("dublincore.description");
112 addItem("dublincore.publisher");
113 addItem("dublincore.contributor");
114 addItem("dublincore.date");
115 addItem("dublincore.type");
116 addItem("dublincore.format");
117 addItem("dublincore.identifier");
118 addItem("dublincore.source");
119 addItem("dublincore.language");
120 addItem("dublincore.relation");
121 addItem("dublincore.coverage");
122 addItem("dublincore.rights");
124 // Application-specific attributes in current use
125 addItem("mime_encoding");
126 addItem("apache_handler");
127 addItem("Beagle.AttrTime");
128 addItem("Beagle.Fingerprint");
129 addItem("Beagle.MTime");
130 addItem("Beagle.Uid");
134 public Component getTableCellEditorComponent(JTable tabulka, Object hodnota, boolean vybraná, int řádek, int sloupec) {
135 obnovHodnoty(hodnota);
140 public Object getCellEditorValue() {
141 return getSelectedItem();
145 public boolean isCellEditable(EventObject anEvent) {
150 public boolean shouldSelectCell(EventObject anEvent) {
155 public boolean stopCellEditing() {
156 fireEditiaceSkončila();
161 public void cancelCellEditing() {
162 fireEditiaceZrušena();
166 public void addCellEditorListener(CellEditorListener l) {
167 posluchače.add(CellEditorListener.class, l);
171 public void removeCellEditorListener(CellEditorListener l) {
172 posluchače.remove(CellEditorListener.class, l);