Changeset 10089 in josm


Ignore:
Timestamp:
2016-03-30T22:28:45+02:00 (6 years ago)
Author:
Don-vip
Message:

add unit test, javadoc

Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java

    r9991 r10089  
    110110    private final ReferringRelationsBrowserModel referrerModel;
    111111
    112     /** the member table */
     112    /** the member table and its model */
    113113    private MemberTable memberTable;
    114114    private final MemberTableModel memberTableModel;
    115115
    116     /** the model for the selection table */
     116    /** the selection table and its model */
    117117    private SelectionTable selectionTable;
    118118    private final SelectionTableModel selectionTableModel;
     
    120120    private AutoCompletingTextField tfRole;
    121121
    122     /** the menu item in the windows menu. Required to properly
    123      * hide on dialog close.
     122    /**
     123     * the menu item in the windows menu. Required to properly hide on dialog close.
    124124     */
    125125    private JMenuItem windowMenuItem;
     
    503503        JPanel pnl = new JPanel(new BorderLayout());
    504504        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);
    507506        selectionTable.setRowHeight(ce.getEditor().getPreferredSize().height);
    508507        pnl.add(new JScrollPane(selectionTable), BorderLayout.CENTER);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java

    r9993 r10089  
    8787    }
    8888
     89    /**
     90     * Registers listeners (selection change and dataset change).
     91     */
    8992    public void register() {
    9093        DataSet.addSelectionListener(this);
     
    9295    }
    9396
     97    /**
     98     * Unregisters listeners (selection change and dataset change).
     99     */
    94100    public void unregister() {
    95101        DataSet.removeSelectionListener(this);
     
    190196    }
    191197
     198    /**
     199     * Populates this model from the given relation.
     200     * @param relation relation
     201     */
    192202    public void populate(Relation relation) {
    193203        members.clear();
     
    348358    }
    349359
     360    /**
     361     * Applies this member model to the given relation.
     362     * @param relation relation
     363     */
    350364    public void applyToRelation(Relation relation) {
    351365        relation.setMembers(members);
     
    678692
    679693    /**
    680      * Selects all mebers which refer to {@link OsmPrimitive}s in the collections
     694     * Selects all members which refer to {@link OsmPrimitive}s in the collections
    681695     * <code>primitmives</code>. Does nothing is primitives is null.
    682696     *
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/SelectionTable.java

    r9078 r10089  
    1010import javax.swing.SwingUtilities;
    1111
    12 import org.openstreetmap.josm.data.osm.OsmPrimitive;
    13 
     12/**
     13 * Selection table of relation editor.
     14 * @since 2563
     15 */
    1416public class SelectionTable extends JTable {
    1517
    1618    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    }
    1832
    1933    protected void build() {
    2034        setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    2135        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;
    3236    }
    3337
     
    3842                return;
    3943            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)));
    4245        }
    4346    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/SelectionTableCellRenderer.java

    r10072 r10089  
    1313/**
    1414 * This is the {@link TableCellRenderer} used in {@link SelectionTable}.
    15  *
     15 * @since 1806
    1616 */
    1717public class SelectionTableCellRenderer extends MemberTableMemberCellRenderer {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/SelectionTableColumnModel.java

    r10072 r10089  
    66import javax.swing.table.DefaultTableColumnModel;
    77import javax.swing.table.TableColumn;
     8import javax.swing.table.TableColumnModel;
    89
     10/**
     11 * This is the {@link TableColumnModel} used in {@link SelectionTable}.
     12 * @since 1790
     13 */
    914public class SelectionTableColumnModel  extends DefaultTableColumnModel {
     15
     16    /**
     17     * Constructs a new {@code SelectionTableColumnModel}.
     18     * @param model member table model
     19     */
    1020    public SelectionTableColumnModel(MemberTableModel model) {
    11         TableColumn col = null;
    12         SelectionTableCellRenderer renderer = new SelectionTableCellRenderer(model);
    13 
    1421        // column 0 - the member role
    15         col = new TableColumn(0);
     22        TableColumn col = new TableColumn(0);
    1623        col.setHeaderValue(tr("Selection"));
    1724        col.setMinWidth(200);
    18         col.setCellRenderer(renderer);
     25        col.setCellRenderer(new SelectionTableCellRenderer(model));
    1926        addColumn(col);
    2027    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/SelectionTableModel.java

    r9078 r10089  
    3535    }
    3636
     37    /**
     38     * Registers listeners (selection change and layer change).
     39     */
    3740    public void register() {
    3841        DataSet.addSelectionListener(this);
     
    4043    }
    4144
     45    /**
     46     * Unregisters listeners (selection change and layer change).
     47     */
    4248    public void unregister() {
    4349        DataSet.removeSelectionListener(this);
     
    116122     *
    117123     * @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
    119126     */
    120127    public OsmPrimitive getPrimitive(int row) {
Note: See TracChangeset for help on using the changeset viewer.