Revision 8f6d819a
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/e4/MediaViewPartE4.java | ||
---|---|---|
18 | 18 |
import org.eclipse.e4.ui.services.EMenuService; |
19 | 19 |
import org.eclipse.e4.ui.services.IServiceConstants; |
20 | 20 |
import org.eclipse.e4.ui.workbench.modeling.ESelectionService; |
21 |
import org.eclipse.jface.viewers.AbstractTreeViewer; |
|
21 | 22 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
22 | 23 |
import org.eclipse.jface.viewers.IStructuredSelection; |
23 | 24 |
import org.eclipse.jface.viewers.StructuredSelection; |
... | ... | |
32 | 33 |
import eu.etaxonomy.cdm.model.description.IDescribable; |
33 | 34 |
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor; |
34 | 35 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
36 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart; |
|
35 | 37 |
import eu.etaxonomy.taxeditor.editor.view.media.MediaContentProvider; |
36 | 38 |
import eu.etaxonomy.taxeditor.editor.view.media.MediaLabelProvider; |
37 | 39 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
... | ... | |
40 | 42 |
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData; |
41 | 43 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
42 | 44 |
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmEditorPartE4; |
45 |
import eu.etaxonomy.taxeditor.view.e4.details.DetailsPartE4; |
|
46 |
import eu.etaxonomy.taxeditor.view.e4.supplementaldata.SupplementalDataPartE4; |
|
43 | 47 |
|
44 | 48 |
/** |
45 | 49 |
* |
... | ... | |
52 | 56 |
|
53 | 57 |
private ISelectionChangedListener selectionChangedListener; |
54 | 58 |
|
55 |
private TreeViewer viewer; |
|
56 |
|
|
57 | 59 |
@Inject |
58 | 60 |
private ESelectionService selService; |
59 | 61 |
|
60 | 62 |
@PostConstruct |
61 | 63 |
public void create(Composite parent, EMenuService menuService) { |
62 | 64 |
|
63 |
viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL
|
|
65 |
TreeViewer treeViewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL
|
|
64 | 66 |
| SWT.V_SCROLL | SWT.FULL_SELECTION)); |
65 | 67 |
|
66 |
viewer.setContentProvider(new MediaContentProvider()); |
|
67 |
viewer.setLabelProvider(new MediaLabelProvider()); |
|
68 |
viewer.setAutoExpandLevel(2); |
|
68 |
treeViewer.setContentProvider(new MediaContentProvider()); |
|
69 |
treeViewer.setLabelProvider(new MediaLabelProvider()); |
|
70 |
treeViewer.setAutoExpandLevel(2); |
|
71 |
viewer = treeViewer; |
|
69 | 72 |
|
70 | 73 |
// Propagate selection from viewer |
71 | 74 |
selectionChangedListener = (event -> selService.setSelection(AbstractUtility.getElementsFromSelectionChangedEvent(event))); |
... | ... | |
87 | 90 |
|
88 | 91 |
Object partObject = createPartObject(activePart); |
89 | 92 |
|
93 |
if (partObject instanceof DetailsPartE4 || partObject instanceof SupplementalDataPartE4 |
|
94 |
|| partObject instanceof DescriptiveViewPart) { |
|
95 |
// do not show empty page as these views are also used to edit the |
|
96 |
// description selected in this view |
|
97 |
return; |
|
98 |
} |
|
99 |
|
|
90 | 100 |
if(partObject instanceof IPartContentHasMedia && ((IPartContentHasMedia) partObject).canAttachMedia()){ |
91 | 101 |
IStructuredSelection structuredSelection = createSelection(selection); |
92 | 102 |
if(structuredSelection==null || structuredSelection.isEmpty()){ |
... | ... | |
94 | 104 |
return; |
95 | 105 |
} |
96 | 106 |
|
97 |
|
|
98 |
// if (partObject instanceof DetailsViewPart || partObject instanceof SupplementalDataViewPart |
|
99 |
// || partObject instanceof DescriptiveViewPart) { |
|
100 |
// // do not show empty page as these views are also used to edit the |
|
101 |
// // description selected in this view |
|
102 |
// return; |
|
103 |
// } |
|
104 |
|
|
105 | 107 |
Object firstElement = structuredSelection.getFirstElement(); |
106 | 108 |
if (partObject instanceof MultiPageTaxonEditor){ |
107 | 109 |
if (firstElement != ((MultiPageTaxonEditor)partObject).getTaxon()){ |
... | ... | |
126 | 128 |
/** {@inheritDoc} */ |
127 | 129 |
@Override |
128 | 130 |
public void changed(Object object) { |
129 |
viewer.expandToLevel(2);
|
|
131 |
((AbstractTreeViewer) viewer).expandToLevel(2);
|
|
130 | 132 |
viewer.refresh(); |
131 | 133 |
if(object != null){ |
132 | 134 |
StructuredSelection selection = new StructuredSelection(object); |
Also available in: Unified diff
ref #6906 Fix selection for supplemental, details and descriptive view