- Timestamp:
- 2010-03-17T11:11:55+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetTagsPanel.java
r3138 r3141 7 7 8 8 import javax.swing.BorderFactory; 9 import javax.swing.DefaultListSelectionModel;10 9 import javax.swing.JPanel; 11 10 import javax.swing.JScrollPane; … … 27 26 setLayout(new BorderLayout()); 28 27 setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 29 DefaultListSelectionModel rowSelectionModel = new DefaultListSelectionModel(); 30 DefaultListSelectionModel colSelectionModel = new DefaultListSelectionModel(); 31 32 model = new TagEditorModel(rowSelectionModel, colSelectionModel); 33 tblTags = new TagTable(model, rowSelectionModel, colSelectionModel); 28 model = new TagEditorModel(); 29 tblTags = new TagTable(model); 34 30 tblTags.setEnabled(false); 35 31 add(new JScrollPane(tblTags), BorderLayout.CENTER); -
trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorModel.java
r3138 r3141 24 24 import org.openstreetmap.josm.data.osm.TagCollection; 25 25 import org.openstreetmap.josm.data.osm.Tagged; 26 import org.openstreetmap.josm.tools.CheckParameterUtil; 26 27 27 28 /** … … 37 38 38 39 /** the list holding the tags */ 39 protected ArrayList<TagModel> tags = null;40 protected final ArrayList<TagModel> tags =new ArrayList<TagModel>(); 40 41 41 42 /** indicates whether the model is dirty */ 42 43 private boolean dirty = false; 43 private PropertyChangeSupport propChangeSupport = null; 44 private final PropertyChangeSupport propChangeSupport = new PropertyChangeSupport(this); 45 44 46 private DefaultListSelectionModel rowSelectionModel; 45 47 private DefaultListSelectionModel colSelectionModel; 46 48 47 49 /** 48 * constructor 49 */ 50 public TagEditorModel(DefaultListSelectionModel rowSelectionModel, DefaultListSelectionModel colSelectionModel){ 51 tags = new ArrayList<TagModel>(); 52 propChangeSupport = new PropertyChangeSupport(this); 50 * Creates a new tag editor model. Internally allocates two selection models 51 * for row selection and column selection. 52 * 53 * To create a {@see JTable} with this model: 54 * <pre> 55 * TagEditorModel model = new TagEditorModel(); 56 * TagTable tbl = new TagTabel(model); 57 * </pre> 58 * 59 * @see #getRowSelectionModel() 60 * @see #getColumnSelectionModel() 61 */ 62 public TagEditorModel() { 63 this.rowSelectionModel = new DefaultListSelectionModel(); 64 this.colSelectionModel = new DefaultListSelectionModel(); 65 } 66 /** 67 * Creates a new tag editor model. 68 * 69 * @param rowSelectionModel the row selection model. Must not be null. 70 * @param colSelectionModel the column selection model. Must not be null. 71 * @throws IllegalArgumentException thrown if {@code rowSelectionModel} is null 72 * @throws IllegalArgumentException thrown if {@code colSelectionModel} is null 73 */ 74 public TagEditorModel(DefaultListSelectionModel rowSelectionModel, DefaultListSelectionModel colSelectionModel) throws IllegalArgumentException{ 75 CheckParameterUtil.ensureParameterNotNull(rowSelectionModel, "rowSelectionModel"); 76 CheckParameterUtil.ensureParameterNotNull(colSelectionModel, "colSelectionModel"); 53 77 this.rowSelectionModel = rowSelectionModel; 54 78 this.colSelectionModel = colSelectionModel; … … 57 81 public void addPropertyChangeListener(PropertyChangeListener listener) { 58 82 propChangeSupport.addPropertyChangeListener(listener); 83 } 84 85 /** 86 * Replies the row selection model used by this tag editor model 87 * 88 * @return the row selection model used by this tag editor model 89 */ 90 public DefaultListSelectionModel getRowSelectionModel() { 91 return rowSelectionModel; 92 } 93 94 /** 95 * Replies the column selection model used by this tag editor model 96 * 97 * @return the column selection model used by this tag editor model 98 */ 99 public DefaultListSelectionModel getColumnSelectionModel() { 100 return colSelectionModel; 59 101 } 60 102 … … 167 209 if (tag == null) { 168 210 tag = new TagModel(name, value); 169 add(tag);211 tags.add(tag); 170 212 } else { 171 213 tag.addValue(value); 172 214 } 173 215 setDirty(true); 216 fireTableDataChanged(); 174 217 } 175 218 … … 306 349 for (String key : primitive.keySet()) { 307 350 String value = primitive.get(key); 308 add(key,value);351 this.tags.add(new TagModel(key,value)); 309 352 } 310 353 TagModel tag = new TagModel(); … … 323 366 for (String key : tags.keySet()) { 324 367 String value = tags.get(key); 325 add(key,value); 326 } 368 this.tags.add(new TagModel(key,value)); 369 } 370 sort(); 327 371 TagModel tag = new TagModel(); 328 sort();329 372 this.tags.add(tag); 330 373 setDirty(false); … … 345 388 for (String key : tags.getKeys()) { 346 389 String value = tags.getJoinedValues(key); 347 add(key,value);390 this.tags.add(new TagModel(key,value)); 348 391 } 349 392 sort(); -
trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorPanel.java
r3083 r3141 9 9 10 10 import javax.swing.BoxLayout; 11 import javax.swing.DefaultListSelectionModel;12 11 import javax.swing.JButton; 13 12 import javax.swing.JPanel; … … 17 16 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionCache; 18 17 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; 18 import org.openstreetmap.josm.tools.CheckParameterUtil; 19 19 20 20 /** … … 42 42 */ 43 43 protected JPanel buildTagTableEditorPanel() { 44 45 44 JPanel pnl = new JPanel(); 46 DefaultListSelectionModel rowSelectionModel = new DefaultListSelectionModel(); 47 DefaultListSelectionModel colSelectionModel = new DefaultListSelectionModel(); 48 49 model = new TagEditorModel(rowSelectionModel, colSelectionModel); 50 tagTable = new TagTable(model, rowSelectionModel, colSelectionModel); 51 45 tagTable = new TagTable(model); 52 46 pnl.setLayout(new BorderLayout()); 53 47 pnl.add(new JScrollPane(tagTable), BorderLayout.CENTER); … … 107 101 108 102 /** 109 * constructor 103 * Creates a new tag editor panel. The editor model is created 104 * internally and can be retrieved with {@see #getModel()}. 110 105 */ 111 106 public TagEditorPanel() { 107 this(null); 108 } 109 110 /** 111 * Creates a new tag editor panel with a supplied model. If 112 * {@code model} is null, a new model is created. 113 * 114 * @param model the tag editor model 115 */ 116 public TagEditorPanel(TagEditorModel model) { 117 this.model = model; 118 if (this.model == null) { 119 this.model = new TagEditorModel(); 120 } 112 121 build(); 113 122 } … … 122 131 } 123 132 124 public void initAutoCompletion(OsmDataLayer layer) { 133 /** 134 * Initializes the auto completion infrastructure used in this 135 * tag editor panel. {@code layer} is the data layer from whose data set 136 * tag values are proposed as auto completion items. 137 * 138 * @param layer the data layer. Must not be null. 139 * @throws IllegalArgumentException thrown if {@code layer} is null 140 */ 141 public void initAutoCompletion(OsmDataLayer layer) throws IllegalArgumentException{ 142 CheckParameterUtil.ensureParameterNotNull(layer, "layer"); 125 143 // initialize the autocompletion infrastructure 126 144 // -
trunk/src/org/openstreetmap/josm/gui/tagging/TagTable.java
r3100 r3141 39 39 import javax.swing.table.DefaultTableColumnModel; 40 40 import javax.swing.table.TableColumn; 41 import javax.swing.table.TableModel;42 41 43 42 import org.openstreetmap.josm.gui.dialogs.relation.RunnableAction; … … 356 355 357 356 /** 358 * constructor 359 * 360 * @param model 361 * @param columnModel 362 */ 363 public TagTable(TableModel model, DefaultListSelectionModel rowSelectionModel, DefaultListSelectionModel colSelectionModel) { 364 super(model, new TagTableColumnModel(colSelectionModel), rowSelectionModel); 357 * Creates a new tag table 358 * 359 * @param model the tag editor model 360 */ 361 public TagTable(TagEditorModel model) { 362 super(model, new TagTableColumnModel(model.getColumnSelectionModel()), model.getRowSelectionModel()); 365 363 init(); 366 364 }
Note:
See TracChangeset
for help on using the changeset viewer.