Changeset 1294 in josm


Ignore:
Timestamp:
2009-01-18T16:40:32+01:00 (14 years ago)
Author:
ulfl
Message:

if a list element is selected, select it on the map and zoom to it immediately

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

Legend:

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

    r1293 r1294  
    3232import javax.swing.JTable;
    3333import javax.swing.ListSelectionModel;
     34import javax.swing.event.ListSelectionEvent;
     35import javax.swing.event.ListSelectionListener;
    3436import javax.swing.event.TableModelEvent;
    3537import javax.swing.event.TableModelListener;
     
    291293            }
    292294        });
     295        ListSelectionModel lsm = memberTable.getSelectionModel();
     296        lsm.addListSelectionListener(new ListSelectionListener() {
     297            @Override public void valueChanged(ListSelectionEvent e) {
     298                ArrayList<OsmPrimitive> sel;
     299                int cnt = memberTable.getSelectedRowCount();
     300                if(cnt > 0)
     301                {
     302                    sel = new ArrayList<OsmPrimitive>(cnt);
     303                    for (int i : memberTable.getSelectedRows())
     304                        sel.add((OsmPrimitive)memberTable.getValueAt(i, 1));
     305                }
     306                else
     307                {
     308                    cnt = memberTable.getRowCount();
     309                    sel = new ArrayList<OsmPrimitive>(cnt);
     310                    for (int i = 0; i < cnt; ++i)
     311                        sel.add((OsmPrimitive)memberTable.getValueAt(i, 1));
     312                }
     313                Main.ds.setSelected(sel);
     314            }
     315        });
    293316        memberTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    294317
     
    353376        }));
    354377
    355         buttonPanel.add(createButton(marktr("Select"),"select",
     378        /*buttonPanel.add(createButton(marktr("Select"),"select",
    356379        tr("Highlight the member from the current table row as JOSM's selection"), KeyEvent.VK_S, new ActionListener() {
    357380            public void actionPerformed(ActionEvent e) {
     
    373396                Main.ds.setSelected(sel);
    374397            }
    375         }));
     398        }));*/
    376399        buttonPanel.add(createButton(marktr("Download Members"),"downloadincomplete",
    377400        tr("Download all incomplete ways and nodes in relation"), KeyEvent.VK_L, new ActionListener() {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r1228 r1294  
    1919import javax.swing.ListSelectionModel;
    2020import javax.swing.event.ListSelectionListener;
     21import javax.swing.event.ListSelectionEvent;
    2122
    2223import org.openstreetmap.josm.Main;
     24import org.openstreetmap.josm.actions.AutoScaleAction;
    2325import org.openstreetmap.josm.command.DeleteCommand;
    2426import org.openstreetmap.josm.data.osm.DataSet;
     
    6971            }
    7072        });
     73        displaylist.addListSelectionListener(new ListSelectionListener(){
     74            @Override public void valueChanged(ListSelectionEvent e) {
     75                Relation toEdit = (Relation) displaylist.getSelectedValue();
     76                if (toEdit != null) {
     77                    Main.ds.setSelected(toEdit);
     78                    AutoScaleAction asa = new AutoScaleAction("selection");
     79                    asa.actionPerformed(null);
     80                }
     81            }
     82        });
    7183
    7284        add(new JScrollPane(displaylist), BorderLayout.CENTER);
     
    8193        }), GBC.std());
    8294
    83         buttonPanel.add(new SideButton(marktr("Select"), "select", "Selection", tr("Select this relation"), new ActionListener() {
     95        /*buttonPanel.add(new SideButton(marktr("Select"), "select", "Selection", tr("Select this relation"), new ActionListener() {
    8496            public void actionPerformed(ActionEvent e) {
    8597                // replace selection with the relation from the list
    8698                Main.ds.setSelected((Relation)displaylist.getSelectedValue());
    8799            }
    88         }), GBC.std());
     100        }), GBC.std());*/
    89101
    90102        buttonPanel.add(new SideButton(marktr("Edit"), "edit", "Selection", tr( "Open an editor for the selected relation"), new ActionListener() {
Note: See TracChangeset for help on using the changeset viewer.