Changeset 24821 in osm for applications


Ignore:
Timestamp:
2010-12-20T15:36:53+01:00 (14 years ago)
Author:
beata.jancso
Message:

bug fixes: http://josm.openstreetmap.de/ticket/5695

Location:
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/MapdustPlugin.java

    r24733 r24821  
    7979    private List<MapdustBug> mapdustBugList;
    8080   
     81    /** Flag indicating if the list of bugs was empty or not */
     82    private boolean wasEmpty;
     83   
    8184    /**
    8285     * Builds a new <code>MapDustPlugin</code> object based on the given
     
    106109        } else {
    107110            /* add MapDust dialog window */
    108             Shortcut shortcut = Shortcut.registerShortcut("mapdust",
    109                     tr("Toggle: {0}", tr("Open MapDust")), KeyEvent.VK_0, 
     111            Shortcut shortcut = Shortcut.registerShortcut("mapdust", 
     112                    tr("Toggle: {0}", tr("Open MapDust")), KeyEvent.VK_0,
    110113                    Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT);
    111114            String name = "MapDust bug reports";
     
    116119            mapdustGUI.addObserver(this);
    117120            newMapFrame.addToggleDialog(mapdustGUI);
     121            MapView.addZoomChangeListener(this);
    118122            MapView.addLayerChangeListener(this);
    119             MapView.addZoomChangeListener(this);
    120123            Main.map.mapView.addMouseListener(this);
    121124        }
     
    135138                if (getMapdustGUI().isDialogShowing()) {
    136139                    /* updates the views */
    137                     updateView();
    138                     /* show message if there is not bug in the given area */
    139                     if (this.mapdustBugList == null
    140                             || this.mapdustBugList.size() == 0) {
    141                         String waringMessage = "There is no MapDust bug ";
    142                         waringMessage += "in your visible area.";
     140                    if ((this.mapdustBugList == null || this.mapdustBugList
     141                            .size() == 0) && !wasEmpty) {
     142                        updateView();
     143                        String waringMessage = "There is no MapDust bug in ";
     144                        waringMessage += "your visible area.";
    143145                        JOptionPane.showMessageDialog(Main.parent,
    144146                                tr(waringMessage), tr("Warning"),
    145147                                JOptionPane.WARNING_MESSAGE);
     148                        wasEmpty = true;
     149                    } else {
     150                        updateView();
     151                        wasEmpty = false;
    146152                    }
    147153                }
     
    215221            }
    216222            mapdustLayer = null;
     223            wasEmpty = false;
    217224        }
    218225    }
     
    223230                && Main.map.mapView.getActiveLayer() == getMapdustLayer()) {
    224231            /* show add bug dialog */
    225             if (event.getClickCount() == 2) {
    226                 mapdustGUI.getPanel().getBtnPanel().getBtnWorkOffline()
    227                         .setEnabled(false);
    228                 mapdustGUI.getPanel().getBtnPanel().getBtnRefresh()
    229                         .setEnabled(false);
    230                 mapdustGUI.getPanel().getBtnPanel().getBtnAddComment()
    231                         .setEnabled(false);
    232                 mapdustGUI.getPanel().getBtnPanel().getBtnFixBugReport()
    233                         .setEnabled(false);
    234                 mapdustGUI.getPanel().getBtnPanel().getBtnInvalidateBugReport()
    235                         .setEnabled(false);
    236                 mapdustGUI.getPanel().getBtnPanel().getBtnReOpenBugReport()
    237                         .setEnabled(false);
    238                 Main.pref.put("mapdust.modify", true);
    239                 MapdustBug selectedBug = mapdustGUI.getPanel().getSelectedBug();
    240                 if (selectedBug != null) {
    241                     Main.pref.put("selectedBug.status", selectedBug.getStatus()
    242                             .getValue());
     232            if (event.getButton() == MouseEvent.BUTTON3
     233                    && event.getClickCount() == 2) {
     234                String mapdustAddBug = Main.pref.get("mapdust.addBug");
     235                boolean addBug = Boolean.parseBoolean(mapdustAddBug);
     236                if (!addBug) {
     237                    mapdustGUI.getPanel().getBtnPanel().getBtnWorkOffline()
     238                            .setEnabled(false);
     239                    mapdustGUI.getPanel().getBtnPanel().getBtnRefresh()
     240                            .setEnabled(false);
     241                    mapdustGUI.getPanel().getBtnPanel().getBtnAddComment()
     242                            .setEnabled(false);
     243                    mapdustGUI.getPanel().getBtnPanel().getBtnFixBugReport()
     244                            .setEnabled(false);
     245                    mapdustGUI.getPanel().getBtnPanel()
     246                            .getBtnInvalidateBugReport().setEnabled(false);
     247                    mapdustGUI.getPanel().getBtnPanel().getBtnReOpenBugReport()
     248                            .setEnabled(false);
     249                    Main.pref.put("mapdust.modify", true);
     250                    MapdustBug selectedBug =
     251                            mapdustGUI.getPanel().getSelectedBug();
     252                    if (selectedBug != null) {
     253                        Main.pref.put("selectedBug.status", selectedBug
     254                                .getStatus().getValue());
     255                    } else {
     256                        Main.pref.put("selectedBug.status", "create");
     257                    }
     258                    String title = "Create bug report";
     259                    String iconName = "dialogs/open.png";
     260                    String messageText =
     261                            "In order to create a new bug report you";
     262                    messageText += " need to provide your nickname and a brief";
     263                    messageText += " description for the bug.";
     264                    Point point = event.getPoint();
     265                    CreateIssueDialog dialog =
     266                            new CreateIssueDialog(tr(title), iconName,
     267                                    tr(messageText), point, this);
     268                    dialog.setLocationRelativeTo(null);
     269                    dialog.getContentPane().setPreferredSize(dialog.getSize());
     270                    dialog.pack();
     271                    dialog.setVisible(true);
    243272                } else {
    244                     Main.pref.put("selectedBug.status", "create");
     273                    Main.pref.put("mapdust.addBug", false);
    245274                }
    246                 String title = "Create bug report";
    247                 String iconName = "dialogs/open.png";
    248                 String messageText = "In order to create a new bug report you";
    249                 messageText += " need to provide your nickname and a brief";
    250                 messageText += " description for the bug.";
    251                 Point point = event.getPoint();
    252                 CreateIssueDialog dialog =
    253                         new CreateIssueDialog(tr(title), iconName,
    254                                 tr(messageText), point, this);
    255                 dialog.setLocationRelativeTo(null);
    256                 dialog.getContentPane().setPreferredSize(dialog.getSize());
    257                 dialog.pack();
    258                 dialog.setVisible(true);
    259                 return;
    260275            }
    261276            if (event.getButton() == MouseEvent.BUTTON1) {
     
    280295        /* update the dialog with the new data */
    281296        mapdustGUI.update(mapdustBugList, this);
     297        mapdustGUI.revalidate();
    282298        if (mapdustLayer == null) {
    283299            /* create and add the layer */
    284             mapdustLayer = new MapdustLayer("MapDust", mapdustGUI, mapdustBugList);
     300            mapdustLayer =
     301                    new MapdustLayer("MapDust", mapdustGUI, mapdustBugList);
    285302            Main.main.addLayer(mapdustLayer);
    286303            Main.map.mapView.moveLayer(mapdustLayer, 0);
     304            ;
     305            Main.map.mapView.addMouseListener(this);
    287306            MapView.addLayerChangeListener(this);
    288307            MapView.addZoomChangeListener(this);
     
    295314        }
    296315        /* repaint */
    297         Main.map.mapView.invalidate();
     316        Main.map.mapView.revalidate();
    298317        Main.map.repaint();
    299         Main.map.mapView.repaint();
    300     }
    301    
    302     /**
    303      * Returns the bounds of the current map view.
    304      *
    305      * @return A <code>Bounds</code> object
    306      */
    307     private Bounds getBounds() {
    308         MapView mapView = Main.map.mapView;
    309         Bounds bounds =
    310                 new Bounds(mapView.getLatLon(0, mapView.getHeight()),
    311                         mapView.getLatLon(mapView.getWidth(), 0));
    312         return bounds;
    313318    }
    314319   
     
    320325    public void initialUpdate() {
    321326        if (containsOsmDataLayer()) {
    322             Main.worker.execute(new Runnable() {
    323                
    324                 @Override
    325                 public void run() {
    326                     updateData();
    327                    
    328                 }
    329             });
    330         }
    331     }
    332    
     327            updateData();
     328        }
     329    }
     330   
     331    /**
     332     * If the zoom was changed, download the bugs from the current map view.
     333     */
    333334    @Override
    334335    public void zoomChanged() {
     
    388389            throws MapdustServiceHandlerException {
    389390        /* get the bounding box */
    390         Bounds bounds = getBounds();
     391        MapView mapView = Main.map.mapView;
     392        Bounds bounds =
     393                new Bounds(mapView.getLatLon(0, mapView.getHeight()),
     394                        mapView.getLatLon(mapView.getWidth(), 0));
    391395        Double minLon = bounds.getMin().lon();
    392396        Double minLat = bounds.getMin().lat();
     
    425429   
    426430    @Override
    427     public void mouseEntered(MouseEvent arg0) {}
     431    public void mouseEntered(MouseEvent event) {
     432
     433    }
    428434   
    429435    @Override
     
    431437   
    432438    @Override
    433     public void mousePressed(MouseEvent arg0) {}
     439    public void mousePressed(MouseEvent event) {
     440
     441    }
    434442   
    435443    @Override
     
    473481   
    474482    /**
     483     * Returns the list of <code>MapdustBug</code> objects
     484     *
    475485     * @return the mapdustBugList
    476486     */
     
    480490   
    481491    /**
     492     * Sets the list of <code>MapdustBug</code> objects
     493     *
    482494     * @param mapdustBugList the mapdustBugList to set
    483495     */
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/MapdustGUI.java

    r24733 r24821  
    5656/**
    5757 * This class is the main graphical user interface class.
    58  *
     58 * 
    5959 * @author Bea
    6060 */
     
    6262        MapdustActionListObserver, MapdustBugDetailsObservable,
    6363        MapdustInitialUpdateObservable {
    64 
     64   
    6565    /** The serial version UID */
    6666    private static final long serialVersionUID = 1L;
    67 
     67   
    6868    /** The list of MapDust bug details observers */
    6969    private final ArrayList<MapdustBugDetailsObserver> bugDetailsObservers =
    7070            new ArrayList<MapdustBugDetailsObserver>();
    71 
     71   
    7272    /** The list of MapDust initial update observers */
    7373    private final ArrayList<MapdustInitialUpdateObserver> initialUpdateObservers =
    7474            new ArrayList<MapdustInitialUpdateObserver>();
    75 
     75   
    7676    /** The <code>MapdustPanel</code> object */
    7777    private MapdustPanel panel;
    78 
     78   
    7979    /** The <code>MapdustActionPanel</code> object */
    8080    private MapdustActionPanel queuePanel;
    81 
     81   
    8282    /** The <code>JTabbedPanel</code> object */
    8383    private JTabbedPane tabbedPane;
    84 
     84   
    8585    /** The <code>MapdustPlugin</code> plugin */
    8686    private MapdustPlugin mapdustPlugin;
    87 
     87   
    8888    /** The <code>MapdustBugPropertiesPanel</code> */
    8989    private final MapdustBugPropertiesPanel detailsPanel;
    90 
     90   
    9191    /** The <code>JPanel</code> */
    9292    private JPanel mainPanel;
    93 
     93   
    9494    /**
    9595     * Flag indicating if the MapDust data was downloaded and the view was
     
    9797     */
    9898    private boolean initialUpdate = false;
    99 
     99   
    100100    /**
    101101     * Builds a <code>MapdustGUi</code> based on the given parameters.
    102      *
     102     * 
    103103     * @param name The name of the GUI
    104104     * @param iconName The name of the icon
     
    149149        }
    150150    }
    151 
     151   
    152152    /**
    153153     * Updates the MapDust GUI with the given list of <code>MapdustBug</code>
    154154     * objects.
    155      *
     155     * 
    156156     * @param mapdustBugs The list of <code>MapdustBug</code> objects
    157157     * @param mapdustPlugin The <code>MapdustPlugin</code> object
     
    178178            /* add panels with updated data */
    179179            panel = new MapdustPanel(mapdustBugs, "Bug reports", mapdustPlugin);
    180             panel.addObserver(detailsPanel);
    181180            MapdustBug selectedBug =
    182181                    (mapdustBugs != null && mapdustBugs.size() > 0) ? mapdustBugs
    183182                            .get(0) : null;
    184183            notifyObservers(selectedBug);
     184            panel.addObserver(detailsPanel);
    185185            mainPanel = new JPanel();
    186186            mainPanel.setAutoscrolls(true);
     
    210210            tabbedPane = new JTabbedPane();
    211211            queuePanel = new MapdustActionPanel(list, "Offline Contribution",
    212                             mapdustPlugin);
     212                    mapdustPlugin);
    213213            panel = new MapdustPanel(mapdustBugs, "Bug reports (offline)",
    214                             mapdustPlugin);
    215             panel.addObserver(detailsPanel);
     214                    mapdustPlugin);
    216215            mainPanel = new JPanel();
    217216            mainPanel.setAutoscrolls(true);
     
    226225        }
    227226    }
    228 
     227   
    229228    /**
    230229     * Adds the given <code>MapdustAction</code> object to the list of actions.
    231      *
     230     * 
    232231     * @param action The <code>MapdustAction</code> object
    233232     */
     
    238237        List<MapdustBug> mapdustBugs = panel.getMapdustBugsList();
    239238        mapdustBugs = modifyBug(mapdustBugs, action.getMapdustBug());
    240 
     239       
    241240        /* remove panels */
    242241        mainPanel.remove(detailsPanel);
     
    260259        mainPanel.add(tabbedPane, BorderLayout.CENTER);
    261260        add(mainPanel, BorderLayout.CENTER);
    262         /* invalidate and repaint */
    263         invalidate();
    264         repaint();
    265     }
    266 
     261        revalidate();
     262    }
     263   
    267264    /**
    268265     * Shows the MapDust main dialog. In the case if the plugin was not updated
     
    270267     * download the MapDust data from the current view, and update the plugin
    271268     * with the new data.
    272      *
     269     * 
    273270     */
    274271    @Override
     
    281278        }
    282279    }
    283 
     280   
    284281    /**
    285282     * Modifies the given <code>MapdustBug</code> in the given list of
    286283     * <code>MapdustBug</code> objects. Returns the list of bugs containing the
    287284     * modified bug.
    288      *
     285     * 
    289286     * @param mapdustBugs The list of <code>MapdustBug</code> objects
    290287     * @param modifiedBug The <code>MapdustBug</code> object
     
    308305        return mapdustBugs;
    309306    }
    310 
     307   
    311308    /**
    312309     * Adds a new MapDust bug details observer to the list of observers.
    313      *
     310     * 
    314311     * @param observer The <code>MapdustBugDetailsObserver</code> object
    315312     */
     
    320317        }
    321318    }
    322 
     319   
    323320    /**
    324321     * Adds a new MapDust initial update observer to the list of observers.
    325      *
     322     * 
    326323     * @param observer The <code>MapdustInitialUpdateObserver</code> object
    327324     */
     
    332329        }
    333330    }
    334 
     331   
    335332    /**
    336333     * Removes the given MapDust bug details observer from the list of
    337334     * observers.
    338      *
     335     * 
    339336     * @param observer The <code>MapdustBugDetailsObserver</code> object
    340337     */
     
    342339    public void removeObserver(MapdustBugDetailsObserver observer) {
    343340        this.bugDetailsObservers.remove(observer);
    344 
    345     }
    346 
     341       
     342    }
     343   
    347344    /**
    348345     * Removes the given MapDust initial update observer from the list of
    349346     * observers.
    350      *
     347     * 
    351348     * @param observer The <code>MapdustInitialUpdateObserver</code> object
    352349     */
     
    354351    public void removeObserver(MapdustInitialUpdateObserver observer) {
    355352        this.initialUpdateObservers.remove(observer);
    356 
    357     }
    358 
     353       
     354    }
     355   
    359356    /**
    360357     * Notifies the <code>MapdustBugDetailsObserver</code> objects observing the
     
    369366        }
    370367    }
    371 
     368   
    372369    /**
    373370     * Notifies the <code>MapdustInitialUpdateObserver</code> objects waiting
     
    382379        }
    383380    }
    384 
     381   
    385382    /**
    386383     * Returns the <code>MapdustPanel</code> object
    387      *
     384     * 
    388385     * @return the panel
    389386     */
     
    391388        return panel;
    392389    }
    393 
     390   
    394391    /**
    395392     * Returns the <code>MapdustActionPanel</code> object
    396      *
     393     * 
    397394     * @return the queuePanel
    398395     */
     
    400397        return queuePanel;
    401398    }
    402 
     399   
    403400}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/adapter/WindowClose.java

    r24514 r24821  
    4141/**
    4242 * Closes the given dialog window.
    43  *
     43 * 
    4444 * @author Bea
    4545 * @version $Revision$
    4646 */
    4747public class WindowClose extends WindowAdapter {
    48 
     48   
    4949    /** Serial version UID */
    5050    private static final long serialVersionUID = 1L;
    51 
     51   
    5252    /** A <code>AbstractDialog</code> object */
    5353    private AbstractDialog dialog;
    54 
     54   
    5555    /** The <code>MapdustButtonPanel</code> object */
    5656    private MapdustButtonPanel btnPanel;
    57 
     57   
    5858    /** The <code>JToggleButton</code> which had fired the dialog */
    5959    private JToggleButton btnFired;
    60 
     60   
    6161    /**
    6262     * Builds a <code>WindowClose</code> object
    6363     */
    6464    public WindowClose() {}
    65 
     65   
    6666    /**
    6767     * Builds a <code>WindowClose</code> object based on the given arguments
    68      *
     68     * 
    6969     * @param dialog The dialog which will be closed
    7070     * @param btnPanel The button panel
     
    7777        this.btnFired = btnFired;
    7878    }
    79 
     79   
    8080    @Override
    8181    public void windowClosing(WindowEvent event) {
     
    128128        }
    129129        /* dispose dialog */
     130        Main.pref.put("mapdust.addBug", true);
    130131        Main.pref.put("mapdust.modify", false);
     132        dialog.setVisible(false);
    131133        dialog.dispose();
     134        return;
    132135    }
    133 
    134136}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteCancel.java

    r24514 r24821  
    6565    }
    6666
     67
    6768    @Override
    6869    public void actionPerformed(ActionEvent event) {
     
    116117                btnPanel.getBtnReOpenBugReport().setSelected(false);
    117118            }
    118             /* dispose dialog */
    119             Main.pref.put("mapdust.modify", false);
    120             getDialog().dispose();
    121119        }
     120
     121        Main.pref.put("mapdust.addBug", true);
     122        Main.pref.put("mapdust.modify", false);
     123        /* dispose dialog */
     124        getDialog().setVisible(false);
     125        getDialog().dispose();
    122126    }
    123 
     127   
    124128}
Note: See TracChangeset for help on using the changeset viewer.