use of com.google.gwt.user.client.ui.TreeItem in project che by eclipse.
the class PreviewViewImpl method setTreeOfChanges.
/** {@inheritDoc} */
@Override
public void setTreeOfChanges(final RefactoringPreview changes) {
showDiffPanel(false);
final SelectionModel<RefactoringPreview> selectionModel = new SingleSelectionModel<>();
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
@Override
public void onSelectionChange(SelectionChangeEvent event) {
RefactoringPreview selectedNode = (RefactoringPreview) ((SingleSelectionModel) selectionModel).getSelectedObject();
delegate.onSelectionChanged(selectedNode);
}
});
Tree tree = new Tree();
tree.getElement().setId("tree-of-changes");
for (RefactoringPreview parentChange : changes.getChildrens()) {
TreeItem treeItem = new TreeItem();
containerChanges.put(treeItem, parentChange);
createTreeElement(treeItem, parentChange.getText(), parentChange.getChildrens());
tree.addItem(treeItem);
}
tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
@Override
public void onSelection(SelectionEvent<TreeItem> event) {
if (selectedElement != null) {
selectedElement.getStyle().setProperty("background", "transparent");
}
selectedElement = event.getSelectedItem().getWidget().getElement();
selectedElement.getStyle().setProperty("background", getEditorSelectionColor());
}
});
treePanel.add(tree);
}
use of com.google.gwt.user.client.ui.TreeItem in project rstudio by rstudio.
the class DocumentOutlineWidget method rebuildScopeTree.
private void rebuildScopeTree(JsArray<Scope> scopeTree, Scope currentScope) {
scopeTree_ = scopeTree;
currentScope_ = currentScope;
currentVisibleScope_ = getCurrentVisibleScope(currentScope_);
if (scopeTree_.length() == 0) {
setActiveWidget(emptyPlaceholder_);
return;
}
setActiveWidget(tree_);
int h1Count = 0;
for (int i = 0; i < scopeTree_.length(); i++) {
Scope node = scopeTree_.get(i);
if (node.isMarkdownHeader()) {
if (node.getDepth() == 1)
h1Count++;
}
}
int initialDepth = h1Count == 1 ? -1 : 0;
Counter counter = new Counter(-1);
for (int i = 0; i < scopeTree_.length(); i++) buildScopeTreeImpl(scopeTree_.get(i), initialDepth, counter);
// Clean up leftovers in the tree.
int oldTreeSize = tree_.getItemCount();
int newTreeSize = counter.increment();
for (int i = oldTreeSize - 1; i >= newTreeSize; i--) {
TreeItem item = tree_.getItem(i);
if (item != null)
item.remove();
}
}
use of com.google.gwt.user.client.ui.TreeItem in project rstudio by rstudio.
the class ScopeTreeWidget method addItem.
private void addItem(Scope node) {
TreeItem item = new TreeItem();
item.setText(node.getLabel());
tree_.addItem(item);
}
use of com.google.gwt.user.client.ui.TreeItem in project che by eclipse.
the class PreviewViewImpl method checkChildrenState.
private void checkChildrenState(TreeItem treeItem, Boolean value) {
int childCount = treeItem.getChildCount();
if (childCount == 0) {
return;
}
for (int i = 0; i < childCount; i++) {
TreeItem childItem = treeItem.getChild(i);
if (!(childItem.getWidget() instanceof FlowPanel)) {
return;
}
FlowPanel childItemContainer = (FlowPanel) childItem.getWidget();
if (!(childItemContainer.getWidget(0) instanceof CheckBox)) {
return;
}
CheckBox childCheckBox = (CheckBox) childItemContainer.getWidget(0);
childCheckBox.setValue(value);
checkChildrenState(childItem, value);
}
}
use of com.google.gwt.user.client.ui.TreeItem in project che by eclipse.
the class PreviewViewImpl method checkParentState.
private void checkParentState(TreeItem treeItem, Boolean value) {
TreeItem parentItem = treeItem.getParentItem();
if (parentItem == null) {
return;
}
if (!(parentItem.getWidget() instanceof FlowPanel)) {
return;
}
FlowPanel parentChangeContainer = (FlowPanel) parentItem.getWidget();
if (!(parentChangeContainer.getWidget(0) instanceof CheckBox)) {
return;
}
CheckBox parentCheckBox = (CheckBox) parentChangeContainer.getWidget(0);
if (value && !parentCheckBox.getValue()) {
parentCheckBox.setValue(true);
checkParentState(parentItem, true);
}
}
Aggregations