Changeset 26694 in osm for applications/editors
- Timestamp:
- 2011-09-22T20:36:58+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/utilsplugin2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/build.xml
r26673 r26694 30 30 <project name="utilsplugin2" default="dist" basedir="."> 31 31 <!-- enter the SVN commit message --> 32 <property name="commit.message" value="Utilsplugin2: republish with JAR and JOSM>=4399"/>32 <property name="commit.message" value="Utilsplugin2: opening URL works without selected object"/> 33 33 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 34 34 <property name="plugin.main.version" value="4399"/> -
applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/ChooseURLAction.java
r26644 r26694 4 4 import java.awt.event.ItemEvent; 5 5 import java.util.List; 6 import java.util.logging.Level; 7 import java.util.logging.Logger; 6 8 import javax.swing.JComboBox; 7 9 import javax.swing.JPanel; 10 import javax.swing.event.ListSelectionEvent; 8 11 import org.openstreetmap.josm.gui.ExtendedDialog; 9 12 import org.openstreetmap.josm.tools.GBC; … … 11 14 import java.awt.event.ActionEvent; 12 15 import java.awt.event.ItemListener; 16 import java.awt.event.KeyEvent; 13 17 import javax.swing.JCheckBox; 14 18 import javax.swing.JLabel; 19 import javax.swing.JList; 15 20 import javax.swing.JTextField; 21 import javax.swing.ListSelectionModel; 22 import javax.swing.event.ListSelectionListener; 16 23 import org.openstreetmap.josm.actions.JosmAction; 24 import org.openstreetmap.josm.gui.SelectionManager; 17 25 import static org.openstreetmap.josm.tools.I18n.tr; 18 26 … … 26 34 @Override 27 35 public void actionPerformed(ActionEvent e) { 28 showConfigDialog( );36 showConfigDialog(false); 29 37 } 30 38 … … 38 46 } 39 47 40 public static void showConfigDialog( ) {48 public static void showConfigDialog(final boolean fast) { 41 49 JPanel all = new JPanel(); 42 50 GridBagLayout layout = new GridBagLayout(); … … 54 62 } 55 63 final JLabel label1=new JLabel(tr("Please select one of custom URLs (configured in Preferences)")); 56 final J ComboBox combo1=new JComboBox(names);64 final JList list1=new JList(names); 57 65 final JTextField editField=new JTextField(); 58 66 final JCheckBox check1=new JCheckBox(tr("Ask every time")); 59 67 60 61 combo1.addItemListener(new ItemListener() { 68 final ExtendedDialog dialog = new ExtendedDialog(Main.parent, 69 tr("Configure custom URL"), 70 new String[] {tr("OK"),tr("Cancel"),} 71 ); 72 list1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 73 list1.addListSelectionListener(new ListSelectionListener() { 62 74 @Override 63 public void itemStateChanged(ItemEvent e) {64 int idx= combo1.getSelectedIndex();75 public void valueChanged(ListSelectionEvent e) { 76 int idx=list1.getSelectedIndex(); 65 77 if (idx>=0) editField.setText(vals[idx]); 66 78 } 67 79 }); 68 combo1.setSelectedIndex(idxToSelect);80 list1.setSelectedIndex(idxToSelect); 69 81 check1.setSelected(Main.pref.getBoolean("utilsplugin2.askurl",false)); 70 82 … … 72 84 73 85 all.add(label1,GBC.eop().fill(GBC.HORIZONTAL).insets(15,5,15,0)); 74 all.add( combo1,GBC.eop().fill(GBC.HORIZONTAL).insets(5,5,0,0));86 all.add(list1,GBC.eop().fill(GBC.HORIZONTAL).insets(5,5,0,0)); 75 87 all.add(editField,GBC.eop().fill(GBC.HORIZONTAL).insets(5,5,0,0)); 76 88 all.add(check1,GBC.eop().fill(GBC.HORIZONTAL).insets(5,5,0,0)); 77 89 78 ExtendedDialog dialog = new ExtendedDialog(Main.parent, 79 tr("Configure custom URL"), 80 new String[] {tr("OK"),tr("Cancel"),} 81 ); 90 82 91 dialog.setContent(all, false); 83 92 dialog.setButtonIcons(new String[] {"ok.png","cancel.png",}); … … 85 94 dialog.showDialog(); 86 95 87 int idx = combo1.getSelectedIndex();96 int idx = list1.getSelectedIndex(); 88 97 if (dialog.getValue() ==1 && idx>=0) { 89 98 Main.pref.put("utilsplugin2.customurl", vals[idx]); -
applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/OpenPageAction.java
r26662 r26694 2 2 package utilsplugin2; 3 3 4 import java.awt.GridBagLayout;5 4 import java.io.UnsupportedEncodingException; 6 5 import static org.openstreetmap.josm.tools.I18n.tr; … … 12 11 import java.util.Collection; 13 12 14 import java.util.List;15 13 import java.util.regex.Matcher; 16 14 17 15 import java.util.regex.Pattern; 18 import javax.swing.BorderFactory;19 import javax.swing.JComboBox;20 16 import javax.swing.JOptionPane; 21 17 22 import javax.swing.JPanel;23 import javax.swing.border.EtchedBorder;24 18 import org.openstreetmap.josm.Main; 25 19 import org.openstreetmap.josm.actions.JosmAction; 20 import org.openstreetmap.josm.data.coor.LatLon; 26 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; 27 22 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 28 import org.openstreetmap.josm.gui.ExtendedDialog;29 import org.openstreetmap.josm.gui.widgets.HistoryComboBox;30 import org.openstreetmap.josm.gui.widgets.HtmlPanel;31 import org.openstreetmap.josm.tools.GBC;32 23 import org.openstreetmap.josm.tools.OpenBrowser; 33 24 import org.openstreetmap.josm.tools.Shortcut; … … 54 45 Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected(); 55 46 OsmPrimitive p=null; 56 if (sel.size() ==1) {47 if (sel.size()>=1) { 57 48 p=sel.iterator().next(); 58 } else {59 JOptionPane.showMessageDialog(60 Main.parent,61 tr("Please select one element to open custom URL for it. You can choose the URL in Preferences, Utils tab."),62 tr("Information"),63 JOptionPane.INFORMATION_MESSAGE64 );65 return;66 49 } 50 67 51 if (Main.pref.getBoolean("utilsplugin2.askurl",false)==true) 68 ChooseURLAction.showConfigDialog(); 52 ChooseURLAction.showConfigDialog(true); 53 54 //lat = p.getBBox().getTopLeft().lat(); 55 //lon = p.getBBox().getTopLeft().lon(); 56 LatLon center = Main.map.mapView.getLatLon(Main.map.mapView.getWidth()/2, Main.map.mapView.getHeight()/2); 57 69 58 70 59 String addr = Main.pref.get("utilsplugin2.customurl", defaultURL); … … 76 65 try { 77 66 while (m.find()) { 78 key=m.group(1); 67 key=m.group(1); val=null; 79 68 if (key.equals("#id")) { 80 val=Long.toString(p.getId());69 if (p!=null) val=Long.toString(p.getId()); ; 81 70 } else if (key.equals("#type")) { 82 val = OsmPrimitiveType.from(p).getAPIName();71 if (p!=null) val = OsmPrimitiveType.from(p).getAPIName(); ; 83 72 } else if (key.equals("#lat")) { 84 val = Double.toString( p.getBBox().getTopLeft().lat());73 val = Double.toString(center.lat()); 85 74 } else if (key.equals("#lon")) { 86 val = Double.toString( p.getBBox().getTopLeft().lon());75 val = Double.toString(center.lon()); 87 76 } 88 77 else { 89 val =p.get(key); 90 if (val!=null) val =URLEncoder.encode(p.get(key), "UTF-8"); else return; 78 if (p!=null) { 79 val =p.get(key); 80 if (val!=null) val =URLEncoder.encode(p.get(key), "UTF-8"); else return; 81 } 91 82 } 92 83 keys[i]=m.group(); … … 118 109 setEnabled(false); 119 110 } else { 120 updateEnabledState(getCurrentDataSet().getSelected());111 setEnabled(true); 121 112 } 122 113 } 123 114 124 @Override 125 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 126 setEnabled(selection != null ); 127 } 128 115 129 116 } -
applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/SelectAllInsideAction.java
r26670 r26694 39 39 Set<Relation> selectedRels = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Relation.class); 40 40 41 for (Way w: selectedWays) {42 if (!w.isClosed()) selectedWays.remove(w);43 }44 41 for (Relation r: selectedRels) { 45 42 if (!r.isMultipolygon()) selectedRels.remove(r);
Note:
See TracChangeset
for help on using the changeset viewer.