\r
import org.apache.log4j.Logger;\r
import org.eclipse.jface.action.Action;\r
+import org.eclipse.jface.dialogs.MessageDialog;\r
import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.eclipse.ui.IEditorPart;\r
+import org.eclipse.ui.PartInitException;\r
\r
import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
import eu.etaxonomy.cdm.model.taxon.Synonym;\r
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;\r
import eu.etaxonomy.taxeditor.ITaxEditorConstants;\r
import eu.etaxonomy.taxeditor.TaxEditorPlugin;\r
+import eu.etaxonomy.taxeditor.UiUtil;\r
import eu.etaxonomy.taxeditor.model.CdmUtil;\r
\r
/**\r
// TODO: Call a taxon service method similar to makeTaxonSynonym()\r
// instead of implementing the logic here\r
\r
+ try {\r
+ IEditorPart oldEditor = UiUtil.getEditorByTaxon(taxon);\r
+ if (oldEditor.isDirty()) {\r
+ if (!MessageDialog.openConfirm(UiUtil.getShell(), "Save before proceeding", \r
+ "All changes must be saved before proceeding with this action.\n\n" +\r
+ "Press \"OK\" to save and continue, or \"Cancel\" to cancel this action.")) {\r
+ return;\r
+ }\r
+ oldEditor.doSave(null);\r
+ }\r
+ } catch (PartInitException e) {\r
+ e.printStackTrace();\r
+ MessageDialog.openError(UiUtil.getShell(), "Error", "Error swapping synonym and taxon");\r
+ return;\r
+ }\r
+ \r
taxon.removeSynonym(synonym);\r
\r
Taxon parentTaxon = taxon.getTaxonomicParent();\r
\r
import org.apache.log4j.Logger;\r
import org.eclipse.jface.action.Action;\r
+import org.eclipse.jface.dialogs.MessageDialog;\r
import org.eclipse.jface.resource.ImageDescriptor;\r
import org.eclipse.swt.widgets.Shell;\r
import org.eclipse.ui.IEditorPart;\r
// Prompt user "Would you like to save?" before showing dialog\r
// "Cancel" cancels action - "No" does not\r
oldEditor = UiUtil.getEditorByTaxon(oldTaxon);\r
- if (UiUtil.getActivePage().saveEditor(oldEditor, true) == false) {\r
- return;\r
+ if (oldEditor.isDirty()) {\r
+ if (!MessageDialog.openConfirm(UiUtil.getShell(), "Save before proceeding", \r
+ "All changes must be saved before proceeding with this action.\n\n" +\r
+ "Press \"OK\" to save and continue, or \"Cancel\" to cancel this action.")) {\r
+ return;\r
+ }\r
+ oldEditor.doSave(null);\r
}\r
+// if (UiUtil.getActivePage().saveEditor(oldEditor, true) == false) {\r
+// return;\r
+// }\r
} catch (PartInitException e1) {\r
e1.printStackTrace();\r
}\r
return;\r
}\r
\r
+ // Create right-click context menu\r
Synonym synonym = (Synonym) getData();\r
ContextMenu contextMenu = createContextMenu();\r
\r
+ // Action to change composite to a misapplied name\r
Action misappliedNameAction = new MoveCompositeToMisappliedCompositeAction(\r
this, managedForm);\r
contextMenu.addAction(misappliedNameAction);\r
\r
+ // Action to delete composite\r
Action deleteSynonymAction = new DeleteSynonymCompositeAction(this,\r
getTaxon());\r
contextMenu.addAction(deleteSynonymAction);\r
\r
+ // Separator\r
contextMenu.addSeparator();\r
\r
+ // Action to make the composite the basionym of the homotypic group\r
final Action addBasionymAction = new AddBasionymCompositeAction(this);\r
contextMenu.addAction(addBasionymAction);\r
\r
+ // Action to remove the composite as basionym of the homotypic group\r
final Action removeBasionymAction = new RemoveBasionymCompositeAction(\r
this);\r
contextMenu.addAction(removeBasionymAction);\r
\r
+ // Listeners to activate / reactivate the above two actions as necessary\r
addBasionymAction\r
.addPropertyChangeListener(new IPropertyChangeListener() {\r
public void propertyChange(\r
}\r
}\r
});\r
-\r
removeBasionymAction\r
.addPropertyChangeListener(new IPropertyChangeListener() {\r
public void propertyChange(\r
}\r
});\r
\r
+ // Separator\r
contextMenu.addSeparator();\r
\r
+ // Action to change this synonym to the taxon's accepted name\r
Action changeToThisTaxon = new ChangeSynonymToTaxonUiAction(synonym,\r
getTaxon());\r
contextMenu.addAction(changeToThisTaxon);\r
\r
+ // Action to make a new taxon with this synonym as the accepted name\r
Action changeToNewAccepted = new ChangeCompositeToNewTaxonAction(this,\r
getTaxon());\r
contextMenu.addAction(changeToNewAccepted);\r