Project

General

Profile

Revision fa0887f6

IDfa0887f6182cd5087f0a59e4aef622c4642cad8f
Parent 7d199d04
Child c9018a76

Added by Patrick Plitzner almost 4 years ago

ref #7095, #7086 Check classification uniqueness of sub tree filter

  • fix imports

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/TaxonNodeDropAdapter.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.editor.workingSet;
10 10

  
11
import java.util.Set;
12

  
11 13
import org.eclipse.jface.util.LocalSelectionTransfer;
12 14
import org.eclipse.jface.viewers.ISelection;
13 15
import org.eclipse.jface.viewers.IStructuredSelection;
......
16 18
import org.eclipse.swt.dnd.TransferData;
17 19

  
18 20
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
21
import eu.etaxonomy.taxeditor.model.MessagingUtils;
19 22

  
20 23
/**
21 24
 * @author pplitzner
......
37 40
    @Override
38 41
    public boolean performDrop(Object data) {
39 42
        TaxonNode taxonNode= (TaxonNode) ((ITreeSelection) data).getFirstElement();
43
        //check if node belongs to same classification
44
        Set<TaxonNode> taxonSubtreeFilter = workingSetEditor.getWorkingSet().getTaxonSubtreeFilter();
45
        if(taxonSubtreeFilter!=null && !taxonSubtreeFilter.isEmpty()){
46
            if(!taxonSubtreeFilter.iterator().next().getClassification().equals(taxonNode.getClassification())){
47
                MessagingUtils.warningDialog("Classifications do not match", this.getClass(),
48
                        "The taxon node you are trying to add belongs to another classification "
49
                        + "than the node(s) belonging to the working set.");
50
                return false;
51
            }
52

  
53
        }
40 54
        workingSetEditor.addTaxonNode(taxonNode);
41 55
        return true;
42 56
    }
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/WorkingSetEditor.java
67 67
import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
68 68

  
69 69
/**
70
 * Editor for configuring WorkingSets
70 71
 * @author pplitzner
71 72
 * @since Nov 21, 2017
72 73
 *
......
215 216
        dirty.setDirty(true);
216 217
    }
217 218

  
218
    /**
219
     * {@inheritDoc}
220
     */
221 219
    @Persist
222 220
    @Override
223 221
    public void save(IProgressMonitor monitor) {
......
266 264
        dirty.setDirty(false);
267 265
    }
268 266

  
269
    /** {@inheritDoc} */
270 267
    @PreDestroy
271 268
    public void dispose() {
272 269
        if (conversation != null) {
......
280 277
        dirty.setDirty(false);
281 278
    }
282 279

  
283
    /** {@inheritDoc} */
284 280
    @Focus
285 281
    public void setFocus() {
286 282
        if (getConversationHolder() != null) {
......
295 291
        return composite.getTaxonNodeTree();
296 292
    }
297 293

  
298
    /**
299
     * {@inheritDoc}
300
     */
294
    public WorkingSet getWorkingSet() {
295
        return workingSet;
296
    }
297

  
301 298
    @Override
302 299
    public void update(CdmDataChangeMap arg0) {
303 300
    }
304 301

  
305
    /**
306
     * {@inheritDoc}
307
     */
308 302
    @Override
309 303
    public ICdmEntitySession getCdmEntitySession() {
310 304
        return cdmEntitySession;
311 305
    }
312 306

  
313
    /**
314
     * {@inheritDoc}
315
     */
316 307
    @Override
317 308
    public Collection<WorkingSet> getRootEntities() {
318 309
        return null;
319 310
    }
320 311

  
321
    /**
322
     * {@inheritDoc}
323
     */
324 312
    @Override
325 313
    public Map<Object, List<String>> getPropertyPathsMap() {
326 314
        return null;
327 315
    }
328 316

  
329
    /**
330
     * {@inheritDoc}
331
     */
332 317
    @Override
333 318
    public ConversationHolder getConversationHolder() {
334 319
        return conversation;
335 320
    }
336 321

  
337
    /**
338
     * {@inheritDoc}
339
     */
340 322
    @Override
341 323
    public void changed(Object element) {
342 324
        dirty.setDirty(true);
343 325
    }
344 326

  
345
    /**
346
     * {@inheritDoc}
347
     */
348 327
    @Override
349 328
    public void forceDirty() {
350 329
        dirty.setDirty(true);
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java
8 8
 */
9 9
package eu.etaxonomy.taxeditor.editor.workingSet.matrix;
10 10

  
11
import java.awt.Button;
12
import java.awt.Color;
13
import java.awt.Composite;
14
import java.awt.DisplayMode;
15
import java.awt.GridLayout;
16
import java.awt.Label;
17
import java.awt.Window;
18 11
import java.io.File;
19 12
import java.io.FileInputStream;
20 13
import java.io.FileOutputStream;
......
33 26

  
34 27
import javax.annotation.PostConstruct;
35 28
import javax.annotation.PreDestroy;
36
import javax.annotation.Resources;
37 29
import javax.inject.Inject;
38 30

  
39 31
import org.apache.commons.collections4.map.LinkedMap;
......
48 40
import org.eclipse.jface.viewers.ComboViewer;
49 41
import org.eclipse.jface.viewers.LabelProvider;
50 42
import org.eclipse.jface.viewers.StructuredSelection;
43
import org.eclipse.jface.window.Window;
51 44
import org.eclipse.nebula.widgets.nattable.NatTable;
52 45
import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
53 46
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
......
55 48
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
56 49
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
57 50
import org.eclipse.nebula.widgets.nattable.config.IEditableRule;
51
import org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate;
58 52
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
59 53
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider;
60 54
import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
......
64 58
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsSortModel;
65 59
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeData;
66 60
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeRowModel;
61
import org.eclipse.nebula.widgets.nattable.freeze.CompositeFreezeLayer;
67 62
import org.eclipse.nebula.widgets.nattable.freeze.FreezeHelper;
63
import org.eclipse.nebula.widgets.nattable.freeze.FreezeLayer;
68 64
import org.eclipse.nebula.widgets.nattable.freeze.config.DefaultFreezeGridBindings;
69 65
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
70 66
import org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand;
......
87 83
import org.eclipse.nebula.widgets.nattable.layer.config.DefaultColumnHeaderStyleConfiguration;
88 84
import org.eclipse.nebula.widgets.nattable.layer.config.DefaultRowHeaderStyleConfiguration;
89 85
import org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent;
86
import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack;
90 87
import org.eclipse.nebula.widgets.nattable.persistence.PersistenceHelper;
91 88
import org.eclipse.nebula.widgets.nattable.persistence.command.DisplayPersistenceDialogCommand;
92 89
import org.eclipse.nebula.widgets.nattable.persistence.command.DisplayPersistenceDialogCommandHandler;
......
99 96
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer;
100 97
import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration;
101 98
import org.eclipse.nebula.widgets.nattable.style.CellStyleAttributes;
99
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
102 100
import org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum;
101
import org.eclipse.nebula.widgets.nattable.style.Style;
103 102
import org.eclipse.nebula.widgets.nattable.style.VerticalAlignmentEnum;
104 103
import org.eclipse.nebula.widgets.nattable.summaryrow.FixedSummaryRowLayer;
105 104
import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer;
......
110 109
import org.eclipse.nebula.widgets.nattable.ui.menu.AbstractHeaderMenuConfiguration;
111 110
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder;
112 111
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
112
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
113 113
import org.eclipse.swt.SWT;
114 114
import org.eclipse.swt.events.SelectionAdapter;
115 115
import org.eclipse.swt.events.SelectionEvent;
116
import org.eclipse.swt.graphics.Color;
116 117
import org.eclipse.swt.graphics.FontData;
117 118
import org.eclipse.swt.layout.GridData;
119
import org.eclipse.swt.layout.GridLayout;
118 120
import org.eclipse.swt.layout.RowLayout;
121
import org.eclipse.swt.widgets.Button;
122
import org.eclipse.swt.widgets.Composite;
123
import org.eclipse.swt.widgets.Label;
119 124

  
120 125
import ca.odell.glazedlists.EventList;
121 126
import ca.odell.glazedlists.GlazedLists;
......
130 135
import eu.etaxonomy.cdm.model.description.FeatureTree;
131 136
import eu.etaxonomy.cdm.model.description.MeasurementUnit;
132 137
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
138
import eu.etaxonomy.cdm.model.description.State;
139
import eu.etaxonomy.cdm.model.description.WorkingSet;
133 140
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
134 141
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
135 142
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.categorical.CategoricalDataCellEditor;
......
143 150
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
144 151
import eu.etaxonomy.taxeditor.model.ImageResources;
145 152
import eu.etaxonomy.taxeditor.model.MessagingUtils;
153
import eu.etaxonomy.taxeditor.preference.Resources;
146 154
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
147 155
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
148 156
import eu.etaxonomy.taxeditor.store.CdmStore;
......
504 512
        // because the Comparator will be set by configuration
505 513
        SortedList<Object> sortedList = new SortedList<>(descriptions, new MatrixRowComparator());
506 514
        // wrap the SortedList with the TreeList
507
        TreeList<Object> treeList = new TreeList(sortedList, new DescriptionTreeFormat(workingSet.getMaxRank()), TreeList.NODES_START_EXPANDED);
515
        TreeList<Object> treeList = new TreeList(sortedList, new DescriptionTreeFormat(workingSet), TreeList.NODES_START_EXPANDED);
508 516
        /**
509 517
         * data provider
510 518
         */
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/DescriptionTreeFormat.java
14 14
import java.util.Set;
15 15

  
16 16
import ca.odell.glazedlists.TreeList;
17
import eu.etaxonomy.cdm.model.description.WorkingSet;
17 18
import eu.etaxonomy.cdm.model.name.Rank;
19
import eu.etaxonomy.cdm.model.taxon.Classification;
18 20
import eu.etaxonomy.cdm.model.taxon.Taxon;
19 21
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
20 22

  
......
29 31
 public class DescriptionTreeFormat implements TreeList.Format<Object> {
30 32

  
31 33
     private Rank maxRank;
34
     private Classification classification;
32 35

  
33
     public DescriptionTreeFormat(Rank maxRank) {
34
         this.maxRank = maxRank;
36
     public DescriptionTreeFormat(WorkingSet workingSet) {
37
         this.maxRank = workingSet.getMaxRank();
38
         Set<TaxonNode> taxonSubtreeFilter = workingSet.getTaxonSubtreeFilter();
39
         if(taxonSubtreeFilter!=null && !taxonSubtreeFilter.isEmpty()){
40
             this.classification = taxonSubtreeFilter.iterator().next().getClassification();
41
         }
35 42
     }
36 43

  
37 44
     @Override
......
39 46
         if(element instanceof RowWrapper){
40 47
             //TODO: check for multiple taxon nodes in multiple classifications
41 48
             Taxon taxon = ((RowWrapper) element).getAssociatedTaxon();
42
             Set<TaxonNode> taxonNodes = taxon.getTaxonNodes();
43
             if(taxonNodes!=null){
44
                 TaxonNode node = taxonNodes.iterator().next();
45
                 addPathRecursive(path, node);
46
             }
49
             TaxonNode taxonNode = taxon.getTaxonNode(classification);
50
             addPathRecursive(path, taxonNode);
47 51
         }
48 52
         path.add(element);
49 53
     }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)