@Test public void shouldUpdateCurrentProjectOnNodeSelection() throws Exception { ProjectDescriptor projectDescriptor = mock(ProjectDescriptor.class); ProjectNode project = mock(ProjectNode.class); when(project.getData()).thenReturn(projectDescriptor); StorableNode node = mock(StorableNode.class); when(node.getProject()).thenReturn(project); final SelectionModel selectionModel = mock(SelectionModel.class); final Array selection = new JsonArrayListAdapter(Collections.singletonList(node)); when(selectionModel.getSelectedNodes()).thenReturn(selection); presenter.onNodeSelected(node, selectionModel); verify(currentProject).setProjectDescription(projectDescriptor); }
@Override public void onNodeSelected(final TreeNode< ? > node, final SelectionModel< ? > model) { final Array< ? > allSelected = model.getSelectedNodes(); final List<Object> newSelection = new ArrayList<>(); for (final Object item : allSelected.asIterable()) { newSelection.add(item); } if (newSelection.contains(node)) { setSelection(new Selection<>(newSelection, node)); } else { setSelection(new Selection<>(newSelection)); } if (node != null && node instanceof StorableNode && appContext.getCurrentProject() != null) { appContext.getCurrentProject().setProjectDescription(node.getProject().getData()); } }
ProjectExplorerPartPresenter extends BasePresenter implements ProjectExplorerView.ActionDelegate,
        ProjectExplorerPart, HasView { @Override public void onNodeSelected(final TreeNode< ? > node, final SelectionModel< ? > model) { final Array< ? > allSelected = model.getSelectedNodes(); final List<Object> newSelection = new ArrayList<>(); for (final Object item : allSelected.asIterable()) { newSelection.add(item); } if (newSelection.contains(node)) { setSelection(new Selection<>(newSelection, node)); } else { setSelection(new Selection<>(newSelection)); } if (node != null && node instanceof StorableNode && appContext.getCurrentProject() != null) { appContext.getCurrentProject().setProjectDescription(node.getProject().getData()); } } }
ProjectExplorerPartPresenter extends BasePresenter implements ProjectExplorerView.ActionDelegate,
        ProjectExplorerPart, HasView { @Override public void onNodeSelected(final TreeNode< ? > node, final SelectionModel< ? > model) { final Array< ? > allSelected = model.getSelectedNodes(); final List<Object> newSelection = new ArrayList<>(); for (final Object item : allSelected.asIterable()) { newSelection.add(item); } if (newSelection.contains(node)) { setSelection(new Selection<>(newSelection, node)); } else { setSelection(new Selection<>(newSelection)); } if (node != null && node instanceof StorableNode && appContext.getCurrentProject() != null) { appContext.getCurrentProject().setProjectDescription(node.getProject().getData()); } } @Inject  ProjectExplorerPartPresenter(ProjectExplorerView view,
                                        EventBus eventBus,
                                        ProjectServiceClient projectServiceClient,
                                        ContextMenu contextMenu,
                                        CoreLocalizationConstant coreLocalizationConstant,
                                        AppContext appContext,
                                        TreeStructureProviderRegistry treeStructureProviderRegistry,
                                        DeleteNodeHandler deleteNodeHandler,
                                        Provider<ProjectListStructure> projectListStructureProvider); }
ProjectExplorerPartPresenter extends BasePresenter implements ProjectExplorerView.ActionDelegate,
        ProjectExplorerPart, HasView { @Override public void onNodeSelected(final TreeNode< ? > node, final SelectionModel< ? > model) { final Array< ? > allSelected = model.getSelectedNodes(); final List<Object> newSelection = new ArrayList<>(); for (final Object item : allSelected.asIterable()) { newSelection.add(item); } if (newSelection.contains(node)) { setSelection(new Selection<>(newSelection, node)); } else { setSelection(new Selection<>(newSelection)); } if (node != null && node instanceof StorableNode && appContext.getCurrentProject() != null) { appContext.getCurrentProject().setProjectDescription(node.getProject().getData()); } } @Inject  ProjectExplorerPartPresenter(ProjectExplorerView view,
                                        EventBus eventBus,
                                        ProjectServiceClient projectServiceClient,
                                        ContextMenu contextMenu,
                                        CoreLocalizationConstant coreLocalizationConstant,
                                        AppContext appContext,
                                        TreeStructureProviderRegistry treeStructureProviderRegistry,
                                        DeleteNodeHandler deleteNodeHandler,
                                        Provider<ProjectListStructure> projectListStructureProvider); @Override void go(AcceptsOneWidget container); @Override View getView(); @Override void onOpen(); @Nonnull @Override String getTitle(); @Override ImageResource getTitleImage(); @Override SVGResource getTitleSVGImage(); @Override String getTitleToolTip(); @Override int getSize(); @Override void onNodeSelected(final TreeNode< ? > node, final SelectionModel< ? > model); @Override void onNodeExpanded(@Nonnull final TreeNode<?> node); @Override void onNodeAction(@Nonnull TreeNode<?> node); @Override void onContextMenu(int mouseX, int mouseY); @Override void onDeleteKey(); @Override void onEnterKey(); }
ProjectExplorerPartPresenter extends BasePresenter implements ProjectExplorerView.ActionDelegate,
        ProjectExplorerPart, HasView { @Override public void onNodeSelected(final TreeNode< ? > node, final SelectionModel< ? > model) { final Array< ? > allSelected = model.getSelectedNodes(); final List<Object> newSelection = new ArrayList<>(); for (final Object item : allSelected.asIterable()) { newSelection.add(item); } if (newSelection.contains(node)) { setSelection(new Selection<>(newSelection, node)); } else { setSelection(new Selection<>(newSelection)); } if (node != null && node instanceof StorableNode && appContext.getCurrentProject() != null) { appContext.getCurrentProject().setProjectDescription(node.getProject().getData()); } } @Inject  ProjectExplorerPartPresenter(ProjectExplorerView view,
                                        EventBus eventBus,
                                        ProjectServiceClient projectServiceClient,
                                        ContextMenu contextMenu,
                                        CoreLocalizationConstant coreLocalizationConstant,
                                        AppContext appContext,
                                        TreeStructureProviderRegistry treeStructureProviderRegistry,
                                        DeleteNodeHandler deleteNodeHandler,
                                        Provider<ProjectListStructure> projectListStructureProvider); @Override void go(AcceptsOneWidget container); @Override View getView(); @Override void onOpen(); @Nonnull @Override String getTitle(); @Override ImageResource getTitleImage(); @Override SVGResource getTitleSVGImage(); @Override String getTitleToolTip(); @Override int getSize(); @Override void onNodeSelected(final TreeNode< ? > node, final SelectionModel< ? > model); @Override void onNodeExpanded(@Nonnull final TreeNode<?> node); @Override void onNodeAction(@Nonnull TreeNode<?> node); @Override void onContextMenu(int mouseX, int mouseY); @Override void onDeleteKey(); @Override void onEnterKey();  }