protected void setAllExpanded(PreferenceTreeNode<?> start, boolean expanded) { fScrolledPageContent.setRedraw(false); fScrolledPageContent.setReflow(false); ArrayList<PreferenceTreeNode<?>> bfsNodes= new ArrayList<>(); if (start != null) { bfsNodes.add(start); } else { bfsNodes.addAll(fRoot.getChildren()); } for (int i= 0; i < bfsNodes.size(); i++) { PreferenceTreeNode<?> node= bfsNodes.get(i); bfsNodes.addAll(bfsNodes.get(i).getChildren()); if (node.getControl() instanceof ExpandableComposite) ((ExpandableComposite) node.getControl()).setExpanded(expanded); } fScrolledPageContent.setReflow(true); Display.getCurrent().asyncExec(() -> fScrolledPageContent.setRedraw(true)); }
public void add(PreferenceTreeNode<?> node) { Control control= node.getControl(); if (node instanceof Section) { // workaround: can't add focus listener directly to ExpadableComposite control= ((Section) node).getToggle(); } fControl2node.put(control, node); add(control); }
@Override public <T extends PreferenceTreeNode<?>> T addChild(PreferenceTreeNode<?> parent, T node) { super.addChild(parent, node); fFocusManager.add(node); if (node instanceof Preference<?>) { Predicate<String> validator = v -> { doValidate(); return true; }; ((Preference<?>) node).init(fWorkingValues, validator , () -> valuesModified()); } if (!(node instanceof Section)) { Label margin= new Label(node.getControl().getParent(), SWT.NONE); margin.setLayoutData(new GridData(fRightMargin, SWT.DEFAULT)); node.addChild(new PreferenceTreeNode<>("", margin, true)); //$NON-NLS-1$ } return node; }
public void unifySectionTitlesHeights(Section section) { List<PreferenceTreeNode<?>> children= section == null ? fRoot.getChildren() : section.getChildren(); int maxHeightDiff= 0; for (PreferenceTreeNode<?> child : children) { if (child instanceof Section) maxHeightDiff= Math.max(maxHeightDiff, ((Section) child).getControl().getTextClientHeightDifference()); } int nextChildIndent= 0; for (PreferenceTreeNode<?> child : children) { int indent= nextChildIndent; nextChildIndent= 0; if (child instanceof Section) { Section sectionChild= (Section) child; int diff= maxHeightDiff - sectionChild.getControl().getTextClientHeightDifference(); nextChildIndent= diff / 2; indent+= diff - diff / 2; unifySectionTitlesHeights(sectionChild); } GridData gd= (GridData) child.getControl().getLayoutData(); gd.verticalIndent+= indent; } } }
protected void updateUI(PreferenceTreeNode<?> node) { //update node Control control= node.getControl(); if (control != null) { boolean visible= node.isVisible(); setVisible(control, visible); if (control instanceof ExpandableComposite) { ((ExpandableComposite) control).setExpanded(visible); } } //update children List<PreferenceTreeNode<?>> children= node.getChildren(); if (children != null) { for (int i= 0; i < children.size(); i++) { updateUI(children.get(i)); } } }
@Override public void mouseDown(MouseEvent e) { if (e.getSource() == fControl && e.x < fControl.getClient().getLocation().x) return; if (e.getSource() == fControl.getClient() && e.x < getChildren().get(0).getControl().getLocation().x) return; fToggle.setFocus(); } };