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;
}
+
+ public static void messageDialogWithDetails(IStatus result, String message, String pluginId) {
+
+ List<String> details = new ArrayList<String>();
+ 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<Object>().toArray();
+
+
+
+ String stackTraceWithContext = getContextInfo(details);
+ CdmDeleteErrorDialog ced = new CdmDeleteErrorDialog(AbstractUtility.getShell(), title, message,new Status(IStatus.INFO, pluginId, null, e), stackTraceWithContext, relatedObjects);
+
+ ced.open();
+
+
+
+ }
+
}
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
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");
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
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
*/
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;
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;
text_description.setLanguageString(element.getDescription(CdmStore
.getDefaultLanguage()));
+ if (text_description.getText().isEmpty()){
+ Map<Language, LanguageString> allDescriptions = element.getAllDescriptions();
+ if (!allDescriptions.isEmpty()){
+ text_description.setLanguageString(allDescriptions.get(Language.ENGLISH()));
+ }
+ }
LanguageString title = element.getTitle(CdmStore.getDefaultLanguage());
}
private void createInfragenerericEpithetControls(ICdmFormElement element, NonViralName nonViralName, int style){
- if (nonViralName.getNomenclaturalCode().equals(NomenclaturalCode.ICZN)){
+ if (nonViralName.getNomenclaturalCode() == null || nonViralName.getNomenclaturalCode().equals(NomenclaturalCode.ICZN)){
if(nonViralName.getRank() != null && nonViralName.getRank().isLower(Rank.GENUS()) ){
text_infragenericEpithet = formFactory.createTextWithLabelElement(element, "Infrageneric Epithet", nonViralName.getInfraGenericEpithet(), style);
}
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.part.ViewPart;
+import org.eclipse.wb.swt.ResourceManager;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
+import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
import eu.etaxonomy.taxeditor.model.IContextListener;
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.dialog.selection.SelectionDialogFactory;
/**
* View which shows a list of "data" that can be imported into the CDM
*/
public abstract class DataImportView<T> extends ViewPart implements IPartContentHasFactualData,
-IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IContextListener{
+IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IContextListener, Listener{
protected final Logger logger = Logger.getLogger(DataImportView.class);
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());
*/
@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();
}
protected void refresh(){
- getTable().removeAll();
+ // getTable().removeAll();
for(T item:results){
TableItem tableItem = new TableItem(getTable(), SWT.NONE);
tableItem.setText(getTextForTableItem(item));
}
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("");
+ }
+ }
}
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;
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;
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 {
unitIdsBioCase = new HashSet<String[]>();
bioCaseOccurrenceQuery = new OccurenceQuery(unitIdsBioCase);
configuratorAbcd.setOccurenceQuery(bioCaseOccurrenceQuery);
+ if (dataImportView.getClassification() != null){
+ configuratorAbcd.setClassificationUuid(dataImportView.getClassification().getUuid());
+ }
+
}
tripleId = response.getTripleID();
unitIdsBioCase.add(tripleId);
}
}
-
+
private void persistTerm(DefinedTermBase<?> term, ITermService termService, ConversationHolder conversation){
if(term!=null){
//if the term does not exist in the DB save it
// new TransientCdmRepository(CdmStore.getCurrentApplicationConfiguration());
//configurator.setCdmAppController(repo);
configurator.setAddMediaAsMediaSpecimen(true);
+ configurator.setAllowReuseOtherClassifications(true);
+
Job job = CdmStore.getImportManager().createIOServiceJob(configurator, resultStream, SOURCE_TYPE.INPUTSTREAM);
CdmStore.getImportManager().run(job);
configurator.setSourceUri(providerSelectionPage.getEndPoint());
configurator.setAddMediaAsMediaSpecimen(true);
configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
+ configurator.setIgnoreAuthorship(true);
//Job job = CdmStore.getImportManager().createIOServiceJob(configurator, new File(source), SOURCE_TYPE.INPUTSTREAM);
//CdmStore.getImportManager().run(job);