Changeset 32627 in osm for applications/editors/josm/plugins/wikipedia/src/org
- Timestamp:
- 2016-07-10T22:57:04+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikidataItemSearchDialog.java
r32626 r32627 6 6 import java.awt.Component; 7 7 import java.awt.Dimension; 8 import java.awt.GridBagLayout; 8 9 import java.awt.event.ActionEvent; 9 10 import java.awt.event.ActionListener; … … 15 16 16 17 import javax.swing.DefaultListCellRenderer; 18 import javax.swing.JLabel; 17 19 import javax.swing.JList; 20 import javax.swing.JPanel; 18 21 19 22 import org.openstreetmap.josm.Main; 20 23 import org.openstreetmap.josm.actions.JosmAction; 24 import org.openstreetmap.josm.data.osm.Tag; 21 25 import org.openstreetmap.josm.gui.ExtendedDialog; 26 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox; 27 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem; 22 28 import org.openstreetmap.josm.gui.util.GuiHelper; 23 29 import org.openstreetmap.josm.gui.widgets.SearchTextResultListPanel; 30 import org.openstreetmap.josm.tools.GBC; 24 31 import org.openstreetmap.josm.tools.Utils; 25 32 … … 27 34 28 35 private final Selector selector; 36 private final AutoCompletingComboBox targetKey; 29 37 private static final WikidataItemSearchDialog INSTANCE = new WikidataItemSearchDialog(); 30 38 31 39 private WikidataItemSearchDialog() { 32 super(Main.parent, tr("Search Wikidata items"), new String[]{tr("Add ''wikipedia'' tag"), tr("Cancel")});40 super(Main.parent, tr("Search Wikidata items"), new String[]{tr("Add Tag"), tr("Cancel")}); 33 41 this.selector = new Selector(); 34 42 this.selector.setDblClickListener(new ActionListener() { … … 38 46 } 39 47 }); 40 setContent(selector, false); 48 this.targetKey = new AutoCompletingComboBox(); 49 this.targetKey.setSelectedItem(new AutoCompletionListItem("wikidata")); 50 51 final JPanel panel = new JPanel(new GridBagLayout()); 52 panel.add(selector, GBC.eop().fill(GBC.BOTH)); 53 panel.add(new JLabel(tr("Target key: "))); 54 panel.add(targetKey, GBC.eol().fill(GBC.HORIZONTAL)); 55 setContent(panel, false); 41 56 setPreferredSize(new Dimension(600, 300)); 42 57 } … … 53 68 @Override 54 69 public ExtendedDialog showDialog() { 70 initTargetKeys(); 55 71 selector.init(); 56 72 super.showDialog(); 57 73 selector.clearSelection(); 74 selector.requestFocus(); 58 75 return this; 76 } 77 78 private void initTargetKeys() { 79 final List<AutoCompletionListItem> keys = Main.getLayerManager().getEditLayer().data.getAutoCompletionManager().getKeys(); 80 targetKey.setPossibleACItems(keys); 81 targetKey.setEditable(true); 59 82 } 60 83 … … 65 88 return; 66 89 } 67 WikipediaToggleDialog.AddWikipediaTagAction.addTag(selector.getSelectedItem()); 90 final WikipediaApp.WikidataEntry selected = selector.getSelectedItem(); 91 if (selected == null) { 92 return; 93 } 94 final String key = Tag.removeWhiteSpaces(targetKey.getEditor().getItem().toString()); 95 final String value = selected.createWikipediaTag().getValue(); 96 WikipediaToggleDialog.AddWikipediaTagAction.addTag(new Tag(key, value)); 68 97 } 69 98
Note:
See TracChangeset
for help on using the changeset viewer.