Ignore:
Timestamp:
2014-09-18T02:23:15+02:00 (10 years ago)
Author:
Don-vip
Message:

fix #8262 - Relation editor: filter autocompletion of roles by relation type

Location:
trunk/src/org/openstreetmap/josm/gui/dialogs/relation
Files:
4 edited

Legend:

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

    r7546 r7556  
    9292/**
    9393 * This dialog is for editing relations.
    94  *
     94 * @since 343
    9595 */
    9696public class GenericRelationEditor extends RelationEditor  {
     
    172172        tagEditorPanel.getModel().ensureOneTag();
    173173
    174         JSplitPane pane = buildSplitPane();
     174        JSplitPane pane = buildSplitPane(relation);
    175175        pane.setPreferredSize(new Dimension(100, 100));
    176176
     
    293293     */
    294294    protected JPanel buildMemberEditorPanel() {
    295         final JPanel pnl = new JPanel();
    296         pnl.setLayout(new GridBagLayout());
     295        final JPanel pnl = new JPanel(new GridBagLayout());
    297296        // setting up the member table
    298         memberTable = new MemberTable(getLayer(),memberTableModel);
     297        memberTable = new MemberTable(getLayer(), getRelation(), memberTableModel);
    299298        memberTable.addMouseListener(new MemberTableDblClickAdapter());
    300299        memberTableModel.addMemberModelListener(memberTable);
     
    350349                        if (list != null) {
    351350                            list.clear();
    352                             getLayer().data.getAutoCompletionManager().populateWithMemberRoles(list);
     351                            getLayer().data.getAutoCompletionManager().populateWithMemberRoles(list, getRelation());
    353352                        }
    354353                    }
     
    454453     * @return the split panel
    455454     */
    456     protected JSplitPane buildSplitPane() {
     455    protected JSplitPane buildSplitPane(Relation relation) {
    457456        final JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    458457        pane.setTopComponent(buildTagEditorPanel());
     
    16031602
    16041603    /**
    1605      * Creates a new relation with a copy of the current editor state
    1606      *
     1604     * Creates a new relation with a copy of the current editor state.
    16071605     */
    16081606    class DuplicateRelationAction extends AbstractAction {
     
    16261624
    16271625    /**
    1628      * Action for editing the currently selected relation
    1629      *
    1630      *
     1626     * Action for editing the currently selected relation.
    16311627     */
    16321628    class EditAction extends AbstractAction implements ListSelectionListener {
     
    17361732            }
    17371733        }
    1738 
    17391734    }
    17401735
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberRoleCellEditor.java

    r6246 r7556  
    1010
    1111import org.openstreetmap.josm.data.osm.DataSet;
     12import org.openstreetmap.josm.data.osm.Relation;
    1213import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField;
    1314import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList;
     
    1516public class MemberRoleCellEditor extends AbstractCellEditor implements TableCellEditor {
    1617    private AutoCompletingTextField editor = null;
    17     private DataSet ds;
     18    private final DataSet ds;
     19    private final Relation relation;
    1820
    1921    /** user input is matched against this list of auto completion items */
     
    2123
    2224    /**
    23      * constructor
     25     * Constructs a new {@code MemberRoleCellEditor}.
     26     * @param ds the data set. Must not be null
     27     * @param relation the relation. Can be null
    2428     */
    25     public MemberRoleCellEditor(DataSet ds) {
     29    public MemberRoleCellEditor(DataSet ds, Relation relation) {
    2630        this.ds = ds;
     31        this.relation = relation;
    2732        editor = new AutoCompletingTextField();
    2833        editor.setBorder(BorderFactory.createEmptyBorder(1,1,1,1));
     
    3136    }
    3237
    33     /**
    34      * replies the table cell editor
    35      */
    3638    @Override
    3739    public Component getTableCellEditorComponent(JTable table,
     
    4143        editor.setText(role);
    4244        autoCompletionList.clear();
    43         ds.getAutoCompletionManager().populateWithMemberRoles(autoCompletionList);
     45        ds.getAutoCompletionManager().populateWithMemberRoles(autoCompletionList, relation);
    4446        return editor;
    4547    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java

    r7005 r7556  
    2929import org.openstreetmap.josm.actions.ZoomToAction;
    3030import org.openstreetmap.josm.data.osm.OsmPrimitive;
     31import org.openstreetmap.josm.data.osm.Relation;
    3132import org.openstreetmap.josm.data.osm.RelationMember;
    3233import org.openstreetmap.josm.data.osm.Way;
     
    5051     * constructor for relation member table
    5152     *
    52      * @param layer the data layer of the relation
     53     * @param layer the data layer of the relation. Must not be null
     54     * @param relation the relation. Can be null
    5355     * @param model the table model
    5456     */
    55     public MemberTable(OsmDataLayer layer, MemberTableModel model) {
    56         super(model, new MemberTableColumnModel(layer.data), model.getSelectionModel());
     57    public MemberTable(OsmDataLayer layer, Relation relation, MemberTableModel model) {
     58        super(model, new MemberTableColumnModel(layer.data, relation), model.getSelectionModel());
    5759        setLayer(layer);
    5860        model.addMemberModelListener(this);
     
    157159     * <li>it jumps over cells in the first column</li> <li>it automatically add a new empty row
    158160     * when the user leaves the last cell in the table</li></ul>
    159      *
    160      *
    161161     */
    162162    class SelectNextColumnCellAction extends AbstractAction {
     
    191191     * Action to be run when the user navigates to the previous cell in the table, for instance by
    192192     * pressing Shift-TAB
    193      *
    194193     */
    195194    private class SelectPreviousColumnCellAction extends AbstractAction {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableColumnModel.java

    r6296 r7556  
    88
    99import org.openstreetmap.josm.data.osm.DataSet;
     10import org.openstreetmap.josm.data.osm.Relation;
    1011
    1112public class MemberTableColumnModel extends DefaultTableColumnModel {
    1213
    13     public MemberTableColumnModel(DataSet ds) {
     14    /**
     15     * Constructs a new {@code MemberTableColumnModel}.
     16     * @param ds the data set. Must not be null
     17     * @param relation the relation. Can be null
     18     */
     19    public MemberTableColumnModel(DataSet ds, Relation relation) {
    1420        TableColumn col = null;
    1521
     
    2026        col.setPreferredWidth(100);
    2127        col.setCellRenderer(new MemberTableRoleCellRenderer());
    22         col.setCellEditor(new MemberRoleCellEditor(ds));
     28        col.setCellEditor(new MemberRoleCellEditor(ds, relation));
    2329        addColumn(col);
    2430
Note: See TracChangeset for help on using the changeset viewer.