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