From: n.hoffmann Date: Tue, 23 Jun 2009 16:57:51 +0000 (+0000) Subject: Added a bunch of functionality that will be needed when opening the editor with an... X-Git-Tag: rcp.ss-first-working-version~854 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/d2443357084b2484b3733947cb9d8d93290b3436 Added a bunch of functionality that will be needed when opening the editor with an empty datasource, such as creation of trees adding and removing taxa s.o. --- diff --git a/.gitattributes b/.gitattributes index fb6707b44..43a7cf526 100644 --- a/.gitattributes +++ b/.gitattributes @@ -835,22 +835,24 @@ taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/Cre 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/NewTaxonomicTreeWizadPage.java -text +taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonomicTreeWizard.java -text taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/QuickCreateChildTaxonHandler.java -text taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/ShowTaxonomicTreeViewHandler.java -text taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/internal/TaxeditorNavigationPlugin.java -text -taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorPropertyTester.java -text -taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorRoot.java -text -taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorSynonymContentProvider.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/Root.java -text +taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/SynonymContentProvider.java -text +taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/SynonymLabelProvider.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-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigator.java -text taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigatorDataChangeBehavior.java -text +taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodeContentProvider.java -text +taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodeLabelProvider.java -text +taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodePropertyTester.java -text +taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonomicTreeContentProvider.java -text +taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonomicTreeLabelProvider.java -text taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/search/SearchBar.java -text taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/search/SearchResultLabelProvider.java -text taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/search/SearchResultView.java -text @@ -971,6 +973,8 @@ taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/dialogs/UriDialog.java -tex taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/handler/ShowDataSourceViewHandler.java -text taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/AbstractExcelExportWizard.java -text taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/AbstractExcelImportWizard.java -text +taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/BerlinModelExportWizard.java -text +taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/BerlinModelExportWizardPage.java -text taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbExportWizard.java -text taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbExportWizardPage.java -text taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbImportWizard.java -text @@ -990,8 +994,8 @@ taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/NameUtil.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 @@ -1009,12 +1013,14 @@ taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/CreateImageOpera taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/CreateMisapplicationOperation.java -text taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/CreateSynonymInExisitingHomotypicalGroupOperation.java -text taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/CreateSynonymInNewGroupOperation.java -text +taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/CreateTaxonomicTreeOperation.java -text taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteConceptRelationOperation.java -text taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteDescriptionElementOperation.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/DeleteTaxonNodeOperation.java -text +taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteTaxonomicTreeOperation.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 diff --git a/taxeditor-application/TaxEditor.product b/taxeditor-application/TaxEditor.product index 7ecdc6d43..c1a2befed 100644 --- a/taxeditor-application/TaxEditor.product +++ b/taxeditor-application/TaxEditor.product @@ -1,87 +1,89 @@ - - - - - - - - %productBlurb - - - - - - - - -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + %productBlurb + + + + + + + + -Xmx256M + -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java index ee9063d1d..17c03a4d7 100644 --- a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java +++ b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java @@ -102,8 +102,8 @@ public class EditorUtil extends AbstractUtility{ * @return The EditorPart. * @throws PartInitException */ - public static IEditorPart openEmpty(UUID parentTaxonNodeUuid) throws PartInitException{ - TaxonEditorInput input = TaxonEditorInput.NewEmptyInstance(parentTaxonNodeUuid); + public static IEditorPart openEmpty(UUID parentNodeUuid) throws PartInitException{ + TaxonEditorInput input = TaxonEditorInput.NewEmptyInstance(parentNodeUuid); return open(input, MultiPageTaxonEditor.ID); } diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java index ff9bb4e41..7449f2396 100644 --- a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java +++ b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java @@ -23,6 +23,7 @@ import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; import eu.etaxonomy.cdm.model.name.TaxonNameBase; import eu.etaxonomy.cdm.model.taxon.Taxon; import eu.etaxonomy.cdm.model.taxon.TaxonNode; +import eu.etaxonomy.cdm.model.taxon.TaxonomicTree; import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; import eu.etaxonomy.taxeditor.preference.PreferencesUtil; import eu.etaxonomy.taxeditor.store.CdmStore; @@ -91,26 +92,29 @@ public class TaxonEditorInput implements IEditorInput, IConversationEnabled, IPe return new TaxonEditorInput(taxonNode, conversation); } - public static TaxonEditorInput NewEmptyInstance(UUID parentTaxonNodeUuid){ + public static TaxonEditorInput NewEmptyInstance(UUID parentNodeUuid){ ConversationHolder conversation = CdmStore.NewTransactionalConversation(); TaxonNameBase name = PreferencesUtil.getInstanceOfPreferredNameClass(); + TaxonNode parentTaxonNode = CdmStore.getTaxonService().getTaxonNodeByUuid(parentNodeUuid); + Taxon newTaxon = 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); - + if(parentTaxonNode == null){ + // parentNodeUUid might be a taxonomic tree + // FIXME this is not very elegant, please refactor + // add new taxon as root node + TaxonomicTree tree = CdmStore.getTaxonService().getTaxonomicTreeByUuid(parentNodeUuid); + + newTaxon = Taxon.NewInstance(name, CdmStore.getDefault().getDefaultSec()); + newTaxonNode = tree.addRoot(newTaxon, null); + }else{ + // add new taxon as child of another taxon 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().saveTaxonNode(newTaxonNode); diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInputFactory.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInputFactory.java index 68977b967..48e92ffa1 100644 --- a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInputFactory.java +++ b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInputFactory.java @@ -17,7 +17,7 @@ import org.eclipse.core.runtime.IAdaptable; import org.eclipse.ui.IElementFactory; import org.eclipse.ui.IMemento; -import eu.etaxonomy.taxeditor.model.TaxonNodeUtil; +import eu.etaxonomy.taxeditor.model.TaxonUtil; import eu.etaxonomy.taxeditor.store.CdmStore; import eu.etaxonomy.taxeditor.store.StoreUtil; diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/DistributionFeatureGroupComposite.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/DistributionFeatureGroupComposite.java index a1b0a0561..ee92553b0 100644 --- a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/DistributionFeatureGroupComposite.java +++ b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/DistributionFeatureGroupComposite.java @@ -58,7 +58,7 @@ public class DistributionFeatureGroupComposite extends DescriptionFeatureGroupCo public void mouseUp(MouseEvent event) { if(event.widget == showMapButton){ - DistributionMapDialog dialog = new DistributionMapDialog(editor, this.getShell(), distributions); + DistributionMapDialog dialog = new DistributionMapDialog(editor, this.getShell()); dialog.open(); } diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/DistributionMapDialog.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/DistributionMapDialog.java index 5f0fd574d..309ed4ecc 100644 --- a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/DistributionMapDialog.java +++ b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/DistributionMapDialog.java @@ -12,7 +12,6 @@ package eu.etaxonomy.taxeditor.editor.description; import java.awt.Color; import java.util.Map; -import java.util.Set; import org.eclipse.swt.SWT; import org.eclipse.swt.browser.Browser; @@ -28,7 +27,7 @@ import org.eclipse.swt.widgets.ProgressBar; import org.eclipse.swt.widgets.Shell; import eu.etaxonomy.cdm.ext.EditGeoService; -import eu.etaxonomy.cdm.model.description.Distribution; +import eu.etaxonomy.cdm.ext.IEditGeoService; import eu.etaxonomy.cdm.model.description.PresenceAbsenceTermBase; import eu.etaxonomy.taxeditor.editor.AbstractTaxonEditor; @@ -39,8 +38,8 @@ import eu.etaxonomy.taxeditor.editor.AbstractTaxonEditor; */ public class DistributionMapDialog extends Dialog { - private Set distributions; - + private IEditGeoService geoService; + private AbstractTaxonEditor editor; private Browser browser; @@ -54,16 +53,16 @@ public class DistributionMapDialog extends Dialog { public DistributionMapDialog(Shell parent, int style) { super(parent, style); this.setText("Map Viewer"); + geoService = new EditGeoService(); } /** * @param parent */ - public DistributionMapDialog(AbstractTaxonEditor editor, Shell parent, Set distributions) { + public DistributionMapDialog(AbstractTaxonEditor editor, Shell parent) { this(parent, 0); this.editor = editor; - this.distributions = distributions; } public Object open () { @@ -143,8 +142,8 @@ public class DistributionMapDialog extends Dialog { String bbox = "-180,-90,180,90"; String backLayer = null; - String parameter = EditGeoService.getEditGeoServiceUrlParameterString( - distributions, + String parameter = geoService.getEditGeoServiceUrlParameterString( + editor.getTaxon(), presenceAbsenceTermColors, width, height, diff --git a/taxeditor-navigation/plugin.xml b/taxeditor-navigation/plugin.xml index b5c47ed07..b27c1413d 100644 --- a/taxeditor-navigation/plugin.xml +++ b/taxeditor-navigation/plugin.xml @@ -109,14 +109,25 @@ commandId="eu.etaxonomy.taxeditor.navigation.command.editTaxon" label="Edit" style="push"> + + + + + + + + + name="taxeditor-navigation.separator1" + visible="true"> + value="eu.etaxonomy.taxeditor.navigation.navigator.Root"> @@ -296,9 +307,9 @@ @@ -307,9 +318,14 @@ class="eu.etaxonomy.taxeditor.navigation.navigator.TaxonDropAdapterAssistant" id="eu.etaxonomy.taxeditor.navigation.navigator.dropassistant"> - - + + + + + + @@ -329,15 +345,15 @@ + value="eu.etaxonomy.cdm.model.taxon.TaxonNode"> + type="eu.etaxonomy.cdm.model.taxon.TaxonNode"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/NavigationUtil.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/NavigationUtil.java index c7910c93c..bfe4f1958 100644 --- a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/NavigationUtil.java +++ b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/NavigationUtil.java @@ -35,6 +35,7 @@ import org.eclipse.ui.handlers.HandlerUtil; import org.eclipse.ui.ide.undo.WorkspaceUndoUtil; import org.eclipse.ui.navigator.CommonViewer; +import eu.etaxonomy.cdm.model.common.CdmBase; import eu.etaxonomy.cdm.model.taxon.Synonym; import eu.etaxonomy.cdm.model.taxon.Taxon; import eu.etaxonomy.cdm.model.taxon.TaxonNode; @@ -82,11 +83,9 @@ public class NavigationUtil extends AbstractUtility{ getActiveWorkbenchWindow(); } - public static void openEmpty(TaxonNode parentTaxonNode) { + public static void openEmpty(UUID parentNodeUuid) { try { - UUID parentTaxonNodeUuid = parentTaxonNode == null ? null : parentTaxonNode.getUuid(); - - EditorUtil.openEmpty(parentTaxonNodeUuid); + EditorUtil.openEmpty(parentNodeUuid); } catch (PartInitException e) { logger.error("Error opening the editor", e); } @@ -133,16 +132,16 @@ public class NavigationUtil extends AbstractUtility{ * @param event * @return */ - public static TaxonNode getCurrentSelection(ExecutionEvent event){ + public static CdmBase 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){ - TaxonNode taxonNode = (TaxonNode) ((TreeSelection) menuSelection).getFirstElement(); - logger.debug("Selected taxon: " + taxonNode); - return taxonNode; + CdmBase cdmBase = (CdmBase) ((TreeSelection) menuSelection).getFirstElement(); + logger.debug("Selected cdmBase object: " + cdmBase); + return cdmBase; } return null; } @@ -188,8 +187,7 @@ public class NavigationUtil extends AbstractUtility{ * @param parentElement */ public static void selectInNavigator(Object element, Object parentElement) { - TaxonNavigator navigator = (TaxonNavigator) TaxeditorEditorPlugin.getDefault().getWorkbench(). - getActiveWorkbenchWindow().getActivePage().findView(TaxonNavigator.ID); + TaxonNavigator navigator = getNavigator(); if (navigator != null) { CommonViewer viewer = navigator.getCommonViewer(); if (viewer != null) { @@ -240,4 +238,12 @@ public class NavigationUtil extends AbstractUtility{ " more than one accepted taxon. This case is not handled yet by the software."); } } + + /** + * @return the TaxonNavigator instance if present + */ + public static TaxonNavigator getNavigator() { + return (TaxonNavigator) TaxeditorEditorPlugin.getDefault().getWorkbench(). + getActiveWorkbenchWindow().getActivePage().findView(TaxonNavigator.ID); + } } \ No newline at end of file diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/CreateChildTaxonHandler.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/CreateChildTaxonHandler.java index 0e2abacce..f83accc48 100644 --- a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/CreateChildTaxonHandler.java +++ b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/CreateChildTaxonHandler.java @@ -14,7 +14,7 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.IHandler; -import eu.etaxonomy.cdm.model.taxon.TaxonNode; +import eu.etaxonomy.cdm.model.common.CdmBase; import eu.etaxonomy.taxeditor.navigation.NavigationUtil; /** @@ -29,10 +29,10 @@ public class CreateChildTaxonHandler extends AbstractHandler implements * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) */ public Object execute(ExecutionEvent event) throws ExecutionException { - TaxonNode parentTaxonNode = NavigationUtil.getCurrentSelection(event); - - // Open editor for new taxon - NavigationUtil.openEmpty(parentTaxonNode); + CdmBase selection = NavigationUtil.getCurrentSelection(event); + + // Open editor for new cdmBase object + NavigationUtil.openEmpty(selection.getUuid()); return null; } diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/DeleteTaxonNodeHandler.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/DeleteTaxonNodeHandler.java index 7b1c29407..e4a935025 100644 --- a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/DeleteTaxonNodeHandler.java +++ b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/DeleteTaxonNodeHandler.java @@ -18,9 +18,12 @@ import org.eclipse.core.commands.IHandler; import org.eclipse.core.commands.common.NotDefinedException; import org.eclipse.core.commands.operations.IUndoableOperation; +import eu.etaxonomy.cdm.model.common.CdmBase; import eu.etaxonomy.cdm.model.taxon.TaxonNode; +import eu.etaxonomy.cdm.model.taxon.TaxonomicTree; import eu.etaxonomy.taxeditor.navigation.NavigationUtil; import eu.etaxonomy.taxeditor.operations.DeleteTaxonNodeOperation; +import eu.etaxonomy.taxeditor.operations.DeleteTaxonomicTreeOperation; /** * @author n.hoffmann @@ -32,13 +35,17 @@ public class DeleteTaxonNodeHandler extends AbstractHandler implements IHandler{ .getLogger(DeleteTaxonNodeHandler.class); public Object execute(ExecutionEvent event) throws ExecutionException { - // FIXME make operation handle taxon node? - TaxonNode taxonNode = NavigationUtil.getCurrentSelection(event); - - IUndoableOperation operation; + CdmBase selection = NavigationUtil.getCurrentSelection(event); + + IUndoableOperation operation = null; try { - operation = new DeleteTaxonNodeOperation(event.getCommand().getName(), - NavigationUtil.getUndoContext(), taxonNode); + if(selection instanceof TaxonomicTree){ + operation = new DeleteTaxonomicTreeOperation(event.getCommand().getName(), + NavigationUtil.getUndoContext(), (TaxonomicTree) selection); + }else if(selection instanceof TaxonNode){ + operation = new DeleteTaxonNodeOperation(event.getCommand().getName(), + NavigationUtil.getUndoContext(), (TaxonNode) selection); + } NavigationUtil.executeOperation(operation); } catch (NotDefinedException e) { logger.warn("Command name not set"); diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/MoveTaxonHandler.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/MoveTaxonHandler.java index e435d1b2f..dfddc0a6c 100644 --- a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/MoveTaxonHandler.java +++ b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/MoveTaxonHandler.java @@ -40,7 +40,7 @@ public class MoveTaxonHandler extends AbstractHandler implements IPostOperationE */ public Object execute(ExecutionEvent event) throws ExecutionException { Shell shell = NavigationUtil.getShell(); - TaxonNode taxonNode = NavigationUtil.getCurrentSelection(event); + TaxonNode taxonNode = (TaxonNode) NavigationUtil.getCurrentSelection(event); Dialog dialog = new TaxonSearchDialog(shell); Object value = ((TaxonSearchDialog) dialog).open(); diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonomicTreeWizadPage.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonomicTreeWizadPage.java new file mode 100644 index 000000000..1ee4b1857 --- /dev/null +++ b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonomicTreeWizadPage.java @@ -0,0 +1,68 @@ +// $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.handler; + +import org.apache.log4j.Logger; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CLabel; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; + +/** + * @author n.hoffmann + * @created 23.06.2009 + * @version 1.0 + */ +public class NewTaxonomicTreeWizadPage extends WizardPage { + private static final Logger logger = Logger + .getLogger(NewTaxonomicTreeWizadPage.class); + + private Text text_treeLabel; + + /** + * @param pageName + */ + protected NewTaxonomicTreeWizadPage(String pageName) { + super(pageName); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + + + Composite composite = new Composite(parent, SWT.NONE); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + composite.setLayout(gridLayout); + + CLabel label_treeLabel = new CLabel(composite, SWT.NULL); + label_treeLabel.setText("Label:"); + + text_treeLabel = new Text(composite, SWT.BORDER); + text_treeLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + + // FIXME this is a rudimentary implementation. Add missing fields. + + setControl(composite); + } + + /** + * @return the text_treeLabel + */ + public String getTreeLabel() { + return text_treeLabel.getText(); + } +} diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonomicTreeWizard.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonomicTreeWizard.java new file mode 100644 index 000000000..8bbf94e33 --- /dev/null +++ b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonomicTreeWizard.java @@ -0,0 +1,79 @@ +// $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.handler; + +import org.apache.log4j.Logger; +import org.eclipse.core.commands.common.NotDefinedException; +import org.eclipse.core.commands.operations.AbstractOperation; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; + +import eu.etaxonomy.taxeditor.editor.EditorUtil; +import eu.etaxonomy.taxeditor.navigation.NavigationUtil; +import eu.etaxonomy.taxeditor.operations.CreateTaxonomicTreeOperation; + +/** + * @author n.hoffmann + * @created 23.06.2009 + * @version 1.0 + */ +public class NewTaxonomicTreeWizard extends Wizard implements INewWizard { + private static final Logger logger = Logger + .getLogger(NewTaxonomicTreeWizard.class); + + public static final String NEW_TAXONOMIC_TREE = "NEW_TAXONOMIC_TREE"; + + private NewTaxonomicTreeWizadPage page; + + /** + * + */ + public NewTaxonomicTreeWizard() { + // TODO Auto-generated constructor stub + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#addPages() + */ + @Override + public void addPages() { + super.addPages(); + + page = new NewTaxonomicTreeWizadPage(NEW_TAXONOMIC_TREE); + + addPage(page); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#performFinish() + */ + @Override + public boolean performFinish() { + + AbstractOperation operation = new CreateTaxonomicTreeOperation("Create Taxonomic Tree", + NavigationUtil.getUndoContext(), page.getTreeLabel()); + NavigationUtil.executeOperation(operation); + + NavigationUtil.getNavigator().getCommonViewer().refresh(); + + return true; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) + */ + public void init(IWorkbench workbench, IStructuredSelection selection) { + // TODO Auto-generated method stub + + } +} diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/QuickCreateChildTaxonHandler.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/QuickCreateChildTaxonHandler.java index c5f570b25..abb9defaf 100644 --- a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/QuickCreateChildTaxonHandler.java +++ b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/QuickCreateChildTaxonHandler.java @@ -9,6 +9,8 @@ package eu.etaxonomy.taxeditor.navigation.handler; +import java.util.UUID; + import org.apache.log4j.Logger; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; @@ -24,7 +26,6 @@ import org.eclipse.ui.handlers.HandlerUtil; 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; @@ -43,7 +44,7 @@ public class QuickCreateChildTaxonHandler extends AbstractHandler implements private static final Logger logger = Logger .getLogger(QuickCreateChildTaxonHandler.class); - private TaxonNode parentTaxonNode; + private UUID parentNodeUuid; /* (non-Javadoc) * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) @@ -51,14 +52,18 @@ public class QuickCreateChildTaxonHandler extends AbstractHandler implements public Object execute(ExecutionEvent event) throws ExecutionException { Shell shell = HandlerUtil.getActiveShell(event); - parentTaxonNode = NavigationUtil.getCurrentSelection(event); - if(NavigationUtil.isDirty(parentTaxonNode)){ + CdmBase selection = NavigationUtil.getCurrentSelection(event); + + + if((selection instanceof TaxonNode) && NavigationUtil.isDirty((TaxonNode) selection)){ 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; } + parentNodeUuid = selection.getUuid(); + InputDialog dialog = new InputDialog(shell, "Quick create child taxon", "Enter child taxon's name to create a new taxon", null, null); if (dialog.open() == Window.OK) { @@ -70,7 +75,7 @@ public class QuickCreateChildTaxonHandler extends AbstractHandler implements CreateChildTaxonOperation operation; try { operation = new CreateChildTaxonOperation(event.getCommand().getName(), - NavigationUtil.getUndoContext(), parentTaxonNode, name, this); + NavigationUtil.getUndoContext(), parentNodeUuid, 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" + @@ -88,7 +93,7 @@ public class QuickCreateChildTaxonHandler extends AbstractHandler implements } public boolean postOperation(CdmBase objectAffectedByOperation) { - NavigationUtil.selectInNavigator(objectAffectedByOperation, parentTaxonNode); + NavigationUtil.selectInNavigator(objectAffectedByOperation, parentNodeUuid); return true; } } diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorRoot.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/Root.java similarity index 84% rename from taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorRoot.java rename to taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/Root.java index df1463f03..2947360e4 100644 --- a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorRoot.java +++ b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/Root.java @@ -27,9 +27,9 @@ import eu.etaxonomy.taxeditor.store.CdmStore; * @created 02.06.2009 * @version 1.0 */ -public class NavigatorRoot extends PlatformObject implements IAdaptable, IPersistableElement, IElementFactory { +public class Root extends PlatformObject implements IAdaptable, IPersistableElement, IElementFactory { - private static final Logger logger = Logger.getLogger(NavigatorRoot.class); + private static final Logger logger = Logger.getLogger(Root.class); public List getParentBeans() { List trees = CdmStore.getDefault().getTaxonomicTrees(); diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorSynonymContentProvider.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/SynonymContentProvider.java similarity index 89% rename from taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorSynonymContentProvider.java rename to taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/SynonymContentProvider.java index 21770a3ff..da7ad5082 100644 --- a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorSynonymContentProvider.java +++ b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/SynonymContentProvider.java @@ -28,9 +28,9 @@ import eu.etaxonomy.taxeditor.editor.name.IterableSynonymyList; * @created 02.06.2009 * @version 1.0 */ -public class NavigatorSynonymContentProvider implements ITreeContentProvider { +public class SynonymContentProvider implements ITreeContentProvider { private static final Logger logger = Logger - .getLogger(NavigatorSynonymContentProvider.class); + .getLogger(SynonymContentProvider.class); private static final Object[] NO_CHILDREN = new Object[0]; diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorSynonymLabelProvider.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/SynonymLabelProvider.java similarity index 90% rename from taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorSynonymLabelProvider.java rename to taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/SynonymLabelProvider.java index aa3ad1344..d1dd2ebe1 100644 --- a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorSynonymLabelProvider.java +++ b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/SynonymLabelProvider.java @@ -30,10 +30,10 @@ import eu.etaxonomy.cdm.model.taxon.Synonym; * @created 04.06.2009 * @version 1.0 */ -public class NavigatorSynonymLabelProvider extends ColumnLabelProvider +public class SynonymLabelProvider extends ColumnLabelProvider implements ILabelProvider, IDescriptionProvider, IStyledLabelProvider { private static final Logger logger = Logger - .getLogger(NavigatorSynonymLabelProvider.class); + .getLogger(SynonymLabelProvider.class); public Image getImage(Object element) { return null; diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigator.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigator.java index 101870553..9a06bff56 100644 --- a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigator.java +++ b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigator.java @@ -65,7 +65,7 @@ public class TaxonNavigator extends CommonNavigator implements IConversationEnab conversation = CdmStore.NewTransactionalConversation(); conversation.registerForDataStoreChanges(this); this.getCommonViewer().refresh(); - return new NavigatorRoot(); + return new Root(); } public void init(IViewSite site, IMemento memento) @@ -179,7 +179,7 @@ public class TaxonNavigator extends CommonNavigator implements IConversationEnab } protected String getFrameToolTipText(Object element) { - if (element instanceof NavigatorRoot) { + if (element instanceof Root) { return "Taxonomic Tree"; } return super.getFrameToolTipText(element); diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorTaxonContentProvider.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodeContentProvider.java similarity index 76% rename from taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorTaxonContentProvider.java rename to taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodeContentProvider.java index 14d318dca..859410daf 100644 --- a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorTaxonContentProvider.java +++ b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodeContentProvider.java @@ -21,9 +21,9 @@ import eu.etaxonomy.cdm.model.taxon.TaxonNode; * @created 02.06.2009 * @version 1.0 */ -public class NavigatorTaxonContentProvider implements ITreeContentProvider { +public class TaxonNodeContentProvider implements ITreeContentProvider { private static final Logger logger = Logger - .getLogger(NavigatorTaxonContentProvider.class); + .getLogger(TaxonNodeContentProvider.class); public Object[] getChildren(Object parentElement) { @@ -35,14 +35,17 @@ public class NavigatorTaxonContentProvider implements ITreeContentProvider { } public Object getParent(Object element) { -// if(element instanceof TaxonNode){ -// return ((TaxonNode) element).getParent(); -// } + if(element instanceof TaxonNode){ + return ((TaxonNode) element).getParent(); + } return null; } public boolean hasChildren(Object element) { - return this.getChildren(element).length > 0; + + boolean length = this.getChildren(element).length > 0; + + return length; } public Object[] getElements(Object inputElement) { diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorTaxonLabelProvider.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodeLabelProvider.java similarity index 91% rename from taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorTaxonLabelProvider.java rename to taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodeLabelProvider.java index 0b5a61a19..119ccf16b 100644 --- a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorTaxonLabelProvider.java +++ b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodeLabelProvider.java @@ -26,10 +26,10 @@ import eu.etaxonomy.cdm.model.taxon.TaxonNode; * @created 04.06.2009 * @version 1.0 */ -public class NavigatorTaxonLabelProvider extends ColumnLabelProvider +public class TaxonNodeLabelProvider extends ColumnLabelProvider implements ILabelProvider, IDescriptionProvider, IStyledLabelProvider { private static final Logger logger = Logger - .getLogger(NavigatorTaxonLabelProvider.class); + .getLogger(TaxonNodeLabelProvider.class); public Image getImage(Object element) { return null; diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorPropertyTester.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodePropertyTester.java similarity index 54% rename from taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorPropertyTester.java rename to taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodePropertyTester.java index 2a01dbe8b..2a1338cfb 100644 --- a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorPropertyTester.java +++ b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodePropertyTester.java @@ -6,16 +6,19 @@ package eu.etaxonomy.taxeditor.navigation.navigator; import org.eclipse.core.expressions.PropertyTester; import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.cdm.model.taxon.TaxonNode; -public class NavigatorPropertyTester extends PropertyTester { +public class TaxonNodePropertyTester extends PropertyTester { private static final Object HAS_SYNONYMS = "hasSynonyms"; - + public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - if (receiver instanceof Taxon && HAS_SYNONYMS.equals(property)) { - return ((Taxon) receiver).hasSynonyms(); + if (receiver instanceof TaxonNode && HAS_SYNONYMS.equals(property)) { + Taxon taxon = ((TaxonNode) receiver).getTaxon(); + return taxon.hasSynonyms(); } + return false; } } diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorTaxonomicTreeContentProvider.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonomicTreeContentProvider.java similarity index 87% rename from taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorTaxonomicTreeContentProvider.java rename to taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonomicTreeContentProvider.java index 093c296e9..885951e9b 100644 --- a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorTaxonomicTreeContentProvider.java +++ b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonomicTreeContentProvider.java @@ -21,16 +21,16 @@ import eu.etaxonomy.cdm.model.taxon.TaxonomicTree; * @created 17.06.2009 * @version 1.0 */ -public class NavigatorTaxonomicTreeContentProvider implements ITreeContentProvider { +public class TaxonomicTreeContentProvider implements ITreeContentProvider { private static final Logger logger = Logger - .getLogger(NavigatorTaxonomicTreeContentProvider.class); + .getLogger(TaxonomicTreeContentProvider.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 Root) { + return ((Root) parentElement).getParentBeans().toArray(); } if(parentElement instanceof TaxonomicTree) { diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorTaxonomicTreeLabelProvider.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonomicTreeLabelProvider.java similarity index 93% rename from taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorTaxonomicTreeLabelProvider.java rename to taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonomicTreeLabelProvider.java index c42d6dbcc..f19dcff0c 100644 --- a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/NavigatorTaxonomicTreeLabelProvider.java +++ b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonomicTreeLabelProvider.java @@ -25,10 +25,10 @@ import eu.etaxonomy.cdm.model.taxon.TaxonomicTree; * @created 17.06.2009 * @version 1.0 */ -public class NavigatorTaxonomicTreeLabelProvider extends ColumnLabelProvider +public class TaxonomicTreeLabelProvider extends ColumnLabelProvider implements ILabelProvider, IDescriptionProvider, IStyledLabelProvider { private static final Logger logger = Logger - .getLogger(NavigatorTaxonomicTreeLabelProvider.class); + .getLogger(TaxonomicTreeLabelProvider.class); /* (non-Javadoc) * @see org.eclipse.jface.viewers.ColumnLabelProvider#getImage(java.lang.Object) diff --git a/taxeditor-store/plugin.xml b/taxeditor-store/plugin.xml index cad100671..b1c2374b6 100644 --- a/taxeditor-store/plugin.xml +++ b/taxeditor-store/plugin.xml @@ -206,6 +206,12 @@ class="selection.Selection1"> + + diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/BerlinModelExportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/BerlinModelExportWizard.java new file mode 100644 index 000000000..faa1a9314 --- /dev/null +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/BerlinModelExportWizard.java @@ -0,0 +1,44 @@ +// $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.io; + +import org.apache.log4j.Logger; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.IExportWizard; +import org.eclipse.ui.IWorkbench; + +/** + * @author n.hoffmann + * @created 23.06.2009 + * @version 1.0 + */ +public class BerlinModelExportWizard extends Wizard implements IExportWizard { + private static final Logger logger = Logger + .getLogger(BerlinModelExportWizard.class); + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#performFinish() + */ + @Override + public boolean performFinish() { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) + */ + public void init(IWorkbench workbench, IStructuredSelection selection) { + // TODO Auto-generated method stub + + } +} diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/BerlinModelExportWizardPage.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/BerlinModelExportWizardPage.java new file mode 100644 index 000000000..dfa3d5d82 --- /dev/null +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/BerlinModelExportWizardPage.java @@ -0,0 +1,45 @@ +// $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.io; + +import org.apache.log4j.Logger; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.widgets.Composite; + +/** + * @author n.hoffmann + * @created 23.06.2009 + * @version 1.0 + */ +public class BerlinModelExportWizardPage extends WizardPage { + + + private static final Logger logger = Logger + .getLogger(BerlinModelExportWizardPage.class); + + /** + * @param pageName + */ + protected BerlinModelExportWizardPage(String pageName) { + super(pageName); + this.setTitle("Berlin Model Export"); + + this.setDescription("Exports the contents of the currently selected database into a Berlin Model database"); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + // TODO Auto-generated method stub + + } +} diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbExportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbExportWizard.java index f4cb8814a..52c7d54d3 100644 --- a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbExportWizard.java +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbExportWizard.java @@ -23,9 +23,10 @@ import org.eclipse.ui.IExportWizard; import org.eclipse.ui.IWorkbench; import eu.etaxonomy.cdm.io.common.CdmDefaultExport; -import eu.etaxonomy.cdm.io.common.ICdmExport; +import eu.etaxonomy.cdm.io.common.ICdmExporter; import eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator; import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository; +import eu.etaxonomy.taxeditor.store.CdmStore; /** * @author n.hoffmann @@ -38,7 +39,7 @@ public class JaxbExportWizard extends Wizard implements IExportWizard { public final String JAXB_EXPORT = "JAXB_EXPORT"; - private ICdmExport export; + private ICdmExporter export; private JaxbExportWizardPage page; @@ -50,11 +51,12 @@ public class JaxbExportWizard extends Wizard implements IExportWizard { @Override public boolean performFinish() { - export = new CdmDefaultExport(); + export = new CdmDefaultExport(); String url = page.getFolderText() + File.pathSeparator + page.getExportFileName(); exportConfigurator = JaxbExportConfigurator.NewInstance(CdmDataSourceRepository.getDefault().getCurrentDataSource(), url); + exportConfigurator.setCdmAppController(CdmStore.getApplicationController()); Job exportJob = new Job("JAXB Export"){ diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/TaxonNodeUtil.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/TaxonNodeUtil.java deleted file mode 100644 index 37bc50143..000000000 --- a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/TaxonNodeUtil.java +++ /dev/null @@ -1,131 +0,0 @@ -/** -* 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.model; - -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -import org.apache.log4j.Logger; - -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.TaxonNode; -import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; -import eu.etaxonomy.taxeditor.store.CdmStore; - -/** - * @author n.hoffmann - * @created 25.03.2009 - * @version 1.0 - */ -public class TaxonNodeUtil { - private static final Logger logger = Logger - .getLogger(TaxonNodeUtil.class); - - /** - * - * @param taxonNodeUuid - * @return - */ - public static boolean deleteTaxonNodeIsolated(UUID taxonNodeUuid){ - // get a new conversation - ConversationHolder conversation = CdmStore.NewTransactionalConversation(); - - TaxonNode taxonNode = CdmStore.getTaxonService().getTaxonNodeByUuid(taxonNodeUuid); - - boolean result = taxonNode.remove(); - - // commit the conversation and throw it away - conversation.commit(true); - return result; - } - - 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 - TaxonNode parentTaxonNode = CdmStore.getTaxonService().getTaxonNodeByUuid(taxonNodeUuid); - // logic to add new taxon name - 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 childTaxonNode; - } - - /** - * - * @param taxonNodeUuid - * @param newParentTaxonNodeUuid - * @return - */ - public static TaxonNode moveTaxonBaseIsolated(UUID taxonNodeUuid, UUID newParentTaxonNodeUuid){ - - // get a new conversation - ConversationHolder conversation = CdmStore.NewTransactionalConversation(); - // 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(); - - TaxonNode newParentTaxonNode = CdmStore.getTaxonService().getTaxonNodeByUuid(newParentTaxonNodeUuid); - TaxonNode newChild = newParentTaxonNode.addChild(taxon, parentChildReference, parentChildMicroReference, synonymUsed); - // commit the conversation - conversation.commit(true); - return newChild; - } - - /** - * TODO this method should be in cdm library - * - * Example: - * TaxonA(fromTaxon) isOverlapping TaxonB(toTaxon) - * - * @param fromTaxon - * @param toTaxon - * @return - * @deprecated TODO this method should be in the library - */ - public static TaxonRelationship getRelationshipBetweenTwoTaxa(Taxon fromTaxon, Taxon toTaxon){ - Set relations = new HashSet(); - - for(TaxonRelationship relation : fromTaxon.getRelationsFromThisTaxon()){ - if(relation.getToTaxon().equals(toTaxon)){ - relations.add(relation); - } - } - - if(relations.size() > 1){ - logger.warn("Found multiple relations between two taxa. Does this make sense?"); - } - - if(relations.size() == 0){ - logger.warn("No relations between the two given taxa"); - new Throwable("No relations between the two given taxa"); - } - - return relations.toArray(new TaxonRelationship[0])[0]; - } -} diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/TaxonUtil.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/TaxonUtil.java new file mode 100644 index 000000000..a98598ae8 --- /dev/null +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/TaxonUtil.java @@ -0,0 +1,61 @@ +/** +* 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.model; + +import java.util.HashSet; +import java.util.Set; + +import org.apache.log4j.Logger; + +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; + +/** + * @author n.hoffmann + * @created 25.03.2009 + * @version 1.0 + */ +public class TaxonUtil { + private static final Logger logger = Logger + .getLogger(TaxonUtil.class); + + + /** + * TODO this method should be in cdm library + * + * Example: + * TaxonA(fromTaxon) isOverlapping TaxonB(toTaxon) + * + * @param fromTaxon + * @param toTaxon + * @return + * @deprecated TODO this method should be in the library + */ + public static TaxonRelationship getRelationshipBetweenTwoTaxa(Taxon fromTaxon, Taxon toTaxon){ + Set relations = new HashSet(); + + for(TaxonRelationship relation : fromTaxon.getRelationsFromThisTaxon()){ + if(relation.getToTaxon().equals(toTaxon)){ + relations.add(relation); + } + } + + if(relations.size() > 1){ + logger.warn("Found multiple relations between two taxa. Does this make sense?"); + } + + if(relations.size() == 0){ + logger.warn("No relations between the two given taxa"); + new Throwable("No relations between the two given taxa"); + } + + return relations.toArray(new TaxonRelationship[0])[0]; + } +} diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/AbstractPostOperation.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/AbstractPostOperation.java index 54d8685b9..8282f3568 100644 --- a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/AbstractPostOperation.java +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/AbstractPostOperation.java @@ -9,6 +9,8 @@ package eu.etaxonomy.taxeditor.operations; +import java.util.UUID; + import org.apache.log4j.Logger; import org.eclipse.core.commands.operations.AbstractOperation; import org.eclipse.core.commands.operations.IUndoContext; @@ -45,16 +47,28 @@ public abstract class AbstractPostOperation extends AbstractOperation { */ protected TaxonNode taxonNode; + protected UUID parentNodeUuid; + /** * * @param label * @param undoContext * @param taxon */ - public AbstractPostOperation(String label, IUndoContext undoContext, - Taxon taxon) { + private AbstractPostOperation(String label, IUndoContext undoContext) { super(label); addContext(undoContext); + } + + /** + * + * @param label + * @param undoContext + * @param taxon + */ + public AbstractPostOperation(String label, IUndoContext undoContext, + Taxon taxon) { + this(label, undoContext); this.taxon = taxon; } @@ -84,6 +98,13 @@ public abstract class AbstractPostOperation extends AbstractOperation { this.taxonNode = taxonNode; } + public AbstractPostOperation(String label, IUndoContext undoContext, UUID parentNodeUuid, IPostOperationEnabled postOperationEnabled){ + this(label, undoContext); + + this.parentNodeUuid = parentNodeUuid; + this.postOperationEnabled = postOperationEnabled; + } + /** * This method will try to call the post operation on a possibly registered * IPostOperationEnabled implementor. Objects that were affected by the operation diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/ChangeConceptRelationshipTypeOperation.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/ChangeConceptRelationshipTypeOperation.java index d48cc38ae..2538d9283 100644 --- a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/ChangeConceptRelationshipTypeOperation.java +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/ChangeConceptRelationshipTypeOperation.java @@ -19,7 +19,7 @@ import org.eclipse.core.runtime.IStatus; import eu.etaxonomy.cdm.model.taxon.Taxon; import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; -import eu.etaxonomy.taxeditor.model.TaxonNodeUtil; +import eu.etaxonomy.taxeditor.model.TaxonUtil; /** * @author n.hoffmann @@ -45,7 +45,7 @@ public class ChangeConceptRelationshipTypeOperation extends AbstractPostOperatio super(label, undoContext, taxon, postOperationEnabled); this.relatedTaxon = relatedTaxon; - this.taxonRelationship = TaxonNodeUtil.getRelationshipBetweenTwoTaxa(relatedTaxon, taxon); + this.taxonRelationship = TaxonUtil.getRelationshipBetweenTwoTaxa(relatedTaxon, taxon); this.oldRelationshipType = taxonRelationship.getType(); this.newRelationshipType = type; } diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/ChangeConceptToSynonymOperation.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/ChangeConceptToSynonymOperation.java index 48f9c795e..607a95323 100644 --- a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/ChangeConceptToSynonymOperation.java +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/ChangeConceptToSynonymOperation.java @@ -22,7 +22,7 @@ import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType; import eu.etaxonomy.cdm.model.taxon.Taxon; import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; -import eu.etaxonomy.taxeditor.model.TaxonNodeUtil; +import eu.etaxonomy.taxeditor.model.TaxonUtil; /** * @author p.ciardelli @@ -45,7 +45,7 @@ public class ChangeConceptToSynonymOperation extends IPostOperationEnabled editor) { super(label, undoContext, taxon, editor); - this.taxonRelationship = TaxonNodeUtil.getRelationshipBetweenTwoTaxa(concept, taxon); + this.taxonRelationship = TaxonUtil.getRelationshipBetweenTwoTaxa(concept, taxon); this.oldRelationshipType = taxonRelationship.getType(); this.concept = concept; diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/CreateChildTaxonOperation.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/CreateChildTaxonOperation.java index 78aee4422..74d686e9d 100644 --- a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/CreateChildTaxonOperation.java +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/CreateChildTaxonOperation.java @@ -10,6 +10,8 @@ package eu.etaxonomy.taxeditor.operations; +import java.util.UUID; + import org.apache.log4j.Logger; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.operations.IUndoContext; @@ -18,9 +20,12 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import eu.etaxonomy.cdm.api.conversation.ConversationHolder; 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.model.TaxonNodeUtil; +import eu.etaxonomy.cdm.model.taxon.TaxonomicTree; +import eu.etaxonomy.taxeditor.store.CdmStore; import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin; /** @@ -45,8 +50,8 @@ public class CreateChildTaxonOperation extends AbstractPostOperation { * @param conversationEnabled */ public CreateChildTaxonOperation(String label, IUndoContext undoContext, - TaxonNode taxonNode, TaxonNameBase name, IPostOperationEnabled postOperationEnabled) { - super(label, undoContext, taxonNode, postOperationEnabled); + UUID parentNodeUuid, TaxonNameBase name, IPostOperationEnabled postOperationEnabled) { + super(label, undoContext, parentNodeUuid, postOperationEnabled); this.newTaxonName = name; } @@ -59,7 +64,7 @@ public class CreateChildTaxonOperation extends AbstractPostOperation { public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - childTaxonNode = TaxonNodeUtil.addChildTaxonBaseIsolated(taxonNode.getUuid(), newTaxonName); + childTaxonNode = addChildTaxonBaseIsolated(parentNodeUuid, newTaxonName); if(childTaxonNode != null){ return postExecute(childTaxonNode); @@ -87,4 +92,34 @@ public class CreateChildTaxonOperation extends AbstractPostOperation { logger.warn("Not yet implemented."); return null; } + + private TaxonNode addChildTaxonBaseIsolated(UUID parentNodeUuid, 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 + TaxonNode parentTaxonNode = CdmStore.getTaxonService().getTaxonNodeByUuid(parentNodeUuid); + + Taxon childTaxon; + TaxonNode childTaxonNode; + + if(parentTaxonNode == null){ + // parent seems to of type TaxonomicTree + TaxonomicTree tree = CdmStore.getTaxonService().getTaxonomicTreeByUuid(parentNodeUuid); + childTaxon = Taxon.NewInstance(newTaxonName, CdmStore.getDefault().getDefaultSec()); + + childTaxonNode = tree.addRoot(childTaxon, null); + }else{ + // logic to add new taxon name + childTaxon = Taxon.NewInstance(newTaxonName, parentTaxonNode.getTaxon().getSec()); + childTaxonNode = parentTaxonNode.addChild(childTaxon); + } + // commit the conversation and throw it away + conversation.commit(true); + return childTaxonNode; + } } diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/CreateTaxonomicTreeOperation.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/CreateTaxonomicTreeOperation.java new file mode 100644 index 000000000..31c403292 --- /dev/null +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/CreateTaxonomicTreeOperation.java @@ -0,0 +1,91 @@ +// $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.operations; + +import org.apache.log4j.Logger; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.operations.AbstractOperation; +import org.eclipse.core.commands.operations.IUndoContext; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; + +import eu.etaxonomy.cdm.api.conversation.ConversationHolder; +import eu.etaxonomy.cdm.model.taxon.TaxonomicTree; +import eu.etaxonomy.taxeditor.model.TaxonUtil; +import eu.etaxonomy.taxeditor.store.CdmStore; + +/** + * @author n.hoffmann + * @created 23.06.2009 + * @version 1.0 + */ +public class CreateTaxonomicTreeOperation extends AbstractOperation { + + private static final Logger logger = Logger + .getLogger(CreateTaxonomicTreeOperation.class); + private String treeLabel; + + /** + * @param label + * @param undoContext + */ + public CreateTaxonomicTreeOperation(String label, IUndoContext undoContext, String treeLabel) { + super(label); + addContext(undoContext); + + this.treeLabel = treeLabel; + } + + /* (non-Javadoc) + * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + */ + @Override + public IStatus execute(IProgressMonitor monitor, IAdaptable info) + throws ExecutionException { + + if(treeLabel.trim().length() == 0){ + return Status.CANCEL_STATUS; + } + + // get a new conversation + ConversationHolder conversation = CdmStore.NewTransactionalConversation(); + + TaxonomicTree tree = TaxonomicTree.NewInstance(treeLabel); + + CdmStore.getTaxonService().saveTaxonomicTree(tree); + + conversation.commit(true); + + return Status.OK_STATUS; + } + + /* (non-Javadoc) + * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + */ + @Override + public IStatus redo(IProgressMonitor monitor, IAdaptable info) + throws ExecutionException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + */ + @Override + public IStatus undo(IProgressMonitor monitor, IAdaptable info) + throws ExecutionException { + // TODO Auto-generated method stub + return null; + } +} diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteConceptRelationOperation.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteConceptRelationOperation.java index 304ab1d74..39aba56e4 100644 --- a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteConceptRelationOperation.java +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteConceptRelationOperation.java @@ -19,7 +19,7 @@ import eu.etaxonomy.cdm.model.reference.ReferenceBase; import eu.etaxonomy.cdm.model.taxon.Taxon; import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; -import eu.etaxonomy.taxeditor.model.TaxonNodeUtil; +import eu.etaxonomy.taxeditor.model.TaxonUtil; /** * Deletes a relation between two taxa. @@ -47,7 +47,7 @@ public class DeleteConceptRelationOperation extends AbstractPostOperation { this.relatedTaxon = relatedTaxon; - relationship = TaxonNodeUtil.getRelationshipBetweenTwoTaxa(relatedTaxon, taxon); + relationship = TaxonUtil.getRelationshipBetweenTwoTaxa(relatedTaxon, taxon); relationshipType = relationship.getType(); diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteTaxonNodeOperation.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteTaxonNodeOperation.java index 2ab5632d5..027d79d92 100644 --- a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteTaxonNodeOperation.java +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteTaxonNodeOperation.java @@ -9,6 +9,8 @@ package eu.etaxonomy.taxeditor.operations; +import java.util.UUID; + import org.apache.log4j.Logger; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.operations.IUndoContext; @@ -19,8 +21,10 @@ import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Shell; +import eu.etaxonomy.cdm.api.conversation.ConversationHolder; import eu.etaxonomy.cdm.model.taxon.TaxonNode; -import eu.etaxonomy.taxeditor.model.TaxonNodeUtil; +import eu.etaxonomy.taxeditor.model.TaxonUtil; +import eu.etaxonomy.taxeditor.store.CdmStore; /** * Delete a taxon node from its TaxonomicTree and thus from the current taxonomic view. @@ -78,7 +82,7 @@ public class DeleteTaxonNodeOperation extends AbstractPostOperation { } // delete the taxon in an isolated conversation - TaxonNodeUtil.deleteTaxonNodeIsolated(taxonNode.getUuid()); + deleteTaxonNodeIsolated(taxonNode.getUuid()); return postExecute(null); @@ -105,4 +109,22 @@ public class DeleteTaxonNodeOperation extends AbstractPostOperation { // so that all the mediation magic does the rest for us return postExecute(null); } + + /** + * + * @param taxonNodeUuid + * @return + */ + private boolean deleteTaxonNodeIsolated(UUID taxonNodeUuid){ + // get a new conversation + ConversationHolder conversation = CdmStore.NewTransactionalConversation(); + + TaxonNode taxonNode = CdmStore.getTaxonService().getTaxonNodeByUuid(taxonNodeUuid); + + boolean result = taxonNode.remove(); + + // commit the conversation and throw it away + conversation.commit(true); + return result; + } } diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteTaxonomicTreeOperation.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteTaxonomicTreeOperation.java new file mode 100644 index 000000000..10c21f81f --- /dev/null +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteTaxonomicTreeOperation.java @@ -0,0 +1,99 @@ +// $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.operations; + +import java.util.UUID; + +import org.apache.log4j.Logger; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.operations.IUndoContext; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; + +import eu.etaxonomy.cdm.api.conversation.ConversationHolder; +import eu.etaxonomy.cdm.model.taxon.TaxonomicTree; +import eu.etaxonomy.taxeditor.store.CdmStore; + +/** + * @author n.hoffmann + * @created 23.06.2009 + * @version 1.0 + */ +public class DeleteTaxonomicTreeOperation extends AbstractPostOperation { + + private static final Logger logger = Logger + .getLogger(DeleteTaxonomicTreeOperation.class); + + private TaxonomicTree taxonomicTree; + + + /** + * @param label + * @param undoContext + * @param taxonNode + * @param postOperationEnabled + */ + public DeleteTaxonomicTreeOperation(String label, IUndoContext undoContext, + TaxonomicTree taxonomicTree) { + super(label, undoContext, null); + + this.taxonomicTree = taxonomicTree; + + } + + + + /* (non-Javadoc) + * @see org.eclipse.core.commands.operations.IUndoableOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + */ + public IStatus execute(IProgressMonitor monitor, IAdaptable info) + throws ExecutionException { + + deleteTaxonomicTreeIsolated(taxonomicTree.getUuid()); + + return postExecute(null); + } + + /* (non-Javadoc) + * @see org.eclipse.core.commands.operations.IUndoableOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + */ + public IStatus redo(IProgressMonitor monitor, IAdaptable info) + throws ExecutionException { + // TODO Auto-generated method stub + return null; + } + + + /* (non-Javadoc) + * @see org.eclipse.core.commands.operations.IUndoableOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + */ + public IStatus undo(IProgressMonitor monitor, IAdaptable info) + throws ExecutionException { + // TODO Auto-generated method stub + return null; + } + + /** + * @param uuid + */ + private boolean deleteTaxonomicTreeIsolated(UUID uuid) { + // get a new conversation + ConversationHolder conversation = CdmStore.NewTransactionalConversation(); + + TaxonomicTree taxonomicTree = CdmStore.getTaxonService().getTaxonomicTreeByUuid(uuid); + CdmStore.getTaxonService().removeTaxonomicTree(taxonomicTree); + + // commit the conversation + conversation.commit(true); + return true; + } +} diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/MoveTaxonOperation.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/MoveTaxonOperation.java index 6674fb0fa..e78b50247 100644 --- a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/MoveTaxonOperation.java +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/MoveTaxonOperation.java @@ -9,6 +9,8 @@ package eu.etaxonomy.taxeditor.operations; +import java.util.UUID; + import org.apache.log4j.Logger; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.operations.IUndoContext; @@ -17,8 +19,13 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import eu.etaxonomy.cdm.api.conversation.ConversationHolder; +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.TaxonNode; -import eu.etaxonomy.taxeditor.model.TaxonNodeUtil; +import eu.etaxonomy.taxeditor.model.TaxonUtil; +import eu.etaxonomy.taxeditor.store.CdmStore; /** * Change the taxonomic parent of a given taxon. @@ -57,7 +64,7 @@ public class MoveTaxonOperation extends AbstractPostOperation { public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - TaxonNode newTaxonNode = TaxonNodeUtil.moveTaxonBaseIsolated(taxonNode.getUuid(), newParentTaxonNode.getUuid()); + TaxonNode newTaxonNode = moveTaxonBaseIsolated(taxonNode.getUuid(), newParentTaxonNode.getUuid()); return postExecute(newTaxonNode); } @@ -78,8 +85,35 @@ public class MoveTaxonOperation extends AbstractPostOperation { public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - TaxonNodeUtil.moveTaxonBaseIsolated(taxonNode.getUuid(), oldParentTaxonNode.getUuid()); + moveTaxonBaseIsolated(taxonNode.getUuid(), oldParentTaxonNode.getUuid()); return Status.OK_STATUS; } + + /** + * + * @param taxonNodeUuid + * @param newParentTaxonNodeUuid + * @return + */ + private TaxonNode moveTaxonBaseIsolated(UUID taxonNodeUuid, UUID newParentTaxonNodeUuid){ + + // get a new conversation + ConversationHolder conversation = CdmStore.NewTransactionalConversation(); + // 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(); + + TaxonNode newParentTaxonNode = CdmStore.getTaxonService().getTaxonNodeByUuid(newParentTaxonNodeUuid); + TaxonNode newChild = newParentTaxonNode.addChild(taxon, parentChildReference, parentChildMicroReference, synonymUsed); + // commit the conversation + conversation.commit(true); + return newChild; + } } diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java index 6fb1108e0..083de428a 100644 --- a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java @@ -212,9 +212,13 @@ public class CdmStore{ this.applicationController = applicationController; } - public CdmApplicationController getApplicationController(){ + private CdmApplicationController getApplicationControllerInternal(){ return applicationController; } + + public static CdmApplicationController getApplicationController(){ + return getDefault().getApplicationControllerInternal(); + } /** @@ -305,7 +309,7 @@ public class CdmStore{ configurator.setDoNamesWithoutTaxa(true); configurator.setDoSynonyms(true); } - configurator.setReferenceBase(null); + configurator.setSec(null); configurator.setPageNumber(0); // TODO currently limit results to 1000 configurator.setPageSize(1000);