コード例 #1
0
  @Override
  public void expandNode(TreeNode<?> node) {
    view.expandAndSelectNode(node);
    view.updateNode(node, node);

    eventBus.fireEvent(new NodeExpandedEvent());
  }
コード例 #2
0
 // TODO remove this method in the nearest feature
 // TODO just use updateNode of view
 private void updateNode(TreeNode<?> node) {
   view.updateNode(node, node);
 }
コード例 #3
0
 /** {@inheritDoc} */
 @Override
 public void onEnterKey() {
   view.getSelectedNode().processNodeAction();
 }
コード例 #4
0
  /** Adds behavior to view's components. */
  protected void bind() {
    view.setDelegate(this);

    eventBus.addHandler(
        ProjectActionEvent.TYPE,
        new ProjectActionHandler() {
          @Override
          public void onProjectReady(ProjectActionEvent event) {
            final ProjectDescriptor project = event.getProject();
            setTree(
                treeStructureProviderRegistry.getTreeStructureProvider(project.getType()).get());
            view.setProjectHeader(event.getProject());
            eventLogger.logEvent("project-opened", new HashMap<String, String>());
          }

          @Override
          public void onProjectClosing(ProjectActionEvent event) {}

          @Override
          public void onProjectClosed(ProjectActionEvent event) {
            // this isn't case when some project going to open while previously opened project is
            // closing
            if (!event.isCloseBeforeOpening()) {
              setTree(projectListStructureProvider.get());
              view.hideProjectHeader();
            }
          }

          @Override
          public void onProjectOpened(ProjectActionEvent event) {}
        });

    //        eventBus.addHandler(RefreshProjectTreeEvent.TYPE, this);

    //        eventBus.addHandler(RefreshProjectTreeEvent.TYPE, new RefreshProjectTreeHandler() {
    //            @Override
    //            public void onRefreshProjectTree(RefreshProjectTreeEvent event) {
    //                eventBus.fireEvent(new PersistProjectTreeStateEvent());
    //                if (appContext.getCurrentProject() == null) {
    //                    setTree(projectListStructureProvider.get());
    //                    return;
    //                }
    //
    //                if (event.refreshSubtree()) {
    //                    nodesToRefresh = view.getOpenedTreeNodes();
    //                    refreshTreeNodes();
    //                    return;
    //                }
    //
    //                if (event.getNode() != null) {
    //                    refreshAndSelectNode(event.getNode());
    //                    return;
    //                }
    //
    //                currentTreeStructure.getRootNodes(new AsyncCallback<List<TreeNode<?>>>() {
    //                    @Override
    //                    public void onSuccess(List<TreeNode<?>> result) {
    //                        for (TreeNode<?> childNode : result) {
    //                            // clear children in order to force to refresh
    //                            childNode.setChildren(new ArrayList<TreeNode<?>>());
    //                            refreshAndSelectNode(childNode);
    //
    //                            ProjectDescriptor projectDescriptor =
    // appContext.getCurrentProject().getRootProject();
    //                            String workspaceName = projectDescriptor.getWorkspaceName();
    //                            String fullProjectPath = "/" + workspaceName +
    // projectDescriptor.getPath();
    //                            eventBus.fireEvent(new
    // RestoreProjectTreeStateEvent(fullProjectPath));
    //                        }
    //                    }
    //
    //                    @Override
    //                    public void onFailure(Throwable caught) {
    //                        Log.error(ProjectExplorerPartPresenter.class, caught);
    //                    }
    //                });
    //            }
    //        });

    eventBus.addHandler(
        NodeChangedEvent.TYPE,
        new NodeChangedHandler() {
          @Override
          public void onNodeRenamed(NodeChangedEvent event) {
            if (appContext.getCurrentProject() == null) {
              // any opened project - all projects list is shown
              setTree(currentTreeStructure);
            } else {
              updateNode(event.getNode().getParent());
              view.selectNode(event.getNode());
            }
          }
        });

    //        eventBus.addHandler(ItemEvent.TYPE, new ItemHandler() {
    //            @Override
    //            public void onItem(final ItemEvent event) {
    //                if (DELETED == event.getOperation()) {
    //                    refreshAndSelectNode(event.getItem().getParent());
    //                } else if (CREATED == event.getOperation()) {
    //                    final TreeNode<?> selectedNode = view.getSelectedNode();
    //                    updateNode(selectedNode.getParent());
    //                    updateNode(selectedNode);
    //                    view.expandAndSelectNode(event.getItem());
    //                }
    //            }
    //        });

    eventBus.addHandler(
        RenameNodeEvent.TYPE,
        new RenameNodeEventHandler() {
          @Override
          public void onNodeRenamed(TreeNode<?> parentNode, String newParenNodePath) {
            if (parentNode instanceof UpdateTreeNodeDataIterable) {
              final StorableNode parent = (StorableNode) parentNode;
              List<TreeNode<?>> children = new ArrayList<>();
              children.add(parent);
              getAllChildren(parentNode, children);
              getOpenedUnCashedFiles(parent, children);
              final Iterator<TreeNode<?>> treeNodeIterator = children.iterator();

              updateDataTreeNode(parent, newParenNodePath, treeNodeIterator);
            }
          }
        });
  }