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.ui.openurl;
|
11
|
|
12
|
import java.util.List;
|
13
|
|
14
|
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
15
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
16
|
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
17
|
import org.eclipse.jface.viewers.TableViewer;
|
18
|
import org.eclipse.jface.wizard.WizardPage;
|
19
|
import org.eclipse.swt.SWT;
|
20
|
import org.eclipse.swt.layout.GridData;
|
21
|
import org.eclipse.swt.layout.GridLayout;
|
22
|
import org.eclipse.swt.widgets.Composite;
|
23
|
|
24
|
import eu.etaxonomy.cdm.ext.openurl.OpenUrlReference;
|
25
|
|
26
|
|
27
|
/**
|
28
|
* @author n.hoffmann
|
29
|
* @created Jan 31, 2011
|
30
|
* @version 1.0
|
31
|
*/
|
32
|
public class OpenUrlResultPage extends WizardPage {
|
33
|
|
34
|
public static final String NAME = "OpenUrlResultPage";
|
35
|
|
36
|
private TableViewer viewer;
|
37
|
|
38
|
/**
|
39
|
* @param pageName
|
40
|
*/
|
41
|
protected OpenUrlResultPage() {
|
42
|
super(NAME);
|
43
|
setTitle("Choose from results");
|
44
|
}
|
45
|
|
46
|
/* (non-Javadoc)
|
47
|
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
48
|
*/
|
49
|
@Override
|
50
|
public void createControl(Composite parent) {
|
51
|
setPageComplete(false);
|
52
|
|
53
|
Composite container = getWizard().getFormFactory().createComposite(parent);
|
54
|
|
55
|
container.setLayout(new GridLayout());
|
56
|
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
57
|
|
58
|
viewer = new TableViewer(container);
|
59
|
viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
60
|
|
61
|
viewer.setContentProvider(new OpenUrlContentProvider());
|
62
|
viewer.setLabelProvider(new OpenUrlLabelProvider());
|
63
|
|
64
|
List<OpenUrlReference> results = getWizard().getResult();
|
65
|
|
66
|
if(results == null || results.isEmpty()){
|
67
|
String nomenclatuaralCitation = getWizard().getReference().getNomenclaturalCitation(getWizard().getReferenceDetail());
|
68
|
setMessage("No results for the given reference: " + nomenclatuaralCitation, WizardPage.WARNING);
|
69
|
}
|
70
|
viewer.setInput(results);
|
71
|
|
72
|
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
73
|
|
74
|
@Override
|
75
|
public void selectionChanged(SelectionChangedEvent event) {
|
76
|
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
|
77
|
|
78
|
OpenUrlReference reference = (OpenUrlReference) selection.getFirstElement();
|
79
|
|
80
|
getWizard().setOpenUrlReference(reference);
|
81
|
|
82
|
|
83
|
((OpenUrlReferencePage) getNextPage()).displayImage();
|
84
|
|
85
|
setPageComplete(true);
|
86
|
}
|
87
|
});
|
88
|
|
89
|
setControl(container);
|
90
|
|
91
|
}
|
92
|
|
93
|
public OpenUrlSelectorWizard getWizard(){
|
94
|
return (OpenUrlSelectorWizard) super.getWizard();
|
95
|
}
|
96
|
|
97
|
/* (non-Javadoc)
|
98
|
* @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage()
|
99
|
*/
|
100
|
@Override
|
101
|
public boolean canFlipToNextPage() {
|
102
|
return super.canFlipToNextPage();
|
103
|
}
|
104
|
|
105
|
/* (non-Javadoc)
|
106
|
* @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
|
107
|
*/
|
108
|
@Override
|
109
|
public boolean isPageComplete() {
|
110
|
return super.isPageComplete();
|
111
|
}
|
112
|
|
113
|
}
|