Project

General

Profile

« Previous | Next » 

Revision 4de91645

Added by Patrick Plitzner over 6 years ago

ref #7005 Refactor package structure

View differences:

eu.etaxonomy.taxeditor.store/fragment.e4xmi
121 121
    <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"/>
122 122
    <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"/>
123 123
    <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"/>
124
    <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"/>
125
    <elements xsi:type="commands:Handler" xmi:id="_6slh0KmfEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.excel.distribution.OpenExcelDistributionImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.excel.distribution.OpenExcelDistributionImportWizard" command="_tpPnUKmfEeeTAPHmaMLwQQ"/>
126
    <elements xsi:type="commands:Handler" xmi:id="_wvx9oKmjEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.excel.taxa.OpenExcelTaxaImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.excel.taxa.OpenExcelTaxaImportWizard" command="_qAEkYKmjEeeTAPHmaMLwQQ"/>
127
    <elements xsi:type="commands:Handler" xmi:id="_96ANIKmsEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.ris.OpenRisImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.ris.OpenRisImportWizard" command="_tBCr8KmsEeeTAPHmaMLwQQ"/>
128
    <elements xsi:type="commands:Handler" xmi:id="_do2IAKmuEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.sdd.OpenSddImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.sdd.OpenSddImportWizard" command="_bLGTMKmuEeeTAPHmaMLwQQ"/>
129
    <elements xsi:type="commands:Handler" xmi:id="_6BmBEKnAEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.excel.specimen.OpenExcelSpecimenImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.excel.specimen.OpenExcelSpecimenImportWizard" command="_2JV9IKnAEeeTAPHmaMLwQQ"/>
130
    <elements xsi:type="commands:Handler" xmi:id="_Q8Z6gKnCEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.tcs.TcsImportWizardE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.tcs.TcsImportWizardE4" command="_OQ9n8KnCEeeTAPHmaMLwQQ"/>
124
    <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.in.abcd.OpenAbcdImportWizard" command="_QbHeEKmQEeeDJPU_cUTI2g"/>
125
    <elements xsi:type="commands:Handler" xmi:id="_6slh0KmfEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.excel.distribution.OpenExcelDistributionImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.in.excel.distribution.OpenExcelDistributionImportWizard" command="_tpPnUKmfEeeTAPHmaMLwQQ"/>
126
    <elements xsi:type="commands:Handler" xmi:id="_wvx9oKmjEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.excel.taxa.OpenExcelTaxaImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.in.excel.taxa.OpenExcelTaxaImportWizard" command="_qAEkYKmjEeeTAPHmaMLwQQ"/>
127
    <elements xsi:type="commands:Handler" xmi:id="_96ANIKmsEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.ris.OpenRisImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.in.ris.OpenRisImportWizard" command="_tBCr8KmsEeeTAPHmaMLwQQ"/>
128
    <elements xsi:type="commands:Handler" xmi:id="_do2IAKmuEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.sdd.OpenSddImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.in.sdd.OpenSddImportWizard" command="_bLGTMKmuEeeTAPHmaMLwQQ"/>
129
    <elements xsi:type="commands:Handler" xmi:id="_6BmBEKnAEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.excel.specimen.OpenExcelSpecimenImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.in.excel.specimen.OpenExcelSpecimenImportWizard" command="_2JV9IKnAEeeTAPHmaMLwQQ"/>
130
    <elements xsi:type="commands:Handler" xmi:id="_Q8Z6gKnCEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.tcs.TcsImportWizardE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.in.tcs.TcsImportWizardE4" command="_OQ9n8KnCEeeTAPHmaMLwQQ"/>
131 131
  </fragments>
132 132
  <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">
133 133
    <elements xsi:type="menu:Menu" xmi:id="_LT3P8IfcEeecZ4F2Y9Z0Og" elementId="eu.etaxonomy.taxeditor.store.menu.termeditor" label="Term Editor">
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/AbstractImportWizardE4.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.taxeditor.io.e4;
11

  
12
import javax.inject.Inject;
13
import javax.inject.Named;
14

  
15
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
16
import org.eclipse.e4.core.contexts.IEclipseContext;
17
import org.eclipse.e4.core.di.annotations.Optional;
18
import org.eclipse.e4.ui.services.IServiceConstants;
19
import org.eclipse.e4.ui.workbench.modeling.EPartService;
20
import org.eclipse.jface.dialogs.MessageDialog;
21
import org.eclipse.jface.viewers.IStructuredSelection;
22
import org.eclipse.jface.wizard.IWizardContainer;
23
import org.eclipse.jface.wizard.Wizard;
24
import org.eclipse.swt.SWT;
25

  
26
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
27
import eu.etaxonomy.cdm.io.common.IIoConfigurator;
28
import eu.etaxonomy.taxeditor.l10n.Messages;
29

  
30
/**
31
 *
32
 * @author pplitzner
33
 * @since Oct 5, 2017
34
 *
35
 * @param <CONFIG>
36
 */
37
public abstract class AbstractImportWizardE4<CONFIG extends IIoConfigurator> extends Wizard {
38

  
39
	protected GenericConfiguratorWizardPageE4 pageConfiguration;
40
	private NomenclaturalCodeWizardPageE4 pageNomenclaturalCode;
41

  
42
	protected IStructuredSelection selection;
43

  
44
    protected IEclipseContext context;
45

  
46
    private EPartService partService;
47

  
48
    @Inject
49
    public AbstractImportWizardE4(IEclipseContext context, EPartService partService) {
50
        this(context, partService, null);
51
    }
52

  
53
	@Inject
54
    public AbstractImportWizardE4(IEclipseContext context, EPartService partService,
55
            @Optional@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection) {
56
	    this.context = context;
57
	    this.partService = partService;
58
	    this.selection = selection;
59
    }
60

  
61
	/** {@inheritDoc} */
62
	@Override
63
	public void addPages() {
64
		super.addPages();
65

  
66
		addConfiguratorPage();
67

  
68
		pageNomenclaturalCode = ContextInjectionFactory.make(NomenclaturalCodeWizardPageE4.class, context);
69
		pageNomenclaturalCode.setConfigurator((IImportConfigurator)getConfigurator());
70
		this.addPage(pageNomenclaturalCode);
71
	}
72

  
73
	protected void addConfiguratorPage(){
74
		pageConfiguration = ContextInjectionFactory.make(GenericConfiguratorWizardPageE4.class, context);
75
		pageConfiguration.initImport(getConfigurator(), null, Messages.AbstractImportWizard_ConfigurationLabel);
76
		this.addPage(pageConfiguration);
77
	}
78

  
79
	@Override
80
	public void setContainer(IWizardContainer wizardContainer) {
81
		if(existUnsavedEditors()){
82
		    MessageDialog.open(MessageDialog.WARNING, getShell(), "Unsaved editors", "Please save all open editors before executing " +
83
		            "an import operation. The import operation will be cancelled", SWT.NONE);
84
		}
85
		else{
86
		    super.setContainer(wizardContainer);
87
		}
88
	}
89

  
90
	public abstract void init();
91

  
92
	protected boolean existUnsavedEditors(){
93
	    return !partService.getDirtyParts().isEmpty();
94
	}
95

  
96
	@Override
97
	public boolean canFinish() {
98
		return !existUnsavedEditors() && super.canFinish();
99
	}
100

  
101
	public abstract CONFIG getConfigurator();
102

  
103
	public void setSelection(IStructuredSelection selection) {
104
		this.selection = selection;
105
	}
106

  
107
	public IStructuredSelection getSelection() {
108
		return selection;
109
	}
110

  
111
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/AbstractOpenImportWizard.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.io.e4;
10

  
11
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
12
import org.eclipse.e4.core.contexts.IEclipseContext;
13
import org.eclipse.e4.core.di.annotations.Execute;
14
import org.eclipse.jface.wizard.WizardDialog;
15
import org.eclipse.swt.widgets.Shell;
16

  
17
/**
18
 * @author pplitzner
19
 * @since Oct 5, 2017
20
 *
21
 */
22
public abstract class AbstractOpenImportWizard {
23
    @Execute
24
    public void execute(IEclipseContext ctx, Shell s)
25
    {
26
        AbstractImportWizardE4 wizard = ContextInjectionFactory.make(getImportWizardClass(), ctx);
27
        wizard.init();
28
        WizardDialog dialog = new WizardDialog(s, wizard);
29
        dialog.open();
30
    }
31

  
32
    protected abstract Class<? extends AbstractImportWizardE4> getImportWizardClass();
33

  
34
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/GenericConfiguratorWizardPageE4.java
1
/**
2
 * Copyright (C) 2007 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9

  
10
package eu.etaxonomy.taxeditor.io.e4;
11

  
12
import java.lang.reflect.Method;
13
import java.util.ArrayList;
14
import java.util.Collections;
15
import java.util.Comparator;
16
import java.util.List;
17
import java.util.MissingResourceException;
18
import java.util.ResourceBundle;
19

  
20
import javax.inject.Inject;
21

  
22
import org.apache.commons.lang.StringUtils;
23
import org.eclipse.jface.wizard.WizardPage;
24
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.events.SelectionAdapter;
26
import org.eclipse.swt.events.SelectionEvent;
27
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.layout.GridLayout;
29
import org.eclipse.swt.widgets.Button;
30
import org.eclipse.swt.widgets.Composite;
31

  
32
import eu.etaxonomy.cdm.io.common.IIoConfigurator;
33
import eu.etaxonomy.taxeditor.model.MessagingUtils;
34

  
35
/**
36
 *
37
 * @author pplitzner
38
 * @since Oct 5, 2017
39
 *
40
 */
41
public class GenericConfiguratorWizardPageE4 extends WizardPage {
42

  
43
    private IIoConfigurator configurator;
44
    private ResourceBundle resourceBundle;
45
    private List<String> ignoreMethods;
46

  
47
    @Inject
48
    public GenericConfiguratorWizardPageE4() {
49
        super("Configuration");
50
    }
51

  
52
    private void init(String title, String description, IIoConfigurator configurator, List<String> ignoreMethods){
53
        this.setTitle(title);
54
        this.setDescription(description);
55
        this.configurator = configurator;
56
        this.ignoreMethods = ignoreMethods;
57
        resourceBundle = getResourceBundle(configurator);
58
    }
59

  
60
    private ResourceBundle getResourceBundle(IIoConfigurator configurator){
61
        try{
62
            if (configurator != null){
63
                return ResourceBundle.getBundle(configurator.getClass().getName());
64
            }else{
65
                return ResourceBundle.getBundle("Configuration");
66
            }
67
        }catch(MissingResourceException e){
68
            return null;
69
        }
70
    }
71

  
72
    public void initImport(IIoConfigurator configurator, List<String> ignoreMethods, String label) {
73
        init("Import Configuration", label, configurator, ignoreMethods);
74
    }
75

  
76
    public void initExport(IIoConfigurator configurator, List<String> ignoreMethods) {
77
        init("Export Configuration", "Configure the export mechanism.", configurator, ignoreMethods);
78
    }
79

  
80
    /** {@inheritDoc} */
81
    @Override
82
    public void createControl(Composite parent) {
83

  
84
        // TODO wrap this composite in a scrolled composite
85
        Composite composite = new Composite(parent, SWT.NULL);
86
        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
87

  
88
        GridLayout gridLayout = new GridLayout();
89
        composite.setLayout(gridLayout);
90

  
91
        List<Method> methods = getConfiguratorsBooleanSetMethods(configurator);
92
        Collections.sort(methods, new Comparator<Method>() {
93
            @Override
94
            public int compare(Method o1, Method o2) {
95
                if (o1.equals(o2)){
96
                    return 0;
97
                }
98
                if(o1.getName()==null && o2.getName()!=null){
99
                    return -1;
100
                }
101
                if(o1.getName()!=null && o2.getName()==null){
102
                    return 1;
103
                }
104
                if(o1.getName()==null && o2.getName()==null){
105
                    return o1.toString().compareTo(o1.toString());
106
                }
107
                int result = o1.getName().compareTo(o2.getName());
108
                if (result == 0){
109
                    return o1.toString().compareTo(o1.toString());
110
                }
111
                return result;
112
            }
113
        });
114

  
115
	        for (Method method : methods) {
116
	        	if (ignoreMethods != null){
117
		            if (!ignoreMethods.contains( method.getName())) {
118
		                createCheckbox(composite, method, configurator);
119
		            }
120
	        	}else{
121
	        		createCheckbox(composite, method, configurator);
122
	        	}
123

  
124
	        }
125

  
126
        setControl(composite);
127
    }
128

  
129
    private void createCheckbox(Composite parent, Method method,
130
            final IIoConfigurator configurator) {
131

  
132
        final String methodName = method.getName();
133
        final Button checkBox = new Button(parent, SWT.CHECK);
134

  
135
       // if(configurator.getClass().equals(Abcd206ImportConfigurator.class)){
136
            String[] r = methodName.split("set")[1].split("(?=\\p{Upper})");
137
            checkBox.setText(getLabel(StringUtils.join(r," ")));
138
//        }
139
//        else{
140
//            checkBox.setText(getLabel(methodName));
141
//        }
142
        // retrieve the default values and set the checkbox accordingly
143
        boolean defaultSelection = executeBooleanGetMethod(configurator, "is"
144
                + methodName.substring(3));
145
        checkBox.setSelection(defaultSelection);
146
        checkBox.addSelectionListener(new SelectionAdapter() {
147

  
148
            @Override
149
            public void widgetSelected(SelectionEvent e) {
150
                executeBooleanSetMethod(configurator, methodName,
151
                        checkBox.getSelection());
152
            }
153

  
154
        });
155

  
156
    }
157

  
158
    private String getLabel(String methodName){
159

  
160
        if(resourceBundle == null){
161
            return methodName;
162
        }
163

  
164
        try{
165
            return resourceBundle.getString(methodName);
166
        }catch(MissingResourceException e){
167
            return methodName;
168
        }
169
    }
170

  
171
    private boolean executeBooleanGetMethod(IIoConfigurator configurator,
172
            String methodName) {
173

  
174
        Class<? extends IIoConfigurator> configuratorClass = configurator
175
                .getClass();
176

  
177
        boolean result = false;
178

  
179
        Method[] methods = configuratorClass.getMethods();
180

  
181
        for (Method method : methods) {
182
            if (!method.getName().equals(methodName)) {
183
                continue;
184
            }
185

  
186
            try {
187
                Object returnType = method.invoke(configurator, null);
188
                if (returnType.getClass().equals(Boolean.class)) {
189
                    result = ((Boolean) returnType).booleanValue();
190
                }
191

  
192
                break;
193
            } catch (Exception e) {
194
                MessagingUtils.warn(this.getClass(), "Could not invoke method");
195
            }
196
        }
197

  
198
        return result;
199
    }
200

  
201
    private void executeBooleanSetMethod(IIoConfigurator configurator,
202
            String methodName, boolean selected) {
203

  
204
        Class<? extends IIoConfigurator> configuratorClass = configurator
205
                .getClass();
206

  
207
        Method[] methods = configuratorClass.getMethods();
208

  
209
        for (Method method : methods) {
210
            if (!method.getName().equals(methodName)) {
211
                continue;
212
            }
213

  
214
            try {
215
                method.invoke(configurator, selected);
216

  
217
                break;
218
            } catch (Exception e) {
219
                MessagingUtils.warn(this.getClass(), "Could not invoke method");
220
            }
221
        }
222
    }
223

  
224
    private List<Method> getConfiguratorsBooleanSetMethods(
225
            IIoConfigurator configurator) {
226
        List<Method> booleanMethods = new ArrayList<Method>();
227

  
228
        Class<? extends IIoConfigurator> configuratorClass = configurator
229
                .getClass();
230

  
231
        Method[] allMethods = configuratorClass.getMethods();
232

  
233
        for (Method method : allMethods) {
234
            if (method.getName().startsWith("set")) {
235

  
236
                Class<?>[] typeList = method.getParameterTypes();
237

  
238
                if (typeList.length > 1) {
239
                    new IllegalStateException(
240
                            "Found a setter with parameter count > 1");
241
                }
242

  
243
                if (typeList[0].getName().equals("boolean")) {
244
                    booleanMethods.add(method);
245
                }
246
            }
247
        }
248

  
249
        return booleanMethods;
250
    }
251
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/ImportFromFileAndChooseVocIdWizardPageE4.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.io.e4;
10

  
11
import java.util.List;
12
import java.util.UUID;
13

  
14
import javax.inject.Inject;
15

  
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.events.SelectionAdapter;
18
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.layout.GridData;
20
import org.eclipse.swt.widgets.Combo;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Label;
23

  
24
import eu.etaxonomy.cdm.api.service.IVocabularyService;
25
import eu.etaxonomy.cdm.common.CdmUtils;
26
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
27
import eu.etaxonomy.cdm.model.common.TermType;
28
import eu.etaxonomy.cdm.model.common.TermVocabulary;
29
import eu.etaxonomy.taxeditor.l10n.Messages;
30
import eu.etaxonomy.taxeditor.store.CdmStore;
31

  
32
/**
33
 * @author k.luther
34
 * @date 04.05.2017
35
 *
36
 */
37
public class ImportFromFileAndChooseVocIdWizardPageE4 extends ImportFromFileDataSourceWizardPageE4 {
38

  
39
    private Combo vocabularyCombo;
40
    UUID vocUuid;
41
    String[][] labelAndValues;
42

  
43
    @Inject
44
    public ImportFromFileAndChooseVocIdWizardPageE4() {
45
        super();
46
        setTitle("Choose Excel File");
47
        setDescription("Please choose an xls file in the Distribution Update format.");
48
        setExtensions(new String[]{"*.xlsx", "*.xls", "*.*"});
49

  
50
    }
51

  
52
    @Override
53
    public void createControl(Composite parent) {
54
        super.createControl(parent);
55
        Composite composite = (Composite)getControl();
56
      //  final Composite composite = new Composite(parent, SWT.NULL);
57
        GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
58
        composite.setLayoutData(gridData);
59
        Label label = new Label(composite, SWT.NONE);
60
        label.setText(Messages.ImportFromFileAndChooseVocIdWizardPage_AreaVoc);
61
        label.setToolTipText(Messages.ImportFromFileAndChooseVocIdWizardOage_AreaVoc_toolTip);
62
        vocabularyCombo = new Combo(composite, SWT.DROP_DOWN);
63
        List<TermVocabulary<DefinedTermBase>> vocs = CdmStore.getService(IVocabularyService.class).findByTermType(TermType.NamedArea, null);
64
        for(TermVocabulary voc: vocs){
65
            vocabularyCombo.add(voc.getLabel());
66
        }
67
        getLabelAndValues(vocs);
68
        vocabularyCombo.select(0);
69
        vocabularyCombo.addSelectionListener(new SelectionAdapter(){
70

  
71
            @Override
72
            public void widgetSelected(SelectionEvent e) {
73
                String name = vocabularyCombo.getText();
74

  
75
                for (String[] labelAndValue: labelAndValues){
76
                    if (labelAndValue[0].equals(name)){
77
                        String uuidString = labelAndValue[1];
78
                        vocUuid = UUID.fromString(uuidString);
79
                        setPageComplete(isPageComplete());
80
                    }
81
                }
82

  
83
            }
84

  
85
        });
86
    }
87

  
88
    public UUID getVocUuid() {
89
        return vocUuid;
90
    }
91

  
92
    public void setVocUuid(UUID vocUuid) {
93
        this.vocUuid = vocUuid;
94
    }
95

  
96
    private String[][] getLabelAndValues(List<TermVocabulary<DefinedTermBase>> vocs) {
97

  
98
        labelAndValues = new String[vocs.size()][2];
99
        for (int i = 0; i < vocs.size(); i++) {
100
            labelAndValues[i][0] = vocs.get(i).getLabel();
101
            labelAndValues[i][1] = vocs.get(i).getUuid().toString();
102
        }
103
        return labelAndValues;
104
    }
105

  
106
    @Override
107
    public boolean isPageComplete() {
108
        boolean result = CdmUtils.isNotBlank(text_source.getText()) && vocUuid != null;
109

  
110
        return result;
111
    }
112

  
113
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/ImportFromFileDataSourceWizardPageE4.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.taxeditor.io.e4;
11

  
12
import java.io.File;
13
import java.net.URI;
14

  
15
import javax.inject.Inject;
16

  
17
import org.eclipse.jface.wizard.WizardPage;
18
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.events.SelectionAdapter;
20
import org.eclipse.swt.events.SelectionEvent;
21
import org.eclipse.swt.layout.GridData;
22
import org.eclipse.swt.layout.GridLayout;
23
import org.eclipse.swt.widgets.Button;
24
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.FileDialog;
26
import org.eclipse.swt.widgets.Label;
27
import org.eclipse.swt.widgets.Text;
28

  
29
import eu.etaxonomy.cdm.common.CdmUtils;
30

  
31
/**
32
 *
33
 * @author pplitzner
34
 * @since Oct 5, 2017
35
 *
36
 */
37
public class ImportFromFileDataSourceWizardPageE4 extends WizardPage {
38

  
39
	public static final String PAGE_NAME = "CdmXmlDataSourceWizardPage";
40

  
41
	private String[] extensions = {"*.xml"};
42

  
43
	private FileDialog fileDialog;
44
	private Text textReferenceString;
45

  
46
    protected Text text_source;
47

  
48
    @Inject
49
	public ImportFromFileDataSourceWizardPageE4() {
50
		super(PAGE_NAME);
51

  
52
		setTitle("Xml File");
53

  
54
		setDescription("Select XML file.");
55

  
56
		setExtensions(new String[]{"*.xml","*.*"});
57
	}
58

  
59
    public void setExtensions(String[] extensions) {
60
        this.extensions = extensions;
61
    }
62

  
63
	/** {@inheritDoc} */
64
	@Override
65
    public void createControl(Composite parent) {
66
		final Composite composite = new Composite(parent, SWT.NULL);
67

  
68
		setPageComplete(false);
69

  
70
		GridLayout gridLayout = new GridLayout();
71
		gridLayout.numColumns = 3;
72
		composite.setLayout(gridLayout);
73

  
74
		Label folderLabel = new Label(composite, SWT.NONE);
75
		folderLabel.setText("File");
76

  
77
		fileDialog = new FileDialog(parent.getShell());
78

  
79
		fileDialog.setFilterExtensions(extensions);
80

  
81
		text_source = new Text(composite, SWT.BORDER);
82
		text_source.setEditable(false);
83
		text_source.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
84

  
85

  
86
		Button button = new Button(composite, SWT.PUSH);
87
		button.setText("Browse...");
88

  
89
		button.addSelectionListener(new SelectionAdapter(){
90

  
91
			@Override
92
			public void widgetSelected(SelectionEvent e) {
93
				String path = fileDialog.open();
94
				if(path!=null){
95
				    text_source.setText(path);
96
				    setPageComplete(isPageComplete());
97
				}
98
			}
99

  
100
		});
101

  
102
		Label labelRef = new Label(composite, SWT.NONE);
103
        labelRef.setText("Default import souce reference");
104
        labelRef.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
105
        textReferenceString = new Text(composite, SWT.NONE);
106
        textReferenceString.setEnabled(true);
107
        GridData gd_textReferenceString = new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1);
108
        gd_textReferenceString.widthHint = 229;
109
        textReferenceString.setLayoutData(gd_textReferenceString);
110
		setControl(composite);
111
	}
112

  
113
	public File getFile() {
114
		return new File(text_source.getText());
115
	}
116

  
117
	public Text getTextReferenceString() {
118
		return textReferenceString;
119
	}
120

  
121
	public void setTextReferenceString(Text textReferenceString) {
122
		this.textReferenceString = textReferenceString;
123
	}
124

  
125
    public URI getUri() {
126
		return getFile().toURI();
127
	}
128

  
129
	@Override
130
	public boolean isPageComplete() {
131
		return CdmUtils.isNotBlank(text_source.getText());
132
	}
133

  
134
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/NomenclaturalCodeWizardPageE4.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.taxeditor.io.e4;
11

  
12
import javax.inject.Inject;
13

  
14
import org.eclipse.jface.wizard.WizardPage;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.events.SelectionAdapter;
17
import org.eclipse.swt.events.SelectionEvent;
18
import org.eclipse.swt.layout.FillLayout;
19
import org.eclipse.swt.layout.GridLayout;
20
import org.eclipse.swt.widgets.Button;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Group;
23

  
24
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
25
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
26
import eu.etaxonomy.taxeditor.model.NomenclaturalCodeHelper;
27
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
28

  
29
/**
30
 *
31
 * @author p.ciardelli
32
 * @created 11.09.2009
33
 * @version 1.0
34
 */
35
public class NomenclaturalCodeWizardPageE4 extends WizardPage {
36

  
37
    private IImportConfigurator configurator;
38

  
39
    @Inject
40
	public NomenclaturalCodeWizardPageE4() {
41
		super("Choose nomenclatural code");
42

  
43
		this.setTitle("Choose nomenclatural code");
44

  
45
		this.setDescription("Choose which code to use for imported names.");
46
	}
47

  
48
    public void setConfigurator(IImportConfigurator configurator) {
49
        this.configurator = configurator;
50
    }
51

  
52
	/** {@inheritDoc} */
53
	@Override
54
    public void createControl(Composite parent) {
55
		Composite container = new Composite(parent, SWT.NULL);
56
		container.setLayout(new FillLayout());
57

  
58
		final Group group = new Group(container, SWT.NONE);
59
		group.setLayout(new GridLayout());
60

  
61
		NomenclaturalCode preferredCode = PreferencesUtil.getPreferredNomenclaturalCode(false);
62

  
63
		// set preferred code as default
64
		configurator.setNomenclaturalCode(preferredCode);
65

  
66
		for (final NomenclaturalCode code : NomenclaturalCodeHelper.getSupportedCodes()) {
67
			Button button = new Button(group, SWT.RADIO);
68
			button.setText(NomenclaturalCodeHelper.getDescription(code));
69
			button.setData(code);
70
			button.setSelection(preferredCode.equals(code));
71
			button.addSelectionListener(new SelectionAdapter() {
72
				@Override
73
                public void widgetSelected(SelectionEvent e) {
74
					configurator.setNomenclaturalCode((NomenclaturalCode) e.widget.getData());
75
				}
76
			});
77
		}
78
		setControl(container);
79
	}
80

  
81
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/abcd/AbcdImportConfiguratorWizardPageE4.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.taxeditor.io.e4.abcd;
11

  
12
import javax.inject.Inject;
13

  
14
import org.eclipse.jface.preference.IPreferenceStore;
15
import org.eclipse.jface.wizard.WizardPage;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.events.SelectionAdapter;
18
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.layout.GridLayout;
20
import org.eclipse.swt.widgets.Button;
21
import org.eclipse.swt.widgets.Composite;
22

  
23
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
24
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
25
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
26

  
27
/**
28
 *
29
 * @author pplitzner
30
 *
31
 */
32
public class AbcdImportConfiguratorWizardPageE4 extends WizardPage {
33

  
34
	public static final String PAGE_NAME = "AbcdImportConfiguratorWizardPage";
35

  
36
	private Abcd206ImportConfigurator configurator;
37

  
38
	@Inject
39
	public AbcdImportConfiguratorWizardPageE4() {
40
        super(PAGE_NAME);
41
        setTitle("Configure import parameters");
42
        setDescription("Tooltips will explain parameters in more detail");
43
    }
44

  
45
//	protected AbcdImportConfiguratorWizardPageE4(String title, String description, Abcd206ImportConfigurator configurator, boolean isPreferencePage) {
46
//		super(PAGE_NAME);
47
//		this.configurator = configurator;
48
//		setTitle(title);
49
//		setDescription(description);
50
//		this.isPreferencePage = isPreferencePage;
51
//	}
52
//
53
//	public static AbcdImportConfiguratorWizardPageE4 createPreferencePage(Abcd206ImportConfigurator configurator){
54
//        return new AbcdImportConfiguratorWizardPageE4("Configure import parameters",
55
//                "Tooltips will explain parameters in more detail", configurator, true);
56
//    }
57

  
58

  
59

  
60
	/** {@inheritDoc} */
61
	@Override
62
    public void createControl(Composite parent) {
63
		final Composite composite = new Composite(parent, SWT.NULL);
64
		//composite = addTab(Messages.DatabasePreferencesPage_Define_Default_NomenclaturalCode);
65
		GridLayout gridLayout = new GridLayout();
66
		composite.setLayout(gridLayout);
67
//        if (isPreferencePage){
68
//            ListComponent list = new ListComponent(composite, composite.getStyle());
69
//        }
70

  
71
		Button checkBoxMediaSpecimen = new Button(composite, SWT.CHECK);
72
		checkBoxMediaSpecimen.setSelection(configurator.isAddMediaAsMediaSpecimen());
73
		checkBoxMediaSpecimen.setText("Import media as media specimen");
74
		checkBoxMediaSpecimen
75
				.setToolTipText("Any media attached to a ABCD unit will be imported as a sub derivative of the specimen created from this unit");
76
		checkBoxMediaSpecimen.addSelectionListener(new SelectionAdapter() {
77
			@Override
78
			public void widgetSelected(SelectionEvent e) {
79
				configurator.setAddMediaAsMediaSpecimen(!configurator.isAddMediaAsMediaSpecimen());
80
			}
81
		});
82

  
83
		Button checkBoxIgnoreExisting = new Button(composite, SWT.CHECK);
84
		checkBoxIgnoreExisting.setSelection(configurator.isIgnoreImportOfExistingSpecimen());
85
		checkBoxIgnoreExisting.setText("Do not import existing specimens");
86
		checkBoxIgnoreExisting
87
		.setToolTipText("Specimens that have previously been imported will be ignored in this import");
88
		checkBoxIgnoreExisting.addSelectionListener(new SelectionAdapter() {
89
			@Override
90
			public void widgetSelected(SelectionEvent e) {
91
				configurator.setIgnoreImportOfExistingSpecimen(!configurator.isIgnoreImportOfExistingSpecimen());
92
			}
93
		});
94

  
95
		Button checkBoxIgnoreAuthorship = new Button(composite, SWT.CHECK);
96
		checkBoxIgnoreAuthorship.setSelection(configurator.isIgnoreAuthorship());
97
		checkBoxIgnoreAuthorship.setText("Ignore Authorship for name matching");
98
		checkBoxIgnoreAuthorship
99
		.setToolTipText("Name matching with existing names will be done without "
100
				+ "the authorship part of the name");
101
		checkBoxIgnoreAuthorship.addSelectionListener(new SelectionAdapter() {
102
			@Override
103
			public void widgetSelected(SelectionEvent e) {
104
				configurator.setIgnoreAuthorship(!configurator.isIgnoreAuthorship());
105
			}
106
		});
107

  
108
		Button checkBoxMapUnitIdToCatalogNumber = new Button(composite, SWT.CHECK);
109
		checkBoxMapUnitIdToCatalogNumber.setSelection(configurator.isMapUnitIdToCatalogNumber());
110
		checkBoxMapUnitIdToCatalogNumber.setText("Map UnitID to catalog number");
111
		checkBoxMapUnitIdToCatalogNumber
112
		.setToolTipText("The UnitID of every ABCD unit will be mapped the catalog number "
113
				+ "of the specimen");
114
		checkBoxMapUnitIdToCatalogNumber.addSelectionListener(new SelectionAdapter() {
115
			@Override
116
			public void widgetSelected(SelectionEvent e) {
117
				configurator.setMapUnitIdToCatalogNumber(!configurator.isMapUnitIdToCatalogNumber());
118
			}
119
		});
120
//TODO: only one of the mappings can be checked!
121
		Button checkBoxMapUnitIdToAccessionNumber = new Button(composite, SWT.CHECK);
122
		checkBoxMapUnitIdToAccessionNumber.setSelection(configurator.isMapUnitIdToAccessionNumber());
123
		checkBoxMapUnitIdToAccessionNumber.setText("Map UnitID to accession number");
124
		checkBoxMapUnitIdToAccessionNumber
125
		.setToolTipText("The UnitID of every ABCD unit will be mapped the accession number "
126
				+ "of the specimen");
127
		checkBoxMapUnitIdToAccessionNumber.addSelectionListener(new SelectionAdapter() {
128
			@Override
129
			public void widgetSelected(SelectionEvent e) {
130
				configurator.setMapUnitIdToAccessionNumber(!configurator.isMapUnitIdToAccessionNumber());
131
			}
132
		});
133

  
134
		Button checkBoxMapUnitIdToBarcode = new Button(composite, SWT.CHECK);
135
		checkBoxMapUnitIdToBarcode.setSelection(configurator.isMapUnitIdToBarcode());
136
		checkBoxMapUnitIdToBarcode.setText("Map UnitID to barcode");
137
		checkBoxMapUnitIdToBarcode
138
		.setToolTipText("The UnitID of every ABCD unit will be mapped the barcode "
139
				+ "of the specimen");
140
		checkBoxMapUnitIdToBarcode.addSelectionListener(new SelectionAdapter() {
141
			@Override
142
			public void widgetSelected(SelectionEvent e) {
143
				configurator.setMapUnitIdToBarcode(!configurator.isMapUnitIdToBarcode());
144
			}
145
		});
146

  
147
		Button checkBoxRemoveCountry = new Button(composite, SWT.CHECK);
148
		checkBoxRemoveCountry.setSelection(configurator.isRemoveCountryFromLocalityText());
149
		checkBoxRemoveCountry.setText("Remove country from locality text");
150
		checkBoxRemoveCountry
151
		.setToolTipText("If the locality text contains information about the "
152
				+ "country which is additionally stored in other ABCD "
153
				+ "elements then it is removed from the locality text");
154
		checkBoxRemoveCountry.addSelectionListener(new SelectionAdapter() {
155
			@Override
156
			public void widgetSelected(SelectionEvent e) {
157
				configurator.setRemoveCountryFromLocalityText(!configurator.isRemoveCountryFromLocalityText());
158
			}
159
		});
160

  
161
		Button checkBoxMoveToDefaultClassification = new Button(composite, SWT.CHECK);
162
		checkBoxMoveToDefaultClassification.setSelection(configurator.isMoveNewTaxaToDefaultClassification());
163
		checkBoxMoveToDefaultClassification.setText("Create new classification for new taxa");
164
		checkBoxMoveToDefaultClassification
165
		.setToolTipText("For taxa that do not exist in the data base "
166
				+ "a new classification will be created");
167
		checkBoxMoveToDefaultClassification.addSelectionListener(new SelectionAdapter() {
168
			@Override
169
			public void widgetSelected(SelectionEvent e) {
170
				configurator.setMoveNewTaxaToDefaultClassification(!configurator.isMoveNewTaxaToDefaultClassification());
171
			}
172
		});
173

  
174
		Button checkBoxImportSiblings = new Button(composite, SWT.CHECK);
175
		checkBoxImportSiblings.setSelection(configurator.isGetSiblings());
176
		checkBoxImportSiblings.setText("Import all children of cultures or tissue samples");
177
		checkBoxImportSiblings
178
        	.setToolTipText("For a tissue sample or culture all children will be searched and imported");
179
		checkBoxImportSiblings.addSelectionListener(new SelectionAdapter() {
180
            @Override
181
            public void widgetSelected(SelectionEvent e) {
182
                configurator.setGetSiblings(checkBoxImportSiblings.getSelection());
183
            }
184
        });
185

  
186
        Button checkBoxAddIndividualsAssociations = new Button(composite, SWT.CHECK);
187
        checkBoxAddIndividualsAssociations.setSelection(configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
188
        checkBoxAddIndividualsAssociations.setText("Create an Individual Association for each Specimen");
189
        checkBoxAddIndividualsAssociations
190
        	.setToolTipText("For each specimen associated to a taxon an indiviadual association to this taxon is created");
191
        checkBoxAddIndividualsAssociations.addSelectionListener(new SelectionAdapter() {
192
            @Override
193
            public void widgetSelected(SelectionEvent e) {
194
                configurator.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(!configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
195
            }
196
        });
197

  
198
        Button checkBoxReuseDescriptiveGroups = new Button(composite, SWT.CHECK);
199
        checkBoxReuseDescriptiveGroups.setSelection(configurator.isReuseExistingDescriptiveGroups());
200
        checkBoxReuseDescriptiveGroups.setText("Reuse existing descriptive group");
201
        checkBoxReuseDescriptiveGroups
202
        	.setToolTipText("Reuse one of the existing descriptive groups or create a new one for every import");
203
        checkBoxReuseDescriptiveGroups.addSelectionListener(new SelectionAdapter() {
204
            @Override
205
            public void widgetSelected(SelectionEvent e) {
206
                configurator.setReuseExistingDescriptiveGroups(!configurator.isReuseExistingDescriptiveGroups());
207
            }
208
        });
209

  
210
        Button checkBoxReuseExistingTaxa = new Button(composite, SWT.CHECK);
211
        checkBoxReuseExistingTaxa.setSelection(configurator.isReuseExistingTaxaWhenPossible());
212
        checkBoxReuseExistingTaxa.setText("Reuse existing taxa when possible");
213
        checkBoxReuseExistingTaxa
214
        	.setToolTipText("Reuse existing taxa when the name matches the identified name of the specimen");
215
        checkBoxReuseExistingTaxa.addSelectionListener(new SelectionAdapter() {
216
            @Override
217
            public void widgetSelected(SelectionEvent e) {
218
                configurator.setReuseExistingDescriptiveGroups(!configurator.isReuseExistingDescriptiveGroups());
219
            }
220
        });
221

  
222

  
223
		setControl(composite);
224
	}
225

  
226
	 public void saveConfigToPrefernceStore() {
227
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS,
228
	                configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
229
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN,
230
                    configurator.isAddMediaAsMediaSpecimen());
231
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS,
232
                    configurator.isAllowReuseOtherClassifications());
233
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS,
234
                    configurator.isDeduplicateClassifications());
235
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES,
236
                    configurator.isDeduplicateReferences());
237
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS,
238
                    configurator.isGetSiblings());
239
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP,
240
                    configurator.isIgnoreAuthorship());
241
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN,
242
                    configurator.isIgnoreImportOfExistingSpecimen());
243
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER,
244
                    configurator.isMapUnitIdToAccessionNumber());
245
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE,
246
                    configurator.isMapUnitIdToBarcode());
247
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER,
248
                    configurator.isMapUnitIdToCatalogNumber());
249
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION,
250
                    configurator.isMoveNewTaxaToDefaultClassification());
251
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN,
252
                    configurator.isOverwriteExistingSpecimens());
253
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS,
254
                    configurator.isReuseExistingDescriptiveGroups());
255
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA,
256
                    configurator.isReuseExistingMetaData());
257
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE,
258
                    configurator.isReuseExistingTaxaWhenPossible());
259

  
260
	    }
261

  
262
	 public String createConfigString(){
263
	    return configurator.toString();
264

  
265
	 }
266

  
267
    public void setConfigurator(Abcd206ImportConfigurator configurator) {
268
        this.configurator = configurator;
269
    }
270

  
271
	 protected IPreferenceStore doGetPreferenceStore() {
272
	        return PreferencesUtil.getPreferenceStore();
273
	    }
274
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/abcd/AbcdImportWizardE4.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.taxeditor.io.e4.abcd;
11

  
12
import java.io.File;
13
import java.net.URI;
14

  
15
import javax.inject.Inject;
16

  
17
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
18
import org.eclipse.e4.core.contexts.IEclipseContext;
19
import org.eclipse.e4.ui.workbench.modeling.EPartService;
20

  
21
import eu.etaxonomy.cdm.database.DbSchemaValidation;
22
import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
23
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
24
import eu.etaxonomy.taxeditor.io.e4.AbstractImportWizardE4;
25
import eu.etaxonomy.taxeditor.io.e4.ImportFromFileDataSourceWizardPageE4;
26
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
27
import eu.etaxonomy.taxeditor.store.CdmStore;
28

  
29
/**
30
 *
31
 * @author pplitzner
32
 * @since Oct 5, 2017
33
 *
34
 */
35
public class AbcdImportWizardE4 extends AbstractImportWizardE4<Abcd206ImportConfigurator> {
36

  
37
	private Abcd206ImportConfigurator configurator;
38
	private ImportFromFileDataSourceWizardPageE4 dataSourcePage;
39
	private ClassificationChooserWizardPageE4 classificationChooserWizardPage;
40

  
41
	@Inject
42
	public AbcdImportWizardE4(IEclipseContext context, EPartService partService) {
43
	    super(context, partService);
44
	}
45

  
46
	/** {@inheritDoc} */
47
	@Override
48
	public Abcd206ImportConfigurator getConfigurator() {
49
		return configurator;
50
	}
51

  
52
	/** {@inheritDoc} */
53
	@Override
54
	public boolean performFinish() {
55
	    URI source = dataSourcePage.getUri();
56
	    configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
57

  
58
	    if(classificationChooserWizardPage.getClassification()!=null){
59
	        configurator.setClassificationUuid(classificationChooserWizardPage.getClassification().getUuid());
60
	    }
61

  
62
	    CdmStore.getImportManager().runMoniteredOperation(configurator, new File(source), SOURCE_TYPE.INPUTSTREAM);
63

  
64
	    return true;
65

  
66
	}
67

  
68
	/** {@inheritDoc} */
69
	@Override
70
    public void init() {
71
		configurator =  PreferencesUtil.getAbcdImportConfigurationPreference(true);
72
	}
73

  
74
	@Override
75
	protected void addConfiguratorPage() {
76
	    AbcdImportConfiguratorWizardPageE4 configuratorWizardPage = ContextInjectionFactory.make(AbcdImportConfiguratorWizardPageE4.class, context);//AbcdImportConfiguratorWizardPage.createPage(configurator);
77
	    configuratorWizardPage.setConfigurator(configurator);
78
		addPage(configuratorWizardPage);
79
	}
80

  
81
	/** {@inheritDoc} */
82
	@Override
83
	public void addPages() {
84
		super.addPages();
85

  
86
		classificationChooserWizardPage = ContextInjectionFactory.make(ClassificationChooserWizardPageE4.class, context);
87

  
88
		dataSourcePage = ContextInjectionFactory.make(ImportFromFileDataSourceWizardPageE4.class, context);
89

  
90
		addPage(classificationChooserWizardPage);
91
		addPage(dataSourcePage);
92
	}
93
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/abcd/ClassificationChooserWizardPageE4.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.taxeditor.io.e4.abcd;
11

  
12
import javax.inject.Inject;
13

  
14
import org.eclipse.jface.wizard.WizardPage;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.layout.GridData;
17
import org.eclipse.swt.layout.GridLayout;
18
import org.eclipse.swt.widgets.Button;
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.swt.widgets.Event;
21
import org.eclipse.swt.widgets.Label;
22
import org.eclipse.swt.widgets.Listener;
23
import org.eclipse.swt.widgets.Text;
24
import org.eclipse.wb.swt.ResourceManager;
25

  
26
import eu.etaxonomy.cdm.model.taxon.Classification;
27
import eu.etaxonomy.taxeditor.ui.dialog.selection.SelectionDialogFactory;
28

  
29
/**
30
 * <p>ImportFromFileDataSourceWizardPage class.</p>
31
 *
32
 * @author n.hoffmann
33
 * @created 04.08.2009
34
 * @version 1.0
35
 */
36
public class ClassificationChooserWizardPageE4 extends WizardPage implements Listener{
37

  
38
	public static final String PAGE_NAME = "ClassificationChooserWizardPage";
39

  
40
	//classification
41
    private Text textClassification;
42
    private Classification classification;
43
    private Button btnBrowseClassification;
44

  
45
    private Button btnClear;
46

  
47
    @Inject
48
	public ClassificationChooserWizardPageE4() {
49
		super(PAGE_NAME);
50

  
51
		setTitle("Configure import destinations");
52

  
53
		setDescription("Note: Selecting no classification will create a default one.");
54

  
55
	}
56

  
57
	/** {@inheritDoc} */
58
	@Override
59
    public void createControl(Composite parent) {
60
		final Composite composite = new Composite(parent, SWT.NULL);
61

  
62
		GridLayout gridLayout = new GridLayout();
63
		gridLayout.numColumns = 4;
64
		composite.setLayout(gridLayout);
65

  
66
		//classification
67
		Label label = new Label(composite, SWT.NONE);
68
		label.setText("Classification");
69
		textClassification = new Text(composite, SWT.NONE);
70
		textClassification.setEnabled(false);
71
		textClassification.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
72
		btnBrowseClassification = new Button(composite, SWT.NONE);
73
		btnBrowseClassification.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
74
		btnBrowseClassification.addListener(SWT.Selection, this);
75
		btnClear = new Button(composite, SWT.NONE);
76
		btnClear.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
77
		btnClear.addListener(SWT.Selection, this);
78

  
79
		setControl(composite);
80
	}
81

  
82
	@Override
83
	public void handleEvent(Event event) {
84
	    if(event.widget==btnBrowseClassification){
85
	        classification = SelectionDialogFactory.getSelectionFromDialog(Classification.class, getShell(), null, null);
86
	        if(classification!=null){
87
	            textClassification.setText(classification.getTitleCache());
88
	        }
89
	    }
90
	    else if(event.widget==btnClear){
91
	        classification = null;
92
	        textClassification.setText("");
93
	    }
94
	}
95

  
96
    /**
97
     * @return the classification
98
     */
99
    public Classification getClassification() {
100
        return classification;
101
    }
102

  
103
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/abcd/OpenAbcdImportWizard.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.io.e4.abcd;
10

  
11
import eu.etaxonomy.taxeditor.io.e4.AbstractImportWizardE4;
12
import eu.etaxonomy.taxeditor.io.e4.AbstractOpenImportWizard;
13

  
14
/**
15
 * @author pplitzner
16
 * @since Oct 5, 2017
17
 *
18
 */
19
public class OpenAbcdImportWizard extends AbstractOpenImportWizard {
20

  
21
    /**
22
     * {@inheritDoc}
23
     */
24
    @Override
25
    protected Class<? extends AbstractImportWizardE4> getImportWizardClass() {
26
        return AbcdImportWizardE4.class;
27
    }
28

  
29
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/excel/distribution/ExcelDistributionUpdateWizardE4.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.io.e4.excel.distribution;
10

  
11
import java.io.File;
12
import java.io.FileInputStream;
13
import java.io.FileNotFoundException;
14
import java.io.IOException;
15
import java.net.URI;
16
import java.util.ArrayList;
17
import java.util.List;
18
import java.util.UUID;
19

  
20
import javax.inject.Inject;
21

  
22
import org.apache.commons.io.IOUtils;
23
import org.apache.log4j.Logger;
24
import org.eclipse.core.runtime.jobs.Job;
25
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
26
import org.eclipse.e4.core.contexts.IEclipseContext;
27
import org.eclipse.e4.ui.workbench.modeling.EPartService;
28

  
29
import eu.etaxonomy.cdm.database.DbSchemaValidation;
30
import eu.etaxonomy.cdm.io.distribution.excelupdate.ExcelDistributionUpdateConfigurator;
31
import eu.etaxonomy.taxeditor.io.e4.AbstractImportWizardE4;
32
import eu.etaxonomy.taxeditor.io.e4.GenericConfiguratorWizardPageE4;
33
import eu.etaxonomy.taxeditor.io.e4.ImportFromFileAndChooseVocIdWizardPageE4;
34
import eu.etaxonomy.taxeditor.l10n.Messages;
35
import eu.etaxonomy.taxeditor.store.CdmStore;
36

  
37
/**
38
 * @author k.luther
39
 * @date 03.05.2017
40
 *
41
 */
42
public class ExcelDistributionUpdateWizardE4 extends AbstractImportWizardE4<ExcelDistributionUpdateConfigurator> {
43

  
44

  
45
    private ExcelDistributionUpdateConfigurator configurator;
46

  
47
    private ImportFromFileAndChooseVocIdWizardPageE4 dataSourcePage;
48

  
49
    private static final Logger logger = Logger.getLogger(ExcelDistributionUpdateWizardE4.class);
50

  
51
    @Inject
52
    public ExcelDistributionUpdateWizardE4(IEclipseContext context, EPartService partService) {
53
        super(context, partService);
54
    }
55

  
56
    /** {@inheritDoc} */
57
    @Override
58
    public ExcelDistributionUpdateConfigurator getConfigurator() {
59
        return configurator;
60
    }
61

  
62
    /** {@inheritDoc} */
63
    @Override
64
    public boolean performFinish() {
65
        URI source = dataSourcePage.getUri();
66
       // configurator.setSource(source);
67
        configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
68
        File file = new File(source);
69
        FileInputStream fis = null;
70

  
71
        try {
72
            fis = new FileInputStream(file);
73
        } catch (FileNotFoundException e) {
74
            logger.error("Error while reading file" + source.toString());
75
        }
76
        try {
77
            configurator.setStream(IOUtils.toByteArray(fis));
78
        } catch (IOException e) {
79
            // TODO Auto-generated catch block
80
            e.printStackTrace();
81
        }
82
        UUID vocUuid = dataSourcePage.getVocUuid();
83

  
84
        configurator.setAreaVocabularyUuid(vocUuid);
85
        //CdmStore.getImportManager().runMoniteredOperation(configurator, new File(source), SOURCE_TYPE.INPUTSTREAM);
86
        Job job = CdmStore.getImportManager().createIOServiceJob(configurator);
87
        CdmStore.getImportManager().run(job);
88

  
89
        return true;
90
    }
91

  
92
    /** {@inheritDoc} */
93
    @Override
94
    public void init() {
95
        configurator =  CdmStore.getImportManager().ExcelDistributionUpdateConfigurator();
96

  
97
    }
98

  
99
    /** {@inheritDoc} */
100
    @Override
101
    public void addPages() {
102
        addConfiguratorPage();
103
        addDataSourcePage();
104

  
105

  
106
    }
107
    @Override
108
    protected void addConfiguratorPage(){
109
        List<String> ignoreMethods = new ArrayList<>();
110
        ignoreMethods.add("setIgnoreNull");
111
        ignoreMethods.add("setInteractWithUser");
112
        ignoreMethods.add("setUseClassification");
113
        pageConfiguration = ContextInjectionFactory.make(GenericConfiguratorWizardPageE4.class, context);
114
        pageConfiguration.initImport(getConfigurator(), ignoreMethods, Messages.ExcelDistributionUpdateWizard_ConfiguratorWizard_label);
115
        addPage(pageConfiguration);
116
    }
117

  
118
    private void addDataSourcePage(){
119
        dataSourcePage = ContextInjectionFactory.make(ImportFromFileAndChooseVocIdWizardPageE4.class, context);
120
        addPage(dataSourcePage);
121
    }
122

  
123

  
124
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/excel/distribution/OpenExcelDistributionImportWizard.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.io.e4.excel.distribution;
10

  
11
import eu.etaxonomy.taxeditor.io.e4.AbstractImportWizardE4;
12
import eu.etaxonomy.taxeditor.io.e4.AbstractOpenImportWizard;
13

  
14
/**
15
 * @author pplitzner
16
 * @since Oct 5, 2017
17
 *
18
 */
19
public class OpenExcelDistributionImportWizard extends AbstractOpenImportWizard {
20

  
21
    /**
22
     * {@inheritDoc}
23
     */
24
    @Override
25
    protected Class<? extends AbstractImportWizardE4> getImportWizardClass() {
26
        return ExcelDistributionUpdateWizardE4.class;
27
    }
28

  
29
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/excel/specimen/OpenExcelSpecimenImportWizard.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.io.e4.excel.specimen;
10

  
11
import eu.etaxonomy.taxeditor.io.e4.AbstractImportWizardE4;
12
import eu.etaxonomy.taxeditor.io.e4.AbstractOpenImportWizard;
13

  
14
/**
15
 * @author pplitzner
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff