Changeset 2869 in josm for trunk/src/org


Ignore:
Timestamp:
2010-01-17T11:56:07+01:00 (15 years ago)
Author:
jttt
Message:

Removed ToggleDialog.tearDown(). All listeners should be unregistered in hideNotify()

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/Main.java

    r2817 r2869  
    111111    public static MapFrame map;
    112112    /**
    113      * The dialog that gets displayed during background task execution.
    114      */
    115     //public static PleaseWaitDialog pleaseWaitDlg;
    116 
    117     /**
    118113     * True, when in applet mode
    119114     */
     
    184179            map.mapView.removeLayer(layer);
    185180            if (map.mapView.getAllLayers().isEmpty()) {
    186                 map.tearDownDialogsPane();
    187181                setMapFrame(null);
    188182            }
  • trunk/src/org/openstreetmap/josm/gui/MapFrame.java

    r2657 r2869  
    199199        // MapFrame gets destroyed when the last layer is removed, but the status line background
    200200        // thread that collects the information doesn't get destroyed automatically.
    201         if(statusLine.thread == null) return;
    202         try {
    203             statusLine.thread.interrupt();
    204         } catch (Exception e) {}
     201        if(statusLine.thread != null) {
     202            try {
     203                statusLine.thread.interrupt();
     204            } catch (Exception e) {
     205                e.printStackTrace();
     206            }
     207        }
    205208    }
    206209
     
    214217    public void initializeDialogsPane() {
    215218        dialogsPanel.initialize(allDialogs);
    216     }
    217 
    218     /**
    219      *
    220      */
    221     public void tearDownDialogsPane() {
    222         dialogsPanel.tearDown();
    223219    }
    224220
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r2626 r2869  
    144144        public void run() {
    145145            for (;;) {
     146
    146147                MouseState ms = new MouseState();
    147148                synchronized (this) {
     
    595596
    596597    @Override
    597     public void addMouseListener(MouseListener ml) {
     598    public synchronized void addMouseListener(MouseListener ml) {
    598599        //super.addMouseListener(ml);
    599600        lonText.addMouseListener(ml);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java

    r2801 r2869  
    142142        MapView.removeEditLayerChangeListener(inSelectionModel);
    143143        DataSet.selListeners.remove(inSelectionModel);
    144     }
    145 
    146     @Override
    147     public void tearDown() {
    148         unregisterAsListener();
    149144    }
    150145
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java

    r2711 r2869  
    119119
    120120        build();
     121        refreshView();
     122    }
     123
     124    @Override
     125    public void showNotify() {
    121126        DataSet.selListeners.add(this);
    122127        MapView.addLayerChangeListener(this);
    123         refreshView();
    124128    }
    125129
    126130    @Override
    127     public void tearDown() {
     131    public void hideNotify() {
    128132        MapView.removeLayerChangeListener(this);
    129133        DataSet.selListeners.remove(this);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java

    r2749 r2869  
    4646        this.add(mSpltPane);
    4747        reconstruct(Action.ELEMENT_SHRINKS, null);
    48     }
    49 
    50     /**
    51      * Invoke before the panel is discarded. This will in turn call {@see ToggleDialog#tearDown()}
    52      * on every dialog.
    53      *
    54      */
    55     public void tearDown() {
    56         for(ToggleDialog dialog: allDialogs) {
    57             dialog.tearDown();
    58         }
    5948    }
    6049
  • trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java

    r2710 r2869  
    77import java.awt.BorderLayout;
    88import java.awt.Component;
    9 import java.awt.GridLayout;
    109import java.awt.event.ActionEvent;
    1110import java.awt.event.ActionListener;
     
    1514import javax.swing.JCheckBox;
    1615import javax.swing.JPanel;
    17 import javax.swing.JPopupMenu;
    1816import javax.swing.JScrollPane;
    1917import javax.swing.JTable;
     
    4745    private SideButton upButton;
    4846    private SideButton downButton;
    49     private JPopupMenu popupMenu;
    5047
    5148    public FilterDialog(){
    5249        super(tr("Filter"), "filter", tr("Filter objects and hide/disable them."),
    5350                Shortcut.registerShortcut("subwindow:filter", tr("Toggle: {0}", tr("Filter")), KeyEvent.VK_F, Shortcut.GROUP_LAYER, Shortcut.SHIFT_DEFAULT), 162);
    54 
     51        build();
     52    }
     53
     54    @Override
     55    public void showNotify() {
    5556        MapView.addLayerChangeListener(this);
    56         build();
    5757    }
    5858
    5959    @Override
    60     public void tearDown() {
     60    public void hideNotify() {
    6161        MapView.removeLayerChangeListener(this);
    6262    }
     
    144144                    @Override
    145145                    public String getToolTipText(MouseEvent e) {
    146                         String tip = null;
    147146                        java.awt.Point p = e.getPoint();
    148147                        int index = columnModel.getColumnIndexAtX(p.x);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r2847 r2869  
    4747import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    4848import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
     49import org.openstreetmap.josm.tools.CheckParameterUtil;
    4950import org.openstreetmap.josm.tools.ImageProvider;
    5051import org.openstreetmap.josm.tools.Shortcut;
    5152import org.openstreetmap.josm.tools.ImageProvider.OverlayPosition;
    52 import org.openstreetmap.josm.tools.CheckParameterUtil;
    5353
    5454/**
     
    7070     */
    7171    static public void createInstance(MapFrame mapFrame) {
     72        if (instance != null)
     73            throw new IllegalStateException("Dialog was already created");
    7274        instance = new LayerListDialog(mapFrame);
    7375    }
     
    115117        activateLayerAction = new ActivateLayerAction();
    116118        adaptTo(activateLayerAction, selectionModel);
    117         MapView.addLayerChangeListener(activateLayerAction);
    118119        buttonPanel.add(new SideButton(activateLayerAction));
    119120
     
    153154        selectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    154155        model = new LayerListModel(selectionModel);
    155         MapView.addLayerChangeListener(model);
    156156
    157157        // create the list control
     
    185185
    186186    @Override
    187     public void tearDown() {
     187    public void showNotify() {
     188        MapView.addLayerChangeListener(activateLayerAction);
     189        MapView.addLayerChangeListener(model);
     190    }
     191
     192    @Override
     193    public void hideNotify() {
    188194        MapView.removeLayerChangeListener(model);
    189195        MapView.removeLayerChangeListener(activateLayerAction);
     
    240246                }
    241247        );
     248    }
     249
     250    @Override
     251    public void destroy() {
     252        super.destroy();
     253        instance = null;
    242254    }
    243255
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r2710 r2869  
    159159        }
    160160
    161         MapView.addEditLayerChangeListener(this);
    162     }
    163 
    164     @Override
    165     public void tearDown() {
    166         MapView.removeEditLayerChangeListener(this);
    167161    }
    168162
     
    170164    public void showNotify() {
    171165        DataSet.selListeners.add(this);
     166        MapView.addEditLayerChangeListener(this);
    172167        updateSelection();
    173168    }
     
    176171    public void hideNotify() {
    177172        DataSet.selListeners.remove(this);
     173        MapView.removeEditLayerChangeListener(this);
    178174    }
    179175
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r2770 r2869  
    77import java.awt.Component;
    88import java.awt.Dimension;
     9import java.awt.FlowLayout;
    910import java.awt.Graphics;
    10 import java.awt.FlowLayout;
     11import java.awt.GridBagLayout;
    1112import java.awt.GridLayout;
    12 import java.awt.GridBagLayout;
    1313import java.awt.Image;
    1414import java.awt.Rectangle;
     
    560560    }
    561561
    562     /**
    563      * This method is called by hosting panel before the panel with the toggle dialogs
    564      * and the toggle dialogs themself are discared, for instance because no layer is
    565      * left in JOSM and  the main screen turns from the map editor to the MOTD panel.
    566      *
    567      * Override in subclasses to unregister as listener. After tearDown() is invoked
    568      * the dialog should be registered as listener.
    569      *
    570      * The default implementation is empty.
    571      */
    572     public void tearDown() {}
    573 
    574562    protected JPanel getButtonPanel(int columns) {
    575563        JPanel pnl = new JPanel();
    576564        pnl.setLayout(Main.pref.getBoolean("dialog.align.left", false)
    577         ? new FlowLayout(FlowLayout.LEFT) : new GridLayout(1,columns));
     565                ? new FlowLayout(FlowLayout.LEFT) : new GridLayout(1,columns));
    578566        return pnl;
    579567    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java

    r2803 r2869  
    6767
    6868        build();
     69    }
     70
     71    @Override
     72    public void showNotify() {
    6973        DataSet.selListeners.add(this);
    7074        MapView.addLayerChangeListener(this);
     
    7276
    7377    @Override
    74     public void tearDown() {
     78    public void hideNotify() {
    7579        MapView.removeLayerChangeListener(this);
    7680        DataSet.selListeners.remove(this);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r2742 r2869  
    155155        listOfUsedTags.rebuildNecessary();
    156156        DataSet.selListeners.add(this);
     157        MapView.addEditLayerChangeListener(this);
    157158        updateSelection();
    158159    }
     
    163164        DatasetEventManager.getInstance().removeDatasetListener(dataChangedAdapter);
    164165        DataSet.selListeners.remove(this);
     166        MapView.removeEditLayerChangeListener(this);
    165167    }
    166168
     
    587589        buttonPanel.add(this.btnDel);
    588590        add(buttonPanel, BorderLayout.SOUTH);
    589 
    590         MapView.addEditLayerChangeListener(this);
    591     }
    592 
    593     @Override
    594     public void tearDown() {
    595         MapView.removeEditLayerChangeListener(this);
    596591    }
    597592
Note: See TracChangeset for help on using the changeset viewer.