From e29e2ebd44f2bfea3e0a54fa79ad3ed432d7b98e Mon Sep 17 00:00:00 2001 From: Katja Luther Date: Fri, 14 Oct 2016 12:05:22 +0200 Subject: [PATCH] smaller changes for specimen import and others --- .../model/DeleteResultMessagingUtils.java | 32 ++++++++++ .../ChecklistEditorGeneralPreference.java | 6 +- .../DeleteTaxonBaseConfiguratorComposite.java | 2 +- .../ui/section/media/MediaMetaElement.java | 9 +++ .../ui/section/name/NameDetailElement.java | 2 +- .../view/dataimport/DataImportView.java | 64 ++++++++++++++++++- .../SaveImportedSpecimenAction.java | 11 +++- .../view/dataimport/SpecimenImportView.java | 2 + .../view/dataimport/SpecimenSearchWizard.java | 1 + 9 files changed, 120 insertions(+), 9 deletions(-) diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DeleteResultMessagingUtils.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DeleteResultMessagingUtils.java index 55854c6bf..66874f128 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DeleteResultMessagingUtils.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DeleteResultMessagingUtils.java @@ -14,6 +14,7 @@ import java.util.Iterator; import java.util.List; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.Status; import eu.etaxonomy.cdm.api.service.DeleteResult; @@ -80,4 +81,35 @@ public class DeleteResultMessagingUtils extends MessagingUtils { } + + public static void messageDialogWithDetails(IStatus result, String message, String pluginId) { + + List details = new ArrayList(); + String title= ""; + Throwable e = null; + if (result.isMultiStatus()){ + for (IStatus childStatus:result.getChildren()){ + details.add(childStatus.getMessage()); + } + e = result.getChildren()[0].getException(); + if (result.equals(Status.OK_STATUS)|| result.equals(Status.WARNING)){ + title = "Delete was successfull."; + } else { + title = "Delete was aborted."; + } + } + StringBuffer relatedObjectsString = new StringBuffer(); + Object[] relatedObjects = new ArrayList().toArray(); + + + + String stackTraceWithContext = getContextInfo(details); + CdmDeleteErrorDialog ced = new CdmDeleteErrorDialog(AbstractUtility.getShell(), title, message,new Status(IStatus.INFO, pluginId, null, e), stackTraceWithContext, relatedObjects); + + ced.open(); + + + + } + } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/ChecklistEditorGeneralPreference.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/ChecklistEditorGeneralPreference.java index b807510bc..d319dfd53 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/ChecklistEditorGeneralPreference.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/ChecklistEditorGeneralPreference.java @@ -47,7 +47,7 @@ public class ChecklistEditorGeneralPreference extends PreferencePage implements composite.setLayout(new GridLayout()); isEditorActivated = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE); final Button activateCheckButton = new Button(composite, SWT.CHECK); - activateCheckButton.setText("Enable Checklist Editor"); + activateCheckButton.setText("Enable Distribution Editor"); activateCheckButton.setSelection(isEditorActivated); activateCheckButton.addSelectionListener(new SelectionAdapter(){ @Override @@ -69,7 +69,7 @@ public class ChecklistEditorGeneralPreference extends PreferencePage implements child.setLayout(new GridLayout()); child.setVisible(isEditorActivated); final CLabel label = new CLabel(child, SWT.NULL); - label.setText("Please open the wizard below, in order to \n" + "choose the areas for the Checklist Editor"); + label.setText("Please open the wizard below, in order to \n" + "choose the areas for the Distribution Editor"); final CommandHandlerButton button_openFeatureTree = new CommandHandlerButton(child, SWT.PUSH, "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardHandler"); @@ -88,7 +88,7 @@ public class ChecklistEditorGeneralPreference extends PreferencePage implements PreferencesUtil.recursiveSetEnabled(button_openFeatureTree, CdmStore.isActive()); boolean isShowRank = PreferencesUtil.isShowRankInChecklistEditor(); final Button activateRankButton = new Button(child, SWT.CHECK); - activateRankButton.setText("Show Rank in Checklist Editor"); + activateRankButton.setText("Show Rank in Distribution Editor"); activateRankButton.setSelection(isShowRank); activateRankButton.addSelectionListener(new SelectionAdapter(){ @Override diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteTaxonBaseConfiguratorComposite.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteTaxonBaseConfiguratorComposite.java index c2efefbb1..675ed5a00 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteTaxonBaseConfiguratorComposite.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteTaxonBaseConfiguratorComposite.java @@ -83,7 +83,7 @@ public class DeleteTaxonBaseConfiguratorComposite extends Composite implements S setBackground(getBackground()); btnDeleteTaxonName = new Button(this, SWT.CHECK); - btnDeleteTaxonName.setText("Delete taxon name if possible"); + btnDeleteTaxonName.setText("Delete name if possible"); btnDeleteTaxonName.setSelection(true); btnDeleteTaxonName.addListener(SWT.Selection, new Listener() { @Override diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/media/MediaMetaElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/media/MediaMetaElement.java index 706ceb4bc..ddeb878aa 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/media/MediaMetaElement.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/media/MediaMetaElement.java @@ -3,6 +3,8 @@ */ package eu.etaxonomy.taxeditor.ui.section.media; +import java.util.Map; + import org.apache.commons.lang.StringUtils; import org.eclipse.jface.action.IAction; import org.eclipse.swt.SWT; @@ -15,6 +17,7 @@ import org.eclipse.swt.widgets.Listener; import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; import eu.etaxonomy.cdm.model.agent.AgentBase; +import eu.etaxonomy.cdm.model.common.Language; import eu.etaxonomy.cdm.model.common.LanguageString; import eu.etaxonomy.cdm.model.media.Media; import eu.etaxonomy.taxeditor.model.AbstractUtility; @@ -89,6 +92,12 @@ public class MediaMetaElement extends AbstractEntityCollectionElement imp text_description.setLanguageString(element.getDescription(CdmStore .getDefaultLanguage())); + if (text_description.getText().isEmpty()){ + Map allDescriptions = element.getAllDescriptions(); + if (!allDescriptions.isEmpty()){ + text_description.setLanguageString(allDescriptions.get(Language.ENGLISH())); + } + } LanguageString title = element.getTitle(CdmStore.getDefaultLanguage()); diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameDetailElement.java index 84a1ae49e..b4e733ed7 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameDetailElement.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameDetailElement.java @@ -179,7 +179,7 @@ public class NameDetailElement extends AbstractIdentifiableEntityDetailElement extends ViewPart implements IPartContentHasFactualData, -IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IContextListener{ +IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IContextListener, Listener{ protected final Logger logger = Logger.getLogger(DataImportView.class); @@ -56,6 +66,24 @@ IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, I private static ConversationHolder conversationHolder; private SaveImportedSpecimenAction saveImportedSpecimenAction; + + private Text textClassification; + private Classification classification; + /** + * @return the classification + */ + public Classification getClassification() { + return classification; + } + + /** + * @param classification the classification to set + */ + public void setClassification(Classification classification) { + this.classification = classification; + } + private Button btnBrowseClassification; + private Button btnClear; private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); @@ -77,11 +105,29 @@ IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, I */ @Override public void createPartControl(Composite parent) { + final Composite composite = new Composite(parent, SWT.NULL); + + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 4; + composite.setLayout(gridLayout); + Label label = new Label(composite, SWT.NONE); + label.setText("Classification"); + textClassification = new Text(composite, SWT.NONE); + textClassification.setEnabled(false); + textClassification.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + btnBrowseClassification = new Button(composite, SWT.NONE); + btnBrowseClassification.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif")); + btnBrowseClassification.addListener(SWT.Selection, this); + btnClear = new Button(composite, SWT.NONE); + btnClear.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif")); + btnClear.addListener(SWT.Selection, this); CheckboxTableViewer checkboxTableViewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER | SWT.FULL_SELECTION); table = checkboxTableViewer.getTable(); toolkit.paintBordersFor(table); + + createActions(); initializeToolBar(); initializeMenu(); @@ -145,7 +191,7 @@ IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, I } protected void refresh(){ - getTable().removeAll(); + // getTable().removeAll(); for(T item:results){ TableItem tableItem = new TableItem(getTable(), SWT.NONE); tableItem.setText(getTextForTableItem(item)); @@ -234,5 +280,17 @@ IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, I } return conversationHolder; } - + @Override + public void handleEvent(Event event) { + if(event.widget==btnBrowseClassification){ + classification = SelectionDialogFactory.getSelectionFromDialog(Classification.class, getSite().getShell(), null, null); + if(classification!=null){ + textClassification.setText(classification.getTitleCache()); + } + } + else if(event.widget==btnClear){ + classification = null; + textClassification.setText(""); + } + } } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/SaveImportedSpecimenAction.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/SaveImportedSpecimenAction.java index b3ca3f460..7e01d6b00 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/SaveImportedSpecimenAction.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/SaveImportedSpecimenAction.java @@ -9,12 +9,14 @@ import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.UUID; import org.apache.http.client.ClientProtocolException; import org.apache.log4j.Logger; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.action.Action; import org.eclipse.jface.text.source.Annotation; +import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableItem; import org.eclipse.ui.IWorkbenchPart; @@ -22,6 +24,7 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import eu.etaxonomy.cdm.api.conversation.ConversationHolder; +import eu.etaxonomy.cdm.api.service.IClassificationService; import eu.etaxonomy.cdm.api.service.IOccurrenceService; import eu.etaxonomy.cdm.api.service.ITermService; import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery; @@ -35,7 +38,9 @@ import eu.etaxonomy.cdm.model.common.DefinedTermBase; import eu.etaxonomy.cdm.model.common.ICdmBase; import eu.etaxonomy.cdm.model.name.TaxonNameBase; import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; +import eu.etaxonomy.cdm.model.taxon.Classification; import eu.etaxonomy.taxeditor.store.CdmStore; +import eu.etaxonomy.taxeditor.ui.dialog.selection.SelectionDialogFactory; public class SaveImportedSpecimenAction extends Action { @@ -110,6 +115,10 @@ public class SaveImportedSpecimenAction extends Action { unitIdsBioCase = new HashSet(); bioCaseOccurrenceQuery = new OccurenceQuery(unitIdsBioCase); configuratorAbcd.setOccurenceQuery(bioCaseOccurrenceQuery); + if (dataImportView.getClassification() != null){ + configuratorAbcd.setClassificationUuid(dataImportView.getClassification().getUuid()); + } + } tripleId = response.getTripleID(); unitIdsBioCase.add(tripleId); @@ -134,7 +143,7 @@ public class SaveImportedSpecimenAction extends Action { } } - + private void persistTerm(DefinedTermBase term, ITermService termService, ConversationHolder conversation){ if(term!=null){ //if the term does not exist in the DB save it diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/SpecimenImportView.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/SpecimenImportView.java index eb01cbb79..11674fd24 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/SpecimenImportView.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/SpecimenImportView.java @@ -71,6 +71,8 @@ public class SpecimenImportView extends DataImportView