Пример #1
0
  protected void addPortlet(String portletKey, String portletName) {
    DashboardPortlet storedPortlet = new DashboardPortlet(portletName, portletKey, 250);
    storedDashboard.addPortlet(storedPortlet);

    String locatorId = getPortletLocatorId(portalLayout, storedPortlet);
    final PortletWindow newPortletWindow =
        new PortletWindow(locatorId, this, storedPortlet, context);
    newPortletWindow.setTitle(portletName);
    newPortletWindow.setHeight(350);
    newPortletWindow.setVisible(false);

    portletWindows.add(newPortletWindow);
    portalLayout.addPortletWindow(newPortletWindow, storedPortlet.getColumn());
    PortalColumn portalColumn = portalLayout.getPortalColumn(storedPortlet.getColumn());

    // also insert a blank spacer element, which will trigger the built-in
    //  animateMembers layout animation
    final LayoutSpacer placeHolder = new LayoutSpacer();
    //        placeHolder.setRect(newPortlet.getRect());
    portalColumn.addMember(placeHolder); // add to top

    // create an outline around the clicked button
    final Canvas outline = new Canvas();
    outline.setLeft(editForm.getAbsoluteLeft() + addPortlet.getLeft());
    outline.setTop(editForm.getAbsoluteTop());
    outline.setWidth(addPortlet.getWidth());
    outline.setHeight(addPortlet.getHeight());
    outline.setBorder("2px solid 8289A6");
    outline.draw();
    outline.bringToFront();

    outline.animateRect(
        newPortletWindow.getPageLeft(),
        newPortletWindow.getPageTop(),
        newPortletWindow.getVisibleWidth(),
        newPortletWindow.getViewportHeight(),
        new AnimationCallback() {
          public void execute(boolean earlyFinish) {
            // callback at end of animation - destroy placeholder and outline; show the new portlet
            placeHolder.destroy();
            outline.destroy();
            newPortletWindow.show();
          }
        },
        750);
    save();
  }