Revision 8263cbc9
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/FactualDataPartE4.java | ||
---|---|---|
20 | 20 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
21 | 21 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
22 | 22 |
import org.eclipse.e4.ui.services.EMenuService; |
23 |
import org.eclipse.jface.action.Action; |
|
24 |
import org.eclipse.jface.action.IAction; |
|
25 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
26 | 23 |
import org.eclipse.jface.viewers.AbstractTreeViewer; |
27 | 24 |
import org.eclipse.jface.viewers.IStructuredSelection; |
28 | 25 |
import org.eclipse.jface.viewers.ITreeContentProvider; |
... | ... | |
32 | 29 |
import org.eclipse.swt.SWT; |
33 | 30 |
import org.eclipse.swt.dnd.DND; |
34 | 31 |
import org.eclipse.swt.dnd.Transfer; |
35 |
import org.eclipse.swt.graphics.ImageData; |
|
36 | 32 |
import org.eclipse.swt.widgets.Composite; |
37 | 33 |
import org.eclipse.swt.widgets.Tree; |
38 | 34 |
|
... | ... | |
60 | 56 |
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails; |
61 | 57 |
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData; |
62 | 58 |
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData; |
63 |
import eu.etaxonomy.taxeditor.model.ImageResources; |
|
64 | 59 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySession; |
65 | 60 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; |
66 | 61 |
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmEditorPartE4; |
... | ... | |
83 | 78 |
*/ |
84 | 79 |
protected Map<DescriptionBase<?>, FeatureNodeContainerTree> featureNodeContainerCache = new HashMap<DescriptionBase<?>, FeatureNodeContainerTree>(); |
85 | 80 |
|
86 |
protected ToggleDescriptionAction showAllElementsAction; |
|
87 |
|
|
88 |
protected ToggleDescriptionAction hideAllElementsAction; |
|
89 |
|
|
90 | 81 |
protected int dndOperations = DND.DROP_COPY | DND.DROP_MOVE; |
91 | 82 |
|
92 | 83 |
private DescriptiveContentProvider provider; |
... | ... | |
121 | 112 |
//create context menu |
122 | 113 |
menuService.registerContextMenu(viewer.getControl(), "eu.etaxonomy.taxeditor.editor.popupmenu.factualDataView"); |
123 | 114 |
|
124 |
showAllElementsAction = new ToggleDescriptionAction(false); |
|
125 |
hideAllElementsAction = new ToggleDescriptionAction(true); |
|
126 |
|
|
127 |
//FIXME E4 implement toolbar |
|
128 |
// createToolbar(); |
|
129 |
|
|
130 |
//FIXME E4 migrate drag and drop |
|
131 | 115 |
} |
132 | 116 |
|
133 |
// protected void createToolbar() { |
|
134 |
// IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager(); |
|
135 |
// toolBarManager.add(showAllElementsAction); |
|
136 |
// toolBarManager.add(hideAllElementsAction); |
|
137 |
// } |
|
138 |
|
|
139 |
|
|
140 | 117 |
@Override |
141 | 118 |
public void selectionChanged_internal(Object selection, MPart activePart, MPart thisPart) { |
142 | 119 |
if(activePart==thisPart){ |
... | ... | |
192 | 169 |
return Messages.DescriptiveViewPart_FACTUAL_DATA; |
193 | 170 |
} |
194 | 171 |
|
195 |
/** |
|
196 |
* |
|
197 |
* @author n.hoffmann |
|
198 |
* @created May 28, 2010 |
|
199 |
* @version 1.0 |
|
200 |
*/ |
|
201 |
protected class ToggleDescriptionAction extends Action{ |
|
202 |
private final boolean expanded; |
|
203 |
|
|
204 |
public ToggleDescriptionAction(boolean expand){ |
|
205 |
super(null, IAction.AS_PUSH_BUTTON); |
|
206 |
expanded = expand; |
|
207 |
setImageAndTooltip(); |
|
208 |
} |
|
209 |
|
|
210 |
private void setImageAndTooltip(){ |
|
211 |
setImageDescriptor(new ImageDescriptor() { |
|
212 |
@Override |
|
213 |
public ImageData getImageData() { |
|
214 |
setText(expanded ? Messages.DescriptiveViewPart_COLLAPSE_ALL : Messages.DescriptiveViewPart_EXPAND_ALL); |
|
215 |
String resource = expanded ? ImageResources.COLLAPSE_ALL : ImageResources.EXPAND_ALL; |
|
216 |
return ImageResources.getImage(resource).getImageData(); |
|
217 |
} |
|
218 |
}); |
|
219 |
|
|
220 |
String toolTipText = expanded ? Messages.DescriptiveViewPart_COLLAPSE_ALL : Messages.DescriptiveViewPart_SHOW_ALL_DATA; |
|
221 |
setToolTipText(toolTipText); |
|
222 |
} |
|
223 |
|
|
224 |
@Override |
|
225 |
public void run() { |
|
226 |
if(expanded){ |
|
227 |
((AbstractTreeViewer) viewer).collapseAll(); |
|
228 |
}else{ |
|
229 |
((AbstractTreeViewer) viewer).expandAll(); |
|
230 |
} |
|
231 |
setImageAndTooltip(); |
|
232 |
} |
|
233 |
} |
|
234 |
|
|
235 | 172 |
/** {@inheritDoc} */ |
236 | 173 |
@Override |
237 | 174 |
public void changed(Object object) { |
... | ... | |
295 | 232 |
} |
296 | 233 |
|
297 | 234 |
public void toggleShowOnlyIndividualAssociations(){ |
298 |
//FIXME E4 migrate toggle menu icon |
|
299 | 235 |
provider.toggleShowOnlyIndividualAssociations(); |
300 | 236 |
viewer.refresh(); |
301 | 237 |
} |
Also available in: Unified diff
ref #6907, #6931 Add "expand" item to factual data part and uses part