コード例 #1
0
  protected ToolbarMenuButton getAddTabButton() {
    shortToLongTabNameMap = UIFactory.getAvailableTabNameMap();

    List<String> enabledTabs = new ArrayList<String>();
    for (AbstractTab tab : tabs) {
      enabledTabs.add(tab.getClass().getName());
    }

    Menu addTabMenu = new Menu();
    for (String tabName : shortToLongTabNameMap.keySet()) {
      CheckItem item =
          new CheckItem(tabName, enabledTabs.contains(shortToLongTabNameMap.get(tabName)));
      addTabMenu.addItem(item);
      item.addListener(
          new CheckItemListenerAdapter() {
            @Override
            public void onCheckChange(CheckItem item, boolean checked) {
              String javaClassName = shortToLongTabNameMap.get(item.getText());
              if (checked) {
                onTabAdded(javaClassName);
              } else {
                onTabRemoved(javaClassName);
              }
            }
          });
    }

    // Add the "Add user defined tab"
    addTabMenu.addSeparator();
    Item item = new Item("Add your own tab");
    addTabMenu.addItem(item);
    item.addListener(
        new BaseItemListenerAdapter() {
          @Override
          public void onClick(BaseItem item, EventObject e) {
            onUserDefinedTabAdded();
          }
        });

    ToolbarMenuButton addTabButton = new ToolbarMenuButton("Add tab", addTabMenu);
    addTabButton.setIcon("images/tab_add.gif");
    return addTabButton;
  }
コード例 #2
0
  protected ToolbarMenuButton getAddPortletButton() {
    shortToLongPortletNameMap = UIFactory.getAvailablePortletNameMap();

    Menu addPortletMenu = new Menu();
    for (String portletName : shortToLongPortletNameMap.keySet()) {
      Item item = new Item(portletName);
      addPortletMenu.addItem(item);
      item.addListener(
          new BaseItemListenerAdapter() {
            @Override
            public void onClick(BaseItem item, EventObject e) {
              String javaClassName = shortToLongPortletNameMap.get(((Item) item).getText());
              onPortletAdded(javaClassName);
            }
          });
    }
    ToolbarMenuButton addPortletButton =
        new ToolbarMenuButton("Add content to this tab", addPortletMenu);
    addPortletButton.setIcon("images/portlet_add.gif");
    return addPortletButton;
  }