Revision 7b78edc5
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.store/fragment.e4xmi | ||
---|---|---|
106 | 106 |
<elements xsi:type="commands:Command" xmi:id="_zJ4-8JMCEeeR4YRjNqCKeA" elementId="eu.etaxonomy.taxeditor.command.openClassificationWizard" commandName="%command.name.OPEN_CLASSIFICATION_WIZARD"/> |
107 | 107 |
<elements xsi:type="commands:Command" xmi:id="_l-AGEKjzEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.openReferencingObjectsView" commandName="%command.name.OPEN_REFERENCING_OBJECTS_VIEW"/> |
108 | 108 |
<elements xsi:type="commands:Command" xmi:id="_TwGSwKkVEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.workbench.command.importSpecimens" commandName="Import specimens"/> |
109 |
<elements xsi:type="commands:Command" xmi:id="_QbHeEKmQEeeDJPU_cUTI2g" elementId="eu.etaxonomy.taxeditor.store.command.importAbcd" commandName="Import ABCD"/> |
|
109 | 110 |
</fragments> |
110 | 111 |
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_swGH0GhvEee3K4uKJljEYg" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application"> |
111 | 112 |
<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"/> |
... | ... | |
114 | 115 |
<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"/> |
115 | 116 |
<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"/> |
116 | 117 |
<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"/> |
118 |
<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"/> |
|
117 | 119 |
</fragments> |
118 | 120 |
<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"> |
119 | 121 |
<elements xsi:type="menu:Menu" xmi:id="_LT3P8IfcEeecZ4F2Y9Z0Og" elementId="eu.etaxonomy.taxeditor.store.menu.termeditor" label="Term Editor"> |
... | ... | |
132 | 134 |
<elements xsi:type="menu:Menu" xmi:id="_QC5O8KkaEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.store.menu.import" label="Import (E4)"> |
133 | 135 |
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_UL4dkKkaEeejedk4mZQIGw" coreExpressionId="isCdmStoreConnected"/> |
134 | 136 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_RUOtQKkVEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.workbench.handledmenuitem.importspecimens" label="Import specimens" command="_TwGSwKkVEeejedk4mZQIGw"/> |
137 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_NO718KmQEeeDJPU_cUTI2g" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.importAbcd" label="ABCD" command="_QbHeEKmQEeeDJPU_cUTI2g"/> |
|
135 | 138 |
</elements> |
136 | 139 |
</fragments> |
137 | 140 |
</fragment:ModelFragments> |
eu.etaxonomy.taxeditor.store/plugin.xml | ||
---|---|---|
445 | 445 |
class="eu.etaxonomy.taxeditor.io.wizard.ExcelNormalExplicitTaxaImportWizard" |
446 | 446 |
id="eu.etaxonomy.taxeditor.io.import.excel.taxa" |
447 | 447 |
name="%wizard.name.2"> |
448 |
</wizard> |
|
449 |
<wizard |
|
450 |
category="eu.etaxonomy.taxeditor.import.category.cdm" |
|
451 |
class="eu.etaxonomy.taxeditor.io.wizard.AbcdImportWizard" |
|
452 |
id="eu.etaxonomy.taxeditor.io.import.abcd" |
|
453 |
name="%wizard.name.3"> |
|
454 | 448 |
</wizard> |
455 | 449 |
<wizard |
456 | 450 |
category="eu.etaxonomy.taxeditor.import.category.cdm" |
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 |
|
|
14 |
import org.eclipse.e4.core.contexts.ContextInjectionFactory; |
|
15 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
|
16 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
17 |
import org.eclipse.jface.dialogs.MessageDialog; |
|
18 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
19 |
import org.eclipse.jface.wizard.IWizardContainer; |
|
20 |
import org.eclipse.jface.wizard.Wizard; |
|
21 |
import org.eclipse.swt.SWT; |
|
22 |
import org.eclipse.ui.IWorkbench; |
|
23 |
|
|
24 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator; |
|
25 |
import eu.etaxonomy.cdm.io.common.IIoConfigurator; |
|
26 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
* @author pplitzner |
|
31 |
* @since Oct 5, 2017 |
|
32 |
* |
|
33 |
* @param <CONFIG> |
|
34 |
*/ |
|
35 |
public abstract class AbstractImportWizardE4<CONFIG extends IIoConfigurator> extends Wizard { |
|
36 |
|
|
37 |
protected GenericConfiguratorWizardPageE4 pageConfiguration; |
|
38 |
private NomenclaturalCodeWizardPageE4 pageNomenclaturalCode; |
|
39 |
|
|
40 |
private IWorkbench workbench; |
|
41 |
|
|
42 |
private 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 = context; |
|
51 |
this.partService = partService; |
|
52 |
} |
|
53 |
|
|
54 |
/** {@inheritDoc} */ |
|
55 |
@Override |
|
56 |
public void addPages() { |
|
57 |
super.addPages(); |
|
58 |
|
|
59 |
addConfiguratorPage(); |
|
60 |
|
|
61 |
pageNomenclaturalCode = ContextInjectionFactory.make(NomenclaturalCodeWizardPageE4.class, context); |
|
62 |
pageNomenclaturalCode.setConfigurator((IImportConfigurator)getConfigurator()); |
|
63 |
this.addPage(pageNomenclaturalCode); |
|
64 |
} |
|
65 |
|
|
66 |
protected void addConfiguratorPage(){ |
|
67 |
pageConfiguration = ContextInjectionFactory.make(GenericConfiguratorWizardPageE4.class, context); |
|
68 |
pageConfiguration.initImport(getConfigurator(), null, Messages.AbstractImportWizard_ConfigurationLabel); |
|
69 |
this.addPage(pageConfiguration); |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public void setContainer(IWizardContainer wizardContainer) { |
|
74 |
if(existUnsavedEditors()){ |
|
75 |
MessageDialog.open(MessageDialog.WARNING, getShell(), "Unsaved editors", "Please save all open editors before executing " + |
|
76 |
"an import operation. The import operation will be cancelled", SWT.NONE); |
|
77 |
} |
|
78 |
else{ |
|
79 |
super.setContainer(wizardContainer); |
|
80 |
} |
|
81 |
} |
|
82 |
|
|
83 |
public abstract void init(); |
|
84 |
|
|
85 |
protected boolean existUnsavedEditors(){ |
|
86 |
return !partService.getDirtyParts().isEmpty(); |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public boolean canFinish() { |
|
91 |
return !existUnsavedEditors() && super.canFinish(); |
|
92 |
} |
|
93 |
|
|
94 |
public abstract CONFIG getConfigurator(); |
|
95 |
|
|
96 |
public void setSelection(IStructuredSelection selection) { |
|
97 |
this.selection = selection; |
|
98 |
} |
|
99 |
|
|
100 |
public IStructuredSelection getSelection() { |
|
101 |
return selection; |
|
102 |
} |
|
103 |
|
|
104 |
public void setWorkbench(IWorkbench workbench) { |
|
105 |
this.workbench = workbench; |
|
106 |
} |
|
107 |
|
|
108 |
public IWorkbench getWorkbench() { |
|
109 |
return workbench; |
|
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 |
private GenericConfiguratorWizardPageE4() { |
|
49 |
super("Configuration"); |
|
50 |
} |
|
51 |
|
|
52 |
public 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/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 n.hoffmann |
|
34 |
* @created 04.08.2009 |
|
35 |
* @version 1.0 |
|
36 |
*/ |
|
37 |
public class ImportFromFileDataSourceWizardPageE4 extends WizardPage { |
|
38 |
|
|
39 |
/** Constant <code>PAGE_NAME="CdmXmlDataSourceWizardPage"</code> */ |
|
40 |
public static final String PAGE_NAME = "CdmXmlDataSourceWizardPage"; |
|
41 |
|
|
42 |
private String[] extensions = {"*.xml"}; |
|
43 |
|
|
44 |
private FileDialog fileDialog; |
|
45 |
private Text textReferenceString; |
|
46 |
|
|
47 |
protected Text text_source; |
|
48 |
|
|
49 |
@Inject |
|
50 |
public ImportFromFileDataSourceWizardPageE4() { |
|
51 |
super(PAGE_NAME); |
|
52 |
|
|
53 |
setTitle("Xml File"); |
|
54 |
|
|
55 |
setDescription("Select XML file."); |
|
56 |
|
|
57 |
this.extensions = new String[]{"*.xml","*.*"}; |
|
58 |
} |
|
59 |
|
|
60 |
/** {@inheritDoc} */ |
|
61 |
@Override |
|
62 |
public void createControl(Composite parent) { |
|
63 |
final Composite composite = new Composite(parent, SWT.NULL); |
|
64 |
|
|
65 |
setPageComplete(false); |
|
66 |
|
|
67 |
GridLayout gridLayout = new GridLayout(); |
|
68 |
gridLayout.numColumns = 3; |
|
69 |
composite.setLayout(gridLayout); |
|
70 |
|
|
71 |
Label folderLabel = new Label(composite, SWT.NONE); |
|
72 |
folderLabel.setText("File"); |
|
73 |
|
|
74 |
fileDialog = new FileDialog(parent.getShell()); |
|
75 |
|
|
76 |
fileDialog.setFilterExtensions(extensions); |
|
77 |
|
|
78 |
text_source = new Text(composite, SWT.BORDER); |
|
79 |
text_source.setEditable(false); |
|
80 |
text_source.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
|
81 |
|
|
82 |
|
|
83 |
Button button = new Button(composite, SWT.PUSH); |
|
84 |
button.setText("Browse..."); |
|
85 |
|
|
86 |
button.addSelectionListener(new SelectionAdapter(){ |
|
87 |
|
|
88 |
@Override |
|
89 |
public void widgetSelected(SelectionEvent e) { |
|
90 |
String path = fileDialog.open(); |
|
91 |
if(path!=null){ |
|
92 |
text_source.setText(path); |
|
93 |
setPageComplete(isPageComplete()); |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
}); |
|
98 |
|
|
99 |
Label labelRef = new Label(composite, SWT.NONE); |
|
100 |
labelRef.setText("Default import souce reference"); |
|
101 |
labelRef.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1)); |
|
102 |
textReferenceString = new Text(composite, SWT.NONE); |
|
103 |
textReferenceString.setEnabled(true); |
|
104 |
GridData gd_textReferenceString = new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1); |
|
105 |
gd_textReferenceString.widthHint = 229; |
|
106 |
textReferenceString.setLayoutData(gd_textReferenceString); |
|
107 |
setControl(composite); |
|
108 |
} |
|
109 |
|
|
110 |
public File getFile() { |
|
111 |
return new File(text_source.getText()); |
|
112 |
} |
|
113 |
|
|
114 |
public Text getTextReferenceString() { |
|
115 |
return textReferenceString; |
|
116 |
} |
|
117 |
|
|
118 |
public void setTextReferenceString(Text textReferenceString) { |
|
119 |
this.textReferenceString = textReferenceString; |
|
120 |
} |
|
121 |
|
|
122 |
public URI getUri() { |
|
123 |
return getFile().toURI(); |
|
124 |
} |
|
125 |
|
|
126 |
@Override |
|
127 |
public boolean isPageComplete() { |
|
128 |
return CdmUtils.isNotBlank(text_source.getText()); |
|
129 |
} |
|
130 |
|
|
131 |
} |
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);//.XML(); |
|
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 |
} |
Also available in: Unified diff
ref #7005 Migrate ABCD import