protected void inputChanged(Object input, Object oldInput) { elements.clear(); Object[] children = getSortedChildren(getRoot()); list.removeAll(); for (int i = 0; i < children.length; i++) { elements.add((FeaturePanelTabDescriptor) children[i]); mapElement(children[i], list); } list.setElements(children); }
/** * We do not consider multiple selections. Only the first element will represent the selection. */ protected void setSelectionToWidget(List l, boolean reveal) { if (l == null || l.size() == 0) { // clear selection list.deselectAll(); } else { Object object = l.get(0); int index = -1; for (int i = 0; i < elements.size(); i++) { if (elements.get(i) == object) { index = i; } } Assert.isTrue( index != -1, "Could not set the selected tab in the feature panel viewer"); // $NON-NLS-1$ list.select(index); } }
protected List<Object> getSelectionFromWidget() { int index = list.getSelectionIndex(); if (index == FeaturePanelList.NONE) { return Collections.EMPTY_LIST; } List<Object> result = new ArrayList<Object>(1); result.add(getElementAt(index)); return result; }
/** * Returns the zero-relative index of the item which is currently selected in the receiver, or -1 * if no item is selected. * * @return the index of the selected item */ public int getSelectionIndex() { return list.getSelectionIndex(); }