1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.gui.tagging;
|
---|
3 |
|
---|
4 | import java.util.Collection;
|
---|
5 | import java.util.List;
|
---|
6 | import java.util.Map;
|
---|
7 | import javax.swing.JPanel;
|
---|
8 | import org.openstreetmap.josm.Main;
|
---|
9 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
10 | import org.openstreetmap.josm.data.osm.Tag;
|
---|
11 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
---|
12 | import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField;
|
---|
13 | import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * This calss reperesentse single part of a preset - one field or text label that
|
---|
17 | * is shown to user
|
---|
18 | */
|
---|
19 | public abstract class TaggingPresetItem {
|
---|
20 |
|
---|
21 | protected void initAutoCompletionField(AutoCompletingTextField field, String key) {
|
---|
22 | OsmDataLayer layer = Main.main.getEditLayer();
|
---|
23 | if (layer == null) {
|
---|
24 | return;
|
---|
25 | }
|
---|
26 | AutoCompletionList list = new AutoCompletionList();
|
---|
27 | Main.main.getEditLayer().data.getAutoCompletionManager().populateWithTagValues(list, key);
|
---|
28 | field.setAutoCompletionList(list);
|
---|
29 | }
|
---|
30 |
|
---|
31 | abstract boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel);
|
---|
32 |
|
---|
33 | abstract void addCommands(List<Tag> changedTags);
|
---|
34 |
|
---|
35 | boolean requestFocusInWindow() {
|
---|
36 | return false;
|
---|
37 | }
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Tests whether the tags match this item.
|
---|
41 | * Note that for a match, at least one positive and no negative is required.
|
---|
42 | * @param tags the tags of an {@link OsmPrimitive}
|
---|
43 | * @return {@code true} if matches (positive), {@code null} if neutral, {@code false} if mismatches (negative).
|
---|
44 | */
|
---|
45 | Boolean matches(Map<String, String> tags) {
|
---|
46 | return null;
|
---|
47 | }
|
---|
48 |
|
---|
49 | }
|
---|