taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/RecentNamesContributionItem.java -text
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/WorkbenchUndoContextAdapterFactory.java -text
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/CreateChildTaxonHandler.java -text
-taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/DeleteTaxonHandler.java -text
+taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/DeleteTaxonNodeHandler.java -text
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/EditTaxonHandler.java -text
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/MoveTaxonHandler.java -text
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/QuickCreateChildTaxonHandler.java -text
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorSynonymLabelProvider.java -text
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorTaxonContentProvider.java -text
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorTaxonLabelProvider.java -text
+taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorTaxonomicTreeContentProvider.java -text
+taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorTaxonomicTreeLabelProvider.java -text
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/OpenTaxonActionProvider.java -text
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonDropAdapterAssistant.java -text
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonLinkHelper.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/dialogs/FilteredCdmResourceSelectionDialog.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/dialogs/FilteredNameSelectionDialog.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/dialogs/FilteredReferenceSelectionDialog.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/dialogs/LoginDialog.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/dialogs/SelectionDialogDetailsLabelProvider.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/dialogs/SelectionDialogSelectionLabelProvider.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/dialogs/UriDialog.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/ReferenceUtil.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/Resources.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/SynonymUtil.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/TaxonNodeUtil.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/TaxonTransfer.java -text
-taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/TaxonUtil.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/TimeUtil.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/AbstractPersistentPostOperation.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/AbstractPostOperation.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteImageOperation.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteMisapplicationOperation.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteSynonymOperation.java -text
-taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteTaxonOperation.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteTaxonNodeOperation.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/IPostOperationEnabled.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/MoveTaxonOperation.java -text
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/RemoveHomotypicalGroupBasionymOperation.java -text
taxeditor-store/src/test/java/eu/etaxonomy/taxeditor/store/operations/DeleteDescriptionElementOperationTest.java -text
taxeditor-store/src/test/java/eu/etaxonomy/taxeditor/store/operations/DeleteMisapplicationOperationTest.java -text
taxeditor-store/src/test/java/eu/etaxonomy/taxeditor/store/operations/DeleteSynonymOperationTest.java -text
-taxeditor-store/src/test/java/eu/etaxonomy/taxeditor/store/operations/DeleteTaxonOperationTest.java -text
+taxeditor-store/src/test/java/eu/etaxonomy/taxeditor/store/operations/DeleteTaxonNodeOperationTest.java -text
taxeditor-store/src/test/java/eu/etaxonomy/taxeditor/store/operations/MoveTaxonOperationTest.java -text
taxeditor-store/src/test/java/eu/etaxonomy/taxeditor/store/operations/SwapSynonymAndAcceptedOperationTest.java -text
taxeditor-store/src/test/resources/dbscripts/001_cdm.ddl -text
import org.apache.log4j.Logger;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
+import eu.etaxonomy.taxeditor.dialogs.LoginDialog;
import eu.etaxonomy.taxeditor.preference.InitNomenclaturalCodePrefDialog;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
configurer.setShowStatusLine(true);
configurer.setShowPerspectiveBar(true);
configurer.setTitle("EDIT Taxonomic Editor");
+
}
public void postWindowOpen() {
+
+ // authentication; activate when needed
+// if(authenticate() != Window.OK){
+// PlatformUI.getWorkbench().close();
+// }
+
checkNomenclaturalCode();
}
code + "\n\nYou can change the nomenclatural code at any time in the \"Preferences\" menu.");
}
}
+
+ private int authenticate(){
+ Shell shell = TaxonomicEditorPlugin.getDefault().getWorkbench()
+ .getActiveWorkbenchWindow().getShell();
+
+ LoginDialog loginDialog = new LoginDialog(shell);
+ return loginDialog.open();
+ }
}
\ No newline at end of file
* Taxon Editors may be opened by supplying a taxon uuid only.\r
* Session gets initialised here and is passed to the editor\r
* \r
- * @param uuid\r
+ * @param taxonNodeUuid\r
* @return\r
* @throws PartInitException \r
*/\r
- public static IEditorPart open(UUID uuid) throws PartInitException {\r
- IEditorInput input = TaxonEditorInput.NewInstance(uuid); \r
+ public static IEditorPart open(UUID taxonNodeUuid) throws PartInitException {\r
+ IEditorInput input = TaxonEditorInput.NewInstance(taxonNodeUuid); \r
return open(input, MultiPageTaxonEditor.ID);\r
}\r
\r
/**\r
- * An unitialized taxon is one that hasn't been saved yet. As such, it should appear in neither\r
+ * An uninitialized taxon is one that hasn't been saved yet. As such, it should appear in neither\r
* the list of recent names nor in the taxonomic tree when opened.\r
* \r
* @param parentTaxon The UUID of the parental taxon or <code>null</code> if this is\r
* @return The EditorPart.\r
* @throws PartInitException \r
*/\r
- public static IEditorPart openEmpty(UUID parentTaxonUuid) throws PartInitException{\r
- TaxonEditorInput input = TaxonEditorInput.NewEmptyInstance(parentTaxonUuid);\r
+ public static IEditorPart openEmpty(UUID parentTaxonNodeUuid) throws PartInitException{\r
+ TaxonEditorInput input = TaxonEditorInput.NewEmptyInstance(parentTaxonNodeUuid);\r
return open(input, MultiPageTaxonEditor.ID);\r
}\r
\r
}\r
\r
/**\r
- * Supposed to be overridden in implementing classes\r
+ * Implement in derived classes\r
* \r
* @param text\r
*/\r
- protected void parse(String text) {\r
- logger.warn("No parse method defined for this composite.");\r
- }\r
+ protected abstract void parse(String text);\r
+\r
\r
/**\r
* If the user hitting carriage return should cause something to happen -\r
private static final Logger logger = Logger.getLogger(MultiPageTaxonEditor.class);\r
\r
public static final String ID = "eu.etaxonomy.taxeditor.editor.multipagetaxonview";\r
- \r
- private Taxon taxon;\r
+\r
private boolean dirty;\r
\r
private ConversationHolder conversation;\r
private IDataChangeBehavior dataChangeBehavior;\r
private IUndoContext undoContext;\r
\r
+ private TaxonEditorInput input;\r
+\r
\r
public MultiPageTaxonEditor() {\r
super(); \r
@Override\r
protected void createPages() {\r
\r
- TaxonEditorInput input = (TaxonEditorInput) getEditorInput();\r
+ input = (TaxonEditorInput) getEditorInput();\r
conversation = input.getConversationHolder();\r
conversation.registerForDataStoreChanges(this);\r
\r
@Override\r
public void init(IEditorSite site, IEditorInput input) throws PartInitException {\r
\r
- if (!(input instanceof IEditorInput))\r
+ if (!(input instanceof TaxonEditorInput))\r
throw new PartInitException(\r
- "Invalid Input: Must be IEditorInput");\r
+ "Invalid Input: Must be TaxonEditorInput");\r
\r
+ // FIXME looks like we do it differently now\r
// Get taxon from editor input\r
- if (input.getAdapter(Taxon.class) != null) {\r
- taxon = (Taxon) input.getAdapter(Taxon.class);\r
- } else {\r
- taxon = null;\r
- }\r
+// if (input.getAdapter(Taxon.class) != null) {\r
+// taxon = (Taxon) input.getAdapter(Taxon.class);\r
+// } else {\r
+// taxon = null;\r
+// }\r
+ \r
+ this.input = (TaxonEditorInput) input;\r
\r
try {\r
// Listen for name changes, \r
// change tab for this taxon editor accordingly\r
- taxon.addPropertyChangeListener("name",\r
+ getTaxon().addPropertyChangeListener("name",\r
new PropertyChangeListener() {\r
public void propertyChange(PropertyChangeEvent e) {\r
setPartName();\r
protected void setPartName() {\r
\r
String partName = null;\r
- TaxonNameBase<?, ?> name = taxon.getName();\r
+ TaxonNameBase<?, ?> name = getTaxon().getName();\r
\r
if (name != null) {\r
partName = name.getTitleCache();\r
}\r
\r
public Taxon getTaxon(){\r
- return this.taxon;\r
+ return input.getTaxon();\r
}\r
\r
/*\r
package eu.etaxonomy.taxeditor.editor;
-import java.util.Set;
import java.util.UUID;
import org.apache.log4j.Logger;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
-import eu.etaxonomy.cdm.model.taxon.Synonym;
import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.cdm.model.taxon.TaxonBase;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.store.CdmStore;
private static final Logger logger = Logger
.getLogger(TaxonEditorInput.class);
- private Taxon taxon;
private ConversationHolder conversation;
+
+ private TaxonNode taxonNode;
- private TaxonEditorInput(Taxon taxon, ConversationHolder conversation){
- this.taxon = taxon;
+ private TaxonEditorInput(TaxonNode taxonNode, ConversationHolder conversation){
+ this.taxonNode = taxonNode;
this.conversation = conversation;
}
public static TaxonEditorInput NewInstance(UUID uuid){
ConversationHolder conversation = CdmStore.NewTransactionalConversation();
- TaxonBase<?> taxonBase = CdmStore.getTaxonService().getTaxonByUuid(uuid);
+ TaxonNode taxonNode = CdmStore.getTaxonService().getTaxonNodeByUuid(uuid);
- if(taxonBase == null){
+ if(taxonNode == null){
MessageDialog.openWarning(EditorUtil.getShell(), "Not yet implemented", "Selected element is not if type TaxonBase.");
return null;
}
Taxon taxon;
- if (taxonBase instanceof Synonym) {
- // TODO: in case of pro parte synonym or any other where we might have multiple
- // accepted taxa we have to provide a mechanism that can deal with that
- // TODO set focus to the synonym
- Set<Taxon> acceptedTaxa = ((Synonym) taxonBase).getAcceptedTaxa();
- if(acceptedTaxa.size() != 1){
- String message;
- if(acceptedTaxa.size() == 0){
- message = "There is no accepted taxon for the chosen synonym. ";
- }else{
- message = "Multiple taxa found for the chosen synonym.";
- }
- MessageDialog.openWarning(EditorUtil.getShell(), "Not yet implemented", message);
- return null;
- }else{
- taxon = acceptedTaxa.toArray(new Taxon[0])[0];
- }
- } else {
- taxon = (Taxon) taxonBase;
- }
-
+ // FIXME had to disable synonym handling for now while implementing taxonNode
+// if (taxonBase instanceof Synonym) {
+// // TODO: in case of pro parte synonym or any other where we might have multiple
+// // accepted taxa we have to provide a mechanism that can deal with that
+// // TODO set focus to the synonym
+// Set<Taxon> acceptedTaxa = ((Synonym) taxonBase).getAcceptedTaxa();
+// if(acceptedTaxa.size() != 1){
+// String message;
+// if(acceptedTaxa.size() == 0){
+// message = "There is no accepted taxon for the chosen synonym. ";
+// }else{
+// message = "Multiple taxa found for the chosen synonym.";
+// }
+// MessageDialog.openWarning(EditorUtil.getShell(), "Not yet implemented", message);
+// return null;
+// }else{
+// taxon = acceptedTaxa.toArray(new Taxon[0])[0];
+// }
+// } else {
+// taxon = (Taxon) taxonBase;
+// }
+
+
logger.trace(TaxonEditorInput.class.getSimpleName() + " created");
- return new TaxonEditorInput(taxon, conversation);
+ return new TaxonEditorInput(taxonNode, conversation);
}
- public static TaxonEditorInput NewEmptyInstance(UUID parentTaxonUuid){
+ public static TaxonEditorInput NewEmptyInstance(UUID parentTaxonNodeUuid){
ConversationHolder conversation = CdmStore.NewTransactionalConversation();
TaxonNameBase<?, ?> name = PreferencesUtil.getInstanceOfPreferredNameClass();
Taxon newTaxon = null;
- if(parentTaxonUuid == null){
- newTaxon = Taxon.NewInstance(name, CdmStore.getDefault().getDefaultSec());
- }else{
- Taxon parentTaxon = (Taxon) CdmStore.getTaxonService().getTaxonByUuid(parentTaxonUuid);
- newTaxon = Taxon.NewInstance(name, parentTaxon.getSec());
- parentTaxon.addTaxonomicChild(newTaxon, null, null);
- }
+ TaxonNode newTaxonNode = null;
+
+ // FIXME adding of root taxon nodes disabled for now. Still have to find a way to
+ // which taxonomic tree the node shoul dbe added
+// if(parentTaxonNodeUuid == null){
+// newTaxon = Taxon.NewInstance(name, CdmStore.getDefault().getDefaultSec());
+// newTaxonNode = new TaxonNode();
+// }else{
+ TaxonNode parentTaxonNode = CdmStore.getTaxonService().getTaxonNodeByUuid(parentTaxonNodeUuid);
+
+ newTaxon = Taxon.NewInstance(name, parentTaxonNode.getTaxon().getSec());
+
+ newTaxonNode = parentTaxonNode.addChild(newTaxon, parentTaxonNode.getReferenceForParentChildRelation(), parentTaxonNode.getMicroReferenceForParentChildRelation());
+// }
// add the new taxon to the editors persistence context
- CdmStore.getTaxonService().save(newTaxon);
+ CdmStore.getTaxonService().saveTaxonNode(newTaxonNode);
- return new TaxonEditorInput(newTaxon, conversation);
+ return new TaxonEditorInput(newTaxonNode, conversation);
}
/* (non-Javadoc)
* @see org.eclipse.ui.IEditorInput#exists()
*/
public boolean exists() {
- return taxon != null;
+ return taxonNode != null;
}
/* (non-Javadoc)
* @see org.eclipse.ui.IEditorInput#getName()
*/
public String getName() {
- TaxonNameBase<?, ?> name = taxon.getName();
+ TaxonNameBase<?, ?> name = getTaxon().getName();
if (name == null || name.getTitleCache() == null) {
return "New taxon";
} else {
public Object getAdapter(Class adapter) {
if (adapter == Taxon.class) {
- return taxon;
+ return taxonNode.getTaxon();
+ }
+
+ if (adapter == TaxonNode.class) {
+ return taxonNode;
}
return null;
*/
public boolean equals(Object obj) {
if (obj.getClass().equals(TaxonEditorInput.class)
- && taxon.equals(((TaxonEditorInput) obj).taxon))
+ && getTaxon().equals(((TaxonEditorInput) obj).getTaxon()))
return true;
return false;
}
+ /**
+ * @return the taxon
+ */
public Taxon getTaxon(){
- return taxon;
+ return taxonNode.getTaxon();
+ }
+
+ /**
+ * @return the taxonNode
+ */
+ public TaxonNode getTaxonNode() {
+ return taxonNode;
}
/*
import org.eclipse.ui.IElementFactory;\r
import org.eclipse.ui.IMemento;\r
\r
-import eu.etaxonomy.taxeditor.model.TaxonUtil;\r
+import eu.etaxonomy.taxeditor.model.TaxonNodeUtil;\r
import eu.etaxonomy.taxeditor.store.CdmStore;\r
import eu.etaxonomy.taxeditor.store.StoreUtil;\r
\r
public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {\r
return annotationHover;\r
}\r
+\r
+// /* (non-Javadoc)\r
+// * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getContentAssistant(org.eclipse.jface.text.source.ISourceViewer)\r
+// */\r
+// @Override\r
+// public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {\r
+// ContentAssistant contentAssistant = new ContentAssistant();\r
+// IContentAssistProcessor assistProcessor = new NameCompletionProcessor();\r
+// contentAssistant.setContentAssistProcessor(assistProcessor, NAME);\r
+// contentAssistant.setContentAssistProcessor(assistProcessor, IDocument.DEFAULT_CONTENT_TYPE);\r
+// contentAssistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));\r
+// return contentAssistant;\r
+// }\r
+ \r
+ \r
}\r
image.dispose();\r
}\r
}\r
+\r
+ /* (non-Javadoc)\r
+ * @see eu.etaxonomy.taxeditor.editor.GroupedComposite#parse(java.lang.String)\r
+ */\r
+ @Override\r
+ protected void parse(String text) {\r
+ throw new IllegalStateException("Parser should not be called on this object");\r
+ }\r
}\r
public IPropertySource getPropertySource() {\r
return null;\r
}\r
+\r
+ /* (non-Javadoc)\r
+ * @see eu.etaxonomy.taxeditor.editor.GroupedComposite#parse(java.lang.String)\r
+ */\r
+ @Override\r
+ protected void parse(String text) {\r
+ throw new IllegalStateException("Parser should not be called on this object");\r
+ }\r
}\r
// calculateErrors();\r
// activateParser();\r
} \r
+ \r
+ public boolean isDirty(){\r
+ \r
+ TaxonNameBase<?, ?> name = getName();\r
+ \r
+ \r
+ \r
+ return false;\r
+ }\r
}
\ No newline at end of file
name="Create Child Taxon">
</command>
<command
- defaultHandler="eu.etaxonomy.taxeditor.navigation.handler.DeleteTaxonHandler"
+ defaultHandler="eu.etaxonomy.taxeditor.navigation.handler.DeleteTaxonNodeHandler"
id="eu.etaxonomy.taxeditor.navigation.command.deleteTaxon"
name="Delete Taxon ">
</command>
</extension>
<extension
point="org.eclipse.ui.navigator.navigatorContent">
+ <navigatorContent
+ contentProvider="eu.etaxonomy.taxeditor.navigation.navigator.NavigatorTaxonomicTreeContentProvider"
+ id="eu.etaxonomy.taxeditor.navigation.taxonomictreecontent"
+ labelProvider="eu.etaxonomy.taxeditor.navigation.navigator.NavigatorTaxonomicTreeLabelProvider"
+ name="Taxonomic Tree">
+ <triggerPoints>
+ <instanceof
+ value="eu.etaxonomy.taxeditor.navigation.navigator.NavigatorRoot">
+ </instanceof>
+ </triggerPoints>
+ <possibleChildren>
+ <instanceof
+ value="eu.etaxonomy.cdm.model.taxon.TaxonNode">
+ </instanceof>
+ </possibleChildren>
+ </navigatorContent>
<navigatorContent
contentProvider="eu.etaxonomy.taxeditor.navigation.navigator.NavigatorTaxonContentProvider"
id="eu.etaxonomy.taxeditor.navigation.taxoncontent"
labelProvider="eu.etaxonomy.taxeditor.navigation.navigator.NavigatorTaxonLabelProvider"
- name="Taxon">
+ name="Taxon Node">
<triggerPoints>
- <instanceof value="eu.etaxonomy.taxeditor.navigation.navigator.NavigatorRoot"/>
+ <instanceof value="eu.etaxonomy.cdm.model.taxon.TaxonNode"/>
</triggerPoints>
<dropAssistant
class="eu.etaxonomy.taxeditor.navigation.navigator.TaxonDropAdapterAssistant"
id="eu.etaxonomy.taxeditor.navigation.navigator.dropassistant">
<possibleDropTargets>
<instanceof
- value="eu.etaxonomy.cdm.model.taxon.Taxon">
+ value="eu.etaxonomy.cdm.model.taxon.TaxonNode">
</instanceof>
</possibleDropTargets>
</dropAssistant>
<possibleChildren>
<instanceof
- value="eu.etaxonomy.cdm.model.taxon.Taxon">
+ value="eu.etaxonomy.cdm.model.taxon.TaxonNode">
</instanceof>
</possibleChildren>
<actionProvider
overrides="org.eclipse.ui.navigator.resources.OpenActions">
<enablement>
<instanceof
- value="eu.etaxonomy.cdm.model.taxon.Taxon">
+ value="eu.etaxonomy.cdm.model.taxon.TaxonNode">
</instanceof>
</enablement>
</actionProvider>
</viewer>
<viewerContentBinding viewerId="eu.etaxonomy.taxeditor.navigation.navigator">
<includes>
+ <contentExtension
+ pattern="eu.etaxonomy.taxeditor.navigation.taxonomictreecontent">
+ </contentExtension>
<contentExtension pattern="eu.etaxonomy.taxeditor.navigation.taxoncontent"/>
<contentExtension pattern="eu.etaxonomy.taxeditor.navigation.taxonlinkhelper"/>
- </includes>
- </viewerContentBinding>
- <viewerContentBinding
- viewerId="eu.etaxonomy.taxeditor.navigation.navigator">
- <includes>
<contentExtension
pattern="eu.etaxonomy.taxeditor.navigation.synonymcontent">
</contentExtension>
class="eu.etaxonomy.taxeditor.navigation.navigator.TaxonLinkHelper"
id="eu.etaxonomy.taxeditor.navigation.taxonlinkhelper">
<selectionEnablement>
- <instanceof value="eu.etaxonomy.cdm.model.taxon.Taxon"/>
+ <instanceof value="eu.etaxonomy.cdm.model.taxon.TaxonNode"/>
</selectionEnablement>
<editorInputEnablement>
<instanceof value="eu.etaxonomy.taxeditor.editor.TaxonEditorInput"/>
package eu.etaxonomy.taxeditor.navigation;
+import java.util.HashSet;
+import java.util.Set;
import java.util.UUID;
import org.apache.log4j.Logger;
import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
import org.eclipse.ui.navigator.CommonViewer;
-import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
+import eu.etaxonomy.cdm.model.taxon.Synonym;
import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
*
* @param uuid
*/
- public static void openEditor(IdentifiableEntity selection) {
+ public static void openEditor(TaxonNode selection) {
try {
UUID entityUuid = selection.getUuid();
EditorUtil.open(entityUuid);
getActiveWorkbenchWindow();
}
- public static void openEmpty(Taxon parentTaxon) {
+ public static void openEmpty(TaxonNode parentTaxonNode) {
try {
- UUID parentTaxonUuid = parentTaxon == null ? null : parentTaxon.getUuid();
+ UUID parentTaxonNodeUuid = parentTaxonNode == null ? null : parentTaxonNode.getUuid();
- EditorUtil.openEmpty(parentTaxonUuid);
+ EditorUtil.openEmpty(parentTaxonNodeUuid);
} catch (PartInitException e) {
logger.error("Error opening the editor", e);
}
* @param event
* @return
*/
- public static Taxon getCurrentSelection(ExecutionEvent event){
+ public static TaxonNode getCurrentSelection(ExecutionEvent event){
ISelection menuSelection = HandlerUtil.getActiveMenuSelection(event);
// The selection should always be a tree selection since we are in the
// taxonomic tree view. Just in case this will be used in another spot.
if(menuSelection instanceof TreeSelection){
- Taxon taxon = (Taxon) ((TreeSelection) menuSelection).getFirstElement();
- logger.debug("Selected taxon: " + taxon);
- return taxon;
+ TaxonNode taxonNode = (TaxonNode) ((TreeSelection) menuSelection).getFirstElement();
+ logger.debug("Selected taxon: " + taxonNode);
+ return taxonNode;
}
return null;
}
return defaultUndoContext;
}
- public static boolean isDirty(Taxon taxon){
+ /**
+ * Whether a taxonNode has unsaved changes.
+ *
+ * @param taxonNode
+ * @return
+ */
+ public static boolean isDirty(TaxonNode taxonNode){
for (IEditorReference reference : getActivePage().getEditorReferences()) {
TaxonEditorInput editorInput;
try {
editorInput = (TaxonEditorInput) reference.getEditorInput();
- if(editorInput.getTaxon().equals(taxon) && reference.isDirty()){
+ if(editorInput.getTaxonNode().equals(taxonNode) && reference.isDirty()){
return true;
}
} catch (PartInitException e) {
}
/**
- * @param parentElement
- * @param childTaxon
+ *
+ * @param element
+ * @param parentElement
*/
public static void selectInNavigator(Object element, Object parentElement) {
TaxonNavigator navigator = (TaxonNavigator) TaxeditorEditorPlugin.getDefault().getWorkbench().
if (parentElement != null) {
viewer.setExpandedState(parentElement, true);
}
- viewer.setSelection(new StructuredSelection((Taxon) element));
+ viewer.setSelection(new StructuredSelection((TaxonNode) element));
+ }
+ }
+ }
+
+ /**
+ * @param selection
+ */
+ public static void openSearch(Object selection) {
+ if(selection instanceof Taxon){
+ Taxon taxon = (Taxon) selection;
+
+ handleOpeningOfMultipleTaxonNodes(taxon.getTaxonNodes());
+
+ }else if(selection instanceof Synonym){
+ Synonym synonym = (Synonym) selection;
+
+ Set<TaxonNode> taxonNodes = new HashSet<TaxonNode>();
+ for (Taxon taxon : synonym.getAcceptedTaxa()){
+ taxonNodes.addAll(taxon.getTaxonNodes());
}
+ handleOpeningOfMultipleTaxonNodes(taxonNodes);
+
+ }else{
+ warningDialog("You chose to open a name that has no connection to a taxa. The Editor does not support editing of such a content type at the moment.");
+ logger.warn("Could not open editor for selection. Selection was of type: " + selection.getClass().getSimpleName());
+ }
+
+ }
+
+ /**
+ * @param taxonNodes
+ */
+ private static void handleOpeningOfMultipleTaxonNodes(
+ Set<TaxonNode> taxonNodes) {
+
+ if(taxonNodes.size() == 1){
+ openEditor(taxonNodes.iterator().next());
+ }else{
+ // FIXME implement a dialog that shows all possible taxa and let the user choose which he wants to open.
+ warningDialog("The accepted taxon is either in multiple taxonmoic views or the synonym has" +
+ " more than one accepted taxon. This case is not handled yet by the software.");
}
}
}
\ No newline at end of file
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
/**
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
- Taxon parentTaxon = NavigationUtil.getCurrentSelection(event);
+ TaxonNode parentTaxonNode = NavigationUtil.getCurrentSelection(event);
// Open editor for new taxon
- NavigationUtil.openEmpty(parentTaxon);
+ NavigationUtil.openEmpty(parentTaxonNode);
return null;
}
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.commands.operations.IUndoableOperation;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
-import eu.etaxonomy.taxeditor.operations.DeleteTaxonOperation;
+import eu.etaxonomy.taxeditor.operations.DeleteTaxonNodeOperation;
/**
* @author n.hoffmann
* @created 06.04.2009
* @version 1.0
*/
-public class DeleteTaxonHandler extends AbstractHandler implements IHandler{
+public class DeleteTaxonNodeHandler extends AbstractHandler implements IHandler{
private static final Logger logger = Logger
- .getLogger(DeleteTaxonHandler.class);
+ .getLogger(DeleteTaxonNodeHandler.class);
public Object execute(ExecutionEvent event) throws ExecutionException {
-
- Taxon taxon = NavigationUtil.getCurrentSelection(event);
+ // FIXME make operation handle taxon node?
+ TaxonNode taxonNode = NavigationUtil.getCurrentSelection(event);
IUndoableOperation operation;
try {
- operation = new DeleteTaxonOperation(event.getCommand().getName(),
- NavigationUtil.getUndoContext(), taxon);
+ operation = new DeleteTaxonNodeOperation(event.getCommand().getName(),
+ NavigationUtil.getUndoContext(), taxonNode);
NavigationUtil.executeOperation(operation);
} catch (NotDefinedException e) {
logger.warn("Command name not set");
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
-import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
/**
ISelection selection = HandlerUtil.getActiveMenuSelection(event);
- IdentifiableEntity<?> entity = (IdentifiableEntity<?>) ((StructuredSelection) selection).getFirstElement();
+ Object selectedObject = ((StructuredSelection) selection).getFirstElement();
- NavigationUtil.openEditor(entity);
+ if(selectedObject instanceof TaxonNode){
+ NavigationUtil.openEditor((TaxonNode) selectedObject);
+ }else{
+ throw new IllegalArgumentException("selectedObject is not of type TaxonNode");
+ }
return null;
}
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.editor.name.TaxonSearchDialog;
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
+import eu.etaxonomy.taxeditor.operations.IPostOperationEnabled;
import eu.etaxonomy.taxeditor.operations.MoveTaxonOperation;
/**
* @created 01.04.2009
* @version 1.0
*/
-public class MoveTaxonHandler extends AbstractHandler {
+public class MoveTaxonHandler extends AbstractHandler implements IPostOperationEnabled {
private static final Logger logger = Logger
.getLogger(MoveTaxonHandler.class);
+ private TaxonNode parentTaxonNode;
/* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = NavigationUtil.getShell();
- Taxon taxon = (Taxon) NavigationUtil.getCurrentSelection(event);
-
+ TaxonNode taxonNode = NavigationUtil.getCurrentSelection(event);
+
Dialog dialog = new TaxonSearchDialog(shell);
Object value = ((TaxonSearchDialog) dialog).open();
- logger.warn("child " +taxon.toString());
- logger.warn("parent " + ((Taxon) value).toString());
+ logger.warn("child " +taxonNode.getTaxon().toString());
+ logger.warn("parent " + ((TaxonNode) value).getTaxon().toString());
- if (value instanceof Taxon) {
- Taxon parentTaxon = (Taxon) value;
+ if (value instanceof TaxonNode) {
+ parentTaxonNode = (TaxonNode) value;
- if(NavigationUtil.isDirty(parentTaxon)){
+ if(NavigationUtil.isDirty(parentTaxonNode)){
MessageDialog.openWarning(shell, "Unsaved Parent Taxon", "There are unsaved " +
- "changes in the parent taxon. Pleas save first.");
+ "changes in the parent taxon. Please save first.");
return null;
}
IUndoableOperation operation = new MoveTaxonOperation
("Move taxon to new parent", NavigationUtil.getUndoContext(),
- taxon, parentTaxon); //$NON-NLS-1$
+ taxonNode, parentTaxonNode, this); //$NON-NLS-1$
NavigationUtil.executeOperation(operation);
} else {
- logger.warn("TaxonSearchDialog did not return a Taxon object.");
+ logger.warn("TaxonSearchDialog did not return a TaxonNode object.");
}
return null;
}
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
+ */
+ public boolean postOperation(CdmBase objectAffectedByOperation) {
+ NavigationUtil.selectInNavigator(objectAffectedByOperation, parentTaxonNode);
+ return true;
+ }
}
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
import eu.etaxonomy.taxeditor.operations.CreateChildTaxonOperation;
IHandler, IPostOperationEnabled {
private static final Logger logger = Logger
.getLogger(QuickCreateChildTaxonHandler.class);
- private Taxon parentTaxon;
+
+ private TaxonNode parentTaxonNode;
/* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = HandlerUtil.getActiveShell(event);
- parentTaxon = NavigationUtil.getCurrentSelection(event);
+ parentTaxonNode = NavigationUtil.getCurrentSelection(event);
- if(NavigationUtil.isDirty(parentTaxon)){
+ if(NavigationUtil.isDirty(parentTaxonNode)){
MessageDialog.openWarning(shell, "Unsaved Parent Taxon", "There are unsaved " +
"changes in the parent taxon. Pleas save first.");
return null;
CreateChildTaxonOperation operation;
try {
operation = new CreateChildTaxonOperation(event.getCommand().getName(),
- NavigationUtil.getUndoContext(), parentTaxon, name, this);
+ NavigationUtil.getUndoContext(), parentTaxonNode, name, this);
IStatus status = EditorUtil.executeOperation(operation);
if(status.getCode() == TaxeditorStorePlugin.ERROR_SAVING_ZERO_NAME){
MessageDialog.openWarning(shell, "No Name Specified", "An attempt was made to save a taxon with" +
" an empty name. Operation was cancelled");
- }
-
-
-
+ }
} catch (NotDefinedException e) {
logger.warn("Command name not set");
}
-
logger.info("Taxon created");
}
}
public boolean postOperation(CdmBase objectAffectedByOperation) {
- NavigationUtil.selectInNavigator(objectAffectedByOperation, parentTaxon);
+ NavigationUtil.selectInNavigator(objectAffectedByOperation, parentTaxonNode);
return true;
}
}
import org.eclipse.ui.IMemento;\r
import org.eclipse.ui.IPersistableElement;\r
\r
-import eu.etaxonomy.cdm.model.taxon.Taxon;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonomicTree;\r
import eu.etaxonomy.taxeditor.store.CdmStore;\r
\r
/**\r
* @version 1.0\r
*/\r
public class NavigatorRoot extends PlatformObject implements IAdaptable, IPersistableElement, IElementFactory {\r
-// implements IAdaptable, IPersistableElement, IElementFactory {\r
+\r
private static final Logger logger = Logger.getLogger(NavigatorRoot.class);\r
\r
- public List<Taxon> getParentBeans() {\r
- return CdmStore.getDefault().getRootTaxa();\r
+ public List<TaxonomicTree> getParentBeans() {\r
+ List<TaxonomicTree> trees = CdmStore.getDefault().getTaxonomicTrees();\r
+ return trees;\r
}\r
\r
/* (non-Javadoc)\r
* @see org.eclipse.ui.IPersistableElement#getFactoryId()\r
*/\r
public String getFactoryId() {\r
- // TODO Auto-generated method stub\r
return null;\r
}\r
\r
* @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)\r
*/\r
public void saveState(IMemento memento) {\r
- // TODO Auto-generated method stub\r
- \r
}\r
\r
/* (non-Javadoc)\r
* @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento)\r
*/\r
public IAdaptable createElement(IMemento memento) {\r
- // TODO Auto-generated method stub\r
return null;\r
}\r
}\r
import eu.etaxonomy.cdm.model.taxon.Synonym;\r
import eu.etaxonomy.cdm.model.taxon.Taxon;\r
import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
import eu.etaxonomy.taxeditor.editor.name.IterableSynonymyList;\r
\r
/**\r
Object[] children = null;\r
if (parentElement instanceof Synonym) {\r
children = NO_CHILDREN;\r
- } else if (parentElement instanceof Taxon) {\r
+ } else if (parentElement instanceof TaxonNode) {\r
List<TaxonBase> list = new ArrayList<TaxonBase>();\r
\r
- for (TaxonBase taxonBase : new IterableSynonymyList((Taxon) parentElement)) {\r
+ Taxon taxon = ((TaxonNode) parentElement).getTaxon();\r
+ \r
+ for (TaxonBase taxonBase : new IterableSynonymyList(taxon)) {\r
if (taxonBase instanceof Synonym) {\r
list.add(taxonBase);\r
}\r
import org.eclipse.jface.viewers.ITreeContentProvider;\r
import org.eclipse.jface.viewers.Viewer;\r
\r
-import eu.etaxonomy.cdm.model.taxon.Taxon;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
\r
/**\r
* @author p.ciardelli\r
\r
public Object[] getChildren(Object parentElement) {\r
\r
- if (parentElement instanceof NavigatorRoot) {\r
- return ((NavigatorRoot) parentElement).getParentBeans().toArray();\r
- }\r
- \r
- if (parentElement instanceof Taxon) {\r
- return ((Taxon) parentElement).getTaxonomicChildren().toArray();\r
+ if (parentElement instanceof TaxonNode) {\r
+ return ((TaxonNode) parentElement).getChildNodes().toArray();\r
}\r
\r
return new Object[0];\r
}\r
\r
public Object getParent(Object element) {\r
+// if(element instanceof TaxonNode){\r
+// return ((TaxonNode) element).getParent();\r
+// } \r
return null;\r
}\r
\r
import org.eclipse.ui.navigator.IDescriptionProvider;\r
\r
import eu.etaxonomy.cdm.model.taxon.Taxon;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
\r
/**\r
* @author p.ciardelli\r
}\r
\r
public String getText(Object element) {\r
- if (element instanceof Taxon &&\r
- ((Taxon) element).getName() != null) {\r
- \r
- return ((Taxon) element).getName().getTitleCache();\r
+ if (element instanceof TaxonNode){\r
+ Taxon taxon = ((TaxonNode) element).getTaxon();\r
+ return taxon.getName() != null ? taxon.getName().getTitleCache() : new String();\r
}\r
return new String();\r
}\r
* @see org.eclipse.ui.navigator.IDescriptionProvider#getDescription(java.lang.Object)\r
*/\r
public String getDescription(Object anElement) {\r
- if (anElement instanceof Taxon) {\r
- Taxon data = (Taxon) anElement;\r
+ if (anElement instanceof TaxonNode) {\r
+ Taxon data = ((TaxonNode) anElement).getTaxon();\r
return "Taxon: " + data.getTitleCache(); //$NON-NLS-1$\r
}\r
return null;\r
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.navigation.navigator;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+import eu.etaxonomy.cdm.model.taxon.TaxonomicTree;
+
+/**
+ * @author n.hoffmann
+ * @created 17.06.2009
+ * @version 1.0
+ */
+public class NavigatorTaxonomicTreeContentProvider implements ITreeContentProvider {
+ private static final Logger logger = Logger
+ .getLogger(NavigatorTaxonomicTreeContentProvider.class);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+ */
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof NavigatorRoot) {
+ return ((NavigatorRoot) parentElement).getParentBeans().toArray();
+ }
+
+ if(parentElement instanceof TaxonomicTree) {
+ return ((TaxonomicTree) parentElement).getRootNodes().toArray();
+ }
+
+ return new Object[0];
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+ */
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+ */
+ public boolean hasChildren(Object element) {
+ return this.getChildren(element).length > 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object inputElement) {
+ return this.getChildren(inputElement);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.navigation.navigator;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.navigator.IDescriptionProvider;
+
+import eu.etaxonomy.cdm.model.taxon.TaxonomicTree;
+
+/**
+ * @author n.hoffmann
+ * @created 17.06.2009
+ * @version 1.0
+ */
+public class NavigatorTaxonomicTreeLabelProvider extends ColumnLabelProvider
+implements ILabelProvider, IDescriptionProvider, IStyledLabelProvider {
+ private static final Logger logger = Logger
+ .getLogger(NavigatorTaxonomicTreeLabelProvider.class);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ColumnLabelProvider#getImage(java.lang.Object)
+ */
+ @Override
+ public Image getImage(Object element) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText(Object element) {
+ if(element instanceof TaxonomicTree){
+ String text = ((TaxonomicTree) element).getName().getText();
+ return text != null ? text : "Unnamed Taxonomic Tree";
+ }
+ return new String();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.IDescriptionProvider#getDescription(java.lang.Object)
+ */
+ public String getDescription(Object anElement) {
+ if (anElement instanceof TaxonomicTree) {
+ return "Taxonomic Tree: " + ((TaxonomicTree) anElement).getTitleCache(); //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
+ */
+ public StyledString getStyledText(Object element) {
+ return new StyledString(getText(element));
+ }
+}
import org.eclipse.ui.navigator.ICommonActionConstants;\r
import org.eclipse.ui.navigator.ICommonActionExtensionSite;\r
\r
-import eu.etaxonomy.cdm.model.taxon.Taxon;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;\r
\r
/**\r
if (selection instanceof TreeSelection) {\r
Object[] selections = ((TreeSelection) selection).toArray();\r
for (Object element : ((TreeSelection) selection).toArray()) {\r
- if (element instanceof Taxon) {\r
- NavigationUtil.openEditor((Taxon) element);\r
+ if (element instanceof TaxonNode) {\r
+ NavigationUtil.openEditor((TaxonNode) element);\r
} \r
}\r
}\r
import org.eclipse.ui.navigator.CommonDropAdapter;\r
import org.eclipse.ui.navigator.CommonDropAdapterAssistant;\r
\r
-import eu.etaxonomy.cdm.model.taxon.Taxon;\r
+import eu.etaxonomy.cdm.model.common.CdmBase;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
import eu.etaxonomy.taxeditor.model.NameUtil;\r
-import eu.etaxonomy.taxeditor.model.TaxonUtil;\r
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;\r
+import eu.etaxonomy.taxeditor.operations.IPostOperationEnabled;\r
import eu.etaxonomy.taxeditor.operations.MoveTaxonOperation;\r
\r
/**\r
* @created 03.06.2009\r
* @version 1.0\r
*/\r
-public class TaxonDropAdapterAssistant extends CommonDropAdapterAssistant {\r
+public class TaxonDropAdapterAssistant extends CommonDropAdapterAssistant implements IPostOperationEnabled{\r
private static final Logger logger = Logger\r
.getLogger(TaxonDropAdapterAssistant.class);\r
\r
public static final String ID = "eu.etaxonomy.taxeditor.navigation.navigator.dropassistant"; //$NON-NLS-1$\r
+\r
+ private TaxonNode newParentTaxonNode;\r
\r
/* (non-Javadoc)\r
* @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#handleDrop(org.eclipse.ui.navigator.CommonDropAdapter, org.eclipse.swt.dnd.DropTargetEvent, java.lang.Object)\r
ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();\r
if (selection instanceof TreeSelection) {\r
Object element = ((TreeSelection) selection).getFirstElement();\r
- if (element instanceof Taxon) {\r
- Taxon childTaxon = (Taxon) element;\r
- if (target instanceof Taxon) {\r
- Taxon parentTaxon = (Taxon) target;\r
+ if (element instanceof TaxonNode) {\r
+ TaxonNode childTaxonNode = (TaxonNode) element;\r
+ if (target instanceof TaxonNode) {\r
+ TaxonNode parentTaxonNode = (TaxonNode) target;\r
\r
- return moveTaxon(childTaxon, parentTaxon);\r
+ return moveTaxon(childTaxonNode, parentTaxonNode);\r
}\r
}\r
}\r
- \r
-// IContainer target = getActualTarget((IResource) dropAdapter\r
-// .getCurrentTarget());\r
-// IContainer target = \r
-// if (target != null && target.isAccessible()) {\r
-// try {\r
-// target.refreshLocal(IResource.DEPTH_ONE, null);\r
-// } catch (CoreException e) {\r
-// }\r
-// }\r
- \r
+ \r
return Status.CANCEL_STATUS;\r
}\r
\r
@Override\r
public IStatus validateDrop(Object target, int operation,\r
TransferData transferType) {\r
- if (target instanceof Taxon) {\r
+ if (target instanceof TaxonNode) {\r
return Status.OK_STATUS;\r
}\r
return Status.CANCEL_STATUS;\r
\r
\r
/**\r
- * @param childTaxon\r
+ * @param childTaxonNode\r
* @param parentTaxon\r
* @return\r
*/\r
- private IStatus moveTaxon(Taxon childTaxon, Taxon newParentTaxon) {\r
+ private IStatus moveTaxon(TaxonNode childTaxonNode, TaxonNode newParentTaxonNode) {\r
+ \r
+ this.newParentTaxonNode = newParentTaxonNode;\r
\r
// Make sure parentTaxon is not a child\r
- if (TaxonUtil.isTaxonChildOfTaxon(newParentTaxon, childTaxon)) {\r
+ if (childTaxonNode.getParent().equals(newParentTaxonNode)){\r
\r
MessageDialog.openError(NavigationUtil.getShell(), "Can't move taxon.",\r
- "'" + NameUtil.getDisplayName(childTaxon) + "' sits above " +\r
- "'" + NameUtil.getDisplayName(newParentTaxon) + "' " +\r
+ "'" + NameUtil.getDisplayName(childTaxonNode.getTaxon()) + "' sits above " +\r
+ "'" + NameUtil.getDisplayName(newParentTaxonNode.getTaxon()) + "' " +\r
"in the taxonomic hierarchy.");\r
\r
return Status.CANCEL_STATUS;\r
}\r
\r
// Make sure taxon is not being dropped onto itself\r
- if (childTaxon.equals(newParentTaxon)) {\r
+ if (childTaxonNode.equals(newParentTaxonNode)) {\r
return Status.CANCEL_STATUS;\r
}\r
\r
// Make sure parent taxon does not have unsaved changes\r
- if (NavigationUtil.isDirty(newParentTaxon)){\r
+ if (NavigationUtil.isDirty(newParentTaxonNode)){\r
MessageDialog.openWarning(NavigationUtil.getShell(), "Unsaved Parent Taxon", "There are unsaved " +\r
"changes in the parent taxon. Pleas save first.");\r
return Status.CANCEL_STATUS;\r
logger.error("Workspace undo context is null. DND operation cancelled");\r
return Status.CANCEL_STATUS;\r
}\r
+\r
IUndoableOperation operation = new MoveTaxonOperation\r
- ("Move Taxon", workspaceUndoContext, childTaxon, newParentTaxon);\r
+ ("Move Taxon", workspaceUndoContext, childTaxonNode, newParentTaxonNode, this);\r
NavigationUtil.executeOperation(operation); \r
\r
- logger.info("Moved taxon " + childTaxon + " to new parent " + newParentTaxon);\r
\r
- NavigationUtil.selectInNavigator(childTaxon, newParentTaxon);\r
+ logger.info("Moved taxon " + childTaxonNode + " to new parent " + newParentTaxonNode);\r
+ \r
+ NavigationUtil.selectInNavigator(childTaxonNode, newParentTaxonNode);\r
\r
return Status.OK_STATUS;\r
}\r
+\r
+ /* (non-Javadoc)\r
+ * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)\r
+ */\r
+ public boolean postOperation(CdmBase objectAffectedByOperation) {\r
+ NavigationUtil.selectInNavigator(objectAffectedByOperation, newParentTaxonNode);\r
+ return true;\r
+ }\r
}\r
import org.eclipse.ui.navigator.ILinkHelper;\r
\r
import eu.etaxonomy.cdm.model.taxon.Taxon;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;\r
\r
/**\r
if (selection == null || selection.isEmpty()) {\r
return;\r
}\r
- if (selection.getFirstElement() instanceof Taxon) {\r
- Taxon taxon = (Taxon) selection.getFirstElement();\r
- TaxonEditorInput taxonEditorInput = TaxonEditorInput.NewInstance(taxon.getUuid());\r
+ if (selection.getFirstElement() instanceof TaxonNode) {\r
+ TaxonNode taxonNode = (TaxonNode) selection.getFirstElement();\r
+ TaxonEditorInput taxonEditorInput = TaxonEditorInput.NewInstance(taxonNode.getUuid());\r
IEditorPart editor = null;\r
if ((editor = page.findEditor(taxonEditorInput)) != null) {\r
page.bringToTop(editor);\r
*/\r
public IStructuredSelection findSelection(IEditorInput editorInput) {\r
if (editorInput instanceof TaxonEditorInput) {\r
- Taxon taxon = ((TaxonEditorInput) editorInput).getTaxon();\r
- if (taxon != null) {\r
- return new StructuredSelection(taxon);\r
+ TaxonNode taxonNode = ((TaxonEditorInput) editorInput).getTaxonNode();\r
+ if (taxonNode != null) {\r
+ return new StructuredSelection(taxonNode);\r
}\r
}\r
return StructuredSelection.EMPTY;\r
import org.apache.log4j.Logger;\r
import org.eclipse.core.runtime.IAdaptable;\r
import org.eclipse.jface.viewers.TreePath;\r
-import org.eclipse.jface.viewers.ViewerComparator;\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.ui.IMemento;\r
import org.eclipse.ui.IViewSite;\r
\r
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;\r
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;\r
-import eu.etaxonomy.cdm.model.taxon.Taxon;\r
+import eu.etaxonomy.cdm.model.common.CdmBase;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonomicTree;\r
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;\r
import eu.etaxonomy.taxeditor.model.DataChangeBridge;\r
import eu.etaxonomy.taxeditor.model.IDataChangeBehavior;\r
}\r
}\r
if (treePaths.size() > 0) {\r
- TreePath[] treePathsArray = (TreePath[]) treePaths.toArray(new TreePath[treePaths.size()]);\r
- this.getCommonViewer().setExpandedTreePaths(treePathsArray);\r
+ this.getCommonViewer().setExpandedTreePaths(treePaths.toArray(new TreePath[0]));\r
}\r
}\r
\r
* @return\r
*/\r
private TreePath createTreePathFromString(String string) {\r
- List<Taxon> pathList = new ArrayList<Taxon>();\r
+ List<TaxonNode> pathList = new ArrayList<TaxonNode>();\r
+ \r
+ if(string.length() == 0) return null; \r
+ \r
for (String uuid : string.split(" ")) {\r
- Taxon taxon = (Taxon) CdmStore.getTaxonService().getTaxonByUuid(UUID.fromString(uuid));\r
- if (taxon == null) {\r
+ TaxonNode taxonNode = CdmStore.getTaxonService().getTaxonNodeByUuid(UUID.fromString(uuid));\r
+ if (taxonNode == null) {\r
return null;\r
}\r
- pathList.add(taxon);\r
+ pathList.add(taxonNode);\r
}\r
return new TreePath(pathList.toArray());\r
}\r
String path = "";\r
for (int i = 0; i < pathLength; i++) {\r
Object segment = treePath.getSegment(i);\r
- if (segment instanceof Taxon) {\r
- path += ((Taxon) segment).getUuid().toString() + " ";\r
+ // FIXME I don't see the meaning of filtering out objects here. \r
+ // Each time a new content type is added to the navigator we have to add it here as \r
+ // well. What is the worst that could happen when a "Non-taxon tree path segment" is encountered\r
+ // or when exactly could this happen? Anomalies should also be handled in the restore code. (n.hoffmann)\r
+ if ((segment instanceof TaxonomicTree) || (segment instanceof TaxonNode)) {\r
+ path += ((CdmBase) segment).getUuid().toString() + " ";\r
} else {\r
logger.warn("Non-taxon tree path segment " + segment);\r
}\r
*/\r
public void createPartControl(Composite aParent) {\r
super.createPartControl(aParent);\r
- ViewerComparator comparator = getCommonViewer().getComparator();\r
restoreState(memento); \r
}\r
\r
if(dataChangeBehavior == null){\r
dataChangeBehavior = new TaxonNavigatorDataChangeBehavior(this);\r
}\r
+ \r
DataChangeBridge.handleDataChange(changeEvents, dataChangeBehavior);\r
}\r
\r
}\r
return super.getFrameToolTipText(element);\r
}\r
+ \r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.ui.part.WorkbenchPart#dispose()\r
+ */\r
+ @Override\r
+ public void dispose() {\r
+ conversation.unregisterForDataStoreChanges(this);\r
+\r
+ super.dispose();\r
+ }\r
}
\ No newline at end of file
package eu.etaxonomy.taxeditor.navigation.navigator;
import org.apache.log4j.Logger;
+import org.eclipse.ui.navigator.CommonViewer;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeEvent.EventType;
*/
public void reactOnDataChange(CdmDataChangeMap events) {
-
if(isRelevant(events)){
- source.getCommonViewer().refresh();
+ CommonViewer viewer = source.getCommonViewer();
+
+ viewer.refresh();
logger.info("DataStore update caused a refresh of the taxonomic tree");
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;\r
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;\r
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;\r
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;\r
import eu.etaxonomy.taxeditor.store.CdmStore;\r
resultViewer.setLabelProvider(new SearchResultLabelProvider());\r
resultViewer.addDoubleClickListener(new IDoubleClickListener() {\r
public void doubleClick(DoubleClickEvent event) {\r
- try {\r
- IdentifiableEntity<?> selection = (IdentifiableEntity<?>) ((StructuredSelection) event.getSelection()).getFirstElement();\r
- NavigationUtil.openEditor(selection);\r
- }catch (IllegalArgumentException e){\r
- // pass\r
- }catch (Exception e) {\r
- logger.warn("Could not open editor from search result.", e);\r
- }\r
+ Object selection = ((StructuredSelection) event.getSelection()).getFirstElement();\r
+ \r
+ NavigationUtil.openSearch(selection);\r
}\r
});\r
\r
import java.util.List;\r
\r
import org.apache.log4j.Logger;\r
-import org.eclipse.core.commands.operations.IUndoableOperation;\r
import org.eclipse.jface.action.GroupMarker;\r
import org.eclipse.jface.action.MenuManager;\r
-import org.eclipse.jface.dialogs.MessageDialog;\r
import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;\r
import org.eclipse.jface.viewers.DoubleClickEvent;\r
import org.eclipse.jface.viewers.IDoubleClickListener;\r
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;\r
import eu.etaxonomy.taxeditor.model.DataChangeBridge;\r
import eu.etaxonomy.taxeditor.model.IDataChangeBehavior;\r
-import eu.etaxonomy.taxeditor.model.NameUtil;\r
import eu.etaxonomy.taxeditor.model.TaxonTransfer;\r
-import eu.etaxonomy.taxeditor.model.TaxonUtil;\r
-import eu.etaxonomy.taxeditor.navigation.NavigationUtil;\r
import eu.etaxonomy.taxeditor.operations.IPostOperationEnabled;\r
-import eu.etaxonomy.taxeditor.operations.MoveTaxonOperation;\r
import eu.etaxonomy.taxeditor.store.CdmStore;\r
\r
/**\r
* @version 1.0\r
* @author n.hoffmann\r
*/\r
-@Deprecated public class TaxonomicTreeView extends ViewPart implements IConversationEnabled, IPostOperationEnabled {\r
+@Deprecated \r
+public class TaxonomicTreeView extends ViewPart implements IConversationEnabled, IPostOperationEnabled {\r
private static final Logger logger = Logger.getLogger(TaxonomicTreeView.class);\r
\r
public static final String ID = "eu.etaxonomy.taxeditor.navigation.taxonomictree.treeView"; //$NON-NLS-1$\r
if (element instanceof Taxon) {\r
// FIXME call EditTaxonHandler\r
logger.info("Doubleclick on taxon element. Should open editor now");\r
- NavigationUtil.openEditor((Taxon) element);\r
+// NavigationUtil.openEditor((Taxon) element);\r
}\r
}\r
}\r
newParentTaxon = (Taxon) event.item.getData();\r
\r
// Make sure parentTaxon is not a child\r
- if (TaxonUtil.isTaxonChildOfTaxon(newParentTaxon, taxon)) {\r
- \r
- MessageDialog.openError(NavigationUtil.getShell(), "Can't move taxon.",\r
- "'" + NameUtil.getDisplayName(taxon) + "' sits above " +\r
- "'" + NameUtil.getDisplayName(newParentTaxon) + "' " +\r
- "in the taxonomic hierarchy.");\r
- \r
- return;\r
- }\r
+// if (TaxonNodeUtil.isTaxonChildOfTaxon(newParentTaxon, taxon)) {\r
+// \r
+// MessageDialog.openError(NavigationUtil.getShell(), "Can't move taxon.",\r
+// "'" + NameUtil.getDisplayName(taxon) + "' sits above " +\r
+// "'" + NameUtil.getDisplayName(newParentTaxon) + "' " +\r
+// "in the taxonomic hierarchy.");\r
+// \r
+// return;\r
+// }\r
\r
// Make sure taxon is not being dropped onto itself\r
if (taxon.equals(newParentTaxon)) {\r
}\r
\r
// Make sure parent taxon does not have unsaved changes\r
- if (NavigationUtil.isDirty(newParentTaxon)){\r
- MessageDialog.openWarning(NavigationUtil.getShell(), "Unsaved Parent Taxon", "There are unsaved " +\r
- "changes in the parent taxon. Pleas save first.");\r
- return;\r
- }\r
+// if (NavigationUtil.isDirty(newParentTaxon)){\r
+// MessageDialog.openWarning(NavigationUtil.getShell(), "Unsaved Parent Taxon", "There are unsaved " +\r
+// "changes in the parent taxon. Pleas save first.");\r
+// return;\r
+// }\r
}\r
\r
- \r
- IUndoableOperation operation = new MoveTaxonOperation\r
- ("Move Taxon", NavigationUtil.getUndoContext(), taxon, newParentTaxon);\r
- \r
- NavigationUtil.executeOperation(operation); \r
+// \r
+// IUndoableOperation operation = new MoveTaxonOperation\r
+// ("Move Taxon", NavigationUtil.getUndoContext(), taxon, newParentTaxon);\r
+// \r
+// NavigationUtil.executeOperation(operation); \r
}\r
});\r
}\r
--- /dev/null
+// $Id$
+/**
+ * Copyright (C) 2007 EDIT
+ * European Distributed Institute of Taxonomy
+ * http://www.e-taxonomy.eu
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
+
+package eu.etaxonomy.taxeditor.dialogs;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.springframework.security.BadCredentialsException;
+import org.springframework.security.providers.UsernamePasswordAuthenticationToken;
+
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author n.hoffmann
+ * @created 16.06.2009
+ * @version 1.0
+ */
+public class LoginDialog extends Dialog {
+
+
+ private static final Logger logger = Logger.getLogger(LoginDialog.class);
+
+ private static Text passwordText;
+ private static Text usernameText;
+
+ /**
+ * @param parentShell
+ */
+ public LoginDialog(Shell parentShell) {
+ super(parentShell);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ //add controls to composite as necessary
+
+
+ // Label for the heading
+ final CLabel titleLabel = new CLabel(composite, SWT.NONE);
+ titleLabel.setText("User Login");
+
+ // Label for the username
+ final CLabel userNameLabel = new CLabel(composite, SWT.NONE);
+ userNameLabel.setText("Username");
+
+ // Textfield for the username
+ usernameText = new Text(composite, SWT.BORDER);
+ usernameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ // Label for the password
+ final CLabel passwordLabel = new CLabel(composite, SWT.NONE);
+ passwordLabel.setText("Password");
+
+ // Textfield for the password
+ passwordText = new Text(composite, SWT.BORDER);
+ passwordText.setEchoChar('*');
+ passwordText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+
+ return composite;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+
+ String username = usernameText.getText().trim();
+ String password = passwordText.getText().trim();
+
+ // password is stored as salted md5 hash
+ String passwordHash = password;
+
+ UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, passwordHash);
+
+ try{
+ CdmStore.getAuthenticationManager().authenticate(token);
+ }catch(BadCredentialsException e){
+ logger.error("Bad credentials");
+ }catch(IllegalArgumentException e){
+ logger.error("Null argument for either user or password");
+ }
+
+ super.okPressed();
+ }
+
+
+}
* This method is for developer convenience.
*/
public static void notImplementedMessage(){
+ warningDialog("Not yet implemented");
+ }
+
+ public static void warningDialog(String warning){
MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
- messageBox.setText("Not yet implemented");
+ messageBox.setText(warning);
messageBox.open();
}
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
+import eu.etaxonomy.cdm.model.reference.ReferenceBase;
+import eu.etaxonomy.cdm.model.taxon.Synonym;
import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.cdm.model.taxon.TaxonBase;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
import eu.etaxonomy.taxeditor.store.CdmStore;
* @created 25.03.2009
* @version 1.0
*/
-public class TaxonUtil {
+public class TaxonNodeUtil {
private static final Logger logger = Logger
- .getLogger(TaxonUtil.class);
-
+ .getLogger(TaxonNodeUtil.class);
/**
- * TODO error handling. throw exceptions if something goes wrong
*
- * @param taxonUuid
+ * @param taxonNodeUuid
* @return
*/
- public static boolean deleteTaxonBaseIsolated(UUID taxonUuid){
+ public static boolean deleteTaxonNodeIsolated(UUID taxonNodeUuid){
// get a new conversation
ConversationHolder conversation = CdmStore.NewTransactionalConversation();
- // find the taxonBase
- TaxonBase<?> taxonBase = CdmStore.getTaxonService().findByUuid(taxonUuid);
- // delete the taxonBase
- CdmStore.getTaxonService().delete(taxonBase);
+
+ TaxonNode taxonNode = CdmStore.getTaxonService().getTaxonNodeByUuid(taxonNodeUuid);
+
+ boolean result = taxonNode.remove();
+
// commit the conversation and throw it away
conversation.commit(true);
- return true;
+ return result;
}
- public static Taxon addChildTaxonBaseIsolated(UUID taxonUuid, TaxonNameBase<?, ?> newTaxonName){
+ public static TaxonNode addChildTaxonBaseIsolated(UUID taxonNodeUuid, TaxonNameBase<?, ?> newTaxonName){
// disallow saving of zero length names
if(newTaxonName.getFullTitleCache().length() == 0){
return null;
// get a new conversation
ConversationHolder conversation = CdmStore.NewTransactionalConversation();
// find the taxonBase
- Taxon parentTaxon = (Taxon) CdmStore.getTaxonService().findByUuid(taxonUuid);
+ TaxonNode parentTaxonNode = CdmStore.getTaxonService().getTaxonNodeByUuid(taxonNodeUuid);
// logic to add new taxon name
- Taxon childTaxon = Taxon.NewInstance(newTaxonName, parentTaxon.getSec());
- parentTaxon.addTaxonomicChild(childTaxon, null, null);
+ Taxon childTaxon = Taxon.NewInstance(newTaxonName, parentTaxonNode.getTaxon().getSec());
+ TaxonNode childTaxonNode = parentTaxonNode.addChild(childTaxon);
//not needed here: CdmStore.getTaxonService().save(parentTaxon);
// commit the conversation and throw it away
conversation.commit(true);
- return childTaxon;
+ return childTaxonNode;
}
- public static boolean moveTaxonBaseIsolated(UUID taxonUuid, UUID newParentTaxonUuid){
+ /**
+ *
+ * @param taxonNodeUuid
+ * @param newParentTaxonNodeUuid
+ * @return
+ */
+ public static TaxonNode moveTaxonBaseIsolated(UUID taxonNodeUuid, UUID newParentTaxonNodeUuid){
// get a new conversation
ConversationHolder conversation = CdmStore.NewTransactionalConversation();
- // find the taxonBases
- Taxon taxon = (Taxon) CdmStore.getTaxonService().findByUuid(taxonUuid);
- Taxon newParentTaxon = (Taxon) CdmStore.getTaxonService().findByUuid(newParentTaxonUuid);
-
- Taxon oldParent = taxon.getTaxonomicParent();
- if (oldParent != null) {
- oldParent.removeTaxonomicChild(taxon);
- }
+ // find the taxon node
+ TaxonNode taxonNode = CdmStore.getTaxonService().getTaxonNodeByUuid(taxonNodeUuid);
+ // store all relevant information of taxon node and delete the taxon node.
+ Taxon taxon = taxonNode.getTaxon();
+ ReferenceBase parentChildReference = taxonNode.getReferenceForParentChildRelation();
+ String parentChildMicroReference = taxonNode.getMicroReferenceForParentChildRelation();
+ Synonym synonymUsed = taxonNode.getSynonymToBeUsed();
+
+ taxonNode.remove();
- newParentTaxon.addTaxonomicChild(taxon, null, null);
+ TaxonNode newParentTaxonNode = CdmStore.getTaxonService().getTaxonNodeByUuid(newParentTaxonNodeUuid);
+ TaxonNode newChild = newParentTaxonNode.addChild(taxon, parentChildReference, parentChildMicroReference, synonymUsed);
+ // commit the conversation
conversation.commit(true);
- return true;
+ return newChild;
}
/**
return relations.toArray(new TaxonRelationship[0])[0];
}
-
- /**
- * Returns true if <code>child</code> belongs to the children, grandchildren,
- * etc. of <code>parent</code>.
- *
- * @param child
- * @param parent
- * @return
- */
- public static boolean isTaxonChildOfTaxon(Taxon child, Taxon parent) {
-
- // Traverse all checkTaxon's children
- for (Taxon childTaxon : parent.getTaxonomicChildren()) {
-
- if (childTaxon.equals(child)) {
- return true;
- } else {
-
- // Compare taxon with childTaxon's children
- if (isTaxonChildOfTaxon(child, childTaxon)) {
- return true;
- }
- }
- }
- return false;
- }
}
\r
import eu.etaxonomy.cdm.model.common.CdmBase;\r
import eu.etaxonomy.cdm.model.taxon.Taxon;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
\r
/**\r
* @author p.ciardelli\r
*/\r
protected Taxon taxon;\r
\r
+ /**\r
+ * A reference to the taxons TaxonNode\r
+ */\r
+ protected TaxonNode taxonNode;\r
+\r
/**\r
* \r
* @param label\r
this.postOperationEnabled = postOperationEnabled;\r
}\r
\r
+ /**\r
+ * \r
+ * @param label\r
+ * @param undoContext\r
+ * @param taxonNode\r
+ * @param postOperationEnabled\r
+ */\r
+ public AbstractPostOperation(String label, IUndoContext undoContext, TaxonNode taxonNode, IPostOperationEnabled postOperationEnabled){\r
+ this(label, undoContext, taxonNode.getTaxon(), postOperationEnabled);\r
+ this.taxonNode = taxonNode;\r
+ }\r
+ \r
/**\r
* This method will try to call the post operation on a possibly registered\r
* IPostOperationEnabled implementor. Objects that were affected by the operation \r
import eu.etaxonomy.cdm.model.taxon.Taxon;\r
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;\r
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;\r
-import eu.etaxonomy.taxeditor.model.TaxonUtil;\r
+import eu.etaxonomy.taxeditor.model.TaxonNodeUtil;\r
\r
/**\r
* @author n.hoffmann\r
super(label, undoContext, taxon, postOperationEnabled);\r
this.relatedTaxon = relatedTaxon;\r
\r
- this.taxonRelationship = TaxonUtil.getRelationshipBetweenTwoTaxa(relatedTaxon, taxon);\r
+ this.taxonRelationship = TaxonNodeUtil.getRelationshipBetweenTwoTaxa(relatedTaxon, taxon);\r
this.oldRelationshipType = taxonRelationship.getType();\r
this.newRelationshipType = type;\r
}\r
import eu.etaxonomy.cdm.model.taxon.Taxon;\r
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;\r
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;\r
-import eu.etaxonomy.taxeditor.model.TaxonUtil;\r
+import eu.etaxonomy.taxeditor.model.TaxonNodeUtil;\r
\r
/**\r
* @author p.ciardelli\r
IPostOperationEnabled editor) {\r
super(label, undoContext, taxon, editor);\r
\r
- this.taxonRelationship = TaxonUtil.getRelationshipBetweenTwoTaxa(concept, taxon);\r
+ this.taxonRelationship = TaxonNodeUtil.getRelationshipBetweenTwoTaxa(concept, taxon);\r
this.oldRelationshipType = taxonRelationship.getType();\r
\r
this.concept = concept;\r
import org.eclipse.core.runtime.Status;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.taxeditor.model.TaxonUtil;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.model.TaxonNodeUtil;
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
/**
private TaxonNameBase<?, ?> newTaxonName;
- private Taxon childTaxon;
+ private TaxonNode childTaxonNode;
/**
* @param conversationEnabled
*/
public CreateChildTaxonOperation(String label, IUndoContext undoContext,
- Taxon taxon, TaxonNameBase<?, ?> name, IPostOperationEnabled postOperationEnabled) {
- super(label, undoContext, taxon, postOperationEnabled);
+ TaxonNode taxonNode, TaxonNameBase<?, ?> name, IPostOperationEnabled postOperationEnabled) {
+ super(label, undoContext, taxonNode, postOperationEnabled);
this.newTaxonName = name;
}
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
- childTaxon = TaxonUtil.addChildTaxonBaseIsolated(taxon.getUuid(), newTaxonName);
+ childTaxonNode = TaxonNodeUtil.addChildTaxonBaseIsolated(taxonNode.getUuid(), newTaxonName);
- if(childTaxon != null){
- return postExecute(childTaxon);
+ if(childTaxonNode != null){
+ return postExecute(childTaxonNode);
}else{
return new Status(IStatus.ERROR, TaxeditorStorePlugin.PLUGIN_ID, TaxeditorStorePlugin.ERROR_SAVING_ZERO_NAME, "Attempt to save taxon with zero length name", null);
}
import eu.etaxonomy.cdm.model.taxon.Taxon;\r
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;\r
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;\r
-import eu.etaxonomy.taxeditor.model.TaxonUtil;\r
+import eu.etaxonomy.taxeditor.model.TaxonNodeUtil;\r
\r
/**\r
* Deletes a relation between two taxa. \r
\r
this.relatedTaxon = relatedTaxon;\r
\r
- relationship = TaxonUtil.getRelationshipBetweenTwoTaxa(relatedTaxon, taxon);\r
+ relationship = TaxonNodeUtil.getRelationshipBetweenTwoTaxa(relatedTaxon, taxon);\r
\r
relationshipType = relationship.getType();\r
\r
import org.eclipse.jface.dialogs.MessageDialog;\r
import org.eclipse.swt.widgets.Shell;\r
\r
-import eu.etaxonomy.cdm.model.taxon.Taxon;\r
-import eu.etaxonomy.taxeditor.model.TaxonUtil;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
+import eu.etaxonomy.taxeditor.model.TaxonNodeUtil;\r
\r
/**\r
- * Delete a taxon from the model.\r
+ * Delete a taxon node from its TaxonomicTree and thus from the current taxonomic view.\r
* \r
- * TODO: Currently all data in session data repository has to be saved before deleting \r
- * a taxon and the whole logic is happening here. This way we would have to implement \r
- * the same logic in another place if we want to delete outside of an operation context\r
- * (NOT undoable). Therefore it is desirable to have the logic implemented in another \r
- * place and merely call a method here.\r
* \r
* @author n.hoffmann\r
* @created 16.01.2009\r
* @version 1.0\r
*/\r
-public class DeleteTaxonOperation extends AbstractPostOperation {\r
+public class DeleteTaxonNodeOperation extends AbstractPostOperation {\r
\r
@SuppressWarnings("unused")\r
- private static Logger logger = Logger.getLogger(DeleteTaxonOperation.class);\r
+ private static Logger logger = Logger.getLogger(DeleteTaxonNodeOperation.class);\r
\r
/**\r
* The taxonomical parent of the taxon to be deleted.\r
*/\r
- private Taxon parentTaxon;\r
+ private TaxonNode parentTaxonNode;\r
\r
- public DeleteTaxonOperation(String text, IUndoContext undoContext,\r
- Taxon taxon) {\r
- super(text, undoContext, taxon, null);\r
+ public DeleteTaxonNodeOperation(String text, IUndoContext undoContext,\r
+ TaxonNode taxonNode) {\r
+ super(text, undoContext, taxonNode, null);\r
\r
- parentTaxon = taxon.getTaxonomicParent();\r
+ parentTaxonNode = taxonNode.getParent();\r
}\r
\r
/* (non-Javadoc)\r
}\r
\r
// Prompt user for confirmation\r
- if(! MessageDialog.openConfirm((Shell) info.getAdapter(Shell.class), "Confirm Deletion", "Are you sure you want to delete taxon '" + taxonName + "'?")){\r
+ if(! MessageDialog.openConfirm((Shell) info.getAdapter(Shell.class), "Confirm Deletion", "Are you sure you want to delete taxon '" + taxonName + "' from this taxonomic view?")){\r
monitor.done();\r
return Status.CANCEL_STATUS;\r
}\r
\r
\r
- // If the taxon has children, cancel operation\r
+ // If the taxon node has child nodes, cancel operation\r
// TODO add option to continue, and delete children\r
- if (taxon.hasTaxonomicChildren()) {\r
+ if (taxonNode.getChildNodes().size() > 0) {\r
MessageDialog.openInformation((Shell) info.getAdapter(Shell.class), "Cannot delete taxon", \r
"'" + taxonName + "' has taxonomic children. " +\r
"These must be manually deleted before their parent.");\r
}\r
\r
// delete the taxon in an isolated conversation\r
- TaxonUtil.deleteTaxonBaseIsolated(taxon.getUuid());\r
+ TaxonNodeUtil.deleteTaxonNodeIsolated(taxonNode.getUuid());\r
\r
\r
return postExecute(null);\r
public IStatus undo(IProgressMonitor monitor, IAdaptable info)\r
throws ExecutionException {\r
// FIXME we have to add old citation\r
- parentTaxon.addTaxonomicChild(taxon, null, null);\r
+ parentTaxonNode.addChild(taxon);\r
// FIXME readding has to take place in an isolated conversation as well\r
// so that all the mediation magic does the rest for us\r
return postExecute(null);\r
import org.eclipse.core.runtime.IStatus;\r
import org.eclipse.core.runtime.Status;\r
\r
-import eu.etaxonomy.cdm.model.taxon.Taxon;\r
-import eu.etaxonomy.taxeditor.model.TaxonUtil;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
+import eu.etaxonomy.taxeditor.model.TaxonNodeUtil;\r
\r
/**\r
* Change the taxonomic parent of a given taxon.\r
/**\r
* A reference to the new taxonomical parent.\r
*/\r
- private Taxon newParentTaxon;\r
+ private TaxonNode newParentTaxonNode;\r
/**\r
* A reference to the former taxonomical parent\r
*/\r
- private Taxon oldParentTaxon;\r
+ private TaxonNode oldParentTaxonNode;\r
\r
public MoveTaxonOperation(String label, IUndoContext undoContext,\r
- Taxon taxon, Taxon newParentTaxon) {\r
- super(label, undoContext, taxon);\r
+ TaxonNode taxonNode, TaxonNode newParentTaxonNode, IPostOperationEnabled postOperationEnabled) {\r
+ super(label, undoContext, taxonNode, null);\r
\r
- this.newParentTaxon = newParentTaxon;\r
+ this.newParentTaxonNode = newParentTaxonNode;\r
\r
- // Save old parent taxon for undo\r
- this.oldParentTaxon = taxon.getTaxonomicParent();\r
+ // Save old parent TaxonNode for undo\r
+ this.oldParentTaxonNode = taxonNode.getParent(); \r
}\r
\r
/* (non-Javadoc)\r
public IStatus execute(IProgressMonitor monitor, IAdaptable info)\r
throws ExecutionException {\r
\r
- TaxonUtil.moveTaxonBaseIsolated(taxon.getUuid(), newParentTaxon.getUuid());\r
+ TaxonNode newTaxonNode = TaxonNodeUtil.moveTaxonBaseIsolated(taxonNode.getUuid(), newParentTaxonNode.getUuid());\r
\r
- return Status.OK_STATUS;\r
+ return postExecute(newTaxonNode);\r
}\r
\r
/* (non-Javadoc)\r
public IStatus undo(IProgressMonitor monitor, IAdaptable info)\r
throws ExecutionException {\r
\r
- TaxonUtil.moveTaxonBaseIsolated(taxon.getUuid(), oldParentTaxon.getUuid());\r
+ TaxonNodeUtil.moveTaxonBaseIsolated(taxonNode.getUuid(), oldParentTaxonNode.getUuid());\r
\r
return Status.OK_STATUS;\r
}\r
import org.junit.Test;
import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.taxeditor.operations.DeleteTaxonOperation;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.operations.DeleteTaxonNodeOperation;
/**
* @author n.hoffmann
* @created 08.04.2009
* @version 1.0
*/
-public class DeleteTaxonOperationTest extends AbstractTaxeditorOperationTest{
+public class DeleteTaxonNodeOperationTest extends AbstractTaxeditorOperationTest{
private static final Logger logger = Logger
- .getLogger(DeleteTaxonOperationTest.class);
+ .getLogger(DeleteTaxonNodeOperationTest.class);
private static Taxon child;
+ private static TaxonNode taxonNode;
+
/**
* @throws java.lang.Exception
*/
taxon.addTaxonomicChild(child, null, null);
- operation = new DeleteTaxonOperation("Delete Taxon", undoContext, taxon);
+ operation = new DeleteTaxonNodeOperation("Delete Taxon", undoContext, taxonNode);
}
/**
- * Test method for {@link eu.etaxonomy.taxeditor.operations.DeleteTaxonOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
+ * Test method for {@link eu.etaxonomy.taxeditor.operations.DeleteTaxonNodeOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
* @throws ExecutionException
*/
@Test
}
/**
- * Test method for {@link eu.etaxonomy.taxeditor.operations.DeleteTaxonOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
+ * Test method for {@link eu.etaxonomy.taxeditor.operations.DeleteTaxonNodeOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
* @throws ExecutionException
*/
@Test
}
/**
- * Test method for {@link eu.etaxonomy.taxeditor.operations.DeleteTaxonOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
+ * Test method for {@link eu.etaxonomy.taxeditor.operations.DeleteTaxonNodeOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
* @throws ExecutionException
*/
@Test
import org.junit.Test;
import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.model.taxon.TaxonomicTree;
import eu.etaxonomy.taxeditor.operations.MoveTaxonOperation;
/**
private static Taxon oldParentTaxon;
private static Taxon newParentTaxon;
+ private static TaxonomicTree tree;
+ private static TaxonNode oldParentTaxonNode;
+ private static TaxonNode newParentTaxonNode;
+ private static TaxonNode taxonNode;
/**
* @throws java.lang.Exception
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception {
+
+
taxon = Taxon.NewInstance(null, null);
+
+
+
oldParentTaxon = Taxon.NewInstance(null, null);
newParentTaxon = Taxon.NewInstance(null, null);
-// oldParentTaxon.addTaxonomicChild(taxon, null, null);
- taxon.setTaxonomicParent(oldParentTaxon, null, null);
- operation = new MoveTaxonOperation("Move Taxon To Different Parent", undoContext, taxon, newParentTaxon);
+ tree = TaxonomicTree.NewInstance(null);
+ oldParentTaxonNode = tree.addRoot(oldParentTaxon, null);
+ newParentTaxonNode = tree.addRoot(newParentTaxon, null);
+
+ taxonNode = oldParentTaxonNode.addChild(taxon);
+
+ operation = new MoveTaxonOperation("Move Taxon To Different Parent", undoContext, taxonNode, newParentTaxonNode, postOperation);
}
/**