Changeset 32913 in osm
- Timestamp:
- 2016-09-03T17:06:49+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/tageditor
- Files:
-
- 1 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/TagEditorDialog.java
r32508 r32913 46 46 /** 47 47 * The dialog for editing name/value-pairs (aka <em>tags</em>) associated with {@link OsmPrimitive}s. 48 * 48 * 49 49 */ 50 50 @SuppressWarnings("serial") … … 57 57 /** 58 58 * Access to the singleton instance 59 * 59 * 60 60 * @return the singleton instance of the dialog 61 61 */ … … 91 91 protected JPanel buildButtonRow() { 92 92 JPanel pnl = new JPanel(new FlowLayout(FlowLayout.CENTER)); 93 93 94 94 // the ok button 95 95 // … … 108 108 // 109 109 tagEditor = new TagEditor(); 110 110 111 111 // create the auto completion list viewer and connect it 112 112 // to the tag editor … … 120 120 JPanel pnlTagGrid = new JPanel(); 121 121 pnlTagGrid.setLayout(new BorderLayout()); 122 123 122 123 124 124 pnlTagGrid.add(tagEditor, BorderLayout.CENTER); 125 125 pnlTagGrid.add(aclViewer, BorderLayout.EAST); 126 126 pnlTagGrid.setBorder(BorderFactory.createEmptyBorder(5, 0,0,0)); 127 127 128 128 JSplitPane splitPane = new JSplitPane( 129 129 JSplitPane.HORIZONTAL_SPLIT, 130 tagEditor, 130 tagEditor, 131 131 aclViewer 132 132 ); 133 133 splitPane.setOneTouchExpandable(false); 134 splitPane.setDividerLocation(600); 134 splitPane.setDividerLocation(600); 135 135 pnlTagGrid.add(splitPane, BorderLayout.CENTER); 136 136 return pnlTagGrid; 137 137 } 138 138 139 139 /** 140 140 * build the GUI … … 148 148 setSize(PREFERRED_SIZE); 149 149 setTitle(tr("JOSM Tag Editor Plugin")); 150 150 151 151 JPanel pnlTagGrid = buildTagGridPanel(); 152 152 … … 156 156 presetSelector.addPresetSelectorListener( 157 157 new IPresetSelectorListener() { 158 @Override 158 159 public void itemSelected(TaggingPreset item) { 159 160 tagEditor.stopEditing(); … … 174 175 tagSelector.addTagSelectorListener( 175 176 new ITagSelectorListener() { 177 @Override 176 178 public void itemSelected(KeyValuePair pair) { 177 179 tagEditor.stopEditing(); … … 192 194 tabbedPane.add(pnlTagSelector, tr("Tags")); 193 195 194 196 195 197 // create split pane 196 198 // 197 199 JSplitPane splitPane = new JSplitPane( 198 200 JSplitPane.VERTICAL_SPLIT, 199 tabbedPane, 201 tabbedPane, 200 202 pnlTagGrid 201 203 ); … … 216 218 @Override public void windowActivated(WindowEvent e) { 217 219 SwingUtilities.invokeLater(new Runnable(){ 220 @Override 218 221 public void run() 219 222 { … … 291 294 } 292 295 296 @Override 293 297 public void actionPerformed(ActionEvent arg0) { 294 298 setVisible(false); … … 305 309 } 306 310 311 @Override 307 312 public void actionPerformed(ActionEvent e) { 308 313 run(); … … 318 323 } 319 324 325 @Override 320 326 public void propertyChange(PropertyChangeEvent evt) { 321 327 if (! evt.getPropertyName().equals(TagEditorModel.PROP_DIRTY)) -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/ac/AutoCompletionListRenderer.java
r30703 r32913 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.tageditor.ac; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.awt.Component; … … 12 14 import javax.swing.UIManager; 13 15 import javax.swing.table.TableCellRenderer; 16 17 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPriority; 14 18 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem; 15 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPriority;16 import static org.openstreetmap.josm.tools.I18n.tr;17 19 18 20 /** 19 21 * This is the table cell renderer for the list of auto completion list items. 20 * 22 * 21 23 */ 22 24 public class AutoCompletionListRenderer extends JLabel implements TableCellRenderer { … … 66 68 /** 67 69 * prepares the renderer for rendering a specific icon 68 * 70 * 69 71 * @param item the item to be rendered 70 72 */ … … 101 103 } 102 104 105 @Override 103 106 public Component getTableCellRendererComponent(JTable table, Object value, 104 107 boolean isSelected, boolean hasFocus, int row, int column) { -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/PresetItemListCellRenderer.java
r31615 r32913 16 16 //private static final Logger logger = Logger.getLogger(PresetItemListCellRenderer.class.getName()); 17 17 18 @Override 18 19 public Component getListCellRendererComponent(JList<? extends TaggingPreset> list, TaggingPreset item, 19 20 int index, boolean isSelected, boolean cellHasFocus) { -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/PresetManager.java
r31615 r32913 41 41 42 42 presets.addItemListener( 43 new ItemListener(){ 43 new ItemListener() { 44 @Override 44 45 public void itemStateChanged(ItemEvent e) { 45 46 syncWidgetStates(); … … 53 54 btnHighlight = new JButton(tr("Highlight")); 54 55 btnHighlight.addActionListener( 55 new ActionListener() { 56 new ActionListener() { 57 @Override 56 58 public void actionPerformed(ActionEvent arg0) { 57 59 highlightCurrentPreset(); … … 65 67 btnRemove.addActionListener( 66 68 new ActionListener() { 69 @Override 67 70 public void actionPerformed(ActionEvent arg0) { 68 71 removeCurrentPreset(); -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagEditor.java
r31560 r32913 28 28 * <li>the main table with the tag names and tag values 29 29 * </ul> 30 * 30 * 31 31 * This component depends on a couple of other components which have to be 32 32 * injected with the respective setter methods: … … 47 47 * AutoCompletionCache autoCompletionCache = ... // init the auto completion cache 48 48 * TagEditorModel model = ... // init the tag editor model 49 * 49 * 50 50 * TagEditor tagEditor = new TagEditor(); 51 51 * tagEditor.setTagEditorModel(model); … … 61 61 private TagTable tblTagEditor; 62 62 private PresetManager presetManager; 63 63 64 64 /** 65 65 * builds the panel with the button row … … 83 83 return pnl; 84 84 } 85 85 86 86 public void addComponentNotStoppingCellEditing(Component c) { 87 87 tblTagEditor.addComponentNotStoppingCellEditing(c); 88 88 } 89 89 90 90 /** 91 91 * builds the GUI … … 96 96 DefaultListSelectionModel rowSelectionModel = new DefaultListSelectionModel(); 97 97 DefaultListSelectionModel colSelectionModel = new DefaultListSelectionModel(); 98 98 99 99 tagEditorModel = new TagEditorModel(rowSelectionModel,colSelectionModel); 100 100 101 101 // build the scrollable table for editing tag names and tag values 102 102 // … … 129 129 gc.anchor = GridBagConstraints.CENTER; 130 130 pnl.add(pnlTagTable,gc); 131 131 132 132 return pnl; 133 133 } 134 134 135 135 /** 136 136 * builds the GUI 137 * 137 * 138 138 */ 139 139 protected void build() { 140 140 setLayout(new BorderLayout()); 141 141 142 142 add(buildTagEditorPanel(), BorderLayout.CENTER); 143 143 … … 163 163 return tagEditorModel; 164 164 } 165 165 166 166 public void clearSelection() { 167 167 tblTagEditor.getSelectionModel().clearSelection(); … … 174 174 } 175 175 } 176 176 177 177 public void setAutoCompletionList(AutoCompletionList autoCompletionList) { 178 178 tblTagEditor.setAutoCompletionList(autoCompletionList); … … 183 183 } 184 184 185 @Override 185 186 public void autoCompletionItemSelected(String item) { 186 187 logger.info("autocompletion item selected ..."); … … 194 195 tblTagEditor.requestFocusInCell(0,0); 195 196 } 196 197 197 198 public TagEditorModel getModel() { 198 199 return tagEditorModel; -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagSpecificationAwareTagCellEditor.java
r31560 r32913 25 25 * values from the current JOSM data set. Keys already present in the 26 26 * current tag model are removed from the auto completion list. 27 * 27 * 28 28 * @param model the tag editor model 29 29 * @param currentTag the current tag 30 30 */ 31 protected void initAutoCompletionListForKeys(TagEditorModel model, TagModel currentTag) { 31 protected void initAutoCompletionListForKeys(TagEditorModel model, TagModel currentTag) { 32 32 if (getAutoCompletionList() == null) { 33 33 logger.warning("autoCompletionList is null. Make sure an instance of AutoCompletionList is injected into TableCellEditor."); … … 72 72 * set of standard values for a given key and the set of values present in the 73 73 * current data set for the given key. 74 * 74 * 75 75 * @param forKey the key 76 76 */ 77 @Override 77 78 protected void initAutoCompletionListForValues(String forKey) { 78 79 … … 83 84 autoCompletionList.clear(); 84 85 autocomplete.populateWithTagValues(autoCompletionList, forKey); 85 86 86 87 AutoCompletionContext context = new AutoCompletionContext(); 87 88 try { -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagTableCellRenderer.java
r31615 r32913 23 23 */ 24 24 public class TagTableCellRenderer extends JLabel implements TableCellRenderer { 25 25 26 26 //private static Logger logger = Logger.getLogger(TagTableCellRenderer.class.getName()); 27 27 public static final Color BG_COLOR_HIGHLIGHTED = new Color(255,255,204); 28 28 29 29 private Font fontStandard = null; 30 30 private Font fontItalic = null; 31 31 32 32 public TagTableCellRenderer() { 33 33 fontStandard = getFont(); … … 36 36 setBorder(new EmptyBorder(5,5,5,5)); 37 37 } 38 38 39 39 /** 40 40 * renders the name of a tag in the second column of 41 41 * the table 42 * 43 * @param tag the tag 42 * 43 * @param tag the tag 44 44 */ 45 45 protected void renderTagName(TagModel tag) { 46 46 setText(tag.getName()); 47 47 } 48 48 49 49 /** 50 * renders the value of a a tag in the third column of 50 * renders the value of a a tag in the third column of 51 51 * the table 52 * 53 * @param tag the tag 52 * 53 * @param tag the tag 54 54 */ 55 55 protected void renderTagValue(TagModel tag) { … … 63 63 } 64 64 } 65 65 66 66 /** 67 * resets the renderer 67 * resets the renderer 68 68 */ 69 69 protected void resetRenderer() { … … 72 72 setFont(fontStandard); 73 73 } 74 74 75 75 protected TagEditorModel getModel(JTable table) { 76 76 return (TagEditorModel)table.getModel(); 77 77 } 78 78 79 79 protected boolean belongsToSelectedPreset(TagModel tagModel, TagEditorModel model) { 80 80 81 81 // current tag is empty or consists of whitespace only => can't belong to 82 82 // a selected preset … … 85 85 return false; 86 86 } 87 88 // no current preset selected? 87 88 // no current preset selected? 89 89 // 90 90 TaggingPreset item = (TaggingPreset)model.getAppliedPresetsModel().getSelectedItem(); … … 92 92 return false; 93 93 } 94 94 95 95 for(AdvancedTag tag: AdvancedTag.forTaggingPreset(item)) { 96 96 if (tag.getValue() == null) { 97 97 if (tagModel.getName().equals(tag.getKey())) { 98 return true; 98 return true; 99 99 } 100 100 } else { 101 101 if (tagModel.getName().equals(tag.getKey()) 102 102 && tagModel.getValue().equals(tag.getValue())) { 103 return true; 103 return true; 104 104 } 105 105 } 106 } 106 } 107 107 return false; 108 108 } 109 109 110 110 /** 111 111 * renders the background color. The default color is white. It is 112 112 * set to {@see TableCellRenderer#BG_COLOR_HIGHLIGHTED} if this cell 113 * displays the tag which is suggested by the currently selected 113 * displays the tag which is suggested by the currently selected 114 114 * preset. 115 * 116 * @param tagModel the tag model 117 * @param model the tag editor model 115 * 116 * @param tagModel the tag model 117 * @param model the tag editor model 118 118 */ 119 119 protected void renderColor(TagModel tagModel, TagEditorModel model, boolean isSelected) { … … 124 124 setBackground(UIManager.getColor("Table.background")); 125 125 setForeground(UIManager.getColor("Table.foreground")); 126 } 126 } 127 127 if (belongsToSelectedPreset(tagModel, model)) { 128 128 setBackground(BG_COLOR_HIGHLIGHTED); 129 129 } 130 130 } 131 131 132 132 /** 133 * replies the cell renderer component for a specific cell 134 * 133 * replies the cell renderer component for a specific cell 134 * 135 135 * @param table the table 136 136 * @param value the value to be rendered 137 * @param isSelected true, if the value is selected 138 * @param hasFocus true, if the cell has focus 139 * @param rowIndex the row index 140 * @param vColIndex the column index 141 * 142 * @return the renderer component 137 * @param isSelected true, if the value is selected 138 * @param hasFocus true, if the cell has focus 139 * @param rowIndex the row index 140 * @param vColIndex the column index 141 * 142 * @return the renderer component 143 143 */ 144 @Override 144 145 public Component getTableCellRendererComponent(JTable table, Object value, 145 146 boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) { 146 147 147 148 resetRenderer(); 148 149 TagModel tagModel = (TagModel)value; 149 switch(vColIndex) { 150 switch(vColIndex) { 150 151 case 0: renderTagName(tagModel); break; 151 152 case 1: renderTagValue(tagModel); break; -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/ui/NameIconCellRenderer.java
r31615 r32913 14 14 public class NameIconCellRenderer extends JLabel implements TableCellRenderer { 15 15 16 //private static Logger logger = Logger.getLogger(NameIconCellRenderer.class.getName());17 16 public static final Color BG_COLOR_SELECTED = new Color(143,170,255); 18 17 … … 26 25 } 27 26 27 @Override 28 28 public Component getTableCellRendererComponent(JTable table, Object value, 29 29 boolean isSelected, boolean hasFocus, int rowIndex, int colIndex) { -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/ui/PresetsTableModel.java
r31615 r32913 53 53 } 54 54 55 @Override 55 56 public int getColumnCount() { 56 57 return 2; 57 58 } 58 59 60 @Override 59 61 public int getRowCount() { 60 62 return visibleItems.size(); 61 63 } 62 64 65 @Override 63 66 public Object getValueAt(int rowIndex, int columnIndex) { 64 67 TaggingPreset item = visibleItems.get(rowIndex); -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/ui/TabularPresetSelector.java
r31615 r32913 55 55 btn.addActionListener( 56 56 new ActionListener() { 57 @Override 57 58 public void actionPerformed(ActionEvent e) { 58 59 tfFilter.setText(""); … … 95 96 presetsTable.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0)); 96 97 ActionListener enterAction = new ActionListener() { 98 @Override 97 99 public void actionPerformed(ActionEvent e) { 98 100 int rowNum = presetsTable.getSelectedRow(); … … 120 122 btnApply.addActionListener( 121 123 new ActionListener() { 124 @Override 122 125 public void actionPerformed(ActionEvent arg0) { 123 126 int row = presetsTable.getSelectedRow(); … … 141 144 tfFilter.getDocument().addDocumentListener( 142 145 new DocumentListener() { 146 @Override 143 147 public void changedUpdate(DocumentEvent arg0) { 144 148 onUpdate(); 145 149 } 146 150 151 @Override 147 152 public void insertUpdate(DocumentEvent arg0) { 148 153 onUpdate(); 149 154 } 150 155 156 @Override 151 157 public void removeUpdate(DocumentEvent arg0) { 152 158 onUpdate(); … … 161 167 tfFilter.addActionListener( 162 168 new ActionListener() { 169 @Override 163 170 public void actionPerformed(ActionEvent e) { 164 171 filter(tfFilter.getText()); … … 171 178 presetsTable.getSelectionModel().addListSelectionListener( 172 179 new ListSelectionListener() { 180 @Override 173 181 public void valueChanged(ListSelectionEvent e) { 174 182 btnApply.setEnabled(presetsTable.getSelectedRowCount() != 0); -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/TagSpecifications.java
r30738 r32913 74 74 } 75 75 try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { 76 77 78 76 TagSpecifications spec = new TagSpecifications(); 77 spec.load(reader); 78 instance = spec; 79 79 } 80 80 } … … 350 350 } 351 351 352 class ResourceEntityResolver implements EntityResolver { 352 static class ResourceEntityResolver implements EntityResolver { 353 353 354 354 @Override … … 366 366 } 367 367 368 static public void main(String args[]) throws Exception{368 public static void main(String args[]) throws Exception{ 369 369 TagSpecifications.loadFromResources(); 370 370 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/KeyValueCellRenderer.java
r30488 r32913 12 12 public class KeyValueCellRenderer extends JLabel implements TableCellRenderer { 13 13 14 //private static final Logger logger = Logger.getLogger(KeyValueCellRenderer.class.getName());15 16 14 protected void init() { 17 15 setFont(new Font("Courier",Font.PLAIN,getFont().getSize())); … … 23 21 } 24 22 23 @Override 25 24 public Component getTableCellRendererComponent(JTable table, Object value, 26 25 boolean isSelected, boolean hasFocus, int rowIndex, int colIndex) { -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/TabularTagSelector.java
r30737 r32913 51 51 btn.addActionListener( 52 52 new ActionListener() { 53 @Override 53 54 public void actionPerformed(ActionEvent e) { 54 55 tfFilter.setText(""); … … 92 93 tagsTable.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0)); 93 94 ActionListener enterAction = new ActionListener() { 95 @Override 94 96 public void actionPerformed(ActionEvent e) { 95 97 int rowNum = tagsTable.getSelectedRow(); … … 118 120 btnApply.addActionListener( 119 121 new ActionListener() { 122 @Override 120 123 public void actionPerformed(ActionEvent arg0) { 121 124 int row = tagsTable.getSelectedRow(); … … 141 144 tfFilter.getDocument().addDocumentListener( 142 145 new DocumentListener() { 146 @Override 143 147 public void changedUpdate(DocumentEvent arg0) { 144 148 onUpdate(); 145 149 } 146 150 151 @Override 147 152 public void insertUpdate(DocumentEvent arg0) { 148 153 onUpdate(); 149 154 } 150 155 156 @Override 151 157 public void removeUpdate(DocumentEvent arg0) { 152 158 onUpdate(); … … 161 167 tfFilter.addActionListener( 162 168 new ActionListener() { 169 @Override 163 170 public void actionPerformed(ActionEvent e) { 164 171 filter(tfFilter.getText()); … … 171 178 tagsTable.getSelectionModel().addListSelectionListener( 172 179 new ListSelectionListener() { 180 @Override 173 181 public void valueChanged(ListSelectionEvent e) { 174 182 btnApply.setEnabled(tagsTable.getSelectedRowCount() != 0); … … 177 185 ); 178 186 179 180 187 // load the set of presets and bind them to the preset table 181 188 // 182 189 tagsTable.getSelectionModel().clearSelection(); 183 190 btnApply.setEnabled(false); 184 185 191 } 186 192 … … 188 194 build(); 189 195 } 190 191 196 192 197 public void filter(String filter) { -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/TagsTableModel.java
r30737 r32913 31 31 items, 32 32 new Comparator<KeyValuePair>() { 33 @Override 33 34 public int compare(KeyValuePair self, 34 35 KeyValuePair other) { … … 67 68 } 68 69 70 @Override 69 71 public int getColumnCount() { 70 72 return 2; 71 73 } 72 74 75 @Override 73 76 public int getRowCount() { 74 77 return visibleItems.size(); 75 78 } 76 79 80 @Override 77 81 public Object getValueAt(int row, int col) { 78 82 KeyValuePair pair = visibleItems.get(row);
Note:
See TracChangeset
for help on using the changeset viewer.