@Test
  public void testSetRootItem() throws Exception {
    treeItem = mock(IsTreeItem.class);
    view = mock(ModuleTreeItemView.class);
    ClientFactory clientFactory = mock(ClientFactory.class);

    AssetEditorFactory assetEditorFactory = mock(AssetEditorFactory.class);
    when(clientFactory.getAssetEditorFactory()).thenReturn(assetEditorFactory);

    PerspectiveFactory perspectiveFactory = mock(PerspectiveFactory.class);
    when(perspectiveFactory.getRegisteredAssetEditorFormats("package")).thenReturn(new String[0]);

    NavigationViewFactory navigationViewFactory = mock(NavigationViewFactory.class);
    when(clientFactory.getNavigationViewFactory()).thenReturn(navigationViewFactory);
    when(navigationViewFactory.getModuleTreeItemView()).thenReturn(view);

    PackageConfigData packageConfigData = mock(PackageConfigData.class);
    when(packageConfigData.getUuid()).thenReturn("mockUuid");
    new ModuleTreeSelectableItem(clientFactory, treeItem, packageConfigData);

    verify(view).setRootItem(treeItem);

    ArgumentCaptor<ModuleEditorPlace> moduleEditorPlaceArgumentCaptor =
        ArgumentCaptor.forClass(ModuleEditorPlace.class);
    verify(view).setRootUserObject(moduleEditorPlaceArgumentCaptor.capture());
    ModuleEditorPlace assetViewerPlace = moduleEditorPlaceArgumentCaptor.getValue();

    assertEquals("mockUuid", assetViewerPlace.getUuid());
  }
  private void createPresenter() {
    ClientFactory clientFactory = mock(ClientFactory.class);

    NavigationViewFactory navigationViewFactory = mock(NavigationViewFactory.class);
    when(clientFactory.getNavigationViewFactory()).thenReturn(navigationViewFactory);

    when(navigationViewFactory.getModulesTreeView()).thenReturn(view);

    ModulesTreeItemView knowledgeModulesTreeItemView = mock(ModulesTreeItemView.class);
    when(navigationViewFactory.getModulesTreeItemView()).thenReturn(knowledgeModulesTreeItemView);

    ModuleServiceAsync packageService = mock(ModuleServiceAsync.class);
    when(clientFactory.getModuleService()).thenReturn(packageService);

    /*
    MenuBar rootMenuBar = new MenuBar( true );
    when(
            modulesNewAssetMenuView.asWidget()
    ).thenReturn(
            rootMenuBar
    );*/

    GlobalAreaTreeItemView globalAreaTreeItemView = mock(GlobalAreaTreeItemView.class);
    when(navigationViewFactory.getGlobalAreaTreeItemView()).thenReturn(globalAreaTreeItemView);
    EventBus eventBus = mock(EventBus.class);

    new ModulesTree(clientFactory, eventBus, "AuthorPerspective");
  }
  private void fillModuleItemStructure() {
    // If two or more asset editors (that are associated with different formats) have same titles,
    // we group them together and display them as one node on the package tree.
    String[] registeredFormats =
        clientFactory
            .getPerspectiveFactory()
            .getRegisteredAssetEditorFormats(packageConfigData.getFormat());

    // Use list to preserve the order of asset editors defined in configuration.
    List<FormatList> formatListGroupedByTitles = new ArrayList<FormatList>();
    for (String format : registeredFormats) {
      boolean found = false;
      for (FormatList formatListWithSameTitle : formatListGroupedByTitles) {
        found = formatListWithSameTitle.titleAlreadyExists(format);
        if (found) {
          formatListWithSameTitle.add(format);
          break;
        }
      }
      if (!found) {
        FormatList formatListWithSameTile = new FormatList();
        formatListWithSameTile.add(format);
        formatListGroupedByTitles.add(formatListWithSameTile);
      }
    }

    addTitleItems(formatListGroupedByTitles);
  }
Exemple #4
0
 @Override
 public void start(AcceptItem tabbedPanel, EventBus eventBus) {
   if (ExplorerNodeConfig.INCOMING_ID.equals(place.getInboxType())) {
     openInboxIncomingPagedTable(
         tabbedPanel,
         clientFactory.getNavigationViewFactory().getBrowseTreeView().getInboxIncomingName(),
         place.getInboxType());
   } else if (ExplorerNodeConfig.RECENT_EDITED_ID.equals(place.getInboxType())) {
     openInboxPagedTable(
         tabbedPanel,
         clientFactory.getNavigationViewFactory().getBrowseTreeView().getInboxRecentEditedName(),
         place.getInboxType());
   } else if (ExplorerNodeConfig.RECENT_VIEWED_ID.equals(place.getInboxType())) {
     openInboxPagedTable(
         tabbedPanel,
         clientFactory.getNavigationViewFactory().getBrowseTreeView().getInboxRecentViewedName(),
         place.getInboxType());
   }
 }
  @Override
  public void start(final AcceptItem acceptTabItem, EventBus eventBus) {

    view.showLoadingPackageInformationMessage();

    // title is not used.
    acceptTabItem.add(null, view);
    clientFactory
        .getModuleService()
        .loadModule(
            uuid,
            new GenericCallback<Module>() {
              public void onSuccess(Module conf) {
                packageConfigData = conf;
                RulePackageSelector.currentlySelectedPackage = packageConfigData.getName();

                fillModuleItemStructure();

                view.closeLoadingPackageInformationMessage();
              }
            });
  }
 public void viewPackageDetail(Module packageConfigData) {
   clientFactory.getPlaceController().goTo(new ModuleEditorPlace(packageConfigData.getUuid()));
 }
 public AssetViewerActivity(String uuid, ClientFactory clientFactory) {
   this.uuid = uuid;
   this.clientFactory = clientFactory;
   this.view = clientFactory.getNavigationViewFactory().getAssetViewerActivityView();
 }
 private Image getGroupIcon(String format) {
   return clientFactory.getAssetEditorFactory().getAssetEditorIcon(format);
 }
 private String getGroupTitle(String format) {
   return clientFactory.getAssetEditorFactory().getAssetEditorTitle(format);
 }
  private void addTitleItems(List<FormatList> formatListGroupedByTitles) {

    // Record the number of groups expected to have assets, if all are found to be empty we show a
    // warning
    final AssetGroupSemaphore s = new AssetGroupSemaphore(formatListGroupedByTitles.size());
    final AssetViewerSection[] sections = new AssetViewerSection[formatListGroupedByTitles.size()];

    for (int i = 0; i < formatListGroupedByTitles.size(); i++) {

      final FormatList formatList = formatListGroupedByTitles.get(i);
      final int sectionIndex = i;

      // Only add a section to the view if the Format Group contains Format Types
      if (formatList.size() == 0) {
        continue;
      }

      final List<String> formatsInList = getFormatsInList(formatList);
      final Boolean formatIsRegistered = getFormatIsRegistered(formatList);

      // Check if there are any assets for the group
      AssetPageRequest request =
          new AssetPageRequest(packageConfigData.getUuid(), formatsInList, formatIsRegistered);
      clientFactory
          .getAssetService()
          .getAssetCount(
              request,
              new GenericCallback<Long>() {
                public void onSuccess(Long count) {

                  s.recordProcessedGroup();

                  if (count > 0) {

                    // If the group contains assets add a section
                    String title = getGroupTitle(formatList.getFirst());
                    Image icon = getGroupIcon(formatList.getFirst());
                    AssetViewerSection section =
                        new AssetViewerSection(title, icon, formatsInList, formatIsRegistered);
                    sections[sectionIndex] = section;
                  } else {

                    // Otherwise record empty group and show warning, if applicable
                    s.recordEmptyGroup();
                    if (s.areAllGroupsEmpty()) {
                      view.showHasNoAssetsWarning(true);
                    }
                  }

                  // If all groups have been processed add sections to UI
                  if (s.areAllGroupsProcessed()) {
                    for (AssetViewerSection section : sections) {
                      if (section != null) {
                        view.addAssetFormat(
                            section.formatsInList,
                            section.formatIsRegistered,
                            section.title,
                            section.icon,
                            packageConfigData,
                            clientFactory);
                      }
                    }
                  }
                }
              });
    }
  }
 public SOAServicesNewAssetMenu(ClientFactory clientFactory, EventBus eventBus) {
   this.clientFactory = clientFactory;
   this.eventBus = eventBus;
   this.view = clientFactory.getNavigationViewFactory().getServicesNewAssetMenuView();
   view.setPresenter(this);
 }