Project

General

Profile

« Previous | Next » 

Revision 5e1eb4fd

Added by Andreas Kohlbecker over 5 years ago

ref #7591 ReferencePropertyDefinitions adding missing data to 'all'

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferencePopupEditor.java
15 15
import java.util.Map;
16 16
import java.util.Set;
17 17

  
18
import org.apache.log4j.Level;
19
import org.apache.log4j.Logger;
18 20
import org.springframework.context.annotation.Scope;
19 21
import org.springframework.security.core.GrantedAuthority;
20 22

  
......
56 58

  
57 59
    private static final long serialVersionUID = -4347633563800758815L;
58 60

  
61
    private static final Logger logger = Logger.getLogger(ReferencePopupEditor.class);
62

  
59 63
    private TextField titleField;
60 64

  
61 65
    private final static int GRID_COLS = 4; // 12 would fits for 2,3, and 4 Components per row
......
224 228

  
225 229
        GridLayout grid = (GridLayout)getFieldLayout();
226 230

  
227
        // initialize the map of adaptive fields
228
        if(adaptiveFields.isEmpty()){
229
            try{
230
                Map<String, String> fieldPropertyDefinition = ReferencePropertyDefinitions.fieldPropertyDefinition(null);
231
                Set<String> fieldNames = fieldPropertyDefinition.keySet();
232
                for(int row = variableGridStartRow; row <= variableGridLastRow; row++){
233
                    for(int x=0; x < grid.getColumns(); x++){
234
                        Component c = grid.getComponent(x, row);
235
                        if(c != null && c instanceof Field){
236
                            Field<?> field = (Field<?>)c;
237
                            PropertyIdPath propertyIdPath = boundPropertyIdPath(field);
238
                            if(propertyIdPath != null && fieldNames.contains(propertyIdPath.toString())){
239
                                adaptiveFields.put(propertyIdPath.toString(), field);
240
                            }
241
                        }
242
                    }
243
                }
244
            } catch (UnimplemetedCaseException e) {
245
                throw new RuntimeException(e);
246
            }
247
        }
231
        initAdaptiveFields();
248 232

  
249 233
        // clear the variable grid part
250 234
        for(int row = variableGridStartRow; row <= variableGridLastRow; row++){
......
288 272
        return null;
289 273
    }
290 274

  
275
    /**
276
     * @param grid
277
     */
278
    protected void initAdaptiveFields() {
279
        GridLayout grid = (GridLayout)getFieldLayout();
280
        // initialize the map of adaptive fields
281
        logger.setLevel(Level.DEBUG);
282
        if(adaptiveFields.isEmpty()){
283
            try{
284
                Map<String, String> fieldPropertyDefinition = ReferencePropertyDefinitions.fieldPropertyDefinition(null);
285
                Set<String> fieldNames = fieldPropertyDefinition.keySet();
286
                for(int row = variableGridStartRow; row <= variableGridLastRow; row++){
287
                    for(int x=0; x < grid.getColumns(); x++){
288
                        Component c = grid.getComponent(x, row);
289
                        logger.debug("initAdaptiveFields() - y: " + row + " x: " + x + "  component:" + (c != null ? c.getClass().getSimpleName(): "NULL"));
290
                        if(c != null && c instanceof Field){
291
                            Field<?> field = (Field<?>)c;
292
                            PropertyIdPath propertyIdPath = boundPropertyIdPath(field);
293
                            logger.debug("initAdaptiveFields() - " + field.getCaption() + " -> " + propertyIdPath);
294
                            if(propertyIdPath != null && fieldNames.contains(propertyIdPath.toString())){
295
                                adaptiveFields.put(propertyIdPath.toString(), field);
296
                            }
297
                        }
298
                    }
299
                }
300
            } catch (UnimplemetedCaseException e) {
301
                throw new RuntimeException(e);
302
            }
303
        }
304
    }
305

  
291 306
    protected void setAllFieldsVisible(boolean visible){
292 307
        GridLayout grid = (GridLayout)getFieldLayout();
293 308
        for(Component c : grid){

Also available in: Unified diff