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.taxeditor.editor.view.derivate.DerivateViewEditorInput;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.security.RequiredPermissions;
+import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
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 (factsVisible || 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 (mediaVisible || part1!=null && part1.getWidget() != null){
+ if (mediaVisible || (part1!=null && part1.getWidget() != null && partService.isPartVisible(part1))){
mediaVisible = true;
}else{
mediaVisible = false;
if(editorAreaPartStack!=null){
editorAreaPartStack.getChildren().add(part);
}
+
return partService.showPart(part, PartState.ACTIVATE);
+
}
public static MPart showPart(String partId, EModelService modelService, EPartService partService){
}
boolean hasPermission = false;
// if (node != null){
-// hasPermission = CdmStore.currentAuthentiationHasPermission(node, RequiredPermissions.TAXON_EDIT);
+ hasPermission = CdmStore.currentAuthentiationHasPermission(node, RequiredPermissions.TAXON_EDIT);
// }
// if (!hasPermission){
// MessagingUtils.warningDialog(Messages.EditorUtil_MISSING_PERMISSION, TaxonEditorInputE4.class, Messages.EditorUtil_MISSING_PERMISSION_MESSAGE);
MPart part = showPart(NAME_EDITOR_ID, modelService, partService, application);
TaxonNameEditorE4 editor = (TaxonNameEditorE4) part.getObject();
+// editor.setDisabled();
editor.init(input);
- MPart part1 = partService.findPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DESCRIPTIVE_E4_FACTUALDATAPARTE4);
+// editor.setEnabled();
+ editor.setFocus();
if (factsVisible){
showFacts(modelService, partService);
factsVisible = false;
}
- part1 = partService.findPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_MEDIA_E4_MEDIAVIEWPARTE4);
+
if (mediaVisible){
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) {
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 closeObsoleteEditorWithChildren(TaxonNodeDto taxonNode, EPartService partService){
+ String treeIndex = taxonNode.getTreeIndex();
+ Collection<MPart> parts = partService.getParts();
+ for (MPart part : parts) {
+ Object object = part.getObject();
+ if(object instanceof TaxonNameEditorE4){
+ TaxonNameEditorE4 taxonEditor = (TaxonNameEditorE4)object;
+ TaxonNode node = taxonEditor.getEditorInput().getTaxonNode();
+ if (node.treeIndex()!= null){
+ if(node.treeIndex().startsWith(treeIndex)){
+ if (part.isDirty()){
+ forceUserSaveE4Editor(taxonEditor, getShell());
+ }
+ partService.hidePart(part);
+ }
+ }else{
+ logger.debug("The taxonnode of taxon " + node.getTaxon().getTitleCache() + " uuid: " + node.getUuid() + " has no treeindex");;
+ }
+ }
+ }
+ }
+
+
+ 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){
if(node.treeIndex().equals(treeIndex)){
TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstance(node.getUuid());
editor.init(input);
-
-
}
}