Changeset 9588 in josm for trunk/src/org
- Timestamp:
- 2016-01-23T18:20:46+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PresetListPanel.java
r9266 r9588 36 36 * and associates an interaction with (matching) presets via {@code presetHandler}. 37 37 * @param types collection of tagging presets types 38 * @param tags col elction of tags38 * @param tags collection of tags 39 39 * @param presetHandler tagging preset handler 40 40 */ -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r9543 r9588 165 165 // init the various models 166 166 // 167 memberTableModel = new MemberTableModel( getLayer(), presetHandler);167 memberTableModel = new MemberTableModel(relation, getLayer(), presetHandler); 168 168 memberTableModel.register(); 169 169 selectionTableModel = new SelectionTableModel(getLayer()); … … 171 171 referrerModel = new ReferringRelationsBrowserModel(relation); 172 172 173 tagEditorPanel = new TagEditorPanel( presetHandler);173 tagEditorPanel = new TagEditorPanel(relation, presetHandler); 174 174 175 175 // populate the models … … 805 805 try { 806 806 final Collection<TaggingPreset> presets = TaggingPresets.getMatchingPresets( 807 EnumSet.of(TaggingPresetType. RELATION), orig.getKeys(), false);807 EnumSet.of(TaggingPresetType.forPrimitive(orig)), orig.getKeys(), false); 808 808 Relation relation = new Relation(orig); 809 809 boolean modified = false; -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r9496 r9588 54 54 private final transient List<RelationMember> members; 55 55 private transient List<WayConnectionType> connectionType; 56 private final Relation relation; 56 57 57 58 private DefaultListSelectionModel listSelectionModel; … … 65 66 /** 66 67 * constructor 68 * @param relation relation 67 69 * @param layer data layer 68 70 * @param presetHandler tagging preset handler 69 71 */ 70 public MemberTableModel(OsmDataLayer layer, TaggingPresetHandler presetHandler) { 71 members = new ArrayList<>(); 72 listeners = new CopyOnWriteArrayList<>(); 72 public MemberTableModel(Relation relation, OsmDataLayer layer, TaggingPresetHandler presetHandler) { 73 this.relation = relation; 74 this.members = new ArrayList<>(); 75 this.listeners = new CopyOnWriteArrayList<>(); 73 76 this.layer = layer; 74 77 this.presetHandler = presetHandler; … … 114 117 Collection<RelationMember> sel = getSelectedMembers(); 115 118 GuiHelper.runInEDT(new Runnable() { 119 @Override 116 120 public void run() { 117 121 fireTableDataChanged(); … … 437 441 438 442 RelationMember getRelationMemberForPrimitive(final OsmPrimitive primitive) { 439 final Collection<TaggingPreset> presets = TaggingPresets.getMatchingPresets(EnumSet.of(TaggingPresetType. RELATION),443 final Collection<TaggingPreset> presets = TaggingPresets.getMatchingPresets(EnumSet.of(TaggingPresetType.forPrimitive(relation)), 440 444 presetHandler.getSelection().iterator().next().getKeys(), false); 441 445 Collection<String> potentialRoles = new TreeSet<>(); -
trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorModel.java
r9246 r9588 9 9 import java.util.Collection; 10 10 import java.util.Comparator; 11 import java.util.EnumSet; 11 12 import java.util.HashMap; 12 13 import java.util.Iterator; … … 25 26 import org.openstreetmap.josm.data.osm.TagCollection; 26 27 import org.openstreetmap.josm.data.osm.Tagged; 28 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType; 27 29 import org.openstreetmap.josm.tools.CheckParameterUtil; 28 30 29 31 /** 30 * TagEditorModel is a table model .31 * 32 * TagEditorModel is a table model to use with {@link TagEditorPanel}. 33 * @since 1762 32 34 */ 33 35 public class TagEditorModel extends AbstractTableModel { … … 43 45 private final DefaultListSelectionModel rowSelectionModel; 44 46 private final DefaultListSelectionModel colSelectionModel; 47 48 private OsmPrimitive primitive; 45 49 46 50 /** … … 58 62 */ 59 63 public TagEditorModel() { 60 this.rowSelectionModel = new DefaultListSelectionModel(); 61 this.colSelectionModel = new DefaultListSelectionModel(); 64 this(new DefaultListSelectionModel(), new DefaultListSelectionModel()); 62 65 } 63 66 … … 74 77 CheckParameterUtil.ensureParameterNotNull(colSelectionModel, "colSelectionModel"); 75 78 this.rowSelectionModel = rowSelectionModel; 76 this.colSelectionModel 79 this.colSelectionModel = colSelectionModel; 77 80 } 78 81 … … 618 621 } 619 622 623 /** 624 * Returns the list of tagging presets types to consider when updating the presets list panel. 625 * By default returns type of associated primitive or empty set. 626 * @return the list of tagging presets types to consider when updating the presets list panel 627 * @see #forPrimitive 628 * @see TaggingPresetType#forPrimitive 629 * @since 9588 630 */ 631 public Collection<TaggingPresetType> getTaggingPresetTypes() { 632 return primitive == null ? EnumSet.noneOf(TaggingPresetType.class) : EnumSet.of(TaggingPresetType.forPrimitive(primitive)); 633 } 634 635 /** 636 * Makes this TagEditorModel specific to a given OSM primitive. 637 * @param primitive primitive to consider 638 * @return {@code this} 639 * @since 9588 640 */ 641 public TagEditorModel forPrimitive(OsmPrimitive primitive) { 642 this.primitive = primitive; 643 return this; 644 } 645 620 646 class SelectionStateMemento { 621 647 private final int rowMin; -
trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorPanel.java
r9543 r9588 9 9 import java.awt.event.FocusAdapter; 10 10 import java.awt.event.FocusEvent; 11 import java.util.EnumSet;12 11 13 12 import javax.swing.AbstractAction; … … 19 18 import javax.swing.event.TableModelListener; 20 19 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 21 import org.openstreetmap.josm.gui.dialogs.properties.PresetListPanel; 22 22 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 24 24 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager; 25 25 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetHandler; 26 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType;27 26 import org.openstreetmap.josm.tools.CheckParameterUtil; 28 27 … … 32 31 * and tag values. Two action buttons are placed on the left, one for adding 33 32 * a new tag and one for deleting the currently selected tags. 34 * 33 * @since 2040 35 34 */ 36 35 public class TagEditorPanel extends JPanel { … … 140 139 141 140 addFocusListener(new FocusAdapter() { 142 @Override public void focusGained(FocusEvent e) { 141 @Override 142 public void focusGained(FocusEvent e) { 143 143 tagTable.requestFocusInCell(0, 0); 144 144 } … … 149 149 * Creates a new tag editor panel. The editor model is created 150 150 * internally and can be retrieved with {@link #getModel()}. 151 * @param primitive primitive to consider 151 152 * @param presetHandler tagging preset handler 152 153 */ 153 public TagEditorPanel( TaggingPresetHandler presetHandler) {154 this(n ull, presetHandler, 0);154 public TagEditorPanel(OsmPrimitive primitive, TaggingPresetHandler presetHandler) { 155 this(new TagEditorModel().forPrimitive(primitive), presetHandler, 0); 155 156 } 156 157 … … 198 199 editor.setAutoCompletionManager(autocomplete); 199 200 editor.setAutoCompletionList(acList); 200 editor = ( (TagCellEditor) tagTable.getColumnModel().getColumn(1).getCellEditor());201 editor = (TagCellEditor) tagTable.getColumnModel().getColumn(1).getCellEditor(); 201 202 editor.setAutoCompletionManager(autocomplete); 202 203 editor.setAutoCompletionList(acList); … … 211 212 private void updatePresets() { 212 213 presetListPanel.updatePresets( 213 EnumSet.of(TaggingPresetType.RELATION),214 model.getTaggingPresetTypes(), 214 215 model.getTags(), presetHandler); 215 216 validate(); -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetType.java
r9574 r9588 66 66 return CLOSEDWAY; 67 67 if (type == OsmPrimitiveType.MULTIPOLYGON) 68 return TaggingPresetType.MULTIPOLYGON;68 return MULTIPOLYGON; 69 69 if (type == OsmPrimitiveType.RELATION) 70 70 return RELATION;
Note:
See TracChangeset
for help on using the changeset viewer.