Revision 3ee20195
Added by Patrick Plitzner about 10 years ago
- moved actual query execution from the wizard to the editor
.gitattributes | ||
---|---|---|
117 | 117 |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsView.java -text |
118 | 118 |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/DataImportEditor.java -text |
119 | 119 |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/DataImportEditorLineDisplayStrategy.java -text |
120 |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/SpecimenEditorInput.java -text |
|
120 |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/DataImportSpecimenEditorInput.java -text
|
|
121 | 121 |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/wizard/SpecimenSearchWizard.java -text |
122 | 122 |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/wizard/SpecimenSearchWizardPage.java -text |
123 | 123 |
eu.etaxonomy.taxeditor.bulkeditor/src/test/java/eu/etaxonomy/taxeditor/bulkeditor/Application.java -text |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineDocumentProvider.java | ||
---|---|---|
26 | 26 |
import org.eclipse.ui.texteditor.AbstractDocumentProvider; |
27 | 27 |
|
28 | 28 |
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; |
29 |
import eu.etaxonomy.taxeditor.dataimport.SpecimenEditorInput; |
|
29 |
import eu.etaxonomy.taxeditor.dataimport.DataImportSpecimenEditorInput;
|
|
30 | 30 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
31 | 31 |
|
32 | 32 |
|
... | ... | |
219 | 219 |
if (element instanceof AbstractBulkEditorInput) { |
220 | 220 |
return ((AbstractBulkEditorInput)element).getModel(); |
221 | 221 |
} |
222 |
else if(element instanceof SpecimenEditorInput){ |
|
223 |
return ((SpecimenEditorInput) element).getResults(); |
|
222 |
else if(element instanceof DataImportSpecimenEditorInput){
|
|
223 |
return ((DataImportSpecimenEditorInput) element).getResults();
|
|
224 | 224 |
} |
225 | 225 |
return null; |
226 | 226 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/DataImportEditor.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.taxeditor.dataimport; |
11 | 11 |
|
12 |
import org.eclipse.core.runtime.CoreException; |
|
13 |
import org.eclipse.ui.IEditorInput; |
|
14 |
|
|
12 | 15 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
13 | 16 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.AnnotatedLineEditor; |
14 | 17 |
|
... | ... | |
36 | 39 |
@Override |
37 | 40 |
protected void initializeEditor() { |
38 | 41 |
super.initializeEditor(); |
39 |
String editorTitle = "Data Import Editor"; |
|
40 |
setPartName(editorTitle); |
|
41 |
setTitleToolTip(editorTitle); |
|
42 | 42 |
setLineDisplayStrategy(new DataImportEditorLineDisplayStrategy()); |
43 | 43 |
} |
44 | 44 |
|
45 |
/* (non-Javadoc) |
|
46 |
* @see eu.etaxonomy.taxeditor.annotatedlineeditor.AnnotatedLineEditor#doSetInput(org.eclipse.ui.IEditorInput) |
|
47 |
*/ |
|
48 |
@Override |
|
49 |
protected void doSetInput(IEditorInput input) throws CoreException { |
|
50 |
super.doSetInput(input); |
|
51 |
setPartName(input.getName()); |
|
52 |
setTitleToolTip(input.getName()); |
|
53 |
} |
|
54 |
|
|
45 | 55 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/DataImportSpecimenEditorInput.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2013 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.taxeditor.dataimport; |
|
11 |
|
|
12 |
import java.io.IOException; |
|
13 |
import java.net.URISyntaxException; |
|
14 |
import java.util.List; |
|
15 |
|
|
16 |
import org.apache.http.client.ClientProtocolException; |
|
17 |
import org.apache.log4j.Logger; |
|
18 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
19 |
import org.eclipse.ui.IEditorInput; |
|
20 |
import org.eclipse.ui.IPersistableElement; |
|
21 |
|
|
22 |
import eu.etaxonomy.cdm.ext.biocase.BioCaseQuery; |
|
23 |
import eu.etaxonomy.cdm.ext.biocase.BioCaseQueryServiceWrapper; |
|
24 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
|
25 |
|
|
26 |
/** |
|
27 |
* @author pplitzner |
|
28 |
* @date 20.09.2013 |
|
29 |
* |
|
30 |
*/ |
|
31 |
public class DataImportSpecimenEditorInput implements IEditorInput { |
|
32 |
|
|
33 |
private static Logger logger = Logger.getLogger(DataImportSpecimenEditorInput.class); |
|
34 |
|
|
35 |
private List<SpecimenOrObservationBase> results; |
|
36 |
private BioCaseQuery query; |
|
37 |
|
|
38 |
/** |
|
39 |
* @param results |
|
40 |
*/ |
|
41 |
public DataImportSpecimenEditorInput(BioCaseQuery query) { |
|
42 |
this.query = query; |
|
43 |
} |
|
44 |
|
|
45 |
/* (non-Javadoc) |
|
46 |
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) |
|
47 |
*/ |
|
48 |
@Override |
|
49 |
public Object getAdapter(Class adapter) { |
|
50 |
// TODO Auto-generated method stub |
|
51 |
return null; |
|
52 |
} |
|
53 |
|
|
54 |
/* (non-Javadoc) |
|
55 |
* @see org.eclipse.ui.IEditorInput#exists() |
|
56 |
*/ |
|
57 |
@Override |
|
58 |
public boolean exists() { |
|
59 |
return false; |
|
60 |
} |
|
61 |
|
|
62 |
/* (non-Javadoc) |
|
63 |
* @see org.eclipse.ui.IEditorInput#getImageDescriptor() |
|
64 |
*/ |
|
65 |
@Override |
|
66 |
public ImageDescriptor getImageDescriptor() { |
|
67 |
// TODO Auto-generated method stub |
|
68 |
return null; |
|
69 |
} |
|
70 |
|
|
71 |
/* (non-Javadoc) |
|
72 |
* @see org.eclipse.ui.IEditorInput#getName() |
|
73 |
*/ |
|
74 |
@Override |
|
75 |
public String getName() { |
|
76 |
return query.toString(); |
|
77 |
} |
|
78 |
|
|
79 |
/* (non-Javadoc) |
|
80 |
* @see org.eclipse.ui.IEditorInput#getPersistable() |
|
81 |
*/ |
|
82 |
@Override |
|
83 |
public IPersistableElement getPersistable() { |
|
84 |
return null; |
|
85 |
} |
|
86 |
|
|
87 |
/* (non-Javadoc) |
|
88 |
* @see org.eclipse.ui.IEditorInput#getToolTipText() |
|
89 |
*/ |
|
90 |
@Override |
|
91 |
public String getToolTipText() { |
|
92 |
return query.toString(); |
|
93 |
} |
|
94 |
|
|
95 |
/** |
|
96 |
* @return the results |
|
97 |
*/ |
|
98 |
public List<SpecimenOrObservationBase> getResults() { |
|
99 |
String errorMessage = "Could not execute query " + query; |
|
100 |
try { |
|
101 |
return new BioCaseQueryServiceWrapper().query(query); |
|
102 |
} catch (ClientProtocolException e) { |
|
103 |
logger.error(errorMessage, e); |
|
104 |
} catch (IOException e) { |
|
105 |
logger.error(errorMessage, e); |
|
106 |
} catch (URISyntaxException e) { |
|
107 |
logger.error(errorMessage, e); |
|
108 |
} |
|
109 |
return null; |
|
110 |
} |
|
111 |
|
|
112 |
/* (non-Javadoc) |
|
113 |
* @see java.lang.Object#hashCode() |
|
114 |
*/ |
|
115 |
@Override |
|
116 |
public int hashCode() { |
|
117 |
final int prime = 31; |
|
118 |
int result = 1; |
|
119 |
result = prime * result + ((query == null) ? 0 : query.hashCode()); |
|
120 |
return result; |
|
121 |
} |
|
122 |
|
|
123 |
/* (non-Javadoc) |
|
124 |
* @see java.lang.Object#equals(java.lang.Object) |
|
125 |
*/ |
|
126 |
@Override |
|
127 |
public boolean equals(Object obj) { |
|
128 |
if (this == obj) { |
|
129 |
return true; |
|
130 |
} |
|
131 |
if (obj == null) { |
|
132 |
return false; |
|
133 |
} |
|
134 |
if (getClass() != obj.getClass()) { |
|
135 |
return false; |
|
136 |
} |
|
137 |
DataImportSpecimenEditorInput other = (DataImportSpecimenEditorInput) obj; |
|
138 |
if (query == null) { |
|
139 |
if (other.query != null) { |
|
140 |
return false; |
|
141 |
} |
|
142 |
} else if (!query.equals(other.query)) { |
|
143 |
return false; |
|
144 |
} |
|
145 |
if (results == null) { |
|
146 |
if (other.results != null) { |
|
147 |
return false; |
|
148 |
} |
|
149 |
} |
|
150 |
return true; |
|
151 |
} |
|
152 |
|
|
153 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/SpecimenEditorInput.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2013 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.taxeditor.dataimport; |
|
11 |
|
|
12 |
import java.util.List; |
|
13 |
|
|
14 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
15 |
import org.eclipse.ui.IEditorInput; |
|
16 |
import org.eclipse.ui.IPersistableElement; |
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
|
19 |
|
|
20 |
/** |
|
21 |
* @author pplitzner |
|
22 |
* @date 20.09.2013 |
|
23 |
* |
|
24 |
*/ |
|
25 |
public class SpecimenEditorInput implements IEditorInput { |
|
26 |
|
|
27 |
private List<SpecimenOrObservationBase> results; |
|
28 |
|
|
29 |
/** |
|
30 |
* @param results |
|
31 |
*/ |
|
32 |
public SpecimenEditorInput(List<SpecimenOrObservationBase> results) { |
|
33 |
this.results = results; |
|
34 |
} |
|
35 |
|
|
36 |
/* (non-Javadoc) |
|
37 |
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) |
|
38 |
*/ |
|
39 |
@Override |
|
40 |
public Object getAdapter(Class adapter) { |
|
41 |
// TODO Auto-generated method stub |
|
42 |
return null; |
|
43 |
} |
|
44 |
|
|
45 |
/* (non-Javadoc) |
|
46 |
* @see org.eclipse.ui.IEditorInput#exists() |
|
47 |
*/ |
|
48 |
@Override |
|
49 |
public boolean exists() { |
|
50 |
// TODO Auto-generated method stub |
|
51 |
return false; |
|
52 |
} |
|
53 |
|
|
54 |
/* (non-Javadoc) |
|
55 |
* @see org.eclipse.ui.IEditorInput#getImageDescriptor() |
|
56 |
*/ |
|
57 |
@Override |
|
58 |
public ImageDescriptor getImageDescriptor() { |
|
59 |
// TODO Auto-generated method stub |
|
60 |
return null; |
|
61 |
} |
|
62 |
|
|
63 |
/* (non-Javadoc) |
|
64 |
* @see org.eclipse.ui.IEditorInput#getName() |
|
65 |
*/ |
|
66 |
@Override |
|
67 |
public String getName() { |
|
68 |
return "inputName"; |
|
69 |
} |
|
70 |
|
|
71 |
/* (non-Javadoc) |
|
72 |
* @see org.eclipse.ui.IEditorInput#getPersistable() |
|
73 |
*/ |
|
74 |
@Override |
|
75 |
public IPersistableElement getPersistable() { |
|
76 |
// TODO Auto-generated method stub |
|
77 |
return null; |
|
78 |
} |
|
79 |
|
|
80 |
/* (non-Javadoc) |
|
81 |
* @see org.eclipse.ui.IEditorInput#getToolTipText() |
|
82 |
*/ |
|
83 |
@Override |
|
84 |
public String getToolTipText() { |
|
85 |
return "tooltip"; |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* @return the results |
|
90 |
*/ |
|
91 |
public List<SpecimenOrObservationBase> getResults() { |
|
92 |
return results; |
|
93 |
} |
|
94 |
|
|
95 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/wizard/SpecimenSearchWizard.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.taxeditor.dataimport.wizard; |
11 | 11 |
|
12 |
import java.io.IOException; |
|
13 |
import java.net.URISyntaxException; |
|
14 |
import java.util.List; |
|
15 |
|
|
16 |
import org.apache.http.client.ClientProtocolException; |
|
17 | 12 |
import org.apache.log4j.Logger; |
18 | 13 |
import org.eclipse.jface.viewers.IStructuredSelection; |
19 | 14 |
import org.eclipse.jface.wizard.Wizard; |
... | ... | |
24 | 19 |
import org.eclipse.ui.PlatformUI; |
25 | 20 |
|
26 | 21 |
import eu.etaxonomy.cdm.ext.biocase.BioCaseQuery; |
27 |
import eu.etaxonomy.cdm.ext.biocase.BioCaseQueryServiceWrapper; |
|
28 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
|
29 | 22 |
import eu.etaxonomy.taxeditor.dataimport.DataImportEditor; |
30 |
import eu.etaxonomy.taxeditor.dataimport.SpecimenEditorInput; |
|
23 |
import eu.etaxonomy.taxeditor.dataimport.DataImportSpecimenEditorInput;
|
|
31 | 24 |
|
32 | 25 |
/** |
33 | 26 |
* @author pplitzner |
... | ... | |
35 | 28 |
* |
36 | 29 |
*/ |
37 | 30 |
public class SpecimenSearchWizard extends Wizard implements IImportWizard { |
31 |
@SuppressWarnings("unused") |
|
38 | 32 |
private static final Logger logger = Logger.getLogger(SpecimenSearchWizard.class); |
39 | 33 |
|
40 |
private BioCaseQueryServiceWrapper bioCaseQueryServiceWrapper; |
|
41 | 34 |
private BioCaseQuery query; |
42 |
private List<SpecimenOrObservationBase> results; |
|
43 | 35 |
|
44 | 36 |
/** |
45 |
* |
|
37 |
* Creates a new SpecimenSearchWizard
|
|
46 | 38 |
*/ |
47 | 39 |
public SpecimenSearchWizard() { |
48 |
query = new BioCaseQuery(); |
|
49 |
bioCaseQueryServiceWrapper = new BioCaseQueryServiceWrapper(); |
|
50 |
this.results = getResults(); |
|
40 |
//default constructor needed for RCP extension points |
|
51 | 41 |
} |
52 | 42 |
|
53 | 43 |
|
... | ... | |
59 | 49 |
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); |
60 | 50 |
|
61 | 51 |
try { |
62 |
SpecimenEditorInput input = new SpecimenEditorInput(results);
|
|
52 |
DataImportSpecimenEditorInput input = new DataImportSpecimenEditorInput(query);
|
|
63 | 53 |
input.getToolTipText(); |
64 | 54 |
page.openEditor(input, DataImportEditor.ID, true); |
65 | 55 |
} catch ( PartInitException e ) { |
... | ... | |
73 | 63 |
*/ |
74 | 64 |
@Override |
75 | 65 |
public void addPages() { |
76 |
addPage(new SpecimenSearchWizardPage("Specimen Search", results)); |
|
77 |
} |
|
78 |
|
|
79 |
public List<SpecimenOrObservationBase> getResults(){ |
|
80 |
try { |
|
81 |
return bioCaseQueryServiceWrapper.query(query); |
|
82 |
} catch (ClientProtocolException e) { |
|
83 |
// TODO Auto-generated catch block |
|
84 |
e.printStackTrace(); |
|
85 |
} catch (IOException e) { |
|
86 |
// TODO Auto-generated catch block |
|
87 |
e.printStackTrace(); |
|
88 |
} catch (URISyntaxException e) { |
|
89 |
// TODO Auto-generated catch block |
|
90 |
e.printStackTrace(); |
|
91 |
} |
|
92 |
return null; |
|
66 |
addPage(new SpecimenSearchWizardPage("Specimen Search")); |
|
93 | 67 |
} |
94 | 68 |
|
95 | 69 |
/* (non-Javadoc) |
... | ... | |
97 | 71 |
*/ |
98 | 72 |
@Override |
99 | 73 |
public void init(IWorkbench workbench, IStructuredSelection selection) { |
74 |
query = new BioCaseQuery(); |
|
100 | 75 |
} |
101 | 76 |
|
102 | 77 |
/** |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/wizard/SpecimenSearchWizardPage.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.taxeditor.dataimport.wizard; |
11 | 11 |
|
12 |
import java.util.List; |
|
13 |
|
|
14 | 12 |
import org.eclipse.jface.wizard.WizardPage; |
15 | 13 |
import org.eclipse.swt.widgets.Composite; |
16 | 14 |
|
17 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
|
18 | 15 |
import eu.etaxonomy.taxeditor.ui.campanula.specimenSearch.SpecimenSearchController; |
19 | 16 |
|
20 | 17 |
/** |
... | ... | |
24 | 21 |
*/ |
25 | 22 |
public class SpecimenSearchWizardPage extends WizardPage{ |
26 | 23 |
|
27 |
private List<SpecimenOrObservationBase> results; |
|
28 |
|
|
29 | 24 |
/** |
30 | 25 |
* @param pageName |
31 | 26 |
*/ |
32 |
protected SpecimenSearchWizardPage(String pageName, List<SpecimenOrObservationBase> results) {
|
|
27 |
protected SpecimenSearchWizardPage(String pageName) { |
|
33 | 28 |
super(pageName); |
34 |
this.results = results; |
|
35 | 29 |
} |
36 | 30 |
|
37 | 31 |
/* (non-Javadoc) |
... | ... | |
42 | 36 |
setControl(new SpecimenSearchController(parent).getComposite()); |
43 | 37 |
} |
44 | 38 |
|
45 |
/* (non-Javadoc) |
|
46 |
* @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean) |
|
47 |
*/ |
|
48 |
@Override |
|
49 |
public void setVisible(boolean visible) { |
|
50 |
super.setVisible(visible); |
|
51 |
if(visible==false){ |
|
52 |
((SpecimenSearchWizard) getWizard()).getResults(); |
|
53 |
} |
|
54 |
} |
|
55 | 39 |
} |
Also available in: Unified diff