Changeset 153 in josm for src


Ignore:
Timestamp:
2006-10-07T18:14:07+02:00 (18 years ago)
Author:
imi
Message:
  • added possibility to create new download tasks (download data types).
  • removed WMS stuff (now available as landsat - plugin)
  • updated translation files
Location:
src/org/openstreetmap/josm
Files:
5 added
3 deleted
22 edited

Legend:

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

    r149 r153  
    4444import org.openstreetmap.josm.actions.UndoAction;
    4545import org.openstreetmap.josm.actions.UploadAction;
     46import org.openstreetmap.josm.actions.DownloadAction.DownloadTask;
    4647import org.openstreetmap.josm.actions.mapmode.MapMode;
    4748import org.openstreetmap.josm.data.Bounds;
     
    5152import org.openstreetmap.josm.data.projection.Projection;
    5253import org.openstreetmap.josm.gui.MapFrame;
     54import org.openstreetmap.josm.gui.PleaseWaitDialog;
    5355import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    5456import org.openstreetmap.josm.gui.annotation.AnnotationTester;
     
    5860import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener;
    5961import org.openstreetmap.josm.plugins.PluginException;
    60 import org.openstreetmap.josm.plugins.PluginLoader;
     62import org.openstreetmap.josm.plugins.PluginInformation;
    6163import org.openstreetmap.josm.plugins.PluginProxy;
    6264import org.openstreetmap.josm.tools.ImageProvider;
     
    9799         */
    98100        public final static Collection<PluginProxy> plugins = new LinkedList<PluginProxy>();
     101        /**
     102         * The dialog that gets displayed during background task execution.
     103         */
     104        public static PleaseWaitDialog pleaseWaitDlg;
     105
    99106
    100107        /**
     
    130137
    131138                for (PluginProxy plugin : plugins)
    132             plugin.mapFrameInitialized(old, map);
     139                        plugin.mapFrameInitialized(old, map);
    133140        }
    134141
     
    249256
    250257                contentPane.updateUI();
    251                
    252258
    253259                // Plugins
    254260                if (Main.pref.hasKey("plugins")) {
    255                         PluginLoader loader = new PluginLoader();
    256261                        for (String pluginName : Main.pref.get("plugins").split(",")) {
    257262                                try {
    258263                                        File pluginFile = new File(pref.getPreferencesDir()+"plugins/"+pluginName+".jar");
    259264                                        if (pluginFile.exists())
    260                                                 plugins.add(loader.loadPlugin(loader.loadClassName(pluginFile), pluginFile));
     265                                                plugins.add(new PluginInformation(pluginFile).load());
    261266                                        else
    262267                                                JOptionPane.showMessageDialog(Main.parent, tr("Plugin not found: {0}.", pluginName));
     
    268273                }
    269274        }
     275
    270276        /**
    271277         * Add a new layer to the map. If no map exist, create one.
     
    304310
    305311
    306         private static JPanel panel = new JPanel(new BorderLayout());
     312        public static JPanel panel = new JPanel(new BorderLayout());
    307313
    308314        protected final JMenuBar mainMenu = new JMenuBar();
    309315        protected static Rectangle bounds;
    310316
    311         private final UndoAction undoAction = new UndoAction();
    312         private final RedoAction redoAction = new RedoAction();
    313         private final OpenAction openAction = new OpenAction();
    314         private final DownloadAction downloadAction = new DownloadAction();
     317        public final UndoAction undoAction = new UndoAction();
     318        public final RedoAction redoAction = new RedoAction();
     319        public final OpenAction openAction = new OpenAction();
     320        public final DownloadAction downloadAction = new DownloadAction();
    315321
    316322        private final CommandQueueListener redoUndoListener = new CommandQueueListener(){
     
    374380                if (bounds == null)
    375381                        bounds = !args.containsKey("no-fullscreen") ? new Rectangle(0,0,screenDimension.width,screenDimension.height) : new Rectangle(1000,740);
     382
     383                pleaseWaitDlg = new PleaseWaitDialog();
    376384        }
    377385
     
    393401                        if (b == null)
    394402                                JOptionPane.showMessageDialog(Main.parent, tr("Ignoring malformed url: \"{0}\"", s));
    395                         else
    396                                 main.downloadAction.download(false, b.min.lat(), b.min.lon(), b.max.lat(), b.max.lon());
     403                        else {
     404                                DownloadTask osmTask = main.downloadAction.downloadTasks.get(0);
     405                                osmTask.download(main.downloadAction, b.min.lat(), b.min.lon(), b.max.lat(), b.max.lon());
     406                        }
    397407                        return;
    398408                }
     
    410420                if (st.countTokens() == 4) {
    411421                        try {
    412                                 main.downloadAction.download(rawGps, Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()));
     422                                DownloadTask task = main.downloadAction.downloadTasks.get(rawGps ? 1 : 0);
     423                                task.download(main.downloadAction, Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()));
    413424                                return;
    414425                        } catch (final NumberFormatException e) {
  • src/org/openstreetmap/josm/actions/DownloadAction.java

    r138 r153  
    1414import java.awt.event.MouseAdapter;
    1515import java.awt.event.MouseEvent;
    16 import java.io.IOException;
    17 import java.util.Collection;
     16import java.util.ArrayList;
    1817import java.util.HashMap;
     18import java.util.List;
    1919
    2020import javax.swing.DefaultListModel;
     
    3232
    3333import org.openstreetmap.josm.Main;
     34import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask;
     35import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask;
    3436import org.openstreetmap.josm.data.Bounds;
    3537import org.openstreetmap.josm.data.coor.LatLon;
    36 import org.openstreetmap.josm.data.osm.DataSet;
    3738import org.openstreetmap.josm.gui.BookmarkList;
    3839import org.openstreetmap.josm.gui.MapView;
    39 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    4040import org.openstreetmap.josm.gui.WorldChooser;
    4141import org.openstreetmap.josm.gui.BookmarkList.Bookmark;
    42 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    43 import org.openstreetmap.josm.gui.layer.RawGpsLayer;
    44 import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint;
    45 import org.openstreetmap.josm.io.BoundingBoxDownloader;
    4642import org.openstreetmap.josm.tools.GBC;
    47 import org.xml.sax.SAXException;
    4843
    4944/**
    5045 * Action that opens a connection to the osm server and download map data.
    51  * 
     46 *
    5247 * An dialog is displayed asking the user to specify a rectangle to grab.
    5348 * The url and account settings from the preferences are used.
    54  * 
     49 *
    5550 * @author imi
    5651 */
    5752public class DownloadAction extends JosmAction {
    58         /**
    59          * Open the download dialog and download the data.
    60          * Run in the worker thread.
    61          */
    62         private final class DownloadOsmTask extends PleaseWaitRunnable {
    63                 private final BoundingBoxDownloader reader;
    64                 private DataSet dataSet;
    65 
    66                 private DownloadOsmTask(BoundingBoxDownloader reader) {
    67                         super(tr("Downloading data"));
    68                         this.reader = reader;
    69                         reader.setProgressInformation(currentAction, progress);
    70                 }
    71 
    72                 @Override public void realRun() throws IOException, SAXException {
    73                         dataSet = reader.parseOsm();
    74                 }
    75 
    76                 @Override protected void finish() {
    77                         if (dataSet == null)
    78                                 return; // user cancelled download or error occoured
    79                         if (dataSet.allPrimitives().isEmpty())
    80                                 errorMessage = tr("No data imported.");
    81                         Main.main.addLayer(new OsmDataLayer(dataSet, tr("Data Layer"), null));
    82                 }
    83 
    84                 @Override protected void cancel() {
    85                         reader.cancel();
    86                 }
    87         }
    88 
    89 
    90         private final class DownloadGpsTask extends PleaseWaitRunnable {
    91                 private final BoundingBoxDownloader reader;
    92                 private Collection<Collection<GpsPoint>> rawData;
    93 
    94                 private DownloadGpsTask(BoundingBoxDownloader reader) {
    95                         super(tr("Downloading GPS data"));
    96                         this.reader = reader;
    97                         reader.setProgressInformation(currentAction, progress);
    98                 }
    99 
    100                 @Override public void realRun() throws IOException, SAXException {
    101                         rawData = reader.parseRawGps();
    102                 }
    103 
    104                 @Override protected void finish() {
    105                         if (rawData == null)
    106                                 return;
    107                         String name = latlon[0].getText() + " " + latlon[1].getText() + " x " + latlon[2].getText() + " " + latlon[3].getText();
    108                         Main.main.addLayer(new RawGpsLayer(rawData, name, null));
    109                 }
    110 
    111                 @Override protected void cancel() {
    112                         reader.cancel();
    113                 }
    114         }
    115 
     53
     54        public interface DownloadTask {
     55                /**
     56                 * Execute the download.
     57                 */
     58                void download(DownloadAction action, double minlat, double minlon, double maxlat, double maxlon);
     59                /**
     60                 * @return The checkbox presented to the user
     61                 */
     62                JCheckBox getCheckBox();
     63                /**
     64                 * @return The name of the preferences suffix to use for storing the
     65                 * selection state.
     66                 */
     67                String getPreferencesSuffix();
     68        }
     69
     70        /**
     71         * The list of download tasks. First entry should be the osm data entry
     72         * and the second the gps entry. After that, plugins can register additional
     73         * download possibilities.
     74         */
     75        public final List<DownloadTask> downloadTasks = new ArrayList<DownloadTask>(5);
    11676
    11777        /**
    11878         * minlat, minlon, maxlat, maxlon
    11979         */
    120         JTextField[] latlon = new JTextField[]{
     80        public JTextField[] latlon = new JTextField[]{
    12181                        new JTextField(9),
    12282                        new JTextField(9),
    12383                        new JTextField(9),
    12484                        new JTextField(9)};
    125         JCheckBox rawGps = new JCheckBox(tr("Open as raw gps data"), false);
    12685
    12786        public DownloadAction() {
     
    13089                for (JTextField f : latlon)
    13190                        f.setMinimumSize(new Dimension(100,new JTextField().getMinimumSize().height));
     91
     92                downloadTasks.add(new DownloadOsmTask());
     93                downloadTasks.add(new DownloadGpsTask());
    13294        }
    13395
     
    155117                                        mv.getLatLon(0, mv.getHeight()),
    156118                                        mv.getLatLon(mv.getWidth(), 0)));
    157                         rawGps.setSelected(mv.getActiveLayer() instanceof RawGpsLayer);
    158                 }
    159                 dlg.add(rawGps, GBC.eop());
     119                }
     120
     121                // adding the download tasks
     122                dlg.add(new JLabel(tr("Download the following data:")), GBC.eol().insets(0,5,0,0));
     123                for (DownloadTask task : downloadTasks) {
     124                        dlg.add(task.getCheckBox(), GBC.eol().insets(20,0,0,0));
     125                        task.getCheckBox().setSelected(Main.pref.getBoolean("download."+task.getPreferencesSuffix()));
     126                }
    160127
    161128                // OSM url edit
    162                 dlg.add(new JLabel(tr("URL from www.openstreetmap.org")), GBC.eol());
     129                dlg.add(new JLabel(tr("URL from www.openstreetmap.org")), GBC.eol().insets(0,5,0,0));
    163130                final JTextField osmUrl = new JTextField();
    164131                dlg.add(osmUrl, GBC.eop().fill(GBC.HORIZONTAL));
     
    204171                                                if (b != null)
    205172                                                        setEditBounds(b);
    206                                                 else 
     173                                                else
    207174                                                        for (JTextField f : latlon)
    208175                                                                f.setText("");
     
    222189                                        latlon[i].setCaretPosition(0);
    223190                                }
    224                                 rawGps.setSelected(b == null ? false : b.rawgps);
    225191                                osmUrlRefresher.keyTyped(null);
    226192                        }
     
    267233                // Finally: the dialog
    268234                Bookmark b;
     235                boolean anySelected = false;
    269236                do {
    270237                        final JOptionPane pane = new JOptionPane(dlg, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
     
    283250                                return;
    284251                        b = readBookmark();
     252
     253                        for (DownloadTask task : downloadTasks) {
     254                                if (task.getCheckBox().isSelected()) {
     255                                        anySelected = true;
     256                                        break;
     257                                }
     258                        }
     259
    285260                        if (b == null)
    286261                                JOptionPane.showMessageDialog(Main.parent,tr("Please enter the desired coordinates or click on a bookmark."));
    287                 } while (b == null);
     262                        else if (!anySelected)
     263                                JOptionPane.showMessageDialog(Main.parent,tr("Please select at least one download data type."));
     264                } while (b == null && anySelected);
    288265
    289266                double minlon = b.latlon[0];
     
    291268                double maxlon = b.latlon[2];
    292269                double maxlat = b.latlon[3];
    293                 download(rawGps.isSelected(), minlon, minlat, maxlon, maxlat);
     270                download(minlon, minlat, maxlon, maxlat);
    294271        }
    295272
     
    309286                                b.latlon[i] = Double.parseDouble(latlon[i].getText());
    310287                        }
    311                         b.rawgps = rawGps.isSelected();
    312288                        return b;
    313289                } catch (NumberFormatException x) {
     
    315291                }
    316292        }
    317 
    318293
    319294        public static Bounds osmurl2bounds(String url) {
     
    329304                                        map.put(arg.substring(0, eq), Double.parseDouble(arg.substring(eq + 1)));
    330305                                } catch (NumberFormatException e) {
    331                                 }                               
     306                                }
    332307                        }
    333308                }
     
    363338         * Do the download for the given area.
    364339         */
    365         public void download(boolean rawGps, double minlat, double minlon, double maxlat, double maxlon) {
    366                 BoundingBoxDownloader reader = new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon);
    367                 PleaseWaitRunnable task = rawGps ? new DownloadGpsTask(reader) : new DownloadOsmTask(reader);
    368                 Main.worker.execute(task);
    369                 task.pleaseWaitDlg.setVisible(true);
     340        public void download(double minlat, double minlon, double maxlat, double maxlon) {
     341                for (DownloadTask task : downloadTasks) {
     342                        Main.pref.put("download."+task.getPreferencesSuffix(), task.getCheckBox().isSelected());
     343                        if (task.getCheckBox().isSelected()) {
     344                                task.download(this, minlat, minlon, maxlat, maxlon);
     345                        }
     346                }
    370347        }
    371348}
  • src/org/openstreetmap/josm/actions/DownloadIncompleteAction.java

    r138 r153  
    2626/**
    2727 * Action that opens a connection to the osm server and download map data.
    28  * 
     28 *
    2929 * An dialog is displayed asking the user to specify a rectangle to grab.
    3030 * The url and account settings from the preferences are used.
    31  * 
     31 *
    3232 * @author imi
    3333 */
     
    4646                        super(trn("Downloading {0} segment", "Downloading {0} segments", toDownload.size(), toDownload.size()));
    4747                        reader = new ObjectListDownloader(toDownload);
    48                         reader.setProgressInformation(currentAction, progress);
    4948                }
    5049
     
    7170                        }
    7271                        reader = new ObjectListDownloader(nodes);
    73                         reader.setProgressInformation(currentAction, progress);
    7472                        nodesLoaded = true;
    7573                        Main.worker.execute(this);
    76                         pleaseWaitDlg.setVisible(true);
    7774                }
    7875
     
    105102                PleaseWaitRunnable task = new DownloadTask(toDownload);
    106103                Main.worker.execute(task);
    107                 task.pleaseWaitDlg.setVisible(true);
    108104        }
    109105}
  • src/org/openstreetmap/josm/actions/ExternalToolsAction.java

    r146 r153  
    6666                        super(msg);
    6767                        this.p = p;
    68                         currentAction.setText(tr("Executing {0}",getValue(NAME)));
    6968                }
    7069
    7170                @Override protected void realRun() throws SAXException, IOException {
     71                        Main.pleaseWaitDlg.currentAction.setText(tr("Executing {0}",getValue(NAME)));
    7272                        if (!input.isEmpty()) {
    7373                                fromDataSet = new DataSet();
     
    201201                        }
    202202                        if (output != null)
    203                                 dataSet = OsmReader.parseDataSet(p.getInputStream(), currentAction, progress);
     203                                dataSet = OsmReader.parseDataSet(p.getInputStream(), Main.pleaseWaitDlg.currentAction, Main.pleaseWaitDlg.progress);
    204204                }
    205205
     
    302302                        PleaseWaitRunnable runner = new ExecuteToolRunner(tr("Executing {0}",getValue(NAME)), p);
    303303                        Main.worker.execute(runner);
    304                         runner.pleaseWaitDlg.setVisible(true);
    305304                } catch (IOException e1) {
    306305                        e1.printStackTrace();
  • src/org/openstreetmap/josm/actions/UploadAction.java

    r113 r153  
    2626/**
    2727 * Action that opens a connection to the osm server and upload all changes.
    28  * 
     28 *
    2929 * An dialog is displayed asking the user to specify a rectangle to grab.
    3030 * The url and account settings from the preferences are used.
    31  * 
     31 *
    3232 * @author imi
    3333 */
     
    7575                PleaseWaitRunnable uploadTask = new PleaseWaitRunnable(tr("Uploading data")){
    7676                        @Override protected void realRun() throws SAXException {
    77                                 server.setProgressInformation(currentAction, progress);
    7877                                server.uploadOsm(all);
    7978                        }
     
    8685                };
    8786                Main.worker.execute(uploadTask);
    88                 uploadTask.pleaseWaitDlg.setVisible(true);
    8987        }
    9088
     
    129127                }
    130128
    131                 return JOptionPane.showConfirmDialog(Main.parent, p, tr("Upload this changes?"), 
     129                return JOptionPane.showConfirmDialog(Main.parent, p, tr("Upload this changes?"),
    132130                                JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
    133131        }
  • src/org/openstreetmap/josm/gui/BookmarkList.java

    r104 r153  
    33import static org.openstreetmap.josm.tools.I18n.tr;
    44
    5 import java.awt.Component;
    65import java.io.BufferedReader;
    76import java.io.File;
     
    1211import java.util.StringTokenizer;
    1312
    14 import javax.swing.DefaultListCellRenderer;
    1513import javax.swing.DefaultListModel;
    16 import javax.swing.JLabel;
    1714import javax.swing.JList;
    1815import javax.swing.JOptionPane;
    1916
    2017import org.openstreetmap.josm.Main;
    21 import org.openstreetmap.josm.tools.ImageProvider;
    2218
    2319/**
     
    3430                public String name;
    3531                public double[] latlon = new double[4]; // minlat, minlon, maxlat, maxlon
    36                 public boolean rawgps;
    3732                @Override public String toString() {
    3833                        return name;
     
    4742                load();
    4843                setVisibleRowCount(7);
    49                 setCellRenderer(new DefaultListCellRenderer(){
    50                         @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    51                                 Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    52                                 if (c instanceof JLabel) {
    53                                         Bookmark b = (Bookmark)value;
    54                                         ((JLabel)c).setIcon(ImageProvider.get("layer/"+(b.rawgps?"rawgps_small":"osmdata_small")));
    55                                 }
    56                                 return c;
    57                         }
    58                 });
    5944        }
    6045
     
    7358                        for (String line = in.readLine(); line != null; line = in.readLine()) {
    7459                                StringTokenizer st = new StringTokenizer(line, ",");
    75                                 if (st.countTokens() != 6)
     60                                if (st.countTokens() != 5)
    7661                                        continue;
    7762                                Bookmark b = new Bookmark();
     
    8065                                        for (int i = 0; i < b.latlon.length; ++i)
    8166                                                b.latlon[i] = Double.parseDouble(st.nextToken());
    82                                         b.rawgps = Boolean.parseBoolean(st.nextToken());
    8367                                        model.addElement(b);
    8468                                } catch (NumberFormatException x) {
     
    10791                                out.print(b.name+",");
    10892                                for (int i = 0; i < b.latlon.length; ++i)
    109                                         out.print(b.latlon[i]+",");
    110                                 out.println(b.rawgps);
     93                                        out.print(b.latlon[i]+(i<b.latlon.length-1?",":""));
     94                                out.println();
    11195                        }
    11296                        out.close();
  • src/org/openstreetmap/josm/gui/MainApplication.java

    r138 r153  
    2626/**
    2727 * Main window class application.
    28  * 
     28 *
    2929 * @author imi
    3030 */
    3131public class MainApplication extends Main {
    3232        /**
    33          * Construct an main frame, ready sized and operating. Does not 
     33         * Construct an main frame, ready sized and operating. Does not
    3434         * display the frame.
    3535         */
     
    6767        /**
    6868         * Main application Startup
    69          * @param args  No parameters accepted.
    7069         */
    7170        public static void main(final String[] argArray) {
     
    7473                /////////////////////////////////////////////////////////////////////////
    7574                // Do not translate the early strings below until the locale is set up.
    76                 // The cannot be translated. That's live. Really. Sorry.
     75                // These strings cannot be translated. That's live. Really. Sorry.
    7776                //
    78                 // The next sending me a patch translating these strings owe me a beer!
     77                // The next one sending me a patch translating these strings owe me a beer!
    7978                //
    8079                //                                                                 Imi.
    8180                /////////////////////////////////////////////////////////////////////////
    82                
     81
    8382                Thread.setDefaultUncaughtExceptionHandler(new BugReportExceptionHandler());
    8483
     
    139138                        }
    140139                }
    141                
     140
    142141                // Locale is set. From now on, tr(), trn() and trc() may be called.
    143142
  • src/org/openstreetmap/josm/gui/MapView.java

    r116 r153  
    2727import org.openstreetmap.josm.gui.layer.Layer;
    2828import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    29 import org.openstreetmap.josm.gui.layer.WmsServerLayer;
    3029import org.openstreetmap.josm.gui.layer.OsmDataLayer.ModifiedChangedListener;
    3130
    3231/**
    3332 * This is a component used in the MapFrame for browsing the map. It use is to
    34  * provide the MapMode's enough capabilities to operate. 
    35  * 
     33 * provide the MapMode's enough capabilities to operate.
     34 *
    3635 * MapView hold meta-data about the data set currently displayed, as scale level,
    3736 * center point viewed, what scrolling mode or editing mode is selected or with
     
    9998                add(zoomSlider);
    10099                zoomSlider.setBounds(3, 0, 114, 30);
    101                
     100
    102101                MapScaler scaler = new MapScaler(this);
    103102                add(scaler);
     
    128127
    129128                // add as a new layer
    130                 if (layer instanceof WmsServerLayer)
     129                if (layer instanceof OsmDataLayer)
     130                        layers.add(0, layer);
     131                else
    131132                        layers.add(layers.size(), layer);
    132                 else
    133                         layers.add(0, layer);
    134133
    135134                for (LayerChangeListener l : listeners)
     
    219218        }
    220219        /**
    221          * Set the new dimension to the projection class. Also adjust the components 
     220         * Set the new dimension to the projection class. Also adjust the components
    222221         * scale, if in autoScale mode.
    223222         */
     
    239238
    240239                        if (v.min == null || v.max == null || v.min.equals(v.max)) {
    241                                 // no bounds means whole world 
     240                                // no bounds means whole world
    242241                                center = getProjection().latlon2eastNorth(new LatLon(0,0));
    243242                                EastNorth world = getProjection().latlon2eastNorth(new LatLon(Projection.MAX_LAT,Projection.MAX_LON));
  • src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java

    r113 r153  
    44
    55import java.awt.EventQueue;
    6 import java.awt.GridBagLayout;
    76import java.awt.event.ActionEvent;
    87import java.awt.event.ActionListener;
     
    1110import java.io.FileNotFoundException;
    1211import java.io.IOException;
     12import java.lang.reflect.InvocationTargetException;
    1313
    14 import javax.swing.BorderFactory;
    15 import javax.swing.BoundedRangeModel;
    16 import javax.swing.JButton;
    17 import javax.swing.JDialog;
    18 import javax.swing.JLabel;
    1914import javax.swing.JOptionPane;
    20 import javax.swing.JPanel;
    21 import javax.swing.JProgressBar;
    2215
    2316import org.openstreetmap.josm.Main;
    24 import org.openstreetmap.josm.tools.GBC;
    25 import org.openstreetmap.josm.tools.I18n;
    2617import org.xml.sax.SAXException;
    2718
     
    2920 * Instanced of this thread will display a "Please Wait" message in middle of JOSM
    3021 * to indicate a progress beeing executed.
    31  * 
     22 *
    3223 * @author Imi
    3324 */
    3425public abstract class PleaseWaitRunnable implements Runnable {
    3526
    36         public final JDialog pleaseWaitDlg;
    3727        public String errorMessage;
    3828
    39         private final JProgressBar progressBar = new JProgressBar();
    4029        private boolean closeDialogCalled = false;
     30        private boolean cancelled = false;
    4131
    42         protected final JLabel currentAction = new JLabel(I18n.tr("Contacting the OSM server..."));
    43         protected final BoundedRangeModel progress = progressBar.getModel();
     32        private final String title;
    4433
    4534        /**
    4635         * Create the runnable object with a given message for the user.
    4736         */
    48         public PleaseWaitRunnable(String msg) {
    49                 pleaseWaitDlg = new JDialog(JOptionPane.getFrameForComponent(Main.parent), msg, true);
    50                 pleaseWaitDlg.setLayout(new GridBagLayout());
    51                 JPanel pane = new JPanel(new GridBagLayout());
    52                 pane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
    53                 pane.add(currentAction, GBC.eol().fill(GBC.HORIZONTAL));
    54                 pane.add(progressBar, GBC.eop().fill(GBC.HORIZONTAL));
    55                 JButton cancel = new JButton(tr("Cancel"));
    56                 pane.add(cancel, GBC.eol().anchor(GBC.CENTER));
    57                 pleaseWaitDlg.setContentPane(pane);
    58                 pleaseWaitDlg.setSize(350,100);
    59                 pleaseWaitDlg.setLocationRelativeTo(Main.parent);
    60 
    61                 cancel.addActionListener(new ActionListener(){
     37        public PleaseWaitRunnable(String title) {
     38                this.title = title;
     39                Main.pleaseWaitDlg.cancel.addActionListener(new ActionListener(){
    6240                        public void actionPerformed(ActionEvent e) {
    63                                 cancel();
     41                                if (!cancelled) {
     42                                        cancelled = true;
     43                                        cancel();
     44                                }
    6445                        }
    6546                });
    66                 pleaseWaitDlg.addWindowListener(new WindowAdapter(){
     47                Main.pleaseWaitDlg.addWindowListener(new WindowAdapter(){
    6748                        @Override public void windowClosing(WindowEvent e) {
    6849                                if (!closeDialogCalled) {
    69                                         cancel();
     50                                        if (!cancelled) {
     51                                                cancelled = true;
     52                                                cancel();
     53                                        }
    7054                                        closeDialog();
    7155                                }
     
    7660        public final void run() {
    7761                try {
     62                        if (cancelled)
     63                                return; // since realRun isn't executed, do not call to finish
     64                        Main.pleaseWaitDlg.setTitle(title);
     65
     66                        // show the dialog
     67                        closeDialogCalled = false;
     68                        EventQueue.invokeLater(new Runnable() {
     69                                public void run() {
     70                                        Main.pleaseWaitDlg.setVisible(true);
     71                                }
     72                        });
     73
    7874                        realRun();
    7975                } catch (SAXException x) {
     
    116112                        return;
    117113                closeDialogCalled  = true;
    118                 EventQueue.invokeLater(new Runnable(){
    119                         public void run() {
    120                                 finish();
    121                                 pleaseWaitDlg.setVisible(false);
    122                                 pleaseWaitDlg.dispose();
    123                                 if (errorMessage != null)
    124                                         JOptionPane.showMessageDialog(Main.parent, errorMessage);
    125                         }
    126                 });
     114                try {
     115                        Runnable runnable = new Runnable(){
     116                                public void run() {
     117                                        try {
     118                                                finish();
     119                                        } finally {
     120                                                Main.pleaseWaitDlg.setVisible(false);
     121                                        }
     122                                        if (errorMessage != null)
     123                                                JOptionPane.showMessageDialog(Main.parent, errorMessage);
     124                                }
     125                        };
     126
     127                        // make sure, this is called in the dispatcher thread ASAP
     128                        if (EventQueue.isDispatchThread())
     129                                runnable.run();
     130                        else
     131                                EventQueue.invokeAndWait(runnable);
     132
     133                } catch (InterruptedException e) {
     134                } catch (InvocationTargetException e) {
     135                        throw new RuntimeException(e);
     136                }
    127137        }
    128138}
  • src/org/openstreetmap/josm/gui/PreferenceDialog.java

    r150 r153  
    4949import org.openstreetmap.josm.Main;
    5050import org.openstreetmap.josm.data.projection.Projection;
    51 import org.openstreetmap.josm.plugins.PluginProxy;
     51import org.openstreetmap.josm.plugins.PluginInformation;
    5252import org.openstreetmap.josm.tools.ColorHelper;
    5353import org.openstreetmap.josm.tools.GBC;
     
    109109
    110110                        String plugins = "";
    111                         for (Entry<String, Boolean> entry : pluginMap.entrySet())
     111                        for (Entry<PluginInformation, Boolean> entry : pluginMap.entrySet())
    112112                                if (entry.getValue())
    113                                         plugins += entry.getKey() + ",";
     113                                        plugins += entry.getKey().name + ",";
    114114                        if (plugins.endsWith(","))
    115115                                plugins = plugins.substring(0, plugins.length()-1);
     
    135135                private static final String CANCELBUTTON_PROP = "OptionPane.cancelButtonText";
    136136                public CancelAction() {
    137                         super(UIManager.getString(CANCELBUTTON_PROP), 
     137                        super(UIManager.getString(CANCELBUTTON_PROP),
    138138                                        UIManager.getIcon("OptionPane.cancelIcon"));
    139139                        try {
     
    157157        private JComboBox lafCombo = new JComboBox(UIManager.getInstalledLookAndFeels());
    158158        private JComboBox languages = new JComboBox(new Locale[]{
    159                         new Locale("en", "US"), 
    160                         new Locale("en", "GB"), 
    161                         Locale.GERMAN, 
     159                        new Locale("en", "US"),
     160                        new Locale("en", "GB"),
     161                        Locale.GERMAN,
    162162                        Locale.FRENCH,
    163163                        new Locale("ro", "RO")});
     
    168168
    169169        /**
    170          * Editfield for the Base url to the REST API from OSM. 
     170         * Editfield for the Base url to the REST API from OSM.
    171171         */
    172172        private JTextField osmDataServer = new JTextField(20);
     
    205205        private JComboBox projectionCombo = new JComboBox(Projection.allProjections);
    206206        private JList annotationSources = new JList(new DefaultListModel());
    207         private Map<String, Boolean> pluginMap = new HashMap<String, Boolean>();
     207        private Map<PluginInformation, Boolean> pluginMap = new HashMap<PluginInformation, Boolean>();
    208208
    209209
     
    285285
    286286                Box pluginPanel = Box.createVerticalBox();
    287                 Collection<String> availablePlugins = new HashSet<String>();
     287                Collection<PluginInformation> availablePlugins = new HashSet<PluginInformation>();
    288288                File[] pluginFiles = new File(Main.pref.getPreferencesDir()+"plugins").listFiles();
    289                 if (pluginFiles != null) {
    290                         for (File f : pluginFiles) {
    291                                 if (!f.isFile() || !f.getName().endsWith(".jar"))
    292                                         continue;
    293                                 availablePlugins.add(f.getName().substring(0, f.getName().length()-4));
    294                         }
    295                 }
     289                if (pluginFiles != null)
     290                        for (File f : pluginFiles)
     291                                if (f.isFile() && f.getName().endsWith(".jar"))
     292                                        availablePlugins.add(new PluginInformation(f));
     293
    296294                Collection<String> enabledPlugins = Arrays.asList(Main.pref.get("plugins").split(","));
    297                 for (final String plugin : availablePlugins) {
    298                         boolean enabled = enabledPlugins.contains(plugin);
    299                         String desc = null;
    300                         for (PluginProxy p : Main.plugins) {
    301                                 if (p.name.equals(plugin)) {
    302                                         desc = p.getDescription();
    303                                         break;
    304                                 }
    305                         }
    306 
    307                         final JCheckBox pluginCheck = new JCheckBox(plugin, enabled);
     295                for (final PluginInformation plugin : availablePlugins) {
     296                        boolean enabled = enabledPlugins.contains(plugin.name);
     297                        final JCheckBox pluginCheck = new JCheckBox(plugin.name, enabled);
    308298                        pluginPanel.add(pluginCheck);
    309                         if (desc != null) {
    310                                 pluginCheck.setToolTipText(desc);
    311                                 JLabel label = new JLabel("<html><i>"+desc+"</i></html>");
    312                                 label.setBorder(BorderFactory.createEmptyBorder(0,20,0,0));
    313                                 pluginPanel.add(label);
    314                                 pluginPanel.add(Box.createVerticalStrut(5));
    315                         }
     299
     300                        pluginCheck.setToolTipText(plugin.file.getAbsolutePath());
     301                        JLabel label = new JLabel("<html><i>"+(plugin.description==null?"no description available":plugin.description)+"</i></html>");
     302                        label.setBorder(BorderFactory.createEmptyBorder(0,20,0,0));
     303                        pluginPanel.add(label);
     304                        pluginPanel.add(Box.createVerticalStrut(5));
     305
    316306                        pluginMap.put(plugin, enabled);
    317307                        pluginCheck.addActionListener(new ActionListener(){
  • src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r128 r153  
    4949 * respects clicks into the selection list. Ctrl-click will remove entries from
    5050 * the list while single click will make the clicked entry the only selection.
    51  * 
     51 *
    5252 * @author imi
    5353 */
     
    6868                }
    6969                @Override protected void realRun() {
    70                         currentAction.setText(tr("Contact {0}...", url.getHost()));
     70                        Main.pleaseWaitDlg.currentAction.setText(tr("Contact {0}...", url.getHost()));
    7171                        sel = mode != SearchMode.remove ? new LinkedList<OsmPrimitive>() : Main.ds.allNonDeletedPrimitives();
    7272                        try {
    7373                                URLConnection con = url.openConnection();
    74                                 InputStream in = new ProgressInputStream(con, progress, currentAction);
    75                                 currentAction.setText(tr("Downloading..."));
     74                                InputStream in = new ProgressInputStream(con);
     75                                Main.pleaseWaitDlg.currentAction.setText(tr("Downloading..."));
    7676                                Map<Long, String> ids = idReader.parseIds(in);
    7777                                for (OsmPrimitive osm : Main.ds.allNonDeletedPrimitives()) {
     
    236236                        if (loader.url != null) {
    237237                                Main.worker.execute(loader);
    238                                 loader.pleaseWaitDlg.setVisible(true);
    239238                                return;
    240239                        }
  • src/org/openstreetmap/josm/gui/layer/GeoImageLayer.java

    r145 r153  
    7979                public int compareTo(ImageEntry image) {
    8080                        return time.compareTo(image.time);
    81                 }               
     81                }
    8282        }
    8383
     
    9393                }
    9494                @Override protected void realRun() throws IOException {
    95                         currentAction.setText(tr("Read GPS..."));
     95                        Main.pleaseWaitDlg.currentAction.setText(tr("Read GPS..."));
    9696                        LinkedList<TimedPoint> gps = new LinkedList<TimedPoint>();
    9797
     
    119119                        ArrayList<ImageEntry> data = new ArrayList<ImageEntry>(files.size());
    120120                        int i = 0;
    121                         progress.setMaximum(files.size());
     121                        Main.pleaseWaitDlg.progress.setMaximum(files.size());
    122122                        for (File f : files) {
    123123                                if (cancelled)
    124124                                        break;
    125                                 currentAction.setText(tr("Reading {0}...",f.getName()));
    126                                 progress.setValue(i++);
     125                                Main.pleaseWaitDlg.currentAction.setText(tr("Reading {0}...",f.getName()));
     126                                Main.pleaseWaitDlg.progress.setValue(i++);
    127127
    128128                                ImageEntry e = new ImageEntry();
     
    153153
    154154        /**
    155          * The delta added to all timestamps in files from the camera 
     155         * The delta added to all timestamps in files from the camera
    156156         * to match to the timestamp from the gps receivers tracklog.
    157157         */
     
    185185        public static void create(Collection<File> files, RawGpsLayer gpsLayer) {
    186186                Loader loader = new Loader(files, gpsLayer);
    187                 new Thread(loader).start();
    188                 loader.pleaseWaitDlg.setVisible(true);
     187                Main.worker.execute(loader);
    189188        }
    190189
     
    192191                super(tr("Geotagged Images"));
    193192                Collections.sort(data);
    194                 Collections.sort(gps);                                 
     193                Collections.sort(gps);
    195194                this.data = data;
    196195                this.gps = gps;
     
    367366                                new JSeparator(),
    368367                                new JMenuItem(new RenameLayerAction(null, this)),
    369                                 new JSeparator(), 
     368                                new JSeparator(),
    370369                                new JMenuItem(new LayerListPopup.InfoAction(this))};
    371370        }
  • src/org/openstreetmap/josm/io/BoundingBoxDownloader.java

    r104 r153  
    88import java.util.LinkedList;
    99
     10import org.openstreetmap.josm.Main;
    1011import org.openstreetmap.josm.data.osm.DataSet;
    1112import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint;
     
    4041                Collection<Collection<GpsPoint>> data = new LinkedList<Collection<GpsPoint>>();
    4142                Collection<GpsPoint> list = new LinkedList<GpsPoint>();
    42    
     43
    4344                for (int i = 0;;++i) {
    44                         currentAction.setText(tr("Downloading points {0} to {1}...", i * 5000, ((i + 1) * 5000)));
     45                        Main.pleaseWaitDlg.currentAction.setText(tr("Downloading points {0} to {1}...", i * 5000, ((i + 1) * 5000)));
    4546                        InputStream in = getInputStream(url+i);
    4647                        if (in == null)
     
    5960                        activeConnection = null;
    6061                }
    61    
     62
    6263                data.add(list);
    6364                return data;
     
    8687                if (in == null)
    8788                        return null;
    88                 currentAction.setText(tr("Downloading OSM data..."));
    89                 final DataSet data = OsmReader.parseDataSet(in, currentAction, progress);
     89                Main.pleaseWaitDlg.currentAction.setText(tr("Downloading OSM data..."));
     90                final DataSet data = OsmReader.parseDataSet(in, Main.pleaseWaitDlg.currentAction, Main.pleaseWaitDlg.progress);
    9091                in.close();
    9192                activeConnection = null;
  • src/org/openstreetmap/josm/io/ObjectListDownloader.java

    r113 r153  
    77import java.util.Collection;
    88
     9import org.openstreetmap.josm.Main;
    910import org.openstreetmap.josm.data.osm.DataSet;
    1011import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    2728
    2829        public DataSet parse() throws SAXException, IOException {
    29                 progress.setMaximum(toDownload.size());
    30                 progress.setValue(0);
     30                Main.pleaseWaitDlg.progress.setMaximum(toDownload.size());
     31                Main.pleaseWaitDlg.progress.setValue(0);
    3132                try {
    3233                        final NameVisitor namer = new NameVisitor();
     
    5657
    5758        private void download(String className, long id) throws IOException, SAXException {
    58                 currentAction.setText(tr("Downloading {0} {1}", className, id));
     59                Main.pleaseWaitDlg.currentAction.setText(tr("Downloading {0} {1}", className, id));
    5960                InputStream in = getInputStream(className+"/"+id);
    6061                if (in == null)
    6162                        return;
    6263                DataSet data = OsmReader.parseDataSet(in, null, null);
    63                 progress.setValue(progress.getValue()+1);
     64                Main.pleaseWaitDlg.progress.setValue(Main.pleaseWaitDlg.progress.getValue()+1);
    6465                if (data.allPrimitives().size() > 1)
    6566                        throw new SAXException(tr("Got more than one object when expecting only one."));
  • src/org/openstreetmap/josm/io/OsmConnection.java

    r104 r153  
    99import java.net.PasswordAuthentication;
    1010
    11 import javax.swing.BoundedRangeModel;
    1211import javax.swing.JCheckBox;
    1312import javax.swing.JLabel;
     
    2322 * Base class that handles common things like authentication for the reader and writer
    2423 * to the osm server.
    25  * 
     24 *
    2625 * @author imi
    2726 */
     
    3433                public OsmParseException(Throwable cause) {super(cause);}
    3534        }
    36        
     35
    3736        protected boolean cancel = false;
    3837        protected HttpURLConnection activeConnection;
    39         protected JLabel currentAction;
    40         protected BoundedRangeModel progress;
    4138
    4239        private static OsmAuth authentication;
     
    116113        }
    117114
    118         public void setProgressInformation(JLabel currentAction, BoundedRangeModel progress) {
    119                 this.currentAction = currentAction;
    120                 this.progress = progress;
    121         }
    122 
    123115        public void cancel() {
    124                 currentAction.setText(tr("Aborting..."));
     116                Main.pleaseWaitDlg.currentAction.setText(tr("Aborting..."));
    125117                cancel = true;
    126118                if (activeConnection != null) {
  • src/org/openstreetmap/josm/io/OsmReader.java

    r113 r153  
    3232/**
    3333 * Parser for the Osm Api. Read from an input stream and construct a dataset out of it.
    34  * 
     34 *
    3535 * Reading process takes place in three phases. During the first phase (including xml parse),
    3636 * all nodes are read and stored. Other information than nodes are stored in a raw list
    37  * 
     37 *
    3838 * The second phase reads from the raw list all segments and create Segment objects.
    39  * 
     39 *
    4040 * The third phase read all ways out of the remaining objects in the raw list.
    41  * 
     41 *
    4242 * @author Imi
    4343 */
  • src/org/openstreetmap/josm/io/OsmServerReader.java

    r115 r153  
    1010/**
    1111 * This DataReader read directly from the REST API of the osm server.
    12  * 
     12 *
    1313 * @author imi
    1414 */
     
    3030                if (isAuthCancelled() && activeConnection.getResponseCode() == 401)
    3131                        return null;
    32                 return new ProgressInputStream(activeConnection, progress, currentAction);
     32                return new ProgressInputStream(activeConnection);
    3333        }
    3434}
  • src/org/openstreetmap/josm/io/OsmServerWriter.java

    r143 r153  
    2626/**
    2727 * Class that uploades all changes to the osm server.
    28  * 
     28 *
    2929 * This is done like this: - All objects with id = 0 are uploaded as new, except
    3030 * those in deleted, which are ignored - All objects in deleted list are
    3131 * deleted. - All remaining objects with modified flag set are updated.
    32  * 
     32 *
    3333 * This class implements visitor and will perform the correct upload action on
    3434 * the visited element.
    35  * 
     35 *
    3636 * @author imi
    3737 */
     
    4141         * This list contain all sucessfull processed objects. The caller of
    4242         * upload* has to check this after the call and update its dataset.
    43          * 
     43         *
    4444         * If a server connection error occours, this may contain fewer entries
    4545         * than where passed in the list to upload*.
     
    6060                initAuthentication();
    6161
    62                 progress.setMaximum(list.size());
    63                 progress.setValue(0);
     62                Main.pleaseWaitDlg.progress.setMaximum(list.size());
     63                Main.pleaseWaitDlg.progress.setValue(0);
    6464
    6565                NameVisitor v = new NameVisitor();
     
    6969                                        return;
    7070                                osm.visit(v);
    71                                 currentAction.setText(tr("Upload {0} {1} ({2})...", tr(v.className), v.name, osm.id));
     71                                Main.pleaseWaitDlg.currentAction.setText(tr("Upload {0} {1} ({2})...", tr(v.className), v.name, osm.id));
    7272                                osm.visit(this);
    73                                 progress.setValue(progress.getValue()+1);
     73                                Main.pleaseWaitDlg.progress.setValue(Main.pleaseWaitDlg.progress.getValue()+1);
    7474                        }
    7575                } catch (RuntimeException e) {
     
    142142         * Send the request. The objects id will be replaced if it was 0 before
    143143         * (on add requests).
    144          * 
     144         *
    145145         * @param requestMethod The http method used when talking with the server.
    146146         * @param urlSuffix The suffix to add at the server url.
    147147         * @param osm The primitive to encode to the server.
    148          * @param addBody <code>true</code>, if the whole primitive body should be added. 
     148         * @param addBody <code>true</code>, if the whole primitive body should be added.
    149149         *              <code>false</code>, if only the id is encoded.
    150150         */
  • src/org/openstreetmap/josm/io/ProgressInputStream.java

    r115 r153  
    55import java.net.URLConnection;
    66
    7 import javax.swing.BoundedRangeModel;
    8 import javax.swing.JLabel;
     7import org.openstreetmap.josm.Main;
    98
    109/**
     
    1514
    1615        private final InputStream in;
    17         private final BoundedRangeModel progress;
    18         private final JLabel currentAction;
    1916        private int readSoFar = 0;
    2017        private int lastDialogUpdate = 0;
    2118        private final URLConnection connection;
    2219
    23         public ProgressInputStream(URLConnection con, BoundedRangeModel progress, JLabel currentAction) throws IOException {
     20        public ProgressInputStream(URLConnection con) throws IOException {
    2421                this.connection = con;
    2522                this.in = con.getInputStream();
    26                 this.progress = progress;
    27                 this.currentAction = currentAction;
    2823                int contentLength = con.getContentLength();
    2924                if (contentLength > 0)
    30                         progress.setMaximum(contentLength);
     25                        Main.pleaseWaitDlg.progress.setMaximum(contentLength);
    3126                else
    32                         progress.setMaximum(0);
    33                 progress.setValue(0);
     27                        Main.pleaseWaitDlg.progress.setMaximum(0);
     28                Main.pleaseWaitDlg.progress.setValue(0);
    3429        }
    3530
     
    5752         */
    5853        private void advanceTicker(int amount) {
    59                 if (progress.getMaximum() == 0 && connection.getContentLength() != -1)
    60                         progress.setMaximum(connection.getContentLength());
     54                if (Main.pleaseWaitDlg.progress.getMaximum() == 0 && connection.getContentLength() != -1)
     55                        Main.pleaseWaitDlg.progress.setMaximum(connection.getContentLength());
    6156
    6257                readSoFar += amount;
     
    6560                        lastDialogUpdate++;
    6661                        String progStr = " "+readSoFar/1024+"/";
    67                         progStr += (progress.getMaximum()==0) ? "??? KB" : (progress.getMaximum()/1024)+" KB";
    68                         progress.setValue(readSoFar);
     62                        progStr += (Main.pleaseWaitDlg.progress.getMaximum()==0) ? "??? KB" : (Main.pleaseWaitDlg.progress.getMaximum()/1024)+" KB";
     63                        Main.pleaseWaitDlg.progress.setValue(readSoFar);
    6964
    70                         String cur = currentAction.getText();
     65                        String cur = Main.pleaseWaitDlg.currentAction.getText();
    7166                        int i = cur.indexOf(' ');
    7267                        if (i != -1)
     
    7469                        else
    7570                                cur += progStr;
    76                         currentAction.setText(cur);
     71                        Main.pleaseWaitDlg.currentAction.setText(cur);
    7772                }
    7873        }
  • src/org/openstreetmap/josm/plugins/Plugin.java

    r149 r153  
    1313 * (or else, the plugin jar will not be within the class path).
    1414 *
    15  * All plugins should have at least one class subclassing this abstract base class. 
    16  * 
     15 * All plugins should have at least one class subclassing this abstract base class.
     16 *
    1717 * The actual implementation of this interface is optional, as all functions will be called
    1818 * via reflection. This is to be able to change this interface without the need of recompiling
     
    2525 *
    2626 *
    27  * The pluginname provided to the constructor is also the name of the directory to 
     27 * The pluginname provided to the constructor is also the name of the directory to
    2828 * store the plugin's own stuff (located under the josm preferences directory)
    2929 *
     
    4040                name = s.substring(lastSlash+1, s.length()-4);
    4141    }
    42        
     42
    4343        /**
    4444         * @return The name of this plugin. This is the name of the .jar file.
     
    5454        }
    5555
    56        
     56
    5757
    5858        /**
     
    6262         */
    6363        public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {}
    64 
    65         /**
    66          * Called to retrieve a one-liner description of what this plugin does for tooltips.
    67          * @return <code>null</code>, which means: "no description available".
    68          */
    69         public String getDescription() {return null;}
    70 
    7164}
  • src/org/openstreetmap/josm/plugins/PluginProxy.java

    r149 r153  
    66/**
    77 * Helper class for the JOSM system to communicate with the plugin.
    8  * 
     8 *
    99 * This class should be of no interest for sole plugin writer.
    10  * 
     10 *
    1111 * @author Immanuel.Scholz
    1212 */
     
    1414
    1515        public final Object plugin;
    16         public final String name;
     16        public final PluginInformation info;
    1717        public boolean misbehaving = false;
    1818
    19         public PluginProxy(Object plugin, String name) {
     19        public PluginProxy(Object plugin, PluginInformation info) {
    2020                this.plugin = plugin;
    21                 this.name = name;
     21                this.info = info;
    2222    }
    2323
    24 
    25        
    2624        @Override public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
    2725                try {
    2826                plugin.getClass().getMethod("mapFrameInitialized", MapFrame.class, MapFrame.class).invoke(plugin, oldFrame, newFrame);
    2927        } catch (Exception e) {
    30                 throw new PluginException(this, name, e);
    31         }
    32     }
    33 
    34         @Override public String getDescription() {
    35             try {
    36                 return (String)plugin.getClass().getMethod("getDescription").invoke(plugin);
    37         } catch (NoSuchMethodException e) {
    38                 return super.getDescription();
    39         } catch (Exception e) {
    40                 throw new PluginException(this, name, e);
     28                throw new PluginException(this, info.name, e);
    4129        }
    4230    }
  • src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java

    r149 r153  
    2626/**
    2727 * An exception handler, that ask the user to send a bug report.
    28  * 
     28 *
    2929 * @author imi
    3030 */
    31 public final class BugReportExceptionHandler implements Thread.UncaughtExceptionHandler {       
     31public final class BugReportExceptionHandler implements Thread.UncaughtExceptionHandler {
    3232
    3333        public void uncaughtException(Thread t, Throwable e) {
     
    3838                                return;
    3939                        }
    40                        
     40
    4141                        if (e instanceof PluginException) {
    4242                                PluginProxy plugin = ((PluginException)e).getPlugin();
    4343                                if (plugin != null && !plugin.misbehaving) {
    44                                         JOptionPane.showMessageDialog(Main.parent, tr("The plugin {0} throwed an exception: {1}\nIt may be outdated. Please contact the plugin's autor.\nThis message will not shown again until JOSM is restarted.", plugin.name, e.getMessage()));
     44                                        JOptionPane.showMessageDialog(Main.parent, tr("The plugin {0} throwed an exception: {1}\nIt may be outdated. Please contact the plugin's autor.\nThis message will not shown again until JOSM is restarted.", plugin.info.name, e.getMessage()));
    4545                                        plugin.misbehaving = true;
    4646                                        return;
    4747                                }
    4848                        }
    49                        
     49
    5050                        Object[] options = new String[]{tr("Do nothing"), tr("Report Bug")};
    5151                        int answer = JOptionPane.showOptionDialog(Main.parent, tr("An unexpected exception occoured.\n\n" +
Note: See TracChangeset for help on using the changeset viewer.