Revision 26334359
Added by Patrick Plitzner about 8 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/ConceptViewPart.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
package eu.etaxonomy.taxeditor.editor.view.concept; |
12 | 12 |
|
13 |
import java.util.Map.Entry; |
|
14 |
|
|
13 | 15 |
import org.eclipse.jface.action.GroupMarker; |
14 | 16 |
import org.eclipse.jface.action.MenuManager; |
15 | 17 |
import org.eclipse.jface.viewers.ISelection; |
18 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
16 | 19 |
import org.eclipse.jface.viewers.ListViewer; |
17 | 20 |
import org.eclipse.jface.viewers.StructuredSelection; |
18 | 21 |
import org.eclipse.jface.viewers.Viewer; |
... | ... | |
26 | 29 |
import org.eclipse.ui.IWorkbenchPart; |
27 | 30 |
|
28 | 31 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
32 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; |
|
29 | 33 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor; |
30 | 34 |
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor; |
31 | 35 |
import eu.etaxonomy.taxeditor.editor.key.AbstractGraphKeyEditor; |
... | ... | |
40 | 44 |
* @created Jan 24, 2011 |
41 | 45 |
* @version 1.0 |
42 | 46 |
*/ |
43 |
public class ConceptViewPart extends AbstractCdmEditorViewPart implements IPartContentHasDetails, IPartContentHasSupplementalData{ |
|
47 |
public class ConceptViewPart extends AbstractCdmEditorViewPart |
|
48 |
implements IPartContentHasDetails, IPartContentHasSupplementalData{ |
|
44 | 49 |
|
45 | 50 |
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.concept"; |
46 | 51 |
|
47 |
private ListViewer viewer;
|
|
52 |
private ConceptRelationViewer viewer;
|
|
48 | 53 |
|
49 | 54 |
@Override |
50 | 55 |
protected void selectionChanged_internal(IWorkbenchPart part, ISelection selection) { |
56 |
if(part == this){ |
|
57 |
return; |
|
58 |
} |
|
51 | 59 |
if(AbstractUtility.getActiveEditor() == null){ |
52 | 60 |
showEmptyPage(); |
53 | 61 |
return; |
... | ... | |
95 | 103 |
|
96 | 104 |
@Override |
97 | 105 |
public void createViewer(Composite parent) { |
98 |
viewer = new ListViewer(parent);
|
|
106 |
viewer = new ConceptRelationViewer(parent);
|
|
99 | 107 |
|
100 | 108 |
viewer.setContentProvider(new ConceptContentProvider()); |
101 | 109 |
viewer.setLabelProvider(new ConceptLabelProvider()); |
... | ... | |
126 | 134 |
super.changed(object); |
127 | 135 |
} |
128 | 136 |
|
137 |
private class ConceptRelationViewer extends ListViewer { |
|
138 |
|
|
139 |
public ConceptRelationViewer(Composite parent) { |
|
140 |
super(parent); |
|
141 |
} |
|
142 |
|
|
143 |
@Override |
|
144 |
public ISelection getSelection() { |
|
145 |
ISelection selection = super.getSelection(); |
|
146 |
if(selection instanceof IStructuredSelection && !selection.isEmpty()){ |
|
147 |
Object firstElement = ((IStructuredSelection) selection).getFirstElement(); |
|
148 |
TaxonRelationship taxonRelationship = ((Entry<TaxonRelationship, Taxon>)firstElement).getKey(); |
|
149 |
return new StructuredSelection(taxonRelationship); |
|
150 |
|
|
151 |
} |
|
152 |
return selection; |
|
153 |
} |
|
154 |
|
|
155 |
@Override |
|
156 |
public void setSelection(ISelection selection) { |
|
157 |
super.setSelection(selection); |
|
158 |
} |
|
159 |
|
|
160 |
} |
|
161 |
|
|
129 | 162 |
} |
Also available in: Unified diff
fix #5801 Fix exceptions during selection propagation for concept
relationship view