Revision 5dec2f7a
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java | ||
---|---|---|
30 | 30 |
|
31 | 31 |
import org.apache.commons.collections4.map.LinkedMap; |
32 | 32 |
import org.eclipse.core.runtime.IProgressMonitor; |
33 |
import org.eclipse.core.runtime.NullProgressMonitor; |
|
33 | 34 |
import org.eclipse.e4.ui.di.Focus; |
34 | 35 |
import org.eclipse.e4.ui.di.Persist; |
35 | 36 |
import org.eclipse.e4.ui.model.application.ui.MDirtyable; |
... | ... | |
52 | 53 |
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider; |
53 | 54 |
import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes; |
54 | 55 |
import org.eclipse.nebula.widgets.nattable.edit.editor.IComboBoxDataProvider; |
55 |
import org.eclipse.nebula.widgets.nattable.export.command.ExportCommand; |
|
56 | 56 |
import org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler; |
57 | 57 |
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer; |
58 | 58 |
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsSortModel; |
... | ... | |
106 | 106 |
import ca.odell.glazedlists.SortedList; |
107 | 107 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
108 | 108 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
109 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
|
109 | 110 |
import eu.etaxonomy.cdm.api.service.IWorkingSetService; |
111 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
110 | 112 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
113 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
|
111 | 114 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
112 | 115 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
113 | 116 |
import eu.etaxonomy.cdm.model.description.Feature; |
114 | 117 |
import eu.etaxonomy.cdm.model.description.FeatureTree; |
118 |
import eu.etaxonomy.cdm.model.description.IndividualsAssociation; |
|
115 | 119 |
import eu.etaxonomy.cdm.model.description.MeasurementUnit; |
120 |
import eu.etaxonomy.cdm.model.description.QuantitativeData; |
|
116 | 121 |
import eu.etaxonomy.cdm.model.description.SpecimenDescription; |
117 | 122 |
import eu.etaxonomy.cdm.model.description.State; |
123 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
|
118 | 124 |
import eu.etaxonomy.cdm.model.description.WorkingSet; |
125 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
|
126 |
import eu.etaxonomy.cdm.model.name.Rank; |
|
127 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
|
119 | 128 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
129 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
120 | 130 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
121 | 131 |
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.categorical.CategoricalDataCellEditor; |
122 | 132 |
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.categorical.CategoricalDataDisplayConverter; |
... | ... | |
210 | 220 |
|
211 | 221 |
//get features/columns stored in working set |
212 | 222 |
FeatureTree tree = workingSet.getDescriptiveSystem(); |
223 |
if(tree==null){ |
|
224 |
MessagingUtils.informationDialog("Initialization failed", "Working set has no feature tree set."); |
|
225 |
return; |
|
226 |
} |
|
213 | 227 |
List<Feature> features = new ArrayList<>(tree.getDistinctFeatures()); |
214 | 228 |
Collections.sort(features); |
215 | 229 |
|
... | ... | |
544 | 558 |
btnExcelExport.addSelectionListener(new SelectionAdapter() { |
545 | 559 |
@Override |
546 | 560 |
public void widgetSelected(SelectionEvent e) { |
547 |
natTable.doCommand( |
|
548 |
new ExportCommand( |
|
549 |
natTable.getConfigRegistry(), |
|
550 |
natTable.getShell())); |
|
561 |
Taxon taxon = Taxon.NewInstance(TaxonName.NewInstance(NomenclaturalCode.ICNAFP, Rank.GENUS(), "Generatus", null, null, null, null, null, null, null), null); |
|
562 |
TaxonDescription description = TaxonDescription.NewInstance(taxon); |
|
563 |
new SpecimenGenerator().generate().forEach(specimen -> |
|
564 |
{ |
|
565 |
IndividualsAssociation association = IndividualsAssociation.NewInstance(specimen); |
|
566 |
association.setFeature(Feature.SPECIMEN()); |
|
567 |
description.addElement(association); |
|
568 |
}); |
|
569 |
CdmStore.getService(ITaxonService.class).save(taxon); |
|
570 |
save(new NullProgressMonitor()); |
|
571 |
// natTable.doCommand( |
|
572 |
// new ExportCommand( |
|
573 |
// natTable.getConfigRegistry(), |
|
574 |
// natTable.getShell())); |
|
551 | 575 |
} |
552 | 576 |
}); |
553 | 577 |
|
... | ... | |
597 | 621 |
for (SpecimenDescription specimenDescription : descriptions) { |
598 | 622 |
Set<Feature> specimenDescriptionFeatures = new HashSet<>(); |
599 | 623 |
for (DescriptionElementBase descriptionElementBase : specimenDescription.getElements()) { |
600 |
specimenDescriptionFeatures.add(descriptionElementBase.getFeature()); |
|
624 |
specimenDescriptionFeatures.add(HibernateProxyHelper.deproxy(descriptionElementBase.getFeature(), Feature.class)); |
|
625 |
} |
|
626 |
for(Feature feature:features){ |
|
627 |
eu.etaxonomy.cdm.model.description.Character character = HibernateProxyHelper.deproxy(feature, eu.etaxonomy.cdm.model.description.Character.class); |
|
628 |
System.out.println(); |
|
629 |
|
|
601 | 630 |
} |
602 | 631 |
if(specimenDescriptionFeatures.containsAll(features)){ |
603 | 632 |
return specimenDescription; |
... | ... | |
607 | 636 |
//Create new specimen description if no match was found |
608 | 637 |
setDirty(); |
609 | 638 |
SpecimenDescription newDesription = SpecimenDescription.NewInstance(specimen); |
639 |
this.indexToFeatureMap.values().forEach(feature -> |
|
640 |
{ |
|
641 |
if(feature.isSupportsCategoricalData()){ |
|
642 |
newDesription.addElement(CategoricalData.NewInstance(feature)); |
|
643 |
} |
|
644 |
else if(feature.isSupportsQuantitativeData()){ |
|
645 |
newDesription.addElement(QuantitativeData.NewInstance(feature)); |
|
646 |
} |
|
647 |
}); |
|
610 | 648 |
newDesription.setTitleCache("WorkingSet "+workingSet.getLabel()+" "+newDesription.generateTitle(), true); |
611 | 649 |
return newDesription; |
612 | 650 |
|
Also available in: Unified diff
ref #7095 Fix potential NPE