Changeset 202 in josm


Ignore:
Timestamp:
2007-02-15T17:32:41+01:00 (17 years ago)
Author:
imi
Message:
  • fixed Bug with AnnotationPresets not loading values-tag properly
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • data

    • Property svn:ignore set to
      *
  • src/org/openstreetmap/josm/gui/annotation/AnnotationPreset.java

    r193 r202  
    9595                public String text;
    9696                public String values;
    97                 public String display_values = "";
     97                public String display_values;
    9898                public String default_;
    9999                public boolean delete_if_empty = false;
     
    103103
    104104                public void addToPanel(JPanel p) {
    105                         combo = new JComboBox(display_values.split(","));
     105                        combo = new JComboBox((display_values != null ? display_values : values).split(","));
    106106                        combo.setEditable(editable);
    107107                        combo.setSelectedItem(default_);
  • src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r201 r202  
    181181                instance.addMouseListener(new MouseAdapter(){
    182182                        private void openPopup(MouseEvent e) {
     183                                Point p = listScrollPane.getMousePosition();
     184                                if (p == null)
     185                                        return; // user is faster than swing with mouse movement
    183186                                int index = instance.locationToIndex(e.getPoint());
    184187                                Layer layer = (Layer)instance.getModel().getElementAt(index);
    185188                                LayerListPopup menu = new LayerListPopup(instance, layer);
    186                                 Point p = listScrollPane.getMousePosition();
    187189                                menu.show(listScrollPane, p.x, p.y-3);
    188190                        }
  • src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java

    r172 r202  
    1212import java.text.DateFormat;
    1313import java.text.SimpleDateFormat;
     14import java.util.Arrays;
    1415import java.util.Date;
     16import java.util.LinkedList;
    1517
    1618import javax.swing.JLabel;
     
    3941                        }
    4042
     43                        // Check for an explicit problem when calling a plugin function
    4144                        if (e instanceof PluginException) {
    4245                                PluginProxy plugin = ((PluginException)e).getPlugin();
     
    4851                        }
    4952
     53                        // Try a heuristic to guess whether the problem may be within a plugin
     54                        String pluginName = guessPlugin(e);
     55                        if (pluginName != null) {
     56                                LinkedList<String> plugins = new LinkedList<String>(Arrays.asList(Main.pref.get("plugins").split(",")));
     57                                if (plugins.contains(pluginName)) {
     58                                        String author = findPluginAuthor(pluginName);
     59                                        int answer = JOptionPane.showConfirmDialog(
     60                                                        Main.parent,
     61                                                        tr("An unexpected exception occoured, that may come from in the ''{0}'' plugin.", pluginName)+"\n"+
     62                                                                (author != null ? tr("According to the information within the plugin, the author is {0}.", author) : "")+"\n"+
     63                                                                tr("Should the plugin be disabled?"),
     64                                                        tr("Disable plugin"),
     65                                                        JOptionPane.YES_NO_OPTION);
     66                                        if (answer == JOptionPane.OK_OPTION) {
     67                                                plugins.remove(pluginName);
     68                                                String p = "";
     69                                                for (String s : plugins)
     70                                                        p += ","+s;
     71                                                if (p.length() > 0)
     72                                                        p = p.substring(1);
     73                                                Main.pref.put("plugins", p);
     74                                                JOptionPane.showMessageDialog(Main.parent, tr("The plugin has been removed from the configuration. Please restart JOSM to unload the plugin."));
     75                                                return;
     76                                        }
     77                                }
     78                        }
     79
    5080                        Object[] options = new String[]{tr("Do nothing"), tr("Report Bug")};
    5181                        int answer = JOptionPane.showOptionDialog(Main.parent, tr("An unexpected exception occoured.\n\n" +
    5282                                        "This is always a coding error. If you are running the latest\n" +
    53                                         "version of JOSM, please consider be kind and file a bug report."),
    54                                         tr("Unexpected Exception"), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE,
    55                                         null, options, options[0]);
     83                        "version of JOSM, please consider be kind and file a bug report."),
     84                        tr("Unexpected Exception"), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE,
     85                        null, options, options[0]);
    5686                        if (answer == 1) {
    5787                                try {
     
    97127                }
    98128        }
     129
     130        /**
     131         * Try to find the author of the given plugin. Return <code>null</code>
     132         * if no author specified or the plugin is not found.
     133         */
     134        private String findPluginAuthor(String pluginName) {
     135                for (PluginProxy proxy : Main.plugins)
     136                        if (pluginName.equals(proxy.info.name))
     137                                return proxy.info.author;
     138                return null;
     139        }
     140
     141        /**
     142         * Analyze the stack of the argument and return a name of a plugin, if
     143         * some known problem pattern has been found or <code>null</code>, if
     144         * the stack does not contain plugin-code.
     145         *
     146         * Note: This heuristic is not meant as discrimination against specific
     147         * plugins, but only to stop the flood of similar bug reports about plugins.
     148         * Of course, plugin writers are free to install their own version of
     149         * an exception handler with their email address listed to receive
     150         * bug reports ;-).
     151         */
     152        private String guessPlugin(Throwable e) {
     153                for (StackTraceElement element : e.getStackTrace()) {
     154                        String c = element.getClassName();
     155                        if (c.contains("wmsplugin.") || c.contains(".WMSLayer"))
     156                                return "wmsplugin";
     157                        if (c.contains("landsat.") || c.contains(".LandsatLayer"))
     158                                return "landsat";
     159                        if (c.contains("mappaint."))
     160                                return "mappaint";
     161                        if (c.contains("annotationtester."))
     162                                return "annotation-tester";
     163                }
     164                return null;
     165        }
    99166}
Note: See TracChangeset for help on using the changeset viewer.