<elements xsi:type="commands:Command" xmi:id="_zJ4-8JMCEeeR4YRjNqCKeA" elementId="eu.etaxonomy.taxeditor.command.openClassificationWizard" commandName="%command.name.OPEN_CLASSIFICATION_WIZARD"/>
<elements xsi:type="commands:Command" xmi:id="_l-AGEKjzEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.openReferencingObjectsView" commandName="%command.name.OPEN_REFERENCING_OBJECTS_VIEW"/>
<elements xsi:type="commands:Command" xmi:id="_TwGSwKkVEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.workbench.command.importSpecimens" commandName="Import specimens"/>
+ <elements xsi:type="commands:Command" xmi:id="_QbHeEKmQEeeDJPU_cUTI2g" elementId="eu.etaxonomy.taxeditor.store.command.importAbcd" commandName="Import ABCD"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_swGH0GhvEee3K4uKJljEYg" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Handler" xmi:id="_rVEdIGcjEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" command="_fNBtQGcjEee0qLTtA2ZpVQ"/>
<elements xsi:type="commands:Handler" xmi:id="_8HUM8JMCEeeR4YRjNqCKeA" elementId="eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenClassificationWizardHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenClassificationWizardHandlerE4" command="_zJ4-8JMCEeeR4YRjNqCKeA"/>
<elements xsi:type="commands:Handler" xmi:id="_fKcuoKjzEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.handler.defaultHandler.OpenReferencingObjectsViewHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.handler.defaultHandler.OpenReferencingObjectsViewHandler" command="_l-AGEKjzEeejedk4mZQIGw"/>
<elements xsi:type="commands:Handler" xmi:id="_WyDA0KkVEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.view.dataimport.e4.handler.OpenSpecimenImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.dataimport.e4.handler.OpenSpecimenImportWizard" command="_TwGSwKkVEeejedk4mZQIGw"/>
+ <elements xsi:type="commands:Handler" xmi:id="_2yHUgKmYEeeDJPU_cUTI2g" elementId="eu.etaxonomy.taxeditor.io.e4.abcd.OpenAbcdImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.abcd.OpenAbcdImportWizard" command="_QbHeEKmQEeeDJPU_cUTI2g"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_qT4hgIfTEeecZ4F2Y9Z0Og" featurename="children" parentElementId="eu.etaxonomy.taxeditor.workbench.menu.window" positionInList="before:eu.etaxonomy.taxeditor.application.windowMenu.last">
<elements xsi:type="menu:Menu" xmi:id="_LT3P8IfcEeecZ4F2Y9Z0Og" elementId="eu.etaxonomy.taxeditor.store.menu.termeditor" label="Term Editor">
<elements xsi:type="menu:Menu" xmi:id="_QC5O8KkaEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.store.menu.import" label="Import (E4)">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_UL4dkKkaEeejedk4mZQIGw" coreExpressionId="isCdmStoreConnected"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_RUOtQKkVEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.workbench.handledmenuitem.importspecimens" label="Import specimens" command="_TwGSwKkVEeejedk4mZQIGw"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_NO718KmQEeeDJPU_cUTI2g" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.importAbcd" label="ABCD" command="_QbHeEKmQEeeDJPU_cUTI2g"/>
</elements>
</fragments>
</fragment:ModelFragments>
class="eu.etaxonomy.taxeditor.io.wizard.ExcelNormalExplicitTaxaImportWizard"
id="eu.etaxonomy.taxeditor.io.import.excel.taxa"
name="%wizard.name.2">
- </wizard>
- <wizard
- category="eu.etaxonomy.taxeditor.import.category.cdm"
- class="eu.etaxonomy.taxeditor.io.wizard.AbcdImportWizard"
- id="eu.etaxonomy.taxeditor.io.import.abcd"
- name="%wizard.name.3">
</wizard>
<wizard
category="eu.etaxonomy.taxeditor.import.category.cdm"
--- /dev/null
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.io.e4;
+
+import javax.inject.Inject;
+
+import org.eclipse.e4.core.contexts.ContextInjectionFactory;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.ui.workbench.modeling.EPartService;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardContainer;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.SWT;
+import org.eclipse.ui.IWorkbench;
+
+import eu.etaxonomy.cdm.io.common.IImportConfigurator;
+import eu.etaxonomy.cdm.io.common.IIoConfigurator;
+import eu.etaxonomy.taxeditor.l10n.Messages;
+
+/**
+ *
+ * @author pplitzner
+ * @since Oct 5, 2017
+ *
+ * @param <CONFIG>
+ */
+public abstract class AbstractImportWizardE4<CONFIG extends IIoConfigurator> extends Wizard {
+
+ protected GenericConfiguratorWizardPageE4 pageConfiguration;
+ private NomenclaturalCodeWizardPageE4 pageNomenclaturalCode;
+
+ private IWorkbench workbench;
+
+ private IStructuredSelection selection;
+
+ protected IEclipseContext context;
+
+ private EPartService partService;
+
+ @Inject
+ public AbstractImportWizardE4(IEclipseContext context, EPartService partService) {
+ this.context = context;
+ this.partService = partService;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void addPages() {
+ super.addPages();
+
+ addConfiguratorPage();
+
+ pageNomenclaturalCode = ContextInjectionFactory.make(NomenclaturalCodeWizardPageE4.class, context);
+ pageNomenclaturalCode.setConfigurator((IImportConfigurator)getConfigurator());
+ this.addPage(pageNomenclaturalCode);
+ }
+
+ protected void addConfiguratorPage(){
+ pageConfiguration = ContextInjectionFactory.make(GenericConfiguratorWizardPageE4.class, context);
+ pageConfiguration.initImport(getConfigurator(), null, Messages.AbstractImportWizard_ConfigurationLabel);
+ this.addPage(pageConfiguration);
+ }
+
+ @Override
+ public void setContainer(IWizardContainer wizardContainer) {
+ if(existUnsavedEditors()){
+ MessageDialog.open(MessageDialog.WARNING, getShell(), "Unsaved editors", "Please save all open editors before executing " +
+ "an import operation. The import operation will be cancelled", SWT.NONE);
+ }
+ else{
+ super.setContainer(wizardContainer);
+ }
+ }
+
+ public abstract void init();
+
+ protected boolean existUnsavedEditors(){
+ return !partService.getDirtyParts().isEmpty();
+ }
+
+ @Override
+ public boolean canFinish() {
+ return !existUnsavedEditors() && super.canFinish();
+ }
+
+ public abstract CONFIG getConfigurator();
+
+ public void setSelection(IStructuredSelection selection) {
+ this.selection = selection;
+ }
+
+ public IStructuredSelection getSelection() {
+ return selection;
+ }
+
+ public void setWorkbench(IWorkbench workbench) {
+ this.workbench = workbench;
+ }
+
+ public IWorkbench getWorkbench() {
+ return workbench;
+ }
+}
--- /dev/null
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.io.e4;
+
+import org.eclipse.e4.core.contexts.ContextInjectionFactory;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @author pplitzner
+ * @since Oct 5, 2017
+ *
+ */
+public abstract class AbstractOpenImportWizard {
+ @Execute
+ public void execute(IEclipseContext ctx, Shell s)
+ {
+ AbstractImportWizardE4 wizard = ContextInjectionFactory.make(getImportWizardClass(), ctx);
+ wizard.init();
+ WizardDialog dialog = new WizardDialog(s, wizard);
+ dialog.open();
+ }
+
+ protected abstract Class<? extends AbstractImportWizardE4> getImportWizardClass();
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (C) 2007 EDIT
+ * European Distributed Institute of Taxonomy
+ * http://www.e-taxonomy.eu
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
+
+package eu.etaxonomy.taxeditor.io.e4;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import javax.inject.Inject;
+
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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 eu.etaxonomy.cdm.io.common.IIoConfigurator;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+
+/**
+ *
+ * @author pplitzner
+ * @since Oct 5, 2017
+ *
+ */
+public class GenericConfiguratorWizardPageE4 extends WizardPage {
+
+ private IIoConfigurator configurator;
+ private ResourceBundle resourceBundle;
+ private List<String> ignoreMethods;
+
+ @Inject
+ private GenericConfiguratorWizardPageE4() {
+ super("Configuration");
+ }
+
+ public void init(String title, String description, IIoConfigurator configurator, List<String> ignoreMethods){
+ this.setTitle(title);
+ this.setDescription(description);
+ this.configurator = configurator;
+ this.ignoreMethods = ignoreMethods;
+ resourceBundle = getResourceBundle(configurator);
+ }
+
+ private ResourceBundle getResourceBundle(IIoConfigurator configurator){
+ try{
+ if (configurator != null){
+ return ResourceBundle.getBundle(configurator.getClass().getName());
+ }else{
+ return ResourceBundle.getBundle("Configuration");
+ }
+ }catch(MissingResourceException e){
+ return null;
+ }
+ }
+
+ public void initImport(IIoConfigurator configurator, List<String> ignoreMethods, String label) {
+ init("Import Configuration", label, configurator, ignoreMethods);
+ }
+
+ public void initExport(IIoConfigurator configurator, List<String> ignoreMethods) {
+ init("Export Configuration", "Configure the export mechanism.", configurator, ignoreMethods);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void createControl(Composite parent) {
+
+ // TODO wrap this composite in a scrolled composite
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ GridLayout gridLayout = new GridLayout();
+ composite.setLayout(gridLayout);
+
+ List<Method> methods = getConfiguratorsBooleanSetMethods(configurator);
+ Collections.sort(methods, new Comparator<Method>() {
+ @Override
+ public int compare(Method o1, Method o2) {
+ if (o1.equals(o2)){
+ return 0;
+ }
+ if(o1.getName()==null && o2.getName()!=null){
+ return -1;
+ }
+ if(o1.getName()!=null && o2.getName()==null){
+ return 1;
+ }
+ if(o1.getName()==null && o2.getName()==null){
+ return o1.toString().compareTo(o1.toString());
+ }
+ int result = o1.getName().compareTo(o2.getName());
+ if (result == 0){
+ return o1.toString().compareTo(o1.toString());
+ }
+ return result;
+ }
+ });
+
+ for (Method method : methods) {
+ if (ignoreMethods != null){
+ if (!ignoreMethods.contains( method.getName())) {
+ createCheckbox(composite, method, configurator);
+ }
+ }else{
+ createCheckbox(composite, method, configurator);
+ }
+
+ }
+
+ setControl(composite);
+ }
+
+ private void createCheckbox(Composite parent, Method method,
+ final IIoConfigurator configurator) {
+
+ final String methodName = method.getName();
+ final Button checkBox = new Button(parent, SWT.CHECK);
+
+ // if(configurator.getClass().equals(Abcd206ImportConfigurator.class)){
+ String[] r = methodName.split("set")[1].split("(?=\\p{Upper})");
+ checkBox.setText(getLabel(StringUtils.join(r," ")));
+// }
+// else{
+// checkBox.setText(getLabel(methodName));
+// }
+ // retrieve the default values and set the checkbox accordingly
+ boolean defaultSelection = executeBooleanGetMethod(configurator, "is"
+ + methodName.substring(3));
+ checkBox.setSelection(defaultSelection);
+ checkBox.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ executeBooleanSetMethod(configurator, methodName,
+ checkBox.getSelection());
+ }
+
+ });
+
+ }
+
+ private String getLabel(String methodName){
+
+ if(resourceBundle == null){
+ return methodName;
+ }
+
+ try{
+ return resourceBundle.getString(methodName);
+ }catch(MissingResourceException e){
+ return methodName;
+ }
+ }
+
+ private boolean executeBooleanGetMethod(IIoConfigurator configurator,
+ String methodName) {
+
+ Class<? extends IIoConfigurator> configuratorClass = configurator
+ .getClass();
+
+ boolean result = false;
+
+ Method[] methods = configuratorClass.getMethods();
+
+ for (Method method : methods) {
+ if (!method.getName().equals(methodName)) {
+ continue;
+ }
+
+ try {
+ Object returnType = method.invoke(configurator, null);
+ if (returnType.getClass().equals(Boolean.class)) {
+ result = ((Boolean) returnType).booleanValue();
+ }
+
+ break;
+ } catch (Exception e) {
+ MessagingUtils.warn(this.getClass(), "Could not invoke method");
+ }
+ }
+
+ return result;
+ }
+
+ private void executeBooleanSetMethod(IIoConfigurator configurator,
+ String methodName, boolean selected) {
+
+ Class<? extends IIoConfigurator> configuratorClass = configurator
+ .getClass();
+
+ Method[] methods = configuratorClass.getMethods();
+
+ for (Method method : methods) {
+ if (!method.getName().equals(methodName)) {
+ continue;
+ }
+
+ try {
+ method.invoke(configurator, selected);
+
+ break;
+ } catch (Exception e) {
+ MessagingUtils.warn(this.getClass(), "Could not invoke method");
+ }
+ }
+ }
+
+ private List<Method> getConfiguratorsBooleanSetMethods(
+ IIoConfigurator configurator) {
+ List<Method> booleanMethods = new ArrayList<Method>();
+
+ Class<? extends IIoConfigurator> configuratorClass = configurator
+ .getClass();
+
+ Method[] allMethods = configuratorClass.getMethods();
+
+ for (Method method : allMethods) {
+ if (method.getName().startsWith("set")) {
+
+ Class<?>[] typeList = method.getParameterTypes();
+
+ if (typeList.length > 1) {
+ new IllegalStateException(
+ "Found a setter with parameter count > 1");
+ }
+
+ if (typeList[0].getName().equals("boolean")) {
+ booleanMethods.add(method);
+ }
+ }
+ }
+
+ return booleanMethods;
+ }
+}
--- /dev/null
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.io.e4;
+
+import java.io.File;
+import java.net.URI;
+
+import javax.inject.Inject;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import eu.etaxonomy.cdm.common.CdmUtils;
+
+/**
+ *
+ * @author n.hoffmann
+ * @created 04.08.2009
+ * @version 1.0
+ */
+public class ImportFromFileDataSourceWizardPageE4 extends WizardPage {
+
+ /** Constant <code>PAGE_NAME="CdmXmlDataSourceWizardPage"</code> */
+ public static final String PAGE_NAME = "CdmXmlDataSourceWizardPage";
+
+ private String[] extensions = {"*.xml"};
+
+ private FileDialog fileDialog;
+ private Text textReferenceString;
+
+ protected Text text_source;
+
+ @Inject
+ public ImportFromFileDataSourceWizardPageE4() {
+ super(PAGE_NAME);
+
+ setTitle("Xml File");
+
+ setDescription("Select XML file.");
+
+ this.extensions = new String[]{"*.xml","*.*"};
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void createControl(Composite parent) {
+ final Composite composite = new Composite(parent, SWT.NULL);
+
+ setPageComplete(false);
+
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 3;
+ composite.setLayout(gridLayout);
+
+ Label folderLabel = new Label(composite, SWT.NONE);
+ folderLabel.setText("File");
+
+ fileDialog = new FileDialog(parent.getShell());
+
+ fileDialog.setFilterExtensions(extensions);
+
+ text_source = new Text(composite, SWT.BORDER);
+ text_source.setEditable(false);
+ text_source.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+
+ Button button = new Button(composite, SWT.PUSH);
+ button.setText("Browse...");
+
+ button.addSelectionListener(new SelectionAdapter(){
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ String path = fileDialog.open();
+ if(path!=null){
+ text_source.setText(path);
+ setPageComplete(isPageComplete());
+ }
+ }
+
+ });
+
+ Label labelRef = new Label(composite, SWT.NONE);
+ labelRef.setText("Default import souce reference");
+ labelRef.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
+ textReferenceString = new Text(composite, SWT.NONE);
+ textReferenceString.setEnabled(true);
+ GridData gd_textReferenceString = new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1);
+ gd_textReferenceString.widthHint = 229;
+ textReferenceString.setLayoutData(gd_textReferenceString);
+ setControl(composite);
+ }
+
+ public File getFile() {
+ return new File(text_source.getText());
+ }
+
+ public Text getTextReferenceString() {
+ return textReferenceString;
+ }
+
+ public void setTextReferenceString(Text textReferenceString) {
+ this.textReferenceString = textReferenceString;
+ }
+
+ public URI getUri() {
+ return getFile().toURI();
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ return CdmUtils.isNotBlank(text_source.getText());
+ }
+
+}
--- /dev/null
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.io.e4;
+
+import javax.inject.Inject;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+import eu.etaxonomy.cdm.io.common.IImportConfigurator;
+import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
+import eu.etaxonomy.taxeditor.model.NomenclaturalCodeHelper;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+
+/**
+ *
+ * @author p.ciardelli
+ * @created 11.09.2009
+ * @version 1.0
+ */
+public class NomenclaturalCodeWizardPageE4 extends WizardPage {
+
+ private IImportConfigurator configurator;
+
+ @Inject
+ public NomenclaturalCodeWizardPageE4() {
+ super("Choose nomenclatural code");
+
+ this.setTitle("Choose nomenclatural code");
+
+ this.setDescription("Choose which code to use for imported names.");
+ }
+
+ public void setConfigurator(IImportConfigurator configurator) {
+ this.configurator = configurator;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NULL);
+ container.setLayout(new FillLayout());
+
+ final Group group = new Group(container, SWT.NONE);
+ group.setLayout(new GridLayout());
+
+ NomenclaturalCode preferredCode = PreferencesUtil.getPreferredNomenclaturalCode(false);
+
+ // set preferred code as default
+ configurator.setNomenclaturalCode(preferredCode);
+
+ for (final NomenclaturalCode code : NomenclaturalCodeHelper.getSupportedCodes()) {
+ Button button = new Button(group, SWT.RADIO);
+ button.setText(NomenclaturalCodeHelper.getDescription(code));
+ button.setData(code);
+ button.setSelection(preferredCode.equals(code));
+ button.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setNomenclaturalCode((NomenclaturalCode) e.widget.getData());
+ }
+ });
+ }
+ setControl(container);
+ }
+
+}
--- /dev/null
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.io.e4.abcd;
+
+import javax.inject.Inject;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
+import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+
+/**
+ *
+ * @author pplitzner
+ *
+ */
+public class AbcdImportConfiguratorWizardPageE4 extends WizardPage {
+
+ public static final String PAGE_NAME = "AbcdImportConfiguratorWizardPage";
+
+ private Abcd206ImportConfigurator configurator;
+
+ @Inject
+ public AbcdImportConfiguratorWizardPageE4() {
+ super(PAGE_NAME);
+ setTitle("Configure import parameters");
+ setDescription("Tooltips will explain parameters in more detail");
+ }
+
+// protected AbcdImportConfiguratorWizardPageE4(String title, String description, Abcd206ImportConfigurator configurator, boolean isPreferencePage) {
+// super(PAGE_NAME);
+// this.configurator = configurator;
+// setTitle(title);
+// setDescription(description);
+// this.isPreferencePage = isPreferencePage;
+// }
+//
+// public static AbcdImportConfiguratorWizardPageE4 createPreferencePage(Abcd206ImportConfigurator configurator){
+// return new AbcdImportConfiguratorWizardPageE4("Configure import parameters",
+// "Tooltips will explain parameters in more detail", configurator, true);
+// }
+
+
+
+ /** {@inheritDoc} */
+ @Override
+ public void createControl(Composite parent) {
+ final Composite composite = new Composite(parent, SWT.NULL);
+ //composite = addTab(Messages.DatabasePreferencesPage_Define_Default_NomenclaturalCode);
+ GridLayout gridLayout = new GridLayout();
+ composite.setLayout(gridLayout);
+// if (isPreferencePage){
+// ListComponent list = new ListComponent(composite, composite.getStyle());
+// }
+
+ Button checkBoxMediaSpecimen = new Button(composite, SWT.CHECK);
+ checkBoxMediaSpecimen.setSelection(configurator.isAddMediaAsMediaSpecimen());
+ checkBoxMediaSpecimen.setText("Import media as media specimen");
+ checkBoxMediaSpecimen
+ .setToolTipText("Any media attached to a ABCD unit will be imported as a sub derivative of the specimen created from this unit");
+ checkBoxMediaSpecimen.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setAddMediaAsMediaSpecimen(!configurator.isAddMediaAsMediaSpecimen());
+ }
+ });
+
+ Button checkBoxIgnoreExisting = new Button(composite, SWT.CHECK);
+ checkBoxIgnoreExisting.setSelection(configurator.isIgnoreImportOfExistingSpecimen());
+ checkBoxIgnoreExisting.setText("Do not import existing specimens");
+ checkBoxIgnoreExisting
+ .setToolTipText("Specimens that have previously been imported will be ignored in this import");
+ checkBoxIgnoreExisting.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setIgnoreImportOfExistingSpecimen(!configurator.isIgnoreImportOfExistingSpecimen());
+ }
+ });
+
+ Button checkBoxIgnoreAuthorship = new Button(composite, SWT.CHECK);
+ checkBoxIgnoreAuthorship.setSelection(configurator.isIgnoreAuthorship());
+ checkBoxIgnoreAuthorship.setText("Ignore Authorship for name matching");
+ checkBoxIgnoreAuthorship
+ .setToolTipText("Name matching with existing names will be done without "
+ + "the authorship part of the name");
+ checkBoxIgnoreAuthorship.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setIgnoreAuthorship(!configurator.isIgnoreAuthorship());
+ }
+ });
+
+ Button checkBoxMapUnitIdToCatalogNumber = new Button(composite, SWT.CHECK);
+ checkBoxMapUnitIdToCatalogNumber.setSelection(configurator.isMapUnitIdToCatalogNumber());
+ checkBoxMapUnitIdToCatalogNumber.setText("Map UnitID to catalog number");
+ checkBoxMapUnitIdToCatalogNumber
+ .setToolTipText("The UnitID of every ABCD unit will be mapped the catalog number "
+ + "of the specimen");
+ checkBoxMapUnitIdToCatalogNumber.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setMapUnitIdToCatalogNumber(!configurator.isMapUnitIdToCatalogNumber());
+ }
+ });
+//TODO: only one of the mappings can be checked!
+ Button checkBoxMapUnitIdToAccessionNumber = new Button(composite, SWT.CHECK);
+ checkBoxMapUnitIdToAccessionNumber.setSelection(configurator.isMapUnitIdToAccessionNumber());
+ checkBoxMapUnitIdToAccessionNumber.setText("Map UnitID to accession number");
+ checkBoxMapUnitIdToAccessionNumber
+ .setToolTipText("The UnitID of every ABCD unit will be mapped the accession number "
+ + "of the specimen");
+ checkBoxMapUnitIdToAccessionNumber.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setMapUnitIdToAccessionNumber(!configurator.isMapUnitIdToAccessionNumber());
+ }
+ });
+
+ Button checkBoxMapUnitIdToBarcode = new Button(composite, SWT.CHECK);
+ checkBoxMapUnitIdToBarcode.setSelection(configurator.isMapUnitIdToBarcode());
+ checkBoxMapUnitIdToBarcode.setText("Map UnitID to barcode");
+ checkBoxMapUnitIdToBarcode
+ .setToolTipText("The UnitID of every ABCD unit will be mapped the barcode "
+ + "of the specimen");
+ checkBoxMapUnitIdToBarcode.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setMapUnitIdToBarcode(!configurator.isMapUnitIdToBarcode());
+ }
+ });
+
+ Button checkBoxRemoveCountry = new Button(composite, SWT.CHECK);
+ checkBoxRemoveCountry.setSelection(configurator.isRemoveCountryFromLocalityText());
+ checkBoxRemoveCountry.setText("Remove country from locality text");
+ checkBoxRemoveCountry
+ .setToolTipText("If the locality text contains information about the "
+ + "country which is additionally stored in other ABCD "
+ + "elements then it is removed from the locality text");
+ checkBoxRemoveCountry.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setRemoveCountryFromLocalityText(!configurator.isRemoveCountryFromLocalityText());
+ }
+ });
+
+ Button checkBoxMoveToDefaultClassification = new Button(composite, SWT.CHECK);
+ checkBoxMoveToDefaultClassification.setSelection(configurator.isMoveNewTaxaToDefaultClassification());
+ checkBoxMoveToDefaultClassification.setText("Create new classification for new taxa");
+ checkBoxMoveToDefaultClassification
+ .setToolTipText("For taxa that do not exist in the data base "
+ + "a new classification will be created");
+ checkBoxMoveToDefaultClassification.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setMoveNewTaxaToDefaultClassification(!configurator.isMoveNewTaxaToDefaultClassification());
+ }
+ });
+
+ Button checkBoxImportSiblings = new Button(composite, SWT.CHECK);
+ checkBoxImportSiblings.setSelection(configurator.isGetSiblings());
+ checkBoxImportSiblings.setText("Import all children of cultures or tissue samples");
+ checkBoxImportSiblings
+ .setToolTipText("For a tissue sample or culture all children will be searched and imported");
+ checkBoxImportSiblings.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setGetSiblings(checkBoxImportSiblings.getSelection());
+ }
+ });
+
+ Button checkBoxAddIndividualsAssociations = new Button(composite, SWT.CHECK);
+ checkBoxAddIndividualsAssociations.setSelection(configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
+ checkBoxAddIndividualsAssociations.setText("Create an Individual Association for each Specimen");
+ checkBoxAddIndividualsAssociations
+ .setToolTipText("For each specimen associated to a taxon an indiviadual association to this taxon is created");
+ checkBoxAddIndividualsAssociations.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(!configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
+ }
+ });
+
+ Button checkBoxReuseDescriptiveGroups = new Button(composite, SWT.CHECK);
+ checkBoxReuseDescriptiveGroups.setSelection(configurator.isReuseExistingDescriptiveGroups());
+ checkBoxReuseDescriptiveGroups.setText("Reuse existing descriptive group");
+ checkBoxReuseDescriptiveGroups
+ .setToolTipText("Reuse one of the existing descriptive groups or create a new one for every import");
+ checkBoxReuseDescriptiveGroups.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setReuseExistingDescriptiveGroups(!configurator.isReuseExistingDescriptiveGroups());
+ }
+ });
+
+ Button checkBoxReuseExistingTaxa = new Button(composite, SWT.CHECK);
+ checkBoxReuseExistingTaxa.setSelection(configurator.isReuseExistingTaxaWhenPossible());
+ checkBoxReuseExistingTaxa.setText("Reuse existing taxa when possible");
+ checkBoxReuseExistingTaxa
+ .setToolTipText("Reuse existing taxa when the name matches the identified name of the specimen");
+ checkBoxReuseExistingTaxa.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setReuseExistingDescriptiveGroups(!configurator.isReuseExistingDescriptiveGroups());
+ }
+ });
+
+
+ setControl(composite);
+ }
+
+ public void saveConfigToPrefernceStore() {
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS,
+ configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN,
+ configurator.isAddMediaAsMediaSpecimen());
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS,
+ configurator.isAllowReuseOtherClassifications());
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS,
+ configurator.isDeduplicateClassifications());
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES,
+ configurator.isDeduplicateReferences());
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS,
+ configurator.isGetSiblings());
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP,
+ configurator.isIgnoreAuthorship());
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN,
+ configurator.isIgnoreImportOfExistingSpecimen());
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER,
+ configurator.isMapUnitIdToAccessionNumber());
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE,
+ configurator.isMapUnitIdToBarcode());
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER,
+ configurator.isMapUnitIdToCatalogNumber());
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION,
+ configurator.isMoveNewTaxaToDefaultClassification());
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN,
+ configurator.isOverwriteExistingSpecimens());
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS,
+ configurator.isReuseExistingDescriptiveGroups());
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA,
+ configurator.isReuseExistingMetaData());
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE,
+ configurator.isReuseExistingTaxaWhenPossible());
+
+ }
+
+ public String createConfigString(){
+ return configurator.toString();
+
+ }
+
+ public void setConfigurator(Abcd206ImportConfigurator configurator) {
+ this.configurator = configurator;
+ }
+
+ protected IPreferenceStore doGetPreferenceStore() {
+ return PreferencesUtil.getPreferenceStore();
+ }
+}
--- /dev/null
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.io.e4.abcd;
+
+import java.io.File;
+import java.net.URI;
+
+import javax.inject.Inject;
+
+import org.eclipse.e4.core.contexts.ContextInjectionFactory;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.ui.workbench.modeling.EPartService;
+
+import eu.etaxonomy.cdm.database.DbSchemaValidation;
+import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
+import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
+import eu.etaxonomy.taxeditor.io.e4.AbstractImportWizardE4;
+import eu.etaxonomy.taxeditor.io.e4.ImportFromFileDataSourceWizardPageE4;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ *
+ * @author pplitzner
+ * @since Oct 5, 2017
+ *
+ */
+public class AbcdImportWizardE4 extends AbstractImportWizardE4<Abcd206ImportConfigurator> {
+
+ private Abcd206ImportConfigurator configurator;
+ private ImportFromFileDataSourceWizardPageE4 dataSourcePage;
+ private ClassificationChooserWizardPageE4 classificationChooserWizardPage;
+
+ @Inject
+ public AbcdImportWizardE4(IEclipseContext context, EPartService partService) {
+ super(context, partService);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Abcd206ImportConfigurator getConfigurator() {
+ return configurator;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean performFinish() {
+ URI source = dataSourcePage.getUri();
+ configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
+
+ if(classificationChooserWizardPage.getClassification()!=null){
+ configurator.setClassificationUuid(classificationChooserWizardPage.getClassification().getUuid());
+ }
+
+ CdmStore.getImportManager().runMoniteredOperation(configurator, new File(source), SOURCE_TYPE.INPUTSTREAM);
+
+ return true;
+
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void init() {
+ configurator = PreferencesUtil.getAbcdImportConfigurationPreference(true);
+ }
+
+ @Override
+ protected void addConfiguratorPage() {
+ AbcdImportConfiguratorWizardPageE4 configuratorWizardPage = ContextInjectionFactory.make(AbcdImportConfiguratorWizardPageE4.class, context);//AbcdImportConfiguratorWizardPage.createPage(configurator);
+ configuratorWizardPage.setConfigurator(configurator);
+ addPage(configuratorWizardPage);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void addPages() {
+ super.addPages();
+
+ classificationChooserWizardPage = ContextInjectionFactory.make(ClassificationChooserWizardPageE4.class, context);
+
+ dataSourcePage = ContextInjectionFactory.make(ImportFromFileDataSourceWizardPageE4.class, context);//.XML();
+
+ addPage(classificationChooserWizardPage);
+ addPage(dataSourcePage);
+ }
+}
--- /dev/null
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.io.e4.abcd;
+
+import javax.inject.Inject;
+
+import org.eclipse.jface.wizard.WizardPage;
+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.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.wb.swt.ResourceManager;
+
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.SelectionDialogFactory;
+
+/**
+ * <p>ImportFromFileDataSourceWizardPage class.</p>
+ *
+ * @author n.hoffmann
+ * @created 04.08.2009
+ * @version 1.0
+ */
+public class ClassificationChooserWizardPageE4 extends WizardPage implements Listener{
+
+ public static final String PAGE_NAME = "ClassificationChooserWizardPage";
+
+ //classification
+ private Text textClassification;
+ private Classification classification;
+ private Button btnBrowseClassification;
+
+ private Button btnClear;
+
+ @Inject
+ public ClassificationChooserWizardPageE4() {
+ super(PAGE_NAME);
+
+ setTitle("Configure import destinations");
+
+ setDescription("Note: Selecting no classification will create a default one.");
+
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void createControl(Composite parent) {
+ final Composite composite = new Composite(parent, SWT.NULL);
+
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 4;
+ composite.setLayout(gridLayout);
+
+ //classification
+ 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);
+
+ setControl(composite);
+ }
+
+ @Override
+ public void handleEvent(Event event) {
+ if(event.widget==btnBrowseClassification){
+ classification = SelectionDialogFactory.getSelectionFromDialog(Classification.class, getShell(), null, null);
+ if(classification!=null){
+ textClassification.setText(classification.getTitleCache());
+ }
+ }
+ else if(event.widget==btnClear){
+ classification = null;
+ textClassification.setText("");
+ }
+ }
+
+ /**
+ * @return the classification
+ */
+ public Classification getClassification() {
+ return classification;
+ }
+
+}
--- /dev/null
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.io.e4.abcd;
+
+import eu.etaxonomy.taxeditor.io.e4.AbstractImportWizardE4;
+import eu.etaxonomy.taxeditor.io.e4.AbstractOpenImportWizard;
+
+/**
+ * @author pplitzner
+ * @since Oct 5, 2017
+ *
+ */
+public class OpenAbcdImportWizard extends AbstractOpenImportWizard {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Class<? extends AbstractImportWizardE4> getImportWizardClass() {
+ return AbcdImportWizardE4.class;
+ }
+
+}