Project

General

Profile

« Previous | Next » 

Revision a453d164

Added by Cherian Mathew about 7 years ago

StatusComposite : seperated init and refresh methods for the txa table, using seperate method to set visible comun ids
LeafNodeTaxonContainer : corrected isSynonym method

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/StatusComposite.java
132 132
    private static final String IN_VIEW_PREFIX = "in view : ";
133 133

  
134 134
    private boolean isTaxaTableInitialised = false;
135

  
135 136
    private boolean isFiltertableInitialised = false;
136 137

  
137 138
    private String selectedTaxaTableMenuItem = null;
138 139

  
139 140
    ContextMenu taxaTableContextMenu;
140 141

  
142
    private List<String> columnIds;
143

  
141 144
    /**
142 145
     * The constructor should first build the main layout, set the
143 146
     * composition root and then do any custom initialization.
......
204 207
        return null;
205 208
    }
206 209

  
207
    private void initTaxaTable(int classificationId) {
210
    private void initTaxaTable() {
208 211
        taxaTreeTable.setMultiSelect(taxaTreeTableMultiSelectMode);
209 212
        taxaTreeTable.setImmediate(false);
210 213
        taxaTreeTable.setDragMode(TableDragMode.ROW);
211
        if(listener != null) {
212
            List<String> columnIds = new ArrayList<String>();
213
            columnIds.add(LeafNodeTaxonContainer.NAME_ID);
214
            taxaTreeTable.setColumnExpandRatio(LeafNodeTaxonContainer.NAME_ID, 1);
215
            columnIds.add(LeafNodeTaxonContainer.PB_ID);
216
            taxaTreeTable.setColumnWidth(LeafNodeTaxonContainer.PB_ID, 25);
217

  
218
            if(!isTaxaTableInitialised) {
219
                taxaTreeTable.addGeneratedColumn(LeafNodeTaxonContainer.PB_ID, new TaxonTableCheckBoxGenerator());
220
            }
214
        columnIds = new ArrayList<String>();
215
        columnIds.add(LeafNodeTaxonContainer.NAME_ID);
216
        taxaTreeTable.setColumnExpandRatio(LeafNodeTaxonContainer.NAME_ID, 1);
217
        columnIds.add(LeafNodeTaxonContainer.PB_ID);
218
        taxaTreeTable.setColumnWidth(LeafNodeTaxonContainer.PB_ID, 25);
221 219

  
222
            try {
223
                taxaTreeTable.setContainerDataSource(listener.loadTaxa(classificationId), columnIds);
224
            } catch (SQLException e) {
225
                //TODO : throw up warning dialog
226
                e.printStackTrace();
227
            }
228 220

  
221
        taxaTreeTable.addGeneratedColumn(LeafNodeTaxonContainer.PB_ID, new TaxonTableCheckBoxGenerator());
229 222

  
230
            taxaTreeTable.setCellStyleGenerator(new Table.CellStyleGenerator() {
231

  
232
                @Override
233
                public String getStyle(Table source, Object itemId, Object propertyId) {
234
                    if(source.getItem(itemId) == null) {
235
                        return null;
236
                    }
237
                    if(listener.isSynonym(itemId)) {
238
                        // this is a synonym, so we activate the corresponding css class
239
                        return "synonym";
240
                    } else {
241
                        return "taxon";
242
                    }
223
        taxaTreeTable.setCellStyleGenerator(new Table.CellStyleGenerator() {
243 224

  
225
            @Override
226
            public String getStyle(Table source, Object itemId, Object propertyId) {
227
                if(source.getItem(itemId) == null) {
228
                    return null;
229
                }
230
                if(listener.isSynonym(itemId)) {
231
                    // this is a synonym, so we activate the corresponding css class
232
                    return "synonym";
233
                } else {
234
                    return "taxon";
244 235
                }
245
            });
246

  
247
            taxaTreeTable.setSortContainerPropertyId(LeafNodeTaxonContainer.NAME_ID);
248 236

  
249
            // NOTE : Not really sure why we need to refresh the container here.
250
            // in the case of 'Table' this is not required
251
            listener.refresh();
252
            updateInViewLabel();
253
            isTaxaTableInitialised = true;
254
        }
237
            }
238
        });
255 239

  
256 240
        taxaTableContextMenu = new ContextMenu();
257 241
        taxaTableContextMenu.setAsContextMenuOf(taxaTreeTable);
258 242
        addTaxaTreeContextMenuItemListener();
243
        isTaxaTableInitialised = true;
244
    }
259 245

  
246
    private void refreshTaxaTable(int classificationId) {
247
        if(!isTaxaTableInitialised) {
248
            initTaxaTable();
249
        }
250

  
251
        try {
252
            // Cannot use the setContainerDataSource method which has the column ids as
253
            // second argument, since this method is taken from the Table class and
254
            // hence the container strategy is not set to null, implying that the old
255
            // preorder list is not cleaned up - potential bug in the tree table api ?
256
            taxaTreeTable.setContainerDataSource(listener.loadTaxa(classificationId));
257
            taxaTreeTable.setVisibleColumns(LeafNodeTaxonContainer.NAME_ID, LeafNodeTaxonContainer.PB_ID);
258
        } catch (SQLException e) {
259
            //TODO : throw up warning dialog
260
            e.printStackTrace();
261
        }
262
        // We need to set the sort property id to null and then
263
        // reset it to the name column else the sort is not performed
264
        // since the sort property id has not changed - potential bug
265
        // in the tree table api ?
266
        taxaTreeTable.setSortContainerPropertyId(null);
267
        taxaTreeTable.setSortContainerPropertyId(LeafNodeTaxonContainer.NAME_ID);
268
        updateInViewLabel();
260 269

  
261 270
    }
262 271

  
......
277 286
        }
278 287
    }
279 288

  
280

  
281

  
282 289
    private void initFilterTable() {
283 290
        filterTable.setNullSelectionAllowed(false);
284 291
        final IndexedContainer container = new IndexedContainer();
......
380 387
                if (classificationComboBox.getValue() != null) {
381 388
                    Object selected = classificationComboBox.getValue();
382 389
                    int classificationId = (Integer)((RowId)selected).getId()[0];
383
                    initTaxaTable(classificationId);
390
                    refreshTaxaTable(classificationId);
384 391
                    initFilterTable();
385 392
                    setEnabledAll(true);
386 393
                }
src/main/java/eu/etaxonomy/cdm/vaadin/container/LeafNodeTaxonContainer.java
78 78
        taxonSynonymMap = new HashMap<Object,List<Object>>();
79 79
        initFilters();
80 80
        addContainerFilter(classificationFilter);
81
        enableCacheFlushNotifications();
81 82
        //addContainerFilter(rankFilter);
82 83
    }
83 84

  
......
190 191
     */
191 192
    @Override
192 193
    public boolean areChildrenAllowed(Object itemId) {
193

  
194 194
        Property hasSynProperty = getItem(itemId).getItemProperty(HAS_SYN_ID);
195 195
        if(hasSynProperty == null) {
196 196
            return false;
197 197
        }
198
        return (Long)hasSynProperty.getValue() > 0;
199

  
200

  
198
       return (Long)hasSynProperty.getValue() > 0;
201 199
    }
202 200

  
203 201
    /* (non-Javadoc)
......
225 223
    }
226 224

  
227 225
    public boolean isSynonym(Object itemId) {
228
        return synonymContainer.containsId(itemId);
226
        Property hasSynProperty = getItem(itemId).getItemProperty(HAS_SYN_ID);
227
        return hasSynProperty == null;
229 228
    }
230 229

  
231 230
    public void removeTaxonFromCache(Object itemId) {

Also available in: Unified diff