예제 #1
0
  public SnapshotView(
      ClientFactory clientFactory, EventBus eventBus, SnapshotInfo snapInfo, Module parentPackage) {
    this.clientFactory = clientFactory;
    this.eventBus = eventBus;
    vert = new VerticalPanel();
    this.snapInfo = snapInfo;
    this.parentConf = parentPackage;
    PrettyFormLayout head = new PrettyFormLayout();

    head.addHeader(DroolsGuvnorImages.INSTANCE.snapshot(), header());

    vert.add(head);

    AssetViewerActivity assetViewerActivity =
        new AssetViewerActivity(parentConf.getUuid(), clientFactory);
    assetViewerActivity.start(
        new AcceptItem() {
          public void add(String tabTitle, IsWidget widget) {
            ScrollPanel pnl = new ScrollPanel();
            pnl.setWidth("100%");
            pnl.add(widget);
            vert.add(pnl);
          }
        },
        null);

    vert.setWidth("100%");
    initWidget(vert);
  }
예제 #2
0
  @Test
  public void testSetRootItem() throws Exception {
    IsTreeItem treeItem = mock(IsTreeItem.class);
    ModuleTreeItemView view = mock(ModuleTreeItemView.class);

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

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

    Module packageConfigData = mock(Module.class);
    when(packageConfigData.getUuid()).thenReturn("mockUuid");
    new ModuleTreeSelectableItem(navigationViewFactory, 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());
  }
예제 #3
0
 public void viewPackageDetail(Module packageConfigData) {
   clientFactory.getPlaceController().goTo(new ModuleEditorPlace(packageConfigData.getUuid()));
 }
예제 #4
0
  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);
                      }
                    }
                  }
                }
              });
    }
  }