import java.util.Collection;
import java.util.HashSet;
+import java.util.List;
import java.util.UUID;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.ui.handlers.HandlerUtil;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
+import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4;
import eu.etaxonomy.taxeditor.bulkeditor.input.TaxonEditorInput;
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.DescriptiveDataSetEditor;
editor.init(descriptiveDataSetUuid, true);
}
- public static void openDistributionEditor(UUID parentTaxonUuid, EModelService modelService, EPartService partService, MApplication application){
+ public static void openDistributionEditor(UuidAndTitleCache parentUuidAndTitleCache, EModelService modelService, EPartService partService, MApplication application){
Collection<MPart> parts = partService.getParts();
String partId = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_CHECKLIST_E4_DISTRIBUTIONEDITORPART;
+ checkAndCloseFactsAndMediaParts(partService);
+ MPart part = showPart(partId, modelService, partService, application);
+ DistributionEditorPart editor = (DistributionEditorPart) part.getObject();
+ editor.init(parentUuidAndTitleCache);
+ }
+
+ public static void openDistributionEditor(List<UuidAndTitleCache> parentTaxonUuidList, EModelService modelService, EPartService partService, MApplication application){
+ Collection<MPart> parts = partService.getParts();
+ String partId = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_CHECKLIST_E4_DISTRIBUTIONEDITORPART;
+ checkAndCloseFactsAndMediaParts(partService);
+ MPart part = showPart(partId, modelService, partService, application);
+ DistributionEditorPart editor = (DistributionEditorPart) part.getObject();
+ editor.init(parentTaxonUuidList);
+ }
+
+ public static void checkAndCloseFactsAndMediaParts(EPartService partService) {
String partIdFactualData = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DESCRIPTIVE_E4_FACTUALDATAPARTE4;
String partIdMedia = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_MEDIA_E4_MEDIAVIEWPARTE4;
MPart part1 = partService.findPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DESCRIPTIVE_E4_FACTUALDATAPARTE4);
- if (part1!=null && part1.getWidget() != null){
+ if (factsVisible || (part1!=null && part1.getWidget() != null && partService.isPartVisible(part1))){
factsVisible = true;
}else{
factsVisible = false;
}
part1 = partService.findPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_MEDIA_E4_MEDIAVIEWPARTE4);
- if (part1!=null && part1.getWidget() != null){
+ if (mediaVisible || (part1!=null && part1.getWidget() != null && partService.isPartVisible(part1))){
mediaVisible = true;
}else{
mediaVisible = false;
}
closePart(partIdMedia, partService);
closePart(partIdFactualData, partService);
- MPart part = showPart(partId, modelService, partService, application);
- DistributionEditorPart editor = (DistributionEditorPart) part.getObject();
- editor.init(parentTaxonUuid);
}
if(editorAreaPartStack!=null){
editorAreaPartStack.getChildren().add(part);
}
+
return partService.showPart(part, PartState.ACTIVATE);
+
}
public static MPart showPart(String partId, EModelService modelService, EPartService partService){
TaxonNameEditorE4 editor = (TaxonNameEditorE4) part.getObject();
editor.init(input);
- MPart part1 = partService.findPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DESCRIPTIVE_E4_FACTUALDATAPARTE4);
+
if (factsVisible){
- String partIdFactualData = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DESCRIPTIVE_E4_FACTUALDATAPARTE4;
- showPart(partIdFactualData, modelService, partService);
+ showFacts(modelService, partService);
factsVisible = false;
}
- part1 = partService.findPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_MEDIA_E4_MEDIAVIEWPARTE4);
+
if (mediaVisible){
- String partIdFactualData = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_MEDIA_E4_MEDIAVIEWPARTE4;
- showPart(partIdFactualData, modelService, partService);
+ showMedia(modelService, partService);
mediaVisible = false;
}
-// String partIdFactualData = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DESCRIPTIVE_E4_FACTUALDATAPARTE4;
-// String partIdMedia = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_MEDIA_E4_MEDIAVIEWPARTE4;
-// showPart(partIdMedia, modelService, partService);
-// showPart(partIdFactualData, modelService, partService);
+
editor.setFocus();
}
+ public static void showMedia(EModelService modelService, EPartService partService) {
+ String partIdFactualData = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_MEDIA_E4_MEDIAVIEWPARTE4;
+ showPart(partIdFactualData, modelService, partService);
+
+ }
+
+ public static void showFacts(EModelService modelService, EPartService partService) {
+ String partIdFactualData = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DESCRIPTIVE_E4_FACTUALDATAPARTE4;
+ showPart(partIdFactualData, modelService, partService);
+
+ }
+
public static Collection<MPart> checkForChanges(UUID taxonUUID, EPartService partService ){
Collection<MPart> parts = partService.getParts();
Collection<MPart> dirtyParts = new HashSet();
return true;
}
- public static boolean forceUserSaveE4Editor(TaxonNameEditorE4 editor, Shell shell) {
+ public static boolean forceUserSaveE4Editor(IE4SavablePart editor, Shell shell) {
if (editor.isDirty()) {
boolean doSave = MessageDialog
}
+ public static void closeObsoleteDescriptiveDatasetEditor(UUID datasetUuid, EPartService partService){
+
+ Collection<MPart> parts = partService.getParts();
+ for (MPart part : parts) {
+ Object object = part.getObject();
+ if(object instanceof DescriptiveDataSetEditor){
+ DescriptiveDataSetEditor editor = (DescriptiveDataSetEditor)object;
+ DescriptiveDataSet descDataSet = editor.getDescriptiveDataSet();
+ if(descDataSet.getUuid().equals(datasetUuid)){
+ if (part.isDirty()){
+ forceUserSaveE4Editor(editor, getShell());
+ }
+ partService.hidePart(part);
+ }
+
+ }
+ }
+ }
+
+
public static void closePart(String partID, EPartService partService){
Collection<MPart> parts = partService.getParts();