Changeset 3525 in josm
- Timestamp:
- 2010-09-13T21:41:49+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r3518 r3525 7 7 import java.awt.BorderLayout; 8 8 import java.awt.Component; 9 import java.awt.Dialog.ModalityType; 9 10 import java.awt.Font; 10 11 import java.awt.GridBagLayout; 11 12 import java.awt.Point; 12 import java.awt.Dialog.ModalityType;13 13 import java.awt.event.ActionEvent; 14 14 import java.awt.event.ActionListener; … … 18 18 import java.awt.event.MouseAdapter; 19 19 import java.awt.event.MouseEvent; 20 import java.net.HttpURLConnection; 21 import java.net.URI; 20 22 import java.util.ArrayList; 21 23 import java.util.Collection; … … 26 28 import java.util.List; 27 29 import java.util.Map; 30 import java.util.Vector; 28 31 import java.util.TreeMap; 29 import java.util.Vector;30 32 import java.util.Map.Entry; 31 33 … … 86 88 import org.openstreetmap.josm.tools.GBC; 87 89 import org.openstreetmap.josm.tools.ImageProvider; 90 import org.openstreetmap.josm.tools.LanguageInfo; 91 import org.openstreetmap.josm.tools.OpenBrowser; 88 92 import org.openstreetmap.josm.tools.Shortcut; 89 93 … … 705 709 buttonPanel.add(this.btnDel); 706 710 add(buttonPanel, BorderLayout.SOUTH); 711 712 // -- help action 713 // 714 HelpAction helpAction = new HelpAction(); 715 propertyTable.getSelectionModel().addListSelectionListener(helpAction); 716 getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( 717 KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), "onHelp"); 718 getActionMap().put("onHelp", helpAction); 707 719 } 708 720 … … 1022 1034 } 1023 1035 1036 class HelpAction extends AbstractAction implements ListSelectionListener { 1037 public HelpAction() { 1038 putValue(NAME, tr("Help")); 1039 putValue(SHORT_DESCRIPTION, tr("Launch browser with wiki help to selected object")); 1040 updateEnabledState(); 1041 } 1042 1043 public void actionPerformed(ActionEvent e) { 1044 if (!isEnabled()) 1045 return; 1046 1047 try { 1048 String base = new String(Main.pref.get("url.openstreetmap-wiki", "http://wiki.openstreetmap.org/wiki/")); 1049 String l = LanguageInfo.getWikiLanguagePrefix(); 1050 List<URI> uris = new ArrayList<URI>(); 1051 1052 int row; 1053 if (propertyTable.getSelectedRowCount() == 1) { 1054 row = propertyTable.getSelectedRow(); 1055 String key = propertyData.getValueAt(row, 0).toString(); 1056 @SuppressWarnings("unchecked") 1057 String val = ((Map<String,Integer>)propertyData.getValueAt(row, 1)).entrySet().iterator().next().getKey(); 1058 1059 uris.add(new URI(String.format("%s%sTag:%s=%s", base, l, key, val))); 1060 uris.add(new URI(String.format("%sTag:%s=%s", base, key, val))); 1061 uris.add(new URI(String.format("%s%sKey:%s", base, l, key))); 1062 uris.add(new URI(String.format("%sKey:%s", base, key))); 1063 uris.add(new URI(String.format("%s%sMap_Features", base, l))); 1064 uris.add(new URI(String.format("%sMap_Features", base))); 1065 } else if (membershipTable.getSelectedRowCount() == 1) { 1066 row = membershipTable.getSelectedRow(); 1067 String type = ((Relation)membershipData.getValueAt(row, 0)).get("type"); 1068 1069 if (type != null && !type.equals("")) { 1070 uris.add(new URI(String.format("%s%sRelation:%s", base, l, type))); 1071 uris.add(new URI(String.format("%sRelation:%s", base, type))); 1072 } 1073 uris.add(new URI(String.format("%s%sRelations", base, l))); 1074 uris.add(new URI(String.format("%sRelations", base))); 1075 } 1076 1077 // find a page that actually exists in the wiki 1078 URI uri = null; 1079 for (URI u : uris) { 1080 System.out.println("INFO: looking for " + u); 1081 if (((HttpURLConnection) u.toURL().openConnection()).getResponseCode() == 200) { 1082 uri = u; 1083 break; 1084 } 1085 } 1086 1087 // browse the help page 1088 if (uri != null) { 1089 System.out.println("INFO: browsing to url " + uri); 1090 OpenBrowser.displayUrl(uri); 1091 } 1092 } catch (Exception e1) { 1093 e1.printStackTrace(); 1094 } 1095 } 1096 1097 protected void updateEnabledState() { 1098 setEnabled( 1099 propertyTable.getSelectedRowCount() == 1 1100 ^ membershipTable.getSelectedRowCount() == 1 1101 ); 1102 } 1103 1104 public void valueChanged(ListSelectionEvent e) { 1105 updateEnabledState(); 1106 } 1107 } 1108 1024 1109 static class SelectRelationAction extends AbstractAction { 1025 1110 boolean selectionmode;
Note:
See TracChangeset
for help on using the changeset viewer.