import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
+import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
/**
* Utility for the editor package
return dirtyParts;
}
- public static Collection<MPart> checkForTaxonChanges(UUID taxonUUID, EPartService partService ){
+ public static Collection<IE4SavablePart> checkForTaxonChanges(UUID taxonUUID, EPartService partService ){
Collection<MPart> parts = partService.getParts();
- Collection<MPart> dirtyParts = new HashSet();
+ Collection<IE4SavablePart> dirtyParts = new HashSet<>();
//check if part is already opened
- boolean isDirty = false;
for (MPart part : parts) {
if(part.getObject() instanceof TaxonNameEditorE4
&& ((TaxonNameEditorE4) part.getObject()).getTaxon()!=null
&& ((TaxonNameEditorE4) part.getObject()).getTaxon().getUuid().equals(taxonUUID)){
if (part.isDirty()){
- dirtyParts.add(part);
+ dirtyParts.add((IE4SavablePart) part);
}
break;
}else if (taxonUUID == null){
if (part.isDirty() && (part.getObject() instanceof TaxonNameEditorE4 || (part.getObject() instanceof BulkEditorE4 && ((BulkEditorE4)part.getObject()).getEditorInput() instanceof TaxonEditorInput))){
- dirtyParts.add(part);
+ dirtyParts.add((IE4SavablePart) part);
}
}
}
import javax.inject.Named;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.di.annotations.Optional;
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.MoveDescriptionElementsOperation;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
+import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
/**
}
newAcceptedTaxonNodeUuid = newAcceptedTaxonNode.getUuid();
- Collection<MPart> targetEditors = EditorUtil.checkForChanges(targetTaxon.getUuid(), partService);
-
- if (targetEditors != null || this.editor.isDirty()){
- boolean proceed = MessageDialog.openQuestion(null,
- Messages.MoveDescriptionToOtherTaxonHandler_SAVE_CHANGES, Messages.MoveDescriptionToOtherTaxonHandler_SAVE_CHANGES_MESSAGE);
- if( targetEditors.iterator().hasNext() ){
- MPart part = targetEditors.iterator().next();
- if (proceed) {
- if (part != null){
- if (part.getElementId().equals("eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4")){
- TaxonNameEditorE4 targetEditor = (TaxonNameEditorE4) WorkbenchUtility.getE4WrappedPart(part);
-
- targetEditor.save(AbstractUtility.getMonitor());
- }
- if (editor.isDirty()){
- editor.save(AbstractUtility.getMonitor());
- }
- } else {
- return;
- }
- }
+ Collection<IE4SavablePart> targetEditors = EditorUtil.checkForTaxonChanges(targetTaxon.getUuid(), partService);
+
+ if (!targetEditors.isEmpty() || this.editor.isDirty()){
+ if(MessageDialog.openQuestion(null,Messages.MoveDescriptionToOtherTaxonHandler_SAVE_CHANGES, Messages.MoveDescriptionToOtherTaxonHandler_SAVE_CHANGES_MESSAGE)){
+ this.editor.save(new NullProgressMonitor());
+ targetEditors.forEach(editor->editor.save(new NullProgressMonitor()));
+ return;
+ }
+ else{
+ return;
}
}
-// if ((targetEditor != null && targetEditor.getElementId().equals("eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4")) || this.editor.isDirty()){
-// boolean proceed = MessageDialog.openQuestion(null,
-// Messages.MoveDescriptionToOtherTaxonHandler_SAVE_CHANGES, Messages.MoveDescriptionToOtherTaxonHandler_SAVE_CHANGES_MESSAGE);
-// if (proceed) {
-// if (targetEditor != null){
-// e4WrappedPart = WorkbenchUtility.getE4WrappedPart(targetEditor);
-// ((TaxonNameEditorE4)e4WrappedPart).save(AbstractUtility.getMonitor());
-// }
-// if (editor.isDirty()){
-// editor.save(AbstractUtility.getMonitor());
-// }
-// } else {
-// return;
-// }
-// }
-
String moveMessage = String.format(Messages.MoveDescriptionElementsHandler_ELEMENTS_MOVED, editor.getTaxon());
AbstractPostTaxonOperation operation = new MoveDescriptionElementsOperation(
import javax.inject.Named;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.di.annotations.Optional;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
+import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
/**
*
newAcceptedTaxonNodeUuid = newAcceptedTaxonNode.getUuid();
newAcceptedTaxonUuid = newAcceptedTaxonNode.getTaxon().getUuid();
- Collection<MPart> targetEditors = EditorUtil.checkForChanges(newAcceptedTaxonUuid, partService);
-
- if (targetEditors != null || this.editor.isDirty()){
- boolean proceed = MessageDialog.openQuestion(null,
- Messages.MoveDescriptionToOtherTaxonHandler_SAVE_CHANGES, Messages.MoveDescriptionToOtherTaxonHandler_SAVE_CHANGES_MESSAGE);
- if( targetEditors.iterator().hasNext() ){
- MPart part = targetEditors.iterator().next();
- if (proceed) {
- if (part != null){
- if (part.getElementId().equals("eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4")){
- TaxonNameEditorE4 targetEditor = (TaxonNameEditorE4) WorkbenchUtility.getE4WrappedPart(part);
- targetEditor.save(AbstractUtility.getMonitor());
- }
- if (editor.isDirty()){
- editor.save(AbstractUtility.getMonitor());
- }
- } else {
- return;
- }
- }
+ Collection<IE4SavablePart> targetEditors = EditorUtil.checkForTaxonChanges(newAcceptedTaxonUuid, partService);
+
+ if (!targetEditors.isEmpty() || this.editor.isDirty()){
+ if(MessageDialog.openQuestion(null,Messages.MoveDescriptionToOtherTaxonHandler_SAVE_CHANGES, Messages.MoveDescriptionToOtherTaxonHandler_SAVE_CHANGES_MESSAGE)) {
+ this.editor.save(new NullProgressMonitor());
+ targetEditors.forEach(editor->editor.save(new NullProgressMonitor()));
+ return;
+ }
+ else{
+ return;
}
}
package eu.etaxonomy.taxeditor.editor.view.descriptive.operation;
-import org.apache.commons.lang.StringUtils;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.runtime.IAdaptable;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.api.service.IDescriptionService;
-import eu.etaxonomy.cdm.model.common.Annotation;
-import eu.etaxonomy.cdm.model.common.AnnotationType;
-import eu.etaxonomy.cdm.model.common.Language;
import eu.etaxonomy.cdm.model.description.TaxonDescription;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.taxeditor.editor.l10n.Messages;
import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
-
monitor.worked(20);
bind();
-
- String moveMessage = String.format(Messages.MoveDescriptionToOtherTaxonOperation_MOVED_FROM, description.getTaxon());
- if(description.isProtectedTitleCache()){
- String separator = ""; //$NON-NLS-1$
- if(!StringUtils.isBlank(description.getTitleCache())){
- separator = " - "; //$NON-NLS-1$
- }
- description.setTitleCache(description.getTitleCache() + separator + moveMessage, true);
- }
- Annotation annotation = Annotation.NewInstance(moveMessage, Language.getDefaultLanguage());
- annotation.setAnnotationType(AnnotationType.TECHNICAL());
- description.addAnnotation(annotation);
CdmStore.getService(IDescriptionService.class).moveTaxonDescription(description.getUuid(), newAcceptedTaxonNode.getTaxon().getUuid());
monitor.worked(40);
import eu.etaxonomy.cdm.api.service.config.PublishForSubtreeConfigurator;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
-import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
import eu.etaxonomy.taxeditor.navigation.navigator.operation.SetPublishForSubtreeOperation;
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
import eu.etaxonomy.taxeditor.ui.dialog.configurator.SetPublishForSubtreeWizard;
-import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
+import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
/**
* @author k.luther
"unknown", //$NON-NLS-1$
TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE);
}
- Collection<MPart> dirtyParts = EditorUtil.checkForTaxonChanges(null, partService);
+ Collection<IE4SavablePart> dirtyParts = EditorUtil.checkForTaxonChanges(null, partService);
if (dirtyParts != null && !dirtyParts.isEmpty()){
String[] buttonLables = {YES, NO,CANCEL};
return Status.CANCEL_STATUS;
}
- Iterator<MPart> partIterator = dirtyParts.iterator();
+ Iterator<IE4SavablePart> partIterator = dirtyParts.iterator();
while( partIterator.hasNext() ){
- MPart part = partIterator.next();
+ IE4SavablePart part = partIterator.next();
if (proceed) {
if (part != null){
- if (part.getElementId().equals("eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4")){ //$NON-NLS-1$
- TaxonNameEditorE4 targetEditor = (TaxonNameEditorE4) WorkbenchUtility.getE4WrappedPart(part);
- targetEditor.save(new NullProgressMonitor());
- }else if (part.getElementId().equals("bulkeditor.editor")){ //$NON-NLS-1$
- BulkEditorE4 targetEditor = (BulkEditorE4) WorkbenchUtility.getE4WrappedPart(part);
- targetEditor.save(new NullProgressMonitor());
- }
-
+ part.save(new NullProgressMonitor());
}
-
}
}
}
import eu.etaxonomy.cdm.api.service.config.SecundumForSubtreeConfigurator;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
-import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
import eu.etaxonomy.taxeditor.navigation.navigator.operation.SetSecundumForSubtreeOperation;
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
import eu.etaxonomy.taxeditor.ui.dialog.configurator.SetSecundumForSubtreeConfigurationWizard;
-import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
+import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
/**
* @author k.luther
"unknown", //$NON-NLS-1$
TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE);
}
- Collection<MPart> dirtyParts = EditorUtil.checkForTaxonChanges(null, partService);
+ Collection<IE4SavablePart> dirtyParts = EditorUtil.checkForTaxonChanges(null, partService);
if (dirtyParts != null && !dirtyParts.isEmpty()){
String[] buttonLables = {Messages.YES, Messages.NO,Messages.TreeNodeDropAdapter_CANCEL};
return Status.CANCEL_STATUS;
}
- Iterator<MPart> partIterator = dirtyParts.iterator();
+ Iterator<IE4SavablePart> partIterator = dirtyParts.iterator();
while( partIterator.hasNext() ){
- MPart part = partIterator.next();
+ IE4SavablePart part = partIterator.next();
if (proceed) {
if (part != null){
- if (part.getElementId().equals("eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4")){ //$NON-NLS-1$
- TaxonNameEditorE4 targetEditor = (TaxonNameEditorE4) WorkbenchUtility.getE4WrappedPart(part);
- targetEditor.save(new NullProgressMonitor());
- }else if (part.getElementId().equals("bulkeditor.editor")){ //$NON-NLS-1$
- BulkEditorE4 targetEditor = (BulkEditorE4) WorkbenchUtility.getE4WrappedPart(part);
- targetEditor.save(new NullProgressMonitor());
- }
-
+ part.save(new NullProgressMonitor());
}
-
}
}
}