- Timestamp:
- 2012-11-17T18:19:03+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r5576 r5586 11 11 import java.awt.GridBagConstraints; 12 12 import java.awt.GridBagLayout; 13 import java.awt.Image; 13 14 import java.awt.Insets; 14 15 import java.awt.Rectangle; … … 45 46 import javax.swing.DefaultListModel; 46 47 import javax.swing.DefaultListSelectionModel; 48 import javax.swing.Icon; 49 import javax.swing.ImageIcon; 47 50 import javax.swing.JButton; 48 51 import javax.swing.JCheckBox; … … 75 78 import org.openstreetmap.josm.Main; 76 79 import org.openstreetmap.josm.actions.ExtensionFileFilter; 80 import org.openstreetmap.josm.data.Version; 77 81 import org.openstreetmap.josm.gui.ExtendedDialog; 78 82 import org.openstreetmap.josm.gui.HelpAwareOptionPane; … … 85 89 import org.openstreetmap.josm.tools.ImageProvider; 86 90 import org.openstreetmap.josm.tools.LanguageInfo; 91 import org.openstreetmap.josm.tools.Utils; 87 92 import org.xml.sax.SAXException; 88 93 … … 628 633 public String link; 629 634 public String description; 635 public Integer minJosmVersion; 630 636 631 637 public ExtendedSourceEntry(String simpleFileName, String url) { 632 638 super(url, null, null, true); 633 639 this.simpleFileName = simpleFileName; 634 version = author = link = description = title = null;635 640 } 636 641 … … 661 666 if (version != null) { 662 667 appendRow(s, tr("Version:"), version); 668 } 669 if (minJosmVersion != null) { 670 appendRow(s, tr("Minimum JOSM Version:"), Integer.toString(minJosmVersion)); 663 671 } 664 672 return "<html><style>th{text-align:right}td{width:400px}</style>" … … 925 933 public void actionPerformed(ActionEvent e) { 926 934 List<ExtendedSourceEntry> sources = availableSourcesModel.getSelected(); 935 int josmVersion = Version.getInstance().getVersion(); 936 if (josmVersion != Version.JOSM_UNKNOWN_VERSION) { 937 Collection<String> messages = new ArrayList<String>(); 938 for (ExtendedSourceEntry entry : sources) { 939 if (entry.minJosmVersion != null && entry.minJosmVersion > josmVersion) { 940 messages.add(tr("Entry ''{0}'' requires JOSM Version {1}. (Currently running: {2})", 941 entry.title, 942 Integer.toString(entry.minJosmVersion), 943 Integer.toString(josmVersion)) 944 ); 945 } 946 } 947 if (!messages.isEmpty()) { 948 ExtendedDialog dlg = new ExtendedDialog(Main.parent, tr("Warning"), new String [] { tr("Cancel"), tr("Continue anyway") }); 949 dlg.setButtonIcons(new Icon[] { 950 ImageProvider.get("cancel"), 951 ImageProvider.overlay( 952 ImageProvider.get("ok"), 953 new ImageIcon(ImageProvider.get("warning-small").getImage().getScaledInstance(12 , 12, Image.SCALE_SMOOTH)), 954 ImageProvider.OverlayPosition.SOUTHEAST) 955 }); 956 dlg.setToolTipTexts(new String[] { 957 tr("Cancel and return to the previous dialog"), 958 tr("Ignore warning and install style anyway")}); 959 dlg.setContent("<html>" + tr("Some entries have unmet dependencies:") + 960 "<br>" + Utils.join("<br>", messages) + "</html>"); 961 dlg.setIcon(JOptionPane.WARNING_MESSAGE); 962 if (dlg.showDialog().getValue() != 2) 963 return; 964 } 965 } 927 966 activeSourcesModel.addExtendedSourceEntries(sources); 928 967 } … … 1236 1275 } else if ((lang + "description").equals(key)) { 1237 1276 last.description = value; 1277 } else if ("min-josm-version".equals(key)) { 1278 try { 1279 last.minJosmVersion = Integer.parseInt(value); 1280 } catch (NumberFormatException e) { 1281 // ignore 1282 } 1238 1283 } 1239 1284 }
Note:
See TracChangeset
for help on using the changeset viewer.