Changeset 34671 in osm for applications/editors
- Timestamp:
- 2018-09-24T19:30:37+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/ModuleHandler.java
r34646 r34671 118 118 new ButtonSpec( 119 119 tr("Update modules"), 120 ImageProvider.get("dialogs", "refresh"),120 new ImageProvider("dialogs", "refresh"), 121 121 tr("Click to update the activated modules"), 122 122 null /* no specific help context */ … … 124 124 new ButtonSpec( 125 125 tr("Skip update"), 126 ImageProvider.get("cancel"),126 new ImageProvider("cancel"), 127 127 tr("Click to skip updating the activated modules"), 128 128 null /* no specific help context */ … … 512 512 new ButtonSpec( 513 513 tr("Disable module"), 514 ImageProvider.get("dialogs", "delete"),514 new ImageProvider("dialogs", "delete"), 515 515 tr("Click to delete the module ''{0}''", name), 516 516 null /* no specific help context */ … … 518 518 new ButtonSpec( 519 519 tr("Keep module"), 520 ImageProvider.get("cancel"),520 new ImageProvider("cancel"), 521 521 tr("Click to keep the module ''{0}''", name), 522 522 null /* no specific help context */ … … 536 536 } 537 537 538 /*public static Module getModule(String name) {539 for (Module module : moduleList)540 if (module.getModuleInformation().name.equals(name))541 return module;542 return null;543 }*/544 545 538 /** 546 539 * Installs downloaded modules. Moves files with the suffix ".jar.new" to the corresponding … … 585 578 } 586 579 587 /*private static boolean confirmDeactivatingModuleAfterException(Module module) {588 ButtonSpec [] options = new ButtonSpec[] {589 new ButtonSpec(590 tr("Disable module"),591 ImageProvider.get("dialogs", "delete"),592 tr("Click to disable the module ''{0}''", module.getModuleInformation().name),593 null // no specific help context594 ),595 new ButtonSpec(596 tr("Keep module"),597 ImageProvider.get("cancel"),598 tr("Click to keep the module ''{0}''",module.getModuleInformation().name),599 null // no specific help context600 )601 };602 603 StringBuffer msg = new StringBuffer();604 msg.append("<html>");605 msg.append(tr("An unexpected exception occurred that may have come from the ''{0}'' module.", module.getModuleInformation().name));606 msg.append("<br>");607 if(module.getModuleInformation().author != null) {608 msg.append(tr("According to the information within the module, the author is {0}.", module.getModuleInformation().author));609 msg.append("<br>");610 }611 msg.append(tr("Try updating to the newest version of this module before reporting a bug."));612 msg.append("<br>");613 msg.append(tr("Should the module be disabled?"));614 msg.append("</html>");615 616 int ret = HelpAwareOptionPane.showOptionDialog(617 MainApplication.getMainFrame(),618 msg.toString(),619 tr("Update modules"),620 JOptionPane.QUESTION_MESSAGE,621 null,622 options,623 options[0],624 null625 );626 return ret == 0;627 }*/628 629 /*630 * Replies the module which most likely threw the exception <code>ex</code>.631 *632 * @param ex the exception633 * @return the module; null, if the exception probably wasn't thrown from a module634 */635 /*private static Module getModuleCausingException(Throwable ex) {636 Module err = null;637 StackTraceElement[] stack = ex.getStackTrace();638 // remember the error position, as multiple modules may be involved,639 // we search the topmost one640 int pos = stack.length;641 for (Module p : moduleList) {642 String baseClass = p.getModuleInformation().className;643 baseClass = baseClass.substring(0, baseClass.lastIndexOf("."));644 for (int elpos = 0; elpos < pos; ++elpos) {645 if (stack[elpos].getClassName().startsWith(baseClass)) {646 pos = elpos;647 err = p;648 }649 }650 }651 return err;652 }*/653 654 /*655 * Checks whether the exception <code>e</code> was thrown by a module. If so,656 * conditionally deactivates the module, but asks the user first.657 *658 * @param e the exception659 */660 /*public static void disableModuleAfterException(Throwable e) {661 Module module = null;662 // Check for an explicit problem when calling a module function663 if (e instanceof ModuleException) {664 module = ((ModuleException) e).module;665 }666 if (module == null) {667 module = getModuleCausingException(e);668 }669 if (module == null)670 // don't know what module threw the exception671 return;672 673 Set<String> modules = new HashSet<String>(674 Config.getPref().getCollection(PREF_MODULES, Collections.<String> emptySet())675 );676 if (! modules.contains(module.getModuleInformation().name))677 // module not activated ? strange in this context but anyway, don't bother678 // the user with dialogs, skip conditional deactivation679 return;680 681 if (!confirmDeactivatingModuleAfterException(module))682 // user doesn't want to deactivate the module683 return;684 685 // deactivate the module686 modules.remove(module.getModuleInformation().name);687 Config.getPref().putCollection(PREF_MODULES, modules);688 JOptionPane.showMessageDialog(689 MainApplication.getMainFrame(),690 tr("The module has been removed from the configuration. Please restart JOSM to unload the module."),691 tr("Information"),692 JOptionPane.INFORMATION_MESSAGE693 );694 return;695 }*/696 697 /*public static String getBugReportText() {698 String text = "";699 LinkedList <String> pl = new LinkedList<String>(Config.getPref().getCollection(PREF_MODULES, new LinkedList<String>()));700 for (final Module pp : moduleList) {701 ModuleInformation pi = pp.getModuleInformation();702 pl.remove(pi.name);703 pl.add(pi.name + " (" + (pi.localversion != null && !pi.localversion.equals("")704 ? pi.localversion : "unknown") + ")");705 }706 Collections.sort(pl);707 for (String s : pl) {708 text += "Module: " + s + "\n";709 }710 return text;711 }*/712 713 /*public static JPanel getInfoPanel() {714 JPanel moduleTab = new JPanel(new GridBagLayout());715 for (final Module p : moduleList) {716 final ModuleInformation info = p.getModuleInformation();717 String name = info.name718 + (info.version != null && !info.version.equals("") ? " Version: " + info.version : "");719 moduleTab.add(new JLabel(name), GBC.std());720 moduleTab.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL));721 moduleTab.add(new JButton(new AbstractAction(tr("Information")) {722 public void actionPerformed(ActionEvent event) {723 StringBuilder b = new StringBuilder();724 for (Entry<String, String> e : info.attr.entrySet()) {725 b.append(e.getKey());726 b.append(": ");727 b.append(e.getValue());728 b.append("\n");729 }730 JTextArea a = new JTextArea(10, 40);731 a.setEditable(false);732 a.setText(b.toString());733 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), new JScrollPane(a), tr("Module information"),734 JOptionPane.INFORMATION_MESSAGE);735 }736 }), GBC.eol());737 738 JTextArea description = new JTextArea((info.description == null ? tr("no description available")739 : info.description));740 description.setEditable(false);741 description.setFont(new JLabel().getFont().deriveFont(Font.ITALIC));742 description.setLineWrap(true);743 description.setWrapStyleWord(true);744 description.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));745 description.setBackground(UIManager.getColor("Panel.background"));746 747 moduleTab.add(description, GBC.eop().fill(GBC.HORIZONTAL));748 }749 return moduleTab;750 }*/751 752 580 private static class UpdateModulesMessagePanel extends JPanel { 753 581 private JMultilineLabel lblMessage;
Note:
See TracChangeset
for help on using the changeset viewer.