/** * Instantiates a new NavigationViewImpl. */ public NavigationViewImpl() { treeModel = new NavigationTreeViewModel(); menuTree = new CellTree(treeModel, null); kaaAdminStyle = Utils.kaaAdminStyle; initWidget(uiBinder.createAndBindUi(this)); }
/** * Collects parents going up the element tree, terminated at the tree root. */ private void collectElementChain(ArrayList<Element> chain, Element hRoot, Element hElem) { if ((hElem == null) || (hElem == hRoot)) { return; } collectElementChain(chain, hRoot, hElem.getParentElement()); chain.add(hElem); }
private CellTreeNodeView<?> findItemByChain(ArrayList<Element> chain, int idx, CellTreeNodeView<?> parent) { if (idx == chain.size()) { return parent; } Element hCurElem = chain.get(idx); for (int i = 0, n = parent.getChildCount(); i < n; ++i) { CellTreeNodeView<?> child = parent.getChildNode(i); if (child.getElement() == hCurElem) { CellTreeNodeView<?> retItem = findItemByChain(chain, idx + 1, child); if (retItem == null) { return child; } return retItem; } } return findItemByChain(chain, idx + 1, parent); }
/** * Sets the node that will be selected when the CellTree gains keyboard focus. * * @param parentNode a node in the tree that is currently open * @param childIndex the index of the child to select * @param stealFocus if true, also change keyboard focus to this CellTree. */ public void setKeyboardSelectedTreeNode(TreeNode parentNode, int childIndex, boolean stealFocus) { CellTreeNodeView nodeView = getCellTreeNodeView(parentNode); // Just to ensure necessary checks are done, e.g. // assertNotDestroyed();checkChildBounds(childIndex);flush(); nodeView.getTreeNode().getChildValue(childIndex); keyboardSelect(nodeView.getChildNode(childIndex), stealFocus); }
initWidget(new SimplePanel()); setStyleName(this.style.cellTreeWidget()); ImageResource treeClosed = resources.cellTreeClosedItem(); ImageResource treeLoading = resources.cellTreeLoading(); openImageHtml = getImageHtml(treeOpen, false); closedImageHtml = getImageHtml(treeClosed, false); openImageTopHtml = getImageHtml(treeOpen, true); closedImageTopHtml = getImageHtml(treeClosed, true); loadingImageHtml = getImageHtml(treeLoading, false); imageWidth = Math.max(Math.max(treeOpen.getWidth(), treeClosed.getWidth()), treeLoading.getWidth()); setAnimation(SlideAnimation.create()); getElement(), rootValue, messages); keyboardSelectedNode = rootNode = root; root.setOpen(true, false); Roles.getTreeRole().set(getElement());
onFocus(); } else if (BrowserEvents.BLUR.equals(eventType)) { onBlur(); } else if (BrowserEvents.KEYDOWN.equals(eventType) && !cellIsEditing) { int keyCode = event.getKeyCode(); case KeyCodes.KEY_RIGHT: case KeyCodes.KEY_LEFT: handleKeyNavigation(keyCode); collectElementChain(chain, getElement(), target); final CellTreeNodeView<?> nodeView = findItemByChain(chain, 0, rootNode); if (nodeView != null) { Element showMoreElem = nodeView.getShowMoreElement(); keyboardSelect(nodeView, !isFocusable);
tree.cancelTreeNodeAnimation(); this.animate = true; this.open = open; if (!nodeInfoLoaded) { nodeInfoLoaded = true; nodeInfo = tree.getNodeInfo(value); showOrHide(emptyMessageElem, false); if (!isRootNode()) { setStyleName(getCellParent(), tree.getStyle().cellTreeOpenItem(), true); setStyleName(getCellParent(), tree.getStyle().cellTreeOpenItem(), false); tree.maybeAnimateTreeNode(this); updateImage(false); CellTreeNodeView<?> keySelected = tree.getKeyboardSelectedNode(); while (keySelected != null) { if (keySelected == this) { tree.keyboardSelect(this, true); break;
if (tree.isKeyboardSelectionDisabled()) { return; } else { FocusImpl focusImpl = FocusImpl.getFocusImplForWidget(); focusImpl.setTabIndex(cellParent, tree.getTabIndex()); char accessKey = tree.getAccessKey(); if (accessKey != 0) { focusImpl.setAccessKey(cellParent, accessKey); if (KeyboardSelectionPolicy.BOUND_TO_SELECTION == tree.getKeyboardSelectionPolicy()) { setSelected(selected);
SafeHtml html = tree.getClosedImageHtml(isTopLevel); if (open) { html = isLoading ? tree.getLoadingImageHtml() : tree.getOpenImageHtml(isTopLevel);
/** {@inheritDoc} */ @Override public void setTreeOfDestinations( RefactorInfo refactorInfo, List<JavaProjectStructure> projects) { final SingleSelectionModel<Object> selectionModel = new SingleSelectionModel<>(); selectionModel.addSelectionChangeHandler( event -> { Object object = selectionModel.getSelectedObject(); if (object instanceof PackageFragmentRoot) { PackageFragmentRoot fragmentRoot = (PackageFragmentRoot) object; delegate.setMoveDestinationPath(fragmentRoot.getUri(), fragmentRoot.getProjectUri()); } if (object instanceof PackageFragment) { PackageFragment fragment = (PackageFragment) object; delegate.setMoveDestinationPath(fragment.getUri(), fragment.getProjectUri()); } }); CellTree tree = new CellTree( new ProjectsAndPackagesModel(projects, refactorInfo, selectionModel, resources), null, cellTreeResources); tree.setAnimationEnabled(true); treePanel.clear(); treePanel.add(tree); }
/** * Construct a new {@link CellTree}. * * @param <T> the type of data in the root node * @param viewModel the {@link TreeViewModel} that backs the tree * @param rootValue the hidden root value of the tree */ public <T> CellTree(TreeViewModel viewModel, T rootValue) { this(viewModel, rootValue, getDefaultResources()); }
/** * Set up the node when it is opened. * * @param nodeInfo the {@link NodeInfo} that provides information about the * child values * @param <C> the child data type of the node */ protected <C> void onOpen(final NodeInfo<C> nodeInfo) { NodeCellList<C> view = new NodeCellList<C>(nodeInfo, this, tree.getDefaultNodeSize()); listView = view; view.setSelectionModel(nodeInfo.getSelectionModel()); nodeInfo.setDataDisplay(view); }
onFocus(); } else if (BrowserEvents.BLUR.equals(eventType)) { onBlur(); } else if (BrowserEvents.KEYDOWN.equals(eventType) && !cellIsEditing) { int keyCode = event.getKeyCode(); case KeyCodes.KEY_RIGHT: case KeyCodes.KEY_LEFT: handleKeyNavigation(keyCode); collectElementChain(chain, getElement(), target); final CellTreeNodeView<?> nodeView = findItemByChain(chain, 0, rootNode); if (nodeView != null) { if (isMouseDown) { keyboardSelect(nodeView, !isFocusable);
tree.cancelTreeNodeAnimation(); this.animate = true; this.open = open; if (!nodeInfoLoaded) { nodeInfoLoaded = true; nodeInfo = tree.getNodeInfo(value); showOrHide(emptyMessageElem, false); if (!isRootNode()) { setStyleName(getCellParent(), tree.getStyle().cellTreeOpenItem(), true); setStyleName(getCellParent(), tree.getStyle().cellTreeOpenItem(), false); tree.maybeAnimateTreeNode(this); updateImage(false); CellTreeNodeView<?> keySelected = tree.getKeyboardSelectedNode(); while (keySelected != null) { if (keySelected == this) { tree.keyboardSelect(this, true); break;
initWidget(new SimplePanel()); setStyleName(this.style.cellTreeWidget()); ImageResource treeClosed = resources.cellTreeClosedItem(); ImageResource treeLoading = resources.cellTreeLoading(); openImageHtml = getImageHtml(treeOpen, false); closedImageHtml = getImageHtml(treeClosed, false); openImageTopHtml = getImageHtml(treeOpen, true); closedImageTopHtml = getImageHtml(treeClosed, true); loadingImageHtml = getImageHtml(treeLoading, false); imageWidth = Math.max(Math.max(treeOpen.getWidth(), treeClosed.getWidth()), treeLoading.getWidth()); setAnimation(SlideAnimation.create()); getElement(), rootValue, messages); keyboardSelectedNode = rootNode = root; root.setOpen(true, false); Roles.getTreeRole().set(getElement());
if (tree.isKeyboardSelectionDisabled()) { return; } else { FocusImpl focusImpl = FocusImpl.getFocusImplForWidget(); focusImpl.setTabIndex(cellParent, tree.getTabIndex()); char accessKey = tree.getAccessKey(); if (accessKey != 0) { focusImpl.setAccessKey(cellParent, accessKey); if (KeyboardSelectionPolicy.BOUND_TO_SELECTION == tree.getKeyboardSelectionPolicy()) { setSelected(selected);
SafeHtml html = tree.getClosedImageHtml(isTopLevel); if (open) { html = isLoading ? tree.getLoadingImageHtml() : tree.getOpenImageHtml(isTopLevel);
/** * Sets the node that will be selected when the CellTree gains keyboard focus. * * @param parentNode a node in the tree that is currently open * @param childIndex the index of the child to select * @param stealFocus if true, also change keyboard focus to this CellTree. */ public void setKeyboardSelectedTreeNode(TreeNode parentNode, int childIndex, boolean stealFocus) { CellTreeNodeView nodeView = getCellTreeNodeView(parentNode); // Just to ensure necessary checks are done, e.g. // assertNotDestroyed();checkChildBounds(childIndex);flush(); nodeView.getTreeNode().getChildValue(childIndex); keyboardSelect(nodeView.getChildNode(childIndex), stealFocus); }
/** * Construct a new {@link CellTree}. * * @param <T> the type of data in the root node * @param viewModel the {@link TreeViewModel} that backs the tree * @param rootValue the hidden root value of the tree */ public <T> CellTree(TreeViewModel viewModel, T rootValue) { this(viewModel, rootValue, getDefaultResources()); }
/** * Set up the node when it is opened. * * @param nodeInfo the {@link NodeInfo} that provides information about the * child values * @param <C> the child data type of the node */ protected <C> void onOpen(final NodeInfo<C> nodeInfo) { NodeCellList<C> view = new NodeCellList<C>(nodeInfo, this, tree.getDefaultNodeSize()); listView = view; view.setSelectionModel(nodeInfo.getSelectionModel()); nodeInfo.setDataDisplay(view); }