Changeset 2930 in josm


Ignore:
Timestamp:
2010-02-03T09:07:36+01:00 (10 years ago)
Author:
jttt
Message:

Make sure ConflictResolutionDialog is disposed when closed

Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

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

    r2880 r2930  
    165165        conflicts = editLayer == null?new ConflictCollection():editLayer.getConflicts();
    166166        model.fireContentChanged();
     167        updateTitle(conflicts.size());
     168    }
     169
     170    private void updateTitle(int conflictsCount) {
     171        if (conflictsCount > 0) {
     172            setTitle(tr("Conflicts: {0} unresolved", conflicts.size()));
     173        } else {
     174            setTitle(tr("Conflict"));
     175        }
    167176    }
    168177
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java

    r2915 r2930  
    2121import javax.swing.JOptionPane;
    2222import javax.swing.JPanel;
     23import javax.swing.WindowConstants;
    2324
    2425import org.openstreetmap.josm.Main;
     
    4344    private ConflictResolver resolver;
    4445
     46    private ApplyResolutionAction applyResolutionAction;
     47
    4548    /**
    4649     * restore position and size on screen from preference settings
     
    9598        Main.pref.put("conflictresolutiondialog.width", Integer.toString(d.width));
    9699        Main.pref.put("conflictresolutiondialog.height", Integer.toString(d.height));
     100    }
     101
     102    @Override
     103    public void removeNotify() {
     104        super.removeNotify();
     105        unregisterListeners();
    97106    }
    98107
     
    104113        } else {
    105114            rememberPositionAndDimension();
     115            unregisterListeners();
    106116        }
    107117        super.setVisible(isVisible);
     118    }
     119
     120    private void closeDialog() {
     121        setVisible(false);
     122        dispose();
    108123    }
    109124
     
    117132        pnl.setLayout(new FlowLayout(FlowLayout.CENTER));
    118133
    119         ApplyResolutionAction applyResolutionAction = new ApplyResolutionAction();
    120         resolver.addPropertyChangeListener(applyResolutionAction);
     134        applyResolutionAction = new ApplyResolutionAction();
    121135        JButton btn = new JButton(applyResolutionAction);
    122136        btn.setName("button.apply");
     
    135149    }
    136150
     151    private void registerListeners() {
     152        resolver.addPropertyChangeListener(applyResolutionAction);
     153    }
     154
     155    private void unregisterListeners() {
     156        resolver.removePropertyChangeListener(applyResolutionAction);
     157    }
     158
    137159    /**
    138160     * builds the GUI
    139161     */
    140162    protected void build() {
     163        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    141164        updateTitle();
    142165        getContentPane().setLayout(new BorderLayout());
     
    149172        resolver.addPropertyChangeListener(this);
    150173        HelpUtil.setHelpContext(this.getRootPane(), "Dialog/ConflictDialog");
     174
     175        registerListeners();
    151176    }
    152177
     
    172197
    173198        public void actionPerformed(ActionEvent arg0) {
    174             setVisible(false);
     199            closeDialog();
    175200        }
    176201    }
     
    231256                switch(ret) {
    232257                case JOptionPane.YES_OPTION:
    233                     setVisible(false);
     258                    closeDialog();
    234259                    break;
    235260                default:
     
    240265                Command cmd = resolver.buildResolveCommand();
    241266                Main.main.undoRedo.add(cmd);
    242                 setVisible(false);
     267                closeDialog();
    243268            } catch(OperationCancelledException e) {
    244269                // do nothing. Exception already reported
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r2912 r2930  
    174174        SelectionEventManager.getInstance().removeSelectionListener(this);
    175175        MapView.removeEditLayerChangeListener(this);
     176        updateTitle(0, 0, 0);
    176177    }
    177178
     
    274275        }
    275276
    276         if( (nodes+ways+relations) != 0) {
    277             setTitle(tr("Sel.: Rel.:{0} / Ways:{1} / Nodes:{2}", relations, ways, nodes));
    278         } else {
    279             setTitle(tr("Selection"));
    280         }
     277        updateTitle(nodes, ways, relations);
    281278
    282279        if (selectionHistory != null && newSelection.size() > 0 && !newSelection.equals(historyIgnoreSelection)) {
     
    293290                selectionHistory.removeLast();
    294291            }
     292        }
     293    }
     294
     295    private void updateTitle(int nodes, int ways, int relations) {
     296        if( (nodes+ways+relations) != 0) {
     297            setTitle(tr("Sel.: Rel.:{0} / Ways:{1} / Nodes:{2}", relations, ways, nodes));
     298        } else {
     299            setTitle(tr("Selection"));
    295300        }
    296301    }
  • trunk/src/org/openstreetmap/josm/tools/CopyList.java

    r2907 r2930  
    130130
    131131    private void rangeCheck(int index) {
    132         if (index >= size || index < 0) throw new IndexOutOfBoundsException();
     132        if (index >= size || index < 0) throw new IndexOutOfBoundsException("Index:" + index + " Size:" + size);
    133133    }
    134134
Note: See TracChangeset for help on using the changeset viewer.