Changeset 6797 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2014-02-01T02:15:45+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #9406 - Verify for new versions of plugins on crashes

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

Legend:

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

    r6730 r6797  
    377377        });
    378378
    379         List<PluginInformation> pluginsToLoad = PluginHandler.buildListOfPluginsToLoad(splash,monitor.createSubTaskMonitor(1, false));
     379        Collection<PluginInformation> pluginsToLoad = PluginHandler.buildListOfPluginsToLoad(splash,monitor.createSubTaskMonitor(1, false));
    380380        if (!pluginsToLoad.isEmpty() && PluginHandler.checkAndConfirmPluginUpdate(splash)) {
    381381            monitor.subTask(tr("Updating plugins"));
    382             pluginsToLoad = PluginHandler.updatePlugins(splash,pluginsToLoad, monitor.createSubTaskMonitor(1, false));
     382            pluginsToLoad = PluginHandler.updatePlugins(splash, null, monitor.createSubTaskMonitor(1, false));
    383383        }
    384384
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java

    r6666 r6797  
    66
    77import java.awt.BorderLayout;
     8import java.awt.Component;
    89import java.awt.GridBagConstraints;
    910import java.awt.GridBagLayout;
     
    113114        return sb.toString();
    114115    }
     116   
     117    /**
     118     * Notifies user about result of a finished plugin download task.
     119     * @param parent The parent component
     120     * @param task The finished plugin download task
     121     * @since 6797
     122     */
     123    public static void notifyDownloadResults(final Component parent, PluginDownloadTask task) {
     124        final Collection<PluginInformation> downloaded = task.getDownloadedPlugins();
     125        final Collection<PluginInformation> failed = task.getFailedPlugins();
     126        final StringBuilder sb = new StringBuilder();
     127        sb.append("<html>");
     128        sb.append(buildDownloadSummary(task));
     129        if (!downloaded.isEmpty()) {
     130            sb.append(tr("Please restart JOSM to activate the downloaded plugins."));
     131        }
     132        sb.append("</html>");
     133        GuiHelper.runInEDTAndWait(new Runnable() {
     134            @Override
     135            public void run() {
     136                HelpAwareOptionPane.showOptionDialog(
     137                        parent,
     138                        sb.toString(),
     139                        tr("Update plugins"),
     140                        !failed.isEmpty() ? JOptionPane.WARNING_MESSAGE : JOptionPane.INFORMATION_MESSAGE,
     141                                HelpUtil.ht("/Preferences/Plugins")
     142                        );
     143            }
     144        });
     145    }
    115146
    116147    private JosmTextField tfFilter;
     
    327358        }
    328359
    329         protected void notifyDownloadResults(PluginDownloadTask task) {
    330             final Collection<PluginInformation> downloaded = task.getDownloadedPlugins();
    331             final Collection<PluginInformation> failed = task.getFailedPlugins();
    332             final StringBuilder sb = new StringBuilder();
    333             sb.append("<html>");
    334             sb.append(buildDownloadSummary(task));
    335             if (!downloaded.isEmpty()) {
    336                 sb.append(tr("Please restart JOSM to activate the downloaded plugins."));
    337             }
    338             sb.append("</html>");
    339             GuiHelper.runInEDTAndWait(new Runnable() {
    340                 @Override
    341                 public void run() {
    342                     HelpAwareOptionPane.showOptionDialog(
    343                             pnlPluginPreferences,
    344                             sb.toString(),
    345                             tr("Update plugins"),
    346                             !failed.isEmpty() ? JOptionPane.WARNING_MESSAGE : JOptionPane.INFORMATION_MESSAGE,
    347                                     HelpUtil.ht("/Preferences/Plugins")
    348                             );
    349                 }
    350             });
    351         }
    352 
    353360        protected void alertNothingToUpdate() {
    354361            try {
     
    391398                    if (pluginDownloadTask.isCanceled())
    392399                        return;
    393                     notifyDownloadResults(pluginDownloadTask);
     400                    notifyDownloadResults(pnlPluginPreferences, pluginDownloadTask);
    394401                    model.refreshLocalPluginVersion(pluginDownloadTask.getDownloadedPlugins());
    395402                    model.clearPendingPlugins(pluginDownloadTask.getDownloadedPlugins());
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r6643 r6797  
    3232import java.util.Set;
    3333import java.util.TreeSet;
     34import java.util.concurrent.Callable;
    3435import java.util.concurrent.ExecutionException;
    3536import java.util.concurrent.ExecutorService;
    3637import java.util.concurrent.Executors;
    3738import java.util.concurrent.Future;
     39import java.util.concurrent.FutureTask;
    3840import java.util.jar.JarFile;
    3941
     
    5860import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    5961import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     62import org.openstreetmap.josm.gui.util.GuiHelper;
    6063import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    6164import org.openstreetmap.josm.gui.widgets.JosmTextArea;
    62 import org.openstreetmap.josm.tools.CheckParameterUtil;
    6365import org.openstreetmap.josm.tools.GBC;
    6466import org.openstreetmap.josm.tools.I18n;
     
    183185     * List of unmaintained plugins. Not really up-to-date as the vast majority of plugins are not really maintained after a few months, sadly...
    184186     */
    185     final public static String [] UNMAINTAINED_PLUGINS = new String[] {"gpsbabelgui", "Intersect_way"};
     187    public static final String [] UNMAINTAINED_PLUGINS = new String[] {"gpsbabelgui", "Intersect_way"};
    186188
    187189    /**
     
    208210        }
    209211    }
     212   
     213    private static PluginDownloadTask pluginDownloadTask = null;
    210214
    211215    public static Collection<ClassLoader> getResourceClassLoaders() {
     
    819823     *
    820824     * @param parent the parent component for message boxes
    821      * @param plugins the collection of plugins to update. Must not be null.
     825     * @param pluginsWanted the collection of plugins to update. Updates all plugins if {@code null}
    822826     * @param monitor the progress monitor. Defaults to {@link NullProgressMonitor#INSTANCE} if null.
    823827     * @throws IllegalArgumentException thrown if plugins is null
    824828     */
    825     public static List<PluginInformation> updatePlugins(Component parent,
    826             List<PluginInformation> plugins, ProgressMonitor monitor)
    827             throws IllegalArgumentException{
    828         CheckParameterUtil.ensureParameterNotNull(plugins, "plugins");
     829    public static Collection<PluginInformation> updatePlugins(Component parent,
     830            Collection<PluginInformation> pluginsWanted, ProgressMonitor monitor)
     831            throws IllegalArgumentException {
     832        Collection<PluginInformation> plugins = null;
     833        pluginDownloadTask = null;
    829834        if (monitor == null) {
    830835            monitor = NullProgressMonitor.INSTANCE;
     
    847852                allPlugins = task1.getAvailablePlugins();
    848853                plugins = buildListOfPluginsToLoad(parent,monitor.createSubTaskMonitor(1, false));
     854                // If only some plugins have to be updated, filter the list
     855                if (pluginsWanted != null && !pluginsWanted.isEmpty()) {
     856                    for (Iterator<PluginInformation> it = plugins.iterator(); it.hasNext();) {
     857                        PluginInformation pi = it.next();
     858                        boolean found = false;
     859                        for (PluginInformation piw : pluginsWanted) {
     860                            if (pi.name.equals(piw.name)) {
     861                                found = true;
     862                                break;
     863                            }
     864                        }
     865                        if (!found) {
     866                            it.remove();
     867                        }
     868                    }
     869                }
    849870            } catch (ExecutionException e) {
    850871                Main.warn(tr("Failed to download plugin information list")+": ExecutionException");
     
    886907                // try to update the locally installed plugins
    887908                //
    888                 PluginDownloadTask task2 = new PluginDownloadTask(
     909                pluginDownloadTask = new PluginDownloadTask(
    889910                        monitor.createSubTaskMonitor(1,false),
    890911                        pluginsToDownload,
     
    892913                );
    893914
    894                 future = service.submit(task2);
     915                future = service.submit(pluginDownloadTask);
    895916                try {
    896917                    future.get();
     
    907928                // Update Plugin info for downloaded plugins
    908929                //
    909                 refreshLocalUpdatedPluginInfo(task2.getDownloadedPlugins());
     930                refreshLocalUpdatedPluginInfo(pluginDownloadTask.getDownloadedPlugins());
    910931
    911932                // notify user if downloading a locally installed plugin failed
    912933                //
    913                 if (! task2.getFailedPlugins().isEmpty()) {
    914                     alertFailedPluginUpdate(parent, task2.getFailedPlugins());
     934                if (! pluginDownloadTask.getFailedPlugins().isEmpty()) {
     935                    alertFailedPluginUpdate(parent, pluginDownloadTask.getFailedPlugins());
    915936                    return plugins;
    916937                }
     
    919940            monitor.finishTask();
    920941        }
    921         // remember the update because it was successful
    922         //
    923         Main.pref.putInteger("pluginmanager.version", Version.getInstance().getVersion());
    924         Main.pref.put("pluginmanager.lastupdate", Long.toString(System.currentTimeMillis()));
     942        if (pluginsWanted == null) {
     943            // if all plugins updated, remember the update because it was successful
     944            //
     945            Main.pref.putInteger("pluginmanager.version", Version.getInstance().getVersion());
     946            Main.pref.put("pluginmanager.lastupdate", Long.toString(System.currentTimeMillis()));
     947        }
    925948        return plugins;
    926949    }
     
    10941117    }
    10951118
    1096     private static boolean confirmDeactivatingPluginAfterException(PluginProxy plugin) {
    1097         ButtonSpec [] options = new ButtonSpec[] {
     1119    private static int askUpdateDisableKeepPluginAfterException(PluginProxy plugin) {
     1120        final ButtonSpec[] options = new ButtonSpec[] {
     1121                new ButtonSpec(
     1122                        tr("Update plugin"),
     1123                        ImageProvider.get("dialogs", "refresh"),
     1124                        tr("Click to update the plugin ''{0}''", plugin.getPluginInformation().name),
     1125                        null /* no specific help context */
     1126                ),
    10981127                new ButtonSpec(
    10991128                        tr("Disable plugin"),
     
    11101139        };
    11111140
    1112         StringBuffer msg = new StringBuffer();
     1141        final StringBuffer msg = new StringBuffer();
    11131142        msg.append("<html>");
    11141143        msg.append(tr("An unexpected exception occurred that may have come from the ''{0}'' plugin.", plugin.getPluginInformation().name));
    11151144        msg.append("<br>");
    1116         if(plugin.getPluginInformation().author != null) {
     1145        if (plugin.getPluginInformation().author != null) {
    11171146            msg.append(tr("According to the information within the plugin, the author is {0}.", plugin.getPluginInformation().author));
    11181147            msg.append("<br>");
    11191148        }
    11201149        msg.append(tr("Try updating to the newest version of this plugin before reporting a bug."));
    1121         msg.append("<br>");
    1122         msg.append(tr("Should the plugin be disabled?"));
    11231150        msg.append("</html>");
    11241151
    1125         int ret = HelpAwareOptionPane.showOptionDialog(
    1126                 Main.parent,
    1127                 msg.toString(),
    1128                 tr("Update plugins"),
    1129                 JOptionPane.QUESTION_MESSAGE,
    1130                 null,
    1131                 options,
    1132                 options[0],
    1133                 ht("/ErrorMessages#ErrorInPlugin")
    1134         );
    1135         return ret == 0;
     1152        try {
     1153            FutureTask<Integer> task = new FutureTask<Integer>(new Callable<Integer>() {
     1154                @Override
     1155                public Integer call() {
     1156                    return HelpAwareOptionPane.showOptionDialog(
     1157                            Main.parent,
     1158                            msg.toString(),
     1159                            tr("Update plugins"),
     1160                            JOptionPane.QUESTION_MESSAGE,
     1161                            null,
     1162                            options,
     1163                            options[0],
     1164                            ht("/ErrorMessages#ErrorInPlugin")
     1165                    );
     1166                }
     1167            });
     1168            GuiHelper.runInEDT(task);
     1169            return task.get();
     1170        } catch (InterruptedException e) {
     1171            Main.warn(e);
     1172        } catch (ExecutionException e) {
     1173            Main.warn(e);
     1174        }
     1175        return -1;
    11361176    }
    11371177
     
    11631203    /**
    11641204     * Checks whether the exception <code>e</code> was thrown by a plugin. If so,
    1165      * conditionally deactivates the plugin, but asks the user first.
     1205     * conditionally updates or deactivates the plugin, but asks the user first.
    11661206     *
    11671207     * @param e the exception
    1168      */
    1169     public static void disablePluginAfterException(Throwable e) {
     1208     * @return plugin download task if the plugin has been updated to a newer version, {@code null} if it has been disabled or kept as it
     1209     */
     1210    public static PluginDownloadTask updateOrdisablePluginAfterException(Throwable e) {
    11701211        PluginProxy plugin = null;
    11711212        // Check for an explicit problem when calling a plugin function
     
    11781219        if (plugin == null)
    11791220            // don't know what plugin threw the exception
    1180             return;
     1221            return null;
    11811222
    11821223        Set<String> plugins = new HashSet<String>(
    11831224                Main.pref.getCollection("plugins",Collections.<String> emptySet())
    11841225        );
    1185         if (! plugins.contains(plugin.getPluginInformation().name))
     1226        final PluginInformation pluginInfo = plugin.getPluginInformation();
     1227        if (! plugins.contains(pluginInfo.name))
    11861228            // plugin not activated ? strange in this context but anyway, don't bother
    11871229            // the user with dialogs, skip conditional deactivation
    1188             return;
    1189 
    1190         if (!confirmDeactivatingPluginAfterException(plugin))
     1230            return null;
     1231
     1232        switch (askUpdateDisableKeepPluginAfterException(plugin)) {
     1233        case 0:
     1234            // update the plugin
     1235            updatePlugins(Main.parent, Collections.singleton(pluginInfo), null);
     1236            return pluginDownloadTask;
     1237        case 1:
     1238            // deactivate the plugin
     1239            plugins.remove(plugin.getPluginInformation().name);
     1240            Main.pref.putCollection("plugins", plugins);
     1241            GuiHelper.runInEDTAndWait(new Runnable() {
     1242                @Override
     1243                public void run() {
     1244                    JOptionPane.showMessageDialog(
     1245                            Main.parent,
     1246                            tr("The plugin has been removed from the configuration. Please restart JOSM to unload the plugin."),
     1247                            tr("Information"),
     1248                            JOptionPane.INFORMATION_MESSAGE
     1249                    );
     1250                }
     1251            });
     1252            return null;
     1253        default:
    11911254            // user doesn't want to deactivate the plugin
    1192             return;
    1193 
    1194         // deactivate the plugin
    1195         plugins.remove(plugin.getPluginInformation().name);
    1196         Main.pref.putCollection("plugins", plugins);
    1197         JOptionPane.showMessageDialog(
    1198                 Main.parent,
    1199                 tr("The plugin has been removed from the configuration. Please restart JOSM to unload the plugin."),
    1200                 tr("Information"),
    1201                 JOptionPane.INFORMATION_MESSAGE
    1202         );
    1203         return;
     1255            return null;
     1256        }
    12041257    }
    12051258
  • trunk/src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java

    r6643 r6797  
    2424import org.openstreetmap.josm.actions.ShowStatusReportAction;
    2525import org.openstreetmap.josm.gui.ExtendedDialog;
     26import org.openstreetmap.josm.gui.preferences.plugin.PluginPreference;
    2627import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    2728import org.openstreetmap.josm.gui.widgets.JosmTextArea;
    2829import org.openstreetmap.josm.gui.widgets.UrlLabel;
     30import org.openstreetmap.josm.plugins.PluginDownloadTask;
    2931import org.openstreetmap.josm.plugins.PluginHandler;
    3032
     
    3739
    3840    private static boolean handlingInProgress = false;
     41    private static BugReporterThread bugReporterThread = null;
    3942    private static int exceptionCounter = 0;
    4043    private static boolean suppressExceptionDialogs = false;
     44   
     45    private static class BugReporterThread extends Thread {
     46       
     47        final Throwable e;
     48       
     49        public BugReporterThread(Throwable t) {
     50            super("Bug Reporter");
     51            this.e = t;
     52        }
     53
     54        @Override
     55        public void run() {
     56         // Give the user a chance to deactivate the plugin which threw the exception (if it was thrown from a plugin)
     57            final PluginDownloadTask pluginDownloadTask = PluginHandler.updateOrdisablePluginAfterException(e);
     58
     59            SwingUtilities.invokeLater(new Runnable() {
     60                @Override
     61                public void run() {
     62                    // Then ask for submitting a bug report, for exceptions thrown from a plugin too, unless updated to a new version
     63                    if (pluginDownloadTask == null) {
     64                        ExtendedDialog ed = new ExtendedDialog(Main.parent, tr("Unexpected Exception"), new String[] {tr("Do nothing"), tr("Report Bug")});
     65                        ed.setIcon(JOptionPane.ERROR_MESSAGE);
     66                        JPanel pnl = new JPanel(new GridBagLayout());
     67                        pnl.add(new JLabel(
     68                                "<html>" + tr("An unexpected exception occurred.<br>" +
     69                                              "This is always a coding error. If you are running the latest<br>" +
     70                                              "version of JOSM, please consider being kind and file a bug report."
     71                                              )
     72                                         + "</html>"), GBC.eol());
     73                        JCheckBox cbSuppress = null;
     74                        if (exceptionCounter > 1) {
     75                            cbSuppress = new JCheckBox(tr("Suppress further error dialogs for this session."));
     76                            pnl.add(cbSuppress, GBC.eol());
     77                        }
     78                        ed.setContent(pnl);
     79                        ed.showDialog();
     80                        if (cbSuppress != null && cbSuppress.isSelected()) {
     81                            suppressExceptionDialogs = true;
     82                        }
     83                        if (ed.getValue() != 2) return;
     84                        askForBugReport(e);
     85                    } else {
     86                        // Ask for restart to install new plugin
     87                        PluginPreference.notifyDownloadResults(Main.parent, pluginDownloadTask);
     88                    }
     89                }
     90            });
     91        }
     92    }
    4193
    4294    @Override
     
    59111     */
    60112    public static void handleException(final Throwable e) {
    61         if (handlingInProgress)
     113        if (handlingInProgress || suppressExceptionDialogs)
    62114            return;                  // we do not handle secondary exceptions, this gets too messy
    63         if (suppressExceptionDialogs)
     115        if (bugReporterThread != null && bugReporterThread.isAlive())
    64116            return;
    65117        handlingInProgress = true;
     
    80132                }
    81133
    82 
    83                 SwingUtilities.invokeLater(new Runnable() {
    84                     @Override
    85                     public void run() {
    86                         // Give the user a chance to deactivate the plugin which threw the exception (if it
    87                         // was thrown from a plugin)
    88                         //
    89                         PluginHandler.disablePluginAfterException(e);
    90 
    91                         // Then ask for submitting a bug report, for exceptions thrown from a plugin too
    92                         //
    93                         ExtendedDialog ed = new ExtendedDialog(Main.parent, tr("Unexpected Exception"), new String[] {tr("Do nothing"), tr("Report Bug")});
    94                         ed.setIcon(JOptionPane.ERROR_MESSAGE);
    95                         JPanel pnl = new JPanel(new GridBagLayout());
    96                         pnl.add(new JLabel(
    97                                 "<html>"
    98                                         + tr("An unexpected exception occurred.<br>" +
    99                                                 "This is always a coding error. If you are running the latest<br>" +
    100                                                 "version of JOSM, please consider being kind and file a bug report."
    101                                                 )
    102                                                 + "</html>"), GBC.eol());
    103                         JCheckBox cbSuppress = null;
    104                         if (exceptionCounter > 1) {
    105                             cbSuppress = new JCheckBox(tr("Suppress further error dialogs for this session."));
    106                             pnl.add(cbSuppress, GBC.eol());
    107                         }
    108                         ed.setContent(pnl);
    109                         ed.showDialog();
    110                         if (cbSuppress != null && cbSuppress.isSelected()) {
    111                             suppressExceptionDialogs = true;
    112                         }
    113                         if (ed.getValue() != 2) return;
    114 
    115                         try {
    116                             final int maxlen = 6000;
    117                             StringWriter stack = new StringWriter();
    118                             e.printStackTrace(new PrintWriter(stack));
    119 
    120                             String text = ShowStatusReportAction.getReportHeader()
    121                                     + stack.getBuffer().toString();
    122                             String urltext = text.replaceAll("\r",""); /* strip useless return chars */
    123                             if(urltext.length() > maxlen)
    124                             {
    125                                 urltext = urltext.substring(0,maxlen);
    126                                 int idx = urltext.lastIndexOf('\n');
    127                                 /* cut whole line when not loosing too much */
    128                                 if(maxlen-idx < 200) {
    129                                     urltext = urltext.substring(0,idx+1);
    130                                 }
    131                                 urltext += "...<snip>...\n";
    132                             }
    133 
    134                             JPanel p = new JPanel(new GridBagLayout());
    135                             p.add(new JMultilineLabel(
    136                                     tr("You have encountered an error in JOSM. Before you file a bug report " +
    137                                             "make sure you have updated to the latest version of JOSM here:")), GBC.eol());
    138                             p.add(new UrlLabel(Main.JOSM_WEBSITE,2), GBC.eop().insets(8,0,0,0));
    139                             p.add(new JMultilineLabel(
    140                                     tr("You should also update your plugins. If neither of those help please " +
    141                                             "file a bug report in our bugtracker using this link:")), GBC.eol());
    142                             p.add(getBugReportUrlLabel(urltext), GBC.eop().insets(8,0,0,0));
    143                             p.add(new JMultilineLabel(
    144                                     tr("There the error information provided below should already be " +
    145                                             "filled in for you. Please include information on how to reproduce " +
    146                                             "the error and try to supply as much detail as possible.")), GBC.eop());
    147                             p.add(new JMultilineLabel(
    148                                     tr("Alternatively, if that does not work you can manually fill in the information " +
    149                                             "below at this URL:")), GBC.eol());
    150                             p.add(new UrlLabel(Main.JOSM_WEBSITE+"/newticket",2), GBC.eop().insets(8,0,0,0));
    151                             if (Utils.copyToClipboard(text)) {
    152                                 p.add(new JLabel(tr("(The text has already been copied to your clipboard.)")), GBC.eop());
    153                             }
    154 
    155                             JosmTextArea info = new JosmTextArea(text, 18, 60);
    156                             info.setCaretPosition(0);
    157                             info.setEditable(false);
    158                             p.add(new JScrollPane(info), GBC.eop());
    159 
    160                             for (Component c: p.getComponents()) {
    161                                 if (c instanceof JMultilineLabel) {
    162                                     ((JMultilineLabel)c).setMaxWidth(400);
    163                                 }
    164                             }
    165 
    166                             JOptionPane.showMessageDialog(Main.parent, p, tr("You have encountered a bug in JOSM"), JOptionPane.ERROR_MESSAGE);
    167                         } catch (Exception e1) {
    168                             Main.error(e1);
    169                         }
    170                     }
    171                 });
     134                bugReporterThread = new BugReporterThread(e);
     135                bugReporterThread.start();
    172136            }
    173137        } finally {
    174138            handlingInProgress = false;
     139        }
     140    }
     141   
     142    private static void askForBugReport(final Throwable e) {
     143        try {
     144            final int maxlen = 6000;
     145            StringWriter stack = new StringWriter();
     146            e.printStackTrace(new PrintWriter(stack));
     147
     148            String text = ShowStatusReportAction.getReportHeader() + stack.getBuffer().toString();
     149            String urltext = text.replaceAll("\r","");
     150            if (urltext.length() > maxlen) {
     151                urltext = urltext.substring(0,maxlen);
     152                int idx = urltext.lastIndexOf('\n');
     153                // cut whole line when not loosing too much
     154                if (maxlen-idx < 200) {
     155                    urltext = urltext.substring(0,idx+1);
     156                }
     157                urltext += "...<snip>...\n";
     158            }
     159
     160            JPanel p = new JPanel(new GridBagLayout());
     161            p.add(new JMultilineLabel(
     162                    tr("You have encountered an error in JOSM. Before you file a bug report " +
     163                            "make sure you have updated to the latest version of JOSM here:")), GBC.eol());
     164            p.add(new UrlLabel(Main.JOSM_WEBSITE,2), GBC.eop().insets(8,0,0,0));
     165            p.add(new JMultilineLabel(
     166                    tr("You should also update your plugins. If neither of those help please " +
     167                            "file a bug report in our bugtracker using this link:")), GBC.eol());
     168            p.add(getBugReportUrlLabel(urltext), GBC.eop().insets(8,0,0,0));
     169            p.add(new JMultilineLabel(
     170                    tr("There the error information provided below should already be " +
     171                            "filled in for you. Please include information on how to reproduce " +
     172                            "the error and try to supply as much detail as possible.")), GBC.eop());
     173            p.add(new JMultilineLabel(
     174                    tr("Alternatively, if that does not work you can manually fill in the information " +
     175                            "below at this URL:")), GBC.eol());
     176            p.add(new UrlLabel(Main.JOSM_WEBSITE+"/newticket",2), GBC.eop().insets(8,0,0,0));
     177            if (Utils.copyToClipboard(text)) {
     178                p.add(new JLabel(tr("(The text has already been copied to your clipboard.)")), GBC.eop());
     179            }
     180
     181            JosmTextArea info = new JosmTextArea(text, 18, 60);
     182            info.setCaretPosition(0);
     183            info.setEditable(false);
     184            p.add(new JScrollPane(info), GBC.eop());
     185
     186            for (Component c: p.getComponents()) {
     187                if (c instanceof JMultilineLabel) {
     188                    ((JMultilineLabel)c).setMaxWidth(400);
     189                }
     190            }
     191
     192            JOptionPane.showMessageDialog(Main.parent, p, tr("You have encountered a bug in JOSM"), JOptionPane.ERROR_MESSAGE);
     193        } catch (Exception e1) {
     194            Main.error(e1);
    175195        }
    176196    }
Note: See TracChangeset for help on using the changeset viewer.