eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/IElementHasDetails.java -text
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/IPartChangeListener.java -text
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/IPartContentHasDetails.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/IPartContentHasFactualData.java -text
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/IPartContentHasSupplementalData.java -text
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/ImageResources.java -text
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/LineSelection.java -text
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider;
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
-import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.store.CdmStore;
*/
private void displayWarningDialog() {
IPreferenceStore prefs = PreferencesUtil.getPreferenceStore();
- if (!prefs.getBoolean(IPreferenceKeys.HIDE_BULKEDITOR_INFO)) {
+ if (!prefs.getBoolean(PreferencesUtil.HIDE_BULKEDITOR_INFO)) {
String msg = "The Bulk Editor allows you to edit objects used to reference other objects, such as names, references, and authors.\n\n" +
"Any changes you make to an object in the Bulk Editor will be displayed wherever the object is used.\n\n" +
"For instance, a reference may be displayed with both a name and a descriptive element. If the reference name is changed here, the display of both the name and the descriptive element will be affected.";
MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm
(getSite().getShell(), "Bulk Editor", msg, "Do not show this message again",
- false, null, IPreferenceKeys.HIDE_BULKEDITOR_INFO);
+ false, null, PreferencesUtil.HIDE_BULKEDITOR_INFO);
if (dialog.getReturnCode() == Window.OK) {
- prefs.setValue(IPreferenceKeys.HIDE_BULKEDITOR_INFO, dialog.getToggleState());
+ prefs.setValue(PreferencesUtil.HIDE_BULKEDITOR_INFO, dialog.getToggleState());
}
}
}
import eu.etaxonomy.taxeditor.model.IDataChangeBehavior;
import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider;
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
+import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
/**
* @version 1.0
*/
public class MultiPageTaxonEditor extends FormEditor implements
- IConversationEnabled, IPostOperationEnabled,
+ IPartContentHasFactualData, IConversationEnabled, IPostOperationEnabled,
IDirtyMarkableSelectionProvider, IPartContentHasDetails, ISecuredEditor {
/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.taxon"{trunked}</code> */
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider;
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
+import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.ui.campanula.derivatesearch.DerivateLabelProvider;
* Displays the derivate hierarchy of all derivates belonging to a taxon.
*
*/
-public class DerivateView extends EditorPart implements IDirtyMarkableSelectionProvider, IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData {
+public class DerivateView extends EditorPart implements IPartContentHasFactualData, IDirtyMarkableSelectionProvider, IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData {
/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.desc"{trunked}</code> */
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView";
import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.FeatureTree;
-import eu.etaxonomy.cdm.model.description.TaxonDescription;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
+import eu.etaxonomy.cdm.model.description.IDescribable;
import eu.etaxonomy.taxeditor.editor.UsageTermCollection;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainerTree;
public class DescriptiveContentProvider implements ITreeContentProvider {
protected static final Object[] NO_CHILDREN = new Object[0];
- protected Map<TaxonDescription, FeatureNodeContainerTree> featureNodeContainerCache;
+ protected Map<DescriptionBase<?>, FeatureNodeContainerTree> featureNodeContainerCache;
/**
* <p>Constructor for DescriptiveContentProvider.</p>
*
* @param featureNodeContainerCache a {@link java.util.Map} object.
*/
- public DescriptiveContentProvider(Map<TaxonDescription, FeatureNodeContainerTree> featureNodeContainerCache) {
+ public DescriptiveContentProvider(Map<DescriptionBase<?>, FeatureNodeContainerTree> featureNodeContainerCache) {
this.featureNodeContainerCache = featureNodeContainerCache;
}
/** {@inheritDoc} */
@Override
public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof TaxonEditorInput) {
- return getDescriptions((TaxonEditorInput) parentElement).toArray();
+ if (parentElement instanceof IDescribable<?>) {
+ return getDescriptions((IDescribable<?>) parentElement).toArray();
}
- else if (parentElement instanceof TaxonDescription) {
- if ( ! ((TaxonDescription) parentElement).isImageGallery()) {
- TaxonDescription description = (TaxonDescription) parentElement;
+ else if (parentElement instanceof DescriptionBase<?>) {
+ if ( ! ((DescriptionBase<?>) parentElement).isImageGallery()) {
+ DescriptionBase<?> description = (DescriptionBase<?>) parentElement;
FeatureNodeContainerTree containerTree = getContainerTreeForDesription(description);
return NO_CHILDREN;
}
- private FeatureNodeContainerTree getContainerTreeForDesription(TaxonDescription description){
+ private FeatureNodeContainerTree getContainerTreeForDesription(DescriptionBase<?> description){
if(! featureNodeContainerCache.containsKey(description)){
FeatureNodeContainerTree containerTree = new FeatureNodeContainerTree(description, getFeatureTree(description));
featureNodeContainerCache.put(description, containerTree);
/** {@inheritDoc} */
@Override
public boolean hasChildren(Object element) {
- if (element instanceof TaxonDescription){
- TaxonDescription description = (TaxonDescription) element;
+ if (element instanceof DescriptionBase<?>){
+ DescriptionBase<?> description = (DescriptionBase<?>) element;
FeatureNodeContainerTree containerTree = featureNodeContainerCache.get(description);
if(containerTree != null && containerTree.getRoot() != null){
return containerTree.getRoot().getChildren().size() != 0;
* @param parentElement
* @return
*/
- protected List<DescriptionBase> getDescriptions(TaxonEditorInput parentElement) {
- Taxon taxon = parentElement.getTaxon();
- List<DescriptionBase> descriptions = new ArrayList<DescriptionBase>();
- for(DescriptionBase description : taxon.getDescriptions()){
+ protected List<DescriptionBase> getDescriptions(IDescribable<?> parentElement) {
+ Set<? extends DescriptionBase<?>> elementDescriptions = parentElement.getDescriptions();
+ List<DescriptionBase> resultDescriptions = new ArrayList<DescriptionBase>();
+ for(DescriptionBase description : elementDescriptions){
if(! description.isImageGallery()){
MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseMarkerType);
Set<Marker> descriptionMarkers = description.getMarkers();
if(descriptionMarkers != null && !descriptionMarkers.isEmpty()) {
for (Marker marker: descriptionMarkers) {
if(!(marker.getMarkerType().equals(useMarkertype))) {
- descriptions.add(description);
+ resultDescriptions.add(description);
}
}
}
else {
- descriptions.add(description);
+ resultDescriptions.add(description);
}
}
}
- return descriptions;
+ return resultDescriptions;
}
/* (non-Javadoc)
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
-import eu.etaxonomy.cdm.model.description.TaxonDescription;
-import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
-import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
-import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor;
-import eu.etaxonomy.taxeditor.editor.key.AbstractGraphKeyEditor;
+import eu.etaxonomy.cdm.model.description.IDescribable;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainerTree;
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
+import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
import eu.etaxonomy.taxeditor.model.ImageResources;
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
+import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
+import eu.etaxonomy.taxeditor.view.supplementaldata.SupplementalDataViewPart;
/**
* <p>DescriptiveViewPart class.</p>
protected TreeViewer viewer;
- /**
- * Maps {@link FeatureNodeContainerTree} to their corresponding {@link TaxonDescritpion}.<br>
- * This serves as input for the {@link ITreeContentProvider} of the {@link TreeViewer}
- */
- protected Map<TaxonDescription, FeatureNodeContainerTree> featureNodeContainerCache = new HashMap<TaxonDescription, FeatureNodeContainerTree>();
+ protected Map<DescriptionBase<?>, FeatureNodeContainerTree> featureNodeContainerCache = new HashMap<DescriptionBase<?>, FeatureNodeContainerTree>();
protected ToggleDescriptionAction showAllElementsAction;
return;
}
- if(part instanceof BulkEditor){
- showEmptyPage();
- return;
+ if(part == this){
+ return;
}
-
- if(part instanceof AbstractGraphKeyEditor){
- showEmptyPage();
- return;
+ if(part instanceof DetailsViewPart || part instanceof SupplementalDataViewPart){
+ // do not show empty page as these views are also used to edit the description selected in this view
+ return;
}
- if(part instanceof DefinedTermEditor){
- showEmptyPage();
- return;
+ if(selection instanceof IStructuredSelection
+ && ((IStructuredSelection) selection).getFirstElement() instanceof IDescribable<?>
+ && part instanceof IPartContentHasFactualData){
+ featureNodeContainerCache.clear();
+ showViewer(part, (IStructuredSelection) selection);
+ return;
}
-
- if(part instanceof MultiPageTaxonEditor){
- if(! part.equals(this.part)){
- IEditorInput input = ((IEditorPart) part).getEditorInput();
- featureNodeContainerCache.clear();
- showViewer(part, new StructuredSelection(input));
- }
+ else{
+ showEmptyPage();
}
}
// $Id$
/**
* Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy
+ * 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.
*/
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeSelection;
-import org.eclipse.jface.viewers.TreePath;
import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.handlers.HandlerUtil;
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.description.TaxonDescription;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateDescriptionElementOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
* ExecutionEvent)
*/
- /** {@inheritDoc} */
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IWorkbenchPart part = HandlerUtil.getActivePart(event);
- IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part
- : null;
+ /** {@inheritDoc} */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IWorkbenchPart part = HandlerUtil.getActivePart(event);
+ IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part
+ : null;
- IEditorPart editor = HandlerUtil.getActiveEditor(event);
- if (editor instanceof FormEditor) {
- editor = ((FormEditor) editor).getActiveEditor();
- }
- IEditorInput input = editor.getEditorInput();
- if (input instanceof TaxonEditorInput) {
- Taxon taxon = ((TaxonEditorInput) input).getTaxon();
- TaxonDescription description = null;
+ DescriptionBase<?> description = null;
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (selection instanceof ITreeSelection) {
- TreePath[] paths = ((ITreeSelection) selection).getPaths();
- Object firstSegment = paths[0].getFirstSegment();
- if (firstSegment instanceof TaxonDescription) {
- description = (TaxonDescription) firstSegment;
- }
- }else if (selection instanceof IStructuredSelection) {
- Object selectedElement = ((IStructuredSelection) selection)
- .getFirstElement();
- if (selectedElement instanceof TaxonDescription){
- description = (TaxonDescription) selectedElement;
- }
- }
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (selection instanceof IStructuredSelection) {
+ Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
+ if (selectedElement instanceof DescriptionBase<?>) {
+ description = (DescriptionBase<?>) selectedElement;
+ }
+ }
- if (description != null) {
- AbstractPostOperation operation = null;
- try {
- // TODO use undo context specific to editor
- operation = operationCreationInstance(event.getCommand().getName(), event, taxon, description, postOperationEnabled);
- EditorUtil.executeOperation(operation);
- } catch (NotDefinedException e) {
- EditorUtil.warn(getClass(), "Command name not set");
- }
- } else {
- EditorUtil.error(getClass(), new IllegalArgumentException("Could not determine the taxon description"));
- return null;
- }
- }
- return null;
+ if (description != null) {
+ AbstractPostOperation operation = null;
+ try {
+ // TODO use undo context specific to editor
+ operation = operationCreationInstance(event.getCommand().getName(), event, description, postOperationEnabled);
+ AbstractUtility.executeOperation(operation);
+ } catch (NotDefinedException e) {
+ AbstractUtility.warn(getClass(), "Command name not set");
+ }
+ } else {
+ AbstractUtility.error(getClass(), new IllegalArgumentException("Could not determine the taxon description"));
+ return null;
+ }
+ return null;
- }
-
- /**
+ }
+
+ /**
* Added to make the Class more generic and limit the amount of code changes required
* @param label
* @param event
* @param postOperationEnabled
* @return
*/
- protected AbstractPostOperation operationCreationInstance(String label, ExecutionEvent event, Taxon taxon, TaxonDescription description, IPostOperationEnabled postOperationEnabled) {
+ protected AbstractPostOperation operationCreationInstance(String label, ExecutionEvent event, DescriptionBase<?> description, IPostOperationEnabled postOperationEnabled) {
Feature feature = (Feature) ((Event) event.getTrigger()).data;
- return new CreateDescriptionElementOperation(label,
- EditorUtil.getUndoContext(), taxon,
- description, feature, postOperationEnabled);
+ return new CreateDescriptionElementOperation(label, EditorUtil.getUndoContext(), description, feature, postOperationEnabled);
}
}
// $Id$
/**
* Copyright (C) 2011 EDIT
-* European Distributed Institute of Taxonomy
+* 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.
*/
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.handlers.HandlerUtil;
+import eu.etaxonomy.cdm.model.description.SpecimenDescription;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateTaxonDescriptionOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
/** {@inheritDoc} */
- public Object execute(ExecutionEvent event) throws ExecutionException {
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart part = HandlerUtil.getActivePart(event);
IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null;
-
-
+
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (editor instanceof FormEditor) {
editor = ((FormEditor) editor).getActiveEditor();
}
IEditorInput input = editor.getEditorInput();
+ // taxon description
if (input instanceof TaxonEditorInput) {
- Taxon taxon = ((TaxonEditorInput) input).getTaxon();
+ Taxon taxon = ((TaxonEditorInput) input).getTaxon();
AbstractPostOperation operation;
try {
-
+
operation = createOperationInstance(event.getCommand().getName(), taxon, postOperationEnabled);
- EditorUtil.executeOperation(operation);
+ AbstractUtility.executeOperation(operation);
} catch (NotDefinedException e) {
- EditorUtil.warn(getClass(), "Command name not set.");
+ AbstractUtility.warn(getClass(), "Command name not set.");
}
- }
+ }
+ // specimen description
+ else{
+ //FIXME: no undo and redo supported. Should also use postOperation
+ ISelection selection = editor.getSite().getSelectionProvider().getSelection();
+ if(selection instanceof IStructuredSelection){
+ Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
+ if(selectedElement instanceof SpecimenOrObservationBase<?>){
+ SpecimenDescription description = SpecimenDescription.NewInstance((SpecimenOrObservationBase<?>) selectedElement);
+ postOperationEnabled.postOperation(description);
+ }
+ }
+ }
return null;
}
-
- /**Comments for funtion createOperationInstance
+
+ /**
* The function is used to make the specific object creation more generic
* @param eventLabel
* @param taxon
* @return
*/
protected AbstractPostOperation createOperationInstance(String eventLabel, Taxon taxon, IPostOperationEnabled postOperationEnabled) {
- // TODO use undo context specific to editor
+ // TODO use undo context specific to editor
return new CreateTaxonDescriptionOperation(eventLabel, EditorUtil.getUndoContext(), taxon, postOperationEnabled);
}
-
+
}
import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.FeatureNode;
import eu.etaxonomy.cdm.model.description.FeatureTree;
-import eu.etaxonomy.cdm.model.description.TaxonDescription;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateDescriptionElementOperation;
*/
public class DynamicFeatureMenu extends CompoundContributionItem {
- private ISelectionService selectionService = EditorUtil.getActivePart()
+ private final ISelectionService selectionService = EditorUtil.getActivePart()
.getSite().getWorkbenchWindow().getSelectionService();
- private IHandlerService handlerService = (IHandlerService) EditorUtil
+ private final IHandlerService handlerService = (IHandlerService) EditorUtil
.getService(IHandlerService.class);
/*
Object selectedElement = structuredSelection
.getFirstElement();
- if (selectedElement instanceof TaxonDescription) {
- FeatureTree featureTree = getFeatureTree((TaxonDescription) selectedElement);
+ if (selectedElement instanceof DescriptionBase<?>) {
+ FeatureTree featureTree = getFeatureTree((DescriptionBase<?>) selectedElement);
for (FeatureNode childNode : featureTree.getRootChildren()) {
createMenuItem(menu, childNode.getFeature());
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* 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.
*/
import eu.etaxonomy.cdm.model.description.CategoricalData;
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
import eu.etaxonomy.cdm.model.description.Distribution;
import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
import eu.etaxonomy.cdm.model.description.QuantitativeData;
-import eu.etaxonomy.cdm.model.description.TaxonDescription;
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
import eu.etaxonomy.cdm.model.description.TextData;
import eu.etaxonomy.cdm.model.taxon.Taxon;
* @version 1.0
*/
public class CreateDescriptionElementOperation extends AbstractPostOperation {
-
+
/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.descripti"{trunked}</code> */
public static final String ID = "eu.etaxonomy.taxeditor.editor.description.createDescriptionElement";
-
- private TaxonDescription description;
- private Feature feature;
+
+ private final DescriptionBase<?> description;
+ private final Feature feature;
private DescriptionElementBase element;
/**
* @param label a {@link java.lang.String} object.
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
* @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
- * @param description a {@link eu.etaxonomy.cdm.model.description.TaxonDescription} object.
+ * @param description a {@link DescriptionBase} object.
* @param feature a {@link eu.etaxonomy.cdm.model.description.Feature} object.
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
*/
public CreateDescriptionElementOperation(String label, IUndoContext undoContext,
- Taxon taxon, TaxonDescription description, Feature feature, IPostOperationEnabled postOperationEnabled) {
- super(label, undoContext, taxon, postOperationEnabled);
-
+ DescriptionBase<?> description, Feature feature, IPostOperationEnabled postOperationEnabled) {
+ super(label, undoContext, (Taxon)null, postOperationEnabled);
+
this.description = description;
this.feature = feature;
}
*
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
* @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
- * @param description a {@link eu.etaxonomy.cdm.model.description.TaxonDescription} object.
+ * @param description a {@link DescriptionBase} object.
* @param feature a {@link eu.etaxonomy.cdm.model.description.Feature} object.
* @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
* @param label a {@link java.lang.String} object.
*/
public CreateDescriptionElementOperation(String label,
- IUndoContext undoContext, Taxon taxon,
- TaxonDescription description, Feature feature,
+ IUndoContext undoContext, DescriptionBase<?> description, Feature feature,
DescriptionElementBase element, IPostOperationEnabled postOperationEnabled) {
- this(label, undoContext, taxon, description, feature, postOperationEnabled);
-
+ this(label, undoContext, description, feature, postOperationEnabled);
+
this.element = element;
}
if (element == null) {
if (feature.isSupportsCommonTaxonName()) {
element = CommonTaxonName.NewInstance("", null);
- }
+ }
else if (feature.isSupportsDistribution()) {
element = Distribution.NewInstance();
- }
+ }
else if(feature.isSupportsTaxonInteraction()){
element = TaxonInteraction.NewInstance();
}
@Override
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
-
+
description.addElement(element);
-
+
return postExecute(element);
}
@Override
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
-
+
description.removeElement(element);
-
+
return postExecute(null);
}
}
/**\r
* Copyright (C) 2011 EDIT\r
- * European Distributed Institute of Taxonomy \r
+ * European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
- * \r
+ *\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
import java.util.Map;\r
import java.util.Set;\r
\r
-import org.eclipse.jface.viewers.ITreeContentProvider;\r
-import org.eclipse.jface.viewers.Viewer;\r
-\r
import eu.etaxonomy.cdm.api.service.ITermService;\r
import eu.etaxonomy.cdm.model.common.Marker;\r
import eu.etaxonomy.cdm.model.common.MarkerType;\r
import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
-import eu.etaxonomy.cdm.model.description.Feature;\r
-import eu.etaxonomy.cdm.model.description.FeatureTree;\r
-import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
+import eu.etaxonomy.cdm.model.description.IDescribable;\r
import eu.etaxonomy.cdm.model.taxon.Taxon;\r
-import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;\r
import eu.etaxonomy.taxeditor.editor.UsageTermCollection;\r
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveContentProvider;\r
-import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;\r
import eu.etaxonomy.taxeditor.model.FeatureNodeContainerTree;\r
-import eu.etaxonomy.taxeditor.preference.PreferencesUtil;\r
import eu.etaxonomy.taxeditor.store.CdmStore;\r
-import eu.etaxonomy.taxeditor.store.TermStore;\r
\r
/**\r
* The class provides the required content to the Uses View\r
- * @author a.theys \r
+ * @author a.theys\r
* @created mar 13, 2012\r
* @version 1.0\r
*/\r
-public class UsesContentProvider extends DescriptiveContentProvider implements ITreeContentProvider {\r
+public class UsesContentProvider extends DescriptiveContentProvider {\r
\r
Set<MarkerType> markerTypes = new HashSet<MarkerType>();\r
- \r
+\r
/**\r
* <p>Constructor for DescriptiveContentProvider.</p>\r
*\r
* @param featureNodeContainerCache a {@link java.util.Map} object.\r
*/\r
- public UsesContentProvider(Map<TaxonDescription, FeatureNodeContainerTree> featureNodeContainerCache) {\r
+ public UsesContentProvider(Map<DescriptionBase<?>, FeatureNodeContainerTree> featureNodeContainerCache) {\r
super(featureNodeContainerCache);\r
this.featureNodeContainerCache = featureNodeContainerCache;\r
}\r
\r
/**\r
* Get all descriptions associated with the given TaxonEditorInput\r
- * \r
+ *\r
* @param parentElement\r
* @return\r
*/\r
@Override\r
- protected List<DescriptionBase> getDescriptions(TaxonEditorInput parentElement) {\r
- this.markerTypes.addAll(CdmStore.getTermManager().getPreferredTerms(MarkerType.class));\r
- Taxon taxon = parentElement.getTaxon();\r
- List<DescriptionBase> descriptions = new ArrayList<DescriptionBase>();\r
- \r
- for(DescriptionBase description : taxon.getDescriptions()){\r
- if(! description.isImageGallery()){\r
- MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseMarkerType);\r
- Set<Marker> descriptionMarkers = description.getMarkers();\r
- if(descriptionMarkers != null) {\r
- for (Marker marker: descriptionMarkers) {\r
- if(marker.getMarkerType().equals(useMarkertype)) {\r
- descriptions.add(description);\r
- }\r
- }\r
- }\r
- }\r
- } \r
+ protected List<DescriptionBase> getDescriptions(IDescribable<?> parentElement) {\r
+ List<DescriptionBase> descriptions = new ArrayList<DescriptionBase>();\r
+ if(parentElement instanceof Taxon){\r
+ Taxon taxon = (Taxon) parentElement;\r
+ this.markerTypes.addAll(CdmStore.getTermManager().getPreferredTerms(MarkerType.class));\r
+ for(DescriptionBase description : taxon.getDescriptions()){\r
+ if(! description.isImageGallery()){\r
+ MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseMarkerType);\r
+ Set<Marker> descriptionMarkers = description.getMarkers();\r
+ if(descriptionMarkers != null) {\r
+ for (Marker marker: descriptionMarkers) {\r
+ if(marker.getMarkerType().equals(useMarkertype)) {\r
+ descriptions.add(description);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
return descriptions;\r
}\r
\r
/**
* Copyright (C) 2011 EDIT
- * European Distributed Institute of Taxonomy
+ * 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.
*/
import org.eclipse.core.commands.ExecutionEvent;
import eu.etaxonomy.cdm.api.service.ITermService;
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.description.TaxonDescription;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.UsageTermCollection;
import eu.etaxonomy.taxeditor.editor.view.descriptive.handler.CreateDescriptionElementHandler;
/**
* CreateUseRecordHandler Class
- * @author a.theys
+ * @author a.theys
* @created mar 13, 2012
* @version 1.0
*/
public class CreateUseRecordHandler extends CreateDescriptionElementHandler {
/** {@inheritDoc} */
@Override
- protected AbstractPostOperation operationCreationInstance(String label, ExecutionEvent event, Taxon taxon, TaxonDescription description, IPostOperationEnabled postOperationEnabled) {
+ protected AbstractPostOperation operationCreationInstance(String label, ExecutionEvent event, DescriptionBase<?> description, IPostOperationEnabled postOperationEnabled) {
//Use Record Feature retrieval below
Feature feature = (Feature) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseRecordFeature);
feature.setSupportsCategoricalData(true);
return new CreateUseRecordOperation(label,
- EditorUtil.getUndoContext(), taxon,
+ EditorUtil.getUndoContext(),
description, feature, postOperationEnabled);
}
-
-
-
+
+
+
}
/**\r
* Copyright (C) 2011 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
-* \r
+*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
import org.eclipse.core.commands.ExecutionEvent;\r
\r
import eu.etaxonomy.cdm.api.service.ITermService;\r
+import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
import eu.etaxonomy.cdm.model.description.Feature;\r
-import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
-import eu.etaxonomy.cdm.model.taxon.Taxon;\r
import eu.etaxonomy.taxeditor.editor.EditorUtil;\r
import eu.etaxonomy.taxeditor.editor.UsageTermCollection;\r
import eu.etaxonomy.taxeditor.editor.view.descriptive.handler.CreateDescriptionElementHandler;\r
\r
/**\r
* CreateUseSummaryHandler Class\r
- * @author a.theys \r
+ * @author a.theys\r
* @created mar 13, 2012\r
* @version 1.0\r
*/\r
public class CreateUseSummaryHandler extends CreateDescriptionElementHandler {\r
/** {@inheritDoc} */\r
@Override\r
- protected AbstractPostOperation operationCreationInstance(String label, ExecutionEvent event, Taxon taxon, TaxonDescription description, IPostOperationEnabled postOperationEnabled) {\r
+ protected AbstractPostOperation operationCreationInstance(String label, ExecutionEvent event, DescriptionBase<?> description, IPostOperationEnabled postOperationEnabled) {\r
//Use Record Feature retrieval below\r
Feature feature = (Feature) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseSummaryFeature);\r
feature.setSupportsTextData(true);\r
- return new CreateUseSummaryOperation(label, EditorUtil.getUndoContext(), taxon, description, feature, postOperationEnabled);\r
+ return new CreateUseSummaryOperation(label, EditorUtil.getUndoContext(), description, feature, postOperationEnabled);\r
}\r
- \r
+\r
}\r
/**
* Copyright (C) 2011 EDIT
-* European Distributed Institute of Taxonomy
+* 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.
*/
import org.eclipse.core.runtime.IStatus;
import eu.etaxonomy.cdm.model.description.CategoricalData;
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.TaxonDescription;
/**
* CreateUseRecordOperation Class
- * @author a.theys
+ * @author a.theys
* @created mar 13, 2012
* @version 1.0
*/
public class CreateUseRecordOperation extends AbstractPostOperation {
-
+
/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.use."{trunked}</code> */
public static final String ID = "eu.etaxonomy.taxeditor.editor.use.createUseRecord";
- private TaxonDescription description;
- private Feature feature;
+ private final DescriptionBase<?> description;
+ private final Feature feature;
private DescriptionElementBase element;
/**
* @param feature a {@link eu.etaxonomy.cdm.model.description.Feature} object.
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
*/
- public CreateUseRecordOperation(String label, IUndoContext undoContext,
- Taxon taxon, TaxonDescription description, Feature feature, IPostOperationEnabled postOperationEnabled) {
- super(label, undoContext, taxon, postOperationEnabled);
-
+ public CreateUseRecordOperation(String label, IUndoContext undoContext, DescriptionBase<?> description, Feature feature, IPostOperationEnabled postOperationEnabled) {
+ super(label, undoContext, (Taxon)null, postOperationEnabled);
+
this.description = description;
this.feature = feature;
}
-
+
/**
* <p>Constructor for CreateUseRecordOperation.</p>
*
IUndoContext undoContext, Taxon taxon,
TaxonDescription description, Feature feature,
DescriptionElementBase element, IPostOperationEnabled postOperationEnabled) {
- this(label, undoContext, taxon, description, feature, postOperationEnabled);
-
+ this(label, undoContext, description, feature, postOperationEnabled);
+
this.element = element;
}
}
}
-
+
element.setFeature(feature);
description.addElement(element);
monitor.worked(40);
@Override
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
-
+
description.addElement(element);
-
+
return postExecute(element);
}
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
description.removeElement(element);
-
+
return postExecute(null);
}
}
/**\r
* Copyright (C) 2011 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
-* \r
+*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
import org.eclipse.core.runtime.IProgressMonitor;\r
import org.eclipse.core.runtime.IStatus;\r
\r
+import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
import eu.etaxonomy.cdm.model.description.Feature;\r
import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
\r
/**\r
* CreateUseSummaryOperation Class\r
- * @author a.theys \r
+ * @author a.theys\r
* @created mar 13, 2012\r
* @version 1.0\r
*/\r
public class CreateUseSummaryOperation extends AbstractPostOperation {\r
- \r
+\r
public static final String ID = "eu.etaxonomy.taxeditor.editor.use.createUseRecord";\r
- \r
- private TaxonDescription description;\r
- private Feature feature;\r
+\r
+ private final DescriptionBase<?> description;\r
+ private final Feature feature;\r
private DescriptionElementBase element;\r
\r
- \r
+\r
/**\r
* <p>Constructor for CreateUseSummaryOperation.</p>\r
*\r
* @param feature a {@link eu.etaxonomy.cdm.model.description.Feature} object.\r
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.\r
*/\r
- public CreateUseSummaryOperation(String label, IUndoContext undoContext,\r
- Taxon taxon, TaxonDescription description, Feature feature, IPostOperationEnabled postOperationEnabled) {\r
- super(label, undoContext, taxon, postOperationEnabled);\r
- \r
+ public CreateUseSummaryOperation(String label, IUndoContext undoContext, DescriptionBase<?> description, Feature feature, IPostOperationEnabled postOperationEnabled) {\r
+ super(label, undoContext, (Taxon)null, postOperationEnabled);\r
+\r
this.description = description;\r
this.feature = feature;\r
}\r
IUndoContext undoContext, Taxon taxon,\r
TaxonDescription description, Feature feature,\r
DescriptionElementBase element, IPostOperationEnabled postOperationEnabled) {\r
- this(label, undoContext, taxon, description, feature, postOperationEnabled);\r
- \r
+ this(label, undoContext, description, feature, postOperationEnabled);\r
+\r
this.element = element;\r
}\r
\r
element = TextData.NewInstance();\r
}\r
\r
- \r
+\r
element.setFeature(feature);\r
description.addElement(element);\r
monitor.worked(40);\r
@Override\r
public IStatus redo(IProgressMonitor monitor, IAdaptable info)\r
throws ExecutionException {\r
- \r
+\r
description.addElement(element);\r
- \r
+\r
return postExecute(element);\r
}\r
\r
public IStatus undo(IProgressMonitor monitor, IAdaptable info)\r
throws ExecutionException {\r
description.removeElement(element);\r
- \r
+\r
return postExecute(null);\r
}\r
}\r
private static Feature feature;
- private DescriptionElementBase[] arrayType = new DescriptionElementBase[0];
-
+ private final DescriptionElementBase[] arrayType = new DescriptionElementBase[0];
+
@BeforeClass
public static void setUpBeforeClass() throws Exception {
taxon = Taxon.NewInstance(null, null);
description = TaxonDescription.NewInstance();
feature = Feature.NewInstance();
-
- operation = new CreateDescriptionElementOperation("Add Element", null, taxon, description, feature, postOperation);
+
+ operation = new CreateDescriptionElementOperation("Add Element", null, description, feature, postOperation);
}
@Test
public void testExecute() throws ExecutionException {
operation.execute(monitor, info);
-
+
Assert.assertTrue(description.getElements().size() > 0);
Assert.assertEquals(feature, description.getElements().toArray(arrayType)[0].getFeature());
}
@Test
public void testUndo() throws ExecutionException {
operation.undo(monitor, info);
-
+
Assert.assertTrue(description.getElements().size() == 0);
}
-
+
@Test
public void testRedo() throws ExecutionException {
operation.redo(monitor, info);
-
+
Assert.assertTrue(description.getElements().size() > 0);
Assert.assertEquals(feature, description.getElements().toArray(arrayType)[0].getFeature());
}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2013 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;
+
+/**
+ * Clients implementing this interface indicate, that the data they present is suitable for the factual data view.
+ *
+ * @author pplitzner
+ * @date 03.12.2013
+ *
+ */
+public interface IPartContentHasFactualData {
+
+}
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
import eu.etaxonomy.cdm.model.description.PolytomousKey;
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
+import eu.etaxonomy.cdm.model.description.SpecimenDescription;
import eu.etaxonomy.cdm.model.media.Media;
import eu.etaxonomy.cdm.model.name.NonViralName;
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
createTeamOrPersonBaseDetailSection(rootElement);
} else if (input instanceof DescriptionBase) {
- Set<Marker> descriptionMarkers = ((DescriptionBase) input).getMarkers();
- MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(
- UsageTermCollection.uuidUseMarkerType);
- Boolean isUseDescription = false;
- for (Marker marker : descriptionMarkers) {
- if (marker.getMarkerType().equals(useMarkertype)) {
- isUseDescription = true;
- }
- }
- if (((DescriptionBase) input).isImageGallery()) {
- createImageGallerySection(rootElement);
-
- } else if (isUseDescription) {
- createUseDescriptionSection(rootElement);
- } else {
- createDescriptionSection(rootElement);
-
- }
+ if(input instanceof SpecimenDescription){
+ //TODO: add more sections to DetailsView for SpecimenDescription
+ createSpecimenDescriptionSection(rootElement);
+ }
+ else{
+ Set<Marker> descriptionMarkers = ((DescriptionBase) input).getMarkers();
+ MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(
+ UsageTermCollection.uuidUseMarkerType);
+ Boolean isUseDescription = false;
+ for (Marker marker : descriptionMarkers) {
+ if (marker.getMarkerType().equals(useMarkertype)) {
+ isUseDescription = true;
+ }
+ }
+ if (((DescriptionBase) input).isImageGallery()) {
+ createImageGallerySection(rootElement);
+
+ } else if (isUseDescription) {
+ createUseDescriptionSection(rootElement);
+ } else {
+ createDescriptionSection(rootElement);
+
+ }
+ }
} else if (input instanceof DescriptionElementBase) {
Set<Marker> descriptionMarkers = ((DescriptionElementBase) input).getInDescription().getMarkers();
MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(
addPart(scopeSection);
}
+ /**
+ * createDescriptionSection
+ *
+ * @param parent
+ */
+ private void createSpecimenDescriptionSection(RootElement parent) {
+ destroySections();
+ DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+ addPart(descriptionDetailSection);
+ }
+
/**
* Creates the use Description section
*
return;
}
+ if(part == this){
+ return;
+ }
+
if(!(selection instanceof IStructuredSelection)){
return;
}