Changeset 10089 in josm for trunk/src/org
- Timestamp:
- 2016-03-30T22:28:45+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs/relation
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r9991 r10089 110 110 private final ReferringRelationsBrowserModel referrerModel; 111 111 112 /** the member table */112 /** the member table and its model */ 113 113 private MemberTable memberTable; 114 114 private final MemberTableModel memberTableModel; 115 115 116 /** the model for the selection table*/116 /** the selection table and its model */ 117 117 private SelectionTable selectionTable; 118 118 private final SelectionTableModel selectionTableModel; … … 120 120 private AutoCompletingTextField tfRole; 121 121 122 /** the menu item in the windows menu. Required to properly123 * hide on dialog close.122 /** 123 * the menu item in the windows menu. Required to properly hide on dialog close. 124 124 */ 125 125 private JMenuItem windowMenuItem; … … 503 503 JPanel pnl = new JPanel(new BorderLayout()); 504 504 MemberRoleCellEditor ce = (MemberRoleCellEditor) memberTable.getColumnModel().getColumn(0).getCellEditor(); 505 selectionTable = new SelectionTable(selectionTableModel, new SelectionTableColumnModel(memberTableModel)); 506 selectionTable.setMemberTableModel(memberTableModel); 505 selectionTable = new SelectionTable(selectionTableModel, memberTableModel); 507 506 selectionTable.setRowHeight(ce.getEditor().getPreferredSize().height); 508 507 pnl.add(new JScrollPane(selectionTable), BorderLayout.CENTER); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r9993 r10089 87 87 } 88 88 89 /** 90 * Registers listeners (selection change and dataset change). 91 */ 89 92 public void register() { 90 93 DataSet.addSelectionListener(this); … … 92 95 } 93 96 97 /** 98 * Unregisters listeners (selection change and dataset change). 99 */ 94 100 public void unregister() { 95 101 DataSet.removeSelectionListener(this); … … 190 196 } 191 197 198 /** 199 * Populates this model from the given relation. 200 * @param relation relation 201 */ 192 202 public void populate(Relation relation) { 193 203 members.clear(); … … 348 358 } 349 359 360 /** 361 * Applies this member model to the given relation. 362 * @param relation relation 363 */ 350 364 public void applyToRelation(Relation relation) { 351 365 relation.setMembers(members); … … 678 692 679 693 /** 680 * Selects all me bers which refer to {@link OsmPrimitive}s in the collections694 * Selects all members which refer to {@link OsmPrimitive}s in the collections 681 695 * <code>primitmives</code>. Does nothing is primitives is null. 682 696 * -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/SelectionTable.java
r9078 r10089 10 10 import javax.swing.SwingUtilities; 11 11 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 12 /** 13 * Selection table of relation editor. 14 * @since 2563 15 */ 14 16 public class SelectionTable extends JTable { 15 17 16 18 private final SelectionTableModel model; 17 private MemberTableModel memberTableModel; 19 private final MemberTableModel memberTableModel; 20 21 /** 22 * Constructs a new {@code SelectionTable}. 23 * @param model table model 24 * @param memberTableModel member table model 25 */ 26 public SelectionTable(SelectionTableModel model, MemberTableModel memberTableModel) { 27 super(model, new SelectionTableColumnModel(memberTableModel)); 28 this.model = model; 29 this.memberTableModel = memberTableModel; 30 build(); 31 } 18 32 19 33 protected void build() { 20 34 setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 21 35 addMouseListener(new DoubleClickAdapter()); 22 }23 24 public SelectionTable(SelectionTableModel model, SelectionTableColumnModel columnModel) {25 super(model, columnModel);26 this.model = model;27 build();28 }29 30 public void setMemberTableModel(MemberTableModel memberTableModel) {31 this.memberTableModel = memberTableModel;32 36 } 33 37 … … 38 42 return; 39 43 int row = rowAtPoint(evt.getPoint()); 40 OsmPrimitive primitive = model.getPrimitive(row); 41 memberTableModel.selectMembersReferringTo(Collections.singleton(primitive)); 44 memberTableModel.selectMembersReferringTo(Collections.singleton(model.getPrimitive(row))); 42 45 } 43 46 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/SelectionTableCellRenderer.java
r10072 r10089 13 13 /** 14 14 * This is the {@link TableCellRenderer} used in {@link SelectionTable}. 15 * 15 * @since 1806 16 16 */ 17 17 public class SelectionTableCellRenderer extends MemberTableMemberCellRenderer { -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/SelectionTableColumnModel.java
r10072 r10089 6 6 import javax.swing.table.DefaultTableColumnModel; 7 7 import javax.swing.table.TableColumn; 8 import javax.swing.table.TableColumnModel; 8 9 10 /** 11 * This is the {@link TableColumnModel} used in {@link SelectionTable}. 12 * @since 1790 13 */ 9 14 public class SelectionTableColumnModel extends DefaultTableColumnModel { 15 16 /** 17 * Constructs a new {@code SelectionTableColumnModel}. 18 * @param model member table model 19 */ 10 20 public SelectionTableColumnModel(MemberTableModel model) { 11 TableColumn col = null;12 SelectionTableCellRenderer renderer = new SelectionTableCellRenderer(model);13 14 21 // column 0 - the member role 15 col = new TableColumn(0);22 TableColumn col = new TableColumn(0); 16 23 col.setHeaderValue(tr("Selection")); 17 24 col.setMinWidth(200); 18 col.setCellRenderer( renderer);25 col.setCellRenderer(new SelectionTableCellRenderer(model)); 19 26 addColumn(col); 20 27 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/SelectionTableModel.java
r9078 r10089 35 35 } 36 36 37 /** 38 * Registers listeners (selection change and layer change). 39 */ 37 40 public void register() { 38 41 DataSet.addSelectionListener(this); … … 40 43 } 41 44 45 /** 46 * Unregisters listeners (selection change and layer change). 47 */ 42 48 public void unregister() { 43 49 DataSet.removeSelectionListener(this); … … 116 122 * 117 123 * @param row the row 118 * @return the primitive at row <code>row</code> in this model 124 * @return the primitive at row <code>row</code> in this model 125 * @throws ArrayIndexOutOfBoundsException if index is invalid 119 126 */ 120 127 public OsmPrimitive getPrimitive(int row) {
Note:
See TracChangeset
for help on using the changeset viewer.