|
4 | 4 | import java.awt.event.ActionListener;
|
5 | 5 | import java.awt.event.MouseEvent;
|
6 | 6 | import java.awt.event.MouseListener;
|
| 7 | +import java.util.Collection; |
7 | 8 | import java.util.Iterator;
|
8 | 9 | import java.util.NoSuchElementException;
|
| 10 | +import java.util.Set; |
9 | 11 |
|
10 | 12 | import javax.swing.JOptionPane;
|
11 | 13 |
|
@@ -104,23 +106,15 @@ protected void insertParameterCodeSnippetForColumn(final int index) {
|
104 | 106 | final DataColumnSpec cspec = (DataColumnSpec) o;
|
105 | 107 |
|
106 | 108 | final String columnName = cspec.getName();
|
107 |
| - String memberName = removeIntegers( |
108 |
| - Character.toLowerCase(columnName.charAt(0)) |
109 |
| - + columnName.substring(1)); |
110 |
| - |
111 |
| - int i = 0; |
112 |
| - String chosen = memberName; |
113 |
| - while (m_gui.columnInputMatchingTable().getModuleInfo() |
114 |
| - .getInput(chosen) != null) { |
115 |
| - chosen = memberName + i; |
116 |
| - ++i; |
117 |
| - } |
118 |
| - memberName = chosen; |
| 109 | + String memberName = cleanupMemberName(columnName); |
119 | 110 |
|
120 | 111 | // get the Name of the first createable type
|
121 | 112 | @SuppressWarnings("rawtypes")
|
122 | 113 | final Iterator<InputAdapter> itor = m_inputAdapters
|
123 |
| - .getMatchingInputAdapters(cspec.getType()).iterator(); |
| 114 | + .getMatchingInputAdapters( |
| 115 | + cspec.getType().getPreferredValueClass()) |
| 116 | + .iterator(); |
| 117 | + |
124 | 118 | final Class<?> type;
|
125 | 119 | if (itor.hasNext()) {
|
126 | 120 | type = itor.next().getOutputType();
|
@@ -162,6 +156,29 @@ protected void insertParameterCodeSnippetForColumn(final int index) {
|
162 | 156 | }
|
163 | 157 | }
|
164 | 158 |
|
| 159 | + /** |
| 160 | + * Cleans the columnname from illegal characters to make it usable as a |
| 161 | + * parameter. |
| 162 | + * |
| 163 | + * @param columnName the name of the column |
| 164 | + * @return name of the parameter |
| 165 | + */ |
| 166 | + private String cleanupMemberName(final String columnName) { |
| 167 | + String memberName = removeIntegers( |
| 168 | + Character.toLowerCase(columnName.charAt(0)) |
| 169 | + + columnName.substring(1)); |
| 170 | + |
| 171 | + int i = 0; |
| 172 | + String chosen = memberName; |
| 173 | + while (m_gui.columnInputMatchingTable().getModuleInfo() |
| 174 | + .getInput(chosen) != null) { |
| 175 | + chosen = memberName + i; |
| 176 | + ++i; |
| 177 | + } |
| 178 | + memberName = chosen; |
| 179 | + return memberName; |
| 180 | + } |
| 181 | + |
165 | 182 | private String removeIntegers(final String memberName) {
|
166 | 183 | String ret = memberName;
|
167 | 184 | while (Character.isDigit(ret.charAt(ret.length() - 1))) {
|
|
0 commit comments