Changeset 4536 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2011-10-21T23:57:52+02:00 (13 years ago)
Author:
Don-vip
Message:

Improved plugin interaction with selection and popups of Relation, Selection and Properties dialogs.

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

Legend:

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

    r4475 r4536  
    3030import javax.swing.event.ListSelectionEvent;
    3131import javax.swing.event.ListSelectionListener;
     32import javax.swing.event.PopupMenuListener;
    3233
    3334import org.openstreetmap.josm.Main;
     
    808809    }
    809810
     811    public void addPopupMenuListener(PopupMenuListener l) {
     812        popupMenu.addPopupMenuListener(l);
     813    }
     814
     815    public void removePopupMenuListener(PopupMenuListener l) {
     816        popupMenu.addPopupMenuListener(l);
     817    }
     818   
     819    public Collection<Relation> getSelectedRelations() {
     820        return model.getSelectedRelations();
     821    }
     822
    810823    /* ---------------------------------------------------------------------------------- */
    811824    /* DataSetListener                                                                    */
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r4462 r4536  
    3535import javax.swing.event.ListSelectionEvent;
    3636import javax.swing.event.ListSelectionListener;
     37import javax.swing.event.PopupMenuListener;
    3738
    3839import org.openstreetmap.josm.Main;
     
    224225        return popupMenu.add(a);
    225226    }
    226 
     227   
     228    public void addPopupMenuListener(PopupMenuListener l) {
     229        popupMenu.addPopupMenuListener(l);
     230    }
     231
     232    public void removePopupMenuListener(PopupMenuListener l) {
     233        popupMenu.addPopupMenuListener(l);
     234    }
     235   
     236    public Collection<OsmPrimitive> getSelectedPrimitives() {
     237        return model.getSelected();
     238    }
     239   
    227240    /**
    228241     * Updates the dialog title with a summary of the current JOSM selection
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r4526 r4536  
    5858import javax.swing.event.ListSelectionEvent;
    5959import javax.swing.event.ListSelectionListener;
     60import javax.swing.event.PopupMenuListener;
    6061import javax.swing.table.DefaultTableCellRenderer;
    6162import javax.swing.table.DefaultTableModel;
     
    7172import org.openstreetmap.josm.command.SequenceCommand;
    7273import org.openstreetmap.josm.data.SelectionChangedListener;
     74import org.openstreetmap.josm.data.osm.IRelation;
    7375import org.openstreetmap.josm.data.osm.Node;
    7476import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    12561258    }
    12571259   
     1260    public void addPropertyPopupMenuListener(PopupMenuListener l) {
     1261        propertyMenu.addPopupMenuListener(l);
     1262    }
     1263
     1264    public void removePropertyPopupMenuListener(PopupMenuListener l) {
     1265        propertyMenu.addPopupMenuListener(l);
     1266    }
     1267   
     1268    @SuppressWarnings("unchecked")
     1269    public Tag getSelectedProperty() {
     1270        int row = propertyTable.getSelectedRow();
     1271        if (row == -1) return null;
     1272        TreeMap<String, Integer> map = (TreeMap<String, Integer>) propertyData.getValueAt(row, 1);
     1273        return new Tag(
     1274                propertyData.getValueAt(row, 0).toString(),
     1275                map.size() > 1 ? "" : map.keySet().iterator().next());
     1276    }
     1277   
    12581278    public void addMembershipPopupMenuSeparator() {
    12591279        membershipMenu.addSeparator();
    12601280    }
    1261 
     1281   
    12621282    public JMenuItem addMembershipPopupMenuAction(Action a) {
    12631283        return membershipMenu.add(a);
    12641284    }
    12651285   
     1286    public void addMembershipPopupMenuListener(PopupMenuListener l) {
     1287        membershipMenu.addPopupMenuListener(l);
     1288    }
     1289
     1290    public void removeMembershipPopupMenuListener(PopupMenuListener l) {
     1291        membershipMenu.addPopupMenuListener(l);
     1292    }
     1293   
     1294    public IRelation getSelectedMembershipRelation() {
     1295        int row = membershipTable.getSelectedRow();
     1296        return row > -1 ? (IRelation) membershipData.getValueAt(row, 0) : null;
     1297    }
     1298
    12661299    public static interface RelationRelated {
    12671300        public Relation getRelation();
Note: See TracChangeset for help on using the changeset viewer.