Esempio n. 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();
  }
Esempio n. 2
0
  public Canvas getViewPanel() {

    VLayout layout = new VLayout();
    layout.setMembersMargin(10);

    final Canvas cubeBin = new Canvas("cubeBin");
    cubeBin.setTop(40);
    cubeBin.setWidth(400);
    cubeBin.setHeight(300);
    cubeBin.setShowEdges(true);

    IButton button = new IButton();
    button.setTitle("Create");
    button.setIcon("pieces/16/cube_blue.png");
    button.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            final Img img = new Img();
            img.setLeft(Random.nextInt(340));
            img.setTop(Random.nextInt(240));
            img.setWidth(48);
            img.setHeight(48);
            img.setParentElement(cubeBin);
            img.setSrc("pieces/48/cube_blue.png");
            img.addClickHandler(
                new ClickHandler() {
                  public void onClick(ClickEvent event) {
                    img.destroy();
                  }
                });
            img.draw();
          }
        });
    layout.addMember(button);
    layout.addMember(cubeBin);

    return layout;
  }