Example #1
0
  private Widget header() {
    FlexTable ft = new FlexTable();

    ft.setWidget(0, 0, new Label(Constants.INSTANCE.ViewingSnapshot()));
    ft.setWidget(0, 1, new HTML("<b>" + this.snapInfo.getName() + "</b>"));
    ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    ft.setWidget(1, 0, new Label(Constants.INSTANCE.ForPackage()));
    ft.setWidget(1, 1, new Label(this.parentConf.getName()));
    ft.getFlexCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    HTML dLink =
        new HTML(
            "<a href='"
                + PackageBuilderWidget.getDownloadLink(this.parentConf)
                + "' target='_blank'>"
                + Constants.INSTANCE.clickHereToDownloadBinaryOrCopyURLForDeploymentAgent()
                + "</a>");
    ft.setWidget(2, 0, new Label(Constants.INSTANCE.DeploymentURL()));
    ft.setWidget(2, 1, dLink);
    ft.getFlexCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    ft.setWidget(3, 0, new Label(Constants.INSTANCE.SnapshotCreatedOn()));
    ft.getFlexCellFormatter().setHorizontalAlignment(3, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    ft.setWidget(
        3,
        1,
        new Label(
            DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT)
                .format(parentConf.getLastModified())));
    ft.getFlexCellFormatter().setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    ft.setWidget(4, 0, new Label(Constants.INSTANCE.CommentColon()));
    ft.setWidget(4, 1, new Label(parentConf.getCheckinComment()));
    ft.getFlexCellFormatter().setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    HorizontalPanel actions = new HorizontalPanel();

    actions.add(getDeleteButton(this.snapInfo.getName(), this.parentConf.getName()));
    actions.add(getCopyButton(this.snapInfo.getName(), this.parentConf.getName()));

    ft.setWidget(5, 0, actions);

    ft.setWidget(6, 0, getCompareWidget(this.parentConf.getName(), this.snapInfo.getName()));
    ft.getFlexCellFormatter().setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    ft.getFlexCellFormatter().setColSpan(5, 0, 2);

    return ft;
  }
Example #2
0
  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);
  }
Example #3
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);
  }
Example #4
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());
  }
Example #5
0
 public void viewPackageDetail(Module packageConfigData) {
   clientFactory.getPlaceController().goTo(new ModuleEditorPlace(packageConfigData.getUuid()));
 }
Example #6
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);
                      }
                    }
                  }
                }
              });
    }
  }
 private Module getConfigDataHelper(String uuidStr) {
   Module data = new Module();
   data.setUuid(uuidStr);
   return data;
 }