Exemplo n.º 1
0
  private void buildFavoriteGroupsMenu(Favorites favorites, Menu menu, Set<Integer> groupIds) {

    if (groupIds.isEmpty()) {
      menu.setItems();
      return;
    }

    List<MenuItem> items = new ArrayList<MenuItem>(groupIds.size());

    for (final Integer groupId : groupIds) {
      ResourceGroupComposite groupComposite = favorites.getGroupComposite(groupId);
      if (null == groupComposite) {
        // if the resource group is gone just skip it
        continue;
      }
      final ResourceGroup group = groupComposite.getResourceGroup();

      MenuItem item = new MenuItem(String.valueOf(groupId));
      item.setTitle(group.getName());
      item.setIcon(
          ImageManager.getGroupIcon(
              group.getGroupCategory(), groupComposite.getExplicitAvailabilityType()));

      item.addClickHandler(
          new com.smartgwt.client.widgets.menu.events.ClickHandler() {
            public void onClick(MenuItemClickEvent event) {
              CoreGUI.goToView(LinkManager.getResourceGroupLink(group));
            }
          });
      items.add(item);
    }
    menu.setItems(items.toArray(new MenuItem[items.size()]));
  }
Exemplo n.º 2
0
  private Tab buildBundlesTab(TabSet tabSet) {
    Tab tab = new Tab(MSG.common_title_bundles(), ImageManager.getBundleIcon());
    // NOTE: We will set the tab content to the bundle selector later, once the Bundle Group has
    // been fetched.

    return tab;
  }
Exemplo n.º 3
0
  private void buildFavoriteResourcesMenu(
      Favorites favorites,
      Menu menu,
      Set<Integer> resourceIds,
      AncestryUtil.MapWrapper typesWrapper) {

    if (resourceIds.isEmpty()) {
      menu.setItems();
      return;
    }

    List<MenuItem> items = new ArrayList<MenuItem>(resourceIds.size());

    for (final Integer resourceId : resourceIds) {
      Resource resource = favorites.getResource(resourceId);
      if (null == resource) {
        // if the resource is gone just skip it
        continue;
      }

      MenuItem item = new MenuItem(resource.getName());
      item.setIcon(ImageManager.getResourceIcon(resource));

      // build a subMenu to display a disambiguated resource
      item.setAttribute(AncestryUtil.RESOURCE_ID, resourceId);
      item.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
      item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
      item.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
      item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
      Menu ancestryMenu = new Menu();
      MenuItem ancestryItem = new MenuItem(AncestryUtil.getAncestryHoverHTML(item, -1));
      ancestryItem.setEnabled(false);
      ancestryMenu.setItems(ancestryItem);
      ancestryMenu.setSubmenuDirection("left");
      ancestryMenu.setAutoWidth();
      item.setSubmenu(ancestryMenu);

      item.addClickHandler(
          new com.smartgwt.client.widgets.menu.events.ClickHandler() {
            public void onClick(MenuItemClickEvent event) {
              CoreGUI.goToView(LinkManager.getResourceLink(resourceId));
            }
          });

      items.add(item);
    }

    menu.setCanSelectParentItems(Boolean.TRUE);
    menu.setItems(items.toArray(new MenuItem[items.size()]));
  }
Exemplo n.º 4
0
    @Override
    protected String getIcon(Record record, boolean defaultState) {

      if (record instanceof TreeNode) {
        // boolean open = getTree().isOpen((TreeNode) record);

        if (record instanceof ResourceTypePluginTreeDataSource.ResourceTypeTreeNode) {
          ResourceType resourceType =
              ((ResourceTypePluginTreeDataSource.ResourceTypeTreeNode) record).getResourceType();

          return ImageManager.getResourceIcon(resourceType.getCategory());
        } else if (record instanceof ResourceTypePluginTreeDataSource.PluginTreeNode) {
          return "types/plugin_16.png";
        }
      }
      return null;
    }
Exemplo n.º 5
0
  private void buildRecentlyViewedMenu(
      Favorites favorites,
      Menu menu,
      List<Integer> recentResourceIds,
      List<Integer> recentGroupIds,
      AncestryUtil.MapWrapper typesWrapper) {

    if (recentResourceIds.isEmpty() && recentGroupIds.isEmpty()) {
      return;
    }
    List<MenuItem> items =
        new ArrayList<MenuItem>(recentResourceIds.size() + recentGroupIds.size() + 1);

    for (final Integer resourceId : recentResourceIds) {
      Resource resource = favorites.getResource(resourceId);
      if (null == resource) {
        // if the resource is gone just skip it
        continue;
      }

      MenuItem item = new MenuItem(resource.getName());
      item.setIcon(ImageManager.getResourceIcon(resource));

      // build a subMenu to display a disambiguated resource
      item.setAttribute(AncestryUtil.RESOURCE_ID, resourceId);
      item.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
      item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
      item.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
      item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);

      Menu ancestryMenu = new Menu();
      MenuItem ancestryItem = new MenuItem(AncestryUtil.getAncestryHoverHTML(item, -1));
      ancestryItem.setEnabled(false);
      ancestryMenu.setItems(ancestryItem);
      ancestryMenu.setSubmenuDirection("left");
      ancestryMenu.setAutoWidth();
      item.setSubmenu(ancestryMenu);

      item.addClickHandler(
          new com.smartgwt.client.widgets.menu.events.ClickHandler() {
            public void onClick(MenuItemClickEvent event) {
              CoreGUI.goToView(LinkManager.getResourceLink(resourceId));
            }
          });

      items.add(item);
    }

    if (!recentResourceIds.isEmpty() && !recentGroupIds.isEmpty()) {
      items.add(new MenuItemSeparator());
    }

    for (final Integer groupId : recentGroupIds) {
      ResourceGroupComposite groupComposite = favorites.getGroupComposite(groupId);
      if (null == groupComposite) {
        // if the resource group is gone just skip it
        continue;
      }
      final ResourceGroup group = groupComposite.getResourceGroup();

      MenuItem item = new MenuItem(String.valueOf(groupId));
      item.setTitle(group.getName());
      item.setIcon(
          ImageManager.getGroupIcon(
              group.getGroupCategory(), groupComposite.getExplicitAvailabilityType()));

      item.addClickHandler(
          new com.smartgwt.client.widgets.menu.events.ClickHandler() {
            public void onClick(MenuItemClickEvent event) {
              CoreGUI.goToView(LinkManager.getResourceGroupLink(group));
            }
          });
      items.add(item);
    }

    menu.setCanSelectParentItems(Boolean.TRUE);
    menu.setItems(items.toArray(new MenuItem[items.size()]));
  }
  private String getAlignedAvailabilityResults(
      long total, long up, long down, long unknown, long disabled) {
    StringBuilder results = new StringBuilder();

    results.append("<table><tr>");
    if (0 == total) {
      results.append(
          getColumn(
              false,
              "<img height=\"12\" width=\"12\" src=\""
                  + ImageManager.getFullImagePath(ImageManager.getAvailabilityIcon(null))
                  + "\" /> 0"));
      results.append(getColumn(true));
      results.append(getColumn(false));

    } else {
      if (up > 0) {
        String imagePath =
            ImageManager.getFullImagePath(
                ImageManager.getAvailabilityIconFromAvailType(AvailabilityType.UP));
        results.append(
            getColumn(false, " <img height=\"12\" width=\"12\" src=\"" + imagePath + "\" />", up));
      } else {
        results.append(
            getColumn(
                false,
                "&nbsp;<img src=\""
                    + ImageManager.getBlankIcon()
                    + "\" width=\"12px\" height=\"12px\" />"));
      }

      if (down > 0) {
        String imagePath =
            ImageManager.getFullImagePath(
                ImageManager.getAvailabilityIconFromAvailType(AvailabilityType.DOWN));
        results.append(
            getColumn(
                false, " <img height=\"12\" width=\"12\" src=\"" + imagePath + "\" />", down));
      } else {
        results.append(
            getColumn(
                false,
                "&nbsp;<img src=\""
                    + ImageManager.getBlankIcon()
                    + "\" width=\"12px\" height=\"12px\" />"));
      }

      if (disabled > 0) {
        String imagePath =
            ImageManager.getFullImagePath(
                ImageManager.getAvailabilityIconFromAvailType(AvailabilityType.DISABLED));
        results.append(
            getColumn(
                false, " <img height=\"12\" width=\"12\" src=\"" + imagePath + "\" />", disabled));
      } else {
        results.append(
            getColumn(
                false,
                "&nbsp;<img src=\""
                    + ImageManager.getBlankIcon()
                    + "\" width=\"12px\" height=\"12px\" />"));
      }

      if (unknown > 0) {
        String imagePath =
            ImageManager.getFullImagePath(
                ImageManager.getAvailabilityIconFromAvailType(AvailabilityType.UNKNOWN));
        results.append(
            getColumn(
                false, " <img height=\"12\" width=\"12\" src=\"" + imagePath + "\" />", unknown));
      } else {
        results.append(
            getColumn(
                false,
                "&nbsp;<img src=\""
                    + ImageManager.getBlankIcon()
                    + "\" width=\"1px\" height=\"1px\" />"));
      }
    }
    results.append("</tr></table>");
    return results.toString();
  }
  private void prepareDetailsSection(SectionStack stack, ServerPlugin plugin) {
    DynamicForm form = new DynamicForm();
    form.setMargin(10);
    form.setWidth100();
    form.setWrapItemTitles(false);
    form.setNumCols(4);

    StaticTextItem nameItem = new StaticTextItem("name", MSG.common_title_name());
    nameItem.setValue(plugin.getName());

    StaticTextItem displayNameItem =
        new StaticTextItem("displayName", MSG.common_title_display_name());
    displayNameItem.setValue(plugin.getDisplayName());

    StaticTextItem versionItem = new StaticTextItem("version", MSG.common_title_version());
    versionItem.setValue(plugin.getVersion());

    StaticTextItem md5Item = new StaticTextItem("MD5", "MD5");
    md5Item.setValue(plugin.getMD5());

    StaticTextItem pathItem = new StaticTextItem("path", MSG.common_title_path());
    pathItem.setValue(plugin.getPath());

    StaticTextItem ampsItem =
        new StaticTextItem("ampsVersion", "AMPS " + MSG.common_title_version());
    ampsItem.setValue(plugin.getAmpsVersion());

    StaticTextItem descItem = new StaticTextItem("desc", MSG.common_title_description());
    descItem.setValue(plugin.getDescription());

    StaticTextItem mtimeItem = new StaticTextItem("mtime", MSG.common_title_lastUpdated());
    mtimeItem.setValue(
        TimestampCellFormatter.format(
            Long.valueOf(plugin.getMtime()), TimestampCellFormatter.DATE_TIME_FORMAT_MEDIUM));

    StaticTextItem kindItem = new StaticTextItem("kind", MSG.common_title_kind());
    switch (plugin.getDeployment()) {
      case AGENT:
        kindItem.setValue(MSG.view_admin_plugins_agent());
        break;
      case SERVER:
        kindItem.setValue(MSG.view_admin_plugins_server());
        break;
    }

    CanvasItem enabledItem = new CanvasItem("enabled", MSG.common_title_enabled());
    Img img = new Img(ImageManager.getAvailabilityIcon(plugin.isEnabled()), 16, 16);
    enabledItem.setCanvas(img);

    StaticTextItem typeItem = new StaticTextItem("type", MSG.common_title_type());
    typeItem.setValue(plugin.getType());

    form.setItems(
        displayNameItem,
        nameItem,
        versionItem,
        ampsItem,
        md5Item,
        kindItem,
        descItem,
        pathItem,
        mtimeItem,
        enabledItem,
        typeItem);

    SectionStackSection section = new SectionStackSection(MSG.common_title_details());
    section.setExpanded(true);
    section.setItems(form);

    detailsSection = section;
    ++initSectionCount;

    return;
  }