import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.Persist;
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.services.EMenuService;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
import eu.etaxonomy.cdm.api.service.ITermService;
-import eu.etaxonomy.cdm.model.common.DefinedTermBase;
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
-import eu.etaxonomy.cdm.model.description.FeatureTree;
+import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.location.NamedArea;
import eu.etaxonomy.cdm.model.name.Rank;
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.model.term.DefinedTermBase;
+import eu.etaxonomy.cdm.model.term.TermTree;
+import eu.etaxonomy.cdm.model.term.TermType;
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
import eu.etaxonomy.cdm.persistence.dto.TermDto;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.editor.IDescriptiveDataSetEditor;
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
+import eu.etaxonomy.taxeditor.event.EventUtility;
+import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
*
*/
public class DescriptiveDataSetEditor implements IE4SavablePart, IConversationEnabled, ICdmEntitySessionEnabled,
-IPartContentHasDetails, IPartContentHasSupplementalData, IDirtyMarkable {
+IPartContentHasDetails, IPartContentHasSupplementalData, IDirtyMarkable, IDescriptiveDataSetEditor {
private DescriptiveDataSetComposite composite;
@Inject
private MDirtyable dirty;
+ @Inject
+ private MPart thisPart;
+
@Inject
private ESelectionService selectionService;
@Override
public void modifyText(ModifyEvent e) {
descriptiveDataSet.setLabel(composite.getTxt_label().getText());
+ EventUtility.postSyncEvent(WorkbenchEventConstants.REFRESH_DATASET_NAVIGATOR, descriptiveDataSet);
dirty.setDirty(true);
}
};
composite.getRankMin().addSelectionChangedListener(event->dirty.setDirty(true));
composite.getRankMin().setText("Select min rank...");
composite.getRankMax().addSelectionChangedListener(event->dirty.setDirty(true));
- composite.getRankMin().setText("Select max rank...");
+ composite.getRankMax().setText("Select max rank...");
composite.getBtnRemoveRankMin().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
AreasSelectionDialog areasSelectionDialog = new AreasSelectionDialog(composite.getShell(), composite.getAreas());
if(areasSelectionDialog.open()==Window.OK){
- Set<TermDto> selectedAreas = areasSelectionDialog.getSelectedAreas();
+ List<TermDto> selectedAreas = areasSelectionDialog.getSelectedAreas();
if(selectedAreas!=null){
composite.setAreas(selectedAreas);
dirty.setDirty(true);
}
});
- composite.getFeatureTreeEditorComposite().init("Character Tree", null, null, e->selectionService.setSelection(e.getSelection()), this, null);
+ composite.getFeatureTreeEditorComposite().init("Character Tree",
+ TermType.Character,
+ null,
+ null,
+ e->selectionService.setSelection(e.getSelection()),
+ this,
+ null);
//add drag'n'drop support
Transfer[] transfers = new Transfer[] {LocalSelectionTransfer.getTransfer()};
}
Set<NamedArea> geoFilter = descriptiveDataSet.getGeoFilter();
if(geoFilter!=null && !geoFilter.isEmpty()){
- Set<TermDto> terms = geoFilter.stream().map(filter->new TermDto(
- filter.getUuid(),
- filter.getRepresentations(),
- filter.getPartOf()!=null?filter.getPartOf().getUuid():null,
- filter.getVocabulary().getUuid(),
- filter.getOrderIndex())).collect(Collectors.toSet());
- composite.setAreas(terms);
+ Set<TermDto> terms = geoFilter.stream().map(filter->TermDto.fromTerm(filter, true)).collect(Collectors.toSet());
+ composite.setAreas(new ArrayList<>(terms));
}
Set<TaxonNode> taxonSubtreeFilter = descriptiveDataSet.getTaxonSubtreeFilter();
if(taxonSubtreeFilter!=null){
}
});
selectionService.setSelection(new StructuredSelection(descriptiveDataSet));
+ thisPart.setLabel(descriptiveDataSet.getLabel());
}
public void addTaxonNode(TaxonNodeDto taxonNodeDto){
@Persist
@Override
public void save(IProgressMonitor monitor) {
- Set<TermDto> areas = composite.getAreas();
+ Collection<TermDto> areas = composite.getAreas();
Object input = composite.getTaxonNodeTree().getInput();
if(input!=null){
descriptiveDataSet.setTaxonSubtreeFilter(new HashSet<>());//clear existing filter
}
}
}
- FeatureTree characters = composite.getCharacters();
+ TermTree<Feature> characters = composite.getCharacters();
if(characters!=null){
//save characters because they can be modified in this editor
- characters.getDistinctFeatures().forEach(character->CdmStore.getService(ITermService.class).merge(character,true));
+ characters.getDistinctTerms().forEach(character->CdmStore.getService(ITermService.class).merge(character,true));
}
conversation.commit();
CdmStore.getService(IDescriptiveDataSetService.class).merge(descriptiveDataSet, true);
-
+ //event for updatin matrix
+ EventUtility.postEvent(WorkbenchEventConstants.REFRESH_DESCRIPTIVE_DATASET, descriptiveDataSet.getUuid());
dirty.setDirty(false);
}
+ @Override
+ public boolean isDirty() {
+ return dirty.isDirty();
+ }
+
@PreDestroy
public void dispose() {
if (conversation != null) {
cdmEntitySession = null;
}
dirty.setDirty(false);
+ selectionService.setSelection(null);
}
@Focus