source: josm/trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberRoleCellEditor.java@ 8510

Last change on this file since 8510 was 8510, checked in by Don-vip, 9 years ago

checkstyle: enable relevant whitespace checks and fix them

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.dialogs.relation;
3
4import java.awt.Component;
5
6import javax.swing.AbstractCellEditor;
7import javax.swing.BorderFactory;
8import javax.swing.JTable;
9import javax.swing.table.TableCellEditor;
10
11import org.openstreetmap.josm.data.osm.DataSet;
12import org.openstreetmap.josm.data.osm.Relation;
13import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField;
14import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList;
15
16public class MemberRoleCellEditor extends AbstractCellEditor implements TableCellEditor {
17 private AutoCompletingTextField editor = null;
18 private final transient DataSet ds;
19 private final transient Relation relation;
20
21 /** user input is matched against this list of auto completion items */
22 private AutoCompletionList autoCompletionList = null;
23
24 /**
25 * Constructs a new {@code MemberRoleCellEditor}.
26 * @param ds the data set. Must not be null
27 * @param relation the relation. Can be null
28 */
29 public MemberRoleCellEditor(DataSet ds, Relation relation) {
30 this.ds = ds;
31 this.relation = relation;
32 editor = new AutoCompletingTextField(0, false);
33 editor.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
34 autoCompletionList = new AutoCompletionList();
35 editor.setAutoCompletionList(autoCompletionList);
36 }
37
38 @Override
39 public Component getTableCellEditorComponent(JTable table,
40 Object value, boolean isSelected, int row, int column) {
41
42 String role = (String) value;
43 editor.setText(role);
44 autoCompletionList.clear();
45 ds.getAutoCompletionManager().populateWithMemberRoles(autoCompletionList, relation);
46 return editor;
47 }
48
49 @Override
50 public Object getCellEditorValue() {
51 return editor.getText();
52 }
53
54 /** Returns the edit field for this cell editor. */
55 public AutoCompletingTextField getEditor() {
56 return editor;
57 }
58}
Note: See TracBrowser for help on using the repository browser.