Revision a37d250c
Added by Patrick Plitzner over 8 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsView.java | ||
---|---|---|
22 | 22 |
import org.eclipse.core.runtime.IStatus; |
23 | 23 |
import org.eclipse.core.runtime.Status; |
24 | 24 |
import org.eclipse.core.runtime.jobs.Job; |
25 |
import org.eclipse.jface.action.MenuManager; |
|
25 | 26 |
import org.eclipse.jface.viewers.CellEditor; |
26 | 27 |
import org.eclipse.jface.viewers.ICellModifier; |
27 | 28 |
import org.eclipse.jface.viewers.ISelection; |
... | ... | |
33 | 34 |
import org.eclipse.jface.viewers.Viewer; |
34 | 35 |
import org.eclipse.swt.SWT; |
35 | 36 |
import org.eclipse.swt.widgets.Composite; |
37 |
import org.eclipse.swt.widgets.Control; |
|
36 | 38 |
import org.eclipse.swt.widgets.Display; |
39 |
import org.eclipse.swt.widgets.Menu; |
|
37 | 40 |
import org.eclipse.swt.widgets.Table; |
38 | 41 |
import org.eclipse.ui.IWorkbenchPart; |
39 | 42 |
|
... | ... | |
62 | 65 |
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart; |
63 | 66 |
|
64 | 67 |
/** |
65 |
* <p>ReferencingObjectsView class.</p> |
|
66 |
* |
|
67 | 68 |
* @author p.ciardelli |
68 | 69 |
* @created 08.07.2009 |
69 | 70 |
* @version 1.0 |
... | ... | |
72 | 73 |
private static final Logger logger = Logger |
73 | 74 |
.getLogger(ReferencingObjectsView.class); |
74 | 75 |
|
75 |
/** Constant <code>ID="eu.etaxonomy.taxeditor.bulkeditor.refer"{trunked}</code> */ |
|
76 | 76 |
public static final String ID = "eu.etaxonomy.taxeditor.bulkeditor.view.referencingobjects"; |
77 | 77 |
|
78 | 78 |
private TableViewer viewer; |
... | ... | |
85 | 85 |
cdmEntitySession = CdmStore.getCurrentSessionManager().bindNullSession(); |
86 | 86 |
} |
87 | 87 |
|
88 |
/* (non-Javadoc) |
|
89 |
* @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#createViewer(org.eclipse.swt.widgets.Composite) |
|
90 |
*/ |
|
91 | 88 |
/** {@inheritDoc} */ |
92 | 89 |
@Override |
93 | 90 |
public void createViewer(Composite parent) { |
... | ... | |
99 | 96 |
viewer.setContentProvider(new ReferencingObjectsContentProvider()); |
100 | 97 |
viewer.setLabelProvider(new ReferencingObjectsLabelProvider()); |
101 | 98 |
viewer.setCellModifier(new ICellModifier() { |
102 |
|
|
103 | 99 |
@Override |
104 | 100 |
public void modify(Object element, String property, Object value) { |
105 |
// TODO Auto-generated method stub |
|
106 |
|
|
107 | 101 |
} |
108 | 102 |
|
109 | 103 |
@Override |
... | ... | |
126 | 120 |
return true; |
127 | 121 |
} |
128 | 122 |
}); |
129 |
// viewer.setInput(new ArrayList<CdmBase>()); |
|
123 |
|
|
124 |
//create context menu |
|
125 |
MenuManager menuManager = new MenuManager(); |
|
126 |
getSite().registerContextMenu(menuManager, viewer); |
|
127 |
Control control = viewer.getControl(); |
|
128 |
Menu menu = menuManager.createContextMenu(control); |
|
129 |
control.setMenu(menu); |
|
130 |
|
|
131 |
// Propagate selection from viewer |
|
132 |
getSite().setSelectionProvider(viewer); |
|
130 | 133 |
} |
131 | 134 |
|
132 | 135 |
/** |
... | ... | |
159 | 162 |
public void setFocus() { |
160 | 163 |
cdmEntitySession.bind(); |
161 | 164 |
} |
162 |
/** |
|
163 |
* <p>updateReferencingObjects</p> |
|
164 |
* |
|
165 |
* @param entity a {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity} object. |
|
166 |
*/ |
|
165 |
|
|
167 | 166 |
public void updateReferencingObjects(final UUID entityUUID, final Class objectClass) { |
168 | 167 |
|
169 | 168 |
final Display display = Display.getCurrent(); |
... | ... | |
246 | 245 |
|
247 | 246 |
class ReferencingClassComparator implements Comparator<CdmBase> { |
248 | 247 |
|
249 |
/* (non-Javadoc) |
|
250 |
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) |
|
251 |
*/ |
|
252 | 248 |
@Override |
253 | 249 |
public int compare(CdmBase o1, CdmBase o2) { |
254 | 250 |
String string1 = o1.getClass().getSimpleName(); |
... | ... | |
264 | 260 |
} |
265 | 261 |
} |
266 | 262 |
|
267 |
/** |
|
268 |
* |
|
269 |
*/ |
|
270 | 263 |
private void updateView(List<CdmBase> referencingObjects) { |
271 | 264 |
if (viewer != null && !viewer.getControl().isDisposed()){ |
272 | 265 |
try{ |
... | ... | |
287 | 280 |
/** {@inheritDoc} */ |
288 | 281 |
@Override |
289 | 282 |
public void selectionChanged(IWorkbenchPart part, ISelection selection) { |
283 |
if(part == this){ |
|
284 |
return; |
|
285 |
} |
|
290 | 286 |
if(! (part instanceof BulkEditor)){ |
291 | 287 |
setContentDescription(""); |
292 | 288 |
showEmptyPage(); |
... | ... | |
309 | 305 |
showViewer(part, lineSelection); |
310 | 306 |
} |
311 | 307 |
|
312 |
/* (non-Javadoc) |
|
313 |
* @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#showViewer(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) |
|
314 |
*/ |
|
315 | 308 |
/** {@inheritDoc} */ |
316 | 309 |
@Override |
317 | 310 |
public void showViewer(IWorkbenchPart part, IStructuredSelection selection) { |
... | ... | |
331 | 324 |
|
332 | 325 |
} |
333 | 326 |
|
334 |
/* (non-Javadoc) |
|
335 |
* @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#getViewer() |
|
336 |
*/ |
|
337 | 327 |
/** {@inheritDoc} */ |
338 | 328 |
@Override |
339 | 329 |
public Viewer getViewer() { |
340 | 330 |
return viewer; |
341 | 331 |
} |
342 | 332 |
|
343 |
/* (non-Javadoc) |
|
344 |
* @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#dirtyStateChanged() |
|
345 |
*/ |
|
346 | 333 |
/** {@inheritDoc} */ |
347 | 334 |
@Override |
348 | 335 |
public void changed(Object object) { |
349 | 336 |
// no editing in this view |
350 | 337 |
} |
351 | 338 |
|
352 |
/* (non-Javadoc) |
|
353 |
* @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#onComplete() |
|
354 |
*/ |
|
355 | 339 |
/** {@inheritDoc} */ |
356 | 340 |
@Override |
357 | 341 |
public boolean onComplete() { |
... | ... | |
359 | 343 |
} |
360 | 344 |
|
361 | 345 |
public void refresh(){ |
362 |
|
|
363 | 346 |
selectionService.removePostSelectionListener(this); |
364 | 347 |
selectionService.removeSelectionListener(this); |
365 | 348 |
selectionService.addPostSelectionListener(this); |
Also available in: Unified diff
Add generic "Open in..." context menu to referencing objects view