@Override protected int[] getSelectedRows() { final IObservableList rowObservables = ReflectionUtils.invokeHidden(getRidget(), "getRowObservables"); // $NON-NLS-1$ final Object[] elements = getRidget().getMultiSelectionObservable().toArray(); final int[] result = new int[elements.length]; for (int i = 0; i < elements.length; i++) { final Object element = elements[i]; result[i] = rowObservables.indexOf(element); } return result; }
/** * Returns {@link IChildCreationSpecification} for children of the specified list. * * @param l the list * @param sibling a possible sibling, if non-<code>null</code> * @return the possible top-level children */ public static List<IChildCreationSpecification> getPossibleTopLevelChildObjects( IObservableList l, EObject sibling) { final List<IChildCreationSpecification> specs = new ArrayList<IChildCreationSpecification>(); /* * Figure out the EReference of the elements */ EObject parent = null; EReference ref = null; if (l instanceof EObjectEList<?>) { final EObjectEList<?> el = (EObjectEList<?>) l; final EStructuralFeature sf = el.getEStructuralFeature(); if (sf instanceof EReference) { parent = (EObject) el.getNotifier(); ref = (EReference) sf; } } if (ref == null && l instanceof MyDetailObservableList) { parent = (EObject) ((MyDetailObservableList) l).getObserved(); ref = (EReference) ((MyDetailObservableList) l).getElementType(); } if (ref == null && l instanceof EObjectObservableList) { parent = (EObject) ((EObjectObservableList) l).getObserved(); ref = (EReference) ((EObjectObservableList) l).getElementType(); } if (ref == null) return specs; final EClass childType = ref.getEReferenceType(); int index = -1; if (sibling != null) { index = l.indexOf(sibling); if (index == -1) return specs; } UIBindingsUtils.addToChildCreationSpecification(specs, parent, ref, childType, index); return specs; }