branch | v_0 |
changeset 28 | c2ffda907125 |
parent 27 | dc5786f3482b |
child 29 | 8d42303538ed |
1.1 --- a/java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/gui/EditorNázvůAtributů.java Mon Dec 11 00:10:33 2023 +0100 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,173 +0,0 @@ 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 - * This program is free software: you can redistribute it and/or modify 1.9 - * it under the terms of the GNU General Public License as published by 1.10 - * the Free Software Foundation, either version 3 of the License. 1.11 - * 1.12 - * This program is distributed in the hope that it will be useful, 1.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 1.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1.15 - * GNU General Public License for more details. 1.16 - * 1.17 - * You should have received a copy of the GNU General Public License 1.18 - * along with this program. If not, see <http://www.gnu.org/licenses/>. 1.19 - */ 1.20 -package cz.frantovo.rozsireneAtributy.gui; 1.21 - 1.22 -import java.awt.Component; 1.23 -import java.awt.event.ActionEvent; 1.24 -import java.awt.event.ActionListener; 1.25 -import java.util.EventObject; 1.26 -import javax.swing.JComboBox; 1.27 -import javax.swing.JTable; 1.28 -import javax.swing.event.CellEditorListener; 1.29 -import javax.swing.event.ChangeEvent; 1.30 -import javax.swing.event.EventListenerList; 1.31 -import javax.swing.table.TableCellEditor; 1.32 - 1.33 -/** 1.34 - * Umožňuje výběr názvu atributu z předvoleného seznamu (standardizované atributy). 1.35 - * 1.36 - * @author Ing. František Kučera (frantovo.cz) 1.37 - */ 1.38 -public class EditorNázvůAtributů extends JComboBox<String> implements TableCellEditor { 1.39 - 1.40 - protected EventListenerList posluchače = new EventListenerList(); 1.41 - protected ChangeEvent událost = new ChangeEvent(this); 1.42 - 1.43 - public EditorNázvůAtributů() { 1.44 - super(); 1.45 - setEditable(true); 1.46 - addActionListener(new ActionListener() { 1.47 - 1.48 - @Override 1.49 - public void actionPerformed(ActionEvent e) { 1.50 - fireEditiaceSkončila(); 1.51 - } 1.52 - }); 1.53 - } 1.54 - 1.55 - protected void fireEditiaceSkončila() { 1.56 - for (Object posluchač : posluchače.getListenerList()) { 1.57 - if (posluchač instanceof CellEditorListener) { 1.58 - ((CellEditorListener) posluchač).editingStopped(událost); 1.59 - } 1.60 - } 1.61 - } 1.62 - 1.63 - protected void fireEditiaceZrušena() { 1.64 - for (Object posluchač : posluchače.getListenerList()) { 1.65 - if (posluchač instanceof CellEditorListener) { 1.66 - ((CellEditorListener) posluchač).editingCanceled(událost); 1.67 - } 1.68 - } 1.69 - } 1.70 - 1.71 - /** 1.72 - * TODO: 1.73 - * - další standardní atributy 1.74 - * - konfigurovatelnost 1.75 - * 1.76 - * @see http://www.freedesktop.org/wiki/CommonExtendedAttributes 1.77 - */ 1.78 - private void obnovHodnoty(Object názevAtributu) { 1.79 - removeAllItems(); 1.80 - 1.81 - if (názevAtributu == null) { 1.82 - názevAtributu = ""; 1.83 - } else if (!(názevAtributu instanceof String)) { 1.84 - názevAtributu = String.valueOf(názevAtributu); 1.85 - } 1.86 - addItem((String) názevAtributu); 1.87 - setSelectedItem(názevAtributu); 1.88 - 1.89 - 1.90 - // General attributes in current use 1.91 - addItem("mime_type"); 1.92 - addItem("charset"); 1.93 - addItem("creator"); 1.94 - 1.95 - // Proposed metadata attributes 1.96 - addItem("xdg.comment"); 1.97 - addItem("xdg.origin.url"); 1.98 - addItem("xdg.origin.email.subject"); 1.99 - addItem("xdg.origin.email.from"); 1.100 - addItem("xdg.origin.email.message-id"); 1.101 - addItem("xdg.language"); 1.102 - addItem("xdg.creator"); 1.103 - addItem("xdg.publisher"); 1.104 - 1.105 - // Proposed control attributes 1.106 - addItem("xdg.robots.index"); 1.107 - addItem("xdg.robots.backup"); 1.108 - 1.109 - // Dublin Core 1.110 - addItem("dublincore.title"); 1.111 - addItem("dublincore.creator"); 1.112 - addItem("dublincore.subject"); 1.113 - addItem("dublincore.description"); 1.114 - addItem("dublincore.publisher"); 1.115 - addItem("dublincore.contributor"); 1.116 - addItem("dublincore.date"); 1.117 - addItem("dublincore.type"); 1.118 - addItem("dublincore.format"); 1.119 - addItem("dublincore.identifier"); 1.120 - addItem("dublincore.source"); 1.121 - addItem("dublincore.language"); 1.122 - addItem("dublincore.relation"); 1.123 - addItem("dublincore.coverage"); 1.124 - addItem("dublincore.rights"); 1.125 - 1.126 - // Application-specific attributes in current use 1.127 - addItem("mime_encoding"); 1.128 - addItem("apache_handler"); 1.129 - addItem("Beagle.AttrTime"); 1.130 - addItem("Beagle.Fingerprint"); 1.131 - addItem("Beagle.MTime"); 1.132 - addItem("Beagle.Uid"); 1.133 - } 1.134 - 1.135 - @Override 1.136 - public Component getTableCellEditorComponent(JTable tabulka, Object hodnota, boolean vybraná, int řádek, int sloupec) { 1.137 - obnovHodnoty(hodnota); 1.138 - return this; 1.139 - } 1.140 - 1.141 - @Override 1.142 - public Object getCellEditorValue() { 1.143 - return getSelectedItem(); 1.144 - } 1.145 - 1.146 - @Override 1.147 - public boolean isCellEditable(EventObject anEvent) { 1.148 - return true; 1.149 - } 1.150 - 1.151 - @Override 1.152 - public boolean shouldSelectCell(EventObject anEvent) { 1.153 - return true; 1.154 - } 1.155 - 1.156 - @Override 1.157 - public boolean stopCellEditing() { 1.158 - fireEditiaceSkončila(); 1.159 - return true; 1.160 - } 1.161 - 1.162 - @Override 1.163 - public void cancelCellEditing() { 1.164 - fireEditiaceZrušena(); 1.165 - } 1.166 - 1.167 - @Override 1.168 - public void addCellEditorListener(CellEditorListener l) { 1.169 - posluchače.add(CellEditorListener.class, l); 1.170 - } 1.171 - 1.172 - @Override 1.173 - public void removeCellEditorListener(CellEditorListener l) { 1.174 - posluchače.remove(CellEditorListener.class, l); 1.175 - } 1.176 -}