Changeset 30389 in osm for applications/editors/josm/plugins
- Timestamp:
- 2014-04-09T19:31:36+02:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/utilsplugin2
- Files:
-
- 6 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/build.xml
r30384 r30389 3 3 4 4 <!-- enter the SVN commit message --> 5 <property name="commit.message" value="[josm_utilsplugin2]: usedinways/usedinrealtions; multitagger: center on double-click"/>5 <property name="commit.message" value="[josm_utilsplugin2]: search parents:/children:; multitagger: select, sync"/> 6 6 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 7 7 <property name="plugin.main.version" value="6317"/> -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/multitagger/MultiTagDialog.java
r30384 r30389 30 30 import javax.swing.KeyStroke; 31 31 import javax.swing.ListSelectionModel; 32 import javax.swing.SwingUtilities;33 32 import javax.swing.event.ListSelectionEvent; 34 33 import javax.swing.event.ListSelectionListener; … … 40 39 import org.openstreetmap.josm.data.osm.OsmPrimitive; 41 40 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 42 import org.openstreetmap.josm.data.preferences.StringProperty;43 41 import org.openstreetmap.josm.gui.ExtendedDialog; 44 42 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 45 import org.openstreetmap.josm.gui.tagging.TagCellEditor;46 43 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField; 47 44 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; 48 45 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager; 49 import org.openstreetmap.josm.gui.util.GuiHelper;50 46 import org.openstreetmap.josm.gui.util.HighlightHelper; 51 47 import org.openstreetmap.josm.gui.util.TableHelper; … … 88 84 pnl.add(cbTagSet,GBC.std().fill(GBC.HORIZONTAL)); 89 85 pnl.add(new JButton(new DeleteFromHistoryAction()),GBC.std()); 90 pnl.add(new JButton(new FindMatchingAction()),GBC.eol()); 86 pnl.add(new JButton(new FindMatchingAction()),GBC.std()); 87 final JToggleButton jt = new JToggleButton("", ImageProvider.get("restart"), true); 88 jt.setToolTipText(tr("Sync with JOSM selection")); 89 jt.addActionListener(new ActionListener(){ 90 @Override public void actionPerformed(ActionEvent e) { 91 tableModel.setWatchSelection(jt.isSelected()); 92 }; 93 }); 94 pnl.add(jt,GBC.eol()); 95 96 91 97 pnl.add(createTypeFilterPanel(), GBC.eol().fill(GBC.HORIZONTAL)); 92 98 pnl.add(tbl.getTableHeader(),GBC.eop().fill(GBC.HORIZONTAL)); … … 103 109 private JTable createTable() { 104 110 JTable t = new JTable(tableModel); 111 tableModel.setTable(t); 105 112 t.setFillsViewportHeight(true); 106 t.setSelectionMode(ListSelectionModel. SINGLE_SELECTION);113 t.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 107 114 t.addMouseListener(tableMouseAdapter); 108 115 t.setRowSelectionAllowed(true); 109 116 t.setColumnSelectionAllowed(true); 110 117 t.setDefaultRenderer(OsmPrimitiveType.class, new PrimitiveTypeIconRenderer()); 111 t.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);112 118 t.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); 113 119 t.getSelectionModel().addListSelectionListener(selectionListener); … … 216 222 AutoScaleAction.zoomTo(currentSelection); 217 223 } 224 } 225 }); 226 menu.add(new AbstractAction(tr("Select"), ImageProvider.get("dialogs", "select")) { 227 @Override 228 public void actionPerformed(ActionEvent e) { 229 Main.main.getCurrentDataSet().setSelected(getSelectedPrimitives()); 218 230 } 219 231 }); -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/multitagger/MultiTaggerTableModel.java
r30370 r30389 10 10 import java.util.List; 11 11 import java.util.Set; 12 import javax.swing.JTable; 12 13 import javax.swing.table.AbstractTableModel; 14 import javax.swing.table.TableCellEditor; 13 15 import org.openstreetmap.josm.Main; 14 16 import org.openstreetmap.josm.command.ChangePropertyCommand; … … 32 34 private boolean autoCommit = true; 33 35 List<Command> cmds = new ArrayList<Command>(); 36 private boolean watchSelection = true; 37 private JTable table; 34 38 35 39 public MultiTaggerTableModel() { … … 47 51 } 48 52 53 public void setWatchSelection(boolean watchSelection) { 54 this.watchSelection = watchSelection; 55 if (watchSelection && Main.main.hasEditLayer()) selectionChanged(Main.main.getCurrentDataSet().getSelected()); 56 } 57 49 58 @Override 50 59 public Object getValueAt(int rowIndex, int columnIndex) { … … 86 95 @Override 87 96 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 88 updateData(newSelection); 97 if (watchSelection) 98 updateData(newSelection); 89 99 } 90 100 … … 164 174 165 175 void updateData(Collection<? extends OsmPrimitive> sel) { 166 list.clear(); 176 if (table.isEditing()) table.getCellEditor().stopCellEditing(); 177 178 list.clear(); 167 179 for (OsmPrimitive p : sel) { 168 180 if (shownTypes.contains(p.getDisplayType())) { … … 181 193 cmds.clear(); 182 194 } 195 196 void setTable(JTable t) { 197 table = t; 198 } 183 199 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/ChildrenMatch.java
r30387 r30389 4 4 import org.openstreetmap.josm.actions.search.PushbackTokenizer; 5 5 import org.openstreetmap.josm.actions.search.SearchCompiler; 6 import org.openstreetmap.josm.data.osm.Changeset;7 import org.openstreetmap.josm.data.osm.Node;8 6 import org.openstreetmap.josm.data.osm.OsmPrimitive; 9 7 import org.openstreetmap.josm.data.osm.Relation; 10 8 import org.openstreetmap.josm.data.osm.Way; 11 import org.openstreetmap.josm.data.osm.visitor.Visitor;12 9 import static org.openstreetmap.josm.tools.I18n.tr; 13 10 14 11 /** 15 * Matches objects with a version numberin the given range.12 * Matches objects with a number of child primitives in the given range. 16 13 */ 17 public class UsedInWaysMatch extends RangeMatch {18 public UsedInWaysMatch(PushbackTokenizer.Range range) {super(range);}19 public UsedInWaysMatch(PushbackTokenizer tokenizer) throws SearchCompiler.ParseError {20 this(tokenizer.readRange(tr("Range of attached way cuunt")));14 public class ChildrenMatch extends RangeMatch { 15 public ChildrenMatch(PushbackTokenizer.Range range) {super(range);} 16 public ChildrenMatch(PushbackTokenizer tokenizer) throws SearchCompiler.ParseError { 17 this(tokenizer.readRange(tr("Range of child primitives count"))); 21 18 } 22 private class WayCounter implements Visitor { 23 int count; 24 @Override 25 public void visit(Way w) { count++; } 26 @Override public void visit(Node n) { } 27 @Override public void visit(Relation r) { } 28 @Override public void visit(Changeset cs) { } 19 20 @Override 21 protected Long getNumber(OsmPrimitive osm) { 22 if (osm instanceof Way) { 23 return (long) ((Way)osm).getNodesCount(); 24 } else if (osm instanceof Relation) { 25 return (long) ((Relation)osm).getMembersCount(); 26 } else { 27 return null; 28 } 29 29 } 30 WayCounter counter = new WayCounter();31 30 32 @Override protected Long getNumber(OsmPrimitive osm) { 33 if (osm instanceof Node) { 34 counter.count=0; 35 osm.visitReferrers(counter); 36 return new Long(counter.count); 37 } else return null; 38 } 39 @Override protected String getString() { 40 return "wayrefs"; 31 @Override 32 protected String getString() { 33 return "children"; 41 34 } 42 35 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/ParentsMatch.java
r30387 r30389 4 4 import org.openstreetmap.josm.actions.search.PushbackTokenizer; 5 5 import org.openstreetmap.josm.actions.search.SearchCompiler; 6 import org.openstreetmap.josm.data.osm.Changeset;7 import org.openstreetmap.josm.data.osm.Node;8 6 import org.openstreetmap.josm.data.osm.OsmPrimitive; 9 import org.openstreetmap.josm.data.osm.Relation;10 import org.openstreetmap.josm.data.osm.Way;11 import org.openstreetmap.josm.data.osm.visitor.Visitor;12 7 import static org.openstreetmap.josm.tools.I18n.tr; 13 8 14 9 /** 15 * Matches objects with a version numberin the given range.10 * Matches objects with a number of parent primitives in the given range. 16 11 */ 17 public class UsedInWaysMatch extends RangeMatch {18 public UsedInWaysMatch(PushbackTokenizer.Range range) {super(range);}19 public UsedInWaysMatch(PushbackTokenizer tokenizer) throws SearchCompiler.ParseError {20 this(tokenizer.readRange(tr("Range of attached way cuunt")));12 public class ParentsMatch extends RangeMatch { 13 public ParentsMatch(PushbackTokenizer.Range range) {super(range);} 14 public ParentsMatch(PushbackTokenizer tokenizer) throws SearchCompiler.ParseError { 15 this(tokenizer.readRange(tr("Range of parent primitives count"))); 21 16 } 22 private class WayCounter implements Visitor { 23 int count; 24 @Override 25 public void visit(Way w) { count++; } 26 @Override public void visit(Node n) { } 27 @Override public void visit(Relation r) { } 28 @Override public void visit(Changeset cs) { } 17 @Override 18 protected Long getNumber(OsmPrimitive osm) { 19 return new Long(osm.getReferrers().size()); 29 20 } 30 WayCounter counter = new WayCounter(); 31 32 @Override protected Long getNumber(OsmPrimitive osm) { 33 if (osm instanceof Node) { 34 counter.count=0; 35 osm.visitReferrers(counter); 36 return new Long(counter.count); 37 } else return null; 38 } 39 @Override protected String getString() { 40 return "wayrefs"; 21 @Override 22 protected String getString() { 23 return "parents"; 41 24 } 42 25 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/UsedInRelationsMatch.java
r30384 r30389 30 30 RelationCounter counter = new RelationCounter(); 31 31 32 @Override protected Long getNumber(OsmPrimitive osm) { 32 @Override 33 protected Long getNumber(OsmPrimitive osm) { 33 34 counter.count=0; 34 35 osm.visitReferrers(counter); 35 36 return new Long(counter.count); 36 37 } 37 @Override protected String getString() { 38 @Override 39 protected String getString() { 38 40 return "usedinrelations"; 39 41 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/UsedInWaysMatch.java
r30384 r30389 13 13 14 14 /** 15 * Matches objects with a version number in the given range.15 * Matches nodes that are attached to given range of ways 16 16 */ 17 17 public class UsedInWaysMatch extends RangeMatch { 18 18 public UsedInWaysMatch(PushbackTokenizer.Range range) {super(range);} 19 19 public UsedInWaysMatch(PushbackTokenizer tokenizer) throws SearchCompiler.ParseError { 20 this(tokenizer.readRange(tr("Range of attached way cuunt")));20 this(tokenizer.readRange(tr("Range of attached ways count"))); 21 21 } 22 22 private class WayCounter implements Visitor { -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/UtilsSimpleMatchFactory.java
r30384 r30389 9 9 public class UtilsSimpleMatchFactory implements SimpleMatchFactory { 10 10 11 private static Collection<String> keywords = Arrays.asList("usedinways", "usedinrelations" );11 private static Collection<String> keywords = Arrays.asList("usedinways", "usedinrelations", "parents", "children"); 12 12 13 13 @Override … … 24 24 return new UsedInRelationsMatch(tokenizer); 25 25 } else 26 if ("parents".equals(keyword)) { 27 return new ParentsMatch(tokenizer); 28 } else 29 if ("children".equals(keyword)) { 30 return new ChildrenMatch(tokenizer); 31 } else 26 32 return null; 27 33 };
Note:
See TracChangeset
for help on using the changeset viewer.