/** * Searches breadth-first for the TreeNode with the given content. * * @throws IllegalArgumentException if no such node exists */ public TreeNode<T> findByContent(T content) { requireNonNull(content); Optional<TreeNode<T>> opt = TreeStream.breadthFirst(treeDef(), this).filter(node -> node.getContent().equals(content)).findFirst(); if (opt.isPresent()) { return opt.get(); } else { throw new IllegalArgumentException(this.toString() + " has no child with content " + content); } } }
public ColorComparePanel(Composite parent) { super(new Composite(parent, SWT.NONE)); Layouts.setGrid(wrapped) .numColumns(2) .columnsEqualWidth(true) .horizontalSpacing(0); swatchActual = new Label(wrapped, SWT.NONE); swatchNearest = new Label(wrapped, SWT.NONE); Layouts.setGridData(swatchActual).grabHorizontal(); Layouts.setGridData(swatchNearest).grabHorizontal(); Label actualLbl = new Label(wrapped, SWT.NONE); actualLbl.setText("Actual"); Label nearestLbl = new Label(wrapped, SWT.NONE); nearestLbl.setText("Nearest"); rgbActual = new Text(wrapped, SWT.BORDER | SWT.READ_ONLY); rgbNearest = new Text(wrapped, SWT.BORDER | SWT.READ_ONLY); Layouts.setGridData(rgbActual).grabHorizontal(); Layouts.setGridData(rgbNearest).grabHorizontal(); nameNearest = new Text(wrapped, SWT.BORDER | SWT.READ_ONLY); Layouts.setGridData(nameNearest).horizontalSpan(2).grabHorizontal(); // set all fonts to system large TreeStream.breadthFirst(SwtMisc.treeDefControl(), parent) .forEach(ctl -> ctl.setFont(Fonts.systemLarge())); rgbActual.setText(" "); rgbNearest.setText(" "); }