Revision 2611dff9
Added by Katja Luther almost 3 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/e4/handler/NewObjectHandler.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 |
package eu.etaxonomy.taxeditor.annotatedlineeditor.e4.handler; |
|
10 |
|
|
11 |
import javax.inject.Named; |
|
12 |
|
|
13 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
|
14 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
15 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
16 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
|
17 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
18 |
import org.eclipse.jface.dialogs.IInputValidator; |
|
19 |
import org.eclipse.jface.dialogs.InputDialog; |
|
20 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
21 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
22 |
import org.eclipse.jface.window.Window; |
|
23 |
import org.eclipse.swt.widgets.Shell; |
|
24 |
|
|
25 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
26 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator; |
|
27 |
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants; |
|
28 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
|
29 |
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.GroupCreator; |
|
30 |
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.UserCreator; |
|
31 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
|
32 |
|
|
33 |
/** |
|
34 |
* @author pplitzner |
|
35 |
* @date 12.09.2017 |
|
36 |
*/ |
|
37 |
public class NewObjectHandler { |
|
38 |
|
|
39 |
@Execute |
|
40 |
public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
41 |
@Named(IServiceConstants.ACTIVE_SHELL)Shell shell, |
|
42 |
MHandledMenuItem menuItem) { |
|
43 |
if(!(activePart.getObject() instanceof BulkEditorE4)){ |
|
44 |
return; |
|
45 |
} |
|
46 |
Object key = menuItem.getTransientData().get(IBulkEditorConstants.DYNAMIC_OPEN_OBJECT_ID+".key"); |
|
47 |
|
|
48 |
BulkEditorE4 bulkEditor = (BulkEditorE4) activePart.getObject(); |
|
49 |
|
|
50 |
if (key != null) { |
|
51 |
String text = menuItem.getCommand().getCommandName(); |
|
52 |
//FIXME : This should probably go into some ValidatorFactory |
|
53 |
IInputValidator nonEmptyInputValidator = null; |
|
54 |
//FIXME : This is a workaround to not allow empty strings in the |
|
55 |
// input dialog for User and Group entities. |
|
56 |
// Normally this should be default |
|
57 |
// behaviour, so we need to discuss whether this handler |
|
58 |
// should be used to handle the creating new entities of |
|
59 |
// type other than User and Group. |
|
60 |
// Once #4348 is fixed this check can be removed. |
|
61 |
if(text.equals(UserCreator.USER) || text.equals(GroupCreator.GROUP)) { |
|
62 |
nonEmptyInputValidator = new IInputValidator() { |
|
63 |
@Override |
|
64 |
public String isValid(String text) { |
|
65 |
if(text == null || text.isEmpty()) { |
|
66 |
return Messages.GROUP_CREATOR_Name_not_accepted_message; |
|
67 |
} |
|
68 |
return null; |
|
69 |
} |
|
70 |
}; |
|
71 |
} |
|
72 |
InputDialog dialog = new InputDialog(shell, |
|
73 |
String.format("Create %s", text), String.format("Enter new %s", text), "", |
|
74 |
nonEmptyInputValidator); |
|
75 |
|
|
76 |
if (dialog.open() != Window.CANCEL) { |
|
77 |
IEntityCreator<?> entityCreator = bulkEditor.getEditorInput().getEntityCreator(); |
|
78 |
Object createdEntity = entityCreator.createEntity(key, dialog.getValue()); |
|
79 |
if (createdEntity == null){ |
|
80 |
return; |
|
81 |
} |
|
82 |
bulkEditor.getEditorInput().getModel().add(createdEntity); |
|
83 |
if (createdEntity instanceof CdmBase){ |
|
84 |
if (!((CdmBase)createdEntity).isPersited()){ |
|
85 |
bulkEditor.getEditorInput().addSaveCandidate((CdmBase)createdEntity); |
|
86 |
bulkEditor.setDirty(); |
|
87 |
} |
|
88 |
|
|
89 |
} |
|
90 |
IStructuredSelection selection = new StructuredSelection(createdEntity); |
|
91 |
bulkEditor.refresh(); |
|
92 |
bulkEditor.setFocus(); |
|
93 |
bulkEditor.setSelection(selection); |
|
94 |
} |
|
95 |
} |
|
96 |
} |
|
97 |
|
|
98 |
@CanExecute |
|
99 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
100 |
MHandledMenuItem menuItem){ |
|
101 |
boolean canExecute = false; |
|
102 |
canExecute = activePart.getObject() instanceof BulkEditorE4; |
|
103 |
menuItem.setVisible(canExecute); |
|
104 |
return canExecute; |
|
105 |
} |
|
106 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/e4/DataImportView.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2013 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.view.dataimport.e4; |
|
10 |
|
|
11 |
import java.util.ArrayList; |
|
12 |
import java.util.Collection; |
|
13 |
|
|
14 |
import javax.annotation.PostConstruct; |
|
15 |
import javax.annotation.PreDestroy; |
|
16 |
|
|
17 |
import org.apache.log4j.Logger; |
|
18 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
19 |
import org.eclipse.e4.ui.di.Focus; |
|
20 |
import org.eclipse.jface.viewers.CheckboxTableViewer; |
|
21 |
import org.eclipse.jface.wizard.IWizard; |
|
22 |
import org.eclipse.jface.wizard.WizardDialog; |
|
23 |
import org.eclipse.swt.SWT; |
|
24 |
import org.eclipse.swt.events.SelectionAdapter; |
|
25 |
import org.eclipse.swt.events.SelectionEvent; |
|
26 |
import org.eclipse.swt.layout.GridData; |
|
27 |
import org.eclipse.swt.layout.GridLayout; |
|
28 |
import org.eclipse.swt.widgets.Button; |
|
29 |
import org.eclipse.swt.widgets.Composite; |
|
30 |
import org.eclipse.swt.widgets.Display; |
|
31 |
import org.eclipse.swt.widgets.Event; |
|
32 |
import org.eclipse.swt.widgets.Label; |
|
33 |
import org.eclipse.swt.widgets.Listener; |
|
34 |
import org.eclipse.swt.widgets.Table; |
|
35 |
import org.eclipse.swt.widgets.TableItem; |
|
36 |
import org.eclipse.swt.widgets.Text; |
|
37 |
import org.eclipse.ui.IMemento; |
|
38 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
|
39 |
|
|
40 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
41 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
|
42 |
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery; |
|
43 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator; |
|
44 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
|
45 |
import eu.etaxonomy.taxeditor.databaseAdmin.wizard.ImportPreferencesWizard; |
|
46 |
import eu.etaxonomy.taxeditor.model.IContextListener; |
|
47 |
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails; |
|
48 |
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData; |
|
49 |
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData; |
|
50 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
51 |
import eu.etaxonomy.taxeditor.workbench.part.IEditorAreaPart; |
|
52 |
|
|
53 |
/** |
|
54 |
* View which shows a list of "data" that can be imported into the CDM |
|
55 |
* @author pplitzner |
|
56 |
* @date 22.08.2017 |
|
57 |
* |
|
58 |
* @param <T> the CDM type that will be handled by this view |
|
59 |
*/ |
|
60 |
public abstract class DataImportView<T> implements IPartContentHasFactualData, |
|
61 |
IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IContextListener, Listener, IEditorAreaPart{ |
|
62 |
|
|
63 |
protected final Logger logger = Logger.getLogger(DataImportView.class); |
|
64 |
|
|
65 |
protected Collection<T> results = new ArrayList<>(); |
|
66 |
|
|
67 |
protected boolean updated = false; |
|
68 |
|
|
69 |
protected OccurenceQuery query; |
|
70 |
|
|
71 |
private static ConversationHolder conversationHolder; |
|
72 |
|
|
73 |
private SaveImportedSpecimenAction saveImportedSpecimenAction; |
|
74 |
|
|
75 |
// private Text textClassification; |
|
76 |
|
|
77 |
// private Classification classification; |
|
78 |
|
|
79 |
protected Text textReferenceString; |
|
80 |
|
|
81 |
private Button selectAllButton; |
|
82 |
//private Button selectNoneButton; |
|
83 |
|
|
84 |
private Button importButton; |
|
85 |
|
|
86 |
private boolean state; |
|
87 |
|
|
88 |
private Button openConfigurator; |
|
89 |
|
|
90 |
private Abcd206ImportConfigurator config; |
|
91 |
|
|
92 |
// public Classification getClassification() { |
|
93 |
// return classification; |
|
94 |
// } |
|
95 |
// |
|
96 |
// public void setClassification(Classification classification) { |
|
97 |
// this.classification = classification; |
|
98 |
// } |
|
99 |
|
|
100 |
private Button btnBrowseClassification; |
|
101 |
|
|
102 |
private Button btnClear; |
|
103 |
|
|
104 |
private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); |
|
105 |
|
|
106 |
private Table table; |
|
107 |
private Composite composite_3; |
|
108 |
|
|
109 |
/** |
|
110 |
* Constructs a new DataImportEditor and registers it to listen to context changes |
|
111 |
*/ |
|
112 |
public DataImportView() { |
|
113 |
CdmStore.getContextManager().addContextListener(this); |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* Create contents of the view part. |
|
118 |
* @param parent |
|
119 |
*/ |
|
120 |
@PostConstruct |
|
121 |
public void createPartControl(Composite parent) { |
|
122 |
if(CdmStore.isActive()){ |
|
123 |
initConversation(); |
|
124 |
} |
|
125 |
else{ |
|
126 |
return; |
|
127 |
} |
|
128 |
parent.setLayout(new GridLayout(1, false)); |
|
129 |
Composite composite = new Composite(parent, SWT.NONE); |
|
130 |
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); |
|
131 |
// composite.setBounds(0, 0, 0, 298); |
|
132 |
composite.setLayout(new GridLayout(2, false)); |
|
133 |
|
|
134 |
Composite composite_1 = new Composite(composite, SWT.NONE); |
|
135 |
// gd_composite_1.widthHint = 280; |
|
136 |
composite_1.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1)); |
|
137 |
composite_1.setLayout(new GridLayout(3, false)); |
|
138 |
|
|
139 |
// Label label = new Label(composite_1, SWT.TOP); |
|
140 |
// label.setText("Classification"); |
|
141 |
// label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1)); |
|
142 |
// textClassification = new Text(composite_1, SWT.BORDER); |
|
143 |
// textClassification.setEnabled(false); |
|
144 |
// GridData gd_textClassification = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); |
|
145 |
//// gd_textClassification.widthHint = 118; |
|
146 |
// textClassification.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true)); |
|
147 |
// btnBrowseClassification = new Button(composite_1, SWT.NONE); |
|
148 |
// btnBrowseClassification.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif")); |
|
149 |
// btnBrowseClassification.addListener(SWT.Selection, this); |
|
150 |
// btnClear = new Button(composite_1, SWT.NONE); |
|
151 |
// btnClear.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif")); |
|
152 |
// btnClear.addListener(SWT.Selection, this); |
|
153 |
//source reference |
|
154 |
|
|
155 |
// Label labelRef = new Label(composite_1, SWT.NONE); |
|
156 |
// labelRef.setText("Import souce reference"); |
|
157 |
// labelRef.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1)); |
|
158 |
// textReferenceString = new Text(composite_1, SWT.NONE); |
|
159 |
// textReferenceString.setEnabled(true); |
|
160 |
// GridData gd_textReferenceString = new GridData(SWT.LEFT, SWT.CENTER, true, true, 3, 1); |
|
161 |
// gd_textReferenceString.widthHint = 229; |
|
162 |
// textReferenceString.setLayoutData(gd_textReferenceString); |
|
163 |
// DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd"); |
|
164 |
// LocalDate localDate = LocalDate.now(); |
|
165 |
// |
|
166 |
// textReferenceString.setText("Specimen Import " + localDate.toString()); |
|
167 |
//open configuration |
|
168 |
// |
|
169 |
// PreferencesUtil.getLocalAbcdImportConfigurator(false); |
|
170 |
// |
|
171 |
// openConfigurator = new Button(composite_1, SWT.PUSH); |
|
172 |
// openConfigurator.setText("Configuration"); |
|
173 |
// new Label(composite_1, SWT.NONE); |
|
174 |
// new Label(composite_1, SWT.NONE); |
|
175 |
// |
|
176 |
// openConfigurator.addSelectionListener(new SelectionAdapter(){ |
|
177 |
// @Override |
|
178 |
// public void widgetSelected(SelectionEvent e) { |
|
179 |
// |
|
180 |
// IWizard wizard = new ImportPreferencesWizard(); |
|
181 |
// WizardDialog dialog = new WizardDialog(e.display.getActiveShell(), wizard); |
|
182 |
// dialog.open(); |
|
183 |
// |
|
184 |
// } |
|
185 |
// }); |
|
186 |
|
|
187 |
//checkbox table for result |
|
188 |
Composite composite_2 = new Composite(composite, SWT.NONE); |
|
189 |
composite_2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); |
|
190 |
composite_2.setLayout(new GridLayout(2, false)); |
|
191 |
|
|
192 |
|
|
193 |
CheckboxTableViewer checkboxTableViewer = CheckboxTableViewer.newCheckList(composite_2, SWT.BORDER | SWT.FULL_SELECTION); |
|
194 |
|
|
195 |
|
|
196 |
table = checkboxTableViewer.getTable(); |
|
197 |
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); |
|
198 |
table.addListener(SWT.Selection, this); |
|
199 |
toolkit.paintBordersFor(table); |
|
200 |
|
|
201 |
composite_3 = new Composite(composite_2, SWT.NONE); |
|
202 |
// gd_composite_3.heightHint = 48; |
|
203 |
composite_3.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); |
|
204 |
toolkit.paintBordersFor(composite_3); |
|
205 |
composite_3.setLayout(new GridLayout(1, false)); |
|
206 |
//toggle button |
|
207 |
selectAllButton = new Button(composite_3, SWT.PUSH); |
|
208 |
selectAllButton.setText("Select all/none"); |
|
209 |
new Label(composite_2, SWT.NONE); |
|
210 |
|
|
211 |
// Composite composite_4 = new Composite(composite_2, SWT.NONE); |
|
212 |
// composite_4.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); |
|
213 |
// composite_4.setBackground(composite.getBackground()); |
|
214 |
// toolkit.adapt(composite_4); |
|
215 |
// toolkit.paintBordersFor(composite_4); |
|
216 |
|
|
217 |
importButton = new Button(composite_2, SWT.PUSH); |
|
218 |
importButton.setSize(48, 25); |
|
219 |
importButton.setText("Import"); |
|
220 |
importButton.addSelectionListener(new SelectionAdapter(){ |
|
221 |
@Override |
|
222 |
public void widgetSelected(SelectionEvent e) { |
|
223 |
IWizard wizard = new ImportPreferencesWizard(); |
|
224 |
WizardDialog dialog = new WizardDialog(e.display.getActiveShell(), wizard); |
|
225 |
int status = dialog.open(); |
|
226 |
if (status == 0){ |
|
227 |
saveImportedSpecimenAction.run(); |
|
228 |
} |
|
229 |
} |
|
230 |
}); |
|
231 |
// new Label(composite_2, SWT.NONE); |
|
232 |
// new Label(composite_2, SWT.NONE); |
|
233 |
// new Label(composite_2, SWT.NONE); |
|
234 |
// new Label(composite_2, SWT.NONE); |
|
235 |
// new Label(composite_2, SWT.NONE); |
|
236 |
// new Label(composite_2, SWT.NONE); |
|
237 |
selectAllButton.addSelectionListener(new SelectionAdapter(){ |
|
238 |
@Override |
|
239 |
public void widgetSelected(SelectionEvent e) { |
|
240 |
state = state ? false : true; |
|
241 |
for (TableItem item: getTable().getItems()){ |
|
242 |
item.setChecked(state); |
|
243 |
} |
|
244 |
|
|
245 |
} |
|
246 |
}); |
|
247 |
//import button |
|
248 |
|
|
249 |
saveImportedSpecimenAction = new SaveImportedSpecimenAction(this); |
|
250 |
initializeToolBar(); |
|
251 |
} |
|
252 |
|
|
253 |
/** |
|
254 |
* Initialize the toolbar. |
|
255 |
*/ |
|
256 |
private void initializeToolBar() { |
|
257 |
//FIXME E4 migrate |
|
258 |
// IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager(); |
|
259 |
// tbm.add(saveImportedSpecimenAction); |
|
260 |
} |
|
261 |
|
|
262 |
public Table getTable() { |
|
263 |
return table; |
|
264 |
} |
|
265 |
|
|
266 |
public void setQuery(OccurenceQuery query) { |
|
267 |
this.query = query; |
|
268 |
} |
|
269 |
|
|
270 |
public void setResults(Collection<T> results) { |
|
271 |
this.results = results; |
|
272 |
updated=false; |
|
273 |
|
|
274 |
} |
|
275 |
|
|
276 |
@PreDestroy |
|
277 |
public void dispose() { |
|
278 |
CdmStore.getContextManager().removeContextListener(this); |
|
279 |
} |
|
280 |
|
|
281 |
@Override |
|
282 |
public void contextRefresh(IProgressMonitor monitor) { |
|
283 |
refresh(); |
|
284 |
} |
|
285 |
|
|
286 |
protected void refresh(){ |
|
287 |
if (!updated){ |
|
288 |
if (getTable() != null){ |
|
289 |
getTable().removeAll(); |
|
290 |
} |
|
291 |
if(results!=null){ |
|
292 |
for(T item:results){ |
|
293 |
TableItem tableItem = new TableItem(getTable(), SWT.NONE); |
|
294 |
tableItem.setText(getTextForTableItem(item)); |
|
295 |
tableItem.setData(item); |
|
296 |
} |
|
297 |
} |
|
298 |
updated = true; |
|
299 |
} |
|
300 |
} |
|
301 |
|
|
302 |
public abstract void query(); |
|
303 |
|
|
304 |
@Override |
|
305 |
public void update(CdmDataChangeMap changeEvents) { |
|
306 |
//nothing |
|
307 |
} |
|
308 |
|
|
309 |
/** |
|
310 |
* Returns the text label of the given item. |
|
311 |
* @param item the item for which the label should be returns |
|
312 |
* @return the label of the item |
|
313 |
*/ |
|
314 |
protected abstract String getTextForTableItem(T item); |
|
315 |
|
|
316 |
@Focus |
|
317 |
public void setFocus() { |
|
318 |
if(getTable()!=null){ |
|
319 |
getTable().setFocus(); |
|
320 |
} |
|
321 |
//make sure to bind again if maybe in another view the conversation was unbound |
|
322 |
if(getConversationHolder()!=null && !getConversationHolder().isBound()){ |
|
323 |
getConversationHolder().bind(); |
|
324 |
} |
|
325 |
} |
|
326 |
|
|
327 |
@Override |
|
328 |
public void contextAboutToStop(IMemento memento, IProgressMonitor monitor) { |
|
329 |
} |
|
330 |
|
|
331 |
@Override |
|
332 |
public void contextStop(IMemento memento, IProgressMonitor monitor) { |
|
333 |
} |
|
334 |
|
|
335 |
@Override |
|
336 |
public void contextStart(IMemento memento, IProgressMonitor monitor) { |
|
337 |
initConversation(); |
|
338 |
} |
|
339 |
|
|
340 |
private void initConversation(){ |
|
341 |
if(conversationHolder==null){ |
|
342 |
conversationHolder = CdmStore.createConversation(); |
|
343 |
} |
|
344 |
} |
|
345 |
|
|
346 |
@Override |
|
347 |
public void workbenchShutdown(IMemento memento, IProgressMonitor monitor) { |
|
348 |
if(getConversationHolder()!=null && getConversationHolder().isBound() && !getConversationHolder().isClosed()) { |
|
349 |
getConversationHolder().close(); |
|
350 |
} |
|
351 |
} |
|
352 |
|
|
353 |
/** |
|
354 |
* @return the conversationHolder |
|
355 |
*/ |
|
356 |
@Override |
|
357 |
public ConversationHolder getConversationHolder() { |
|
358 |
if(CdmStore.isActive() && conversationHolder==null){ |
|
359 |
initConversation(); |
|
360 |
} |
|
361 |
return conversationHolder; |
|
362 |
} |
|
363 |
|
|
364 |
@Override |
|
365 |
public void handleEvent(Event event) { |
|
366 |
// if(event.widget==btnBrowseClassification){ |
|
367 |
// classification = SelectionDialogFactory.getSelectionFromDialog(Classification.class, event.widget.getDisplay().getActiveShell(), null, null); |
|
368 |
// if(classification!=null){ |
|
369 |
// textClassification.setText(classification.getTitleCache()); |
|
370 |
// } |
|
371 |
// } |
|
372 |
// else if(event.widget==btnClear){ |
|
373 |
// classification = null; |
|
374 |
// textClassification.setText(""); |
|
375 |
// } |
|
376 |
|
|
377 |
// else { |
|
378 |
if(event.widget == table){ |
|
379 |
TableItem[] item = table.getSelection(); |
|
380 |
if (item.length == 1){ |
|
381 |
Object o = item[0].getData(); |
|
382 |
} |
|
383 |
} |
|
384 |
// } |
|
385 |
} |
|
386 |
|
|
387 |
public String getReferenceString() { |
|
388 |
return textReferenceString.getText(); |
|
389 |
} |
|
390 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/e4/GbifResponseImportView.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2014 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.view.dataimport.e4; |
|
10 |
|
|
11 |
import java.io.IOException; |
|
12 |
import java.net.URISyntaxException; |
|
13 |
import java.util.Collection; |
|
14 |
|
|
15 |
import org.apache.http.client.ClientProtocolException; |
|
16 |
|
|
17 |
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifQueryServiceWrapper; |
|
18 |
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse; |
|
19 |
|
|
20 |
/** |
|
21 |
* @author pplitzner |
|
22 |
* @date Sep 5, 2014 |
|
23 |
* |
|
24 |
*/ |
|
25 |
public class GbifResponseImportView extends DataImportView<GbifResponse> { |
|
26 |
|
|
27 |
|
|
28 |
public static final String ID = "eu.etaxonomy.taxeditor.view.dataimport.GbifResponseImportView"; |
|
29 |
|
|
30 |
/* (non-Javadoc) |
|
31 |
* @see eu.etaxonomy.taxeditor.view.dataimport.DataImportView#getTextForTableItem(java.lang.Object) |
|
32 |
*/ |
|
33 |
@Override |
|
34 |
protected String getTextForTableItem(GbifResponse item) { |
|
35 |
String text = ""; |
|
36 |
if(item.getDataSetProtocol()!=null){ |
|
37 |
text += "["+item.getDataSetProtocol()+"] "; |
|
38 |
} |
|
39 |
text += item.getDerivedUnitFacade().innerDerivedUnit().generateTitle(); |
|
40 |
return text; |
|
41 |
} |
|
42 |
|
|
43 |
/* (non-Javadoc) |
|
44 |
* @see eu.etaxonomy.taxeditor.view.dataimport.DataImportView#query() |
|
45 |
*/ |
|
46 |
@Override |
|
47 |
public void query() { |
|
48 |
String errorMessage = "Could not execute query " + query; |
|
49 |
try{ |
|
50 |
//Collection<GbifResponse> results = new GbifQueryServiceWrapper().query(query); |
|
51 |
//setResults(results); |
|
52 |
|
|
53 |
// String errorMessage = "Could not execute query " + query; |
|
54 |
|
|
55 |
// Collection<SpecimenOrObservationBase<?>> results = new ArrayList<SpecimenOrObservationBase<?>>(); |
|
56 |
Collection<GbifResponse> results = new GbifQueryServiceWrapper().query(query); |
|
57 |
|
|
58 |
setResults(results); |
|
59 |
|
|
60 |
|
|
61 |
// |
|
62 |
// results = repo.getUnits(); |
|
63 |
|
|
64 |
} catch (ClientProtocolException e) { |
|
65 |
logger.error(errorMessage, e); |
|
66 |
} catch (IOException e) { |
|
67 |
logger.error(errorMessage, e); |
|
68 |
} catch (URISyntaxException e) { |
|
69 |
// TODO Auto-generated catch block |
|
70 |
e.printStackTrace(); |
|
71 |
} |
|
72 |
} |
|
73 |
|
|
74 |
// setResults(results); |
|
75 |
// |
|
76 |
// } |
|
77 |
// } catch (ClientProtocolException e) { |
|
78 |
// logger.error(errorMessage, e); |
|
79 |
// } catch (IOException e) { |
|
80 |
// logger.error(errorMessage, e); |
|
81 |
// } catch (URISyntaxException e) { |
|
82 |
// logger.error(errorMessage, e); |
|
83 |
// } |
|
84 |
|
|
85 |
// } |
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/e4/SaveImportedSpecimenAction.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.view.dataimport.e4; |
|
2 |
|
|
3 |
import java.time.LocalDate; |
|
4 |
import java.time.format.DateTimeFormatter; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.Collection; |
|
7 |
import java.util.Collections; |
|
8 |
import java.util.Comparator; |
|
9 |
import java.util.HashSet; |
|
10 |
import java.util.List; |
|
11 |
import java.util.Set; |
|
12 |
|
|
13 |
import org.eclipse.core.runtime.jobs.Job; |
|
14 |
import org.eclipse.jface.action.Action; |
|
15 |
import org.eclipse.swt.widgets.Table; |
|
16 |
import org.eclipse.swt.widgets.TableItem; |
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.common.URI; |
|
19 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
20 |
import eu.etaxonomy.cdm.api.service.ITermService; |
|
21 |
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery; |
|
22 |
import eu.etaxonomy.cdm.ext.occurrence.bioCase.BioCaseResponse; |
|
23 |
import eu.etaxonomy.cdm.ext.occurrence.gbif.DataSetResponse; |
|
24 |
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifDataSetProtocol; |
|
25 |
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse; |
|
26 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator; |
|
27 |
import eu.etaxonomy.cdm.io.specimen.gbif.in.GbifImportConfigurator; |
|
28 |
import eu.etaxonomy.cdm.model.term.DefinedTermBase; |
|
29 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
|
30 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
31 |
import eu.etaxonomy.taxeditor.view.dataimport.GbifResponseComparator; |
|
32 |
|
|
33 |
/** |
|
34 |
* @author pplitzner |
|
35 |
* @since Oct 4, 2017 |
|
36 |
*/ |
|
37 |
public class SaveImportedSpecimenAction extends Action { |
|
38 |
|
|
39 |
private Comparator<GbifResponse> comparator; |
|
40 |
|
|
41 |
private DataImportView<?> dataImportView; |
|
42 |
|
|
43 |
public SaveImportedSpecimenAction(DataImportView<?> dataImportView) { |
|
44 |
super(); |
|
45 |
this.dataImportView = dataImportView; |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public void run() { |
|
50 |
Table table = dataImportView.getTable(); |
|
51 |
Collection<GbifResponse> checkedResults = new HashSet<>(); |
|
52 |
Collection<BioCaseResponse> checkedAbcdResults = new HashSet<>(); |
|
53 |
Object data; |
|
54 |
Set<String[]> unitIdsGbif = new HashSet<>(); |
|
55 |
Set<String[]> unitIdsBioCase = new HashSet<>(); |
|
56 |
List<GbifResponse> biocaseResponses = new ArrayList<>(); |
|
57 |
|
|
58 |
for(TableItem item:table.getItems()){ |
|
59 |
if(item.getChecked()){ |
|
60 |
//Save Specimen |
|
61 |
data = item.getData(); |
|
62 |
if(data instanceof GbifResponse){ |
|
63 |
checkedResults.add((GbifResponse)item.getData()); |
|
64 |
} |
|
65 |
if(data instanceof BioCaseResponse){ |
|
66 |
checkedAbcdResults.add((BioCaseResponse)data); |
|
67 |
} |
|
68 |
} |
|
69 |
} |
|
70 |
String[] tripleId ; |
|
71 |
for (GbifResponse response:checkedResults){ |
|
72 |
if (response != null){ |
|
73 |
tripleId = response.getTripleID(); |
|
74 |
|
|
75 |
if (response.getDataSetProtocol()!=null && response.getDataSetProtocol().equals(GbifDataSetProtocol.BIOCASE)){ |
|
76 |
biocaseResponses.add(response); |
|
77 |
|
|
78 |
}else{ |
|
79 |
unitIdsGbif.add(tripleId); |
|
80 |
} |
|
81 |
} |
|
82 |
} |
|
83 |
Collections.sort(biocaseResponses, getComparator()); |
|
84 |
|
|
85 |
Abcd206ImportConfigurator configuratorAbcd; |
|
86 |
List<Abcd206ImportConfigurator> abcdConfigurators = new ArrayList<>(); |
|
87 |
DataSetResponse dataSetResponse; |
|
88 |
OccurenceQuery bioCaseOccurrenceQuery = null; |
|
89 |
URI dataSetUri = null; |
|
90 |
for (BioCaseResponse response:checkedAbcdResults){ |
|
91 |
|
|
92 |
if (!response.getDataSetUri().equals(dataSetUri)){ |
|
93 |
dataSetUri = response.getDataSetUri(); |
|
94 |
//configuratorAbcd = Abcd206ImportConfigurator.NewInstance(null, null); |
|
95 |
configuratorAbcd = PreferencesUtil.getLastUsedAbcdImportConfigurator(); |
|
96 |
if (configuratorAbcd != null){ |
|
97 |
|
|
98 |
if (configuratorAbcd.getNomenclaturalCode() == null){ |
|
99 |
configuratorAbcd.setNomenclaturalCode(PreferencesUtil.getPreferredNomenclaturalCode()); |
|
100 |
} |
|
101 |
}else{ |
|
102 |
configuratorAbcd = Abcd206ImportConfigurator.NewInstance(null, null); |
|
103 |
|
|
104 |
if (configuratorAbcd.getNomenclaturalCode() == null){ |
|
105 |
configuratorAbcd.setNomenclaturalCode(PreferencesUtil.getPreferredNomenclaturalCode()); |
|
106 |
} |
|
107 |
} |
|
108 |
configuratorAbcd.setSourceUri(dataSetUri); |
|
109 |
if (configuratorAbcd.getSourceReference() == null && configuratorAbcd.getSourceRefUuid() == null){ |
|
110 |
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd"); |
|
111 |
LocalDate localDate = LocalDate.now(); |
|
112 |
|
|
113 |
String sourceRef ="Specimen Import " + localDate.toString(); |
|
114 |
configuratorAbcd.setSourceReferenceTitle(sourceRef); |
|
115 |
} |
|
116 |
|
|
117 |
unitIdsBioCase = new HashSet<>(); |
|
118 |
bioCaseOccurrenceQuery = new OccurenceQuery(unitIdsBioCase); |
|
119 |
configuratorAbcd.setOccurenceQuery(bioCaseOccurrenceQuery); |
|
120 |
|
|
121 |
// if (dataImportView.getClassification() != null){ |
|
122 |
// configuratorAbcd.setClassificationUuid(dataImportView.getClassification().getUuid()); |
|
123 |
// } |
|
124 |
// if (dataImportView.getReferenceString() != null){ |
|
125 |
// configuratorAbcd.setSourceReferenceTitle(dataImportView.getReferenceString()); |
|
126 |
// } |
|
127 |
abcdConfigurators.add(configuratorAbcd); |
|
128 |
|
|
129 |
|
|
130 |
} |
|
131 |
tripleId = response.getTripleID(); |
|
132 |
unitIdsBioCase.add(tripleId); |
|
133 |
|
|
134 |
} |
|
135 |
|
|
136 |
|
|
137 |
// if (!unitIdsBioCase.isEmpty()){ |
|
138 |
// configuratorAbcd = Abcd206ImportConfigurator.NewInstance(dataSetUri, null, false); |
|
139 |
// configuratorAbcd.addMediaAsMediaSpecimen(true); |
|
140 |
// configuratorAbcd.setIgnoreAuthorship(true); |
|
141 |
// configuratorAbcd.setMoveNewTaxaToDefaultClassification(false); |
|
142 |
// if (configuratorAbcd != null){ |
|
143 |
// abcdConfigurators.add(configuratorAbcd); |
|
144 |
// } |
|
145 |
//// unitIdsBioCase = new HashSet<String[]>(); |
|
146 |
// bioCaseOccurrenceQuery = new OccurenceQuery(unitIdsBioCase); |
|
147 |
// configuratorAbcd.setOccurenceQuery(bioCaseOccurrenceQuery); |
|
148 |
// configuratorAbcd.setGetSiblings(true); |
|
149 |
// if (dataImportView.getClassification() != null){ |
|
150 |
// configuratorAbcd.setClassificationUuid(dataImportView.getClassification().getUuid()); |
|
151 |
// } |
|
152 |
// } |
|
153 |
|
|
154 |
// for (GbifResponse response: biocaseResponses){ |
|
155 |
// try { |
|
156 |
// dataSetResponse = new GbifQueryServiceWrapper().queryOriginalDataSet(response); |
|
157 |
// dataSetUri = dataSetResponse.getEndpoint(); |
|
158 |
// } catch (ClientProtocolException e) { |
|
159 |
// // TODO Auto-generated catch block |
|
160 |
// e.printStackTrace(); |
|
161 |
// } catch (IOException e) { |
|
162 |
// // TODO Auto-generated catch block |
|
163 |
// e.printStackTrace(); |
|
164 |
// } |
|
165 |
// if (!response.getDataSetUri().equals(dataSetUri)){ |
|
166 |
// configuratorAbcd = Abcd206ImportConfigurator.NewInstance(dataSetUri, null, false); |
|
167 |
// configuratorAbcd.addMediaAsMediaSpecimen(true); |
|
168 |
// configuratorAbcd.setIgnoreAuthorship(true); |
|
169 |
// configuratorAbcd.setMoveNewTaxaToDefaultClassification(false); |
|
170 |
// if (configuratorAbcd != null){ |
|
171 |
// abcdConfigurators.add(configuratorAbcd); |
|
172 |
// } |
|
173 |
// unitIdsBioCase = new HashSet<String[]>(); |
|
174 |
// bioCaseOccurrenceQuery = new OccurenceQuery(unitIdsBioCase); |
|
175 |
// configuratorAbcd.setOccurenceQuery(bioCaseOccurrenceQuery); |
|
176 |
// configuratorAbcd.setGetSiblings(true); |
|
177 |
// if (dataImportView.getClassification() != null){ |
|
178 |
// configuratorAbcd.setClassificationUuid(dataImportView.getClassification().getUuid()); |
|
179 |
// } |
|
180 |
// |
|
181 |
// } |
|
182 |
// tripleId = response.getTripleID(); |
|
183 |
// unitIdsBioCase.add(tripleId); |
|
184 |
// } |
|
185 |
|
|
186 |
|
|
187 |
// configurator.setQuery(query); |
|
188 |
if (!checkedAbcdResults.isEmpty()){ |
|
189 |
Job bioCaseJob = CdmStore.getImportManager().createIOServiceJob(abcdConfigurators); |
|
190 |
CdmStore.getImportManager().run(bioCaseJob); |
|
191 |
} |
|
192 |
|
|
193 |
if (!unitIdsGbif.isEmpty()){ |
|
194 |
OccurenceQuery query = new OccurenceQuery(unitIdsGbif); |
|
195 |
GbifImportConfigurator configurator = GbifImportConfigurator.newInstance(query); |
|
196 |
configurator.setSourceReferenceTitle("Import Gbif data"); |
|
197 |
|
|
198 |
Job gbifJob = CdmStore.getImportManager().createIOServiceJob(configurator); |
|
199 |
CdmStore.getImportManager().run(gbifJob); |
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
private void persistTerm(DefinedTermBase<?> term, ITermService termService, ConversationHolder conversation){ |
|
204 |
if(term!=null){ |
|
205 |
//if the term does not exist in the DB save it |
|
206 |
if(termService.find(term.getUuid())==null){ |
|
207 |
termService.saveOrUpdate(term); |
|
208 |
} |
|
209 |
} |
|
210 |
} |
|
211 |
|
|
212 |
@Override |
|
213 |
public String getText() { |
|
214 |
return "Import"; |
|
215 |
} |
|
216 |
|
|
217 |
private Comparator<GbifResponse> getComparator(){ |
|
218 |
if (comparator == null){ |
|
219 |
comparator = new GbifResponseComparator(); |
|
220 |
} |
|
221 |
return comparator; |
|
222 |
} |
|
223 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/e4/SpecimenImportView.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2014 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.view.dataimport.e4; |
|
10 |
|
|
11 |
import java.io.IOException; |
|
12 |
import java.io.InputStream; |
|
13 |
import java.util.ArrayList; |
|
14 |
import java.util.Collection; |
|
15 |
|
|
16 |
import org.apache.http.client.ClientProtocolException; |
|
17 |
import org.w3c.dom.Element; |
|
18 |
import org.w3c.dom.NodeList; |
|
19 |
|
|
20 |
import eu.etaxonomy.cdm.common.URI; |
|
21 |
import eu.etaxonomy.cdm.ext.occurrence.bioCase.BioCaseQueryServiceWrapper; |
|
22 |
import eu.etaxonomy.cdm.ext.occurrence.bioCase.BioCaseResponse; |
|
23 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206DataHolder; |
|
24 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator; |
|
25 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportParser; |
|
26 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportState; |
|
27 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206XMLFieldGetter; |
|
28 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.AbcdParseUtility; |
|
29 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Identification; |
|
30 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.UnitAssociationWrapper; |
|
31 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
32 |
|
|
33 |
/** |
|
34 |
* @author pplitzner |
|
35 |
* @date Sep 3, 2014 |
|
36 |
*/ |
|
37 |
public class SpecimenImportView extends DataImportView<BioCaseResponse> { |
|
38 |
|
|
39 |
public static final String ID = "eu.etaxonomy.taxeditor.view.dataimport.SpecimenImportView"; //$NON-NLS-1$ |
|
40 |
|
|
41 |
private URI endPoint; |
|
42 |
|
|
43 |
public SpecimenImportView() { |
|
44 |
|
|
45 |
} |
|
46 |
|
|
47 |
public void setEndpoint(URI endPoint) { |
|
48 |
this.endPoint = endPoint; |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
protected String getTextForTableItem(BioCaseResponse item) { |
|
53 |
//TODO: could be defined in user preferences... |
|
54 |
String name = null; |
|
55 |
if(!(((Abcd206DataHolder)item.getAbcdDataHolder()).getIdentificationList() == null) && !((Abcd206DataHolder)item.getAbcdDataHolder()).getIdentificationList().isEmpty()){ |
|
56 |
Identification identification = ((Abcd206DataHolder)item.getAbcdDataHolder()).getIdentificationList().iterator().next(); |
|
57 |
name = identification.getScientificName(); |
|
58 |
} |
|
59 |
if (name != null){ |
|
60 |
return name +" - "+((Abcd206DataHolder)item.getAbcdDataHolder()).getCollectionCode() + " - "+ ((Abcd206DataHolder)item.getAbcdDataHolder()).getUnitID() + " - "+ ((Abcd206DataHolder)item.getAbcdDataHolder()).getKindOfUnit(); |
|
61 |
}else { |
|
62 |
return ((Abcd206DataHolder)item.getAbcdDataHolder()).getCollectionCode() + " - "+ ((Abcd206DataHolder)item.getAbcdDataHolder()).getUnitID() + " - "+ ((Abcd206DataHolder)item.getAbcdDataHolder()).getKindOfUnit(); |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
public void query() { |
|
68 |
String errorMessage = "Could not execute query " + query; |
|
69 |
|
|
70 |
Collection<BioCaseResponse> results = new ArrayList<BioCaseResponse>(); |
|
71 |
try { |
|
72 |
//FIXME move ABCD import to cdmlib -> this will also get rid of the transient services |
|
73 |
InputStream resultStream; |
|
74 |
resultStream = new BioCaseQueryServiceWrapper().query(query, endPoint); |
|
75 |
Abcd206ImportConfigurator configurator = Abcd206ImportConfigurator.NewInstance(null, null); |
|
76 |
configurator.setSourceUri(endPoint); |
|
77 |
|
|
78 |
// TransientCdmRepository repo = |
|
79 |
// new TransientCdmRepository(CdmStore.getCurrentApplicationConfiguration()); |
|
80 |
//configurator.setCdmAppController(repo); |
|
81 |
|
|
82 |
//TODO: do not query all data but with the selected triple IDs -> see GbifResponseImportView |
|
83 |
configurator.setAddMediaAsMediaSpecimen(true); |
|
84 |
configurator.setAllowReuseOtherClassifications(true); |
|
85 |
configurator.setMoveNewTaxaToDefaultClassification(false); |
|
86 |
UnitAssociationWrapper unitAssociationWrapper = AbcdParseUtility.parseUnitsNodeList(resultStream, null); |
|
87 |
NodeList unitsList = unitAssociationWrapper.getAssociatedUnits(); |
|
88 |
Abcd206DataHolder dataHolder = new Abcd206DataHolder(); |
|
89 |
Abcd206XMLFieldGetter abcdFieldGetter = new Abcd206XMLFieldGetter(dataHolder, unitAssociationWrapper.getPrefix()); |
|
90 |
Abcd206ImportState state = new Abcd206ImportState(configurator); |
|
91 |
state.setDataHolder(dataHolder); |
|
92 |
BioCaseResponse response = null; |
|
93 |
if (unitsList != null){ |
|
94 |
for (int i = 0; i <unitsList.getLength(); i++){ |
|
95 |
Element item = (Element) unitsList.item(i); |
|
96 |
dataHolder = new Abcd206DataHolder(); |
|
97 |
abcdFieldGetter = new Abcd206XMLFieldGetter(dataHolder, unitAssociationWrapper.getPrefix()); |
|
98 |
state.setPrefix(unitAssociationWrapper.getPrefix()); |
|
99 |
Abcd206ImportParser.setUnitPropertiesXML(item, abcdFieldGetter, state); |
|
100 |
String[] tripleIdBioCase = new String[3]; |
|
101 |
tripleIdBioCase[0] =dataHolder.getUnitID(); |
|
102 |
tripleIdBioCase[1] = dataHolder.getInstitutionCode(); |
|
103 |
tripleIdBioCase[2] = dataHolder.getCollectionCode(); |
|
104 |
|
|
105 |
response = new BioCaseResponse(dataHolder, endPoint, tripleIdBioCase ); |
|
106 |
results.add(response); |
|
107 |
} |
|
108 |
} |
|
109 |
|
|
110 |
// Job job = CdmStore.getImportManager().createIOServiceJob(configurator, resultStream, SOURCE_TYPE.INPUTSTREAM); |
|
111 |
// CdmStore.getImportManager().run(job); |
|
112 |
|
|
113 |
setResults(results); |
|
114 |
|
|
115 |
} catch (ClientProtocolException e) { |
|
116 |
MessagingUtils.error(getClass(), e); |
|
117 |
// logger.error(errorMessage, e); |
|
118 |
} catch (IOException e) { |
|
119 |
//logger.error(errorMessage, e); |
|
120 |
MessagingUtils.error(getClass(), e); |
|
121 |
} |
|
122 |
|
|
123 |
// setResults(results); |
|
124 |
|
|
125 |
} |
|
126 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/e4/SpecimenProviderSelectionWizardPage.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2013 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.view.dataimport.e4; |
|
10 |
|
|
11 |
import java.net.MalformedURLException; |
|
12 |
import java.net.URISyntaxException; |
|
13 |
import java.net.URL; |
|
14 |
|
|
15 |
import javax.inject.Inject; |
|
16 |
|
|
17 |
import org.apache.commons.lang3.StringUtils; |
|
18 |
import org.eclipse.jface.wizard.WizardPage; |
|
19 |
import org.eclipse.swt.widgets.Composite; |
|
20 |
|
|
21 |
import eu.etaxonomy.cdm.common.URI; |
|
22 |
import eu.etaxonomy.cdm.ext.common.ServiceWrapperBase; |
|
23 |
import eu.etaxonomy.cdm.ext.occurrence.bioCase.BioCaseQueryServiceWrapper; |
|
24 |
import eu.etaxonomy.taxeditor.view.dataimport.QueryType; |
|
25 |
import eu.etaxonomy.taxeditor.view.search.specimen.SpecimenProviderSelectionController; |
|
26 |
|
|
27 |
/** |
|
28 |
* Wizard page for selecting the specimen provider |
|
29 |
* @author pplitzner |
|
30 |
* @date 12.09.2013 |
|
31 |
*/ |
|
32 |
public class SpecimenProviderSelectionWizardPage extends WizardPage{ |
|
33 |
|
|
34 |
private SpecimenProviderSelectionController specimenProviderSelectionController; |
|
35 |
private URI endPoint; |
|
36 |
private String dataSet; |
|
37 |
private ServiceWrapperBase serviceWrapper; |
|
38 |
|
|
39 |
@Inject |
|
40 |
public SpecimenProviderSelectionWizardPage() { |
|
41 |
super("Select specimen provider"); |
|
42 |
setTitle("Select Specimen Provider"); |
|
43 |
setDescription("Select the provider to query for specimens.\nTo query a BioCASE " + |
|
44 |
"provider the access point URL must be entered."); |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
public void createControl(Composite parent) { |
|
49 |
specimenProviderSelectionController = SpecimenProviderSelectionController.getInstance(parent, getWizard()); |
|
50 |
setControl(specimenProviderSelectionController.getComposite()); |
|
51 |
//serviceWrapper = new BioCaseQueryServiceWrapper(); |
|
52 |
|
|
53 |
} |
|
54 |
|
|
55 |
public QueryType getQueryType(){ |
|
56 |
if(specimenProviderSelectionController.getComposite().getBtnBioCaseProvider().getSelection()){ |
|
57 |
return QueryType.BIOCASE; |
|
58 |
} |
|
59 |
else {// if(specimenProviderSelectionController.getComposite().getBtnGbif().getSelection()){ |
|
60 |
return QueryType.GBIF; |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
64 |
public URI getEndPoint() { |
|
65 |
return endPoint; |
|
66 |
} |
|
67 |
|
|
68 |
@Override |
|
69 |
public boolean isPageComplete() { |
|
70 |
if(specimenProviderSelectionController.getComposite().getBtnBioCaseProvider().getSelection()){ |
|
71 |
endPoint = null; |
|
72 |
try { |
|
73 |
String dataSetAccesPoint = specimenProviderSelectionController.getComposite().getTxtAccessPoint().getText(); |
|
74 |
if (StringUtils.isNotBlank(dataSetAccesPoint)){ |
|
75 |
String accessPoint = dataSetAccesPoint; |
|
76 |
if (dataSetAccesPoint.contains(" - ")){ |
|
77 |
dataSet = dataSetAccesPoint.substring(0, dataSetAccesPoint.indexOf(" - ")); |
|
78 |
accessPoint = dataSetAccesPoint.substring(dataSetAccesPoint.indexOf(" - ") + 3); |
|
79 |
|
|
80 |
} |
|
81 |
|
|
82 |
endPoint = URI.fromUrl(new URL(accessPoint)); |
|
83 |
serviceWrapper = new BioCaseQueryServiceWrapper(); |
|
84 |
serviceWrapper.setBaseUrl(specimenProviderSelectionController.getComposite().getTxtAccessPoint().getText()); |
|
85 |
this.setErrorMessage(null); |
|
86 |
return true; |
|
87 |
} |
|
88 |
} catch (MalformedURLException e) { |
|
89 |
setErrorMessage("A valid URL has to be entered."); |
|
90 |
return false; |
|
91 |
} catch (URISyntaxException e) { |
|
92 |
setErrorMessage("A valid URL has to be entered."); |
|
93 |
return false; |
|
94 |
} |
|
95 |
} |
|
96 |
else if(specimenProviderSelectionController.getComposite().getBtnGbif().getSelection()){ |
|
97 |
this.setErrorMessage(null); |
|
98 |
return true; |
|
99 |
} |
|
100 |
return false; |
|
101 |
} |
|
102 |
|
|
103 |
public ServiceWrapperBase getQueryServiceWrapper() { |
|
104 |
return serviceWrapper; |
|
105 |
} |
|
106 |
|
|
107 |
public void setQueryServiceWrapper(ServiceWrapperBase queryServiceWrapper) { |
|
108 |
this.serviceWrapper = queryServiceWrapper; |
|
109 |
} |
|
110 |
|
|
111 |
public SpecimenProviderSelectionController getController() { |
|
112 |
return specimenProviderSelectionController; |
|
113 |
} |
|
114 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/e4/SpecimenSearchWizard.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2013 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.view.dataimport.e4; |
|
10 |
|
|
11 |
import java.io.IOException; |
|
12 |
import java.io.InputStream; |
|
13 |
|
|
14 |
import javax.inject.Inject; |
|
15 |
|
|
16 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
17 |
import org.eclipse.core.runtime.IStatus; |
|
18 |
import org.eclipse.core.runtime.Status; |
|
19 |
import org.eclipse.core.runtime.jobs.Job; |
|
20 |
import org.eclipse.e4.core.contexts.ContextInjectionFactory; |
|
21 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
|
22 |
import org.eclipse.e4.ui.model.application.MApplication; |
|
23 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
24 |
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack; |
|
25 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
|
26 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
27 |
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; |
|
28 |
import org.eclipse.jface.wizard.Wizard; |
|
29 |
import org.eclipse.swt.widgets.Display; |
|
30 |
|
|
31 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
|
32 |
import eu.etaxonomy.cdm.ext.common.ServiceWrapperBase; |
|
33 |
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery; |
|
34 |
import eu.etaxonomy.cdm.ext.occurrence.bioCase.BioCaseQueryServiceWrapper; |
|
35 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator; |
|
36 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.AbcdParseUtility; |
|
37 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.SpecimenImportReport; |
|
38 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.UnitAssociationWrapper; |
|
39 |
import eu.etaxonomy.taxeditor.store.AppModelId; |
|
40 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
41 |
import eu.etaxonomy.taxeditor.view.dataimport.QueryType; |
|
42 |
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility; |
|
43 |
import eu.etaxonomy.taxeditor.workbench.part.IEditorAreaPart; |
|
44 |
|
|
45 |
/** |
|
46 |
* Wizard for querying specimen provider. |
|
47 |
* @author pplitzner |
|
48 |
* @date 11.09.2013 |
|
49 |
*/ |
|
50 |
public class SpecimenSearchWizard extends Wizard { |
|
51 |
|
|
52 |
private OccurenceQuery query = null; |
|
53 |
private SpecimenProviderSelectionWizardPage providerSelectionPage; |
|
54 |
private SpecimenSearchWizardPage searchPage; |
|
55 |
|
|
56 |
@Inject |
|
57 |
private EPartService partService; |
|
58 |
|
|
59 |
@Inject |
|
60 |
private MApplication application; |
|
61 |
|
|
62 |
@Inject |
|
63 |
private EModelService modelService; |
|
64 |
|
|
65 |
private IEclipseContext context; |
|
66 |
|
|
67 |
/** |
|
68 |
* Creates a new SpecimenSearchWizard |
|
69 |
*/ |
|
70 |
@Inject |
|
71 |
public SpecimenSearchWizard(IEclipseContext context) { |
|
72 |
this.context = context; |
|
73 |
//default constructor needed for RCP extension points |
|
74 |
|
|
75 |
//check if connected to a data source. If not this will open an error dialog |
|
76 |
CdmStore.getCurrentApplicationConfiguration(); |
|
77 |
this.setWindowTitle("Search Specimens"); |
|
78 |
} |
|
79 |
|
|
80 |
@Override |
|
81 |
public boolean performFinish() { |
|
82 |
searchPage.getController().saveLastSate(); |
|
83 |
providerSelectionPage.getController().saveLastState(); |
|
84 |
ServiceWrapperBase serviceWrapper; |
|
85 |
DataImportView<?> dataImportView = null; |
|
86 |
boolean biocase = providerSelectionPage.getQueryType().equals(QueryType.BIOCASE); |
|
87 |
query = searchPage.getQuery(biocase); |
|
88 |
|
|
89 |
//query for specific dataset...<DataSets><DataSet><Metadata><Description><Representation language="EN"><Title>... |
|
90 |
Abcd206ImportConfigurator configurator = CdmStore.getImportManager().AbcdConfigurator(); |
|
91 |
configurator.setOccurenceQuery(query); |
|
92 |
configurator.setSourceUri(providerSelectionPage.getEndPoint()); |
|
93 |
configurator.setAddMediaAsMediaSpecimen(true); |
|
94 |
configurator.setDbSchemaValidation(DbSchemaValidation.CREATE); |
|
95 |
configurator.setIgnoreAuthorship(true); |
|
96 |
configurator.setMoveNewTaxaToDefaultClassification(false); |
|
97 |
|
|
98 |
try { |
|
99 |
serviceWrapper = providerSelectionPage.getQueryServiceWrapper(); |
|
100 |
InputStream stream = null; |
|
101 |
MPart part = null; |
|
102 |
if (providerSelectionPage.getQueryType().equals(QueryType.BIOCASE)){ |
|
103 |
stream =((BioCaseQueryServiceWrapper) serviceWrapper).query(query, configurator.getSourceUri()); |
|
104 |
SpecimenImportReport report = new SpecimenImportReport(); |
|
105 |
UnitAssociationWrapper unitNodesList = AbcdParseUtility.parseUnitsNodeList(stream, report); |
|
106 |
|
|
107 |
part = partService.createPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_VIEW_DATAIMPORT_E4_SPECIMENIMPORTVIEWE4); |
|
108 |
part = partService.showPart(part, PartState.ACTIVATE); |
|
109 |
SpecimenImportView specimenImportView = (SpecimenImportView) part.getObject(); |
|
110 |
specimenImportView.setEndpoint(providerSelectionPage.getEndPoint()); |
|
111 |
specimenImportView.setQuery(query); |
|
112 |
|
|
113 |
dataImportView = specimenImportView; |
|
114 |
|
|
115 |
} else{ |
|
116 |
part = partService.createPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_VIEW_DATAIMPORT_E4_GBIFRESPONSEIMPORTVIEWE4); |
|
117 |
part = partService.showPart(part, PartState.ACTIVATE); |
|
118 |
GbifResponseImportView gbifImportView = (GbifResponseImportView) part.getObject(); |
|
119 |
gbifImportView.setQuery(query); |
|
120 |
|
|
121 |
dataImportView = gbifImportView; |
|
122 |
|
|
123 |
} |
|
124 |
if(part.getObject() instanceof IEditorAreaPart){ |
|
125 |
MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService); |
|
126 |
if(editorAreaPartStack!=null){ |
|
127 |
editorAreaPartStack.getChildren().add(part); |
|
128 |
} |
|
129 |
part = partService.showPart(part, PartState.VISIBLE); |
|
130 |
} |
|
131 |
} catch (IOException e) { |
|
132 |
e.printStackTrace(); |
|
133 |
} |
|
134 |
// CdmStore.getImportManager().run(configurator); |
|
135 |
|
|
136 |
// try { |
|
137 |
// switch (providerSelectionPage.getQueryType()) { |
|
138 |
// case BIOCASE: |
|
139 |
// SpecimenImportView specimenImportView = (SpecimenImportView) TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage() |
|
140 |
// .showView(SpecimenImportView.ID, "query_"+query.toString().replaceAll(",", ""),IWorkbenchPage.VIEW_ACTIVATE); |
|
141 |
// specimenImportView.setEndpoint(providerSelectionPage.getEndPoint()); |
|
142 |
// dataImportView = specimenImportView; |
|
143 |
// break; |
|
144 |
// case GBIF: |
|
145 |
// dataImportView = (GbifResponseImportView) TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage() |
|
146 |
// .showView(GbifResponseImportView.ID, "query_"+query.toString().replaceAll(",", ""),IWorkbenchPage.VIEW_ACTIVATE); |
|
147 |
// break; |
|
148 |
// } |
|
149 |
// } catch ( PartInitException e ) { |
|
150 |
// logger.error("Could not open import view for query: " + query.toString(), e); |
|
151 |
// } |
|
152 |
// if(dataImportView!=null){ |
|
153 |
// dataImportView.setQuery(query); |
|
154 |
//// dataImportView.query(); |
|
155 |
//// Display.getDefault().asyncExec(new Runnable() { |
|
156 |
//// |
|
157 |
//// @Override |
|
158 |
//// public void run() { |
|
159 |
//// CdmStore.getContextManager().notifyContextRefresh(); |
|
160 |
//// } |
|
161 |
//// }); |
|
162 |
Job queryJob = new QueryJob("Query specimen provider", dataImportView); |
|
163 |
queryJob.schedule(); |
|
164 |
|
|
165 |
return true; |
|
166 |
} |
|
167 |
|
|
168 |
@Override |
|
169 |
public void addPages() { |
|
170 |
addPage(providerSelectionPage); |
|
171 |
addPage(searchPage); |
|
172 |
} |
|
173 |
|
|
174 |
public void init() { |
|
175 |
providerSelectionPage = ContextInjectionFactory.make(SpecimenProviderSelectionWizardPage.class, context); |
|
176 |
// new SpecimenProviderSelectionWizardPage("Select specimen provider"); |
|
177 |
// searchPage = new SpecimenSearchWizardPage("Specimen Search"); |
|
178 |
searchPage = ContextInjectionFactory.make(SpecimenSearchWizardPage.class, context); |
|
179 |
} |
|
180 |
|
|
181 |
private class QueryJob extends Job{ |
|
182 |
|
|
183 |
private final DataImportView<?> view; |
|
184 |
|
|
185 |
public QueryJob(String name, DataImportView<?> view) { |
|
186 |
super(name); |
|
187 |
this.view = view; |
|
188 |
} |
|
189 |
|
|
190 |
@Override |
|
191 |
protected IStatus run(IProgressMonitor monitor) { |
|
192 |
view.getConversationHolder().bind(); |
|
193 |
view.query(); |
|
194 |
Display.getDefault().asyncExec(new Runnable() { |
|
195 |
|
|
196 |
@Override |
|
197 |
public void run() { |
|
198 |
CdmStore.getContextManager().notifyContextRefresh(); |
|
199 |
} |
|
200 |
}); |
|
201 |
return Status.OK_STATUS; |
|
202 |
} |
|
203 |
|
|
204 |
} |
|
205 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/e4/SpecimenSearchWizardPage.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2013 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.view.dataimport.e4; |
|
10 |
|
|
11 |
import java.util.Calendar; |
|
12 |
|
|
13 |
import javax.inject.Inject; |
|
14 |
|
|
15 |
import org.eclipse.jface.wizard.WizardPage; |
|
16 |
import org.eclipse.swt.widgets.Composite; |
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery; |
|
19 |
import eu.etaxonomy.taxeditor.view.search.specimen.SpecimenSearchController; |
|
20 |
|
|
21 |
|
|
22 |
/** |
|
23 |
* Wizard page for entering search parameters |
|
24 |
* @author pplitzner |
|
25 |
* @date 12.09.2013 |
|
26 |
* |
|
27 |
*/ |
|
28 |
public class SpecimenSearchWizardPage extends WizardPage{ |
|
29 |
|
|
30 |
private SpecimenSearchController specimenSearchController; |
|
31 |
|
|
32 |
@Inject |
|
33 |
public SpecimenSearchWizardPage() { |
|
34 |
super("Specimen Search"); |
|
35 |
setDescription("Specify search parameters for external search query."); |
|
36 |
setTitle("Search Specimens"); |
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
public void createControl(Composite parent) { |
|
41 |
specimenSearchController = SpecimenSearchController.getInstance(parent); |
|
42 |
setControl(specimenSearchController.getComposite()); |
|
43 |
} |
|
44 |
|
|
45 |
/** |
|
46 |
* Returns an {@link OccurenceQuery} filled with the parameters defined in this wizard page |
|
47 |
* @return |
|
48 |
*/ |
|
49 |
public OccurenceQuery getQuery(boolean biocase) { |
|
50 |
String accessionNumber = specimenSearchController.getAccessionNumber(); |
|
51 |
String collector = specimenSearchController.getCollector(); |
|
52 |
String collectorsNumber = specimenSearchController.getCollectorNumber(); |
|
53 |
String country = specimenSearchController.getCountry(biocase); |
|
54 |
Calendar dateFrom = specimenSearchController.getDateFrom(); |
|
55 |
Calendar dateTo = specimenSearchController.getDateTo(); |
|
56 |
String herbarium = specimenSearchController.getHerbarium(); |
|
57 |
String locality = specimenSearchController.getLocality(); |
|
58 |
String taxonName = specimenSearchController.getTaxonName(); |
|
59 |
OccurenceQuery query = new OccurenceQuery(taxonName, collector, collectorsNumber, accessionNumber, herbarium, country, locality, dateFrom, dateTo, false); |
|
60 |
query.higherTaxon =specimenSearchController.getHigherTaxon(); |
|
61 |
return query; |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* @return the specimenSearchController |
|
66 |
*/ |
|
67 |
public SpecimenSearchController getController() { |
|
68 |
return specimenSearchController; |
|
69 |
} |
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmDataViewer.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.view.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.core.services.log.Logger; |
|
17 |
import org.eclipse.jface.viewers.Viewer; |
|
18 |
import org.eclipse.swt.SWT; |
|
19 |
import org.eclipse.swt.SWTException; |
|
20 |
import org.eclipse.swt.widgets.Composite; |
|
21 |
import org.eclipse.swt.widgets.Control; |
|
22 |
import org.eclipse.swt.widgets.Display; |
|
23 |
import org.eclipse.ui.forms.IFormPart; |
|
24 |
import org.eclipse.ui.forms.ManagedForm; |
|
25 |
import org.eclipse.ui.forms.widgets.ScrolledForm; |
|
26 |
|
|
27 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
28 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
|
29 |
import eu.etaxonomy.taxeditor.model.IDirtyMarkable; |
|
30 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
31 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
|
32 |
import eu.etaxonomy.taxeditor.remoting.CdmEagerLoadingException; |
|
33 |
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection; |
|
34 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
|
35 |
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants; |
|
36 |
import eu.etaxonomy.taxeditor.ui.element.RootElement; |
|
37 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.EmptySection; |
|
38 |
import eu.etaxonomy.taxeditor.view.detail.CdmSectionPart; |
|
39 |
|
|
40 |
/** |
|
41 |
* |
|
42 |
* @author pplitzner |
|
43 |
* @date 18.07.2017 |
|
44 |
* |
|
45 |
*/ |
|
46 |
public abstract class AbstractCdmDataViewer extends Viewer implements IConversationEnabled{ |
|
47 |
@Inject |
|
48 |
private Logger logger; |
|
49 |
|
|
50 |
protected ManagedForm managedForm; |
|
51 |
|
|
52 |
protected CdmFormFactory formFactory; |
|
53 |
|
|
54 |
protected ScrolledForm scrolledForm; |
|
55 |
|
|
56 |
private Composite body; |
|
57 |
|
|
58 |
protected RootElement rootElement; |
|
59 |
|
|
60 |
@Inject |
|
61 |
protected IEclipseContext context; |
|
62 |
|
|
63 |
//TODO: create a super class for this? |
|
64 |
private Object input; |
|
65 |
|
|
66 |
protected IDirtyMarkable part; |
|
67 |
|
|
68 |
@Inject |
|
69 |
public AbstractCdmDataViewer() { |
|
70 |
|
|
71 |
} |
|
72 |
|
|
73 |
public void init(Composite parent, IDirtyMarkable part) { |
|
74 |
this.part = part; |
|
75 |
|
|
76 |
managedForm = new ManagedForm(parent){ |
|
77 |
|
|
78 |
@Override |
|
79 |
public void dirtyStateChanged() { |
|
80 |
markViewPartDirty(); |
|
81 |
} |
|
82 |
}; |
|
83 |
|
|
84 |
createFormFactory(); |
|
85 |
|
|
86 |
scrolledForm = managedForm.getForm(); |
|
87 |
|
|
88 |
body = scrolledForm.getBody(); |
|
89 |
|
|
90 |
body.setLayout(LayoutConstants.LAYOUT()); |
|
91 |
|
|
92 |
rootElement = new RootElement(formFactory, body); |
|
93 |
} |
|
94 |
|
|
95 |
|
|
96 |
protected void createEmptySection(String message, RootElement parent) { |
|
97 |
destroySections(); |
|
98 |
|
|
99 |
EmptySection emptySection = formFactory.createEmptySection(message, formFactory, parent, SWT.NONE); |
|
100 |
|
|
101 |
addPart(emptySection); |
|
102 |
} |
|
103 |
|
|
104 |
public void showEmptyPage(String message){ |
|
105 |
destroySections(); |
|
106 |
createEmptySection(message, rootElement); |
|
107 |
} |
|
108 |
|
|
109 |
protected void markViewPartDirty(){ |
Also available in: Unified diff
ref #9448: remove E4 from file names