Changeset 25591 in osm for applications


Ignore:
Timestamp:
2011-03-14T09:30:11+01:00 (13 years ago)
Author:
beata.jancso
Message:

new feature: MapDust bug filtering & refactoring

Location:
applications/editors/josm/plugins/mapdust
Files:
29 added
7 deleted
76 edited

Legend:

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

    r25127 r25591  
    6060/**
    6161 * Defines the MapDust JOSM layer main functionality.
    62  * 
     62 *
    6363 * @author Bea
    6464 */
    6565public class MapdustLayer extends Layer {
    66    
     66
    6767    /** The <code>MapdustGUI</code> object */
    6868    private MapdustGUI mapdustGUI;
    69    
     69
    7070    /** The list of <code>MapdustBugList</code> objects */
    7171    private List<MapdustBug> mapdustBugList;
    72    
     72
    7373    /** The selected <code>MapdustBug</code> object */
    7474    private MapdustBug bugSelected;
    75    
     75
    7676    /**
    7777     * Builds a <code>MapdustLayer</code> object based on the given parameters.
    78      * 
     78     *
    7979     * @param name The name of the layer
    8080     * @param mapdustGUI The <code>MapdustGUI</code> object
     
    8888        this.bugSelected = null;
    8989    }
    90    
     90
    9191    /**
    9292     * Returns the icon of the MapDust layer.
    93      * 
     93     *
    9494     * @return icon
    9595     */
     
    9999        return layerIcon;
    100100    }
    101    
     101
    102102    /**
    103103     * Returns the info components of the MapDust layer.
    104      * 
     104     *
    105105     * @return object
    106106     */
     
    110110        return tr(infoComponent);
    111111    }
    112    
     112
    113113    /**
    114114     * Returns the menu entries of the MapDust layer.
    115      * 
     115     *
    116116     * @return an array of <code>Action</code> objects.
    117117     */
     
    129129        return menuEntries;
    130130    }
    131    
     131
    132132    /**
    133133     * Returns the text of the tool tip of the MapDust layer.
    134      * 
     134     *
    135135     * @return the tooltip text
    136136     */
     
    140140        return tr(toolTipText);
    141141    }
    142    
     142
    143143    /**
    144144     * Returns the image icon based on the given status and type.
    145      * 
     145     *
    146146     * @param iconType The type of the bug
    147147     * @param status The status of the bug
     
    158158        return icon;
    159159    }
    160    
     160
    161161    /**
    162162     * Draw the objects to the given map view. Also draws the MapDust bugs to
    163163     * the map, and the tooltip for the selected MapDust bug.
    164      * 
     164     *
    165165     * @param g The <code>Graphics2D</code> object
    166166     * @param mv The <code>MapView</code> object
     
    181181                int width = icon.getIconWidth();
    182182                int height = icon.getIconHeight();
    183                 /* need to do drawing 2 times, because in some areas the bug
    184                  * image is invisible */
     183                /*
     184                 * need to do drawing 2 times, because in some areas the bug
     185                 * image is invisible
     186                 */
    185187                for (int i = 0; i < 2; i++) {
    186188                    g.drawImage(icon.getImage(), p.x - (width / 2), p.y
    187189                            - (height / 2), new ImageObserver() {
     190
    188191                        @Override
    189192                        public boolean imageUpdate(Image img, int infoflags,
     
    194197                }
    195198            }
    196            
     199
    197200            /* draw the selected bug description */
    198201            /* selected by clicking */
    199202            MapdustBug bug1 = getBugSelected();
    200203            /* selected from the list */
    201             MapdustBug bugSelected =
    202                     getMapdustGUI().getPanel().getSelectedBug();
     204            MapdustBug bugSelected = getMapdustGUI().getSelectedBug();
    203205            if (bugSelected == null) {
    204206                if (Main.map.mapView.getActiveLayer() == this) {
     
    206208                }
    207209            }
     210            setBugSelected(bugSelected);
    208211            if (bugSelected != null) {
    209212                LatLon ll = bugSelected.getLatLon();
     
    217220                g.drawImage(icon.getImage(), p.x - (width / 2), p.y
    218221                        - (height / 2), new ImageObserver() {
     222
    219223                    @Override
    220224                    public boolean imageUpdate(Image img, int infoflags, int x,
     
    242246        }
    243247    }
    244    
     248
    245249    /**
    246250     * No need to implement this.
     
    250254        return false;
    251255    }
    252    
     256
    253257    /**
    254258     * No need to implement this.
     
    256260    @Override
    257261    public void mergeFrom(Layer layer) {}
    258    
     262
    259263    /**
    260264     * Builds the text of the tooltip containing a short description of the
    261265     * given <code>MapdustBug</code> object.
    262      * 
     266     *
    263267     * @param bug The <code>MapdustBug</code> object
    264268     * @return A string containing the description text
     
    279283        return text;
    280284    }
    281    
     285
    282286    /**
    283287     * No need to implement this.
     
    285289    @Override
    286290    public void visitBoundingBox(BoundingXYVisitor arg0) {}
    287    
     291
    288292    /**
    289293     * Returns the <code>MapdustGUI</code> object
    290      * 
     294     *
    291295     * @return the mapdustGUI
    292296     */
     
    294298        return mapdustGUI;
    295299    }
    296    
     300
    297301    /**
    298302     * Sets the <code>MapdustGUI</code> object
    299      * 
     303     *
    300304     * @param mapdustGUI the mapdustGUI to set
    301305     */
     
    303307        this.mapdustGUI = mapdustGUI;
    304308    }
    305    
     309
    306310    /**
    307311     * Returns the list of <code>MapdustBug</code> objects
    308      * 
     312     *
    309313     * @return the mapdustBugList
    310314     */
     
    312316        return mapdustBugList;
    313317    }
    314    
     318
    315319    /**
    316320     * Returns the selected bug
    317      * 
     321     *
    318322     * @return the bugSelected
    319323     */
     
    321325        return bugSelected;
    322326    }
    323    
     327
    324328    /**
    325329     * Sets the selected bug
    326      * 
     330     *
    327331     * @param bugSelected the bugSelected to set
    328332     */
     
    330334        this.bugSelected = bugSelected;
    331335    }
    332    
     336
    333337    /**
    334338     * Sets the list of <code>MapdustBug</code> objects
    335      * 
     339     *
    336340     * @param mapdustBugList the mapdustBugList to set
    337341     */
     
    339343        this.mapdustBugList = mapdustBugList;
    340344    }
    341    
     345
    342346}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/MapdustPlugin.java

    r25312 r25591  
    3737import java.util.List;
    3838import javax.swing.JOptionPane;
     39import javax.swing.SwingUtilities;
    3940import org.openstreetmap.josm.Main;
    4041import org.openstreetmap.josm.data.Bounds;
     
    4849import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener;
    4950import org.openstreetmap.josm.gui.layer.Layer;
    50 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    5151import org.openstreetmap.josm.plugins.Plugin;
    5252import org.openstreetmap.josm.plugins.PluginInformation;
     
    5454import org.openstreetmap.josm.plugins.mapdust.gui.component.dialog.CreateIssueDialog;
    5555import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObserver;
    56 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustInitialUpdateObserver;
    57 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustRefreshObserver;
     56import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObserver;
    5857import org.openstreetmap.josm.plugins.mapdust.gui.value.MapdustPluginState;
    5958import org.openstreetmap.josm.plugins.mapdust.service.MapdustServiceHandler;
    6059import org.openstreetmap.josm.plugins.mapdust.service.MapdustServiceHandlerException;
     60import org.openstreetmap.josm.plugins.mapdust.service.value.BoundingBox;
    6161import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBug;
     62import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBugFilter;
    6263import org.openstreetmap.josm.tools.Shortcut;
    6364
     
    6667 * This is the main class of the MapDust plug-in. Defines the MapDust plug-in
    6768 * main functionality.
    68  * 
     69 *
    6970 * @author Bea
    70  *
    7171 */
    7272public class MapdustPlugin extends Plugin implements LayerChangeListener,
    7373        ZoomChangeListener, PreferenceChangedListener, MouseListener,
    74         MapdustRefreshObserver, MapdustBugObserver,
    75         MapdustInitialUpdateObserver {
    76    
     74        MapdustUpdateObserver, MapdustBugObserver {
     75
    7776    /** The graphical user interface of the plug-in */
    7877    private MapdustGUI mapdustGUI;
    79    
     78
    8079    /** The layer of the MapDust plug-in */
    8180    private MapdustLayer mapdustLayer;
    82    
     81
     82    /** The <code>CreateIssueDialog</code> object */
     83    private CreateIssueDialog dialog;
     84
     85    /** The JOSM user identity manager, it is used for obtaining the username */
     86    private final JosmUserIdentityManager userIdentityManager;
     87
    8388    /** The list of <code>MapdustBug</code> objects */
    8489    private List<MapdustBug> mapdustBugList;
    85    
    86     /** The <code>CreateIssueDialog</code> object */
    87     private CreateIssueDialog dialog;
    88    
     90
     91    /** The bounding box from where the MapDust bugs are downloaded */
     92    private BoundingBox bBox;
     93
     94    /**
     95     * The <code>MapdustBugFilter</code> object representing the selected
     96     * filters
     97     */
     98    private MapdustBugFilter filter;
     99
    89100    /** Specifies if there was or not an error downloading the data */
    90101    private boolean wasError = false;
    91    
    92     /** The JOSM user identity manager, it is used for obtaining the username */
    93     private final JosmUserIdentityManager userIdentityManager;
    94    
     102
    95103    /**
    96104     * Builds a new <code>MapDustPlugin</code> object based on the given
    97105     * arguments.
    98      * 
     106     *
    99107     * @param info The <code>MapDustPlugin</code> object
    100108     */
    101109    public MapdustPlugin(PluginInformation info) {
    102110        super(info);
    103         /* create instance for JOSM user identity manager */
    104         userIdentityManager = JosmUserIdentityManager.getInstance();
    105         /* initialize the plugin */
     111        this.userIdentityManager = JosmUserIdentityManager.getInstance();
     112        this.filter = null;
     113        this.bBox = null;
    106114        initializePlugin();
    107115    }
    108    
     116
    109117    /**
    110118     * Initialize the <code>MapdustPlugin</code> object. Creates the
    111119     * <code>MapdustGUI</code> and initializes the following variables with
    112120     * default values: 'mapdust.pluginState', 'mapdust.nickname',
    113      * 'mapdust.showError'.
     121     * 'mapdust.showError', 'mapdust.version' and 'mapdust.localVersion'.
    114122     */
    115123    private void initializePlugin() {
    116124        /* create MapDust GUI */
    117         Shortcut shortcut = Shortcut.registerShortcut("mapdust", tr("Toggle: {0}",
    118                 tr("Open MapDust")), KeyEvent.VK_0, Shortcut.GROUP_MENU,
    119                 Shortcut.SHIFT_DEFAULT);
     125        String shortTxt = "MapDust";
     126        String longTxt = tr("Toggle: {0}", tr("Open MapDust"));
     127        Shortcut shortcut = Shortcut.registerShortcut(shortTxt, longTxt,
     128                KeyEvent.VK_0, Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT);
    120129        String name = "MapDust bug reports";
    121130        String tooltip = "Activates the MapDust bug reporter plugin";
     
    123132                shortcut, 150, this);
    124133        /* add default values for static variables */
    125         Main.pref.put("mapdust.pluginState",
    126                 MapdustPluginState.ONLINE.getValue());
     134        Main.pref.put("mapdust.pluginState", MapdustPluginState.ONLINE.getValue());
    127135        Main.pref.put("mapdust.nickname", "");
    128136        Main.pref.put("mapdust.showError", true);
     
    131139                getPluginInformation().localversion);
    132140    }
    133    
     141
    134142    /**
    135143     * Initializes the new <code>MapFrame</code>. Adds the
    136144     * <code>MapdustGUI</code> to the new <code>MapFrame</code> and sets the
    137145     * observers/listeners.
    138      * 
     146     *
    139147     * @param oldMapFrame The old <code>MapFrame</code> object
    140148     * @param newMapFrame The new <code>MapFrame</code> object
     
    149157            /* add MapDust dialog window */
    150158            if (Main.map != null && Main.map.mapView != null) {
    151                 /* set bounds for MapdustGUI */
     159                /* add MapdustGUI */
    152160                mapdustGUI.setBounds(newMapFrame.getBounds());
    153                 /* add observer */
    154161                mapdustGUI.addObserver(this);
    155                 /* add dialog to new MapFrame */
    156162                newMapFrame.addToggleDialog(mapdustGUI);
    157                 /* add ZoomChangeListener */
     163                /* add Listeners */
    158164                NavigatableComponent.addZoomChangeListener(this);
    159                 /* add LayerChangeListener */
    160165                MapView.addLayerChangeListener(this);
    161                 /* add MouseListener */
    162166                Main.map.mapView.addMouseListener(this);
    163167                Main.pref.addPreferenceChangeListener(this);
    164168                /* put username to preferences */
    165                 Main.pref.put("mapdust.josmUserName", 
     169                Main.pref.put("mapdust.josmUserName",
    166170                        userIdentityManager.getUserName());
    167171            }
    168172        }
    169173    }
    170    
    171     /**
    172      * Refreshes the MapDust data. Downloads the data from the given area and
    173      * updates the map and the MapDust list with this new data. This method is
    174      * called whenever the 'Refresh' button is pressed by the user.
    175      */
    176     @Override
    177     public void refreshData() {
    178         if (containsOsmDataLayer() && mapdustGUI.isShowing()) {
    179             updatePluginData();
    180         }
    181     }
    182    
    183     /**
    184      * Downloads the MapDust bugs from the current map view, and updates the
    185      * plugin data with the new downloaded data. This method is called only
    186      * once, before first showing the MapDust bugs.
    187      */
    188     @Override
    189     public void initialUpdate() {
    190         if (containsOsmDataLayer()) {
    191             updatePluginData();
    192         }
    193     }
    194    
    195     /**
    196      * Updates the given <code>MapdustBug</code> object from the map and from
    197      * the MapDust bugs list.
    198      *
    199      * @param mapdustBug The <code>MapdustBug</code> object
    200      */
    201     @Override
    202     public synchronized void changedData(MapdustBug mapdustBug) {
    203         if (mapdustBugList == null) {
    204             mapdustBugList = new ArrayList<MapdustBug>();
    205         }
    206         if (getMapdustGUI().isDialogShowing()) {
    207             if (Main.map != null && Main.map.mapView != null) {
    208                 /* if the layer was active , should be active after the update */
    209                 boolean wasActive = false;
    210                 if (Main.map.mapView.getActiveLayer() == getMapdustLayer()) {
    211                     wasActive = true;
    212                 }
    213                 /* update the list with the modified MapDust bug */
    214                 updateMapdustBugList(mapdustBug);
    215                 /* destroy the layer */
    216                 mapdustLayer.destroy();
    217                 Main.main.removeLayer(mapdustLayer);
    218                 mapdustLayer = null;
    219                 /* update the view, and activate the layer */
    220                 updateView();
    221                 if (wasActive) {
    222                     Main.map.mapView.setActiveLayer(getMapdustLayer());
    223                 }
    224             }
    225         }
    226     }
    227    
    228     /**
    229      * If the zoom was changed, download the bugs from the current map view.
    230      * This method is called whenever the zoom was changed.
    231      */
    232     @Override
    233     public void zoomChanged() {
    234         if (containsOsmDataLayer() && this.mapdustGUI.isShowing() && !wasError) {
    235             updatePluginData();
    236         }
    237     }
    238    
    239     /**
    240      * No need to implement this.
    241      */
    242     @Override
    243     public void activeLayerChange(Layer arg0, Layer arg1) {}
    244    
    245     /**
    246      * Adds the <code>MapdustLayer</code> to the JOSM editor. If the list of
    247      * <code>MapdustBug</code>s is null then downloads the data from the MapDust
    248      * Service and updates the editor with this new data.
    249      *
    250      * @param layer The <code>Layer</code> which will be added to the JOSM
    251      * editor
    252      */
    253     @Override
    254     public void layerAdded(Layer layer) {
    255         if (layer instanceof MapdustLayer) {
    256             /* download the MapDust bugs and update the plugin */
    257             if (mapdustBugList == null) {
    258                 updateMapdustData();
    259             }
    260         }
    261     }
    262    
    263     /**
    264      * Removes the <code>MapdustLayer</code> from the JOSM editor. Also closes
    265      * the MapDust plugin window.
    266      *
    267      * @param layer The <code>Layer</code> which will be removed from the JOSM
    268      * editor
    269      */
    270     @Override
    271     public void layerRemoved(Layer layer) {
    272         if (layer instanceof MapdustLayer) {
    273             /* remove the layer */
    274             MapView.removeLayerChangeListener(this);
    275             NavigatableComponent.removeZoomChangeListener(this);
    276             Main.map.mapView.removeLayer(layer);
    277             Main.map.remove(mapdustGUI);
    278             if (mapdustGUI != null) {
    279                 mapdustGUI.update(new ArrayList<MapdustBug>(), this);
    280                 mapdustGUI.setVisible(false);
    281             }
    282             mapdustLayer = null;
    283         }
    284     }
    285    
    286     /**
    287      * No need to implement this.
    288      */
    289     @Override
    290     public void mouseEntered(MouseEvent event) {}
    291    
    292     /**
    293      * No need to implement this.
    294      */
    295     @Override
    296     public void mouseExited(MouseEvent arg0) {}
    297    
    298     /**
    299      * No need to implement this.
    300      */
    301     @Override
    302     public void mousePressed(MouseEvent event) {}
    303    
    304     /**
    305      * No need to implement this.
    306      */
    307     @Override
    308     public void mouseReleased(MouseEvent arg0) {}
    309    
    310     /**
    311      * At mouse click the following two actions can be done: adding a new bug,
    312      * and selecting a bug from the map. A bug can be added if the plugin is the
    313      * only active plugin and you double click on the map. You can select a bug
    314      * from the map by clicking on it.
    315      *
    316      * @event The <code>MouseEvent</code> object
    317      */
    318     @Override
    319     public void mouseClicked(MouseEvent event) {
    320         if (mapdustLayer != null && mapdustLayer.isVisible()) {
    321             if (event.getButton() == MouseEvent.BUTTON1) {
    322                 if (event.getClickCount() == 2 && !event.isConsumed()) {
    323                     if (Main.map.mapView.getActiveLayer() == getMapdustLayer()) {
    324                         /* show add bug dialog */
    325                         MapdustBug bug = mapdustGUI.getPanel().getSelectedBug();
    326                         if (bug != null) {
    327                             Main.pref.put("selectedBug.status", bug.getStatus()
    328                                     .getValue());
    329                         } else {
    330                             Main.pref.put("selectedBug.status", "create");
    331                         }
    332                         /* disable MapdustButtonPanel */
    333                         mapdustGUI.disableBtnPanel();
    334                         /* create and show dialog */
    335                         dialog = new CreateIssueDialog(event.getPoint(), this);
    336                         dialog.showDialog();
    337                         event.consume();
    338                         return;
    339                     }
    340                 }
    341                 if (event.getClickCount() == 1 && !event.isConsumed()) {
    342                     /* allow click on the bug icon on the map */
    343                     Point p = event.getPoint();
    344                     MapdustBug nearestBug = getNearestBug(p);
    345                     if (nearestBug != null) {
    346                         mapdustLayer.setBugSelected(nearestBug);
    347                         /* set also in the list of bugs the element */
    348                         mapdustGUI.getPanel().setSelectedBug(nearestBug);
    349                         Main.map.mapView.repaint();
    350                     }
    351                     return;
    352                 }
    353             }
    354         }
    355     }
    356    
     174
    357175    /**
    358176     * Listens for the events of type <code>PreferenceChangeEvent</code> . If
     
    362180     * MapDust , re-set the 'mapdust.josmUserName' and 'mapdust.nickname'
    363181     * properties.
    364      * 
     182     *
    365183     * @param event The <code>PreferenceChangeEvent</code> obejct
    366184     */
    367185    @Override
    368186    public void preferenceChanged(PreferenceChangeEvent event) {
    369         if (this.mapdustGUI.isShowing() && !wasError && mapdustLayer != null
     187        if (mapdustGUI.isShowing() && !wasError && mapdustLayer != null
    370188                && mapdustLayer.isVisible()) {
    371189            if (event.getKey().equals("osm-server.username")) {
     
    390208        }
    391209    }
    392    
    393     /**
    394      * Updates the <code>MapdustPlugin</code> data. Downloads the
    395      * <code>MapdustBug</code> objects from the current view, and updates the
    396      * <code>MapdustGUI</code> and the map with the new data.
    397      */
    398     private void updatePluginData() {
    399         Main.worker.execute(new Runnable() {
    400             @Override
    401             public void run() {
    402                 updateMapdustData();
    403             }
    404         });
    405     }
    406    
    407     /**
    408      * Returns the bounds of the current <code>MapView</code>.
    409      *
    410      * @return bounds
    411      */
    412     private Bounds getBounds() {
    413         MapView mapView = Main.map.mapView;
    414         Bounds bounds = new Bounds(mapView.getLatLon(0, mapView.getHeight()),
    415                 mapView.getLatLon(mapView.getWidth(), 0));
    416         return bounds;
    417     }
    418    
    419     /**
    420      * Updates the MapDust plugin data. Downloads the list of
    421      * <code>MapdustBug</code> objects for the given area, and updates the map
    422      * and the MapDust layer with the new data.
    423      */
    424     private synchronized void updateMapdustData() {
    425         if (Main.map != null && Main.map.mapView != null) {
    426             /* download the MapDust data */
    427             try {
    428                 Bounds bounds = getBounds();
    429                 MapdustServiceHandler handler = new MapdustServiceHandler();
    430                 mapdustBugList = handler.getBugs(bounds.getMin().lon(),
    431                         bounds.getMin().lat(), bounds.getMax().lon(),
    432                         bounds.getMax().lat());
    433                 wasError = false;
    434             } catch (MapdustServiceHandlerException e) {
    435                 wasError = true;
    436                 mapdustBugList = new ArrayList<MapdustBug>();
    437                 updateView();
    438                 handleError();
    439             }
    440             /* update the view */
    441             if (!wasError) {
    442                 updateView();
    443             }
    444         }
    445     }
    446    
    447     /**
    448      * Updates the current view ( map and MapDust bug list), with the given list
    449      * of <code>MapdustBug</code> objects.
    450      */
    451     private void updateView() {
    452         /* update the dialog with the new data */
    453         mapdustGUI.update(mapdustBugList, this);
    454         mapdustGUI.setVisible(true);
    455         mapdustGUI.revalidate();
    456         /* update the MapdustLayer */
    457         if (mapdustLayer == null) {
    458             /* create and add the layer */
    459             mapdustLayer = new MapdustLayer("MapDust", mapdustGUI, mapdustBugList);
    460             Main.main.addLayer(this.mapdustLayer);
    461             Main.map.mapView.moveLayer(this.mapdustLayer, 0);
    462             Main.map.mapView.addMouseListener(this);
    463             MapView.addLayerChangeListener(this);
    464             NavigatableComponent.addZoomChangeListener(this);
    465         } else {
    466             /* re-set the properties */
    467             mapdustLayer.destroy();
    468             mapdustLayer.setMapdustGUI(mapdustGUI);
    469             mapdustLayer.setMapdustBugList(mapdustBugList);
    470             mapdustLayer.setBugSelected(null);
    471         }
    472         /* repaint */
    473         Main.map.mapView.revalidate();
    474         Main.map.repaint();
    475     }
    476    
    477     /**
    478      * Updates the MapDust bugs list with the given <code>MapdustBug</code>
    479      * object.
    480      *
     210
     211    /**
     212     * Updates the map and the MapDust bugs list with the given
     213     * <code>MapdustBug</code> object. If the bug is already contained in the
     214     * list and map, then this object will be updated with the new properties.
     215     * If the filter settings does not allow this new bug to be shown in the map
     216     * and list, then it will be removed from the map and list.
     217     *
    481218     * @param mapdustBug The <code>MapdustBug</code> object
    482219     */
    483     private void updateMapdustBugList(MapdustBug mapdustBug) {
    484         MapdustBug oldBug = null;
    485         for (MapdustBug bug : this.mapdustBugList) {
    486             if (bug.getId().equals(mapdustBug.getId())) {
    487                 oldBug = bug;
    488             }
    489         }
    490         if (oldBug != null) {
    491             /* remove, add */
    492             this.mapdustBugList.remove(oldBug);
    493             this.mapdustBugList.add(0, mapdustBug);
    494         } else {
    495             /* new add */
    496             this.mapdustBugList.add(0, mapdustBug);
    497         }
    498     }
    499    
     220    @Override
     221    public synchronized void changedData(MapdustBug mapdustBug) {
     222        if (mapdustBugList == null) {
     223            mapdustBugList = new ArrayList<MapdustBug>();
     224        }
     225        if (getMapdustGUI().isDialogShowing()) {
     226            if (Main.map != null && Main.map.mapView != null) {
     227                MapdustBug oldBug = null;
     228                for (MapdustBug bug : mapdustBugList) {
     229                    if (bug.getId().equals(mapdustBug.getId())) {
     230                        oldBug = bug;
     231                    }
     232                }
     233                boolean showBug = shouldDisplay(mapdustBug);
     234                if (oldBug != null) {
     235                    /* remove, add */
     236                    if (showBug) {
     237                        mapdustBugList.remove(oldBug);
     238                        mapdustBugList.add(0, mapdustBug);
     239                    } else {
     240                        mapdustBugList.remove(oldBug);
     241                    }
     242                } else {
     243                    /* new add */
     244                    if (showBug) {
     245                        mapdustBugList.add(0, mapdustBug);
     246                    }
     247                }
     248                mapdustGUI.update(mapdustBugList, this);
     249                mapdustLayer.setMapdustGUI(mapdustGUI);
     250                if (showBug) {
     251                    mapdustGUI.setSelectedBug(mapdustBugList.get(0));
     252                } else {
     253                    mapdustLayer.setBugSelected(null);
     254                    mapdustGUI.enableBtnPanel(true);
     255                    Main.map.mapView.repaint();
     256                    String title = "MapDust";
     257                    String message = "The operation was successful.";
     258                    JOptionPane.showMessageDialog(Main.parent, message, title,
     259                            JOptionPane.INFORMATION_MESSAGE);
     260                }
     261            }
     262        }
     263    }
     264
     265    /**
     266     * Verifies if the given <code>MapdustBug</code> object should be displayed
     267     * on the map and on the bugs list. A <code>MapdustBug</code> will be
     268     * displayed on the map only if it is permitted by the selected filter
     269     * settings.
     270     *
     271     * @param mapdustBug The <code>MapdustBug</code> object
     272     * @return true if the given bug should be displayed false otherwise
     273     */
     274    private boolean shouldDisplay(MapdustBug mapdustBug) {
     275        boolean result = true;
     276        if (filter != null) {
     277            boolean containsStatus = false;
     278            if (filter.getStatuses() != null && !filter.getStatuses().isEmpty()) {
     279                Integer statusKey = mapdustBug.getStatus().getKey();
     280                if (filter.getStatuses().contains(statusKey)) {
     281                    containsStatus = true;
     282                }
     283            } else {
     284                containsStatus = true;
     285            }
     286            boolean containsType = false;
     287            if (filter.getTypes() != null && !filter.getTypes().isEmpty()) {
     288                String typeKey = mapdustBug.getType().getKey();
     289                if (filter.getTypes().contains(typeKey)) {
     290                    containsType = true;
     291                }
     292            } else {
     293                containsType = true;
     294            }
     295            if (filter.getDescr() != null && filter.getDescr()) {
     296                if (!mapdustBug.getIsDefaultDescription()) {
     297                    result = false;
     298                }
     299            } else {
     300                result = containsStatus && containsType;
     301            }
     302        }
     303        return result;
     304    }
     305
     306    /**
     307     * No need to implement this.
     308     */
     309    @Override
     310    public void mouseEntered(MouseEvent event) {}
     311
     312    /**
     313     * No need to implement this.
     314     */
     315    @Override
     316    public void mouseExited(MouseEvent arg0) {}
     317
     318    /**
     319     * No need to implement this.
     320     */
     321    @Override
     322    public void mousePressed(MouseEvent event) {}
     323
     324    /**
     325     * No need to implement this.
     326     */
     327    @Override
     328    public void mouseReleased(MouseEvent arg0) {}
     329
     330    /**
     331     * At mouse click the following two actions can be done: adding a new bug,
     332     * and selecting a bug from the map. A bug can be added if the plugin is the
     333     * only active plugin and you double click on the map. You can select a bug
     334     * from the map by clicking on it.
     335     *
     336     * @param event The <code>MouseEvent</code> object
     337     */
     338    @Override
     339    public void mouseClicked(MouseEvent event) {
     340        if (mapdustLayer != null && mapdustLayer.isVisible()) {
     341            if (event.getButton() == MouseEvent.BUTTON1) {
     342                if (event.getClickCount() == 2 && !event.isConsumed()) {
     343                    if (Main.map.mapView.getActiveLayer() == getMapdustLayer()) {
     344                        /* show add bug dialog */
     345                        MapdustBug bug = mapdustGUI.getSelectedBug();
     346                        if (bug != null) {
     347                            Main.pref.put("selectedBug.status", bug.getStatus()
     348                                    .getValue());
     349                        } else {
     350                            Main.pref.put("selectedBug.status", "create");
     351                        }
     352                        /* disable MapdustButtonPanel */
     353                        mapdustGUI.getPanel().disableBtnPanel();
     354                        /* create and show dialog */
     355                        dialog = new CreateIssueDialog(event.getPoint(), this);
     356                        dialog.showDialog();
     357                        event.consume();
     358                        return;
     359                    }
     360                }
     361                if (event.getClickCount() == 1 && !event.isConsumed()) {
     362                    /* allow click on the bug icon on the map */
     363                    Point p = event.getPoint();
     364                    MapdustBug nearestBug = getNearestBug(p);
     365                    if (nearestBug != null) {
     366                        mapdustLayer.setBugSelected(nearestBug);
     367                        /* set also in the list of bugs the element */
     368                        mapdustGUI.setSelectedBug(nearestBug);
     369                        Main.map.mapView.repaint();
     370                    }
     371                    return;
     372                }
     373            }
     374        }
     375    }
     376
    500377    /**
    501378     * Returns the nearest <code>MapdustBug</code> object to the given point on
    502379     * the map.
    503      * 
     380     *
    504381     * @param p A <code>Point</code> object
    505382     * @return A <code>MapdustBug</code> object
     
    521398        return nearestBug;
    522399    }
    523    
    524     /**
    525      * Verifies if the <code>OsmDataLayer</code> layer has been added to the
    526      * list of layers.
    527      *
    528      * @return true if the <code>OsmDataLayer</code> layer has been added false
    529      * otherwise
    530      */
    531     private boolean containsOsmDataLayer() {
    532         boolean contains = false;
    533         List<Layer> l = Main.map.mapView.getAllLayersAsList();
    534         for (Layer ll : l) {
    535             if (ll instanceof OsmDataLayer) {
    536                 contains = true;
    537             }
    538         }
    539         return contains;
    540     }
    541    
     400
     401    /**
     402     * No need to implement this.
     403     */
     404    @Override
     405    public void activeLayerChange(Layer arg0, Layer arg1) {}
     406
     407    /**
     408     * Adds the <code>MapdustLayer</code> to the JOSM editor. If the list of
     409     * <code>MapdustBug</code>s is null then downloads the data from the MapDust
     410     * Service and updates the editor with this new data.
     411     *
     412     * @param layer The <code>Layer</code> which will be added to the JOSM
     413     * editor
     414     */
     415    @Override
     416    public void layerAdded(Layer layer) {
     417        if (layer instanceof MapdustLayer) {
     418            /* download the MapDust bugs and update the plugin */
     419            if (mapdustBugList == null) {
     420                updatePluginData();
     421            }
     422        }
     423    }
     424
     425    /**
     426     * Removes the <code>MapdustLayer</code> from the JOSM editor. Also closes
     427     * the MapDust plugin window.
     428     *
     429     * @param layer The <code>Layer</code> which will be removed from the JOSM
     430     * editor
     431     */
     432    @Override
     433    public void layerRemoved(Layer layer) {
     434        if (layer instanceof MapdustLayer) {
     435            /* remove the layer */
     436            Main.pref.put("mapdust.pluginState",
     437                    MapdustPluginState.ONLINE.getValue());
     438            MapView.removeLayerChangeListener(this);
     439            NavigatableComponent.removeZoomChangeListener(this);
     440            Main.map.mapView.removeLayer(layer);
     441            Main.map.remove(mapdustGUI);
     442            if (mapdustGUI != null) {
     443                mapdustGUI.update(new ArrayList<MapdustBug>(), this);
     444                mapdustGUI.setVisible(false);
     445                mapdustGUI.destroy();
     446            }
     447            mapdustLayer = null;
     448            filter = null;
     449            mapdustBugList = null;
     450        }
     451    }
     452
     453    /**
     454     * Listens for the zoom change event. If the zoom was changed, then it will
     455     * download the MapDust bugs data from the current view. The new data will
     456     * be downloaded only if the current bounding box is different from the
     457     * previous one.
     458     */
     459    @Override
     460    public void zoomChanged() {
     461        if (mapdustGUI.isShowing() && !wasError) {
     462            boolean download = true;
     463            BoundingBox curentBBox = getBBox();
     464            if (bBox != null) {
     465                if (bBox.equals(curentBBox)) {
     466                    download = false;
     467                }
     468            }
     469            bBox = curentBBox;
     470            if (download) {
     471                updatePluginData();
     472            }
     473        }
     474    }
     475
     476    /**
     477     * Updates the plugin with a new MapDust bugs data. If the filters are set
     478     * then the MapDust data will be filtered. If initialUpdate flag is true
     479     * then the plugin is updated for the first time with the MapDust data. By
     480     * default the first time there is no filter applied to the MapDust data.
     481     *
     482     * @param filter The <code>MapdustBugFilter</code> containing the filter
     483     * settings
     484     * @param initialUpdate If true then there will be no filter applied.
     485     */
     486    @Override
     487    public void update(MapdustBugFilter filter, boolean initialUpdate) {
     488        bBox = getBBox();
     489        if (initialUpdate) {
     490            updatePluginData();
     491        } else {
     492            if (filter != null) {
     493                this.filter = filter;
     494            }
     495            if (mapdustGUI.isShowing() && !wasError) {
     496                updatePluginData();
     497            }
     498        }
     499    }
     500
     501    /**
     502     * Returns the current bounding box. If the bounding box values are not in
     503     * the limits, then it will normalized.
     504     *
     505     * @return A <code>BoundingBox</code>
     506     */
     507    private BoundingBox getBBox() {
     508        MapView mapView = Main.map.mapView;
     509        Bounds bounds =
     510                new Bounds(mapView.getLatLon(0, mapView.getHeight()),
     511                        mapView.getLatLon(mapView.getWidth(), 0));
     512        return new BoundingBox(bounds.getMin().lon(), bounds.getMin().lat(),
     513                bounds.getMax().lon(), bounds.getMax().lat());
     514    }
     515
     516    /**
     517     * Updates the <code>MapdustPlugin</code> data. Downloads the
     518     * <code>MapdustBug</code> objects from the current view, and updates the
     519     * <code>MapdustGUI</code> and the map with the new data.
     520     */
     521    private void updatePluginData() {
     522        Main.worker.execute(new Runnable() {
     523
     524            @Override
     525            public void run() {
     526                updateMapdustData();
     527            }
     528        });
     529
     530    }
     531
     532    /**
     533     * Updates the MapDust plugin data. Downloads the list of
     534     * <code>MapdustBug</code> objects for the given area, and updates the map
     535     * and the MapDust layer with the new data.
     536     */
     537    protected synchronized void updateMapdustData() {
     538        if (Main.map != null && Main.map.mapView != null) {
     539            /* download the MapDust data */
     540            try {
     541                MapdustServiceHandler handler = new MapdustServiceHandler();
     542                mapdustBugList = handler.getBugs(bBox, filter);
     543                wasError = false;
     544            } catch (MapdustServiceHandlerException e) {
     545                wasError = true;
     546                mapdustBugList = new ArrayList<MapdustBug>();
     547            }
     548            /* update the view */
     549            SwingUtilities.invokeLater(new Runnable() {
     550
     551                @Override
     552                public void run() {
     553                    updateView();
     554                    if (wasError) {
     555                        handleError();
     556                    }
     557                }
     558            });
     559
     560        }
     561    }
     562
     563    /**
     564     * Updates the current view ( map and MapDust bug list), with the given list
     565     * of <code>MapdustBug</code> objects.
     566     */
     567    protected void updateView() {
     568        /* update the dialog with the new data */
     569        mapdustGUI.update(mapdustBugList, this);
     570        /* update the MapdustLayer */
     571        if (mapdustLayer == null) {
     572            /* create and add the layer */
     573            mapdustLayer =
     574                    new MapdustLayer("MapDust", mapdustGUI, mapdustBugList);
     575            Main.main.addLayer(this.mapdustLayer);
     576            Main.map.mapView.moveLayer(this.mapdustLayer, 0);
     577            Main.map.mapView.addMouseListener(this);
     578            MapView.addLayerChangeListener(this);
     579            NavigatableComponent.addZoomChangeListener(this);
     580        } else {
     581            /* re-set the properties */
     582            mapdustLayer.destroy();
     583            mapdustLayer.setMapdustGUI(mapdustGUI);
     584            mapdustLayer.setMapdustBugList(mapdustBugList);
     585            mapdustLayer.setBugSelected(null);
     586        }
     587        /* repaint */
     588        mapdustGUI.revalidate();
     589        Main.map.mapView.revalidate();
     590        Main.map.repaint();
     591    }
     592
    542593    /**
    543594     * Handles the <code>MapdustServiceHandlerException</code> error.
    544      * 
     595     *
    545596     */
    546597    private void handleError() {
     
    555606        }
    556607    }
    557    
     608
    558609    /**
    559610     * Returns the <code>MapdustGUI</code> object
    560      * 
     611     *
    561612     * @return the mapdustGUI
    562613     */
     
    564615        return mapdustGUI;
    565616    }
    566    
     617
    567618    /**
    568619     * Sets the <code>MapdustGUI</code> object.
    569      * 
     620     *
    570621     * @param mapdustGUI the mapdustGUI to set
    571622     */
     
    573624        this.mapdustGUI = mapdustGUI;
    574625    }
    575    
     626
    576627    /**
    577628     * Returns the <code>MapdustLayer</code> object.
    578      * 
     629     *
    579630     * @return the mapdustLayer
    580631     */
     
    582633        return mapdustLayer;
    583634    }
    584    
     635
    585636    /**
    586637     * Sets the <code>MapdustLayer</code> object.
    587      * 
     638     *
    588639     * @param mapdustLayer the mapdustLayer to set
    589640     */
     
    591642        this.mapdustLayer = mapdustLayer;
    592643    }
    593    
     644
    594645    /**
    595646     * Returns the list of <code>MapdustBug</code> objects
    596      * 
     647     *
    597648     * @return the mapdustBugList
    598649     */
     
    600651        return mapdustBugList;
    601652    }
    602    
    603     /**
    604      * Sets the list of <code>MapdustBug</code> objects
    605      * 
    606      * @param mapdustBugList the mapdustBugList to set
    607      */
    608     public void setMapdustBugList(List<MapdustBug> mapdustBugList) {
    609         this.mapdustBugList = mapdustBugList;
    610     }
    611    
     653
     654    /**
     655     * Returns the MapDust bug filter
     656     *
     657     * @return the filter
     658     */
     659    public MapdustBugFilter getFilter() {
     660        return filter;
     661    }
     662
    612663}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/MapdustActionUploaderException.java

    r24514 r25591  
    3131/**
    3232 * Specific exception for the <code>MapdustActionUploader</code> object
    33  * 
     33 *
    3434 * @author Bea
    3535 * @version $Revision$
    3636 */
    3737public class MapdustActionUploaderException extends Exception {
    38    
     38
    3939    /** Serial version UID */
    40     private static final long serialVersionUID = 1L;
    41    
     40    private static final long serialVersionUID = -6128820229665805478L;
     41
    4242    /**
    4343     * Builds an empty <code>MapdustActionUploaderException</code> object.
     
    4646        super();
    4747    }
    48    
     48
    4949    /**
    5050     * Builds a <code>MapdustActionUploaderException</code> object based on the
    5151     * given argument.
    52      * 
     52     *
    5353     * @param message The message of the exception.
    5454     */
     
    5656        super(message);
    5757    }
    58    
     58
    5959    /**
    6060     * Builds a <code>MapdustActionUploaderException</code> object based on the
    6161     * given argument.
    62      * 
     62     *
    6363     * @param cause The cause of the exception.
    6464     */
     
    6666        super(cause);
    6767    }
    68    
     68
    6969    /**
    7070     * Builds a <code>MapdustActionUploaderException</code> object based on the
    7171     * given arguments.
    72      * 
     72     *
    7373     * @param message The message of the exception.
    7474     * @param cause The cause of the exception.
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/MapdustGUI.java

    r25127 r25591  
    4040import org.openstreetmap.josm.plugins.mapdust.MapdustPlugin;
    4141import org.openstreetmap.josm.plugins.mapdust.gui.component.panel.MapdustActionPanel;
     42import org.openstreetmap.josm.plugins.mapdust.gui.component.panel.MapdustBugListPanel;
    4243import org.openstreetmap.josm.plugins.mapdust.gui.component.panel.MapdustBugPropertiesPanel;
    43 import org.openstreetmap.josm.plugins.mapdust.gui.component.panel.MapdustPanel;
    44 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionListObserver;
     44import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObserver;
    4545import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugDetailsObservable;
    4646import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugDetailsObserver;
    47 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustInitialUpdateObservable;
    48 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustInitialUpdateObserver;
     47import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObservable;
     48import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObserver;
    4949import org.openstreetmap.josm.plugins.mapdust.gui.value.MapdustAction;
    5050import org.openstreetmap.josm.plugins.mapdust.gui.value.MapdustPluginState;
     51import org.openstreetmap.josm.plugins.mapdust.gui.value.MapdustServiceCommand;
    5152import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBug;
     53import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBugFilter;
     54import org.openstreetmap.josm.plugins.mapdust.service.value.Status;
    5255import org.openstreetmap.josm.tools.Shortcut;
    5356
     
    5558/**
    5659 * This class is the main graphical user interface class.
    57  * 
     60 *
    5861 * @author Bea
    5962 */
    60 public class MapdustGUI extends ToggleDialog implements
    61         MapdustActionListObserver, MapdustBugDetailsObservable,
    62         MapdustInitialUpdateObservable {
    63    
     63public class MapdustGUI extends ToggleDialog implements MapdustActionObserver,
     64        MapdustBugDetailsObservable, MapdustUpdateObservable {
     65
    6466    /** The serial version UID */
    65     private static final long serialVersionUID = 1L;
    66    
     67    private static final long serialVersionUID = -1194197412364335190L;
     68
    6769    /** The list of MapDust bug details observers */
    6870    private final ArrayList<MapdustBugDetailsObserver> bugDetailsObservers =
    6971            new ArrayList<MapdustBugDetailsObserver>();
    70    
     72
    7173    /** The list of MapDust initial update observers */
    72     private final ArrayList<MapdustInitialUpdateObserver> initialUpdateObservers =
    73             new ArrayList<MapdustInitialUpdateObserver>();
    74    
    75     /** The <code>MapdustPanel</code> object */
    76     private MapdustPanel panel;
    77    
     74    private final ArrayList<MapdustUpdateObserver> initialUpdateObservers =
     75            new ArrayList<MapdustUpdateObserver>();
     76
     77    /** The <code>MapdustPlugin</code> plugin */
     78    private MapdustPlugin mapdustPlugin;
     79
     80    /** The <code>MapdustBugPropertiesPanel</code> */
     81    private MapdustBugPropertiesPanel detailsPanel;
     82
     83    /** The <code>MapdustBugListPanel</code> object */
     84    private MapdustBugListPanel panel;
     85
    7886    /** The <code>MapdustActionPanel</code> object */
    79     private MapdustActionPanel queuePanel;
    80    
     87    private MapdustActionPanel actionPanel;
     88
    8189    /** The <code>JTabbedPanel</code> object */
    8290    private JTabbedPane tabbedPane;
    83    
    84     /** The <code>MapdustPlugin</code> plugin */
    85     private MapdustPlugin mapdustPlugin;
    86    
    87     /** The <code>MapdustBugPropertiesPanel</code> */
    88     private MapdustBugPropertiesPanel detailsPanel;
    89    
     91
    9092    /** The <code>JPanel</code> */
    9193    private JPanel mainPanel;
    92    
     94
    9395    /** Specifies if the MapDust data was or not downloaded */
    9496    private boolean downloaded = false;
    95    
     97
    9698    /**
    9799     * Builds a <code>MapdustGUi</code> based on the given parameters.
    98      * 
     100     *
    99101     * @param name The name of the GUI
    100102     * @param iconName The name of the icon
     
    109111        this.mapdustPlugin = mapdustPlugin;
    110112    }
    111    
     113
     114    /**
     115     * Displays the <code>MapdustGUI</code> dialog window in the JOSM editor. If
     116     * the MapDust data was not downloaded yet, it will donwload the data and
     117     * also update the MapDust plugin with the data. If the MapDust data was
     118     * already downloaded, then the <code>MapdustGUI</code> will be displayed.
     119     */
     120    @Override
     121    public void showDialog() {
     122        if (!downloaded) {
     123            notifyObservers(null, true);
     124            downloaded = true;
     125        }
     126        super.showDialog();
     127    }
     128
     129    /**
     130     * Adds the given <code>MapdustAction</code> object to the list of actions.
     131     *
     132     * @param action The <code>MapdustAction</code> object
     133     */
     134    @Override
     135    public synchronized void addAction(MapdustAction action) {
     136        /* add the action */
     137        List<MapdustAction> actionList = actionPanel.getActionList();
     138        actionList.add(action);
     139        List<MapdustBug> mapdustBugs = panel.getMapdustBugsList();
     140        boolean showBug = shouldDisplay(action.getMapdustBug(),
     141                mapdustPlugin.getFilter());
     142        mapdustBugs = modifyBug(mapdustBugs, action.getMapdustBug(), showBug);
     143
     144        /* update panels */
     145        updateMapdustPanel(mapdustBugs);
     146        updateMapdustActionPanel(actionList);
     147        if (showBug &&
     148                !action.getCommand().equals(MapdustServiceCommand.ADD_BUG)) {
     149            panel.resetSelectedBug(0);
     150        } else {
     151            mapdustPlugin.getMapdustLayer().setBugSelected(null);
     152        }
     153        revalidate();
     154        Main.map.mapView.revalidate();
     155        Main.map.repaint();
     156    }
     157
     158    /**
     159     * Verifies if the given <code>MapdustBug</code> should be shown on the
     160     * MapDust bug list/ map. Any <code>MapdustBug</code> should be shown on the
     161     * MapDust bug list / map only if it is permitted by the selected filters.
     162     *
     163     * @param modifiedBug The <code>MapdustBug</code> object
     164     * @param filter The <code>MapdustBugFilter</code> object
     165     * @return true if the given MapDust bug should be shown in the list/map
     166     * false otherwise
     167     */
     168    private boolean shouldDisplay(MapdustBug modifiedBug,
     169            MapdustBugFilter filter) {
     170        boolean result = false;
     171        if (filter != null && filter.getStatuses() != null
     172                && !filter.getStatuses().isEmpty()) {
     173            if (filter.getStatuses().contains(modifiedBug.getStatus().getKey())) {
     174                result = true;
     175            }
     176        } else {
     177            result = true;
     178        }
     179        return result;
     180    }
     181
    112182    /**
    113183     * Updates the MapDust GUI with the given list of <code>MapdustBug</code>
    114184     * objects.
    115      * 
     185     *
    116186     * @param mapdustBugs The list of <code>MapdustBug</code> objects
    117187     * @param mapdustPlugin The <code>MapdustPlugin</code> object
     
    119189    public synchronized void update(List<MapdustBug> mapdustBugs,
    120190            MapdustPlugin mapdustPlugin) {
    121         this.mapdustPlugin = mapdustPlugin;
     191        setMapdustPlugin(mapdustPlugin);
    122192        String pluginState = Main.pref.get("mapdust.pluginState");
    123193        if (pluginState.equals(MapdustPluginState.ONLINE.getValue())) {
    124             /* remove the panels */
    125194            if (tabbedPane != null) {
    126                 /* offline to online */
     195                /* from offline to online */
    127196                remove(mainPanel);
    128                 queuePanel = null;
    129             } else {
    130                 /* online to online */
    131                 if (mainPanel != null) {
    132                     remove(mainPanel);
    133                 }
    134             }
    135             /* add panels with updated data */
    136             panel = new MapdustPanel(mapdustBugs, "Bug reports", mapdustPlugin);
    137             MapdustBug selectedBug = (mapdustBugs != null && mapdustBugs.size()
    138                     > 0) ? mapdustBugs.get(0) : null;
    139             if (detailsPanel == null) {
    140                 detailsPanel = new MapdustBugPropertiesPanel(selectedBug);
    141                 panel.addObserver(detailsPanel);
    142                 addObserver(detailsPanel);
    143             }
    144             notifyObservers(selectedBug);
    145             panel.addObserver(detailsPanel);
    146             mainPanel = new JPanel();
    147             mainPanel.setAutoscrolls(true);
    148             mainPanel.setLayout(new BorderLayout());
    149             if (mapdustBugs != null) {
    150                 mainPanel.add(detailsPanel, BorderLayout.NORTH);
    151             }
    152             mainPanel.add(panel, BorderLayout.CENTER);
    153             add(mainPanel, BorderLayout.CENTER);
     197                tabbedPane = null;
     198                actionPanel = null;
     199                mainPanel = null;
     200                panel = null;
     201            }
     202            updateMapdustPanel(mapdustBugs);
     203            if (mainPanel == null) {
     204                createMainPanel();
     205            }
    154206        } else {
    155             List<MapdustAction> list = new ArrayList<MapdustAction>();
    156             /* remove panels */
    157             if (queuePanel == null) {
     207            if (tabbedPane == null) {
    158208                /* from online to offline */
    159209                remove(mainPanel);
    160             } else {
    161                 list = queuePanel.getActionList();
    162                 remove(mainPanel);
    163             }
    164             /* add panels with updated data */
    165             tabbedPane = new JTabbedPane();
    166             queuePanel = new MapdustActionPanel(list, "Offline Contribution",
     210                mainPanel = null;
     211                panel = null;
     212            }
     213            List<MapdustAction> actionList =
     214                    actionPanel != null ? actionPanel.getActionList()
     215                            : new ArrayList<MapdustAction>();
     216
     217            /* update panels */
     218            List<MapdustBug> bugs =
     219                    filterMapdustBugList(mapdustBugs, actionList,
     220                            mapdustPlugin.getFilter());
     221            updateMapdustPanel(bugs);
     222            updateMapdustActionPanel(actionList);
     223            if (mainPanel == null) {
     224                createMainPanel();
     225            }
     226        }
     227    }
     228
     229
     230    /**
     231     * Updates the MapDust bugs panel with the new list of data.
     232     *
     233     * @param mapdustBugs The list of <code>MapdustBug</code> objects
     234     */
     235    private void updateMapdustPanel(List<MapdustBug> mapdustBugs) {
     236        MapdustBug selectedBug =
     237                (mapdustBugs != null && mapdustBugs.size() > 0) ? mapdustBugs
     238                        .get(0) : null;
     239        if (detailsPanel == null) {
     240            detailsPanel = new MapdustBugPropertiesPanel(selectedBug);
     241            addObserver(detailsPanel);
     242        }
     243        if (panel == null) {
     244            panel = new MapdustBugListPanel(mapdustBugs, "Bug reports",
    167245                    mapdustPlugin);
    168             panel = new MapdustPanel(mapdustBugs, "Bug reports (offline)",
    169                     mapdustPlugin);
    170             MapdustBug selectedBug = (mapdustBugs != null && mapdustBugs.size()
    171                     > 0) ? mapdustBugs.get(0) : null;
    172             if (detailsPanel == null) {
    173                 detailsPanel = new MapdustBugPropertiesPanel(selectedBug);
    174                 panel.addObserver(detailsPanel);
    175                 addObserver(detailsPanel);
    176             }
     246            panel.addObserver(detailsPanel);
     247        } else {
     248            panel.updateComponents(mapdustBugs);
    177249            notifyObservers(selectedBug);
    178             panel.addObserver(detailsPanel);
    179             mainPanel = new JPanel();
    180             mainPanel.setAutoscrolls(true);
    181             mainPanel.setLayout(new BorderLayout());
    182             if (mapdustBugs != null) {
    183                 mainPanel.add(detailsPanel, BorderLayout.NORTH);
    184             }
    185             tabbedPane.add(panel, 0);
    186             tabbedPane.add(queuePanel);
    187             mainPanel.add(tabbedPane, BorderLayout.CENTER);
    188             add(mainPanel, BorderLayout.CENTER);
    189         }
    190     }
    191    
    192     /**
    193      * Adds the given <code>MapdustAction</code> object to the list of actions.
    194      *
    195      * @param action The <code>MapdustAction</code> object
    196      */
    197     @Override
    198     public synchronized void addAction(MapdustAction action) {
    199         /* add the action */
    200         List<MapdustAction> list = queuePanel.getActionList();
    201         List<MapdustBug> mapdustBugs = panel.getMapdustBugsList();
    202         mapdustBugs = modifyBug(mapdustBugs, action.getMapdustBug());
    203        
    204         /* remove panels */
    205         if (mainPanel != null) {
    206             remove(mainPanel);
    207         }
    208         /* create new tabbed pane */
    209         tabbedPane = new JTabbedPane();
    210         list.add(action);
    211         queuePanel = new MapdustActionPanel(list, "Offline Contribution",
    212                 mapdustPlugin);
    213         panel = new MapdustPanel(mapdustBugs, "Bug reports (offline)",
    214                 mapdustPlugin);
     250        }
     251    }
     252
     253    /**
     254     * Updates the MapDust action panel with the new list of data.
     255     *
     256     * @param actionList The list of <code>MapdustAction</code> objects
     257     */
     258    private void updateMapdustActionPanel(List<MapdustAction> actionList) {
     259        if (actionPanel == null) {
     260            actionPanel = new MapdustActionPanel(actionList,
     261                    "Offline Contribution", mapdustPlugin);
     262        } else {
     263            actionPanel.updateComponents(actionList);
     264        }
     265    }
     266
     267    /**
     268     * Creates the main panel of the plugin and adds to the content pane.
     269     */
     270    private void createMainPanel() {
    215271        mainPanel = new JPanel();
    216272        mainPanel.setAutoscrolls(true);
    217273        mainPanel.setLayout(new BorderLayout());
    218274        mainPanel.add(detailsPanel, BorderLayout.NORTH);
    219         tabbedPane.add(panel, 0);
    220         tabbedPane.add(queuePanel);
    221         mainPanel.add(tabbedPane, BorderLayout.CENTER);
     275        if (actionPanel == null) {
     276            mainPanel.add(panel, BorderLayout.CENTER);
     277        } else {
     278            tabbedPane = new JTabbedPane();
     279            tabbedPane.add(panel, 0);
     280            tabbedPane.add(actionPanel);
     281            mainPanel.add(tabbedPane, BorderLayout.CENTER);
     282        }
    222283        add(mainPanel, BorderLayout.CENTER);
    223         revalidate();
    224     }
    225    
    226     /**
    227      * Disables the buttons from the <code>MapdustButtonPanel</code> buttons.
    228      *
    229      */
    230     public void disableBtnPanel() {
    231         panel.getBtnPanel().getBtnWorkOffline().setEnabled(false);
    232         panel.getBtnPanel().getBtnRefresh().setEnabled(false);
    233         panel.getBtnPanel().getBtnAddComment().setEnabled(false);
    234         panel.getBtnPanel().getBtnFixBugReport().setEnabled(false);
    235         panel.getBtnPanel().getBtnInvalidateBugReport().setEnabled(false);
    236         panel.getBtnPanel().getBtnReOpenBugReport().setEnabled(false);
    237     }
    238    
    239    
     284    }
     285
     286
     287    /**
     288     * Filters the given list of <code>MapdustBug</code>s based on the given
     289     * list of <code>MapdustAction</code>s. The filtering is done in order to
     290     * show the modified bugs ( but not already committed operations) if they
     291     * also appears in the new list of bugs, according to the latest
     292     * modifications.
     293     *
     294     * @param bugList The list of <code>MapdustBug</code> objects
     295     * @param actionList The list of <code>MapdustAction</code> objects
     296     * @param filter The <code>MapdustBugFilter</code> object
     297     * @return A filtered list of <code>MapdustBug</code>s
     298     */
     299    private List<MapdustBug> filterMapdustBugList(List<MapdustBug> bugList,
     300            List<MapdustAction> actionList, MapdustBugFilter filter) {
     301        if (bugList != null && actionList != null) {
     302            for (MapdustAction action : actionList) {
     303                int index = bugList.indexOf(action.getMapdustBug());
     304                if (index >= 0) {
     305                    if (action.getNewStatus() != null) {
     306                        Status newStatus =
     307                                Status.getStatus(action.getNewStatus());
     308                        if (filter != null && filter.getStatuses() != null
     309                                && !filter.getStatuses().isEmpty()) {
     310                            if (filter.getStatuses().contains(
     311                                    newStatus.getKey())) {
     312                                bugList.get(index).setStatus(newStatus);
     313                            } else {
     314                                bugList.remove(index);
     315                            }
     316                        } else {
     317                            bugList.get(index).setStatus(newStatus);
     318                        }
     319                    }
     320                }
     321            }
     322        }
     323        return bugList;
     324    }
     325
    240326    /**
    241327     * Modifies the given <code>MapdustBug</code> in the given list of
    242328     * <code>MapdustBug</code> objects. Returns the list of bugs containing the
    243329     * modified bug.
    244      * 
     330     *
    245331     * @param mapdustBugs The list of <code>MapdustBug</code> objects
    246332     * @param modifiedBug The <code>MapdustBug</code> object
     333     * @param showBug A flag indicating if the given modified bug should be
     334     * displayed on the map and on the list of bugs
    247335     * @return the modified list
    248336     */
    249337    private List<MapdustBug> modifyBug(List<MapdustBug> mapdustBugs,
    250             MapdustBug modifiedBug) {
     338            MapdustBug modifiedBug, boolean showBug) {
    251339        int index = -1;
    252340        for (int i = 0; i < mapdustBugs.size(); i++) {
     
    260348            /* remove, and add to the top of the list */
    261349            mapdustBugs.remove(index);
    262             mapdustBugs.add(0, modifiedBug);
     350            if (showBug) {
     351                mapdustBugs.add(0, modifiedBug);
     352            }
    263353        }
    264354        return mapdustBugs;
    265355    }
    266    
    267     /**
    268      * Displays the <code>MapdustGUI</code> dialog window in the JOSM editor. If
    269      * the MapDust data was not downloaded yet, it will donwload the data and
    270      * also update the MapDust plugin with the data. If the MapDust data was
    271      * already downloaded, then the <code>MapdustGUI</code> will be displayed.
    272      */
    273     @Override
    274     public void showDialog() {
    275         if (!downloaded) {
    276             notifyObservers();
    277             downloaded = true;
    278         }
    279         super.showDialog();
    280     }
    281    
     356
     357    /**
     358     * Returns the selected bug from the list of bugs. If there is no bug
     359     * selected then the returned result is null.
     360     *
     361     * @return The selected bug
     362     */
     363    public MapdustBug getSelectedBug() {
     364        MapdustBug selectedBug = null;
     365        if (panel != null) {
     366            selectedBug = panel.getSelectedBug();
     367        }
     368        return selectedBug;
     369    }
     370
     371    /**
     372     * Sets the given <code>MapdustBug</code> to be selected from the list of
     373     * bugs.
     374     *
     375     * @param mapdustBug The <code>MapdustBug</code> object
     376     */
     377    public void setSelectedBug(MapdustBug mapdustBug) {
     378        if (panel != null) {
     379            panel.setSelectedBug(mapdustBug);
     380        }
     381    }
     382
     383    /**
     384     * Disables the buttons from the <code>MapdustPanel</code>.
     385     *
     386     */
     387    public void disableBtnPanel() {
     388        if (panel != null) {
     389            panel.disableBtnPanel();
     390        }
     391    }
     392
     393    /**
     394     * Enables the basic components from the <code>MapdustButtonPanel</code>.
     395     * Basic components are considered the following buttons: work offline,
     396     * filter bug report, and refresh.If the onlyBasic flag is true then the
     397     * other buttons will be disabled.
     398     *
     399     * @param onlyBasic If true then the not basic buttons will be disabled
     400     */
     401    public void enableBtnPanel(boolean onlyBasic) {
     402        if (panel != null) {
     403            panel.enableBtnPanel(onlyBasic);
     404        }
     405    }
     406
     407    /**
     408     * Returns the list of <code>MapdustAction</code> objects.
     409     *
     410     * @return list of <code>MapdustAction</code>
     411     */
     412    public List<MapdustAction> getMapdustActionList() {
     413        return getActionPanel().getActionList();
     414    }
     415
    282416    /**
    283417     * Adds a new MapDust bug details observer to the list of observers.
    284      * 
     418     *
    285419     * @param observer The <code>MapdustBugDetailsObserver</code> object
    286420     */
     
    291425        }
    292426    }
    293    
    294     /**
    295      * Adds a new MapDust initial update observer to the list of observers.
    296      * 
    297      * @param observer The <code>MapdustInitialUpdateObserver</code> object
    298      */
    299     @Override
    300     public void addObserver(MapdustInitialUpdateObserver observer) {
     427
     428    /**
     429     * Adds a new MapDust update observer to the list of observers.
     430     *
     431     * @param observer The <code>MapdustUpdateObserver</code> object
     432     */
     433    @Override
     434    public void addObserver(MapdustUpdateObserver observer) {
    301435        if (!this.initialUpdateObservers.contains(observer)) {
    302436            this.initialUpdateObservers.add(observer);
    303437        }
    304438    }
    305    
     439
    306440    /**
    307441     * Removes the given MapDust bug details observer from the list of
    308442     * observers.
    309      * 
     443     *
    310444     * @param observer The <code>MapdustBugDetailsObserver</code> object
    311445     */
     
    313447    public void removeObserver(MapdustBugDetailsObserver observer) {
    314448        this.bugDetailsObservers.remove(observer);
    315        
    316     }
    317    
     449
     450    }
     451
    318452    /**
    319453     * Removes the given MapDust initial update observer from the list of
    320454     * observers.
    321      * 
     455     *
    322456     * @param observer The <code>MapdustInitialUpdateObserver</code> object
    323457     */
    324458    @Override
    325     public void removeObserver(MapdustInitialUpdateObserver observer) {
     459    public void removeObserver(MapdustUpdateObserver observer) {
    326460        this.initialUpdateObservers.remove(observer);
    327        
    328     }
    329    
     461
     462    }
     463
    330464    /**
    331465     * Notifies the <code>MapdustBugDetailsObserver</code> objects observing the
     
    340474        }
    341475    }
    342    
     476
    343477    /**
    344478     * Notifies the <code>MapdustInitialUpdateObserver</code> objects waiting
     
    346480     */
    347481    @Override
    348     public void notifyObservers() {
    349         Iterator<MapdustInitialUpdateObserver> elements =
     482    public void notifyObservers(MapdustBugFilter filter, boolean first) {
     483        Iterator<MapdustUpdateObserver> elements =
    350484                this.initialUpdateObservers.iterator();
    351485        while (elements.hasNext()) {
    352             (elements.next()).initialUpdate();
    353         }
    354     }
    355    
     486            (elements.next()).update(null, true);
     487        }
     488    }
     489
    356490    /**
    357491     * Returns the <code>MapdustPanel</code> object
    358      * 
     492     *
    359493     * @return the panel
    360494     */
    361     public MapdustPanel getPanel() {
     495    public MapdustBugListPanel getPanel() {
    362496        return panel;
    363497    }
    364    
     498
    365499    /**
    366500     * Returns the <code>MapdustActionPanel</code> object
    367      * 
     501     *
    368502     * @return the queuePanel
    369503     */
    370     public MapdustActionPanel getQueuePanel() {
    371         return queuePanel;
    372     }
    373    
     504    public MapdustActionPanel getActionPanel() {
     505        return actionPanel;
     506    }
     507
     508    /**
     509     * @return the mapdustPlugin
     510     */
     511    public MapdustPlugin getMapdustPlugin() {
     512        return mapdustPlugin;
     513    }
     514
     515    /**
     516     * @param mapdustPlugin the mapdustPlugin to set
     517     */
     518    public void setMapdustPlugin(MapdustPlugin mapdustPlugin) {
     519        this.mapdustPlugin = mapdustPlugin;
     520    }
     521
    374522}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/adapter/DisplayMenu.java

    r24514 r25591  
    9292    private void showMenu(MouseEvent event) {
    9393        if (event.isPopupTrigger()) {
    94             JList c = (JList) event.getComponent();
    9594            int x = event.getX();
    9695            int y = event.getY();
     
    9998            if (!listBugs.isSelectionEmpty()
    10099                    && locationToIndex == selectedIndex) {
    101                 int count = c.getModel().getSize();
    102                 int cal = count * 18;
    103                 if (y <= cal) {
    104                     menu.show(listBugs, x, y);
    105                 }
     100                menu.show(listBugs, x, y);
     101
    106102            }
    107103        }
    108104    }
     105
    109106}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/adapter/WindowClose.java

    r25127 r25591  
    3131import java.awt.event.WindowAdapter;
    3232import java.awt.event.WindowEvent;
    33 import javax.swing.JToggleButton;
    3433import org.openstreetmap.josm.Main;
    3534import org.openstreetmap.josm.plugins.mapdust.gui.component.dialog.AbstractDialog;
     
    4847
    4948    /** Serial version UID */
    50     private static final long serialVersionUID = 1L;
    5149
    5250    /** A <code>AbstractDialog</code> object */
     
    5553    /** The <code>MapdustButtonPanel</code> object */
    5654    private MapdustButtonPanel btnPanel;
    57 
    58     /** The <code>JToggleButton</code> which had fired the dialog */
    59     private JToggleButton btnFired;
    6055
    6156    /**
     
    6964     * @param dialog The dialog which will be closed
    7065     * @param btnPanel The button panel
    71      * @param btnFired The button which fired the display dialog action
    7266     */
    73     public WindowClose(AbstractDialog dialog, MapdustButtonPanel btnPanel,
    74             JToggleButton btnFired) {
     67    public WindowClose(AbstractDialog dialog, MapdustButtonPanel btnPanel ) {
    7568        this.dialog = dialog;
    7669        this.btnPanel = btnPanel;
    77         this.btnFired = btnFired;
    7870    }
    7971
     
    8678            btnPanel.getBtnWorkOffline().setEnabled(true);
    8779            btnPanel.getBtnWorkOffline().setSelected(false);
     80            btnPanel.getBtnWorkOffline().setFocusable(false);
     81            btnPanel.getBtnFilter().setEnabled(true);
     82            btnPanel.getBtnFilter().setSelected(false);
     83            btnPanel.getBtnFilter().setFocusable(false);
    8884            if (pluginState.equals(MapdustPluginState.OFFLINE.getValue())) {
    8985                btnPanel.getBtnRefresh().setEnabled(false);
    9086            } else {
    9187                btnPanel.getBtnRefresh().setEnabled(true);
     88                btnPanel.getBtnRefresh().setSelected(false);
     89                btnPanel.getBtnRefresh().setFocusable(false);
    9290            }
    9391            if (status.equals(Status.OPEN.getValue())) {
    9492                btnPanel.getBtnFixBugReport().setEnabled(true);
    9593                btnPanel.getBtnInvalidateBugReport().setEnabled(true);
    96                 btnPanel.getBtnReOpenBugReport().setEnabled(false);
    9794                btnPanel.getBtnAddComment().setEnabled(true);
    9895            } else {
    9996                if (status.equals(Status.FIXED.getValue())) {
    100                     btnPanel.getBtnFixBugReport().setEnabled(false);
    101                     btnPanel.getBtnInvalidateBugReport().setEnabled(false);
    10297                    btnPanel.getBtnReOpenBugReport().setEnabled(true);
    10398                    btnPanel.getBtnAddComment().setEnabled(true);
    10499                } else {
    105100                    if (status.equals(Status.INVALID.getValue())) {
    106                         btnPanel.getBtnFixBugReport().setEnabled(false);
    107                         btnPanel.getBtnInvalidateBugReport().setEnabled(false);
    108101                        btnPanel.getBtnReOpenBugReport().setEnabled(true);
    109102                        btnPanel.getBtnAddComment().setEnabled(true);
    110                     } else {
    111                         btnPanel.getBtnFixBugReport().setEnabled(false);
    112                         btnPanel.getBtnInvalidateBugReport().setEnabled(false);
    113                         btnPanel.getBtnReOpenBugReport().setEnabled(false);
    114                         btnPanel.getBtnAddComment().setEnabled(false);
    115103                    }
    116104                }
    117105            }
    118             btnPanel.getBtnRefresh().setSelected(false);
    119             btnPanel.getBtnAddComment().setSelected(false);
    120             btnPanel.getBtnFixBugReport().setSelected(false);
    121             btnPanel.getBtnInvalidateBugReport().setSelected(false);
    122             btnPanel.getBtnReOpenBugReport().setSelected(false);
    123106        }
    124         /* enable fired button */
    125         if (btnFired != null) {
    126             btnFired.setEnabled(true);
    127             btnFired.setSelected(false);
    128         }
     107
     108        btnPanel.getBtnAddComment().setSelected(false);
     109        btnPanel.getBtnAddComment().setFocusable(false);
     110        btnPanel.getBtnFixBugReport().setSelected(false);
     111        btnPanel.getBtnFixBugReport().setFocusable(false);
     112        btnPanel.getBtnInvalidateBugReport().setSelected(false);
     113        btnPanel.getBtnInvalidateBugReport().setFocusable(false);
     114        btnPanel.getBtnReOpenBugReport().setSelected(false);
     115        btnPanel.getBtnReOpenBugReport().setFocusable(false);
     116
    129117        /* dispose dialog */
    130         dialog.setVisible(false);
    131118        dialog.dispose();
    132119    }
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteActionList.java

    r25127 r25591  
    3939import org.openstreetmap.josm.plugins.mapdust.gui.MapdustActionUploaderException;
    4040import org.openstreetmap.josm.plugins.mapdust.gui.MapdustGUI;
    41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustRefreshObservable;
    42 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustRefreshObserver;
     41import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObservable;
     42import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObserver;
    4343import org.openstreetmap.josm.plugins.mapdust.gui.value.MapdustPluginState;
     44import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBugFilter;
    4445
    4546
     
    5354 */
    5455public class ExecuteActionList extends MapdustExecuteAction implements
    55         MapdustRefreshObservable {
     56        MapdustUpdateObservable {
    5657
    5758    /** Serial version UID */
    58     private static final long serialVersionUID = 1L;
     59    private static final long serialVersionUID = -7487830542214611774L;
    5960
    6061    /** List of MapdustRefreshObserver objects */
    61     private final ArrayList<MapdustRefreshObserver> observers =
    62             new ArrayList<MapdustRefreshObserver>();
     62    private final ArrayList<MapdustUpdateObserver> observers =
     63            new ArrayList<MapdustUpdateObserver>();
    6364
    6465    /**
     
    7273
    7374    /**
    74      * Uploads the content of the action list to the MapDust service. 
    75      * 
     75     * Uploads the content of the action list to the MapDust service.
     76     *
    7677     * @param event The event which fires this action
    7778     */
     
    8182            try {
    8283                MapdustActionUploader.getInstance().uploadData(
    83                         getMapdustGUI().getQueuePanel().getActionList());
     84                        getMapdustGUI().getMapdustActionList());
    8485            } catch (MapdustActionUploaderException e) {
    8586                String errorMessage = "There was an error uploading the ";
     
    8889                        tr("Error"), JOptionPane.ERROR_MESSAGE);
    8990            }
    90             Main.pref.put("mapdust.pluginState", MapdustPluginState.ONLINE.getValue());
    91             getMapdustGUI().getPanel().getBtnPanel().getBtnRefresh().setEnabled(true);
    92             notifyObservers();
     91            Main.pref.put("mapdust.pluginState",
     92                    MapdustPluginState.ONLINE.getValue());
     93            notifyObservers(null, false);
    9394        }
    9495    }
     
    100101     */
    101102    @Override
    102     public void addObserver(MapdustRefreshObserver observer) {
     103    public void addObserver(MapdustUpdateObserver observer) {
    103104        if (!this.observers.contains(observer)) {
    104105            this.observers.add(observer);
     
    112113     */
    113114    @Override
    114     public void removeObserver(MapdustRefreshObserver observer) {
     115    public void removeObserver(MapdustUpdateObserver observer) {
    115116        this.observers.remove(observer);
    116117    }
     
    120121     */
    121122    @Override
    122     public void notifyObservers() {
    123         Iterator<MapdustRefreshObserver> elements = this.observers.iterator();
     123    public void notifyObservers(MapdustBugFilter filter, boolean first) {
     124        Iterator<MapdustUpdateObserver> elements = this.observers.iterator();
    124125        while (elements.hasNext()) {
    125             (elements.next()).refreshData();
     126            (elements.next()).update(filter, false);
    126127        }
    127128    }
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteAddBug.java

    r25127 r25591  
    3939import org.openstreetmap.josm.plugins.mapdust.gui.MapdustGUI;
    4040import org.openstreetmap.josm.plugins.mapdust.gui.component.dialog.CreateIssueDialog;
    41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionListObservable;
    42 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionListObserver;
     41import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObservable;
     42import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObserver;
    4343import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObservable;
    4444import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObserver;
     
    6464 */
    6565public class ExecuteAddBug extends MapdustExecuteAction implements
    66         MapdustBugObservable, MapdustActionListObservable {
     66        MapdustBugObservable, MapdustActionObservable {
    6767
    6868    /** The serial version UID */
    69     private static final long serialVersionUID = 1L;
    70 
    71     /** The list of Mapdust bug observers */
     69    private static final long serialVersionUID = 8023875766573474513L;
     70
     71    /** The list of MapDust bug observers */
    7272    private final ArrayList<MapdustBugObserver> bugObservers =
    7373            new ArrayList<MapdustBugObserver>();
    7474
    75     /** The list of Mapdust action observers */
    76     private final ArrayList<MapdustActionListObserver> actionObservers =
    77             new ArrayList<MapdustActionListObserver>();
     75    /** The list of MapDust action observers */
     76    private final ArrayList<MapdustActionObserver> actionObservers =
     77            new ArrayList<MapdustActionObserver>();
    7878
    7979    /**
     
    9797     * are valid. Otherwise a corresponding warning message will be shown to the
    9898     * user.
    99      * 
     99     *
    100100     * @param event The action event which fires this action
    101101     */
     
    122122                latlon = Main.map.mapView.getLatLon(p.x, p.y);
    123123            }
    124             MapdustBug bug = new MapdustBug(latlon, type, commentText, nickname);
     124            MapdustBug bug = new MapdustBug(latlon, type, commentText,
     125                    nickname);
    125126            String pluginState = Main.pref.get("mapdust.pluginState");
    126127            if (pluginState.equals(MapdustPluginState.OFFLINE.getValue())) {
    127128                /* offline state */
    128                 int index = getSelectedBugIndex();
    129129                bug.setStatus(Status.OPEN);
    130130                String iconPath = getIconPath(bug);
    131131                MapdustAction mapdustAction = new MapdustAction(
    132132                        MapdustServiceCommand.ADD_BUG, iconPath, bug);
    133                 if (getMapdustGUI().getQueuePanel() != null) {
     133                /* destroy dialog */
     134                getDialog().dispose();
     135                mapdustGUI.enableBtnPanel(false);
     136                if (getMapdustGUI().getActionPanel() != null) {
    134137                    notifyObservers(mapdustAction);
    135138                }
    136                 resetSelectedBug(index);
    137139            } else {
    138140                /* online state */
     
    143145                } catch (MapdustServiceHandlerException e) {
    144146                    errorMessage = "There was a Mapdust service error.";
    145                     JOptionPane.showMessageDialog(Main.parent, tr(errorMessage), 
     147                    JOptionPane.showMessageDialog(Main.parent, tr(errorMessage),
    146148                            tr("Error"), JOptionPane.ERROR_MESSAGE);
    147149                }
     
    153155                    } catch (MapdustServiceHandlerException e) {
    154156                        errorMessage = "There was a Mapdust service error.";
    155                         JOptionPane.showMessageDialog(Main.parent, tr(errorMessage),
    156                                 tr("Error"), JOptionPane.ERROR_MESSAGE);
     157                        JOptionPane.showMessageDialog(Main.parent,
     158                                tr(errorMessage), tr("Error"),
     159                                JOptionPane.ERROR_MESSAGE);
    157160                    }
     161                    /* destroy dialog */
     162                    getDialog().dispose();
     163                    mapdustGUI.enableBtnPanel(false);
    158164                    if (newMapdustBug != null) {
    159165                        notifyObservers(newMapdustBug);
    160166                    }
    161167                }
    162                 resetSelectedBug(0);
    163168            }
    164             /* destroy dialog */
    165             getDialog().dispose();
    166             return;
    167169        }
    168170    }
     
    209211     */
    210212    @Override
    211     public void addObserver(MapdustActionListObserver observer) {
     213    public void addObserver(MapdustActionObserver observer) {
    212214        if (!this.actionObservers.contains(observer)) {
    213215            this.actionObservers.add(observer);
     
    222224     */
    223225    @Override
    224     public void removeObserver(MapdustActionListObserver observer) {
     226    public void removeObserver(MapdustActionObserver observer) {
    225227        this.actionObservers.remove(observer);
    226228
     
    234236    @Override
    235237    public void notifyObservers(MapdustAction mapdustAction) {
    236         Iterator<MapdustActionListObserver> elements =
     238        Iterator<MapdustActionObserver> elements =
    237239                this.actionObservers.iterator();
    238240        while (elements.hasNext()) {
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteCancel.java

    r25127 r25591  
    4747
    4848    /** The serial version UID */
    49     private static final long serialVersionUID = 1L;
     49    private static final long serialVersionUID = 5357125707042485489L;
    5050
    5151    /**
     
    6767    /**
    6868     * Cancels the executed action, and closes the visible dialog window.
    69      * 
     69     *
    7070     * @param event The action event which fires this action
    7171     */
     
    7676            String status = Main.pref.get("selectedBug.status");
    7777            /* enable buttons */
    78             MapdustButtonPanel btnPanel = getMapdustGUI().getPanel().getBtnPanel();
     78            MapdustButtonPanel btnPanel =
     79                    getMapdustGUI().getPanel().getBtnPanel();
    7980            if (btnPanel != null) {
    8081                btnPanel.getBtnWorkOffline().setEnabled(true);
     82                btnPanel.getBtnWorkOffline().setFocusable(false);
    8183                btnPanel.getBtnWorkOffline().setSelected(false);
    8284                if (pluginState.equals(MapdustPluginState.OFFLINE.getValue())) {
     
    102104                                    false);
    103105                            btnPanel.getBtnReOpenBugReport().setEnabled(true);
    104 
    105106                            btnPanel.getBtnAddComment().setEnabled(true);
    106107                        } else {
    107                             // created bug, then close dialog
    108                             btnPanel.getBtnFixBugReport().setEnabled(false);
    109                             btnPanel.getBtnInvalidateBugReport().setEnabled(
    110                                     false);
    111                             btnPanel.getBtnReOpenBugReport().setEnabled(false);
    112                             btnPanel.getBtnAddComment().setEnabled(false);
     108                            if (!status.isEmpty()) {
     109                                btnPanel.getBtnFixBugReport().setEnabled(false);
     110                                btnPanel.getBtnInvalidateBugReport()
     111                                        .setEnabled(false);
     112                                btnPanel.getBtnReOpenBugReport().setEnabled(
     113                                        false);
     114                                btnPanel.getBtnAddComment().setEnabled(false);
     115                            }
    113116                        }
    114117                    }
    115118                }
    116                 btnPanel.getBtnRefresh().setSelected(false);
     119                btnPanel.getBtnFilter().setEnabled(true);
     120                btnPanel.getBtnFilter().setSelected(false);
     121                btnPanel.getBtnFilter().setFocusable(false);
    117122                btnPanel.getBtnAddComment().setSelected(false);
     123                btnPanel.getBtnAddComment().setFocusable(false);
    118124                btnPanel.getBtnFixBugReport().setSelected(false);
     125                btnPanel.getBtnFixBugReport().setFocusable(false);
    119126                btnPanel.getBtnInvalidateBugReport().setSelected(false);
     127                btnPanel.getBtnInvalidateBugReport().setFocusable(false);
    120128                btnPanel.getBtnReOpenBugReport().setSelected(false);
     129                btnPanel.getBtnReOpenBugReport().setFocusable(false);
    121130            }
    122131        }
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteCloseBug.java

    r25127 r25591  
    3838import org.openstreetmap.josm.plugins.mapdust.gui.MapdustGUI;
    3939import org.openstreetmap.josm.plugins.mapdust.gui.component.dialog.ChangeIssueStatusDialog;
    40 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionListObservable;
    41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionListObserver;
     40import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObservable;
     41import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObserver;
    4242import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObservable;
    4343import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObserver;
     
    6363 */
    6464public class ExecuteCloseBug extends MapdustExecuteAction implements
    65         MapdustBugObservable, MapdustActionListObservable {
     65        MapdustBugObservable, MapdustActionObservable {
    6666
    6767    /** Serial version UID */
    68     private static final long serialVersionUID = 1L;
     68    private static final long serialVersionUID = 3468827127588061014L;
    6969
    7070    /** The list of Mapdust bug observers */
     
    7373
    7474    /** The list of Mapdust action observers */
    75     private final ArrayList<MapdustActionListObserver> actionObservers =
    76             new ArrayList<MapdustActionListObserver>();
     75    private final ArrayList<MapdustActionObserver> actionObservers =
     76            new ArrayList<MapdustActionObserver>();
    7777
    7878    /**
     
    9595     * Closes the given MapDust bug. If the entered informations are invalid a
    9696     * corresponding warning message will be displayed.
    97      * 
     97     *
    9898     * @param event The action event which fires this action
    9999     */
     
    118118                /* valid input data */
    119119                Main.pref.put("mapdust.nickname", nickname);
    120                 MapdustBug selectedBug = getSelectedBug();
     120                MapdustBug selectedBug = mapdustGUI.getSelectedBug();
    121121                MapdustComment comment = new MapdustComment(selectedBug.getId(),
    122122                        commentText, nickname);
     
    129129                            MapdustServiceCommand.CHANGE_BUG_STATUS, iconPath,
    130130                            selectedBug, comment, 2);
    131                     if (getMapdustGUI().getQueuePanel() != null) {
     131                    /* destroy dialog */
     132                    enableFiredButton(issueDialog.getFiredButton());
     133                    mapdustGUI.enableBtnPanel(false);
     134                    issueDialog.dispose();
     135                    if (getMapdustGUI().getActionPanel()!= null) {
    132136                        notifyObservers(mapdustAction);
    133137                    }
     
    140144                    } catch (MapdustServiceHandlerException e) {
    141145                        errorMessage = "There was a Mapdust service error.";
    142                         JOptionPane.showMessageDialog(Main.parent, tr(errorMessage),
    143                                 tr("Error"), JOptionPane.ERROR_MESSAGE);
     146                        JOptionPane.showMessageDialog(Main.parent,
     147                                tr(errorMessage), tr("Error"),
     148                                JOptionPane.ERROR_MESSAGE);
    144149                    }
    145150                    if (id != null) {
     
    147152                        MapdustBug newMapdustBug = null;
    148153                        try {
    149                             newMapdustBug = handler.getBug(selectedBug.getId(), null);
     154                            newMapdustBug = handler.getBug(selectedBug.getId(),
     155                                    null);
    150156                        } catch (MapdustServiceHandlerException e) {
    151157                            errorMessage = "There was a Mapdust service error.";
    152                             JOptionPane.showMessageDialog(Main.parent, tr(errorMessage),
    153                                     tr("Error"), JOptionPane.ERROR_MESSAGE);
     158                            JOptionPane.showMessageDialog(Main.parent,
     159                                    tr(errorMessage), tr("Error"),
     160                                    JOptionPane.ERROR_MESSAGE);
    154161                        }
     162                        /* destroy dialog */
     163                        enableFiredButton(issueDialog.getFiredButton());
     164                        mapdustGUI.enableBtnPanel(false);
     165                        issueDialog.dispose();
    155166                        if (newMapdustBug != null) {
    156167                            notifyObservers(newMapdustBug);
     
    158169                    }
    159170                }
    160                 /* enable buttons */
    161                 enableFiredButton(issueDialog.getFiredButton());
    162                 resetSelectedBug(0);
    163                 /* destroy dialog */
    164                 issueDialog.dispose();
    165171            }
    166172        }
     
    185191     */
    186192    @Override
    187     public void addObserver(MapdustActionListObserver observer) {
     193    public void addObserver(MapdustActionObserver observer) {
    188194        if (!this.actionObservers.contains(observer)) {
    189195            this.actionObservers.add(observer);
     
    201207
    202208    }
    203     /**
    204      * Removes the MapDust action list observer object from the list of observers.
     209
     210    /**
     211     * Removes the MapDust action list observer object from the list of
     212     * observers.
    205213     *
    206214     * @param observer The <code>MapdustActionListObserver</code> object
    207215     */
    208216    @Override
    209     public void removeObserver(MapdustActionListObserver observer) {
     217    public void removeObserver(MapdustActionObserver observer) {
    210218        this.actionObservers.remove(observer);
    211219
     
    228236    @Override
    229237    public void notifyObservers(MapdustAction mapdustAction) {
    230         Iterator<MapdustActionListObserver> elements =
     238        Iterator<MapdustActionObserver> elements =
    231239                this.actionObservers.iterator();
    232240        while (elements.hasNext()) {
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteCommentBug.java

    r25127 r25591  
    3838import org.openstreetmap.josm.plugins.mapdust.gui.MapdustGUI;
    3939import org.openstreetmap.josm.plugins.mapdust.gui.component.dialog.CommentIssueDialog;
    40 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionListObservable;
    41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionListObserver;
     40import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObservable;
     41import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObserver;
    4242import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObservable;
    4343import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObserver;
     
    5454 * Comments the given <code>MapdustBug</code> object. Validates the input data,
    5555 * and based on the plugin state executes the corresponding action. If the
    56  * plugin is in the "ONLINE" state then executes the Mapdust Service
     56 * plugin is in the "ONLINE" state then executes the MapDust Service
    5757 * 'commentBug' method with the given input parameters. If the plugin is in the
    5858 * "OFFLINE" state then the given action is added to the actions list.
     
    6262 */
    6363public class ExecuteCommentBug extends MapdustExecuteAction implements
    64         MapdustBugObservable, MapdustActionListObservable {
     64        MapdustBugObservable, MapdustActionObservable {
    6565
    6666    /** The serial version UID */
    67     private static final long serialVersionUID = 1L;
    68 
    69     /** The list of Mapdust bug observers */
     67    private static final long serialVersionUID = 4391634740784919337L;
     68
     69    /** The list of MapDust bug observers */
    7070    private final ArrayList<MapdustBugObserver> bugObservers =
    7171            new ArrayList<MapdustBugObserver>();
    7272
    7373    /** The list of mapdust action observers */
    74     private final ArrayList<MapdustActionListObserver> actionObservers =
    75             new ArrayList<MapdustActionListObserver>();
     74    private final ArrayList<MapdustActionObserver> actionObservers =
     75            new ArrayList<MapdustActionObserver>();
    7676
    7777    /**
     
    9494     * Creates a comment for the given MapDust bug. If the entered informations
    9595     * are invalid a corresponding warning message will be displayed.
    96      * 
     96     *
    9797     * @param event The action event which fires this action
    9898     */
     
    117117                /* valid */
    118118                Main.pref.put("mapdust.nickname", nickname);
    119                 MapdustBug selectedBug = getSelectedBug();
     119                MapdustBug selectedBug = mapdustGUI.getSelectedBug();
    120120                MapdustComment comment = new MapdustComment(selectedBug.getId(),
    121121                        commentText, nickname);
     
    127127                            MapdustServiceCommand.COMMENT_BUG, iconPath,
    128128                            selectedBug, comment);
    129                     if (getMapdustGUI().getQueuePanel() != null) {
     129                    if (getMapdustGUI().getActionPanel() != null) {
     130                        issueDialog.dispose();
    130131                        notifyObservers(mapdustAction);
    131132                    }
     
    138139                    } catch (MapdustServiceHandlerException e) {
    139140                        errorMessage = "There was a Mapdust service error.";
    140                         JOptionPane.showMessageDialog(Main.parent, tr(errorMessage),
    141                                 tr("Error"), JOptionPane.ERROR_MESSAGE);
     141                        JOptionPane.showMessageDialog(Main.parent,
     142                                tr(errorMessage), tr("Error"),
     143                                JOptionPane.ERROR_MESSAGE);
    142144                    }
    143145                    if (id != null) {
     
    145147                        MapdustBug newMapdustBug = null;
    146148                        try {
    147                             newMapdustBug = handler.getBug(selectedBug.getId(), null);
     149                            newMapdustBug = handler.getBug(selectedBug.getId(),
     150                                    null);
    148151                        } catch (MapdustServiceHandlerException e) {
    149152                            errorMessage = "There was a Mapdust service error.";
     
    159162                /* enable buttons */
    160163                enableFiredButton(issueDialog.getFiredButton());
    161                 resetSelectedBug(0);
     164                mapdustGUI.enableBtnPanel(false);
     165                mapdustGUI.getPanel().resetSelectedBug(0);
    162166                /* destroy dialog */
    163167                issueDialog.dispose();
     
    184188     */
    185189    @Override
    186     public void addObserver(MapdustActionListObserver observer) {
     190    public void addObserver(MapdustActionObserver observer) {
    187191        if (!this.actionObservers.contains(observer)) {
    188192            this.actionObservers.add(observer);
     
    202206
    203207    /**
    204      * Removes the MapDust action list observer object from the list of observers.
     208     * Removes the MapDust action list observer object from the list of
     209     * observers.
    205210     *
    206211     * @param observer The <code>MapdustActionListObserver</code> object
    207212     */
    208213    @Override
    209     public void removeObserver(MapdustActionListObserver observer) {
     214    public void removeObserver(MapdustActionObserver observer) {
    210215        this.actionObservers.remove(observer);
    211216    }
     
    227232    @Override
    228233    public void notifyObservers(MapdustAction mapdustAction) {
    229         Iterator<MapdustActionListObserver> elements =
     234        Iterator<MapdustActionObserver> elements =
    230235                this.actionObservers.iterator();
    231236        while (elements.hasNext()) {
     
    233238        }
    234239    }
    235    
     240
    236241}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteInvalidateBug.java

    r25127 r25591  
    3838import org.openstreetmap.josm.plugins.mapdust.gui.MapdustGUI;
    3939import org.openstreetmap.josm.plugins.mapdust.gui.component.dialog.ChangeIssueStatusDialog;
    40 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionListObservable;
    41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionListObserver;
     40import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObservable;
     41import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObserver;
    4242import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObservable;
    4343import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObserver;
     
    6464 */
    6565public class ExecuteInvalidateBug extends MapdustExecuteAction implements
    66         MapdustBugObservable, MapdustActionListObservable {
     66        MapdustBugObservable, MapdustActionObservable {
    6767
    6868    /** The serial version UID */
    69     private static final long serialVersionUID = 1L;
     69    private static final long serialVersionUID = 542699469544481797L;
    7070
    7171    /** The list of mapdust bug observers */
     
    7474
    7575    /** The list of mapdust action observers */
    76     private final ArrayList<MapdustActionListObserver> actionObservers =
    77             new ArrayList<MapdustActionListObserver>();
     76    private final ArrayList<MapdustActionObserver> actionObservers =
     77            new ArrayList<MapdustActionObserver>();
    7878
    7979    /**
     
    9898     * Invalidates the given MapDust bug. If the entered informations are
    9999     * invalid a corresponding warning message will be displayed.
    100      * 
     100     *
    101101     * @param event The action event which fires this action
    102102     */
     
    115115                if (errorMessage != null) {
    116116                    /* invalid input */
    117                     JOptionPane.showMessageDialog(Main.parent, tr(errorMessage), 
     117                    JOptionPane.showMessageDialog(Main.parent, tr(errorMessage),
    118118                            tr("Missing input data"), JOptionPane.WARNING_MESSAGE);
    119119                    return;
     
    121121                /* valid input */
    122122                Main.pref.put("mapdust.nickname", nickname);
    123                 MapdustBug selectedBug = getSelectedBug();
    124                 MapdustComment comment = new MapdustComment(selectedBug.getId(), 
     123                MapdustBug selectedBug = mapdustGUI.getSelectedBug();
     124                MapdustComment comment = new MapdustComment(selectedBug.getId(),
    125125                        commentText, nickname);
    126126                String pluginState = Main.pref.get("mapdust.pluginState");
     
    130130                    String iconPath = getIconPath(selectedBug);
    131131                    MapdustAction mapdustAction = new MapdustAction(
    132                             MapdustServiceCommand.CHANGE_BUG_STATUS, iconPath, 
     132                            MapdustServiceCommand.CHANGE_BUG_STATUS, iconPath,
    133133                            selectedBug, comment, 3);
    134                     if (getMapdustGUI().getQueuePanel() != null) {
     134                    /* destroy dialog */
     135
     136                    /* enable buttons */
     137                    mapdustGUI.enableBtnPanel(false);
     138                    enableFiredButton(issueDialog.getFiredButton());
     139                    issueDialog.dispose();
     140                    if (getMapdustGUI().getActionPanel() != null) {
    135141                        notifyObservers(mapdustAction);
    136142                    }
     
    143149                    } catch (MapdustServiceHandlerException e) {
    144150                        errorMessage = "There was a Mapdust service error.";
    145                         JOptionPane.showMessageDialog(Main.parent, 
     151                        JOptionPane.showMessageDialog(Main.parent,
    146152                                tr(errorMessage), tr("Error"),
    147153                                JOptionPane.ERROR_MESSAGE);
     
    151157                        MapdustBug newMapdustBug = null;
    152158                        try {
    153                             newMapdustBug = handler.getBug(selectedBug.getId(), 
     159                            newMapdustBug = handler.getBug(selectedBug.getId(),
    154160                                    null);
    155161                        } catch (MapdustServiceHandlerException e) {
    156162                            errorMessage = "There was a Mapdust service error.";
    157163                            errorMessage += "Mapdust bug report.";
    158                             JOptionPane.showMessageDialog(Main.parent, 
     164                            JOptionPane.showMessageDialog(Main.parent,
    159165                                    tr(errorMessage), tr("Error"),
    160166                                    JOptionPane.ERROR_MESSAGE);
    161167                        }
     168                        /* destroy dialog */
     169
     170                        /* enable buttons */
     171                        enableFiredButton(issueDialog.getFiredButton());
     172                        mapdustGUI.enableBtnPanel(false);
     173                        issueDialog.dispose();
     174
    162175                        if (newMapdustBug != null) {
    163176                            notifyObservers(newMapdustBug);
     
    165178                    }
    166179                }
    167                 /* enable buttons */
    168                 enableFiredButton(issueDialog.getFiredButton());
    169                 resetSelectedBug(0);
    170                 /* destroy dialog */
    171                 issueDialog.dispose();
     180
    172181            }
    173182        }
     
    192201     */
    193202    @Override
    194     public void addObserver(MapdustActionListObserver observer) {
     203    public void addObserver(MapdustActionObserver observer) {
    195204        if (!this.actionObservers.contains(observer)) {
    196205            this.actionObservers.add(observer);
     
    215224     */
    216225    @Override
    217     public void removeObserver(MapdustActionListObserver observer) {
     226    public void removeObserver(MapdustActionObserver observer) {
    218227        this.actionObservers.remove(observer);
    219228
     
    236245    @Override
    237246    public void notifyObservers(MapdustAction mapdustAction) {
    238         Iterator<MapdustActionListObserver> elements =
     247        Iterator<MapdustActionObserver> elements =
    239248                this.actionObservers.iterator();
    240249        while (elements.hasNext()) {
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteReOpenBug.java

    r25127 r25591  
    3838import org.openstreetmap.josm.plugins.mapdust.gui.MapdustGUI;
    3939import org.openstreetmap.josm.plugins.mapdust.gui.component.dialog.ChangeIssueStatusDialog;
    40 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionListObservable;
    41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionListObserver;
     40import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObservable;
     41import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObserver;
    4242import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObservable;
    4343import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObserver;
     
    6464 */
    6565public class ExecuteReOpenBug extends MapdustExecuteAction implements
    66         MapdustBugObservable, MapdustActionListObservable {
     66        MapdustBugObservable, MapdustActionObservable {
    6767
    6868    /** The serial version UID */
    69     private static final long serialVersionUID = 1L;
    70 
    71     /** The list of mapdust bug observers */
     69    private static final long serialVersionUID = 8275121997644127251L;
     70
     71    /** The list of MapDust bug observers */
    7272    private final ArrayList<MapdustBugObserver> bugObservers =
    7373            new ArrayList<MapdustBugObserver>();
    7474
    75     /** The list of mapdust action observers */
    76     private final ArrayList<MapdustActionListObserver> actionObservers =
    77             new ArrayList<MapdustActionListObserver>();
     75    /** The list of MapDust action observers */
     76    private final ArrayList<MapdustActionObserver> actionObservers =
     77            new ArrayList<MapdustActionObserver>();
    7878
    7979    /**
     
    9595
    9696    /**
    97      * 
     97     *
    9898     * @param event The event which fires this action
    9999     */
     
    112112                if (errorMessage != null) {
    113113                    /* invalid data */
    114                     JOptionPane.showMessageDialog(Main.parent,
    115                             tr(errorMessage), tr("Missing input data"),
    116                             JOptionPane.WARNING_MESSAGE);
     114                    JOptionPane.showMessageDialog(Main.parent, tr(errorMessage),
     115                            tr("Missing input data"), JOptionPane.WARNING_MESSAGE);
    117116                    return;
    118117                }
    119118                /* valid */
    120119                Main.pref.put("mapdust.nickname", nickname);
    121                 MapdustBug selectedBug = getSelectedBug();
    122                 MapdustComment comment =
    123                         new MapdustComment(selectedBug.getId(), commentText,
    124                                 nickname);
     120                MapdustBug selectedBug = mapdustGUI.getSelectedBug();
     121                MapdustComment comment = new MapdustComment(selectedBug.getId(),
     122                        commentText, nickname);
    125123                String pluginState = Main.pref.get("mapdust.pluginState");
    126124                if (pluginState.equals(MapdustPluginState.OFFLINE.getValue())) {
     
    128126                    selectedBug.setStatus(Status.OPEN);
    129127                    String iconPath = getIconPath(selectedBug);
    130                     MapdustAction mapdustAction =
    131                             new MapdustAction(
    132                                     MapdustServiceCommand.CHANGE_BUG_STATUS,
    133                                     iconPath, selectedBug, comment, 1);
    134                     if (getMapdustGUI().getQueuePanel() != null) {
     128                    MapdustAction mapdustAction = new MapdustAction(
     129                            MapdustServiceCommand.CHANGE_BUG_STATUS, iconPath,
     130                            selectedBug, comment, 1);
     131                    /* destroy dialog */
     132                    mapdustGUI.enableBtnPanel(false);
     133                    enableFiredButton(issueDialog.getFiredButton());
     134                    issueDialog.dispose();
     135                    if (getMapdustGUI().getActionPanel() != null) {
    135136                        notifyObservers(mapdustAction);
    136137                    }
    137138                } else {
    138                     /* online, call Mapdust service method */
     139                    /* online, call MapDust service method */
    139140                    MapdustServiceHandler handler = new MapdustServiceHandler();
    140141                    Long id = null;
     
    149150                    }
    150151                    if (id != null) {
    151                         // success
    152152                        MapdustBug newMapdustBug = null;
    153153                        try {
    154                             newMapdustBug =
    155                                     handler.getBug(selectedBug.getId(), null);
     154                            newMapdustBug = handler.getBug(selectedBug.getId(),
     155                                    null);
    156156                        } catch (MapdustServiceHandlerException e) {
    157157                            errorMessage = "There was a Mapdust service error.";
     
    161161                                    JOptionPane.ERROR_MESSAGE);
    162162                        }
     163                        mapdustGUI.enableBtnPanel(false);
     164                        enableFiredButton(issueDialog.getFiredButton());
     165                        issueDialog.dispose();
    163166                        if (newMapdustBug != null) {
    164167                            notifyObservers(newMapdustBug);
     
    166169                    }
    167170                }
    168                 /* enable buttons */
    169                 enableFiredButton(issueDialog.getFiredButton());
    170                 resetSelectedBug(0);
    171                 /* destroy dialog */
    172                 issueDialog.dispose();
    173171            }
    174172        }
     
    193191     */
    194192    @Override
    195     public void addObserver(MapdustActionListObserver observer) {
     193    public void addObserver(MapdustActionObserver observer) {
    196194        if (!this.actionObservers.contains(observer)) {
    197195            this.actionObservers.add(observer);
     
    211209
    212210    /**
    213      * Removes the MapDust action list observer object from the list of observers.
     211     * Removes the MapDust action list observer object from the list of
     212     * observers.
    214213     *
    215214     * @param observer The <code>MapdustActionListObserver</code> object
    216215     */
    217216    @Override
    218     public void removeObserver(MapdustActionListObserver observer) {
     217    public void removeObserver(MapdustActionObserver observer) {
    219218        this.actionObservers.remove(observer);
    220219
     
    237236    @Override
    238237    public void notifyObservers(MapdustAction mapdustAction) {
    239         Iterator<MapdustActionListObserver> elements =
     238        Iterator<MapdustActionObserver> elements =
    240239                this.actionObservers.iterator();
    241240        while (elements.hasNext()) {
     
    243242        }
    244243    }
    245    
     244
    246245}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteRefresh.java

    r25127 r25591  
    3535import javax.swing.JToggleButton;
    3636import org.openstreetmap.josm.Main;
    37 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustRefreshObservable;
    38 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustRefreshObserver;
     37import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObservable;
     38import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObserver;
     39import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBugFilter;
    3940
    4041
     
    4748 */
    4849public class ExecuteRefresh extends AbstractAction implements
    49         MapdustRefreshObservable {
     50        MapdustUpdateObservable {
    5051
    5152    /** The serial version UID */
    52     private static final long serialVersionUID = 1L;
     53    private static final long serialVersionUID = 1507634893685333278L;
    5354
    5455    /** The list of MapDust refresh observers */
    55     private final ArrayList<MapdustRefreshObserver> observers =
    56             new ArrayList<MapdustRefreshObserver>();
     56    private final ArrayList<MapdustUpdateObserver> observers =
     57            new ArrayList<MapdustUpdateObserver>();
    5758
    5859    /**
     
    6263
    6364    /**
    64      * Updates the Mapdust data.
    65      * 
     65     * Updates the MapDust data.
     66     *
    6667     * @param event The event which fires this action
    6768     */
     
    7273            /* update the bugs */
    7374            Main.pref.put("mapdust.showError", true);
    74             notifyObservers();
     75            notifyObservers(null, false);
    7576            btn.setSelected(false);
     77            btn.setFocusable(false);
    7678        }
    7779    }
     
    8385     */
    8486    @Override
    85     public void addObserver(MapdustRefreshObserver observer) {
     87    public void addObserver(MapdustUpdateObserver observer) {
    8688        if (!this.observers.contains(observer)) {
    8789            this.observers.add(observer);
     
    9597     */
    9698    @Override
    97     public void removeObserver(MapdustRefreshObserver observer) {
     99    public void removeObserver(MapdustUpdateObserver observer) {
    98100        this.observers.remove(observer);
    99101    }
     
    103105     */
    104106    @Override
    105     public void notifyObservers() {
    106         Iterator<MapdustRefreshObserver> elements = this.observers.iterator();
     107    public void notifyObservers(MapdustBugFilter filter, boolean first) {
     108        Iterator<MapdustUpdateObserver> elements = this.observers.iterator();
    107109        while (elements.hasNext()) {
    108             (elements.next()).refreshData();
     110            (elements.next()).update(filter, false);
    109111        }
    110112    }
    111    
     113
    112114}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteWorkOffline.java

    r25127 r25591  
    3939import org.openstreetmap.josm.plugins.mapdust.gui.MapdustActionUploaderException;
    4040import org.openstreetmap.josm.plugins.mapdust.gui.MapdustGUI;
    41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustRefreshObservable;
    42 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustRefreshObserver;
     41import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObservable;
     42import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObserver;
    4343import org.openstreetmap.josm.plugins.mapdust.gui.value.MapdustPluginState;
     44import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBugFilter;
    4445
    4546
    4647/**
    47  * Executes the work offline action. In the offline mode the user actions will
     48 * Executes the "work offline" action. In the offline mode the user actions will
    4849 * not be uploaded immediately to the MapDust service. The user can perform the
    4950 * following actions in offline mode: add bug, comment bug and change bug
     
    5556 */
    5657public class ExecuteWorkOffline extends MapdustExecuteAction implements
    57         MapdustRefreshObservable {
     58        MapdustUpdateObservable {
    5859
    5960    /** The serial version UID */
    60     private static final long serialVersionUID = 1L;
     61    private static final long serialVersionUID = 8792828131813689548L;
    6162
    62     /** The list of mapdust refresh observers */
    63     private final ArrayList<MapdustRefreshObserver> observers =
    64             new ArrayList<MapdustRefreshObserver>();
     63    /** The list of MapDust refresh observers */
     64    private final ArrayList<MapdustUpdateObserver> observers =
     65            new ArrayList<MapdustUpdateObserver>();
    6566
    6667    /**
     
    8182    /**
    8283     * Sets the 'offline' mode for the plugin.
    83      * 
     84     *
    8485     * @param event The event which fires this action
    8586     */
     
    102103                            tr(message), tr(title), JOptionPane.YES_NO_OPTION);
    103104                    if (result == JOptionPane.YES_OPTION) {
    104                         // process data
    105105                        try {
    106106                            MapdustActionUploader.getInstance().uploadData(
    107                                     getMapdustGUI().getQueuePanel().getActionList());
     107                                    getMapdustGUI().getMapdustActionList());
    108108                        } catch (MapdustActionUploaderException e) {
    109                             String errorMessage = "There was a Mapdust service error.";
     109                            String errorMessage = "There was a Mapdust service";
     110                            errorMessage+=" error.";
    110111                            JOptionPane.showMessageDialog(Main.parent,
    111112                                    tr(errorMessage), tr("Error"),
     
    117118                    btn.setSelected(false);
    118119                }
    119                 notifyObservers();
     120                notifyObservers(null, false);
    120121            }
    121122        }
     
    128129     */
    129130    @Override
    130     public void addObserver(MapdustRefreshObserver observer) {
     131    public void addObserver(MapdustUpdateObserver observer) {
    131132        if (!this.observers.contains(observer)) {
    132133            this.observers.add(observer);
     
    140141     */
    141142    @Override
    142     public void removeObserver(MapdustRefreshObserver observer) {
     143    public void removeObserver(MapdustUpdateObserver observer) {
    143144        this.observers.remove(observer);
    144145    }
     
    148149     */
    149150    @Override
    150     public void notifyObservers() {
    151         Iterator<MapdustRefreshObserver> elements = this.observers.iterator();
     151    public void notifyObservers(MapdustBugFilter filter, boolean first) {
     152        Iterator<MapdustUpdateObserver> elements = this.observers.iterator();
    152153        while (elements.hasNext()) {
    153             (elements.next()).refreshData();
     154            (elements.next()).update(filter, false);
    154155        }
    155156    }
    156    
     157
    157158}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/MapdustExecuteAction.java

    r24514 r25591  
    3030
    3131import javax.swing.AbstractAction;
    32 import javax.swing.JList;
    3332import javax.swing.JToggleButton;
    3433import org.openstreetmap.josm.plugins.mapdust.gui.MapdustGUI;
     
    4746
    4847    /** Serial version UID */
    49     private static final long serialVersionUID = 1L;
     48    private static final long serialVersionUID = 4318259806647818543L;
    5049
    5150    /** The abstract dialog object */
     
    113112
    114113    /**
    115      * Returns the selected MapDust bug from the MapDust bugs list.
    116      *
    117      * @return A <code>MapdustBug</code> object
    118      */
    119     protected MapdustBug getSelectedBug() {
    120         JList listBugs = this.mapdustGUI.getPanel().getListBugs();
    121         MapdustBug selectedBug = (MapdustBug) listBugs.getSelectedValue();
    122         return selectedBug;
    123     }
    124 
    125     /**
    126      * Returns the index of the MapDust bug selected from the MapDust bugs list.
    127      *
    128      * @return index
    129      */
    130     protected int getSelectedBugIndex() {
    131         JList listBugs = this.mapdustGUI.getPanel().getListBugs();
    132         int index = listBugs.getSelectedIndex();
    133         return index;
    134     }
    135 
    136     /**
    137      * Sets the given object from the given index to be selected.
    138      *
    139      * @param index The index of the element from the list of bugs
    140      */
    141     protected void resetSelectedBug(int index) {
    142         JList listBugs = this.mapdustGUI.getPanel().getListBugs();
    143         listBugs.setSelectedIndex(index);
    144     }
    145 
    146     /**
    147114     * Enables the given button. This button had fired a corresponding action,
    148115     * and after the action finishes, the button need to become enabled.
     
    152119    protected void enableFiredButton(JToggleButton button) {
    153120        if (button != null) {
    154             button.setEnabled(true);
    155121            button.setSelected(false);
     122            button.setFocusable(false);
    156123        }
    157124    }
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/package-info.java

    r24514 r25591  
    11/**
    2  * Contains the Action classes which handles the user actions.
     2 * Contains the action classes which handles the user actions.
     3 * Each of these class extends the <code>MapdustExecuteAction</code> abstract
     4 * class.
    35 */
    46package org.openstreetmap.josm.plugins.mapdust.gui.action.execute;
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/package-info.java

    r24514 r25591  
    11/**
    2  * Contains the GUI action classes.
     2 * Contains the MapDust GUI action classes. The action classes are divided
     3 * in three main categories: adapter, execute and show.
    34 */
    45package org.openstreetmap.josm.plugins.mapdust.gui.action;
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/show/MapdustShowAction.java

    r25127 r25591  
    4444
    4545    /** The serial version UID */
    46     private static final long serialVersionUID = 1L;
     46    private static final long serialVersionUID = -4894445690647156702L;
    4747
    4848    /** The title of the dialog window */
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/show/ShowCloseBugAction.java

    r25127 r25591  
    3030
    3131import java.awt.event.ActionEvent;
     32import javax.swing.JMenuItem;
    3233import javax.swing.JToggleButton;
    3334import org.openstreetmap.josm.plugins.mapdust.MapdustPlugin;
     
    3738
    3839/**
    39  * Displays the close bug action dialog window.
     40 * Displays the <code>ChangeIssueStatusDialog</code> dialog window of type
     41 * 'close'. This action is executed whenever the user clicks on the
     42 * "Close bug report" button or selects the "Close bug" option from the pop-up
     43 * menu.
    4044 *
    4145 * @author Bea
     
    4549
    4650    /** The serial version UID */
    47     private static final long serialVersionUID = 1L;
     51    private static final long serialVersionUID = 6459224244170352152L;
    4852
    4953    /**
     
    5357
    5458    /**
    55      * Builds a <code>ShowCloseBugAction</code> object
     59     * Builds a <code>ShowCloseBugAction</code> object based on the given
     60     * argument.
    5661     *
    5762     * @param mapdustPlugin The <code>MapdustPlugin</code> object
     
    6671    }
    6772
     73    /**
     74     * Builds a <code>ChangeIssueStatusDialog</code> dialog window of type
     75     * "close" and displays on the screen.
     76     *
     77     * @param event The <code>ActionEvent</code> object
     78     */
    6879    @Override
    6980    public void actionPerformed(ActionEvent event) {
     
    7283            if (event.getSource() instanceof JToggleButton) {
    7384                btn = (JToggleButton) event.getSource();
    74                 btn.setEnabled(false);
     85            } else {
     86                if (event.getSource() instanceof JMenuItem) {
     87                    getButtonPanel().getBtnFixBugReport().setSelected(true);
     88                }
    7589            }
    7690            disableButtons(getButtonPanel());
     
    8599    }
    86100
     101    /**
     102     * Disables the buttons from the <code>MapdustButtonPanel</code> according
     103     * to the executed action type. The only enabled button will be close bug
     104     * report button.
     105     *
     106     * @param buttonPanel The <code>MapdustButtonPanel</code> object
     107     */
    87108    @Override
    88109    void disableButtons(MapdustButtonPanel buttonPanel) {
    89110        buttonPanel.getBtnWorkOffline().setEnabled(false);
     111        buttonPanel.getBtnWorkOffline().setSelected(false);
     112        buttonPanel.getBtnWorkOffline().setFocusable(false);
    90113        buttonPanel.getBtnRefresh().setEnabled(false);
     114        buttonPanel.getBtnRefresh().setSelected(false);
     115        buttonPanel.getBtnRefresh().setFocusable(false);
     116        buttonPanel.getBtnFilter().setEnabled(false);
     117        buttonPanel.getBtnFilter().setSelected(false);
     118        buttonPanel.getBtnFilter().setFocusable(false);
    91119        buttonPanel.getBtnAddComment().setEnabled(false);
     120        buttonPanel.getBtnAddComment().setSelected(false);
     121        buttonPanel.getBtnAddComment().setFocusable(false);
    92122        buttonPanel.getBtnInvalidateBugReport().setEnabled(false);
     123        buttonPanel.getBtnInvalidateBugReport().setSelected(false);
     124        buttonPanel.getBtnInvalidateBugReport().setFocusable(false);
    93125        buttonPanel.getBtnReOpenBugReport().setEnabled(false);
    94 
     126        buttonPanel.getBtnReOpenBugReport().setSelected(false);
     127        buttonPanel.getBtnReOpenBugReport().setFocusable(false);
    95128    }
    96129
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/show/ShowCommentBugAction.java

    r25127 r25591  
    3030
    3131import java.awt.event.ActionEvent;
     32import javax.swing.JMenuItem;
    3233import javax.swing.JToggleButton;
    3334import org.openstreetmap.josm.plugins.mapdust.MapdustPlugin;
     
    3738
    3839/**
    39  * Displays the comment bug dialog.
     40 * Displays the <code>CommentIssueDialog</code> dialog window. This action is
     41 * executed whenever the user clicks on the "Create bug report comment" button
     42 * or selects the "Add comment" option from the pop-up menu.
    4043 *
    4144 * @author Bea
     
    4548
    4649    /** The serial version UID */
    47     private static final long serialVersionUID = 1L;
     50    private static final long serialVersionUID = -8174561825477499474L;
    4851
    4952    /**
     
    6770    }
    6871
     72    /**
     73     * Builds a <code>CommentIssueDialog</code> dialog window and displays
     74     * on the screen.
     75     *
     76     * @param event The <code>ActionEvent</code> object
     77     */
    6978    @Override
    7079    public void actionPerformed(ActionEvent event) {
     
    7382            if (event.getSource() instanceof JToggleButton) {
    7483                btn = (JToggleButton) event.getSource();
    75                 btn.setEnabled(false);
     84            } else {
     85                if (event.getSource() instanceof JMenuItem) {
     86                    getButtonPanel().getBtnAddComment().setSelected(true);
     87                }
    7688            }
    7789            disableButtons(getButtonPanel());
     
    8597    }
    8698
     99    /**
     100     * Disables the buttons from the <code>MapdustButtonPanel</code> according
     101     * to the executed action type. The only enabled button will be the "Create
     102     * bug report comment" button.
     103     *
     104     * @param buttonPanel The <code>MapdustButtonPanel</code> object
     105     */
    87106    @Override
    88107    void disableButtons(MapdustButtonPanel buttonPanel) {
    89108        buttonPanel.getBtnWorkOffline().setEnabled(false);
     109        buttonPanel.getBtnWorkOffline().setSelected(false);
     110        buttonPanel.getBtnWorkOffline().setFocusable(false);
    90111        buttonPanel.getBtnRefresh().setEnabled(false);
     112        buttonPanel.getBtnRefresh().setSelected(false);
     113        buttonPanel.getBtnRefresh().setFocusable(false);
     114        buttonPanel.getBtnFilter().setEnabled(false);
     115        buttonPanel.getBtnFilter().setSelected(false);
     116        buttonPanel.getBtnFilter().setFocusable(false);
     117        buttonPanel.getBtnInvalidateBugReport().setEnabled(false);
     118        buttonPanel.getBtnInvalidateBugReport().setSelected(false);
     119        buttonPanel.getBtnInvalidateBugReport().setFocusable(false);
     120        buttonPanel.getBtnReOpenBugReport().setEnabled(false);
     121        buttonPanel.getBtnReOpenBugReport().setSelected(false);
     122        buttonPanel.getBtnReOpenBugReport().setFocusable(false);
    91123        buttonPanel.getBtnFixBugReport().setEnabled(false);
    92         buttonPanel.getBtnInvalidateBugReport().setEnabled(false);
    93         buttonPanel.getBtnReOpenBugReport().setEnabled(false);
     124        buttonPanel.getBtnFixBugReport().setSelected(false);
     125        buttonPanel.getBtnFixBugReport().setFocusable(false);
    94126    }
    95127
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/show/ShowInvalidateBugAction.java

    r25127 r25591  
    3030
    3131import java.awt.event.ActionEvent;
     32import javax.swing.JMenuItem;
    3233import javax.swing.JToggleButton;
    3334import org.openstreetmap.josm.plugins.mapdust.MapdustPlugin;
     
    3738
    3839/**
    39  * Displays the invalidate bug dialog.
     40 * Displays the <code>ChangeIssueStatusDialog</code> dialog window of type
     41 * 'invalidate'. This action is executed whenever the user clicks on the
     42 * "Invalidate bug report" button or selects the "Invalidate bug" option from
     43 * the pop-up menu.
    4044 *
    4145 * @author Bea
     
    6771    }
    6872
     73    /**
     74     * Builds a <code>ChangeIssueStatusDialog</code> dialog window of type
     75     * "invalidate" and displays on the screen.
     76     *
     77     * @param event The <code>ActionEvent</code> object
     78     */
    6979    @Override
    7080    public void actionPerformed(ActionEvent event) {
     
    7383            if (event.getSource() instanceof JToggleButton) {
    7484                btn = (JToggleButton) event.getSource();
    75                 btn.setEnabled(false);
     85            } else {
     86                if (event.getSource() instanceof JMenuItem) {
     87                    getButtonPanel().getBtnInvalidateBugReport().setSelected(
     88                            true);
     89                }
    7690            }
    7791            disableButtons(getButtonPanel());
     
    86100    }
    87101
     102    /**
     103     * Disables the buttons from the <code>MapdustButtonPanel</code> according
     104     * to the executed action type. The only enabled button will be the
     105     * "Invalidate bug report" button.
     106     *
     107     * @param buttonPanel The <code>MapdustButtonPanel</code> object
     108     */
    88109    @Override
    89110    void disableButtons(MapdustButtonPanel buttonPanel) {
    90111        buttonPanel.getBtnWorkOffline().setEnabled(false);
     112        buttonPanel.getBtnWorkOffline().setSelected(false);
     113        buttonPanel.getBtnWorkOffline().setFocusable(false);
    91114        buttonPanel.getBtnRefresh().setEnabled(false);
     115        buttonPanel.getBtnRefresh().setSelected(false);
     116        buttonPanel.getBtnRefresh().setFocusable(false);
     117        buttonPanel.getBtnFilter().setEnabled(false);
     118        buttonPanel.getBtnFilter().setSelected(false);
     119        buttonPanel.getBtnFilter().setFocusable(false);
    92120        buttonPanel.getBtnAddComment().setEnabled(false);
     121        buttonPanel.getBtnAddComment().setSelected(false);
     122        buttonPanel.getBtnAddComment().setFocusable(false);
     123        buttonPanel.getBtnReOpenBugReport().setEnabled(false);
     124        buttonPanel.getBtnReOpenBugReport().setSelected(false);
     125        buttonPanel.getBtnReOpenBugReport().setFocusable(false);
    93126        buttonPanel.getBtnFixBugReport().setEnabled(false);
    94         buttonPanel.getBtnReOpenBugReport().setEnabled(false);
     127        buttonPanel.getBtnFixBugReport().setSelected(false);
     128        buttonPanel.getBtnFixBugReport().setFocusable(false);
    95129    }
    96130
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/show/ShowReOpenBugAction.java

    r25127 r25591  
    3030
    3131import java.awt.event.ActionEvent;
     32import javax.swing.JMenuItem;
    3233import javax.swing.JToggleButton;
    3334import org.openstreetmap.josm.plugins.mapdust.MapdustPlugin;
     
    3738
    3839/**
    39  * Displays the re-open bug dialog window.
     40 * Displays the <code>ChangeIssueStatusDialog</code> dialog window of type
     41 * 'reopen'. This action is executed whenever the user clicks on the
     42 * "Re-open bug report" button or selects the "Re-open bug" option from
     43 * the pop-up menu.
    4044 *
    4145 * @author Bea
     
    6670    }
    6771
     72    /**
     73     * Builds a <code>ChangeIssueStatusDialog</code> dialog window of type
     74     * "re-open" and displays on the screen.
     75     *
     76     * @param event The <code>ActionEvent</code> object
     77     */
    6878    @Override
    6979    public void actionPerformed(ActionEvent event) {
     
    7282            if (event.getSource() instanceof JToggleButton) {
    7383                btn = (JToggleButton) event.getSource();
    74                 btn.setEnabled(false);
     84                btn.setSelected(true);
     85            } if (event.getSource() instanceof JMenuItem){
     86                getButtonPanel().getBtnReOpenBugReport().setSelected(true);
    7587            }
    7688            disableButtons(getButtonPanel());
     
    8597    }
    8698
     99    /**
     100     * Disables the buttons from the <code>MapdustButtonPanel</code> according
     101     * to the executed action type. The only enabled button will be the
     102     * "Re-open bug report" button.
     103     *
     104     * @param buttonPanel The <code>MapdustButtonPanel</code> object
     105     */
    87106    @Override
    88107    void disableButtons(MapdustButtonPanel buttonPanel) {
    89108        if (buttonPanel != null) {
    90109            buttonPanel.getBtnWorkOffline().setEnabled(false);
     110            buttonPanel.getBtnWorkOffline().setSelected(false);
     111            buttonPanel.getBtnWorkOffline().setFocusable(false);
    91112            buttonPanel.getBtnRefresh().setEnabled(false);
     113            buttonPanel.getBtnRefresh().setSelected(false);
     114            buttonPanel.getBtnRefresh().setFocusable(false);
     115            buttonPanel.getBtnFilter().setEnabled(false);
     116            buttonPanel.getBtnFilter().setSelected(false);
     117            buttonPanel.getBtnFilter().setFocusable(false);
    92118            buttonPanel.getBtnAddComment().setEnabled(false);
     119            buttonPanel.getBtnAddComment().setSelected(false);
     120            buttonPanel.getBtnAddComment().setFocusable(false);
     121            buttonPanel.getBtnInvalidateBugReport().setEnabled(false);
     122            buttonPanel.getBtnInvalidateBugReport().setSelected(false);
     123            buttonPanel.getBtnInvalidateBugReport().setFocusable(false);
    93124            buttonPanel.getBtnFixBugReport().setEnabled(false);
    94             buttonPanel.getBtnInvalidateBugReport().setEnabled(false);
     125            buttonPanel.getBtnFixBugReport().setSelected(false);
     126            buttonPanel.getBtnFixBugReport().setFocusable(false);
    95127        }
    96128    }
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/show/package-info.java

    r24514 r25591  
    11/**
    2  * Contains the classes, which are used in order to display the dialogs of the plugin.
     2 * Contains the classes, which are used in order to display the dialogs of the
     3 * plugin.
     4 * Each of these classes extends the <code>MapdustShowAction</code> abstract
     5 * class.
    36 */
    47package org.openstreetmap.josm.plugins.mapdust.gui.action.show;
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/dialog/AbstractDialog.java

    r24514 r25591  
    4242
    4343    /** The serial version UID */
    44     private static final long serialVersionUID = 1L;
     44    private static final long serialVersionUID = 7543537884312236858L;
    4545
    4646    /** The button which opened the dialog window */
     
    7171        this.firedButton = firedButton;
    7272    }
     73
    7374}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/dialog/ChangeIssueStatusDialog.java

    r25312 r25591  
    5858 * related actions: close bug report, invalidate bug report and re-open bug
    5959 * report.
    60  * 
     60 *
    6161 * @author Bea
    6262 */
    6363public class ChangeIssueStatusDialog extends AbstractDialog {
    64    
     64
    6565    /** The serial version UID */
    66     private static final long serialVersionUID = 1L;
    67    
     66    private static final long serialVersionUID = -4106150600118847229L;
     67
    6868    /** The message test */
    6969    private final String messageText;
    70    
     70
    7171    /** Custom text */
    7272    private JScrollPane cmpMessage;
    73    
     73
    7474    /** Nickname label */
    7575    private JLabel lblNickname;
    76    
     76
    7777    /** Nickname text field */
    7878    private JTextField txtNickname;
    79    
     79
    8080    /** Comment label */
    8181    private JLabel lblComment;
    82    
     82
    8383    /** Description text area */
    8484    private JScrollPane cmpDescription;
    85    
     85
    8686    /** The description text */
    8787    private JTextArea txtDescription;
    88    
     88
    8989    /** Cancel button */
    9090    private JButton btnCancel;
    91    
     91
    9292    /** OK button */
    9393    private JButton btnOk;
    94    
     94
    9595    /** The type */
    9696    private final String type;
    97    
     97
    9898    /**
    9999     * Builds a new <code>ChangeStatusDialog</code> object with the given
    100100     * parameters.
    101      * 
     101     *
    102102     * @param title The title of the dialog
    103103     * @param iconName The name of the icon
     
    126126        setLayout(null);
    127127        addComponents(mapdustPlugin);
    128         MapdustButtonPanel btnPanel = mapdustPlugin.getMapdustGUI().getPanel().getBtnPanel();
    129         addWindowListener(new WindowClose(this, btnPanel, getFiredButton()));
    130     }
    131    
    132     /**
    133      * Adds the components to the panel.
    134      *
     128        MapdustButtonPanel btnPanel =
     129                mapdustPlugin.getMapdustGUI().getPanel().getBtnPanel();
     130        addWindowListener(new WindowClose(this, btnPanel));
     131    }
     132
     133    /**
     134     * Adds the components to the dialog window.
     135     *
    135136     * @param mapdustPlugin The <code>MapdustPlugin</code> object
    136137     */
     
    142143        /* create the message cmp */
    143144        if (cmpMessage == null) {
    144             JTextPane txtPane = ComponentUtil.createJTextPane(messageText, 
     145            JTextPane txtPane = ComponentUtil.createJTextPane(messageText,
    145146                    backgroundColor);
    146147            Rectangle bounds = new Rectangle(10, 10, 330, 50);
     
    176177            txtDescription.setLineWrap(true);
    177178            txtDescription.setFont(new Font("Times New Roman", Font.PLAIN, 12));
    178             cmpDescription = ComponentUtil.createJScrollPane(txtDescription, 
     179            cmpDescription = ComponentUtil.createJScrollPane(txtDescription,
    179180                    bounds, backgroundColor, false, true);
    180181        }
    181182        /* creates the cancel action */
    182         ExecuteCancel cancelAction = new ExecuteCancel(this, 
     183        ExecuteCancel cancelAction = new ExecuteCancel(this,
    183184                mapdustPlugin.getMapdustGUI());
    184185        AbstractAction okAction;
     
    191192            if (type.equals("invalidate")) {
    192193                /* create the invalidate bug action */
    193                 okAction = new ExecuteInvalidateBug(this, mapdustPlugin.getMapdustGUI());
     194                okAction = new ExecuteInvalidateBug(this,
     195                        mapdustPlugin.getMapdustGUI());
    194196                ((ExecuteInvalidateBug) okAction).addObserver(mapdustPlugin);
    195197                ((ExecuteInvalidateBug) okAction).addObserver(mapdustPlugin
     
    197199            } else {
    198200                /* executes the re-open bug action */
    199                 okAction = new ExecuteReOpenBug(this, mapdustPlugin.getMapdustGUI());
     201                okAction = new ExecuteReOpenBug(this,mapdustPlugin.getMapdustGUI());
    200202                ((ExecuteReOpenBug) okAction).addObserver(mapdustPlugin);
    201                 ((ExecuteReOpenBug) okAction).addObserver(mapdustPlugin.getMapdustGUI());
     203                ((ExecuteReOpenBug) okAction).addObserver(mapdustPlugin
     204                        .getMapdustGUI());
    202205            }
    203206        }
     
    205208        if (btnCancel == null) {
    206209            Rectangle bounds = new Rectangle(240, 170, 90, 25);
    207             btnCancel = ComponentUtil.createJButton("Cancel", bounds, cancelAction);
     210            btnCancel = ComponentUtil.createJButton("Cancel", bounds,
     211                    cancelAction);
    208212        }
    209213        /* creates the ok button */
     
    222226        setSize(340, 210);
    223227    }
    224    
     228
    225229    /**
    226230     * Returns the <code>JScrollPane</code> of the info message.
    227      * 
     231     *
    228232     * @return the cmpMessage
    229233     */
     
    231235        return this.cmpMessage;
    232236    }
    233    
     237
    234238    /**
    235239     * Returns the <code>JLabel</code> of the nickname
    236      * 
     240     *
    237241     * @return the lblNickname
    238242     */
     
    240244        return this.lblNickname;
    241245    }
    242    
     246
    243247    /**
    244248     * Returns the <code>JTextField</code> of the nickname
    245      * 
     249     *
    246250     * @return the txtNickname
    247251     */
     
    249253        return this.txtNickname;
    250254    }
    251    
     255
    252256    /**
    253257     * Returns the <code>JLabel</code> of the comment
    254      * 
     258     *
    255259     * @return the lblComment
    256260     */
     
    258262        return this.lblComment;
    259263    }
    260    
     264
    261265    /**
    262266     * Returns the <code>JScrollPane</code> of the description
    263      * 
     267     *
    264268     * @return the cmpDescription
    265269     */
     
    267271        return this.cmpDescription;
    268272    }
    269    
     273
    270274    /**
    271275     * Returns the <code>JTextArea</code> of the description
    272      * 
     276     *
    273277     * @return the txtDescription
    274278     */
     
    276280        return this.txtDescription;
    277281    }
    278    
     282
    279283    /**
    280284     * Returns the cancel button
    281      * 
     285     *
    282286     * @return the btnCancel
    283287     */
     
    285289        return this.btnCancel;
    286290    }
    287    
     291
    288292    /**
    289293     * Returns the ok buttons
    290      * 
     294     *
    291295     * @return the btnOk
    292296     */
     
    294298        return this.btnOk;
    295299    }
    296    
     300
    297301    /**
    298302     * Retruns the message text
    299      * 
     303     *
    300304     * @return the messageText
    301305     */
     
    303307        return this.messageText;
    304308    }
    305    
    306     /**
    307      * Returns the type
    308      * 
     309
     310    /**
     311     * Returns the type of the dialog window
     312     *
    309313     * @return the type
    310314     */
     
    312316        return this.type;
    313317    }
    314    
     318
    315319}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/dialog/CommentIssueDialog.java

    r25312 r25591  
    6161
    6262    /** The serial version UID */
    63     private static final long serialVersionUID = 1L;
     63    private static final long serialVersionUID = 7788698281871951326L;
    6464
    6565    /** The message text */
     
    118118        setLayout(null);
    119119        addComponents(mapdustPlugin);
    120         MapdustButtonPanel btnPanel = mapdustPlugin.getMapdustGUI().getPanel().getBtnPanel();
    121         addWindowListener(new WindowClose(this, btnPanel, getFiredButton()));
    122     }
    123 
    124     /**
    125      * Add the components to the panel
     120        MapdustButtonPanel btnPanel =
     121                mapdustPlugin.getMapdustGUI().getPanel().getBtnPanel();
     122        addWindowListener(new WindowClose(this, btnPanel));
     123    }
     124
     125    /**
     126     * Add the components to the dialog window.
     127     *
     128     * @param mapdustPlugin The <code>MapdustPlugin</code> object
    126129     */
    127130    @Override
    128131    public void addComponents(MapdustPlugin mapdustPlugin) {
    129         /* initialize components of the JDialog */
    130132        Color backgroundColor = getContentPane().getBackground();
    131133        Font font = new Font("Times New Roman", Font.BOLD, 14);
    132         /* create the message cmp */
     134        /* message text */
    133135        if (cmpMessage == null) {
    134136            JTextPane txtPane = ComponentUtil.createJTextPane(messageText,
     
    138140                    backgroundColor, true, true);
    139141        }
    140         /* create the nickname label and text field */
     142        /* nickaname */
    141143        if (lblNickname == null) {
    142144            Rectangle bounds = new Rectangle(10, 70, 91, 25);
     
    156158            }
    157159        }
    158         /* creates the comment label and text area */
     160        /* comment */
    159161        if (lblComment == null) {
    160162            Rectangle bounds = new Rectangle(10, 110, 79, 25);
     
    169171                    backgroundColor, false, true);
    170172        }
    171         /* creates the cancel button */
     173        /* cancel button */
    172174        if (btnCancel == null) {
    173175            Rectangle bounds = new Rectangle(240, 170, 90, 25);
    174176            ExecuteCancel cancelAction = new ExecuteCancel(this,
    175177                    mapdustPlugin.getMapdustGUI());
    176             btnCancel = ComponentUtil.createJButton("Cancel", bounds, cancelAction);
    177         }
    178         /* creates the ok button */
     178            btnCancel = ComponentUtil.createJButton("Cancel", bounds,
     179                    cancelAction);
     180        }
     181        /* ok button */
    179182        if (btnOk == null) {
    180183            Rectangle bounds = new Rectangle(170, 170, 60, 25);
     
    185188            btnOk = ComponentUtil.createJButton("OK", bounds, okAction);
    186189        }
    187         /* add components to the frame */
     190        /* add components */
    188191        add(cmpMessage);
    189192        add(lblNickname);
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/dialog/CreateIssueDialog.java

    r25312 r25591  
    5454
    5555/**
    56  * This class is used for creating a dialog window for the new issue Mapdust Bug
     56 * This class is used for creating a dialog window for the new issue MapDust Bug
    5757 * action.
    5858 *
     
    6363
    6464    /** The serial version UID */
    65     private static final long serialVersionUID = 1L;
     65    private static final long serialVersionUID = 1912577313684808253L;
    6666
    6767    /** The create issue text */
     
    7171    private JScrollPane cmpMessage;
    7272
    73     /** Type */
     73    /** The label of the bug type */
    7474    private JLabel lblType;
    7575
    76     /** The type combo box */
     76    /** The combo box for the bug types */
    7777    private JComboBox cbbType;
    7878
    79     /** Nickname */
     79    /** The nickname label */
    8080    private JLabel lblNickname;
    8181
    82     /** The txt nickname */
     82    /** The nickname text field */
    8383    private JTextField txtNickname;
    8484
    85     /** Description */
     85    /** The description label */
    8686    private JLabel lblDescription;
    8787
     
    105105     * parameters.
    106106     *
    107      * @param title The title of the dialog
    108      * @param iconName The name of the icon
    109      * @param messageText The text of the message component.
    110107     * @param point The position where the bug was created
    111108     * @param mapdustPlugin The <code>MapdustPlugin</code> object
     
    120117        /* add components to the dialog */
    121118        addComponents(mapdustPlugin);
    122         /* add window listenet */
     119        /* add window listener */
    123120        MapdustButtonPanel btnPanel =
    124121                mapdustPlugin.getMapdustGUI().getPanel().getBtnPanel();
    125         addWindowListener(new WindowClose(this, btnPanel, null));
     122        addWindowListener(new WindowClose(this, btnPanel));
    126123    }
    127124
     
    144141
    145142    /**
    146      * Displays the dialog.
     143     * Displays the dialog window on the screen.
    147144     */
    148145    public void showDialog() {
     
    153150    }
    154151
     152    /**
     153     * Adds the components to the dialog window.
     154     *
     155     * @param mapdustPlugin The <code>MapdustPlugin</code> object
     156     */
    155157    @Override
    156158    public void addComponents(MapdustPlugin mapdustPlugin) {
    157159        Color backgroundColor = getContentPane().getBackground();
    158160        Font font = new Font("Times New Roman", Font.BOLD, 14);
    159         /* create the message cmp */
     161        /* text message */
    160162        if (cmpMessage == null) {
    161163            JTextPane txtPane = ComponentUtil.createJTextPane(createIssueText,
    162164                    backgroundColor);
    163             cmpMessage = ComponentUtil.createJScrollPane(txtPane,
    164                     new Rectangle(10,10, 330, 50), backgroundColor, true, true);
    165         }
    166         /* the type label and combo box */
     165            Rectangle bounds = new Rectangle(10, 10, 330, 50);
     166            cmpMessage = ComponentUtil.createJScrollPane(txtPane, bounds,
     167                    backgroundColor, true, true);
     168        }
     169        /* type */
    167170        if (lblType == null) {
    168             lblType = ComponentUtil.createJLabel("Type", font,
    169                     new Rectangle(10, 70, 91, 25));
     171            Rectangle bounds = new Rectangle(10, 70, 91, 25);
     172            lblType = ComponentUtil.createJLabel("Type", font, bounds);
    170173        }
    171174        if (cbbType == null) {
    172175            ComboBoxRenderer renderer = new ComboBoxRenderer();
    173             cbbType = ComponentUtil.createJComboBox(new Rectangle(110, 70, 230,
    174                     25), renderer, backgroundColor);
    175         }
    176         /* create the nickname label and text field */
     176            Rectangle bounds = new Rectangle(110, 70, 230, 25);
     177            cbbType = ComponentUtil.createJComboBox(bounds, renderer,
     178                    backgroundColor);
     179        }
     180        /* nickname */
    177181        if (lblNickname == null) {
    178             lblNickname = ComponentUtil.createJLabel("Nickname", font,
    179                     new Rectangle(10, 110, 79, 25));
     182            Rectangle bounds = new Rectangle(10, 110, 79, 25);
     183            lblNickname = ComponentUtil.createJLabel("Nickname", font, bounds);
    180184        }
    181185        if (txtNickname == null) {
    182             txtNickname = ComponentUtil.createJTextField(new Rectangle(110, 110,
    183                     230,25));
     186            Rectangle bounds = new Rectangle(110, 110, 230,25);
     187            txtNickname = ComponentUtil.createJTextField(bounds);
    184188            /* get the nickname */
    185189            String nickname = Main.pref.get("mapdust.nickname");
     
    192196            }
    193197        }
    194         /* creates the description label and text area */
     198        /* description */
    195199        if (lblDescription == null) {
     200            Rectangle bounds = new Rectangle(10, 150, 95, 25);
    196201            lblDescription = ComponentUtil.createJLabel("Description", font,
    197                     new Rectangle(10, 150, 95, 25));
     202                    bounds);
    198203        }
    199204        if (cmpDescription == null) {
     205            Rectangle bounds = new Rectangle(110, 150, 230, 50);
    200206            txtDescription = new JTextArea();
    201207            txtDescription.setFont(new Font("Times New Roman", Font.PLAIN, 12));
    202208            txtDescription.setLineWrap(true);
    203209            cmpDescription = ComponentUtil.createJScrollPane(txtDescription,
    204                     new Rectangle(110, 150, 230, 50), backgroundColor, false,
    205                     true);
    206         }
    207         /* creates the cancel button */
     210                    bounds, backgroundColor, false, true);
     211        }
     212        /* cancel button */
    208213        if (btnCancel == null) {
    209214            Rectangle bounds = new Rectangle(250, 210, 90, 25);
     
    213218                    cancelAction);
    214219        }
    215         /* creates the ok button */
     220        /* ok button */
    216221        if (btnOk == null) {
    217222            Rectangle bounds = new Rectangle(180, 210, 60, 25);
    218             ExecuteAddBug okAction = new ExecuteAddBug(this,
    219                     mapdustPlugin.getMapdustGUI());
     223            ExecuteAddBug okAction =
     224                    new ExecuteAddBug(this, mapdustPlugin.getMapdustGUI());
    220225            okAction.addObserver(mapdustPlugin);
    221226            okAction.addObserver(mapdustPlugin.getMapdustGUI());
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/dialog/package-info.java

    r24514 r25591  
    11/**
    2  * Contains the dialog classes.
     2 * Contains the MapDust GUI dialog classes. The dialog classes extends the
     3 * <code>AbstractDialog</code> abstract class.
    34 */
    45package org.openstreetmap.josm.plugins.mapdust.gui.component.dialog;
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/model/ActionListModel.java

    r24514 r25591  
    4343
    4444    /** The serial version UID */
    45     private static final long serialVersionUID = 1L;
     45    private static final long serialVersionUID = -4919264544683489112L;
    4646
    4747    /**
     
    5151
    5252    /**
    53      * Builds a <code>MapdustAction</code> object
     53     * Builds an empty <code>MapdustAction</code> object
    5454     */
    5555    public ActionListModel() {
     
    5858
    5959    /**
    60      * Builds a <code>MapdustAction</code> object
     60     * Builds a <code>MapdustAction</code> object based on the given argument
     61     *
    6162     * @param list A list of <code>MapdustAction</code> objects
    6263     */
     
    6566    }
    6667
     68    /**
     69     * Returns the <code>MapdustAction</code> from the given position.
     70     *
     71     * @param index The position of the element
     72     * @return <code>MapdustAction</code> from the given position
     73     */
    6774    @Override
    6875    public Object getElementAt(int index) {
    69         return list.get(index);
     76        if (index >= 0 && index < list.size()) {
     77            return list.get(index);
     78        }
     79        return null;
    7080    }
    7181
     82    /**
     83     * Returns the size of the list of objects.
     84     *
     85     * @return size
     86     */
    7287    @Override
    7388    public int getSize() {
    74         return list.size();
     89        return (list != null ? list.size() : 0);
    7590    }
    7691
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/model/BugsListModel.java

    r24514 r25591  
    3030
    3131import java.util.List;
    32 import javax.swing.ListModel;
    33 import javax.swing.event.ListDataListener;
     32import javax.swing.AbstractListModel;
    3433import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBug;
    3534
     
    4140 *
    4241 */
    43 public class BugsListModel implements ListModel {
     42public class BugsListModel extends AbstractListModel {
     43
     44    /** The serial version UID */
     45    private static final long serialVersionUID = 3451277352571392219L;
    4446
    4547    /** The list of <code>MapdustBug</code> objects */
     
    6264    }
    6365
    64     @Override
    65     public void addListDataListener(ListDataListener l) {}
    66 
     66    /**
     67     * Returns the <code>MapdustBug</code> from the given position.
     68     *
     69     * @param index The position of the element
     70     * @return <code>MapdustBug</code> from the given position
     71     */
    6772    @Override
    6873    public Object getElementAt(int index) {
    69         return bugs.get(index);
     74        if (index >= 0 && index < bugs.size()) {
     75            return bugs.get(index);
     76        }
     77        return null;
    7078    }
    7179
     80    /**
     81     * Returns the size of the list of objects.
     82     *
     83     * @return size
     84     */
    7285    @Override
    7386    public int getSize() {
     
    7588    }
    7689
    77     @Override
    78     public void removeListDataListener(ListDataListener l) {}
     90    /**
     91     * Updates the bugs list model.
     92     */
     93    public void update() {
     94        this.fireContentsChanged(this, 0, bugs.size() - 1);
     95    }
    7996
    8097}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/model/CommentListModel.java

    r24514 r25591  
    3535
    3636/**
    37  * List model for <code>MapdustComment</code> objects
     37 * List model for <code>MapdustComment</code> objects.
    3838 *
    3939 * @author Bea
     
    6161    }
    6262
    63     @Override
    64     public void addListDataListener(ListDataListener l) {}
    65 
     63    /**
     64     * Returns the <code>MapdustComment</code> from the given position.
     65     *
     66     * @param index The position of the element
     67     * @return <code>MapdustComment</code> from the given position
     68     */
    6669    @Override
    6770    public Object getElementAt(int index) {
    68         return comments[index];
     71        if (index > 0 && index < comments.length) {
     72            return comments[index];
     73        }
     74        return null;
    6975    }
    7076
     77    /**
     78     * Returns the size of the list of objects.
     79     *
     80     * @return size
     81     */
    7182    @Override
    7283    public int getSize() {
    73         return comments.length;
     84        return (comments != null ? comments.length : 0);
    7485    }
    7586
     
    7788    public void removeListDataListener(ListDataListener l) {}
    7889
     90    @Override
     91    public void addListDataListener(ListDataListener l) {}
     92
    7993}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/model/TypesListModel.java

    r24514 r25591  
    4343
    4444    /** The serial version UID */
    45     private static final long serialVersionUID = 1L;
     45    private static final long serialVersionUID = 4005728061902494996L;
    4646
    4747    /** The array of types */
     
    5858    }
    5959
     60    /**
     61     * Returns the <code>Type</code> from the given position.
     62     *
     63     * @param index The position of the element
     64     * @return <code>Type</code> from the given position
     65     */
    6066    @Override
    6167    public Object getElementAt(int index) {
     
    6369    }
    6470
     71    /**
     72     * Returns the size of the list of objects.
     73     *
     74     * @return size
     75     */
    6576    @Override
    6677    public int getSize() {
     
    6879    }
    6980
     81    /**
     82     * Returns the selected <code>Type</code> object.
     83     *
     84     * @return selected item
     85     */
    7086    @Override
    7187    public Object getSelectedItem() {
     
    7389    }
    7490
     91    /**
     92     * Sets the selected <code>Type</code> object.
     93     *
     94     * @param anItem The selected item
     95     */
    7596    @Override
    7697    public void setSelectedItem(Object anItem) {
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/model/package-info.java

    r24514 r25591  
    1 
     1/**
     2 * Contains the <code>ListModel</code> classes used for building customized
     3 * list and combo box GUI elements for the MapDust plugin.
     4 */
    25package org.openstreetmap.josm.plugins.mapdust.gui.component.model;
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustActionPanel.java

    r24514 r25591  
    3939import org.openstreetmap.josm.plugins.mapdust.MapdustPlugin;
    4040import org.openstreetmap.josm.plugins.mapdust.gui.action.execute.ExecuteActionList;
     41import org.openstreetmap.josm.plugins.mapdust.gui.component.model.ActionListModel;
    4142import org.openstreetmap.josm.plugins.mapdust.gui.component.util.ComponentUtil;
    4243import org.openstreetmap.josm.plugins.mapdust.gui.value.MapdustAction;
     
    5253
    5354    /** The serial version UID */
    54     private static final long serialVersionUID = 1L;
     55    private static final long serialVersionUID = -6648507056357610823L;
    5556
    5657    /** The scroll pane */
     
    5859
    5960    /** The JList containing the MapDust action objects */
    60     private JList queueList;
     61    private JList actionJList;
    6162
    6263    /** The list of <code>MapdustAction</code> objects */
    63     private final List<MapdustAction> actionList;
     64    private List<MapdustAction> actionList;
    6465
    6566    /**
     
    8889            MapdustPlugin mapdustPlugin) {
    8990        /* create components */
    90         AbstractAction action = new ExecuteActionList(mapdustPlugin.getMapdustGUI());
     91        AbstractAction action = new ExecuteActionList
     92        (mapdustPlugin.getMapdustGUI());
    9193        JToggleButton btnUpload = ComponentUtil.createJButton("Upload list data",
    9294                null, null, action);
    9395        ((ExecuteActionList) action).addObserver(mapdustPlugin);
    9496        if (cmpActionList == null) {
    95             queueList = ComponentUtil.createJList(list);
    96             cmpActionList = ComponentUtil.createJScrollPane(queueList);
     97            actionJList = ComponentUtil.createJList(list);
     98            cmpActionList = ComponentUtil.createJScrollPane(actionJList);
    9799        }
    98100        add(cmpActionList, BorderLayout.CENTER);
     
    101103
    102104    /**
    103      * Returns the list of <code>MapdustAction</code> object
     105     * Updates the <code>MapdustActionPanel</code> with the given list of
     106     * <code>MapdustAction</code>s.
     107     *
     108     * @param actionList The list of <code>MapdustAction</code> objects
     109     */
     110    public void updateComponents(List<MapdustAction> actionList) {
     111        setActionList(actionList);
     112        actionJList.setModel(new ActionListModel(actionList));
     113        cmpActionList.getViewport().setView(actionJList);
     114        cmpActionList.invalidate();
     115
     116    }
     117
     118    /**
     119     * Returns the list of <code>MapdustAction</code>s
    104120     *
    105121     * @return the actionList
     
    110126
    111127    /**
    112      * Returns the action list <code>JScrollPane</code> object
     128     * Sets the list of <code>MapdustAction</code>s
    113129     *
    114      * @return the cmpActionList
     130     * @param actionList the actionList to set
    115131     */
    116     public JScrollPane getCmpActionList() {
    117         return cmpActionList;
    118     }
    119 
    120     /**
    121      * Returns the action list <code>JList</code> object
    122      *
    123      * @return the queueList
    124      */
    125     public JList getQueueList() {
    126         return queueList;
     132    public void setActionList(List<MapdustAction> actionList) {
     133        this.actionList = actionList;
    127134    }
    128135
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustAddressPanel.java

    r24514 r25591  
    4848
    4949    /** The serial version UID */
    50     private static final long serialVersionUID = 1L;
     50    private static final long serialVersionUID = 8388870946800544374L;
    5151
    5252    /**
     
    6363
    6464    /**
     65     * Updates the components of the <code>MapdustAddressPanel</code> based
     66     * on the given parameters.
     67     *
     68     * @param address The <code>Address</code> of a MapDust bug
     69     * @param coordinates The <code>LatLon</code> of a MapDust bug
     70     */
     71    public void updateComponents(Address address,LatLon coordinates){
     72        removeAll();
     73        addComponents(address, coordinates);
     74    }
     75
     76    /**
    6577     * Creates the components of the panel, and adds to the parent panel.
    6678     *
     
    7385        Font fontLabelVal = new Font("Times New Roman", Font.PLAIN, 12);
    7486
    75         /* add country */
     87        /* country */
    7688        add(ComponentUtil.createJLabel("Country: ", fontLabel, null));
    7789        String country = address != null ? address.getCountryCode() : "";
    7890        add(ComponentUtil.createJLabel(country, fontLabelVal, null));
    7991
    80         /* add label */
     92        /* label */
    8193        add(ComponentUtil.createJLabel("City: ", fontLabel, null));
    8294        String city = address != null ? address.getCity() : "";
    8395        add(ComponentUtil.createJLabel(city, fontLabelVal, null));
    8496
    85         /* add statecode */
     97        /* statecode */
    8698        add(ComponentUtil.createJLabel("State code: ", fontLabel, null));
    8799        String state = address != null ? address.getStateCode() : "";
    88100        add(ComponentUtil.createJLabel(state, fontLabelVal, null));
    89101
    90         /* add label */
     102        /* label */
    91103        add(ComponentUtil.createJLabel("Zip code: ", fontLabel, null));
    92104        String zip = address != null ? address.getZipCode() : "";
    93105        add(ComponentUtil.createJLabel(zip, fontLabelVal, null));
    94106
    95         /* add street name */
     107        /* street name */
    96108        add(ComponentUtil.createJLabel("Street: ", fontLabel, null));
    97109        String street = address != null ? address.getStreetName() : "";
    98110        add(ComponentUtil.createJLabel(street, fontLabelVal, null));
    99111
    100         /* add house number */
     112        /* house number */
    101113        add(ComponentUtil.createJLabel("House number: ", fontLabel, null));
    102114        String houseNr = address != null ? address.getHouseNumber() : "";
    103115        add(ComponentUtil.createJLabel(houseNr, fontLabelVal, null));
    104116
    105         /* add lat */
     117        /* lat */
    106118        add(ComponentUtil.createJLabel("Latitude: ", fontLabel, null));
    107119        String lat = coordinates != null ? ("" + coordinates.lat()) : "";
    108120        add(ComponentUtil.createJLabel(lat, fontLabelVal, null));
    109121
    110         /* add lon */
     122        /* lon */
    111123        add(ComponentUtil.createJLabel("Longitude: ", fontLabel, null));
    112124        String lon = coordinates != null ? ("" + coordinates.lon()) : "";
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustBugDetailsPanel.java

    r24733 r25591  
    5858
    5959    /** The serial version UID */
    60     private static final long serialVersionUID = 1L;
     60    private static final long serialVersionUID = 65974543949362926L;
    6161
    6262    /** The <code>MapdustBug</code> object */
    63     private final MapdustBug bug;
     63    private MapdustBug bug;
    6464
    6565    /**
     
    7676
    7777    /**
     78     * Updates the components of the <code>MapdustBugDetailsPanel</code> based
     79     * on the given parameter.
     80     *
     81     * @param bug The <code>MapdustBug</code>
     82     */
     83    public void updateComponents(MapdustBug bug) {
     84        this.bug = bug;
     85        removeAll();
     86        addComponents();
     87    }
     88
     89    /**
    7890     * Add the components to the panel.
    7991     */
     
    8193        /* the font of the label and label value */
    8294        Font fontLabel = new Font("Times New Roman", Font.BOLD, 12);
    83         Font fontLabelVal = new Font("Times New Roman", Font.PLAIN,12);
     95        Font fontLabelVal = new Font("Times New Roman", Font.PLAIN, 12);
    8496        /* date formatter */
    85         DateFormat df = DateFormat.getDateInstance( DateFormat.DEFAULT,
     97        DateFormat df = DateFormat.getDateInstance(DateFormat.DEFAULT,
    8698                Locale.getDefault());
    8799
    88         /* add the id */
     100        /* the id */
    89101        add(ComponentUtil.createJLabel("Id: ", fontLabel, null));
    90102        String idStr = bug != null ? bug.getId().toString() : "";
     
    101113        add(txtId);
    102114
    103         /* add the type */
     115        /* the type */
    104116        add(ComponentUtil.createJLabel("Type: ", fontLabel, null));
    105117        String typeStr = bug != null ? bug.getType().getValue() : "";
    106118        add(ComponentUtil.createJLabel(typeStr, fontLabelVal, null));
    107119
    108         /* add the status */
     120        /* the status */
    109121        add(ComponentUtil.createJLabel("Status: ", fontLabel, null));
    110122        String statusStr = bug != null ? bug.getStatus().getValue() : "";
    111123        add(ComponentUtil.createJLabel(statusStr, fontLabelVal, null));
    112124
    113         /* add the source */
     125        /* the source */
    114126        add(ComponentUtil.createJLabel("Source: ", fontLabel, null));
    115127        String sourceStr = bug != null ? bug.getSource() : "";
    116128        add(ComponentUtil.createJLabel(sourceStr, fontLabelVal, null));
    117129
    118         /* add the nickname */
     130        /* the nickname */
    119131        add(ComponentUtil.createJLabel("Created by: ", fontLabel, null));
    120132        String nicknameStr = bug != null ? bug.getNickname() : "";
    121133        add(ComponentUtil.createJLabel(nicknameStr, fontLabelVal, null));
    122134
    123         /* add the date created */
     135        /* the date created */
    124136        add(ComponentUtil.createJLabel("Date created: ", fontLabel, null));
    125137        String dateCreatedStr =
     
    127139        add(ComponentUtil.createJLabel(dateCreatedStr, fontLabelVal, null));
    128140
    129         /* add the date updated */
     141        /* the date updated */
    130142        add(ComponentUtil.createJLabel("Date updated: ", fontLabel, null));
    131143        String dateUpdatedStr =
    132144                bug != null ? df.format(bug.getDateUpdated()) : "";
    133145        add(ComponentUtil.createJLabel(dateUpdatedStr, fontLabelVal, null));
    134 
    135146    }
    136147
     
    141152            if (bug != null) {
    142153                String mapdustSite =
    143                         Configuration.getInstance().getMapdustBugDetailsUrl();
     154                    Configuration.getInstance().getMapdustBugDetailsUrl();
    144155                bugDetailsUrl = mapdustSite + bug.getId().toString();
    145156            }
     
    150161                    String errorMessage = "Error opening the MapDust bug ";
    151162                    errorMessage += "details page";
    152                     JOptionPane.showMessageDialog(Main.parent,
    153                             tr(errorMessage), tr("Error"),
    154                             JOptionPane.ERROR_MESSAGE);
     163                    JOptionPane.showMessageDialog(Main.parent, tr(errorMessage),
     164                            tr("Error"), JOptionPane.ERROR_MESSAGE);
    155165                }
    156166            }
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustBugPropertiesPanel.java

    r25127 r25591  
    4949/**
    5050 * Defines the JPanel for the <code>MapdustBug</code> object properties.
     51 * The MapDust bug properties panel displays detailed information about a
     52 * given <code>MapdustBug</code> and it is composed by the following panels:
     53 * <code>MapdustBugDetailsPanel</code>, <code>MapdustAddressPanel</code>,
     54 * <code>MapdustDescriptionPanel</code>, <code>MapdustCommentsPanel</code> and
     55 * <code>MapdustHelpPanel</code>.
    5156 *
    5257 * @author Bea
     
    5661
    5762    /** The serial version UID */
    58     private static final long serialVersionUID = 1L;
     63    private static final long serialVersionUID = 5320232823004570279L;
     64
     65    /** The <code>MapdustBugDetailsPanel</code> object */
     66    private MapdustBugDetailsPanel detailsPanel;
     67
     68    /** The <code>MapdustAddressPanel</code> object */
     69    private MapdustAddressPanel addressPanel;
     70
     71    /** The <code>MapdustDescriptionPanel</code> object */
     72    private MapdustDescriptionPanel descriptionPanel;
    5973
    6074    /** The <code>MapdustCommentsPanel</code> object */
    6175    private MapdustCommentsPanel commentsPanel;
    6276
    63     /** The <code>MapdustBugDetailsPanel</code> object */
    64     private MapdustBugDetailsPanel detailsPanel;
    65 
    66     /** The <code>MapdustAddressPanel</code> object */
    67     private MapdustAddressPanel addressPanel;
    68 
    69     /** The <code>MapdustDescriptionPanel</code> object */
    70     private MapdustDescriptionPanel descriptionPanel;
    71 
    7277    /** The <code>MapdustHelpPanel</code> object */
    7378    private MapdustHelpPanel helpPanel;
     
    8388
    8489    /**
    85      * Builds a <code>MapdustBugPropertiesPanel</code> object.
     90     * Builds a <code>MapdustBugPropertiesPanel</code> object based on the given
     91     * argument.
    8692     *
    8793     * @param mapdustBug The <code>MapdustBug</code> object
     
    96102    /**
    97103     * Displays the details of the given MapDust bug.
    98      * 
     104     *
    99105     * @param mapdustBug The <code>MapdustBug</code> object
    100106     */
     
    112118        if (mainPanel != null) {
    113119            index = mainPanel.getSelectedIndex();
    114             if (mainPanel.getComponentCount() > 0) {
    115                 mainPanel.remove(cmpDetails);
    116                 mainPanel.remove(cmpAddress);
    117                 mainPanel.remove(descriptionPanel);
    118                 mainPanel.remove(commentsPanel);
    119                 mainPanel.remove(helpPanel);
    120             }
    121             remove(mainPanel);
    122         }
     120        }
     121
    123122        /* create the panels */
    124123        createPanels(selectedBug);
     
    134133     */
    135134    private void addComponents(MapdustBug mapdustBug) {
    136         MapdustBug selectedBug=mapdustBug;
     135        MapdustBug selectedBug = mapdustBug;
    137136        if (mapdustBug != null) {
    138137            if (mapdustBug.getNumberOfComments() > 0) {
     
    140139                selectedBug = getBug(id);
    141140            }
    142             createPanels(selectedBug);
    143         }
     141        }
     142        createPanels(selectedBug);
    144143    }
    145144
     
    150149     */
    151150    private void createPanels(MapdustBug mapdustBug) {
    152         /* create details panel */
    153         detailsPanel = new MapdustBugDetailsPanel(mapdustBug);
    154         cmpDetails = ComponentUtil.createJScrollPane(detailsPanel, getBounds(),
    155                 getBackground(), true, true);
    156         cmpDetails.setPreferredSize(new Dimension(100, 100));
    157         cmpDetails.setName("Bug Details");
    158 
    159         /* create address panel */
     151        /* details panel */
     152        if (cmpDetails == null) {
     153            detailsPanel = new MapdustBugDetailsPanel(mapdustBug);
     154            cmpDetails = ComponentUtil.createJScrollPane(detailsPanel,
     155                    getBounds(), getBackground(), true, true);
     156            cmpDetails.setPreferredSize(new Dimension(100, 100));
     157            cmpDetails.setName("Bug Details");
     158        } else {
     159            detailsPanel.updateComponents(mapdustBug);
     160        }
     161
     162        /* address panel */
    160163        Address address = mapdustBug != null ? mapdustBug.getAddress() : null;
    161164        LatLon coordinates = mapdustBug != null ? mapdustBug.getLatLon() : null;
    162         addressPanel = new MapdustAddressPanel(address, coordinates);
    163         cmpAddress = ComponentUtil.createJScrollPane(addressPanel, getBounds(),
    164                 getBackground(), true, true);
    165         cmpAddress.setName("Address");
    166         cmpAddress.setPreferredSize(new Dimension(100, 100));
    167 
    168         /* create description panel */
     165        if (cmpAddress == null) {
     166            addressPanel = new MapdustAddressPanel(address, coordinates);
     167            cmpAddress = ComponentUtil.createJScrollPane(addressPanel,
     168                    getBounds(), getBackground(), true, true);
     169            cmpAddress.setName("Address");
     170            cmpAddress.setPreferredSize(new Dimension(100, 100));
     171        } else {
     172            addressPanel.updateComponents(address, coordinates);
     173        }
     174
     175        /* description panel */
    169176        String description = mapdustBug != null ? mapdustBug.getDescription() : "";
    170         descriptionPanel = new MapdustDescriptionPanel(description);
    171 
    172         /* create comments panel */
     177        if (descriptionPanel == null) {
     178            descriptionPanel = new MapdustDescriptionPanel(description);
     179        } else {
     180            descriptionPanel.updateComponents(description);
     181        }
     182
     183        /* comments panel */
    173184        MapdustComment[] comments = mapdustBug != null ? mapdustBug.getComments()
    174185                : new MapdustComment[0];
    175         commentsPanel = new MapdustCommentsPanel(comments);
    176 
    177         /* create the help panel */
    178         helpPanel = new MapdustHelpPanel();
     186        if (commentsPanel == null) {
     187            commentsPanel = new MapdustCommentsPanel(comments);
     188        } else {
     189           commentsPanel.updateComponents(comments);
     190           mainPanel.setTitleAt(3, commentsPanel.getName());
     191        }
     192
     193        /* the help panel */
     194        if (helpPanel == null) {
     195            helpPanel = new MapdustHelpPanel();
     196        }
    179197
    180198        /* creates the main panel */
    181         mainPanel = new JTabbedPane();
    182         mainPanel.setIgnoreRepaint(true);
    183         mainPanel.add(cmpDetails, 0);
    184         mainPanel.add(cmpAddress, 1);
    185         mainPanel.add(descriptionPanel, 2);
    186         mainPanel.add(commentsPanel, 3);
    187         mainPanel.add(helpPanel);
    188         add(mainPanel, BorderLayout.CENTER);
     199        if (mainPanel == null) {
     200            mainPanel = new JTabbedPane();
     201            mainPanel.setIgnoreRepaint(true);
     202            mainPanel.add(cmpDetails, 0);
     203            mainPanel.add(cmpAddress, 1);
     204            mainPanel.add(descriptionPanel, 2);
     205            mainPanel.add(commentsPanel, 3);
     206            mainPanel.add(helpPanel);
     207            add(mainPanel, BorderLayout.CENTER);
     208        } else {
     209            mainPanel.revalidate();
     210        }
    189211    }
    190212
     
    201223        } catch (MapdustServiceHandlerException e) {
    202224            String errorMessage = "There was a MapDust service error durring ";
    203             errorMessage+=" the MapDust bug retrieve process.";
     225            errorMessage += " the MapDust bug retrieve process.";
    204226            JOptionPane.showMessageDialog(Main.parent, tr(errorMessage),
    205227                    tr("Error"), JOptionPane.ERROR_MESSAGE);
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustButtonPanel.java

    r24514 r25591  
    3939import org.openstreetmap.josm.plugins.mapdust.gui.action.show.ShowCloseBugAction;
    4040import org.openstreetmap.josm.plugins.mapdust.gui.action.show.ShowCommentBugAction;
     41import org.openstreetmap.josm.plugins.mapdust.gui.action.show.ShowFilterBugAction;
    4142import org.openstreetmap.josm.plugins.mapdust.gui.action.show.ShowInvalidateBugAction;
    4243import org.openstreetmap.josm.plugins.mapdust.gui.action.show.ShowReOpenBugAction;
     
    4647
    4748/**
    48  * Defines the panel of the Mapdust bug list action buttons.
     49 * Defines the panel of buttons for the MapDust bugs list.
    4950 *
    5051 * @author Bea
     
    5455
    5556    /** The serial version UID */
    56     private static final long serialVersionUID = 1L;
     57    private static final long serialVersionUID = -4234650664854226973L;
    5758
    5859    /** The work offline button */
    5960    private JToggleButton btnWorkOffline;
    6061
     62    /** The filter button */
     63    private JToggleButton btnFilter;
     64
     65    /** The add comment button */
     66    private JToggleButton btnAddComment;
     67
     68    /** The fix bug report button */
     69    private JToggleButton btnFixBugReport;
     70
     71    /** The invalidate bug report button */
     72    private JToggleButton btnInvalidateBugReport;
     73
     74    /** The re-open bug report button */
     75    private JToggleButton btnReOpenBugReport;
     76
    6177    /** The refresh button */
    6278    private JToggleButton btnRefresh;
    63 
    64     /** The add comment button */
    65     private JToggleButton btnAddComment;
    66 
    67     /** The fix bug report button */
    68     private JToggleButton btnFixBugReport;
    69 
    70     /** The invalidate bug report button */
    71     private JToggleButton btnInvalidateBugReport;
    72 
    73     /** The re-open bug report button */
    74     private JToggleButton btnReOpenBugReport;
    7579
    7680    /**
     
    9195
    9296    /**
    93      * Add the components to the button panel
     97     * Add the components to the button panel.
    9498     *
    9599     * @param mapdustPlugin The <code>MapdustPlugin</code> object
    96100     */
    97101    private void addComponents(MapdustPlugin mapdustPlugin) {
    98         /* create components */
    99102        /* 'Work offline' button */
    100103        if (btnWorkOffline == null) {
     
    109112                imagePath = "dialogs/online.png";
    110113            }
    111             AbstractAction action = new ExecuteWorkOffline(mapdustPlugin.getMapdustGUI());
     114            AbstractAction action =
     115                    new ExecuteWorkOffline(mapdustPlugin.getMapdustGUI());
    112116            ((ExecuteWorkOffline) action).addObserver(mapdustPlugin);
    113             btnWorkOffline = ComponentUtil.createJButton("Work offline",
    114                     tooltipText, imagePath, action);
     117            btnWorkOffline =
     118                    ComponentUtil.createJButton("Work offline", tooltipText,
     119                            imagePath, action);
     120            btnWorkOffline.setSelected(false);
     121            btnWorkOffline.setFocusTraversalKeysEnabled(false);
     122        }
     123        /* 'Filter' button */
     124        if (btnFilter == null) {
     125            AbstractAction action = new ShowFilterBugAction(mapdustPlugin);
     126            btnFilter =
     127                    ComponentUtil.createJButton("Filter bug reports",
     128                            "Filter bug reports",
     129                            "dialogs/mapdust_bug_filter.png", action);
     130            btnFilter.setEnabled(true);
     131            btnFilter.setFocusTraversalKeysEnabled(false);
     132        }
     133        /* 'Add Comment' button */
     134        if (btnAddComment == null) {
     135            AbstractAction action = new ShowCommentBugAction(mapdustPlugin);
     136            btnAddComment =
     137                    ComponentUtil
     138                            .createJButton("Comment bug report",
     139                                    "Comment bug report",
     140                                    "dialogs/comment.png", action);
     141            btnAddComment.setEnabled(false);
     142            btnAddComment.setFocusTraversalKeysEnabled(false);
     143        }
     144        /* 'Fix bug report' button */
     145        if (btnFixBugReport == null) {
     146            AbstractAction action = new ShowCloseBugAction(mapdustPlugin);
     147            btnFixBugReport =
     148                    ComponentUtil.createJButton("Close bug report",
     149                            "Close bug report", "dialogs/fixed.png", action);
     150            btnFixBugReport.setEnabled(false);
     151            btnFixBugReport.setFocusTraversalKeysEnabled(false);
     152        }
     153        /* 'Invalidate bug report' button */
     154        if (btnInvalidateBugReport == null) {
     155            AbstractAction action = new ShowInvalidateBugAction(mapdustPlugin);
     156            btnInvalidateBugReport =
     157                    ComponentUtil.createJButton("Invalidate bug report",
     158                            "Invalidate bug report", "dialogs/invalid.png",
     159                            action);
     160            btnInvalidateBugReport.setEnabled(false);
     161            btnInvalidateBugReport.setFocusTraversalKeysEnabled(false);
     162        }
     163        /* 'Re-open bug report' button */
     164        if (btnReOpenBugReport == null) {
     165            AbstractAction action = new ShowReOpenBugAction(mapdustPlugin);
     166            btnReOpenBugReport =
     167                    ComponentUtil.createJButton("Re-open bug report",
     168                            "Re-open bug report", "dialogs/reopen.png", action);
     169            btnReOpenBugReport.setEnabled(false);
     170            btnReOpenBugReport.setFocusTraversalKeysEnabled(false);
    115171        }
    116172        /* 'Refresh' button */
     
    119175            AbstractAction action = new ExecuteRefresh();
    120176            ((ExecuteRefresh) action).addObserver(mapdustPlugin);
    121             btnRefresh = ComponentUtil.createJButton("Refresh", "Refresh",
    122                     "dialogs/refresh.png", action);
     177            btnRefresh =
     178                    ComponentUtil.createJButton("Refresh", "Refresh",
     179                            "dialogs/mapdust_refresh.png", action);
    123180            if (pluginState.equals(MapdustPluginState.OFFLINE.getValue())) {
    124181                btnRefresh.setEnabled(false);
    125182            }
    126         }
    127         /* 'Add Comment' button */
    128         if (btnAddComment == null) {
    129             AbstractAction action = new ShowCommentBugAction(mapdustPlugin);
    130             btnAddComment = ComponentUtil.createJButton("Comment bug report",
    131                     "Comment bug report", "dialogs/comment.png", action);
    132             btnAddComment.setEnabled(false);
    133         }
    134         /* 'Fix bug report' button */
    135         if (btnFixBugReport == null) {
    136             AbstractAction action = new ShowCloseBugAction(mapdustPlugin);
    137             btnFixBugReport = ComponentUtil.createJButton("Close bug report",
    138                     "Close bug report", "dialogs/fixed.png", action);
    139             btnFixBugReport.setEnabled(false);
    140         }
    141         /* 'Invalidate bug report' button */
    142         if (btnInvalidateBugReport == null) {
    143             AbstractAction action = new ShowInvalidateBugAction(mapdustPlugin);
    144             btnInvalidateBugReport = ComponentUtil.createJButton("Invalidate bug report",
    145                     "Invalidate bug report", "dialogs/invalid.png", action);
    146             btnInvalidateBugReport.setEnabled(false);
    147         }
    148         /* 'Re-open bug report' button */
    149         if (btnReOpenBugReport == null) {
    150             AbstractAction action = new ShowReOpenBugAction(mapdustPlugin);
    151             btnReOpenBugReport = ComponentUtil.createJButton("Re-open bug report",
    152                     "Re-open bug report", "dialogs/reopen.png", action);
    153             btnReOpenBugReport.setEnabled(false);
     183            btnRefresh.setFocusTraversalKeysEnabled(false);
    154184        }
    155185
    156186        /* add components */
    157187        add(btnWorkOffline);
    158         add(btnRefresh);
     188        add(btnFilter);
    159189        add(btnAddComment);
    160190        add(btnFixBugReport);
    161191        add(btnInvalidateBugReport);
    162192        add(btnReOpenBugReport);
     193        add(btnRefresh);
     194    }
     195
     196    /**
     197     * Disables the buttons from the <code>MapdustButtonPanel</code>.
     198     */
     199    public void disableComponents() {
     200        if (btnWorkOffline != null) {
     201            btnWorkOffline.setEnabled(false);
     202            btnWorkOffline.setSelected(false);
     203            btnWorkOffline.setFocusable(false);
     204        }
     205        if (btnFilter != null) {
     206            btnFilter.setEnabled(false);
     207            btnFilter.setEnabled(false);
     208            btnFilter.setEnabled(false);
     209        }
     210        if (btnRefresh != null) {
     211            btnRefresh.setEnabled(false);
     212            btnRefresh.setSelected(false);
     213            btnRefresh.setFocusable(false);
     214        }
     215        if (btnAddComment != null) {
     216            btnAddComment.setEnabled(false);
     217            btnAddComment.setSelected(false);
     218            btnAddComment.setFocusable(false);
     219        }
     220        if (btnFixBugReport != null) {
     221            btnFixBugReport.setEnabled(false);
     222            btnFixBugReport.setSelected(false);
     223            btnFixBugReport.setFocusable(false);
     224        }
     225        if (btnInvalidateBugReport != null) {
     226            btnInvalidateBugReport.setEnabled(false);
     227            btnInvalidateBugReport.setEnabled(false);
     228            btnInvalidateBugReport.setEnabled(false);
     229        }
     230        if (btnReOpenBugReport != null) {
     231            btnReOpenBugReport.setEnabled(false);
     232            btnReOpenBugReport.setEnabled(false);
     233            btnReOpenBugReport.setEnabled(false);
     234        }
     235    }
     236
     237    /**
     238     * Enables the basic components from the <code>MapdustButtonPanel</code>.
     239     * Basic components are considered the following buttons: work offline,
     240     * filter bug report, and refresh.If the onlyBasic flag is true then the
     241     * other buttons will be disabled.
     242     *
     243     * @param onlyBasic If true then the not basic buttons will be disabled
     244     */
     245    public void enableBasicComponents(boolean onlyBasic) {
     246        btnWorkOffline.setEnabled(true);
     247        btnFilter.setEnabled(true);
     248        btnRefresh.setEnabled(true);
     249        if (onlyBasic) {
     250            btnAddComment.setEnabled(false);
     251            btnAddComment.setSelected(false);
     252            btnAddComment.setFocusable(false);
     253            btnFixBugReport.setEnabled(false);
     254            btnFixBugReport.setSelected(false);
     255            btnFixBugReport.setFocusable(false);
     256            btnInvalidateBugReport.setEnabled(false);
     257            btnInvalidateBugReport.setEnabled(false);
     258            btnInvalidateBugReport.setEnabled(false);
     259            btnReOpenBugReport.setEnabled(false);
     260            btnReOpenBugReport.setEnabled(false);
     261            btnReOpenBugReport.setEnabled(false);
     262
     263        }
    163264    }
    164265
     
    182283
    183284    /**
     285     * @return the btnFilter
     286     */
     287    public JToggleButton getBtnFilter() {
     288        return btnFilter;
     289    }
     290
     291    /**
    184292     * Returns the add comment button
    185293     *
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustCommentsPanel.java

    r25127 r25591  
    5252
    5353    /** The serial version UID */
    54     private static final long serialVersionUID = 1L;
     54    private static final long serialVersionUID = 5730420562553912697L;
    5555
    5656    /**
     
    6262    public MapdustCommentsPanel(MapdustComment[] comments) {
    6363        setLayout(new BorderLayout());
    64         String name = "Bug Comments (";
    65         name += comments.length + " )";
    66         setName(name);
     64        addComponents(comments);
     65    }
     66
     67    /**
     68     * Updates the components of the <code>MapdustCommentsPanel</code> based on
     69     * the given parameter.
     70     *
     71     * @param comments The array of <code>MapdustComment</code>s
     72     */
     73    public void updateComponents(MapdustComment[] comments) {
     74        removeAll();
    6775        addComponents(comments);
    6876    }
     
    7482     */
    7583    private void addComponents(MapdustComment[] comments) {
     84        String name = "Bug Comments (";
     85        name += comments.length + " )";
     86        setName(name);
    7687        JTextArea txt = new JTextArea();
    7788        txt.setAutoscrolls(true);
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustDescriptionPanel.java

    r24514 r25591  
    4949
    5050    /** The serial version UID */
    51     private static final long serialVersionUID = 1L;
     51    private static final long serialVersionUID = -4246874841836269643L;
    5252
    5353    /**
     
    6060        String name = "Description ";
    6161        setName(name);
     62        addComponents(description);
     63    }
     64
     65    /**
     66     * Updates the components of the <code>MapdustDescriptionPanel</code> based
     67     * on the given parameter
     68     *
     69     * @param description The description
     70     */
     71    public void updateComponents(String description) {
     72        removeAll();
     73        addComponents(description);
     74    }
     75
     76    /**
     77     * Adds the components to the <code>MapdustDescriptionPanel</code>.
     78     *
     79     * @param description the description
     80     */
     81    private void addComponents(String description) {
    6282        if (description != null && !description.isEmpty()) {
    6383            JTextArea txtDescription = new JTextArea(description);
     
    6585            txtDescription.setFont(new Font("Times New Roman", Font.BOLD, 12));
    6686            txtDescription.setEditable(false);
    67             JScrollPane cmpDescription = ComponentUtil.createJScrollPane(txtDescription,
    68                     null, Color.white, true, true);
     87            JScrollPane cmpDescription = ComponentUtil.createJScrollPane(
     88                    txtDescription, null, Color.white, true, true);
    6989            cmpDescription.setPreferredSize(new Dimension(100, 100));
    7090            add(cmpDescription, BorderLayout.CENTER);
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustHelpPanel.java

    r25312 r25591  
    5555
    5656    /** The serial version UID */
    57     private static final long serialVersionUID = 1L;
     57    private static final long serialVersionUID = 8366853437915060878L;
    5858
    5959    /**
     
    9494     * related to the MapDust plugin.
    9595     *
    96      * @return
     96     * @return a string containing the text which will be displayed on the Help
     97     * tab
    9798     */
    9899    private String buildText() {
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/package-info.java

    r24514 r25591  
    11/**
    2  * constains the panel classes
     2 * Contains the customized <code>JPanel</code> classes used for building
     3 * the MapDust plugin GUI.
    34 */
    45package org.openstreetmap.josm.plugins.mapdust.gui.component.panel;
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/renderer/ActionListCellRenderer.java

    r24514 r25591  
    4949
    5050    /** The serial version UID */
    51     private static final long serialVersionUID = 1L;
     51    private static final long serialVersionUID = 7552949107018269769L;
    5252
    5353    /**
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/renderer/BugListCellRenderer.java

    r25127 r25591  
    4949
    5050    /** The serial version UID */
    51     private static final long serialVersionUID = 1L;
     51    private static final long serialVersionUID = -5888587819204364046L;
    5252
    5353    /**
     
    7878            text += mapdustBug.getType().getValue();
    7979            if (mapdustBug.getAddress() != null) {
    80                 text += " (" + mapdustBug.getAddress().toString() + " )";
     80                String addressStr=mapdustBug.getAddress().toString();
     81                if (!addressStr.trim().isEmpty()) {
     82                    text += " (" + mapdustBug.getAddress().toString() + " )";
     83                }
    8184            }
    8285            DateFormat df = DateFormat.getDateInstance(DateFormat.DEFAULT,
     
    8689            label.setText(text);
    8790            label.setFont(new Font("Times New Roman", Font.BOLD, 12));
     91            label.setSize(200, 20);
    8892        }
    8993        if (value instanceof String){
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/util/ComponentUtil.java

    r24514 r25591  
    3838import javax.swing.Action;
    3939import javax.swing.JButton;
     40import javax.swing.JCheckBox;
    4041import javax.swing.JComboBox;
    4142import javax.swing.JLabel;
     
    4950import javax.swing.ListCellRenderer;
    5051import javax.swing.ListSelectionModel;
     52import javax.swing.SwingConstants;
    5153import javax.swing.border.LineBorder;
    5254import org.openstreetmap.josm.plugins.mapdust.gui.component.model.ActionListModel;
     
    7476     * @param font The font of the label
    7577     * @param bounds The bounds of the element
    76      * @return A <code>JLabel</code> label
     78     * @return A <code>JLabel</code> object
    7779     */
    7880    public static JLabel createJLabel(String text, Font font, Rectangle bounds) {
     
    8385        jLabel.setText(text);
    8486        jLabel.setFont(font);
     87        return jLabel;
     88    }
     89
     90    /**
     91     * Creates a <code>JLabel</code> object with the given properties.
     92     *
     93     * @param text The text of the label
     94     * @param iconName The name of the label icon
     95     * @param bounds The dimension of the label
     96     * @return A <code>JLabel</code> object
     97     */
     98    public static JLabel createJLabel(String text, String iconName,
     99            Rectangle bounds) {
     100        JLabel jLabel = new JLabel(text, ImageProvider.get(iconName),
     101                SwingConstants.LEFT);
     102        jLabel.setBounds(bounds);
     103        jLabel.setFont(new Font("Times New Roman", Font.BOLD, 12));
    85104        return jLabel;
    86105    }
     
    286305    }
    287306
     307    /**
     308     * Creates a new <code>JCheckBox</code> object with the given properties.
     309     *
     310     * @param bounds The dimension of the check box
     311     * @return A <code>JCheckBox</code> object
     312     */
     313    public static JCheckBox createJCheckBox(Rectangle bounds) {
     314        JCheckBox jCheckBox = new JCheckBox();
     315        jCheckBox.setBounds(bounds);
     316        return jCheckBox;
     317    }
     318
    288319}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/util/package-info.java

    r24514 r25591  
    1 
     1/**
     2 * Contains helper classes used for building the GUI.
     3 */
    24package org.openstreetmap.josm.plugins.mapdust.gui.component.util;
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/observer/MapdustBugDetailsObservable.java

    r24514 r25591  
    5555
    5656    /**
    57      * Notifies all the observers observing the given <code>MapdustAction</code>
    58      * object.
     57     * Notifies all the observers observing the details of the given
     58     * <code>MapdustBug</code> object.
    5959     *
    6060     * @param mapdustBug The <code>MapdustBug</code> object
    6161     */
    6262    public void notifyObservers(MapdustBug mapdustBug);
     63
    6364}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/observer/MapdustBugDetailsObserver.java

    r24514 r25591  
    4747     */
    4848    public void showDetails(MapdustBug mapdustBug);
     49
    4950}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/observer/MapdustBugObservable.java

    r24514 r25591  
    4444     * Adds a new observer to the list of observers.
    4545     *
    46      * @param observer The <code>MapdustBugObservable</code> object
     46     * @param observer The <code>MapdustBugObserver</code> object
    4747     */
    4848    public void addObserver(MapdustBugObserver observer);
     
    5151     * Removes the given observer from the list of observers.
    5252     *
    53      * @param observer The <code>MapdustBugObservable</code> object
     53     * @param observer The <code>MapdustBugObserver</code> object
    5454     */
    5555    public void removeObserver(MapdustBugObserver observer);
     
    6262     */
    6363    public void notifyObservers(MapdustBug mapdustBug);
     64
    6465}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/observer/MapdustBugObserver.java

    r24514 r25591  
    4646     */
    4747    public void changedData(MapdustBug mapdustBug);
     48
    4849}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/observer/package-info.java

    r24514 r25591  
    1 
     1/**
     2 * Contains the observer and observable interfaces.
     3 */
    24package org.openstreetmap.josm.plugins.mapdust.gui.observer;
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/package-info.java

    r24514 r25591  
    11/**
    2  * Contains the graphical user interface related part of the Mapdust plugin.
     2 * Contains the graphical user interface related classes of the MapDust plugin.
     3 * These classes are divided based on their type in the following four packages:
     4 * action, component, observer and value.
    35 */
    46package org.openstreetmap.josm.plugins.mapdust.gui;
    57
     8
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/value/MapdustPluginState.java

    r24514 r25591  
    3030
    3131/**
    32  * Enum representing the MapDust plugin state. The plugin can be in the
     32 * Enumeration representing the MapDust plugin state. The plugin can be in the
    3333 * following 2 states: online and offline.
    3434 *
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/value/MapdustServiceCommand.java

    r24514 r25591  
    3030
    3131/**
    32  * Enum representing the MapDust service "commands".
     32 * Enumeration representing the MapDust service "commands".
    3333 *
    3434 * @author Bea
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/value/package-info.java

    r24514 r25591  
    1 
     1/**
     2 * Contains helper classes used by GUI.
     3 */
    24package org.openstreetmap.josm.plugins.mapdust.gui.value;
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/package-info.java

    r24514 r25591  
    11/**
    2  * The Mapdust OSM Bug reported JOSM plugin classes.
    3  * 
     2 * Contains the JOSM MapDust Bug reporter plugin classes.
     3 *
    44 */
    55package org.openstreetmap.josm.plugins.mapdust;
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/MapdustServiceHandler.java

    r24514 r25591  
    3636import org.openstreetmap.josm.plugins.mapdust.service.connector.response.MapdustPostResponse;
    3737import org.openstreetmap.josm.plugins.mapdust.service.converter.MapdustConverter;
     38import org.openstreetmap.josm.plugins.mapdust.service.value.BoundingBox;
    3839import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBug;
     40import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBugFilter;
    3941import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustComment;
    4042import org.openstreetmap.josm.plugins.mapdust.service.value.Paging;
     
    7880     * a corresponding exception will be thrown.
    7981     *
    80      * @param minLon The minimum longitude. This parameter is required.
    81      * @param minLat The minimum latitude.This parameter is required.
    82      * @param maxLon The maximum longitude.This parameter is required.
    83      * @param maxLat The maximum latitude.This parameter is required.
     82     * @param bBox The bounding box where the bugs are searched.
     83     * @param filter The MapDust bug filter. The bugs can be filtered based on
     84     * the status, type and description. This parameter is not required.
    8485     * @return A list of <code>MapdustBug</code> objects.
    85      *
    8686     * @throws MapdustServiceHandlerException In the case of an error
    8787     */
    88     public List<MapdustBug> getBugs(Double minLon, Double minLat,
    89             Double maxLon, Double maxLat) throws MapdustServiceHandlerException {
     88    public List<MapdustBug> getBugs(BoundingBox bBox, MapdustBugFilter filter)
     89            throws MapdustServiceHandlerException {
    9090        MapdustGetBugsResponse getBugsResponse = null;
    9191        /* validates the coordinates */
    92         if (minLon == null || minLat == null || maxLon == null
    93                 || maxLat == null) {
     92        if (bBox.getMinLon() == null || bBox.getMinLat() == null
     93                || bBox.getMaxLon() == null || bBox.getMaxLat() == null) {
    9494            throw new MapdustServiceHandlerException("Invalid coordinates!");
    9595        }
    9696        /* executes the getBug MapDust method */
    9797        try {
    98             getBugsResponse = connector.getBugs(minLon, minLat, maxLon, maxLat);
     98            getBugsResponse = connector.getBugs(bBox, filter);
    9999        } catch (MapdustConnectorException e) {
    100100            throw new MapdustServiceHandlerException(e.getMessage(), e);
     
    152152            throw new MapdustServiceHandlerException(errorMessage);
    153153        }
    154         /* executes the addbug MapDust method */
     154        /* executes the addBug MapDust method */
    155155        try {
    156156            postResponse = connector.addBug(bug);
     
    181181        /* validates comment */
    182182        if (comment == null) {
    183             String errorMessage="Invalid comment. The comment cannot be null!";
     183            String errorMessage = "Invalid comment. The comment cannot be null!";
    184184            throw new MapdustServiceHandlerException(errorMessage);
    185185        }
     
    219219        /* validates comment */
    220220        if (comment == null) {
    221             String errorMessage="Invalid comment. The comment cannot be null!";
     221            String errorMessage =
     222                    "Invalid comment. The comment cannot be null!";
    222223            throw new MapdustServiceHandlerException(errorMessage);
    223224        }
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/MapdustServiceHandlerException.java

    r24514 r25591  
    3131/**
    3232 * Defines the exception type for <code>MapdustServiceHandler</code> object.
    33  * 
     33 *
    3434 * @author Bea
    3535 */
    3636public class MapdustServiceHandlerException extends Exception {
    37    
     37
    3838    /** The serial version UID */
    39     private static final long serialVersionUID = 1L;
    40    
     39    private static final long serialVersionUID = -2860059748215555626L;
     40
    4141    /**
    4242     * Builds an empty <code>MapdustServiceHandlerException</code> object.
     
    4545        super();
    4646    }
    47    
     47
    4848    /**
    4949     * Builds a <code>MapdustServiceHandlerException</code> object based on the
    5050     * given argument.
    51      * 
     51     *
    5252     * @param message The message of the exception.
    5353     */
     
    5555        super(message);
    5656    }
    57    
     57
    5858    /**
    5959     * Builds a <code>MapdustServiceHandlerException</code> object based on the
    6060     * given argument.
    61      * 
     61     *
    6262     * @param cause The cause of the exception.
    6363     */
     
    6565        super(cause);
    6666    }
    67    
     67
    6868    /**
    6969     * Builds a <code>MapdustServiceHandlerException</code> object based on the
    7070     * given arguments.
    71      * 
     71     *
    7272     * @param message The message of the exception.
    7373     * @param cause The cause of the exception.
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/MapdustConnector.java

    r24514 r25591  
    3333import java.net.URL;
    3434import java.util.HashMap;
     35import java.util.List;
    3536import java.util.Map;
     37import org.openstreetmap.josm.plugins.mapdust.service.connector.parser.MapdustParser;
     38import org.openstreetmap.josm.plugins.mapdust.service.connector.parser.MapdustParserException;
    3639import org.openstreetmap.josm.plugins.mapdust.service.connector.response.MapdustGetBugResponse;
    3740import org.openstreetmap.josm.plugins.mapdust.service.connector.response.MapdustGetBugsResponse;
    3841import org.openstreetmap.josm.plugins.mapdust.service.connector.response.MapdustPostResponse;
    39 import org.openstreetmap.josm.plugins.mapdust.service.parser.MapdustParser;
    40 import org.openstreetmap.josm.plugins.mapdust.service.parser.MapdustParserException;
     42import org.openstreetmap.josm.plugins.mapdust.service.value.BoundingBox;
    4143import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBug;
     44import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBugFilter;
    4245import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustComment;
    4346import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustResponseStatusCode;
     
    8588
    8689    /**
    87      * Searches for the OSM Mapdust bugs in the given bounding box. The method
    88      * executes the 'getBugs' Mapdust service method, parses the obtained
     90     * Searches for the OSM MapDust bugs in the given bounding box. The method
     91     * executes the 'getBugs' MapDust service method, parses the obtained
    8992     * response object and return a <code>MapdustGetBugsResponse</code> object
    9093     * containing the pagination information and the array of bugs. In the case
     
    9295     * will be thrown.
    9396     *
    94      * @param minLon The minimum longitude. This parameter is required.
    95      * @param minLat The minimum latitude.This parameter is required.
    96      * @param maxLon The maximum longitude.This parameter is required.
    97      * @param maxLat The maximum latitude.This parameter is required.
     97     * @param bBox The bounding box where the bugs are searched.
     98     * @param filter The MapDust bug filter. The bugs can be filtered based on
     99     * the status, type and description. This parameter is not required.
    98100     * @return A <code>MapdustGetBugsResponse</code> object, containing the
    99101     * pagination information and an array of <code>MapdustBugContent</code>
     
    101103     * @throws MapdustConnectorException In the case of an error.
    102104     */
    103     public MapdustGetBugsResponse getBugs(Double minLon, Double minLat,
    104             Double maxLon, Double maxLat) throws MapdustConnectorException {
     105    public MapdustGetBugsResponse getBugs(BoundingBox bBox,
     106            MapdustBugFilter filter) throws MapdustConnectorException {
    105107        /* execute GET method and get the response */
    106108        HttpResponse httpResponse = null;
    107109        try {
    108             httpResponse = executeGetBugs(minLon, minLat, maxLon, maxLat);
     110            httpResponse = executeGetBugs(bBox, filter);
    109111        } catch (MalformedURLException e) {
    110112            throw new MapdustConnectorException(e.getMessage(), e);
     
    114116            throw new MapdustConnectorException(e.getMessage(), e);
    115117        }
    116 
    117118        /* parse HttpResponse */
    118119        MapdustGetBugsResponse result = null;
     
    120121            /* verify status codes */
    121122            handleStatusCode(httpResponse);
    122             result =(MapdustGetBugsResponse) getParser().parseResponse(
     123            result = (MapdustGetBugsResponse) getParser().parseResponse(
    123124                            httpResponse.getContent(),
    124125                            MapdustGetBugsResponse.class);
     
    131132    }
    132133
     134
    133135    /**
    134136     * Returns the OSM bug with the given id. If the <code>Paging</code> object
    135137     * is set, then the comments of the bug will be paginated. The method
    136      * executes the 'getBug' Mapdust service method, parses the obtained
     138     * executes the 'getBug' MapDust service method, parses the obtained
    137139     * response object and return a <code>MapdustGetBugResponse</code> object.
    138140     * In the case if the response code is not 2
     
    156158            throw new MapdustConnectorException(e.getMessage(), e);
    157159        }
    158 
    159160        /* parse result */
    160161        MapdustGetBugResponse result = null;
    161162        try {
    162163            handleStatusCode(httpResponse);
    163             result =(MapdustGetBugResponse) parser.parseResponse(
    164                             httpResponse.getContent(),
    165                             MapdustGetBugResponse.class);
     164            result = (MapdustGetBugResponse) getParser().parseResponse(
     165                    httpResponse.getContent(), MapdustGetBugResponse.class);
    166166        } catch (MapdustConnectorException e) {
    167167            throw new MapdustConnectorException(e.getMessage(), e);
     
    174174    /**
    175175     * Creates a new OSM bug with the specified arguments. The method executes
    176      * the 'addBug' Mapdust service method, parses the obtained response object
     176     * the 'addBug' MapDust service method, parses the obtained response object
    177177     * and return a <code>MapdustPostResponse</code> object containing the id of
    178178     * the created comment. In the case if the response code is not 200,201 or
     
    202202        try {
    203203            handleStatusCode(httpResponse);
    204             result =(MapdustPostResponse) parser.parseResponse(
    205                             httpResponse.getContent(),
    206                             MapdustPostResponse.class);
     204            result = (MapdustPostResponse) getParser().parseResponse(
     205                    httpResponse.getContent(), MapdustPostResponse.class);
    207206        } catch (MapdustConnectorException e) {
    208207            throw new MapdustConnectorException(e.getMessage(), e);
     
    215214    /**
    216215     * Creates a new comment for the given bug. The method executes the
    217      * 'commentBug' Mapdust service method, parses the obtained response object
     216     * 'commentBug' MapDust service method, parses the obtained response object
    218217     * and return a <code>MapdustPostResponse</code> object containing the id of
    219218     * the created comment. In the case if the response code is not 200,201 or
     
    237236            throw new MapdustConnectorException(e.getMessage(), e);
    238237        }
    239 
    240238        /* parse result */
    241239        MapdustPostResponse result = null;
    242240        try {
    243241            handleStatusCode(httpResponse);
    244             result = (MapdustPostResponse) parser.parseResponse(
    245                             httpResponse.getContent(),
    246                             MapdustPostResponse.class);
     242            result = (MapdustPostResponse) getParser().parseResponse(
     243                    httpResponse.getContent(), MapdustPostResponse.class);
    247244        } catch (MapdustConnectorException e) {
    248245            throw new MapdustConnectorException(e.getMessage(), e);
     
    255252    /**
    256253     * Changes the status of a given bug. The method executes the
    257      * 'changeBugStatus' Mapdust service method, parses the obtained response
     254     * 'changeBugStatus' MapDust service method, parses the obtained response
    258255     * object and return a <code>MapdustPostResponse</code> object containing
    259256     * the id of the created comment. In the case if the response code is not
     
    283280        try {
    284281            handleStatusCode(httpResponse);
    285             result = (MapdustPostResponse) parser.parseResponse(
     282            result = (MapdustPostResponse) getParser().parseResponse(
    286283                    httpResponse.getContent(), MapdustPostResponse.class);
    287284        } catch (MapdustConnectorException e) {
     
    294291
    295292    /**
    296      * Executes the 'getBugs' Mapdust service method.
    297      *
    298      * @param minLon The minimum longitude. This parameter is required.
    299      * @param minLat The minimum latitude.This parameter is required.
    300      * @param maxLon The maximum longitude.This parameter is required.
    301      * @param maxLat The maximum latitude.This parameter is required.
    302      *
     293     * Executes the 'getBugs' MapDust service method.
     294     *
     295     * @param bBox The bounding box where the bugs are searched. This parameter
     296     * it is a required parameter.
     297     * @param filter The MapDust bug filter. The bugs can be filtered based on
     298     * the status, type and description. This parameter is not required.
    303299     * @return A <code>HttpResponse</code> object containing the JSON response.
    304300     * @throws MalformedURLException In the case if the format of the URL is
     
    306302     * @throws IOException In the case of an IO error
    307303     */
    308     private HttpResponse executeGetBugs(Double minLon, Double minLat,
    309             Double maxLon, Double maxLat) throws MalformedURLException,
    310             IOException {
     304    private HttpResponse executeGetBugs(BoundingBox bBox,
     305            MapdustBugFilter filter) throws MalformedURLException, IOException {
    311306        HttpResponse httpResponse = null;
    312307        String mapdustUri = Configuration.getInstance().getMapdustUrl();
     
    317312            urlString += "/getBugs?";
    318313            urlString += "key=" + mapdustApiKey;
    319             urlString += "&bbox=" + minLon + "," + minLat + ",";
    320             urlString += maxLon + "," + maxLat;
     314            urlString += "&bbox=" + bBox.getMinLon();
     315            urlString += "," + bBox.getMinLat();
     316            urlString += "," + bBox.getMaxLon();
     317            urlString += "," + bBox.getMaxLat();
     318            if (filter != null) {
     319                if (filter.getStatuses() != null
     320                        && filter.getStatuses().size() > 0) {
     321                    String paramStatus = buildParameter(filter.getStatuses());
     322                    if (!paramStatus.isEmpty()) {
     323                        urlString += "&fs=" + paramStatus;
     324                    }
     325                }
     326                if (filter.getTypes() != null && filter.getTypes().size() > 0) {
     327                    String paramTypes = buildParameter(filter.getTypes());
     328                    if (!paramTypes.isEmpty()) {
     329                        urlString += "&ft=" + paramTypes;
     330                    }
     331                }
     332                if (filter.getDescr() != null && filter.getDescr()) {
     333                    urlString += "&idd=" + "0";
     334                }
     335            }
    321336        }
    322337        URL url = null;
    323338        if (urlString != null) {
    324339            url = new URL(urlString);
    325             httpResponse = httpConnector.executeGET(url);
    326 
     340            httpResponse = getHttpConnector().executeGET(url);
    327341        }
    328342        return httpResponse;
     
    330344
    331345    /**
    332      * Executes the 'getBug' Mapdust service method.
     346     * Executes the 'getBug' MapDust service method.
    333347     *
    334348     * @param id The id of the object
     
    363377        if (urlString != null) {
    364378            url = new URL(urlString);
    365             httpResponse = httpConnector.executeGET(url);
    366 
     379            httpResponse = getHttpConnector().executeGET(url);
    367380        }
    368381        return httpResponse;
     
    370383
    371384    /**
    372      * Executes the 'addBug' Mapdust service method.
     385     * Executes the 'addBug' MapDust service method.
    373386     *
    374387     * @param bug A <code>MapdustBug</code> object
    375388     * @return A <code>HttpResponse</code> containing the JSON response of the
    376      * Mapdust method.
     389     * MapDust method.
    377390     *
    378391     * @throws MalformedURLException In the case if the format of the URL is
     
    391404            urlString += "/addBug";
    392405            requestParameters.put("key", mapdustApiKey);
    393             String coordinatesStr =
    394                     bug.getLatLon().getX() + "," + bug.getLatLon().getY();
     406            String coordinatesStr = "" + bug.getLatLon().getX();
     407            coordinatesStr += "," + bug.getLatLon().getY();
    395408            requestParameters.put("coordinates", coordinatesStr);
    396409            requestParameters.put("type", bug.getType().getKey());
     
    401414        if (urlString != null) {
    402415            url = new URL(urlString);
    403             httpResponse = httpConnector.executePOST(url, null,
     416            httpResponse = getHttpConnector().executePOST(url, null,
    404417                    requestParameters);
    405 
    406418        }
    407419        return httpResponse;
     
    409421
    410422    /**
    411      * Executes the 'commentBug' Mapdust service method.
     423     * Executes the 'commentBug' MapDust service method.
    412424     *
    413425     * @param comment The <code>MapdustComment</code> object
    414426     * @return A <code>HttpResponse</code> containing the JSON response of the
    415      * Mapdust method.
     427     * MapDust method.
    416428     * @throws MalformedURLException In the case if the format of the URL is
    417429     * invalid
     
    436448        if (urlString != null) {
    437449            url = new URL(urlString);
    438             httpResponse = httpConnector.executePOST(url, null,
     450            httpResponse = getHttpConnector().executePOST(url, null,
    439451                    requestParameters);
    440 
    441452        }
    442453        return httpResponse;
     
    444455
    445456    /**
    446      * Executes the 'changeBugStatus' Mapdust service method.
     457     * Executes the 'changeBugStatus' MapDust service method.
    447458     *
    448459     * @param statusId The id of the status.
    449460     * @param comment A <code>MapdustComment</code> object.
    450461     * @return A <code>HttpResponse</code> containing the JSON response of the
    451      * Mapdust method.
     462     * MapDust method.
    452463     *
    453464     * @throws MalformedURLException In the case if the format of the URL is
     
    474485        if (urlString != null) {
    475486            url = new URL(urlString);
    476             httpResponse = httpConnector.executePOST(url, null,
     487            httpResponse = getHttpConnector().executePOST(url, null,
    477488                    requestParameters);
    478 
    479489        }
    480490        return httpResponse;
     491    }
     492
     493    /**
     494     * Builds a string containing the elements of the given list. The elements
     495     * will be separated by a comma. If the list does not contains any element
     496     * the returned result will be an empty string.
     497     *
     498     * @param list The list of objects.
     499     * @return a string
     500     */
     501    private String buildParameter(List<? extends Object> list) {
     502        StringBuffer sb = new StringBuffer();
     503        for (Object obj : list) {
     504            if (obj != null) {
     505                sb.append(obj).append(",");
     506            }
     507        }
     508        return sb.substring(0, sb.length() - 1);
    481509    }
    482510
     
    508536            case 400:
    509537                errorMessage = statusMessage + " ";
    510                 errorMessage+= MapdustResponseStatusCode.Status400.getDescription();
     538                errorMessage += MapdustResponseStatusCode.Status400.getDescription();
    511539                throw new MapdustConnectorException(errorMessage);
    512540            case 401:
    513                 errorMessage = statusMessage+ " ";
    514                 errorMessage+= MapdustResponseStatusCode.Status401.getDescription();
     541                errorMessage = statusMessage + " ";
     542                errorMessage += MapdustResponseStatusCode.Status401.getDescription();
    515543                throw new MapdustConnectorException(errorMessage);
    516544            case 403:
    517                 errorMessage = statusMessage   + " ";
    518                 errorMessage+= MapdustResponseStatusCode.Status403
    519                                         .getDescription();
     545                errorMessage = statusMessage + " ";
     546                errorMessage += MapdustResponseStatusCode.Status403.getDescription();
    520547                throw new MapdustConnectorException(errorMessage);
    521548            case 404:
    522                 errorMessage = statusMessage+ " ";
    523                 errorMessage+=MapdustResponseStatusCode.Status404
    524                                         .getDescription();
     549                errorMessage = statusMessage + " ";
     550                errorMessage += MapdustResponseStatusCode.Status404.getDescription();
    525551                throw new MapdustConnectorException(errorMessage);
    526552            case 405:
    527                 errorMessage = statusMessage+ " ";
    528                 errorMessage+= MapdustResponseStatusCode.Status405
    529                                         .getDescription();
     553                errorMessage = statusMessage + " ";
     554                errorMessage += MapdustResponseStatusCode.Status405.getDescription();
    530555                throw new MapdustConnectorException(errorMessage);
    531556            case 500:
    532                 errorMessage = statusMessage  + " ";
    533                 errorMessage+=MapdustResponseStatusCode.Status500
    534                                         .getDescription();
     557                errorMessage = statusMessage + " ";
     558                errorMessage += MapdustResponseStatusCode.Status500.getDescription();
    535559                throw new MapdustConnectorException(errorMessage);
    536560            case 601:
    537                 errorMessage = statusMessage  + " ";
    538                 errorMessage+=MapdustResponseStatusCode.Status601
    539                                         .getDescription();
     561                errorMessage = statusMessage + " ";
     562                errorMessage += MapdustResponseStatusCode.Status601.getDescription();
    540563                throw new MapdustConnectorException(errorMessage);
    541564            case 602:
    542                 errorMessage = statusMessage+ " ";
    543                 errorMessage+= MapdustResponseStatusCode.Status602
    544                                         .getDescription();
     565                errorMessage = statusMessage + " ";
     566                errorMessage += MapdustResponseStatusCode.Status602.getDescription();
    545567                throw new MapdustConnectorException(errorMessage);
    546568            default:
     
    551573
    552574    /**
     575     * Returns the <code>HttpConnector</code>
     576     *
    553577     * @return the httpConnector
    554578     */
     
    558582
    559583    /**
     584     * Sets the <code>MapdustParser</code>
     585     *
    560586     * @return the parser
    561587     */
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/MapdustConnectorException.java

    r24514 r25591  
    3131/**
    3232 * Defines the exception type for the <code>MapdustConnector</code> object.
    33  * 
     33 *
    3434 * @author Bea
    35  * 
     35 *
    3636 */
    3737public class MapdustConnectorException extends Exception {
    38    
     38
    3939    /** The serial version UID */
    40     private static final long serialVersionUID = 1L;
    41    
     40    private static final long serialVersionUID = 6222042834700541233L;
     41
    4242    /**
    4343     * Builds a <code>MapdustConnectorException</code> object.
     
    4646        super();
    4747    }
    48    
     48
    4949    /**
    5050     * Builds a <code>MapdustConnectorException</code> object based on the given
    5151     * argument.
    52      * 
     52     *
    5353     * @param message The message of the exception
    5454     */
     
    5656        super(message);
    5757    }
    58    
     58
    5959    /**
    6060     * Builds a <code>MapdustConnectorException</code> object based on the given
    6161     * argument.
    62      * 
     62     *
    6363     * @param cause The cause of the exception
    6464     */
     
    6666        super(cause);
    6767    }
    68    
     68
    6969    /**
    7070     * Builds a <code>MapdustConnectorException</code> object based on the given
    7171     * arguments.
    72      * 
     72     *
    7373     * @param message The message of the exception
    7474     * @param cause The cause of the exception
     
    7777        super(message, cause);
    7878    }
    79    
     79
    8080}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/package-info.java

    r24514 r25591  
    11/**
    2  * contains the http connector
     2 * Contains the MapDust service connector classes.
    33 */
    44package org.openstreetmap.josm.plugins.mapdust.service.connector;
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/response/MapdustBugProperties.java

    r24514 r25591  
    5656    private String description;
    5757
     58    /** Flag indicating if the description is default or not */
     59    private boolean isDefaultDescription;
     60
    5861    /** The nickname of the bug */
    5962    private String nickname;
     
    9396     * @param type The type of the bug
    9497     * @param description The description of the bug
     98     * @param isDefaultDescription Flag indicating if the description is default
     99     * or not
    95100     * @param nickname The nickname
    96101     * @param skoUid The skobbler user id
     
    103108     */
    104109    public MapdustBugProperties(Date dateCreated, Date dateUpdated,
    105             Integer status, String type, String description, String nickname,
    106             String skoUid, String extUid, String source, String kmlUrl,
    107             Address address, Integer numberOfComments,
    108             MapdustCommentProperties[] comments) {
     110            Integer status, String type, String description,
     111            boolean isDefaultDescription, String nickname, String skoUid,
     112            String extUid, String source, String kmlUrl, Address address,
     113            Integer numberOfComments, MapdustCommentProperties[] comments) {
    109114        this.dateCreated = dateCreated;
    110115        this.dateUpdated = dateUpdated;
     
    112117        this.type = type;
    113118        this.description = description;
     119        this.isDefaultDescription = isDefaultDescription;
    114120        this.nickname = nickname;
    115121        this.skoUid = skoUid;
     
    213219
    214220    /**
     221     * Returns the isDefaultDescription flag
     222     *
     223     * @return the isDefaultDescription
     224     */
     225    public boolean getIsDefaultDescription() {
     226        return isDefaultDescription;
     227    }
     228
     229    /**
     230     * Sets the isDefaultDescription flag
     231     *
     232     * @param isDefaultDescription the isDefaultDescription to set
     233     */
     234    public void setIsDefaultDescription(boolean isDefaultDescription) {
     235        this.isDefaultDescription = isDefaultDescription;
     236    }
     237
     238    /**
    215239     * Returns the nickname
    216240     *
     
    355379        this.comments = comments;
    356380    }
     381
    357382}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/response/MapdustCommentProperties.java

    r24514 r25591  
    2727 */
    2828package org.openstreetmap.josm.plugins.mapdust.service.connector.response;
     29
    2930
    3031import java.util.Date;
     
    189190        this.source = source;
    190191    }
     192
    191193}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/response/MapdustGetBugsResponse.java

    r24514 r25591  
    3636 *
    3737 */
    38 public class MapdustGetBugsResponse  {
     38public class MapdustGetBugsResponse {
    3939
    4040    /** The array of <code>MapdustBugContent</code> object */
     
    7373    }
    7474
    75 
    7675}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/response/MapdustGetResponse.java

    r24514 r25591  
    3838 *
    3939 */
    40 public class MapdustGetResponse  {
     40public class MapdustGetResponse {
    4141
    4242    /**
     
    6060
    6161    /**
     62     * Returns the <code>Paging</code> object
     63     *
    6264     * @return the paging
    6365     */
     
    6769
    6870    /**
     71     * Sets the <code>Paging</code> object
     72     *
    6973     * @param paging the paging to set
    7074     */
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/response/MapdustPostResponse.java

    r24514 r25591  
    7373        this.id = id;
    7474    }
     75
    7576}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/response/package-info.java

    r24514 r25591  
    11/**
    2  * contains the response objects
     2 * Contains the MapDust service the response objects.
    33 */
    44package org.openstreetmap.josm.plugins.mapdust.service.connector.response;
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/converter/MapdustConverter.java

    r24514 r25591  
    6565            /* sets the id */
    6666            bug.setId(bugResponse.getId());
    67 
    6867            /* sets the coordinates */
    6968            Geometry geometry = bugResponse.getGeometry();
     
    7675            }
    7776            bug.setLatLon(latLon);
    78 
    7977            /* sets the properties of the bug */
    8078            MapdustBugProperties bugProperties = bugResponse.getProperties();
     
    9492                /* sets the description */
    9593                bug.setDescription(bugProperties.getDescription());
     94                /* sets the isDefaultDescription */
     95                bug.setIsDefaultDescription(bugProperties
     96                        .getIsDefaultDescription());
    9697                /* sets the skobbler user id */
    9798                bug.setSkoUid(bugProperties.getSkoUid());
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/converter/package-info.java

    r24514 r25591  
    11/**
    2  * contains the converter object
     2 * Contains the converter class.
    33 */
    44package org.openstreetmap.josm.plugins.mapdust.service.converter;
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/package-info.java

    r24514 r25591  
    11/**
    2  * retrieves and sends data from/to the Mapdust api
    3  *
     2 * Contains the MapDust API connection classes. These classes are used for
     3 * downloading/uploading MapDust bug data from/to the MapDust service.
     4 * The MapDust service connection classes are divided based on their type
     5 * in the following four packages: connector, converter, parser and value.
     6 *
    47 */
    58package org.openstreetmap.josm.plugins.mapdust.service;
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/value/MapdustBug.java

    r24514 r25591  
    6565    private String description;
    6666
     67    /** Flag indicating if the description is default or not */
     68    private boolean isDefaultDescription;
     69
    6770    /** The nickname of the user who created the bug */
    6871    private String nickname;
     
    120123     * @param type The type of the bug
    121124     * @param description The description of the bug
     125     * @param isDefaultDescription Flag indicating if the description is default
     126     * or not
    122127     * @param nickname The nickname
    123128     * @param skoUid The skobbler user id
     
    130135    public MapdustBug(Long id, LatLon latLon, Address address,
    131136            Date dateCreated, Date dateUpdated, Status status, Type type,
    132             String description, String nickname, String skoUid, String extUid,
    133             String source, String kmlUrl, Integer numberOfComments,
    134             MapdustComment[] comments) {
     137            String description, boolean isDefaultDescription, String nickname,
     138            String skoUid, String extUid, String source, String kmlUrl,
     139            Integer numberOfComments, MapdustComment[] comments) {
    135140        this.id = id;
    136141        this.latLon = latLon;
     
    141146        this.type = type;
    142147        this.description = description;
     148        this.isDefaultDescription = isDefaultDescription;
    143149        this.nickname = nickname;
    144150        this.skoUid = skoUid;
     
    277283
    278284    /**
     285     * Returns the isDefaultDescription flag
     286     *
     287     * @return the isDefaultDescription
     288     */
     289    public boolean getIsDefaultDescription() {
     290        return isDefaultDescription;
     291    }
     292
     293    /**
     294     * Sets the isDefaultDescription flag
     295     *
     296     * @param isDefaultDescription the isDefaultDescription to set
     297     */
     298    public void setIsDefaultDescription(boolean isDefaultDescription) {
     299        this.isDefaultDescription = isDefaultDescription;
     300    }
     301
     302    /**
    279303     * Returns the address
    280304     *
     
    419443    }
    420444
     445    /* (non-Javadoc)
     446     * @see java.lang.Object#hashCode()
     447     */
     448    @Override
     449    public int hashCode() {
     450        final int prime = 31;
     451        int result = 1;
     452        result = prime * result + ((id == null) ? 0 : id.hashCode());
     453        return result;
     454    }
     455
     456    /* (non-Javadoc)
     457     * @see java.lang.Object#equals(java.lang.Object)
     458     */
     459    @Override
     460    public boolean equals(Object obj) {
     461        if (this == obj)
     462            return true;
     463        if (obj == null)
     464            return false;
     465        if (getClass() != obj.getClass())
     466            return false;
     467        MapdustBug other = (MapdustBug) obj;
     468        if (id == null) {
     469            if (other.id != null)
     470                return false;
     471        } else if (!id.equals(other.id))
     472            return false;
     473        return true;
     474    }
     475
     476
    421477}
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/value/Status.java

    r24514 r25591  
    4141
    4242    /** The serial version UID */
    43     private static final long serialVersionUID = 1L;
     43    private static final long serialVersionUID = 5534551701260061940L;
    4444
    4545    /** The key of the <code>Status</code> */
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/value/Type.java

    r24514 r25591  
    4343
    4444    /** The serial version UID */
    45     private static final long serialVersionUID = 1L;
     45    private static final long serialVersionUID = 4022464908172242274L;
    4646
    4747    /** The key of the <code>Type</code> */
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/value/package-info.java

    r24514 r25591  
    11/**
    2  * Contains the objects used by representing the Mapdust data.
     2 * Contains the objects used for representing the MapDust data.
    33 */
    44package org.openstreetmap.josm.plugins.mapdust.service.value;
  • applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/util/http/HttpConnector.java

    r24514 r25591  
    5151
    5252    /** The timeout */
    53     private final int timeout = 10000;
     53    private final int timeout = 20000;
    5454
    5555    /** The <code>RetrySetup</code> */
Note: See TracChangeset for help on using the changeset viewer.