Ejemplo n.º 1
0
 @Override
 public void updateLabel(Portlet portlet) {
   TabItem tab = getTab(portlet);
   if (tab != null) {
     tab.setText(getTabLabel(portlet, 0, 0));
     if (portlet instanceof AppPortlet)
       tab.getHeader().setToolTip(((AppPortlet) portlet).getPresenterToolTip());
   }
 }
Ejemplo n.º 2
0
  @Override
  public boolean reinsert(Portlet portlet, int index, int column, int portletId) {
    //	Do any AppPortlet specific tasks
    if (portlet instanceof AppPortlet) {
      AppPortlet appPortlet = (AppPortlet) portlet;
      //	Make sure there's not already a duplicate portlet, and if so, don't add this one, just jump
      // to that one
      AppPortlet existingPortlet = (AppPortlet) getByIdentity(appPortlet.getPortletIdentity());
      if (existingPortlet != null && !existingPortlet.allowDuplicatePortlets()) {
        scrollToPortlet(existingPortlet);
        return false;
      }
      //	Otherwise, set the id and stuff
      appPortlet.setPortletId(portletId);
      appPortlet.setPresenter(this);
    }

    if (index < 0) index = 0;
    if (column < 0) column = 0;

    //	Get the tab we'll add (with the portlet in it)
    TabItem tab = getNewPortletTab(portlet, index, column);

    //	Create all the columns we need
    while (portletTabs.size() <= column) {
      portletTabs.add(new ArrayList<TabItem>());
    }

    //	Get the column we'll add to
    List<TabItem> tabColumn = portletTabs.get(column);

    //	Now we'll add the tab to the proper column, and to the display

    //	If this is at the end of the column, the tab has to go before the first item in the next
    // column
    if (index >= tabColumn.size()) {
      //	Append to end of the column
      tabColumn.add(tab);

      //	Find the next actual tab item
      TabItem nextTab = null;
      int nextColumn = column + 1;

      while (nextTab == null && nextColumn < portletTabs.size()) {
        //	Insert before first tab in next column
        List<TabItem> nextTabColumn = portletTabs.get(nextColumn);
        nextColumn++;
        if (nextTabColumn.size() > 0) {
          nextTab = nextTabColumn.get(0);
          break;
        }
      }

      //	Add the tab
      if (nextTab == null) {
        //	No next column, just add to end
        tabPanel.add(tab);
      } else {
        tabPanel.insert(tab, tabPanel.indexOf(nextTab));
      }
    } else {
      //	Insert before the specified tab in this column
      TabItem beforeTab = tabColumn.get(index);
      if (beforeTab != null) {
        tabColumn.add(index, tab);
        int tabIndex = tabPanel.indexOf(beforeTab);
        if (tabIndex < 0) tabIndex = 0;
        tabPanel.insert(tab, tabIndex);
      } else {
        tabColumn.add(0, tab);
        tabPanel.insert(tab, 0);
      }
    }

    //	Lastly, set the row and column for the portlet, and fix the local next portlet ID
    if (portlet instanceof AppPortlet) {
      AppPortlet appPortlet = (AppPortlet) portlet;

      // Set the tooltip for the tab
      tab.getHeader().setToolTip(appPortlet.getPresenterToolTip());
      //	appPortlet.registerUserPortlet(appPortlet.getPortletId(), index, column);
      appPortlet.setPortalColumn(column);
      appPortlet.setPortalRow(index);
      if (appPortlet.getPortletId() >= nextPortalId) nextPortalId = appPortlet.getPortletId() + 1;
    }

    return true;
  }