Changeset 6038 in josm for trunk/src/org


Ignore:
Timestamp:
2013-06-28T17:39:49+02:00 (11 years ago)
Author:
akks
Message:

fix #8829: relation was often hanging JOSM after 6036 + better highlighting

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
6 edited

Legend:

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

    r6025 r6038  
    66import java.awt.BorderLayout;
    77import java.awt.Color;
     8import java.awt.Component;
    89import java.awt.event.ActionEvent;
    910import java.awt.event.KeyEvent;
     
    2021import javax.swing.AbstractListModel;
    2122import javax.swing.DefaultListSelectionModel;
     23import javax.swing.FocusManager;
    2224import javax.swing.JComponent;
    2325import javax.swing.JList;
     
    189191        popupMenuHandler.setPrimitives(sel);
    190192       
     193        Component focused = FocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
     194       
    191195        //update highlights
    192         if (Main.isDisplayingMapView()) {
    193             highlightHelper.highlightOnly(sel);
    194             Main.map.mapView.repaint();
     196        if (focused==displaylist && Main.isDisplayingMapView()) {
     197            if (highlightHelper.highlightOnly(sel)) {
     198                Main.map.mapView.repaint();
     199            }
    195200        }
    196201    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r6025 r6038  
    202202                layer.data.setSelected(Collections.singleton((OsmPrimitive)model.getElementAt(idx)));
    203203            } else if (Main.isDisplayingMapView()) {
    204                 helper.highlightOnly((OsmPrimitive)model.getElementAt(idx));
    205                 Main.map.mapView.repaint();
     204                if (helper.highlightOnly((OsmPrimitive)model.getElementAt(idx))) {
     205                    Main.map.mapView.repaint();
     206                }
    206207            }
    207208        }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r6025 r6038  
    418418                    int row = membershipTable.rowAtPoint(e.getPoint());
    419419                    if (row>=0) {
    420                         highlightHelper.highlightOnly((Relation) membershipTable.getValueAt(row, 0));
    421                         Main.map.mapView.repaint();
     420                        if (highlightHelper.highlightOnly((Relation) membershipTable.getValueAt(row, 0))) {
     421                            Main.map.mapView.repaint();
     422                        }
    422423                    }
    423424                }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java

    r6024 r6038  
    609609            // make sure all registered listeners are unregistered
    610610            //
     611            memberTable.stopHighlighting();
    611612            selectionTableModel.unregister();
    612613            memberTableModel.unregister();
     
    13581359        public void run() {
    13591360            Main.pref.put("relation.editor.generic.lastrole", tfRole.getText());
     1361            memberTable.stopHighlighting();
    13601362            if (getRelation() == null) {
    13611363                applyNewRelation();
     
    13981400        @Override
    13991401        public void actionPerformed(ActionEvent e) {
     1402            memberTable.stopHighlighting();
    14001403            if (!memberTableModel.hasSameMembersAs(getRelationSnapshot()) || tagEditorPanel.getModel().isDirty()) {
    14011404                //give the user a chance to save the changes
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java

    r6036 r6038  
    2121import javax.swing.KeyStroke;
    2222import javax.swing.ListSelectionModel;
     23import javax.swing.SwingUtilities;
    2324import javax.swing.event.ListSelectionEvent;
    2425import javax.swing.event.ListSelectionListener;
     
    118119    }
    119120
    120     private void initHighlighting() {
    121         getMemberTableModel().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
     121    ListSelectionListener highlighterListener = new ListSelectionListener() {
    122122            @Override
    123123            public void valueChanged(ListSelectionEvent lse) {
    124124                if (Main.isDisplayingMapView()) {
    125125                    Collection<RelationMember> sel = getMemberTableModel().getSelectedMembers();
    126                     ArrayList<OsmPrimitive> toHighlight = new ArrayList<OsmPrimitive>();
     126                    final ArrayList<OsmPrimitive> toHighlight = new ArrayList<OsmPrimitive>();
    127127                    for (RelationMember r: sel) {
    128128                        if (r.getMember().isUsable()) {
     
    130130                        }
    131131                    }
    132                     if (highlightHelper.highlightOnly(toHighlight)) {
    133                         Main.map.mapView.repaint();
    134                     }
     132                    SwingUtilities.invokeLater(new Runnable() {
     133                        @Override
     134                        public void run() {
     135                            if (highlightHelper.highlightOnly(toHighlight)) {
     136                                Main.map.mapView.repaint();
     137                            }
     138                        }
     139                    });
    135140                }
    136             }});
     141            }};
     142   
     143    private void initHighlighting() {
     144        getMemberTableModel().getSelectionModel().addListSelectionListener(highlighterListener);
    137145        if (Main.isDisplayingMapView()) {
    138146            HighlightHelper.clearAllHighlighted();
     
    200208        super.unlinkAsListener();
    201209        MapView.removeLayerChangeListener(zoomToGap);
    202         highlightHelper.clear();
     210    }
     211   
     212    public void stopHighlighting() {
     213        if (highlighterListener == null) return;
     214        getMemberTableModel().getSelectionModel().removeListSelectionListener(highlighterListener);
     215        highlighterListener = null;
     216        if (Main.isDisplayingMapView()) {
     217            HighlightHelper.clearAllHighlighted();
     218            Main.map.mapView.repaint();
     219        }
    203220    }
    204221
  • trunk/src/org/openstreetmap/josm/gui/util/HighlightHelper.java

    r6026 r6038  
    4848            needsRepaint |= setHighlight(p, true);
    4949        }
    50         //return true;
     50
    5151        return needsRepaint;
    5252    }
Note: See TracChangeset for help on using the changeset viewer.