Changeset 32959 in osm for applications/editors
- Timestamp:
- 2016-09-08T23:59:12+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/tageditor
- Files:
-
- 1 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/tageditor/.project
r32286 r32959 16 16 </arguments> 17 17 </buildCommand> 18 <buildCommand> 19 <name>net.sf.eclipsecs.core.CheckstyleBuilder</name> 20 <arguments> 21 </arguments> 22 </buildCommand> 18 23 </buildSpec> 19 24 <natures> 20 25 <nature>org.eclipse.jdt.core.javanature</nature> 26 <nature>net.sf.eclipsecs.core.CheckstyleNature</nature> 21 27 </natures> 22 28 </projectDescription> -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/LaunchAction.java
r30488 r32959 16 16 public class LaunchAction extends JosmAction implements SelectionChangedListener { 17 17 18 public LaunchAction() 18 public LaunchAction() { 19 19 super( 20 20 tr("Edit tags"), 21 (String) null, //TODO: set "tag-editor" and add /images/tag-editor.png to distrib21 (String) null, //TODO: set "tag-editor" and add /images/tag-editor.png to distrib 22 22 tr("Launches the tag editor dialog"), 23 23 Shortcut.registerShortcut("edit:launchtageditor", tr("Launches the tag editor dialog"), 24 KeyEvent.VK_1, Shortcut.ALT_SHIFT)25 ,true, "tageditor/launch", true);24 KeyEvent.VK_1, Shortcut.ALT_SHIFT), 25 true, "tageditor/launch", true); 26 26 27 27 DataSet.addSelectionListener(this); … … 47 47 @Override 48 48 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 49 setEnabled(newSelection != null && newSelection.size() > 0);49 setEnabled(newSelection != null && newSelection.size() > 0); 50 50 } 51 51 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/TagEditorDialog.java
r32913 r32959 53 53 54 54 /** the unique instance */ 55 static privateTagEditorDialog instance = null;55 private static TagEditorDialog instance = null; 56 56 57 57 /** … … 60 60 * @return the singleton instance of the dialog 61 61 */ 62 static public TagEditorDialog getInstance() {62 public static TagEditorDialog getInstance() { 63 63 if (instance == null) { 64 64 instance = new TagEditorDialog(); … … 68 68 69 69 /** default preferred size */ 70 static public final Dimension PREFERRED_SIZE = new Dimension(700, 500);70 public static final Dimension PREFERRED_SIZE = new Dimension(700, 500); 71 71 72 72 /** the properties table */ … … 99 99 // the cancel button 100 100 // 101 pnl.add(new JButton(cancelAction 101 pnl.add(new JButton(cancelAction = new CancelAction())); 102 102 return pnl; 103 103 } … … 124 124 pnlTagGrid.add(tagEditor, BorderLayout.CENTER); 125 125 pnlTagGrid.add(aclViewer, BorderLayout.EAST); 126 pnlTagGrid.setBorder(BorderFactory.createEmptyBorder(5, 0, 0,0));126 pnlTagGrid.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); 127 127 128 128 JSplitPane splitPane = new JSplitPane( … … 167 167 JPanel pnlPresetSelector = new JPanel(); 168 168 pnlPresetSelector.setLayout(new BorderLayout()); 169 pnlPresetSelector.add(presetSelector, BorderLayout.CENTER);170 pnlPresetSelector.setBorder(BorderFactory.createEmptyBorder(0, 0,5,0));169 pnlPresetSelector.add(presetSelector, BorderLayout.CENTER); 170 pnlPresetSelector.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); 171 171 172 172 // create the tag selector … … 185 185 JPanel pnlTagSelector = new JPanel(); 186 186 pnlTagSelector.setLayout(new BorderLayout()); 187 pnlTagSelector.add(tagSelector, BorderLayout.CENTER);188 pnlTagSelector.setBorder(BorderFactory.createEmptyBorder(0, 0,5,0));187 pnlTagSelector.add(tagSelector, BorderLayout.CENTER); 188 pnlTagSelector.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); 189 189 190 190 // create the tabbed pane … … 209 209 pnlTagGrid.setMinimumSize(minimumSize); 210 210 211 getContentPane().add(splitPane, BorderLayout.CENTER);211 getContentPane().add(splitPane, BorderLayout.CENTER); 212 212 213 213 getContentPane().add(buildButtonRow(), BorderLayout.SOUTH); … … 217 217 new WindowAdapter() { 218 218 @Override public void windowActivated(WindowEvent e) { 219 SwingUtilities.invokeLater(new Runnable() {219 SwingUtilities.invokeLater(new Runnable() { 220 220 @Override 221 public void run() 222 { 221 public void run() { 223 222 getModel().ensureOneTag(); 224 223 tagEditor.clearSelection(); … … 233 232 // and in the aclViewer is handled by okAction 234 233 // 235 getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put((KeyStroke)cancelAction.getValue(Action.ACCELERATOR_KEY), okAction.getValue(AbstractAction.NAME)); 234 getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 235 (KeyStroke) cancelAction.getValue(Action.ACCELERATOR_KEY), okAction.getValue(AbstractAction.NAME)); 236 236 getRootPane().getActionMap().put(cancelAction.getValue(Action.NAME), cancelAction); 237 237 238 getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put((KeyStroke)okAction.getValue(Action.ACCELERATOR_KEY), okAction.getValue(AbstractAction.NAME)); 238 getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 239 (KeyStroke) okAction.getValue(Action.ACCELERATOR_KEY), okAction.getValue(AbstractAction.NAME)); 239 240 getRootPane().getActionMap().put(okAction.getValue(Action.NAME), okAction); 240 241 … … 287 288 288 289 class CancelAction extends AbstractAction { 289 publicCancelAction() {290 CancelAction() { 290 291 putValue(NAME, tr("Cancel")); 291 292 putValue(SMALL_ICON, ImageProvider.get("cancel")); 292 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));293 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)); 293 294 putValue(SHORT_DESCRIPTION, tr("Abort tag editing and close dialog")); 294 295 } … … 302 303 class OKAction extends AbstractAction implements PropertyChangeListener { 303 304 304 publicOKAction() {305 OKAction() { 305 306 putValue(NAME, tr("OK")); 306 307 putValue(SMALL_ICON, ImageProvider.get("ok")); … … 325 326 @Override 326 327 public void propertyChange(PropertyChangeEvent evt) { 327 if (! 328 if (!evt.getPropertyName().equals(TagEditorModel.PROP_DIRTY)) 328 329 return; 329 if (! 330 if (!evt.getNewValue().getClass().equals(Boolean.class)) 330 331 return; 331 boolean dirty = (Boolean) evt.getNewValue();332 boolean dirty = (Boolean) evt.getNewValue(); 332 333 setEnabled(dirty); 333 334 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/ac/AutoCompletionListRenderer.java
r32913 r32959 24 24 public class AutoCompletionListRenderer extends JLabel implements TableCellRenderer { 25 25 26 static public final String RES_OSM_ICON = "/resources/osm.png";27 static public final String RES_SELECTION_ICON = "/resources/selection.png";26 public static final String RES_OSM_ICON = "/resources/osm.png"; 27 public static final String RES_SELECTION_ICON = "/resources/selection.png"; 28 28 29 29 /** the icon used to decorate items of priority … … 111 111 // 112 112 if (value instanceof AutoCompletionListItem) { 113 AutoCompletionListItem item = (AutoCompletionListItem) value;113 AutoCompletionListItem item = (AutoCompletionListItem) value; 114 114 prepareRendererIcon(item); 115 115 setText(item.getValue()); -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/ac/AutoCompletionListViewer.java
r30737 r32959 22 22 23 23 public class AutoCompletionListViewer extends JPanel { 24 24 25 25 //static private Logger logger = Logger.getLogger(AutoCompletionListViewer.class.getName()); 26 26 27 27 /** the table showing the auto completion list entries */ 28 28 private JTable table = null; 29 29 30 30 /** the auto completion list to be displayed */ 31 31 private AutoCompletionList autoCompletionList = null; 32 32 33 33 /** the listeners */ 34 34 private ArrayList<IAutoCompletionListListener> listener = null; 35 35 36 36 /** 37 * creates the GUI 37 * creates the GUI 38 38 */ 39 39 protected void createGUI() { 40 40 setBackground(Color.WHITE); 41 41 setLayout(new BorderLayout()); 42 42 43 43 table = new JTable(); 44 44 45 45 // the table model 46 46 // … … 52 52 table.setModel(autoCompletionList); 53 53 } 54 55 // no table header required 54 55 // no table header required 56 56 table.setTableHeader(null); 57 58 // set cell renderer 57 58 // set cell renderer 59 59 // 60 60 table.setDefaultRenderer(Object.class, new AutoCompletionListRenderer()); 61 62 // embed in a scroll pane 63 JScrollPane p 61 62 // embed in a scroll pane 63 JScrollPane p = new JScrollPane(table); 64 64 p.setBackground(Color.WHITE); 65 65 add(p, BorderLayout.CENTER); 66 66 67 67 // only single selection allowed 68 68 // 69 69 table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 70 70 71 71 // fire item change event on double click 72 72 // … … 80 80 fireAutoCompletionListItemSelected(item); 81 81 } 82 } 82 } 83 83 } 84 84 ); 85 85 } 86 86 87 87 /** 88 * constructor 89 * 88 * constructor 89 * 90 90 * @param list the auto completion list to be rendered. If null, the list is empty. 91 * 91 * 92 92 */ 93 public AutoCompletionListViewer(AutoCompletionList list) { 93 public AutoCompletionListViewer(AutoCompletionList list) { 94 94 this.autoCompletionList = list; 95 95 createGUI(); 96 96 listener = new ArrayList<>(); 97 97 } 98 98 99 99 /** 100 * constructor 100 * constructor 101 101 */ 102 102 public AutoCompletionListViewer() { … … 107 107 108 108 /** 109 * 109 * 110 110 */ 111 @Override public Dimension getMaximumSize() { 111 @Override public Dimension getMaximumSize() { 112 112 Dimension d = super.getMaximumSize(); 113 113 d.width = 100; 114 114 return d; 115 115 } 116 116 117 117 /** 118 * 118 * 119 119 */ 120 @Override public Dimension getPreferredSize() { 120 @Override public Dimension getPreferredSize() { 121 121 Dimension d = super.getMaximumSize(); 122 122 d.width = 150; … … 127 127 /** 128 128 * replies the auto completion list this viewer renders 129 * 130 * @return the auto completion list; may be null 129 * 130 * @return the auto completion list; may be null 131 131 */ 132 132 public AutoCompletionList getAutoCompletionList() { … … 136 136 137 137 /** 138 * sets the auto completion list this viewer renders 139 * 138 * sets the auto completion list this viewer renders 139 * 140 140 * @param autoCompletionList the auto completion list; may be null 141 141 */ … … 148 148 } 149 149 } 150 150 151 151 /** 152 152 * add an {@link IAutoCompletionListListener} 153 * 154 * @param listener the listener 153 * 154 * @param listener the listener 155 155 */ 156 156 public void addAutoCompletionListListener(IAutoCompletionListListener listener) { 157 157 if (listener != null && !this.listener.contains(listener)) { 158 synchronized (this.listener) {158 synchronized (this.listener) { 159 159 this.listener.add(listener); 160 160 } 161 161 } 162 162 } 163 163 164 164 /** 165 * removes a {@link IAutoCompletionListListener} 166 * 167 * @param listener the listener 165 * removes a {@link IAutoCompletionListListener} 166 * 167 * @param listener the listener 168 168 */ 169 169 public void removeAutoCompletionListListener(IAutoCompletionListListener listener) { 170 170 if (listener != null && this.listener.contains(listener)) { 171 synchronized (this.listener) {171 synchronized (this.listener) { 172 172 this.listener.remove(listener); 173 173 } 174 174 } 175 175 } 176 176 177 177 /** 178 * notifies listeners about a selected item in the auto completion list 178 * notifies listeners about a selected item in the auto completion list 179 179 */ 180 180 protected void fireAutoCompletionListItemSelected(String item) { 181 synchronized (this.listener) {181 synchronized (this.listener) { 182 182 for (IAutoCompletionListListener target: listener) { 183 183 target.autoCompletionItemSelected(item); 184 } 184 } 185 185 } 186 } 187 186 } 187 188 188 public void installKeyAction(Action a) { 189 getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put((KeyStroke)a.getValue(AbstractAction.ACCELERATOR_KEY), a.getValue(AbstractAction.NAME)); 189 getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 190 (KeyStroke) a.getValue(AbstractAction.ACCELERATOR_KEY), a.getValue(AbstractAction.NAME)); 190 191 getActionMap().put(a.getValue(AbstractAction.NAME), a); 191 192 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/ac/IAutoCompletionListListener.java
r30488 r32959 3 3 4 4 public interface IAutoCompletionListListener { 5 publicvoid autoCompletionItemSelected(String item);5 void autoCompletionItemSelected(String item); 6 6 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/PresetManager.java
r32913 r32959 66 66 btnRemove = new JButton(tr("Remove")); 67 67 btnRemove.addActionListener( 68 new ActionListener() 68 new ActionListener() { 69 69 @Override 70 70 public void actionPerformed(ActionEvent arg0) { … … 84 84 85 85 protected void removeCurrentPreset() { 86 TaggingPreset item = (TaggingPreset)presets.getSelectedItem();87 if (item != null && model != null) {86 TaggingPreset item = (TaggingPreset) presets.getSelectedItem(); 87 if (item != null && model != null) { 88 88 model.removeAppliedPreset(item); 89 89 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagEditor.java
r32913 r32959 74 74 JButton btn; 75 75 pnl.add(btn = new JButton(tblTagEditor.getAddAction())); 76 btn.setMargin(new Insets(0, 0,0,0));76 btn.setMargin(new Insets(0, 0, 0, 0)); 77 77 tblTagEditor.addComponentNotStoppingCellEditing(btn); 78 78 79 79 // delete action 80 80 pnl.add(btn = new JButton(tblTagEditor.getDeleteAction())); 81 btn.setMargin(new Insets(0, 0,0,0));81 btn.setMargin(new Insets(0, 0, 0, 0)); 82 82 tblTagEditor.addComponentNotStoppingCellEditing(btn); 83 83 return pnl; … … 97 97 DefaultListSelectionModel colSelectionModel = new DefaultListSelectionModel(); 98 98 99 tagEditorModel = new TagEditorModel(rowSelectionModel, colSelectionModel);99 tagEditorModel = new TagEditorModel(rowSelectionModel, colSelectionModel); 100 100 101 101 // build the scrollable table for editing tag names and tag values … … 119 119 gc.weighty = 1.0; 120 120 gc.anchor = GridBagConstraints.NORTHWEST; 121 pnl.add(buildButtonsPanel(), gc);121 pnl.add(buildButtonsPanel(), gc); 122 122 123 123 // -- the panel with the editor table … … 128 128 gc.weighty = 1.0; 129 129 gc.anchor = GridBagConstraints.CENTER; 130 pnl.add(pnlTagTable, gc);130 pnl.add(pnlTagTable, gc); 131 131 132 132 return pnl; … … 186 186 public void autoCompletionItemSelected(String item) { 187 187 logger.info("autocompletion item selected ..."); 188 TagSpecificationAwareTagCellEditor editor = (TagSpecificationAwareTagCellEditor) tblTagEditor.getCellEditor();188 TagSpecificationAwareTagCellEditor editor = (TagSpecificationAwareTagCellEditor) tblTagEditor.getCellEditor(); 189 189 if (editor != null) { 190 190 editor.autoCompletionItemSelected(item); … … 193 193 194 194 public void requestFocusInTopLeftCell() { 195 tblTagEditor.requestFocusInCell(0, 0);195 tblTagEditor.requestFocusInCell(0, 0); 196 196 } 197 197 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagEditorModel.java
r32508 r32959 20 20 21 21 @SuppressWarnings("serial") 22 public class TagEditorModel extends org.openstreetmap.josm.gui.tagging.TagEditorModel 22 public class TagEditorModel extends org.openstreetmap.josm.gui.tagging.TagEditorModel { 23 23 //static private final Logger logger = Logger.getLogger(TagEditorModel.class.getName()); 24 24 25 25 private DefaultComboBoxModel<TaggingPreset> appliedPresets = null; 26 26 … … 28 28 * constructor 29 29 */ 30 public TagEditorModel(DefaultListSelectionModel rowSelectionModel, DefaultListSelectionModel colSelectionModel) {30 public TagEditorModel(DefaultListSelectionModel rowSelectionModel, DefaultListSelectionModel colSelectionModel) { 31 31 super(rowSelectionModel, colSelectionModel); 32 32 appliedPresets = new DefaultComboBoxModel<>(); … … 35 35 /** 36 36 * applies the tags defined for a preset item to the tag model. 37 * 37 * 38 38 * Mandatory tags are added to the list of currently edited tags. 39 39 * Optional tags are not added. 40 40 * The model remembers the currently applied presets. 41 * 41 * 42 42 * @param item the preset item. Must not be null. 43 43 * @exception IllegalArgumentException thrown, if item is null 44 * 44 * 45 45 */ 46 46 public void applyPreset(TaggingPreset item) { … … 49 49 // check whether item is already applied 50 50 // 51 for (int i=0; i < appliedPresets.getSize(); i++) {51 for (int i = 0; i < appliedPresets.getSize(); i++) { 52 52 if (appliedPresets.getElementAt(i).equals(item)) 53 53 // abort - preset already applied … … 57 57 // apply the tags proposed by the preset 58 58 // 59 for (AdvancedTag tag : AdvancedTag.forTaggingPreset(item)) {59 for (AdvancedTag tag : AdvancedTag.forTaggingPreset(item)) { 60 60 if (!tag.isOptional()) { 61 61 if (!includesTag(tag.getKey())) { 62 TagModel tagModel = new TagModel(tag.getKey(), tag.getValue());62 TagModel tagModel = new TagModel(tag.getKey(), tag.getValue()); 63 63 prepend(tagModel); 64 64 } else { … … 85 85 /** 86 86 * applies a tag given by a {@see KeyValuePair} to the model 87 * 87 * 88 88 * @param pair the key value pair 89 89 */ … … 98 98 fireTableDataChanged(); 99 99 } 100 101 100 102 101 public DefaultComboBoxModel<TaggingPreset> getAppliedPresetsModel() { … … 140 139 fireTableDataChanged(); 141 140 } 142 141 143 142 /** 144 143 * updates the tags of the primitives in the current selection with the 145 144 * values in the current tag model 146 * 145 * 147 146 */ 148 147 public void updateJOSMSelection() { … … 152 151 return; 153 152 for (TagModel tag : tags) { 154 Command command = createUpdateTagCommand(selection, tag);153 Command command = createUpdateTagCommand(selection, tag); 155 154 if (command != null) { 156 155 commands.add(command); … … 170 169 Main.main.undoRedo.add(command); 171 170 } 172 171 173 172 /** 174 173 * initializes the model with the tags in the current JOSM selection … … 180 179 for (String key : element.keySet()) { 181 180 String value = element.get(key); 182 add(key, value);181 add(key, value); 183 182 } 184 183 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagSpecificationAwareTagCellEditor.java
r32913 r32959 2 2 package org.openstreetmap.josm.plugins.tageditor.editor; 3 3 4 import java.util.logging.Level;5 4 import java.util.logging.Logger; 6 5 … … 16 15 17 16 public TagSpecificationAwareTagCellEditor() { 18 19 17 super(0); 18 } 20 19 21 20 /** 22 21 * initializes the auto completion list when the table cell editor starts 23 22 * to edit the key of a tag. In this case the auto completion list is … … 39 38 // add the list of standard keys 40 39 // 41 try {42 //autoCompletionList.add(TagSpecifications.getInstance().getKeysForAutoCompletion(context));43 } catch (Exception e) {40 /*try { 41 autoCompletionList.add(TagSpecifications.getInstance().getKeysForAutoCompletion(context)); 42 } catch (Exception e) { 44 43 logger.log(Level.WARNING, "failed to initialize auto completion list with standard keys.", e); 45 } 44 }*/ 46 45 47 46 // add the list of keys in the current data set … … 52 51 context.initFromJOSMSelection(); 53 52 autoCompletionList.add(TagSpecifications.getInstance().getKeysForAutoCompletion(context)); 54 } catch (Exception e) {53 } catch (Exception e) { 55 54 System.out.println("Warning: failed to initialize auto completion list with tag specification keys. Exception was: " + e.toString()); 56 55 e.printStackTrace(); … … 60 59 // 61 60 for (String key : model.getKeys()) { 62 if (! 61 if (!key.equals(currentTag.getName())) { 63 62 autoCompletionList.remove(key); 64 63 } … … 89 88 context.initFromJOSMSelection(); 90 89 autoCompletionList.add(TagSpecifications.getInstance().getLabelsForAutoCompletion(forKey, context)); 91 } catch(Exception e) { 92 System.out.println("Warning: failed to initialize auto completion list with tag specification values. Exception was: " + e.toString()); 90 } catch (Exception e) { 91 System.out.println( 92 "Warning: failed to initialize auto completion list with tag specification values. Exception was: " + e.toString()); 93 93 e.printStackTrace(); 94 94 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagTableCellRenderer.java
r32913 r32959 22 22 * in the tag editor dialog. 23 23 */ 24 public class TagTableCellRenderer extends JLabel implements TableCellRenderer 24 public class TagTableCellRenderer extends JLabel implements TableCellRenderer { 25 25 26 26 //private static Logger logger = Logger.getLogger(TagTableCellRenderer.class.getName()); 27 public static final Color BG_COLOR_HIGHLIGHTED = new Color(255, 255,204);27 public static final Color BG_COLOR_HIGHLIGHTED = new Color(255, 255, 204); 28 28 29 29 private Font fontStandard = null; … … 34 34 fontItalic = fontStandard.deriveFont(Font.ITALIC); 35 35 setOpaque(true); 36 setBorder(new EmptyBorder(5, 5,5,5));36 setBorder(new EmptyBorder(5, 5, 5, 5)); 37 37 } 38 38 … … 58 58 } else if (tag.getValueCount() == 1) { 59 59 setText(tag.getValues().get(0)); 60 } else if (tag.getValueCount() > 60 } else if (tag.getValueCount() > 1) { 61 61 setText(tr("multiple")); 62 62 setFont(fontItalic); … … 74 74 75 75 protected TagEditorModel getModel(JTable table) { 76 return (TagEditorModel) table.getModel();76 return (TagEditorModel) table.getModel(); 77 77 } 78 78 … … 88 88 // no current preset selected? 89 89 // 90 TaggingPreset item = (TaggingPreset) model.getAppliedPresetsModel().getSelectedItem();90 TaggingPreset item = (TaggingPreset) model.getAppliedPresetsModel().getSelectedItem(); 91 91 if (item == null) { 92 92 return false; 93 93 } 94 94 95 for (AdvancedTag tag: AdvancedTag.forTaggingPreset(item)) {95 for (AdvancedTag tag: AdvancedTag.forTaggingPreset(item)) { 96 96 if (tag.getValue() == null) { 97 97 if (tagModel.getName().equals(tag.getKey())) { … … 118 118 */ 119 119 protected void renderColor(TagModel tagModel, TagEditorModel model, boolean isSelected) { 120 if (isSelected) {120 if (isSelected) { 121 121 setBackground(UIManager.getColor("Table.selectionBackground")); 122 122 setForeground(UIManager.getColor("Table.selectionForeground")); … … 147 147 148 148 resetRenderer(); 149 TagModel tagModel = (TagModel)value;149 TagModel tagModel = (TagModel) value; 150 150 switch(vColIndex) { 151 151 case 0: renderTagName(tagModel); break; 152 152 case 1: renderTagValue(tagModel); break; 153 153 } 154 renderColor(tagModel, (TagEditorModel) table.getModel(),isSelected);154 renderColor(tagModel, (TagEditorModel) table.getModel(), isSelected); 155 155 if (hasFocus && isSelected) { 156 156 if (table.getSelectedColumnCount() == 1 && table.getSelectedRowCount() == 1) { -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/AdvancedTag.java
r31615 r32959 48 48 this.optional = optional; 49 49 } 50 50 51 51 public static Collection<AdvancedTag> forTaggingPreset(TaggingPreset preset) { 52 52 Collection<AdvancedTag> result = new ArrayList<>(); … … 54 54 for (TaggingPresetItem item : preset.data) { 55 55 if (item instanceof KeyedItem) { 56 KeyedItem ki = (KeyedItem) item;56 KeyedItem ki = (KeyedItem) item; 57 57 for (String value : ki.getValues()) { 58 58 AdvancedTag tag = new AdvancedTag(ki.key, value); -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/ui/IPresetSelectorListener.java
r31615 r32959 6 6 public interface IPresetSelectorListener { 7 7 8 publicvoid itemSelected(TaggingPreset item);8 void itemSelected(TaggingPreset item); 9 9 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/ui/NameIconCellRenderer.java
r32913 r32959 14 14 public class NameIconCellRenderer extends JLabel implements TableCellRenderer { 15 15 16 public static final Color BG_COLOR_SELECTED = new Color(143, 170,255);16 public static final Color BG_COLOR_SELECTED = new Color(143, 170, 255); 17 17 18 18 protected void init() { 19 19 setOpaque(true); 20 setFont(new Font("SansSerif", Font.PLAIN,10));20 setFont(new Font("SansSerif", Font.PLAIN, 10)); 21 21 } 22 22 … … 31 31 if (isSelected) { 32 32 setBackground(BG_COLOR_SELECTED); 33 } else 33 } else { 34 34 setBackground(Color.WHITE); 35 35 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/ui/PresetsTable.java
r30488 r32959 10 10 11 11 /** 12 * initialize the table 12 * initialize the table 13 13 */ 14 protected void init() { 15 setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 14 protected void init() { 15 setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 16 16 setRowSelectionAllowed(true); 17 17 setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 18 18 setRowHeight(18); // icon height (=16) + minimal border 19 19 } 20 20 21 21 public PresetsTable(TableModel model, TableColumnModel columnModel) { 22 super(model, columnModel);22 super(model, columnModel); 23 23 init(); 24 24 } 25 25 26 26 /** 27 27 * adjusts the width of the columns for the tag name and the tag value 28 28 * to the width of the scroll panes viewport. 29 * 29 * 30 30 * Note: {@see #getPreferredScrollableViewportSize()} did not work as expected 31 * 31 * 32 32 * @param scrollPaneWidth the width of the scroll panes viewport 33 33 */ … … 40 40 tcm.getColumn(0).setMaxWidth(width); 41 41 tcm.getColumn(1).setMinWidth(width); 42 tcm.getColumn(1).setMaxWidth(width); 42 tcm.getColumn(1).setMaxWidth(width); 43 43 } 44 44 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/ui/PresetsTableModel.java
r32913 r32959 10 10 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 11 11 12 public class PresetsTableModel extends AbstractTableModel 12 public class PresetsTableModel extends AbstractTableModel { 13 13 14 14 //private static final Logger logger = Logger.getLogger(PresetsTableModel.class.getName()); … … 39 39 @Override 40 40 public void addTableModelListener(TableModelListener l) { 41 synchronized (listeners) {41 synchronized (listeners) { 42 42 if (l == null) 43 43 return; … … 99 99 100 100 public void filter(String filter) { 101 synchronized (this) {101 synchronized (this) { 102 102 if (filter == null || filter.trim().equals("")) { 103 103 visibleItems.clear(); 104 for (TaggingPreset item: items) {104 for (TaggingPreset item: items) { 105 105 visibleItems.add(item); 106 106 } … … 108 108 visibleItems.clear(); 109 109 filter = filter.toLowerCase(); 110 for (TaggingPreset item: items) {110 for (TaggingPreset item: items) { 111 111 if ((item.getName() != null && item.getName().toLowerCase().trim().contains(filter)) 112 112 || (item.group != null && item.group.getName() != null && item.group.getName().toLowerCase().trim().contains(filter))) { 113 113 visibleItems.add(item); 114 114 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/ui/TabularPresetSelector.java
r32913 r32959 39 39 40 40 private PresetsTable presetsTable = null; 41 private JTextField 41 private JTextField tfFilter = null; 42 42 private final ArrayList<IPresetSelectorListener> listeners = new ArrayList<>(); 43 43 private JScrollPane scrollPane; … … 50 50 tfFilter = new JTextField(20); 51 51 pnl.add(lbl); 52 pnl.add(tfFilter, BorderLayout.CENTER);52 pnl.add(tfFilter, BorderLayout.CENTER); 53 53 JButton btn = new JButton(tr("Clear")); 54 54 pnl.add(btn); … … 67 67 protected JScrollPane buildPresetGrid() { 68 68 69 presetsTable = new PresetsTable(new PresetsTableModel(), new PresetsTableColumnModel());69 presetsTable = new PresetsTable(new PresetsTableModel(), new PresetsTableColumnModel()); 70 70 71 71 scrollPane = new JScrollPane(presetsTable); … … 94 94 // replace Enter action. apply the current preset on enter 95 95 // 96 presetsTable.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));96 presetsTable.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)); 97 97 ActionListener enterAction = new ActionListener() { 98 98 @Override … … 108 108 enterAction, 109 109 "Enter", 110 KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),110 KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), 111 111 JComponent.WHEN_FOCUSED 112 112 ); … … 125 125 public void actionPerformed(ActionEvent arg0) { 126 126 int row = presetsTable.getSelectedRow(); 127 if (row >= 0) {127 if (row >= 0) { 128 128 fireItemSelected(getModel().getVisibleItem(row)); 129 129 } … … 193 193 194 194 public void bindTo(Collection<TaggingPreset> presets) { 195 PresetsTableModel model = (PresetsTableModel) presetsTable.getModel();195 PresetsTableModel model = (PresetsTableModel) presetsTable.getModel(); 196 196 model.setPresets(presets); 197 197 } … … 202 202 203 203 public void addPresetSelectorListener(IPresetSelectorListener listener) { 204 synchronized (this.listeners) {205 if (listener != null && ! 204 synchronized (this.listeners) { 205 if (listener != null && !listeners.contains(listener)) { 206 206 listeners.add(listener); 207 207 } … … 210 210 211 211 public void removePresetSelectorListener(IPresetSelectorListener listener) { 212 synchronized (this.listeners) {212 synchronized (this.listeners) { 213 213 if (listener != null) { 214 214 listeners.remove(listener); … … 218 218 219 219 protected void fireItemSelected(TaggingPreset item) { 220 synchronized (this.listeners) {221 for (IPresetSelectorListener listener: listeners) {220 synchronized (this.listeners) { 221 for (IPresetSelectorListener listener: listeners) { 222 222 listener.itemSelected(item); 223 223 } … … 249 249 // 250 250 Component c = presetsTable; 251 while (c != null) {251 while (c != null) { 252 252 c.doLayout(); 253 253 c.repaint(); … … 257 257 258 258 protected PresetsTableModel getModel() { 259 return (PresetsTableModel) presetsTable.getModel();259 return (PresetsTableModel) presetsTable.getModel(); 260 260 } 261 261 262 262 public void installKeyAction(Action a) { 263 getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put((KeyStroke)a.getValue(AbstractAction.ACCELERATOR_KEY), a.getValue(AbstractAction.NAME)); 263 getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 264 (KeyStroke) a.getValue(AbstractAction.ACCELERATOR_KEY), a.getValue(AbstractAction.NAME)); 264 265 getActionMap().put(a.getValue(AbstractAction.NAME), a); 265 266 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/KeyValuePair.java
r30488 r32959 5 5 private String key = new String(""); 6 6 private String value = new String(""); 7 7 8 8 public KeyValuePair() {} 9 9 10 10 public KeyValuePair(String key, String value) { 11 11 setKey(key); … … 13 13 } 14 14 15 16 15 public String getKey() { 17 16 return key; … … 19 18 20 19 public void setKey(String key) { 21 this.key = key == null ? "" :key;20 this.key = key == null ? "" : key; 22 21 } 23 22 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/TagSpecification.java
r30737 r32959 65 65 /** 66 66 * sets the list of lables for this tag specification 67 * 67 * 68 68 * @param lables the list of lables; must not be null 69 69 * @exception IllegalArgumentException thrown, if lables is null … … 81 81 * Adds a label to the list of label for this tag specification. The label 82 82 * is only added if i 83 * 83 * 84 84 * @param lable the lalbe to add; must not be null 85 85 * @exception IllegalArgumentException thrown, if lable is null 86 86 */ 87 public void addLable(LabelSpecification lable) throws IllegalArgumentException 87 public void addLable(LabelSpecification lable) throws IllegalArgumentException { 88 88 if (lable == null) 89 89 throw new IllegalArgumentException("argument 'lable' must not be null"); … … 111 111 return key; 112 112 } 113 113 114 public void setKey(String key) { 114 115 this.key = key; 115 116 } 117 116 118 public String getType() { 117 119 return type; 118 120 } 121 119 122 public void setType(String type) { 120 123 this.type = type; 121 124 } 125 122 126 public boolean isApplicableToNode() { 123 127 return applicableToNode; 124 128 } 129 125 130 public void setApplicableToNode(boolean applicableToNode) { 126 131 this.applicableToNode = applicableToNode; 127 132 } 133 128 134 public boolean isApplicableToWay() { 129 135 return applicableToWay; 130 136 } 137 131 138 public void setApplicableToWay(boolean applicableToWay) { 132 139 this.applicableToWay = applicableToWay; 133 140 } 141 134 142 public boolean isApplicableToRelation() { 135 143 return applicableToRelation; 136 144 } 145 137 146 public void setApplicableToRelation(boolean applicableToRelation) { 138 147 this.applicableToRelation = applicableToRelation; -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/TagSpecifications.java
r32913 r32959 35 35 public class TagSpecifications { 36 36 37 final static publicString ATTR_KEY = "key";38 final static publicString ATTR_TYPE = "type";39 final static publicString ATTR_FOR_NODE = "for-node";40 final static publicString ATTR_FOR_WAY = "for-way";41 final static publicString ATTR_FOR_RELATION = "for-relation";42 final static publicString ATTR_VALUE = "value";43 44 final static publicString ELEM_ROOT = "osm-tag-definitions";45 final static publicString ELEM_TAG = "tag";46 final static publicString ELEM_LABEL = "label";47 48 final static publicString DTD = "osm-tag-definitions.dtd";37 public static final String ATTR_KEY = "key"; 38 public static final String ATTR_TYPE = "type"; 39 public static final String ATTR_FOR_NODE = "for-node"; 40 public static final String ATTR_FOR_WAY = "for-way"; 41 public static final String ATTR_FOR_RELATION = "for-relation"; 42 public static final String ATTR_VALUE = "value"; 43 44 public static final String ELEM_ROOT = "osm-tag-definitions"; 45 public static final String ELEM_TAG = "tag"; 46 public static final String ELEM_LABEL = "label"; 47 48 public static final String DTD = "osm-tag-definitions.dtd"; 49 49 50 50 51 51 /** the default name of the resource file with the tag specifications */ 52 static public final String RES_NAME_TAG_SPECIFICATIONS = "/resources/osm-tag-definitions.xml";52 public static final String RES_NAME_TAG_SPECIFICATIONS = "/resources/osm-tag-definitions.xml"; 53 53 54 54 /** the logger object */ … … 67 67 * @throws Exception thrown, if an exception occurs 68 68 */ 69 static public void loadFromResources() throws Exception{69 public static void loadFromResources() throws Exception { 70 70 InputStream in = TagSpecifications.class.getResourceAsStream(RES_NAME_TAG_SPECIFICATIONS); 71 71 if (in == null) { … … 80 80 } 81 81 82 static public TagSpecifications getInstance() throws Exception {82 public static TagSpecifications getInstance() throws Exception { 83 83 if (instance == null) { 84 84 loadFromResources(); … … 187 187 * between <tag> ... </tag> 188 188 */ 189 private TagSpecification currentTagSpecification 189 private TagSpecification currentTagSpecification = null; 190 190 191 191 @Override 192 192 public void endDocument() throws SAXException { 193 logger.log(Level.FINE, "END");193 logger.log(Level.FINE, "END"); 194 194 } 195 195 … … 206 206 @Override 207 207 public void startDocument() throws SAXException { 208 logger.log(Level.FINE, "START");208 logger.log(Level.FINE, "START"); 209 209 } 210 210 … … 230 230 * 231 231 * @param atts the XML attributes 232 * @throws SAXException 232 * @throws SAXException if any SAX error occurs 233 233 */ 234 234 protected void startElementOsmTagDefinitions(Attributes atts) throws SAXException { … … 239 239 * handles an end element with name <code>osm-tag-specifications</code> 240 240 * 241 * @throws SAXException 241 * @throws SAXException if any SAX error occurs 242 242 */ 243 243 protected void endElementOsmTagDefinitions() throws SAXException { … … 249 249 * 250 250 * @param atts the XML attributes of the element 251 * @throws SAXException 251 * @throws SAXException if any SAX error occurs 252 252 */ 253 253 protected void startElementTag(Attributes atts) throws SAXException { 254 254 currentTagSpecification = new TagSpecification(); 255 for (int i =0; i< atts.getLength(); i++) {255 for (int i = 0; i < atts.getLength(); i++) { 256 256 String name = atts.getQName(i); 257 257 String value = atts.getValue(i); … … 272 272 } 273 273 274 275 274 /** 276 275 * handles an end element with name <code>tag</code> 277 * @throws SAXException 276 * @throws SAXException if any SAX error occurs 278 277 */ 279 278 protected void endElementTag() throws SAXException { 280 279 tagSpecifications.add(currentTagSpecification); 281 280 currentTagSpecification = null; 282 283 281 } 284 282 … … 287 285 * 288 286 * @param atts the XML attributes 289 * @throws SAXException 287 * @throws SAXException if any SAX error occurs 290 288 */ 291 289 protected void startElementLabel(Attributes atts) throws SAXException { 292 290 LabelSpecification ls = new LabelSpecification(); 293 for (int i =0; i< atts.getLength(); i++) {291 for (int i = 0; i < atts.getLength(); i++) { 294 292 String name = atts.getQName(i); 295 293 String value = atts.getValue(i); … … 312 310 * handles an end element with name <code>label</code> 313 311 * 314 * @throws SAXException 312 * @throws SAXException if any SAX error occurs 315 313 */ 316 314 protected void endElementLabel() throws SAXException { … … 353 351 354 352 @Override 355 353 public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { 356 354 if (systemId != null && systemId.endsWith(DTD)) { 357 355 InputStream stream = TagSpecifications.class.getResourceAsStream("/resources/"+DTD); … … 366 364 } 367 365 368 public static void main(String args[]) throws Exception{366 public static void main(String[] args) throws Exception { 369 367 TagSpecifications.loadFromResources(); 370 368 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/ITagSelectorListener.java
r30488 r32959 5 5 6 6 public interface ITagSelectorListener { 7 publicvoid itemSelected(KeyValuePair pair);7 void itemSelected(KeyValuePair pair); 8 8 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/KeyValueCellRenderer.java
r32913 r32959 10 10 import javax.swing.table.TableCellRenderer; 11 11 12 public class KeyValueCellRenderer extends JLabel implements TableCellRenderer 12 public class KeyValueCellRenderer extends JLabel implements TableCellRenderer { 13 13 14 14 protected void init() { 15 setFont(new Font("Courier", Font.PLAIN,getFont().getSize()));15 setFont(new Font("Courier", Font.PLAIN, getFont().getSize())); 16 16 setOpaque(true); 17 17 } … … 28 28 setBackground(UIManager.getColor("Table.selectionBackground")); 29 29 setForeground(UIManager.getColor("Table.selectionForeground")); 30 } else 30 } else { 31 31 setBackground(UIManager.getColor("Table.background")); 32 32 setForeground(UIManager.getColor("Table.foreground")); 33 33 } 34 setText((String) value);34 setText((String) value); 35 35 setIcon(null); 36 36 return this; -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/TabularTagSelector.java
r32913 r32959 46 46 tfFilter = new JTextField(20); 47 47 pnl.add(lbl); 48 pnl.add(tfFilter, BorderLayout.CENTER);48 pnl.add(tfFilter, BorderLayout.CENTER); 49 49 JButton btn = new JButton(tr("Clear")); 50 50 pnl.add(btn); … … 63 63 protected JScrollPane buildPresetGrid() { 64 64 65 tagsTable = new TagsTable(new TagsTableModel(), new TagsTableColumnModel());65 tagsTable = new TagsTable(new TagsTableModel(), new TagsTableColumnModel()); 66 66 getModel().initFromTagSpecifications(); 67 67 … … 91 91 // replace Enter action. apply the current preset on enter 92 92 // 93 tagsTable.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));93 tagsTable.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)); 94 94 ActionListener enterAction = new ActionListener() { 95 95 @Override … … 106 106 enterAction, 107 107 "Enter", 108 KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),108 KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), 109 109 JComponent.WHEN_FOCUSED 110 110 ); … … 123 123 public void actionPerformed(ActionEvent arg0) { 124 124 int row = tagsTable.getSelectedRow(); 125 if (row >= 0) {125 if (row >= 0) { 126 126 KeyValuePair item = getModel().getVisibleItem(row); 127 127 fireItemSelected(item); … … 209 209 // 210 210 Component c = tagsTable; 211 while (c != null) {211 while (c != null) { 212 212 c.doLayout(); 213 213 c.repaint(); … … 217 217 218 218 protected TagsTableModel getModel() { 219 return (TagsTableModel)tagsTable.getModel(); 220 } 221 219 return (TagsTableModel) tagsTable.getModel(); 220 } 222 221 223 222 public void addTagSelectorListener(ITagSelectorListener listener) { 224 synchronized (this.listeners) {225 if (listener != null && ! 223 synchronized (this.listeners) { 224 if (listener != null && !listeners.contains(listener)) { 226 225 listeners.add(listener); 227 226 } … … 230 229 231 230 public void removeTagSelectorListener(ITagSelectorListener listener) { 232 synchronized (this.listeners) {231 synchronized (this.listeners) { 233 232 if (listener != null) { 234 233 listeners.remove(listener); … … 238 237 239 238 protected void fireItemSelected(KeyValuePair pair) { 240 synchronized (this.listeners) {241 for (ITagSelectorListener listener: listeners) {239 synchronized (this.listeners) { 240 for (ITagSelectorListener listener: listeners) { 242 241 listener.itemSelected(pair); 243 242 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/TagsTable.java
r30488 r32959 9 9 public class TagsTable extends JTable { 10 10 /** 11 * initialize the table 11 * initialize the table 12 12 */ 13 protected void init() { 14 setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 13 protected void init() { 14 setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 15 15 setRowSelectionAllowed(true); 16 16 setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 17 17 } 18 18 19 19 public TagsTable(TableModel model, TableColumnModel columnModel) { 20 super(model, columnModel);20 super(model, columnModel); 21 21 init(); 22 22 } 23 23 24 24 /** 25 25 * adjusts the width of the columns for the tag name and the tag value 26 26 * to the width of the scroll panes viewport. 27 * 27 * 28 28 * Note: {@see #getPreferredScrollableViewportSize()} did not work as expected 29 * 29 * 30 30 * @param scrollPaneWidth the width of the scroll panes viewport 31 31 */ … … 38 38 tcm.getColumn(0).setMaxWidth(width); 39 39 tcm.getColumn(1).setMinWidth(width); 40 tcm.getColumn(1).setMaxWidth(width); 40 tcm.getColumn(1).setMaxWidth(width); 41 41 } 42 42 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/TagsTableModel.java
r32913 r32959 17 17 public class TagsTableModel extends AbstractTableModel { 18 18 19 static privateLogger logger = Logger.getLogger(TagsTableModel.class.getName());19 private static Logger logger = Logger.getLogger(TagsTableModel.class.getName()); 20 20 21 21 private ArrayList<KeyValuePair> items = null; … … 34 34 public int compare(KeyValuePair self, 35 35 KeyValuePair other) { 36 int ret = self.getKey().compareToIgnoreCase(other.getKey());36 int ret = self.getKey().compareToIgnoreCase(other.getKey()); 37 37 38 38 if (ret == 0) … … 56 56 try { 57 57 spec = TagSpecifications.getInstance(); 58 } catch (Exception e) {58 } catch (Exception e) { 59 59 logger.log(Level.SEVERE, "failed to init TagTableModel. Exception:" + e); 60 60 return; … … 63 63 items = spec.asList(); 64 64 sort(); 65 for (KeyValuePair item : items) {65 for (KeyValuePair item : items) { 66 66 visibleItems.add(item); 67 67 } … … 86 86 default: 87 87 /* should not happen */ 88 throw new IllegalArgumentException(tr("unexpected column number {0}", col));88 throw new IllegalArgumentException(tr("unexpected column number {0}", col)); 89 89 } 90 90 } 91 91 92 92 public void filter(String filter) { 93 synchronized (this) {93 synchronized (this) { 94 94 if (filter == null || filter.trim().equals("")) { 95 95 visibleItems.clear(); 96 for (KeyValuePair pair: items) {96 for (KeyValuePair pair: items) { 97 97 visibleItems.add(pair); 98 98 } … … 100 100 visibleItems.clear(); 101 101 filter = filter.toLowerCase(); 102 for (KeyValuePair pair: items) {102 for (KeyValuePair pair: items) { 103 103 if (pair.getKey().toLowerCase().trim().startsWith(filter) 104 || 104 || pair.getValue().toLowerCase().trim().startsWith(filter)) { 105 105 visibleItems.add(pair); 106 106 }
Note:
See TracChangeset
for help on using the changeset viewer.