eu.etaxonomy.taxeditor.bulkeditor,
eu.etaxonomy.taxeditor.editor,
eu.etaxonomy.taxeditor.printpublisher,
+ eu.etaxonomy.taxeditor.molecular,
eu.etaxonomy.taxeditor.help,
org.eclipse.equinox.ds,
org.eclipse.equinox.util,
id="eu_etaxonomy_taxeditor_product"\r
point="org.eclipse.core.runtime.products">\r
<product\r
- application="eu.etaxonomy.taxeditor.application.application"\r
+ application="eu.etaxonomy.taxeditor.editor.application"\r
name="EDIT Taxonomic Editor">\r
<property\r
name="appName"\r
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.equinox.internal.p2.ui.ProvUI;
import org.eclipse.equinox.internal.p2.ui.model.ElementUtils;
import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.operations.ProvisioningJob;
import org.eclipse.equinox.p2.operations.ProvisioningSession;
+import org.eclipse.equinox.p2.operations.RepositoryTracker;
import org.eclipse.equinox.p2.operations.Update;
import org.eclipse.equinox.p2.operations.UpdateOperation;
-import org.eclipse.equinox.p2.repository.IRepository;
-import org.eclipse.equinox.p2.repository.IRepositoryManager;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
*
*/
public static void checkForUpdates() {
-
+ // the main job which performs the update
Job updateJob = new Job("Update Job") {
@Override
public IStatus run(IProgressMonitor monitor) {
*/
private static IStatus doCheckForUpdates(IProgressMonitor monitor) {
- // force refresh all the caches before
- IMetadataRepositoryManager metaManager = ProvUI.getMetadataRepositoryManager(ProvisioningUI.getDefaultUI().getSession());
- URI[] repos = metaManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
- for(URI repo : repos) {
- try {
- metaManager.refreshRepository(repo, monitor);
- } catch (ProvisionException pe) {
- IStatus errorStatus = new Status(IStatus.ERROR, TaxonomicEditorPlugin.PLUGIN_ID,
- "Error occured while reloading cache.", pe);
-
- } catch (OperationCanceledException oce) {
- IStatus errorStatus = new Status(IStatus.ERROR, TaxonomicEditorPlugin.PLUGIN_ID,
- "Error occured while reloading cache.", oce);
- }
- }
BundleContext bundleContext = TaxonomicEditorPlugin.getContext();
ServiceReference reference = bundleContext.getServiceReference(IProvisioningAgent.SERVICE_NAME);
if (reference == null) {
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.texteditor.IDocumentProvider;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.strategy.merge.MergeException;
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityContainer;
import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation;
import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel;
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants;
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
+import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* <p>MergeGroupHandler class.</p>
}
Object targetEntity = ((IEntityContainer<?>) targetAnnotation).getEntity();
+ TeamOrPersonBase teamOrPerson = null;
+ Reference ref = null;
+ if (targetEntity instanceof TeamOrPersonBase){
+ teamOrPerson = HibernateProxyHelper.deproxy(targetEntity, TeamOrPersonBase.class);
+ } else if(targetEntity instanceof Reference){
+ ref = HibernateProxyHelper.deproxy(targetEntity, Reference.class);
+ }
logger.info("Merging group");
// model.printAnnotations();
for (LineAnnotation annotation : candidateAnnotations) {
+ //first check whether entities are mergeable
+
+ try{
+ if (ref != null){
+ Reference ref2 = HibernateProxyHelper.deproxy(annotation.getEntity(), Reference.class);
+
+ if (!CdmStore.getCommonService().isMergeable(ref, ref2, null)){
+ MessageDialog.openWarning(HandlerUtil.getActiveShell(event),
+ "No merge possible", "A merge of " + ref.getTitleCache() + " and " + ref2.getTitleCache() + " is not possible.");
+ return null;
+ }
+ }
+ if (teamOrPerson != null){
+ TeamOrPersonBase teamOrPerson2 = HibernateProxyHelper.deproxy(annotation.getEntity(), TeamOrPersonBase.class);
+
+ if (!CdmStore.getCommonService().isMergeable(teamOrPerson, teamOrPerson2, null)){
+ MessageDialog.openWarning(HandlerUtil.getActiveShell(event),
+ "No merge possible", "A merge of " + teamOrPerson.getTitleCache() + " and " + teamOrPerson2.getTitleCache() + " is not possible.");
+ return null;
+ }
+ }
+ }catch(MergeException e){
+
+ }
((BulkEditor) editor).removeAnnotatedLine(annotation);
// Mark entity container for merging with target entity
editor.name.2 = Polytomous Key Graph Editor\r
editor.name.3 = Polytomous Key List Editor\r
editor.name.4 = Cdm Authority Editor\r
-editor.name.5 = Derivative View\r
+editor.name.5 = Derivative Editor\r
view.name = Factual Data\r
view.name.0 = Uses\r
view.name.1 = Media\r
command.name.33 = Open Related Concept\r
category.name.7 = -- Group\r
command.name.34 = Edit CDM Authorities\r
-command.name.35 = Open Derivative View\r
+command.name.35 = Open Derivative Editor\r
scheme.description = The default key binding scheme for the Taxonomic Editor\r
scheme.name = Taxonomic Editor Default Key Bindings\r
editor.name.6 = Specimen Import Editor\r
command.name.33 = \u00d6ffne verbundenes Konzept
category.name.7 = -- Gruppe
command.name.34 = Bearbeite CDM Rechte
-command.name.35 = \u00d6ffne Derivate Ansicht
+command.name.35 = \u00d6ffne Derivat-Editor
scheme.description = Die Standard Tastenkombinationsschema f\u00fcr den Taxonomischen Editor
scheme.name = Taxonomic Editor Standard Tastenkombinationen
editor.name.6 = Specimen Import Editor
command.name.33 = Open Related Concept\r
category.name.7 = -- Group\r
command.name.34 = Edit CDM Authorities\r
-command.name.35 = Open Derivate View\r
scheme.description = The default key binding scheme for the Taxonomic Editor\r
scheme.name = Taxonomic Editor Default Key Bindingseditor.name.6 = Specimen Import Editor\r
editor.name.7 = Gbif Import Editor\r
commandId="eu.etaxonomy.taxeditor.editor.command.new.name"
label="%command.label.46"
style="push">
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
<command
commandId="eu.etaxonomy.taxeditor.editor.command.new.reference"
label="%command.label.47"
style="push">
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
<command
commandId="eu.etaxonomy.taxeditor.editor.command.new.team"
label="%command.label.1"
style="push">
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
<command
commandId="eu.etaxonomy.taxeditor.editor.command.new.person"
label="%command.label.2"
style="push">
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
<separator
name="eu.etaxonomy.navigation.menu.new.separator2"
commandId="eu.etaxonomy.taxeditor.editor.command.new.specimen"
label="%command.label.3"
style="push">
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
<separator
name="eu.etaxonomy.navigation.menu.new.separator3"
commandId="eu.etaxonomy.taxeditor.editor.command.new.datasource"
label="%command.label.48"
style="push">
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
</menuContribution>
<menuContribution
name="org.eclipse.ui.views.showView.viewId"
value="eu.etaxonomy.taxeditor.editor.view.descriptive">
</parameter>
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
<command
commandId="org.eclipse.ui.views.showView"
name="org.eclipse.ui.views.showView.viewId"
value="eu.etaxonomy.taxeditor.editor.view.media">
</parameter>
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
<command
commandId="org.eclipse.ui.views.showView"
name="org.eclipse.ui.views.showView.viewId"
value="eu.etaxonomy.taxeditor.editor.view.concept">
</parameter>
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
<command
commandId="org.eclipse.ui.views.showView"
value="eu.etaxonomy.taxeditor.editor.view.concept.graph">
</parameter>
<visibleWhen
- checkEnabled="true">
- <and>
- <reference
- definitionId="isShowExperimentalFeatures">
- </reference>
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </and>
+ checkEnabled="false">
+ <reference
+ definitionId="isShowExperimentalFeatures">
+ </reference>
</visibleWhen>
</command>
</menuContribution>
commandId="eu.etaxonomy.taxeditor.editor.command.openParent"
label="%command.label.8"
style="push">
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
</menuContribution>
<menuContribution
<visibleWhen
checkEnabled="true">
<or>
- <reference
- definitionId="isDescriptionElement">
- </reference>
<reference
definitionId="isFeatureNodeContainer">
</reference>
name="org.eclipse.ui.views.showView.viewId"
value="eu.etaxonomy.taxeditor.editor.view.validation.problems">
</parameter>
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
</menuContribution>
</extension>
id="eu.etaxonomy.taxeditor.editor.media.command.delete"
name="%command.name.49">
</command>
+
<category
id="eu.etaxonomy.taxeditor.editor.new.category"
name="%category.name.4">
<command
categoryId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.category"
defaultHandler="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.MoveDescriptionToOtherTaxonHandler"
- id="eu.etaxonomy.taxeditor.editor.commands.description.moveDescriptionToTaxon"
+ id="eu.etaxonomy.taxeditor.editor.view.descriptive.command.moveDescriptionToTaxon"
name="%command.name.13">
</command>
+
<command
categoryId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.category"
defaultHandler="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.MoveDescriptionElementsHandler"
- id="eu.etaxonomy.taxeditor.description.commands.moveDescriptionElements"
+ id="eu.etaxonomy.taxeditor.editor.view.descriptive.command.moveDescriptionElements"
name="%command.name.12">
</command>
</description>
</wizard>
</extension>
+ <extension
+ point="eu.etaxonomy.taxeditor.store.cdmViewer">
+ <cdmViewer
+ class="eu.etaxonomy.taxeditor.editor.EditorCdmViewer">
+ </cdmViewer>
+ </extension>
</plugin>
@Override
public void setFocus() {
+ getConversationHolder().commit(true);
getConversationHolder().bind();
super.setFocus();
}
@Override
public boolean postOperation(CdmBase objectAffectedByOperation) {
viewer.refresh();
-
+ getConversationHolder().bind();
+ getConversationHolder().commit(true);
editor.changed(objectAffectedByOperation);
if (objectAffectedByOperation != null) {
import org.eclipse.ui.handlers.HandlerUtil;
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
+import eu.etaxonomy.cdm.api.service.DeleteResult;
import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService;
import eu.etaxonomy.cdm.api.service.ITaxonService;
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
+import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
import eu.etaxonomy.taxeditor.store.CdmStore;
controller = (ICdmApplicationConfiguration) CdmStore.getCurrentApplicationConfiguration();
IPolytomousKeyNodeService service = controller.getPolytomousKeyNodeService();
-
+ DeleteResult result;
if (node.getChildren().size()>0){
if(! MessageDialog.openQuestion(null, "Confirm deletion of children", "The selected node has children, do you want to delete them, too?")) {
- service.delete(node.getUuid(), false);
+ result = service.delete(node.getUuid(), false);
} else{
- service.delete(node.getUuid(), true);
+ result = service.delete(node.getUuid(), true);
}
} else{
- service.delete(node.getUuid(), true);
+ result = service.delete(node.getUuid(), true);
+ }
+
+ if (!result.isOk() || result.getExceptions().size() > 0){
+ Exception t = new Exception();
+ if (result.getExceptions().size() >1){
+ for (Exception e:result.getExceptions()){
+ t.addSuppressed(e);
+ }
+ }else {
+ t = result.getExceptions().iterator().next();
+ }
+ MessagingUtils.errorDialog("Exception occured. Delete not possible", getClass(),null, TaxeditorBulkeditorPlugin.PLUGIN_ID, t, true);
}
return postExecute(null);
}
import eu.etaxonomy.taxeditor.store.CdmStore;
/**
+ * Input for {@link DataImportEditor}. This class queries a data source for
+ * occurrences and passes them to the editor.
+ *
* @author pplitzner
* @date 25.02.2014
*
protected OccurenceQuery query;
- /**
- * @param results
- */
public DataImportEditorInput() {
this.conversationHolder = CdmStore.createConversation();
}
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
@Override
public Object getAdapter(Class adapter) {
// TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#exists()
- */
@Override
public boolean exists() {
return false;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
- */
@Override
public ImageDescriptor getImageDescriptor() {
// TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#getPersistable()
- */
@Override
public IPersistableElement getPersistable() {
return null;
}
- /**
- * @return the results
- */
public Collection<T> getResults() {
return results;
}
- /**
- * @param results the results to set
- */
public void setResults(Collection<T> results) {
this.results = results;
}
- /**
- * @return the conversationHolder
- */
public ConversationHolder getConversationHolder() {
return conversationHolder;
}
*/
public class GbifImportEditorInput extends DataImportEditorInput<GbifResponse> {
- /**
- * @param query
- */
public GbifImportEditorInput(OccurenceQuery query) {
super();
this.query = query;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#getName()
- */
@Override
public String getName() {
return "[GBIF] " + query.toString();
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#getToolTipText()
- */
@Override
public String getToolTipText() {
return "[GBIF] " + query.toString();
}
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() {
final int prime = 31;
return result;
}
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(Object obj) {
if (this == obj) {
public List<List<Synonym>> getSynonymsByHomotypicGroup(Taxon taxon, List<String> propertyPaths) {
return defaultService.getSynonymsByHomotypicGroup(taxon, propertyPaths);
}
-
+
@Override
public Synonym changeRelatedTaxonToSynonym(Taxon fromTaxon, Taxon toTaxon,
TaxonRelationshipType oldRelationshipType,
DerivateViewEditorInput derivateViewEditorInput = (DerivateViewEditorInput) getEditorInput();
return derivateViewEditorInput.getName();
}
- return "Derivative View";
+ return "Derivative Editor";
}
/* (non-Javadoc)
derivateView = (DerivateView) getPostOperationEnabled();
}
if(derivateView==null){
- MessagingUtils.operationDialog(this, new NullPointerException("DerivativeView was null"), TaxeditorEditorPlugin.PLUGIN_ID, this.getLabel(), getLabel());
+ MessagingUtils.operationDialog(this, new NullPointerException("Derivative Editor was null"), TaxeditorEditorPlugin.PLUGIN_ID, this.getLabel(), getLabel());
return Status.CANCEL_STATUS;
}
if(derivateView.isDirty()){
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.handlers.HandlerUtil;
import eu.etaxonomy.cdm.api.service.IDescriptionService;
import eu.etaxonomy.cdm.api.service.ITaxonService;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.common.Annotation;
import eu.etaxonomy.cdm.model.common.AnnotationType;
+import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.common.Language;
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
import eu.etaxonomy.cdm.model.description.TaxonDescription;
import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
+import eu.etaxonomy.taxeditor.editor.Page;
+import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.MoveDescriptionElementsOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonBaseSelectionDialog;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
/**
* @created Feb 8, 2011
* @version 1.0
*/
-public class MoveDescriptionElementsHandler extends AbstractHandler {
-
+public class MoveDescriptionElementsHandler extends AbstractHandler implements IPostOperationEnabled{
+ private UUID newAcceptedTaxonNodeUuid;
+ private TaxonNameEditor editor;
/* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
// ConversationHolder conversation = CdmStore.createConversation();
-
+ editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(Page.NAME);
ISelection selection = HandlerUtil.getCurrentSelection(event);
if(selection instanceof IStructuredSelection){
if(elements.size() == 0){
return null;
}
+ DescriptionBase description = elements.get(0).getInDescription();
+ List<UUID> excludeTaxa = new ArrayList<UUID>();
+ if (description.isInstanceOf(TaxonDescription.class)){
+ TaxonDescription taxonDescription = HibernateProxyHelper.deproxy(description, TaxonDescription.class);
+ Taxon actualTaxon = taxonDescription.getTaxon();
+ excludeTaxa.add(actualTaxon.getUuid());
+ }
- Taxon targetTaxon = TaxonBaseSelectionDialog.selectTaxon(HandlerUtil.getActiveShell(event), EditorUtil.getActiveMultiPageTaxonEditor().getConversationHolder(), null);
+
+ TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event),
+ editor.getConversationHolder(),
+ "Choose the accepted taxon",
+ excludeTaxa,
+ null,
+ null);
+ Taxon targetTaxon = newAcceptedTaxonNode.getTaxon();
if(targetTaxon == null){
// canceled
return null;
}
-
+ newAcceptedTaxonNodeUuid = newAcceptedTaxonNode.getUuid();
TaxonDescription targetDescription = TaxonDescription.NewInstance(targetTaxon);
String moveMessage = String.format("Elements moved from %s", EditorUtil.getActiveMultiPageTaxonEditor().getTaxon());
targetDescription.setTitleCache(moveMessage, true);
try {
AbstractPostOperation operation = new MoveDescriptionElementsOperation(
event.getCommand().getName(), EditorUtil.getUndoContext(),
- targetDescription, elements, false, (IPostOperationEnabled) EditorUtil.getView(DescriptiveViewPart.ID, true));
+ targetDescription, elements, false, this);
+
EditorUtil.executeOperation(operation);
-// conversation.commit(true);
- CdmStore.getService(ITaxonService.class).saveOrUpdate(targetTaxon);
+
+ //CdmStore.getService(ITaxonService.class).saveOrUpdate(targetTaxon);
} catch (NotDefinedException e) {
MessagingUtils.error(getClass(), e);
return null;
}
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
+ */
+ /** {@inheritDoc} */
+ @Override
+ public boolean postOperation(CdmBase objectAffectedByOperation) {
+
+ editor.getConversationHolder().bind();
+ editor.getConversationHolder().commit(true);
+ Display.getDefault().asyncExec(new Runnable(){
+
+ public void run() {
+ //AbstractUtility.close(editor.getMultiPageTaxonEditor());
+
+ try {
+ MultiPageTaxonEditor possibleOpenEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(newAcceptedTaxonNodeUuid);
+ if(possibleOpenEditor != null){
+ AbstractUtility.close(possibleOpenEditor);
+ }
+ EditorUtil.openTaxonNode(newAcceptedTaxonNodeUuid);
+ } catch (PartInitException e) {
+ MessagingUtils.error(this.getClass(), e);
+ throw new RuntimeException(e);
+ } catch (Exception e) {
+ MessagingUtils.warningDialog("Could not create Taxon", this, e.getMessage());
+ }
+ }
+
+ });
+
+
+ return true;
+ }
+
+ @Override
+ public boolean onComplete() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
}
import eu.etaxonomy.cdm.api.service.IDescriptionService;
import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.TaxonDescription;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.MoveDescriptionToOtherTaxonOperation;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
import eu.etaxonomy.taxeditor.store.CdmStore;
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
for(Object element : structuredSelection.toArray()){
- if (element instanceof TaxonDescription){
- UUID uuid = ((TaxonDescription)element).getUuid();
+ UUID uuid = null;
+ if (element instanceof FeatureNodeContainer){
+ uuid = ((FeatureNodeContainer)element).getDescription().getUuid();
+ } else if (element instanceof DescriptionBase){
+ uuid = ((DescriptionBase)element).getUuid();
+ }
+
+ if (uuid != null){
descriptions.add((TaxonDescription) CdmStore.getService(IDescriptionService.class).load(uuid, null));
}
}
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PartInitException;
import eu.etaxonomy.cdm.api.service.IDescriptionService;
+import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
import eu.etaxonomy.taxeditor.store.CdmStore;
* @created Feb 8, 2011
* @version 1.0
*/
-public class MoveDescriptionElementsOperation extends AbstractPostTaxonOperation {
+public class MoveDescriptionElementsOperation extends AbstractPostTaxonOperation{
private Collection<DescriptionElementBase> descriptionElements;
private DescriptionBase targetDescription;
service.moveDescriptionElementsToDescription(descriptionElements, targetDescription, isCopy);
+
return postExecute(targetDescription);
}
// TODO Auto-generated method stub
return null;
}
+
+
}
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Vendor: EDIT
+Export-Package: eu.etaxonomy.taxeditor.molecular,
+ eu.etaxonomy.taxeditor.molecular.editor,
+ eu.etaxonomy.taxeditor.molecular.handler
+Bundle-ClassPath: .
-bin.includes = META-INF/,\
+bin.includes = .,\
+ META-INF/,\
plugin.xml,\
icons/,\
OSGI-INF/
+source.. = src/main/java/
<dynamic
class="eu.etaxonomy.taxeditor.navigation.RecentNamesContributionItem"
id="eu.etaxonomy.taxeditor.navigation.recentnames">
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</dynamic>
</menuContribution>
<menuContribution
name="org.eclipse.ui.views.showView.viewId"
value="eu.etaxonomy.taxeditor.navigation.navigator">
</parameter>
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
<command
commandId="org.eclipse.ui.views.showView"
name="org.eclipse.ui.views.showView.viewId"
value="eu.etaxonomy.taxeditor.navigation.key.polytomous.polytomousKeyViewPart">
</parameter>
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
</menuContribution>
<menuContribution
id="eu.etaxonomy.taxeditor.navigation.search.toolbar">
<control
class="eu.etaxonomy.taxeditor.navigation.search.SearchBar">
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</control>
</toolbar>
</menuContribution>
commandId="eu.etaxonomy.taxeditor.navigation.command.create.taxonNode"
label="%command.label.13"
style="push">
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
<separator
name="eu.etaxonomy.navigation.menu.new.separator1"
id="eu.etaxonomy.taxeditor.navigation.create.classificationHandler"
label="%command.label.14"
style="push">
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
</menuContribution>
<menuContribution
</with>
</definition>
</extension>
+ <extension
+ point="eu.etaxonomy.taxeditor.store.cdmViewer">
+ <cdmViewer
+ class="eu.etaxonomy.taxeditor.navigation.NavigationCdmViewer">
+ </cdmViewer>
+ </extension>
</plugin>
*/
@Override
public boolean postOperation(CdmBase objectAffectedByOperation) {
+ getConversationHolder().bind();
+ getConversationHolder().commit(true);
viewer.refresh();
return true;
}
--- /dev/null
+package eu.etaxonomy.taxeditor.navigation.navigator;
+
+import org.eclipse.ui.internal.navigator.NavigatorContentService;
+import org.eclipse.ui.navigator.INavigatorDnDService;
+
+public class TaxonNavigatorContentService extends NavigatorContentService {
+
+ private TaxonNavigatorDnDService navigatorDnDService;
+
+ public TaxonNavigatorContentService(String viewerID) {
+ super(viewerID);
+
+
+ }
+
+ public TaxonNavigatorContentService(String aViewerId,
+ TaxonNavigatorViewer taxonNavigatorViewer) {
+ super(aViewerId, taxonNavigatorViewer);
+ getDnDService();
+ }
+
+ @Override
+ public TaxonNavigatorDnDService getDnDService() {
+ if (navigatorDnDService == null) {
+ navigatorDnDService = new TaxonNavigatorDnDService(this);
+ }
+ return navigatorDnDService;
+ }
+
+}
--- /dev/null
+package eu.etaxonomy.taxeditor.navigation.navigator;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.ui.internal.navigator.dnd.CommonDropAdapterDescriptor;
+import org.eclipse.ui.internal.navigator.dnd.CommonDropDescriptorManager;
+import org.eclipse.ui.internal.navigator.extensions.CommonDragAssistantDescriptor;
+import org.eclipse.ui.internal.navigator.extensions.NavigatorViewerDescriptor;
+import org.eclipse.ui.navigator.CommonDragAdapterAssistant;
+import org.eclipse.ui.navigator.CommonDropAdapter;
+import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
+import org.eclipse.ui.navigator.INavigatorContentService;
+import org.eclipse.ui.navigator.INavigatorDnDService;
+
+import eu.etaxonomy.taxeditor.navigation.navigator.dnd.TaxonNavigatorDragAdapterAssistant;
+
+public class TaxonNavigatorDnDService implements INavigatorDnDService {
+ private static final CommonDropAdapterAssistant[] NO_ASSISTANTS = new CommonDropAdapterAssistant[0];
+
+ private INavigatorContentService contentService;
+
+ private TaxonNavigatorDragAdapterAssistant[] dragAssistants;
+
+ private TreeNodeDropAdapter dropAdapter;
+
+ private final Map dropAssistants = new HashMap();
+
+ public TaxonNavigatorDnDService(INavigatorContentService contentService){
+ this.contentService = contentService;
+ }
+
+
+ @Override
+ public CommonDragAdapterAssistant[] getCommonDragAssistants() {
+
+ return dragAssistants;
+ }
+
+ @Override
+ public void bindDragAssistant(CommonDragAdapterAssistant anAssistant) {
+ if(dragAssistants == null)
+ initializeDragAssistants();
+ TaxonNavigatorDragAdapterAssistant[] newDragAssistants = new TaxonNavigatorDragAdapterAssistant[dragAssistants.length + 1];
+ System.arraycopy(dragAssistants, 0, newDragAssistants, 0, dragAssistants.length);
+ newDragAssistants[dragAssistants.length] = (TaxonNavigatorDragAdapterAssistant) anAssistant;
+ dragAssistants = newDragAssistants;
+
+ }
+
+ private void initializeDragAssistants() {
+ int i = 0;
+ Set dragDescriptors = ((NavigatorViewerDescriptor) contentService
+ .getViewerDescriptor()).getDragAssistants();
+ dragAssistants = new TaxonNavigatorDragAdapterAssistant[dragDescriptors
+ .size()];
+ for (Iterator iter = dragDescriptors.iterator(); iter.hasNext();) {
+ CommonDragAssistantDescriptor descriptor = (CommonDragAssistantDescriptor) iter
+ .next();
+ dragAssistants[i++] = (TaxonNavigatorDragAdapterAssistant) descriptor.createDragAssistant();
+ }
+ }
+
+ @Override
+ public CommonDropAdapterAssistant[] findCommonDropAdapterAssistants(
+ Object aDropTarget, TransferData aTransferType) {
+ CommonDropAdapterDescriptor[] descriptors = CommonDropDescriptorManager
+ .getInstance().findCommonDropAdapterAssistants(aDropTarget,
+ contentService);
+
+ if (descriptors.length == 0) {
+ return NO_ASSISTANTS;
+ }
+
+ if (LocalSelectionTransfer.getTransfer().isSupportedType(aTransferType)
+ && LocalSelectionTransfer.getTransfer().getSelection() instanceof IStructuredSelection) {
+ return getAssistantsBySelection(descriptors, (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection());
+ }
+ return getAssistantsByTransferData(descriptors, aTransferType);
+ }
+
+ private CommonDropAdapterAssistant[] getAssistantsByTransferData(
+ CommonDropAdapterDescriptor[] descriptors,
+ TransferData aTransferType) {
+
+ Set assistants = new LinkedHashSet();
+ for (int i = 0; i < descriptors.length; i++) {
+ CommonDropAdapterAssistant asst = getAssistant(descriptors[i]);
+ if (asst.isSupportedType(aTransferType)) {
+ assistants.add(asst);
+ }
+ }
+ return sortAssistants((CommonDropAdapterAssistant[]) assistants
+ .toArray(new CommonDropAdapterAssistant[assistants.size()]));
+
+ }
+
+ private CommonDropAdapterAssistant[] getAssistantsBySelection(
+ CommonDropAdapterDescriptor[] descriptors, IStructuredSelection aSelection) {
+
+ Set assistants = new LinkedHashSet();
+
+ for (int i = 0; i < descriptors.length; i++) {
+ if(descriptors[i].areDragElementsSupported(aSelection)) {
+ assistants.add(getAssistant(descriptors[i]));
+ }
+ }
+
+ return sortAssistants((CommonDropAdapterAssistant[]) assistants
+ .toArray(new CommonDropAdapterAssistant[assistants.size()]));
+ }
+
+ private CommonDropAdapterAssistant getAssistant(
+ CommonDropAdapterDescriptor descriptor) {
+ TreeNodeDropAdapterAssistant asst = (TreeNodeDropAdapterAssistant) dropAssistants
+ .get(descriptor);
+ if (asst != null) {
+ return asst;
+ }
+ synchronized (dropAssistants) {
+ asst = (TreeNodeDropAdapterAssistant) dropAssistants.get(descriptor);
+ if (asst == null) {
+ dropAssistants.put(descriptor, (asst = (TreeNodeDropAdapterAssistant) descriptor
+ .createDropAssistant()));
+ asst.init(contentService);
+ //asst.setCommonDropAdapter(dropAdapter);
+ }
+ }
+ return asst;
+ }
+
+
+ private CommonDropAdapterAssistant[] sortAssistants(CommonDropAdapterAssistant[] array) {
+ Arrays.sort(array, new Comparator() {
+ public int compare(Object arg0, Object arg1) {
+ CommonDropAdapterAssistant a = (CommonDropAdapterAssistant) arg0;
+ CommonDropAdapterAssistant b = (CommonDropAdapterAssistant) arg1;
+ // This is to ensure that the navigator resources drop assistant will
+ // always be first on the list of drop assistant, if a conflict ever
+ // occurs.
+ String id = "org.eclipse.ui.navigator.resources."; //$NON-NLS-1$
+ if (a.getClass().getName().startsWith(id))
+ return -1;
+ if (b.getClass().getName().startsWith(id))
+ return 1;
+ return a.getClass().getName().compareTo(b.getClass().getName());
+ }
+ });
+ return array;
+ }
+
+ @Override
+ public CommonDropAdapterAssistant[] findCommonDropAdapterAssistants(
+ Object aDropTarget, IStructuredSelection theDragSelection) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setDropAdaptor(TreeNodeDropAdapter da) {
+ dropAdapter = da;
+ }
+}
--- /dev/null
+package eu.etaxonomy.taxeditor.navigation.navigator;
+
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.internal.navigator.NavigatorContentService;
+import org.eclipse.ui.internal.navigator.dnd.NavigatorDnDService;
+import org.eclipse.ui.navigator.CommonDragAdapter;
+import org.eclipse.ui.navigator.CommonDropAdapter;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.INavigatorContentService;
+
+import eu.etaxonomy.taxeditor.dnd.transfer.TaxonNodeTransfer;
+
+public class TaxonNavigatorViewer extends CommonViewer {
+
+ private NavigatorContentService contentService;
+ String viewerId;
+
+ public TaxonNavigatorViewer(String aViewerId, Composite aParent, int aStyle) {
+ super(aViewerId, aParent, aStyle);
+ contentService = new TaxonNavigatorContentService(aViewerId, this);
+ viewerId = aViewerId;
+ }
+
+ @Override
+ protected void initDragAndDrop() {
+
+ int operations = DND.DROP_MOVE ;
+
+ CommonDragAdapter dragAdapter = createDragAdapter();
+ addDragSupport(operations, dragAdapter.getSupportedDragTransfers(),
+ dragAdapter);
+ Transfer[] transfers = new Transfer[] { TaxonNodeTransfer.getInstance() };
+ TreeNodeDropAdapter dropAdapter = createTreeNodeDropAdapter();
+ addDropSupport(operations, transfers, dropAdapter);
+
+ TaxonNavigatorDnDService dnd = (TaxonNavigatorDnDService)getNavigatorContentService().getDnDService();
+ dnd.setDropAdaptor(dropAdapter);
+ }
+
+
+ protected TreeNodeDropAdapter createTreeNodeDropAdapter() {
+ return new TreeNodeDropAdapter(this);
+ }
+
+ public NavigatorContentService getNavigatorContentService(){
+ if (contentService == null){
+ contentService = new TaxonNavigatorContentService(viewerId);
+ }
+ return contentService;
+ }
+
+}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2015 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.navigation.navigator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.dnd.DragSourceAdapter;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.ui.navigator.CommonViewer;
+
+
+import eu.etaxonomy.cdm.model.common.DefinedTermBase;
+import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.dnd.transfer.TaxonNodeTransfer;
+import eu.etaxonomy.taxeditor.editor.definedterm.TermTransfer;
+
+/**
+ * @author k.luther
+ * @date 02.06.2015
+ *
+ */
+public class TreeNodeDragListener extends DragSourceAdapter {
+ private CommonViewer viewer;
+
+ /**
+ *
+ */
+ public TreeNodeDragListener(CommonViewer viewer) {
+ this.viewer = viewer;
+ }
+
+
+ public void setViewer(CommonViewer viewer){
+ this.viewer = viewer;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.dnd.DragSourceAdapter#dragStart(org.eclipse.swt.dnd.DragSourceEvent)
+ */
+ @Override
+ public void dragStart(DragSourceEvent event) {
+
+ event.doit = true;// set to false if needed - default is true
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.dnd.DragSourceAdapter#dragFinished(org.eclipse.swt.dnd.DragSourceEvent)
+ */
+ @Override
+ public void dragFinished(DragSourceEvent event) {
+ // TODO Auto-generated method stub
+ super.dragFinished(event);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.dnd.DragSourceAdapter#dragSetData(org.eclipse.swt.dnd.DragSourceEvent)
+ */
+ @Override
+ public void dragSetData(DragSourceEvent event) {
+
+ IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+ List<ITaxonTreeNode> taxonNodes = new ArrayList<ITaxonTreeNode>();
+
+ for (Object object : selection.toList()){
+ taxonNodes.add((ITaxonTreeNode)object);
+ }
+
+ if (TaxonNodeTransfer.getInstance().isSupportedType(
+ event.dataType)) {
+ event.data = taxonNodes.toArray(new TaxonNode[taxonNodes.size()]);
+ }
+ }
+}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2015 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.navigation.navigator;
+
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IconAndMessageDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerDropAdapter;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.navigator.CommonDropAdapter;
+import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
+import org.eclipse.ui.navigator.CommonViewer;
+
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.common.OrderedTermBase;
+import eu.etaxonomy.cdm.model.common.TermBase;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
+import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor;
+import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
+import eu.etaxonomy.taxeditor.navigation.navigator.operation.MoveTaxonOperation;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * <p>TreeNodeDropAdapter class.</p>
+ *
+ * @author k.luther
+ * @date 02.06.2015
+ * @version 1.0
+ */
+public class TreeNodeDropAdapter extends ViewerDropAdapter implements IPostOperationEnabled {
+
+ /**
+ * @param viewer
+ */
+ protected TreeNodeDropAdapter(TaxonNavigatorViewer navigatorViewer) {
+ super(navigatorViewer);
+ this.navigatorViewer = navigatorViewer;
+
+ }
+
+ private final TaxonNavigatorViewer navigatorViewer;
+ private static final Logger logger = Logger.getLogger(TreeNodeDropAdapter.class);
+
+ /** Constant <code>ID="eu.etaxonomy.taxeditor.navigation.navig"{trunked}</code> */
+ public static final String ID = "eu.etaxonomy.taxeditor.navigation.navigator.dropassistant"; //$NON-NLS-1$
+
+ private static final EnumSet<CRUD> UPDATE = EnumSet.of(CRUD.UPDATE);
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#handleDrop(org.eclipse.ui.navigator.CommonDropAdapter, org.eclipse.swt.dnd.DropTargetEvent, java.lang.Object)
+ */
+ /** {@inheritDoc} */
+ @Override
+ public boolean performDrop(Object target) {
+
+
+ if (target instanceof ITaxonTreeNode) {
+ Set<TaxonNode> taxonNodes = getSelectedTaxa();
+ ITaxonTreeNode targetTreeNode = (ITaxonTreeNode) target;
+ if (targetTreeNode instanceof Classification){
+ targetTreeNode = ((Classification)targetTreeNode).getRootNode();
+ targetTreeNode = HibernateProxyHelper.deproxy(targetTreeNode, TaxonNode.class);
+ }
+ if(taxonNodes != null) {
+ if (taxonNodes.size() == 1){
+ return moveTaxon(taxonNodes.iterator().next(), targetTreeNode);
+ } else{
+ if( MessageDialog.openConfirm(null, "Moving taxon", "The operation move accepted taxon to other parent is available only for a single taxon.")){
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private Set<TaxonNode> getSelectedTaxa(){
+ HashSet<TaxonNode> taxonNodes = new HashSet<TaxonNode>();
+
+ ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
+ if (selection instanceof TreeSelection) {
+
+ Iterator selectionIterator = ((TreeSelection) selection).iterator();
+
+ while (selectionIterator.hasNext()){
+ Object object = selectionIterator.next();
+ if(object instanceof TaxonNode){
+ TaxonNode taxonNode = (TaxonNode) object;
+ taxonNodes.add(taxonNode);
+ }
+ }
+ }
+ return taxonNodes.size() > 0 ? taxonNodes : null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonDropAdapter#validateDrop(java.lang.Object, int, org.eclipse.swt.dnd.TransferData)
+ */
+ /** {@inheritDoc} */
+ @Override
+ public boolean validateDrop(Object target, int operation,
+ TransferData transferType) {
+
+ if (target instanceof ITaxonTreeNode) {
+
+ // check users permissions with target taxonnode and taxon
+ if (target instanceof TaxonNode) {
+ TaxonNode targetNode = (TaxonNode)target;
+ Boolean hasTargetNodePermission = CdmStore.currentAuthentiationHasPermission(targetNode, UPDATE);
+ Boolean hasTargetTaxonPermission = CdmStore.currentAuthentiationHasPermission(targetNode.getTaxon(), UPDATE);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("target: " + targetNode.getTaxon().getTitleCache());
+ }
+
+ if(!hasTargetNodePermission || ! hasTargetNodePermission){
+ if(logger.isDebugEnabled()){
+ logger.debug("CANCEL_STATUS for target node: " + hasTargetNodePermission.toString() + " " + hasTargetTaxonPermission.toString() + " ");
+ }
+ return false;
+ }
+ }
+
+ // do not allow to drop onto itself and
+ // check users permissions with all selected taxon nodes and taxa
+ for(TaxonNode taxonNode : getSelectedTaxa()){
+ logger.debug("selectedTaxa: " + taxonNode.getTaxon().getTitleCache());
+ Boolean isSameTaxonNode = taxonNode.equals(target);
+ Boolean hasTaxonNodePermission = CdmStore.currentAuthentiationHasPermission(taxonNode, UPDATE);
+ Boolean hasTaxonPermission = CdmStore.currentAuthentiationHasPermission(taxonNode.getTaxon(), UPDATE);
+ if (
+ isSameTaxonNode
+ || !hasTaxonNodePermission
+ || !hasTaxonPermission
+ ) {
+ if(logger.isDebugEnabled()){
+ logger.debug("CANCEL_STATUS for selected " + isSameTaxonNode.toString() + " " + hasTaxonNodePermission.toString() + " " + hasTaxonPermission.toString() + " ");
+ }
+ return false;
+ }
+ }
+ logger.debug("OK_STATUS");
+ return true;
+ }
+ logger.debug("CANCEL_STATUS");
+ return false;
+ }
+
+
+ /**
+ * @param childTaxonNode
+ * @param parentTaxon
+ * @return
+ */
+ private boolean moveTaxon(TaxonNode taxonNode, ITaxonTreeNode targetITaxonTreeNode) {
+
+ TaxonNavigator taxonNavigator;
+ taxonNavigator = (TaxonNavigator) NavigationUtil.showView(TaxonNavigator.ID);
+
+ if(targetITaxonTreeNode instanceof TaxonNode){
+
+ TaxonNode targetTaxonNode = (TaxonNode) targetITaxonTreeNode;
+ // Make sure parent taxon does not have unsaved changes
+ if (NavigationUtil.isDirty(targetTaxonNode)){
+ MessageDialog.openWarning(NavigationUtil.getShell(), "Unsaved Parent Taxon", "There are unsaved " +
+ "changes in the parent taxon. Pleas save first.");
+ return false;
+ }
+
+ }
+ if (!PreferencesUtil.getSortNodesNaturally()){
+ IUndoContext workspaceUndoContext = NavigationUtil.getWorkbenchUndoContext();
+ if (workspaceUndoContext == null) {
+ logger.error("Workspace undo context is null. DND operation cancelled");
+ return false;
+ }
+
+ AbstractPostOperation operation = new MoveTaxonOperation
+ ("Move Taxon", workspaceUndoContext, taxonNode, targetITaxonTreeNode, this, taxonNavigator, true);
+ NavigationUtil.executeOperation(operation);
+
+ logger.info("Moved taxa to new parent " + targetITaxonTreeNode);
+ return true;
+ }else{
+ String[] buttonLables = {"Parent", "Predecessor", "Cancel"};
+ MessageDialog dialog = new MessageDialog(null, "Target node", null, "Do you want to use the target node as parent or do you want to move the taxon below the target.", MessageDialog.QUESTION_WITH_CANCEL, buttonLables, 0);
+ dialog.open();
+ int returnCode = dialog.getReturnCode();
+ if (returnCode == 0){
+ IUndoContext workspaceUndoContext = NavigationUtil.getWorkbenchUndoContext();
+ if (workspaceUndoContext == null) {
+ logger.error("Workspace undo context is null. DND operation cancelled");
+ return false;
+ }
+
+ AbstractPostOperation operation = new MoveTaxonOperation
+ ("Move Taxon", workspaceUndoContext, taxonNode, targetITaxonTreeNode, this, taxonNavigator, true);
+ NavigationUtil.executeOperation(operation);
+
+ logger.info("Moved taxa to new parent " + targetITaxonTreeNode);
+ return true;
+ }else if (returnCode == 1){
+ IUndoContext workspaceUndoContext = NavigationUtil.getWorkbenchUndoContext();
+ if (workspaceUndoContext == null) {
+ logger.error("Workspace undo context is null. DND operation cancelled");
+ return false;
+ }
+
+ AbstractPostOperation operation = new MoveTaxonOperation
+ ("Move Taxon", workspaceUndoContext, taxonNode, targetITaxonTreeNode, this, taxonNavigator, false);
+ NavigationUtil.executeOperation(operation);
+
+ logger.info("Moved taxa to new parent " + targetITaxonTreeNode);
+ return true;
+ } else{
+ return false;
+ }
+
+
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
+ */
+ /** {@inheritDoc} */
+ @Override
+ public boolean postOperation(CdmBase objectAffectedByOperation) {
+ return true;
+ }
+
+ /**
+ * <p>onComplete</p>
+ *
+ * @return a boolean.
+ */
+ @Override
+ public boolean onComplete() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+ @Override
+ public void dragOver(DropTargetEvent event) {
+ super.dragOver(event);
+ event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_INSERT_AFTER;
+
+ }
+
+}
ITaxonTreeNode treeNode = treeNodes.iterator().next();
ITaxonTreeNode taxonNode =treeNode;
TaxonNodeDeletionConfigurator configNodes = new TaxonNodeDeletionConfigurator();
+ //configNodes.setDeleteTaxon(false);
if (taxonNode instanceof Classification && taxonNode.hasChildNodes()){
if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification? The tree has children, they will be deleted, too.")){
return null;
}
}else{
- if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected node?")){
+ if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(configNodes, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected node?")){
return null;
- }
+ }
+ config.setTaxonNodeConfig(configNodes);
}
}
name="org.eclipse.ui.views.showView.viewId"
value="eu.etaxonomy.taxeditor.view.derivateSearch.DerivateSearchView">
</parameter>
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
<separator
name="eu.etaxonomy.taxeditor.store.showViewMenu.details"
name="org.eclipse.ui.views.showView.viewId"
value="eu.etaxonomy.taxeditor.view.detail">
</parameter>
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
<command
commandId="org.eclipse.ui.views.showView"
name="org.eclipse.ui.views.showView.viewId"
value="eu.etaxonomy.taxeditor.view.supplementalData">
</parameter>
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
<!-- Originally used by validation framework, currently not in use -->
<!-- <command
</parameter>
<visibleWhen
checkEnabled="true">
- <and>
- <reference
- definitionId="isShowExperimentalFeatures">
- </reference>
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </and>
+ <reference
+ definitionId="isShowExperimentalFeatures">
+ </reference>
</visibleWhen>
</command>
</menu>
</menuContribution>
+ <menuContribution
+ class="eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermMenuFactory"
+ locationURI="menu:org.eclipse.ui.main.menu.window?before=eu.etaxonomy.taxeditor.application.windowMenu.last">
+ </menuContribution>
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu.file?after=eu.etaxonomy.taxeditor.application.filemenu.io">
<command
commandId="eu.etaxonomy.taxeditor.store.operations.showLoginWindow"
label="%command.label.5"
style="push">
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
</command>
<separator
name="eu.etaxonomy.taxeditor.application.filemenu.login"
</visibleWhen>
</command>
</menuContribution>
- <menuContribution
- allPopups="false"
- locationURI="menu:org.eclipse.ui.main.menu.window?before=eu.etaxonomy.taxeditor.application.windowMenu.last">
- <dynamic
- class="eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermMenu"
- id="eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermMenu">
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
- </dynamic>
- </menuContribution>
</extension>
<extension
point="org.eclipse.ui.handlers">
</annotation>
<complexType>
<sequence>
- <element ref="cdmViewer" minOccurs="0" maxOccurs="unbounded"/>
- <element ref="viewCommandMapping" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="cdmViewer" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
</complexType>
</element>
- <element name="viewCommandMapping">
- <annotation>
- <documentation>
- Maps a viewing class, like editors or views, to a command which opens it.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="commandId" type="string" use="required">
- <annotation>
- <documentation>
- The command which opens the viewer to show the selected object
- </documentation>
- <appInfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.ui.commands/command/@id"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="viewerName" type="string">
- <annotation>
- <documentation>
- The name of the viewer which shows the selected element
- </documentation>
- </annotation>
- </attribute>
- <attribute name="selection" type="string" use="required">
- <annotation>
- <documentation>
- The class of the selected element
- </documentation>
- <appInfo>
- <meta.attribute kind="java"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
<annotation>
<appInfo>
<meta.section type="since"/>
+++ /dev/null
-// $Id$
-/**
-* Copyright (C) 2009 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.editor.definedterm;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.swt.SWT;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.CompoundContributionItem;
-import org.eclipse.ui.menus.CommandContributionItem;
-import org.eclipse.ui.menus.CommandContributionItemParameter;
-
-import eu.etaxonomy.cdm.model.common.TermType;
-
-/**
- * Menu used in the store plugin xml to dynamically generate menu (sub-menu) contribution items
- * for term types which when clicked open the defined term editor for the chosen term type
- *
- * @author pplitzner
- * @date 21 Jul 2015
- *
- */
-
-public class DefinedTermMenu extends CompoundContributionItem {
-
-
- @Override
- protected IContributionItem[] getContributionItems() {
- Collection<IContributionItem> items = new ArrayList<IContributionItem>();
- MenuManager dtMenuManager =
- new MenuManager("Term Editor","eu.etaxonomy.taxeditor.store.definedTermEditorMenu");
-
- dtMenuManager.setVisible(true);
-
- items.add(dtMenuManager);
- List<TermType> ttList = new ArrayList<TermType>(EnumSet.allOf(TermType.class));
- Collections.sort(ttList,new SortByTermTypeMessage());
- for (TermType tt : ttList)
- {
- // if term type has a parent, do not add it
- // it will be added in the recursive call
- if(tt.getKindOf() == null) {
- IContributionItem ici = addChildTermsToMenuManager(tt);
- if(ici != null) {
- dtMenuManager.add(ici);
- }
- }
- }
- return items.toArray(new IContributionItem[]{});
- }
-
- private IContributionItem addChildTermsToMenuManager(TermType termType) {
-
- //FIXME : need a better way to find out if a term type can be editable (ticket 3853)
- if(termType.getEmptyDefinedTermBase() != null) {
- Set<TermType> children = termType.getGeneralizationOf();
- // term type has no children, so create menu item
- if(children.isEmpty()) {
- return createMenuItem(termType);
- }
- // term type has children, so create sub menu
- MenuManager dtMenuManager =
- new MenuManager(termType.getMessage(),"eu.etaxonomy.taxeditor.store." + termType.getKey() + "Menu");
- dtMenuManager.setVisible(true);
- dtMenuManager.add(createDefaultMenuItem(termType));
-
- Separator sep = new Separator();
- dtMenuManager.add(sep);
- // add child items to the sub menu
- for(TermType tt : children) {
- IContributionItem item = addChildTermsToMenuManager(tt);
- if(item != null) {
- dtMenuManager.add(item);
- }
- }
- return dtMenuManager;
- } else {
- return null;
- }
-
- }
-
- private CommandContributionItem createMenuItem(TermType termType) {
-
- Map<String, String> params = new HashMap<String, String>();
- params.put("eu.etaxonomy.taxeditor.store.openDefinedTermEditor.termTypeUuid",
- termType.getUuid().toString());
-
- CommandContributionItemParameter p = new CommandContributionItemParameter(
- PlatformUI.getWorkbench(),
- "",
- "eu.etaxonomy.taxeditor.store.openDefinedTermEditor",
- params,
- null,
- null,
- null,
- termType.getMessage(),
- "",
- "",
- SWT.PUSH,
- "",
- true);
-
- CommandContributionItem item = new CommandContributionItem(p);
- return item;
-
- }
-
- private CommandContributionItem createDefaultMenuItem(TermType termType) {
-
- Map<String, String> params = new HashMap<String, String>();
- params.put("eu.etaxonomy.taxeditor.store.openDefinedTermEditor.termTypeUuid",
- termType.getUuid().toString());
-
- CommandContributionItemParameter p = new CommandContributionItemParameter(
- PlatformUI.getWorkbench(),
- "",
- "eu.etaxonomy.taxeditor.store.openDefinedTermEditor",
- params,
- null,
- null,
- null,
- "Other " + termType.getMessage() + "s",
- "",
- "",
- SWT.PUSH,
- "",
- true);
-
-
-
- CommandContributionItem item = new CommandContributionItem(p);
- return item;
-
- }
-
- private class SortByTermTypeMessage implements Comparator<TermType> {
- @Override
- public int compare(TermType t1, TermType t2) {
- return t1.getMessage().compareTo(t2.getMessage());
- }
- }
-
-
-}
// $Id$
/**
* Copyright (C) 2009 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.
*/
/**
* Menu factory used in the store plugin xml to dynamically generate menu (sub-menu) contribution items
* for term types which when clicked open the defined term editor for the chosen term type
- *
+ *
* @author c.mathew
* @date 18 Jul 2013
*
*/
-public class DefinedTermMenuFactory extends ExtensionContributionFactory {
-
+public class DefinedTermMenuFactory extends ExtensionContributionFactory {
+
@Override
public void createContributionItems(IServiceLocator serviceLocator,
- IContributionRoot additions) {
- MenuManager dtMenuManager =
- new MenuManager("Term Editor","eu.etaxonomy.taxeditor.store.definedTermEditorMenu");
-
- dtMenuManager.setVisible(true);
-
- additions.addContributionItem(dtMenuManager, null);
- List<TermType> ttList = new ArrayList<TermType>(EnumSet.allOf(TermType.class));
- Collections.sort(ttList,new SortByTermTypeMessage());
- for (TermType tt : ttList)
- {
- // if term type has a parent, do not add it
- // it will be added in the recursive call
- if(tt.getKindOf() == null) {
- IContributionItem ici = addChildTermsToMenuManager(tt, serviceLocator);
- if(ici != null) {
- dtMenuManager.add(ici);
- }
- }
- }
+ IContributionRoot additions) {
+
+ MenuManager dtMenuManager =
+ new MenuManager("Term Editor","eu.etaxonomy.taxeditor.store.definedTermEditorMenu");
+
+ dtMenuManager.setVisible(true);
+
+ additions.addContributionItem(dtMenuManager, null);
+ List<TermType> ttList = new ArrayList<TermType>(EnumSet.allOf(TermType.class));
+ Collections.sort(ttList,new SortByTermTypeMessage());
+ for (TermType tt : ttList)
+ {
+ // if term type has a parent, do not add it
+ // it will be added in the recursive call
+ if(tt.getKindOf() == null) {
+ IContributionItem ici = addChildTermsToMenuManager(tt, serviceLocator);
+ if(ici != null) {
+ dtMenuManager.add(ici);
+ }
+ }
+ }
}
-
+
private IContributionItem addChildTermsToMenuManager(TermType termType, IServiceLocator serviceLocator) {
-
+
//FIXME : need a better way to find out if a term type can be editable (ticket 3853)
if(termType.getEmptyDefinedTermBase() != null) {
Set<TermType> children = termType.getGeneralizationOf();
// term type has no children, so create menu item
- if(children.isEmpty()) {
+ if(children.isEmpty()) {
return createMenuItem(termType, serviceLocator);
}
- // term type has children, so create sub menu
- MenuManager dtMenuManager =
- new MenuManager(termType.getMessage(),"eu.etaxonomy.taxeditor.store." + termType.getKey() + "Menu");
+ // term type has children, so create sub menu
+ MenuManager dtMenuManager =
+ new MenuManager(termType.getMessage(),"eu.etaxonomy.taxeditor.store." + termType.getKey() + "Menu");
dtMenuManager.setVisible(true);
dtMenuManager.add(createDefaultMenuItem(termType, serviceLocator));
Separator sep = new Separator();
dtMenuManager.add(sep);
// add child items to the sub menu
- for(TermType tt : children) {
+ for(TermType tt : children) {
IContributionItem item = addChildTermsToMenuManager(tt,serviceLocator);
- if(item != null) {
+ if(item != null) {
dtMenuManager.add(item);
- }
- }
+ }
+ }
return dtMenuManager;
} else {
return null;
}
-
+
}
-
+
private CommandContributionItem createMenuItem(TermType termType, IServiceLocator serviceLocator) {
-
+
Map<String, String> params = new HashMap<String, String>();
params.put("eu.etaxonomy.taxeditor.store.openDefinedTermEditor.termTypeUuid",
- termType.getUuid().toString());
-
+ termType.getUuid().toString());
+
CommandContributionItemParameter p = new CommandContributionItemParameter(
- serviceLocator,
+ serviceLocator,
"",
"eu.etaxonomy.taxeditor.store.openDefinedTermEditor",
params,
null,
termType.getMessage(),
"",
- "",
+ "",
SWT.PUSH,
"",
true);
-
- CommandContributionItem item = new CommandContributionItem(p);
+
+ CommandContributionItem item = new CommandContributionItem(p);
return item;
-
+
}
-
+
private CommandContributionItem createDefaultMenuItem(TermType termType, IServiceLocator serviceLocator) {
-
+
Map<String, String> params = new HashMap<String, String>();
params.put("eu.etaxonomy.taxeditor.store.openDefinedTermEditor.termTypeUuid",
- termType.getUuid().toString());
-
+ termType.getUuid().toString());
+
CommandContributionItemParameter p = new CommandContributionItemParameter(
- serviceLocator,
+ serviceLocator,
"",
"eu.etaxonomy.taxeditor.store.openDefinedTermEditor",
params,
null,
"Other " + termType.getMessage() + "s",
"",
- "",
+ "",
SWT.PUSH,
"",
true);
-
-
-
- CommandContributionItem item = new CommandContributionItem(p);
+
+
+
+ CommandContributionItem item = new CommandContributionItem(p);
return item;
-
+
}
-
+
private class SortByTermTypeMessage implements Comparator<TermType> {
- @Override
- public int compare(TermType t1, TermType t2) {
+ public int compare(TermType t1, TermType t2) {
return t1.getMessage().compareTo(t2.getMessage());
}
}
-
+
}
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator;
import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;
+import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
/**
* Abstract subclass of MessageDialog providing the functionality to configure
}
else if(configurator instanceof SpecimenDeleteConfigurator){
composite.addConfiguratorComposite(new DeleteSpecimenConfiguratorComposite((SpecimenDeleteConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
+ } else if(configurator instanceof TaxonNodeDeletionConfigurator){
+ composite.addConfiguratorComposite(new DeleteNodeConfiguratorComposite((TaxonNodeDeletionConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
}
+
return composite;
}
--- /dev/null
+package eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator;
+/**
+* Copyright (C) 2015 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.
+*/
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.beans.PojoProperties;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.layout.RowLayout;
+
+import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
+import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
+/**
+ * @author kluther
+ * @date Jul 13, 2015
+ *
+ */
+public class DeleteNodeConfiguratorComposite extends Composite {
+ // $Id$
+
+ private final DataBindingContext m_bindingContext;
+
+ private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
+ private final TaxonNodeDeletionConfigurator configurator;
+ private final Button btnDeleteTaxon;
+
+
+ /**
+ * Create the composite.
+ * @param parent
+ * @param style
+ */
+ public DeleteNodeConfiguratorComposite(TaxonNodeDeletionConfigurator configurator, Composite parent, int style) {
+ super(parent, style);
+ this.configurator = configurator;
+ addDisposeListener(new DisposeListener() {
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ toolkit.dispose();
+ }
+ });
+ toolkit.paintBordersFor(this);
+ setLayout(new RowLayout(SWT.VERTICAL));
+ setBackground(getBackground());
+
+ btnDeleteTaxon = new Button(this, SWT.CHECK);
+ btnDeleteTaxon.setText("Delete taxon if possible");
+
+ m_bindingContext = initDataBindings();
+
+ }
+
+ protected DataBindingContext initDataBindings() {
+ DataBindingContext bindingContext = new DataBindingContext();
+ //
+ IObservableValue observeSelectionBtnDeleteTaxonObserveWidget = WidgetProperties.selection().observe(btnDeleteTaxon);
+ IObservableValue deleteTaxonIfPossibleConfiguratorObserveValue = PojoProperties.value("deleteTaxon").observe(configurator);
+ bindingContext.bindValue(observeSelectionBtnDeleteTaxonObserveWidget, deleteTaxonIfPossibleConfiguratorObserveValue, null, null);
+ //
+ return bindingContext;
+ }
+ }
+
+
import java.net.URI;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
/**
public URI getUri(){
try {
- labelException.setBackground(getPersistentBackground());
labelException.setText("");
return new URI(super.getText());
} catch (Exception e) {
- labelException.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
labelException.setText(e.getMessage());
return null;
}
getTaxonDescriptions(),
false,
false,
+
null,
presenceAbsenceTermColors,
languages);
element_statement = formFactory.createKeyStatementElement(formElement,
"State(ment)", entity.getStatement(), 50, style);
- //if (entity.isLeaf()) {
+ if (entity.isLeaf()) {
selection_taxon = formFactory
.createSelectionElement(Taxon.class,
getConversationHolder(), formElement, "Taxon",
entity.getTaxon(), EntitySelectionElement.NOTHING,
style);
- //}
+ } else{
+ selection_taxon = formFactory
+ .createSelectionElement(Taxon.class,
+ getConversationHolder(), formElement, "Taxon",
+ entity.getTaxon(), EntitySelectionElement.DELETABLE,
+ style);
+ }
selection_subkey = formFactory
.createSelectionElement(PolytomousKey.class,
try {
URI uri = text_uri.getUri();
getEntity().setUri(uri);
- if(uri==null){
- //buffer URI if parsing error occurred
- MediaDetailElement parentMediaDetailElement = getParentMediaDetailElement();
- if(parentMediaDetailElement!=null){
- parentMediaDetailElement.setUriBuffer(text_uri.getText());
- }
- }
+
loadImage(getEntity().getUri(), true);
*/
package eu.etaxonomy.taxeditor.ui.section.media;
-import java.net.URI;
import java.util.List;
import java.util.Set;
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
import eu.etaxonomy.cdm.model.media.MediaUtils;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
private ICdmFormElement parentFormElement;
private int style;
- /**
- * Used to store the URI even if it is invalid and thus cannot be stored in CDM
- */
- private String uriBuffer;
-
public MediaDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) {
super(formFactory, formElement);
}
public void handleEvent(Object eventSource){
if(eventSource==textUri){
textUri.setBackground(getPersistentBackground());
- URI uri = textUri.getUri();
- singleMediaRepresentationPart.setUri(uri);
- if(uri==null){
- uriBuffer=textUri.getText();
- }
+ singleMediaRepresentationPart.setUri(textUri.getUri());
}
}
- public void toggleAdvancedMediaView() {
- if (getEntity().getRepresentations() != null
- && (getEntity().getRepresentations().size() > 1 ||
- (getEntity().getRepresentations().size() == 1
- && getEntity().getRepresentations().iterator().next().getParts().size() > 1))) {
- MessagingUtils.informationDialog("Toggling not possible",
- "Media has consists of multiple representations or representatio parts");
- // toggling is only possible if there are no more than one
- // MediaRepresentation resp. MediaRepresentationParts
- return;
- }
+ public void toggleAdvancedMediaView(){
isAdvancedMediaView = !isAdvancedMediaView;
showAdvancedView();
reflowParentScrolledForm(true);
section_mediaRepresentation = formFactory.createMediaRepresentationSection(getConversationHolder(), parentFormElement, style);
section_mediaRepresentation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
section_mediaRepresentation.setEntity(getEntity());
- //set buffered uri as text if uri had parsing problems in simple view
- if(uriBuffer!=null){
- section_mediaRepresentation.getLayoutComposite().getChildren();
- }
}
else{
if(section_mediaRepresentation!=null){
removeElementsAndControls(section_mediaRepresentation);
}
textUri = formFactory.createUriWithLabelElement(parentFormElement, "Media URI", null, style);
- URI uri = singleMediaRepresentationPart.getUri();
- textUri.setUri(uri);
- //set buffered uri as text if uri had parsing problems in advanced view
- if(uri==null && uriBuffer!=null){
- textUri.setText(uriBuffer);
- textUri.getUri();
- }
+ textUri.setUri(singleMediaRepresentationPart.getUri());
textUri.getLayoutComposite().layout();
}
}
return isAdvancedMediaView;
}
- public void setUriBuffer(String uriBuffer) {
- this.uriBuffer = uriBuffer;
- }
-
- public String getUriBuffer() {
- return uriBuffer;
- }
-
}
text_size.setText(FileUtils.byteCountToDisplaySize(entity.getSize()));
}
if(entity.getUri() != null){
- text_uri.setUri(entity.getUri());
- } else {
- String uriBuffer = getParentMediaDetailElement().getUriBuffer();
- if(uriBuffer!=null){
- text_uri.setText(uriBuffer);
- text_uri.getUri();//just to update the error label
- }
- }
+ text_uri.setText(entity.getUri().toString());
+ }
}
@Override
if(eventSource == text_uri){
URI uri = text_uri.getUri();
getEntity().setUri(uri);
- if(uri==null){
- //buffer URI if parsing error occurred
- MediaDetailElement parentMediaDetailElement = getParentMediaDetailElement();
- if(parentMediaDetailElement!=null){
- parentMediaDetailElement.setUriBuffer(text_uri.getText());
- }
- }
-
firePropertyChangeEvent(this);
}
}
- protected MediaDetailElement getParentMediaDetailElement() {
- ICdmFormElement parentElement = getParentElement();
- while(parentElement!=null){
- parentElement = parentElement.getParentElement();
- if(parentElement instanceof MediaDetailElement){
- return (MediaDetailElement) parentElement;
- }
- }
- return null;
- }
-
}
import java.util.Map;
import java.util.Map.Entry;
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.jface.action.ContributionItem;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.CompoundContributionItem;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.IHandlerService;
-
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
/**
* Generic context menu for opening elements in the taxeditor.
new ContributionItem() {
@Override
public void fill(Menu menu, int index) {
- final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- final ISelection selection = window.getActivePage().getSelection();
-
MenuItem addItem = new MenuItem(menu, SWT.CASCADE);
addItem.setText("Open in...");
Menu addMenu = new Menu(menu);
addItem.setMenu(addMenu);
+ final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ final ISelection selection = window.getActivePage().getSelection();
if(selection instanceof IStructuredSelection){
Object firstElement = ((IStructuredSelection) selection).getFirstElement();
- Map<String, String> availableViewers = CdmViewerUtil.getAvailableViewers(firstElement);
- for(Entry<String, String> entry:availableViewers.entrySet()){
- final String commandId = entry.getKey();
- String viewerName = entry.getValue();
+ Map<Entry<Class<?>, String>, ICdmViewer> nameViewerMap = CdmViewerUtil.getNameViewerMap(firstElement);
+ for(Entry<Entry<Class<?>, String>, ICdmViewer> entry:nameViewerMap.entrySet()){
+ Entry<Class<?>, String> viewerClass = entry.getKey();
MenuItem menuItem = new MenuItem(addMenu, SWT.NONE);
- menuItem.setText(viewerName);
- menuItem.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
-
- Command command = commandService.getCommand(commandId);
- if(command.isEnabled()) {
- IHandlerService handlerService = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class);
- try {
- handlerService.executeCommand(commandId, null);
- } catch (NotDefinedException nde) {
- throw new RuntimeException("Could not find open command: " + commandId);
- } catch (Exception exception) {
- MessagingUtils.error(getClass(), "An exception occured while trying execute "+commandId, exception);
- }
- }
- }
- }) ;
+ menuItem.setText(viewerClass.getValue());
+ menuItem.addSelectionListener(new OpenInViewerListener(entry.getValue(), firstElement, viewerClass.getKey()));
}
}
}
public static Map<Entry<Class<?>, String>, ICdmViewer> getNameViewerMap(Object input){
Map<Entry<Class<?>, String>, ICdmViewer> nameViewerMap = new HashMap<Entry<Class<?>, String>, ICdmViewer>();
-
+
IExtensionRegistry reg = Platform.getExtensionRegistry();
IConfigurationElement[] extensions = reg
.getConfigurationElementsFor("eu.etaxonomy.taxeditor.store.cdmViewer");
return nameViewerMap;
}
- public static Map<String, String> getAvailableViewers(Object input){
- Map<String, String> commandViewerNameMap = new HashMap<String, String>();
-
- if(input!=null){
- IExtensionRegistry reg = Platform.getExtensionRegistry();
- IConfigurationElement[] extensions = reg
- .getConfigurationElementsFor("eu.etaxonomy.taxeditor.store.cdmViewer");
- for (IConfigurationElement configElement : extensions) {
- if(configElement.getName().equals("viewCommandMapping")){
- String commandId = configElement.getAttribute("commandId");
- String viewerName = configElement.getAttribute("viewerName");
- try {
- Object selectionObject = configElement.createExecutableExtension("selection");
- Class<? extends Object> selectionClass = selectionObject.getClass();
- if(input.getClass().isAssignableFrom(selectionClass)){
- commandViewerNameMap.put(commandId, viewerName);
- }
- } catch (CoreException e) {
- MessagingUtils.error(CdmViewerChooser.class, "Could not initalize selection class element of cdmViewer extension", e);
- }
- }
- }
- }
- return commandViewerNameMap;
- }
-
}
<java.codelevel>1.6</java.codelevel>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cdmlib.version>3.8.0-SNAPSHOT</cdmlib.version>
+ <!-- TODO can we use project.version ????? -->
<tycho.version>0.22.0</tycho.version>
<taxeditor.version>3.8.0-SNAPSHOT</taxeditor.version>
<update.dir>snapshot</update.dir>
<module>eu.etaxonomy.taxeditor.bulkeditor</module>
<module>eu.etaxonomy.taxeditor.printpublisher</module>
<module>eu.etaxonomy.taxeditor.help</module>
+ <module>eu.etaxonomy.taxeditor.molecular</module>
+ <module>eu.etaxonomy.taxeditor.molecular.lib</module>
<module>eu.etaxonomy.taxeditor.application</module>
<module>eu.etaxonomy.taxeditor.feature.platform</module>
<module>eu.etaxonomy.taxeditor.feature</module>
- <module>eu.etaxonomy.taxeditor.molecular</module>
- <module>eu.etaxonomy.taxeditor.molecular.lib</module>
<module>eu.etaxonomy.taxeditor</module>
</modules>
<scm>