コード例 #1
0
  public void saveTab(FormEvent event) throws IOException {

    String lang = event.getPortletRequest().getLocale().getLanguage();
    String name = event.getPortletRequest().getParameter("myTF");
    String label = event.getAction().getParameter("tabid");

    PortletTabbedPane pane = layoutMgr.getUserTabbedPane(event.getPortletRequest());
    List tabs = pane.getPortletTabs();
    Iterator it = tabs.iterator();
    while (it.hasNext()) {
      PortletTab tab = (PortletTab) it.next();
      if (tab.getLabel().equals(label)) {
        tab.setTitle(lang, name);
        tab.setLabel(URLEncoder.encode(name, "UTF-8"));
      }
    }
    pane.save();
    PortletPage page = layoutMgr.getPortletPage(event.getPortletRequest());
    PortletTabbedPane mypane = page.getPortletTabbedPane();
    it = mypane.getPortletTabs().iterator();
    while (it.hasNext()) {
      PortletTab tab = (PortletTab) it.next();
      if (tab.getLabel().equals(label)) {
        tab.setTitle(lang, name);
        tab.setLabel(URLEncoder.encode(name, "UTF-8"));
      }
    }
    layoutMgr.reloadPage(event.getPortletRequest());
  }
コード例 #2
0
  public void deleteTab(FormEvent event) throws IOException {
    String label = event.getAction().getParameter("tabid");

    PortletTabbedPane pane = layoutMgr.getUserTabbedPane(event.getPortletRequest());
    List tabs = pane.getPortletTabs();
    Iterator it = tabs.iterator();
    while (it.hasNext()) {
      PortletTab tab = (PortletTab) it.next();
      if (tab.getLabel().equals(label)) {
        it.remove();
      }
    }
    pane.save();
    PortletPage page = layoutMgr.getPortletPage(event.getPortletRequest());
    PortletTabbedPane mypane = page.getPortletTabbedPane();
    it = mypane.getPortletTabs().iterator();
    while (it.hasNext()) {
      PortletTab tab = (PortletTab) it.next();
      if (tab.getLabel().equals(label)) {
        it.remove();
      }
    }
    layoutMgr.reloadPage(event.getPortletRequest());
  }
コード例 #3
0
  public void createNewTab(FormEvent event) throws PortletException, IOException {

    String tabName = event.getTextFieldBean("userTabTF").getValue();
    RadioButtonBean rb = event.getRadioButtonBean("colsRB");
    String rbtype = rb.getSelectedValue();

    int cols = Integer.valueOf(rbtype).intValue();
    if (tabName == null) {
      createErrorMessage(
          event, this.getLocalizedText(event.getPortletRequest(), "LAYOUT_NOTAB_ERROR"));
      return;
    }
    log.debug("creating tab " + tabName + " cols= " + cols);
    PortletTabbedPane pane = layoutMgr.getUserTabbedPane(event.getPortletRequest());
    if (pane != null) {
      Iterator it = pane.getPortletTabs().iterator();
      while (it.hasNext()) {
        PortletTab tab = (PortletTab) it.next();
        if (tab.getLabel().equals(tabName + "Tab")) {
          createErrorMessage(
              event, this.getLocalizedText(event.getPortletRequest(), "LAYOUT_SAMETAB_ERROR"));
          return;
        }
      }
    }

    pane = layoutMgr.createUserTabbedPane(event.getPortletRequest(), cols, tabName);

    PortletTab tab = pane.getLastPortletTab();

    pane.save();
    PortletPage page = layoutMgr.getPortletPage(event.getPortletRequest());
    PortletTabbedPane mypane = page.getPortletTabbedPane();
    List tabs = mypane.getPortletTabs();
    tabs.add(tab);
    Collections.sort(tabs, new PortletTab());
    layoutMgr.reloadPage(event.getPortletRequest());
  }