private void doSelectionChanged() { StatusInfo status = new StatusInfo(); List selected = fHistoryList.getSelectedElements(); if (selected.size() != 1) { status.setError(""); // $NON-NLS-1$ fResult = null; } else { fResult = (IModelElement) selected.get(0); } fHistoryList.enableButton( 0, fHistoryList.getSize() > selected.size() && selected.size() != 0); fHistoryStatus = status; updateStatus(status); }
/* * @see Dialog#createDialogArea(Composite) */ protected Control createDialogArea(Composite parent) { initializeDialogUnits(parent); Composite composite = (Composite) super.createDialogArea(parent); Composite inner = new Composite(composite, SWT.NONE); inner.setFont(parent.getFont()); inner.setLayoutData(new GridData(GridData.FILL_BOTH)); LayoutUtil.doDefaultLayout(inner, new DialogField[] {fHistoryList}, true, 0, 0); LayoutUtil.setHeightHint(fHistoryList.getListControl(null), convertHeightInCharsToPixels(12)); LayoutUtil.setHorizontalGrabbing(fHistoryList.getListControl(null)); applyDialogFont(composite); return composite; }
private HistoryListDialog(Shell shell, IModelElement[] elements) { super(shell); setTitle(TypeHierarchyMessages.HistoryListDialog_title); String[] buttonLabels = new String[] { TypeHierarchyMessages.HistoryListDialog_remove_button, }; IListAdapter adapter = new IListAdapter() { public void customButtonPressed(ListDialogField field, int index) { doCustomButtonPressed(); } public void selectionChanged(ListDialogField field) { doSelectionChanged(); } public void doubleClicked(ListDialogField field) { doDoubleClicked(); } }; ModelElementLabelProvider labelProvider = new ModelElementLabelProvider( ModelElementLabelProvider.SHOW_QUALIFIED | ModelElementLabelProvider.SHOW_ROOT); fHistoryList = new ListDialogField(adapter, buttonLabels, labelProvider); fHistoryList.setLabelText(TypeHierarchyMessages.HistoryListDialog_label); fHistoryList.setElements(Arrays.asList(elements)); ISelection sel; if (elements.length > 0) { sel = new StructuredSelection(elements[0]); } else { sel = new StructuredSelection(); } fHistoryList.selectElements(sel); }
public IModelElement[] getRemaining() { List elems = fHistoryList.getElements(); return (IModelElement[]) elems.toArray(new IModelElement[elems.size()]); }
/** Method doCustomButtonPressed. */ private void doCustomButtonPressed() { fHistoryList.removeElements(fHistoryList.getSelectedElements()); }