예제 #1
0
  /** Show lightbox */
  public void show() {
    int w = getWidth();
    int h = getHeight();

    background.setWidth(Integer.toString(w));
    background.setHeight(Integer.toString(h));
    if (GWT.isScript()) {
      background.setWidget(png = new PNGImage("images/lightbox.png", w, h));
    }
    background.setPopupPosition(0, 0);
    hideSelects();

    background.show();
    backgroundFixup(background.getElement());

    /**
     * Using setPopupPositionAndShow so child popup will not jump when centering
     *
     * @author Luis Faria
     */
    child.setPopupPositionAndShow(
        new PositionCallback() {

          public void setPosition(int offsetWidth, int offsetHeight) {
            center(offsetWidth, offsetHeight);
          }
        });
  }
 private void showMessagePopup() {
   Label validationMessageLabel = new Label();
   validationMessageLabel.setStyleName("validation-textbox-message-label"); // $NON-NLS-1$
   validationMessageLabel.setText(getValidationMessage());
   VerticalPanel messagePanel = new VerticalPanel();
   messagePanel.add(validationMessageLabel);
   HorizontalPanel bottomPanel = new HorizontalPanel();
   SimplePanel hSpacer = new SimplePanel();
   hSpacer.setStylePrimaryName("validation-textbox-left-image-buffer"); // $NON-NLS-1$
   bottomPanel.add(hSpacer);
   SimplePanel tailImagePanel = new SimplePanel();
   image = new Image(GWT.getModuleBaseURL() + "images/spacer.gif"); // $NON-NLS-1$
   image.setStylePrimaryName("validation-textbox-tail-image"); // $NON-NLS-1$
   tailImagePanel.add(image);
   bottomPanel.add(tailImagePanel);
   messagePanel.add(bottomPanel);
   popupPanel = new PopupPanel(true, false);
   popupPanel.setWidget(messagePanel);
   popupPanel.setPopupPositionAndShow(
       new PositionCallback() {
         public void setPosition(int offsetWidth, int offsetHeight) {
           int absLeft = -1;
           int absTop = -1;
           absLeft = textBox.getAbsoluteLeft();
           absTop = textBox.getAbsoluteTop();
           Rectangle popupSize = ElementUtils.getSize(popupPanel.getElement());
           popupPanel.setPopupPosition(
               absLeft, absTop - popupSize.height >= 0 ? absTop - popupSize.height : absTop);
         }
       });
   popupPanel.show();
 }
예제 #3
0
 @Override
 public void show(int x, int y, Element parent, Date value) {
   currentValue = value;
   createMenu(value);
   popupPanel.setPopupPosition(x, y);
   popupPanel.show();
   menu.focus();
 }
예제 #4
0
 @Override
 public void onBrowserEvent(Event event) {
   if (DOM.eventGetType(event) == Event.ONMOUSEDOWN && enabled) {
     setupPopup();
     popup.setPopupPosition(event.getClientX(), event.getClientY());
     popup.show();
   }
 }
예제 #5
0
 public void setWaitVisible(boolean visible) {
   if (visible) {
     wait.setPopupPosition(bodyContainer.getAbsoluteLeft(), bodyContainer.getAbsoluteTop());
     wait.setPixelSize(bodyContainer.getOffsetWidth(), bodyContainer.getOffsetHeight());
     wait.show();
   } else {
     wait.hide();
   }
 }
 // @UiHandler({"edit_items"})
 public void editItemsCmd(ClickEvent ev) {
   PopupPanel p = new PopupPanel(true);
   // p.setTitle("Редактирование элементов...");
   p.setModal(false);
   // p.setPopupPosition(200, 200);
   p.setSize("100%", "100%");
   p.setWidget(new MultiValuedEntity(this.dto, null, this.filling, "", this));
   p.show();
   p.center();
 }
 // @UiHandler({"edit_field"})
 public void editFieldCmd(ClickEvent ev) {
   PopupPanel p = new PopupPanel();
   // p.setTitle("Редактирование поля...");
   p.setModal(true);
   // p.setPopupPosition(200, 200);
   p.setSize("100%", "100%");
   p.setWidget(new FieldEditor(new MultiValuedField(this.dto, null, this.filling, base_name), p));
   p.show();
   p.center();
 }
예제 #8
0
 /** Popup menu listener */
 public void onClick(ClickEvent event) {
   int x = event.getX();
   int y = event.getY();
   if (screen[x][y] != 0) {
     currentPerson = getPersonById(screen[x][y]);
     popup.showRelativeTo(currentPerson);
     popup.show();
   } else {
     popup.hide();
   }
 }
예제 #9
0
  private void openPanel() {

    if (isEnabled) {
      popup.setWidth((header.getOffsetWidth() - 10) + "px");
      popup.setHeight((cellList.getRowCount() * 25) + "px");

      popup.setPopupPosition(header.getAbsoluteLeft(), header.getAbsoluteTop() + 22);

      popup.show();
    }
  }
예제 #10
0
파일: SearchBar.java 프로젝트: galderz/rhq
  private void setupSavedSearches() {
    savedSearchesPanel.add(savedSearchesGrid);
    savedSearchesPanel.setStyleName("savedSearchesPanel");
    savedSearchesGrid.addStyleName("savedSearchesPanel");

    // panel position will be re-calculated on down-arrow click
    savedSearchesPanel.show();
    savedSearchesPanel.hide();

    SavedSearchesEventHandler handler = new SavedSearchesEventHandler();
    savedSearchesPanel.addCloseHandler(handler);
    savedSearchesGrid.setSavedSearchSelectionHandler(handler);
  }
 /**
  * On right click.
  *
  * @param value the value
  * @param event the event
  * @param element the element
  */
 public void onRightClick(CellTreeNode value, Event event, Element element) {
   clearMessages();
   selectedNode = value;
   selectionModel.setSelected(selectedNode, true);
   int x = element.getAbsoluteRight() - 10;
   int y = element.getAbsoluteBottom() + 5;
   popupPanel.setPopupPosition(x, y);
   popupPanel.setAnimationEnabled(true);
   //		popupPanel.setSize("175px", "75px");
   popupPanel.show();
   popupPanel.setStyleName("popup");
   clauseWorkspaceContextMenu.displayMenuItems(popupPanel);
 }
  @UiHandler({"editBtn"})
  public void editBtnCmd(ClickEvent ev) {
    final PopupPanel p = new PopupPanel();
    // p.setTitle("Добавление экземпляра сущности...");
    // p.setModal(false);
    p.setAutoHideEnabled(true);
    Widget source = (Widget) ev.getSource();
    int left = source.getAbsoluteLeft();
    int top = source.getAbsoluteTop();
    p.setPopupPosition(left, top);
    // p.setPopupPosition(200, 200);
    // p.setSize("190px", "100px");
    p.setSize("100%", "100%");

    Anchor editSel = new Anchor("Изменить выбор");
    Anchor editField = new Anchor("Изменить структуру");
    Anchor editItems = new Anchor("К элементам");
    editSel.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent ev) {
            editSelectionCmd(ev);
            p.hide();
          }
        });
    editField.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent ev) {
            editFieldCmd(ev);
            p.hide();
          }
        });
    editItems.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent ev) {
            editItemsCmd(ev);
            p.hide();
          }
        });

    VerticalPanel pnl = new VerticalPanel();
    pnl.add(editSel);
    pnl.add(editField);
    pnl.add(editItems);
    p.add(pnl);
    p.show();
  }
  @Override
  public void show() {
    super.show();
    //		GeneralPanel.setSize(400+Constants.PX, 40+Constants.PX);
    EditorZone.setVisible(false);
    GeneralPanel.setSize(
        PanelActivity.getOffsetWidth() + Constants.PX,
        PanelActivity.getOffsetHeight() + Constants.PX);

    if (ActualState.isLanguageActive()) {
      GeneralPanel.setHeight(Constants.TAMANO_PANEL_EDICION_INT + 40 + Constants.PX);
      EditorZone.setVisible(true);
      closeEditPanel();
    }
  }
예제 #14
0
 /** Refreshing satus */
 public void refresh() {
   if (flag_getChilds) {
     int left =
         ((Main.get().findFolderSelectPopup.getOffsetWidth() - 200) / 2)
             + Main.get().findFolderSelectPopup.getAbsoluteLeft();
     int top =
         ((Main.get().findFolderSelectPopup.getOffsetHeight() - 40) / 2)
             + Main.get().findFolderSelectPopup.getAbsoluteTop();
     setPopupPosition(left, top);
     Main.get().findFolderSelectPopup.scrollFolderPanel.addStyleName("okm-PanelRefreshing");
     super.show();
   } else {
     super.hide();
     Main.get().findFolderSelectPopup.scrollFolderPanel.removeStyleName("okm-PanelRefreshing");
   }
 }
  private void showSelectRefreshIntervalPopup(
      final int left, final int top, final Button refreshIntervalSelector) {
    VerticalPanel popupContent = new VerticalPanel();

    // int configuredSeconds = presenter.getAutoRefreshSeconds();
    int configuredSeconds = view.getRefreshValue();
    if (configuredSeconds > 0) {
      updateRefreshInterval(true, configuredSeconds);
    } else {
      updateRefreshInterval(false, 0);
    }

    RadioButton oneMinuteRadioButton =
        createTimeSelectorRadioButton(
            60, "1 Minute", configuredSeconds, refreshIntervalSelector, popupContent);
    RadioButton fiveMinuteRadioButton =
        createTimeSelectorRadioButton(
            300, "5 Minutes", configuredSeconds, refreshIntervalSelector, popupContent);
    RadioButton tenMinuteRadioButton =
        createTimeSelectorRadioButton(
            600, "10 Minutes", configuredSeconds, refreshIntervalSelector, popupContent);

    popupContent.add(oneMinuteRadioButton);
    popupContent.add(fiveMinuteRadioButton);
    popupContent.add(tenMinuteRadioButton);

    Button resetButton = new Button("Disable Autorefresh");
    resetButton.setSize(ButtonSize.MINI);
    resetButton.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            updateRefreshInterval(false, 0);
            view.saveRefreshValue(0);
            refreshIntervalSelector.setActive(false);
            popup.hide();
          }
        });

    popupContent.add(resetButton);

    popup.setWidget(popupContent);
    popup.show();
    int finalLeft = left - popup.getOffsetWidth();
    popup.setPopupPosition(finalLeft, top);
  }
 // @UiHandler({"edit_selection"})
 public void editSelectionCmd(ClickEvent ev) {
   // DialogBox dialogBox = createDialogBox("Редактирование выбора...");
   // dialogBox.setGlassEnabled(true);
   // dialogBox.setAnimationEnabled(true);
   PopupPanel p = new PopupPanel(true);
   p.setModal(false);
   // p.setPopupPosition(200, 200);
   p.setAnimationEnabled(true);
   // p.setTitle("Редактирование выбора...");
   // dialogBox.setModal(true);
   // dialogBox.center();
   p.setSize("100%", "100%");
   p.setWidget(new MultiselectionEditor(this, p));
   p.setVisible(true);
   p.show();
   p.center();
 }
예제 #17
0
  private void openPanel() {

    int winWidth = popupWidth != -1 ? popupWidth : header.getOffsetWidth() * 2;
    int winHeight = (int) (winWidth / GOLDEN_RATIO);

    popup.setWidth(winWidth + "px");
    popup.setHeight(winHeight + "px");

    // right to left
    if (isRightToLeft) {
      int popupLeft = header.getAbsoluteLeft() - (winWidth - header.getOffsetWidth());
      popup.setPopupPosition(popupLeft - 15, header.getAbsoluteTop() + 21);
    } else {
      int popupLeft = header.getAbsoluteLeft();
      popup.setPopupPosition(popupLeft, header.getAbsoluteTop() + 21);
    }

    popup.show();
  }
예제 #18
0
  /**
   * Opens an HTML popup info window at the given screen coordinates (within the plot bounds)
   *
   * <p>It sets the same font family, size, color and bgcolor defined for markers, if you wanted
   * override them use the css selector div.chrono-infoWindow-content.
   *
   * <p>FIXME: (MCM) this should be a unique instance of popup: ask Shawn
   */
  public InfoWindow createInfoWindow(String html, double x, double y) {
    final PopupPanel pp = new DecoratedPopupPanel(true);
    pp.addStyleName("chrono-infoWindow");
    Widget content = new HTML(html);
    content.setStyleName("chrono-infoWindow-content");
    pp.setWidget(content);
    pp.setPopupPosition(
        getElement().getAbsoluteLeft() + (int) x, getElement().getAbsoluteTop() + (int) y);

    GssProperties markerProperties = gssContext.getPropertiesBySelector("marker");
    if (markerProperties != null) {
      pp.getElement().getStyle().setBackgroundColor(markerProperties.bgColor.toString());
      pp.getElement().getStyle().setColor(markerProperties.color.toString());
      pp.getElement().getStyle().setProperty("fontFamily", markerProperties.fontFamily.toString());
      pp.getElement().getStyle().setProperty("fontSize", markerProperties.fontSize.toString());
      pp.getElement().getStyle().setPadding(5, Unit.PX);
    }
    pp.getElement().getStyle().setZIndex(9999);
    pp.show();

    return new BrowserInfoWindow(this, pp);
  }
예제 #19
0
 public static String getPathFoto() {
   init();
   popup.show();
   return fileUpload.getFilename();
 }
예제 #20
0
  /** Main class */
  public void onModuleLoad() {

    // basic settings
    session.setUiElements(new UiElements(null));

    // Get web page's BODY
    RootLayoutPanel body = RootLayoutPanel.get();

    // check RPC url
    if (session.getRpcUrl().isEmpty()) {
      VerticalPanel bodyContents = new VerticalPanel();
      bodyContents.setSize("100%", "300px");
      bodyContents.add(
          new HTML(new Image(LargeIcons.INSTANCE.errorIcon()) + "<h2>RPC SERVER NOT FOUND!</h2>"));
      bodyContents.setCellHorizontalAlignment(
          bodyContents.getWidget(0), HasHorizontalAlignment.ALIGN_CENTER);
      bodyContents.setCellVerticalAlignment(
          bodyContents.getWidget(0), HasVerticalAlignment.ALIGN_BOTTOM);
      body.add(bodyContents);
      return;
    }

    // WEB PAGE SPLITTER
    body.add(bodySplitter);

    // left menu
    leftMenu = new ApplicationFormLeftMenu();

    // show loading box
    loadingBox = session.getUiElements().perunLoadingBox();
    loadingBox.show();

    // switch menu event
    JsonCallbackEvents events =
        new JsonCallbackEvents() {
          @Override
          public void onFinished(JavaScriptObject jso) {

            bodySplitter.clear();
            bodySplitter.addSouth(getFooter(), 23);
            ArrayList<Application> apps = JsonUtils.jsoAsList(jso);
            if (apps != null && !apps.isEmpty()) {
              // show menu
              bodySplitter.addWest(leftMenu, 280);
            }
            // else don't show menu
            // MAIN CONTENT
            contentPanel.setSize("100%", "100%");
            contentPanel.add(leftMenu.getContent());
            bodySplitter.add(contentPanel);

            // Append more GUI elements from UiElements class which are not part of splitted design
            // WE DON'T WANT TO CONFUSE USER WITH STATUS MESSAGES
            // bodySplitter.getElement().appendChild(session.getUiElements().getStatus().getElement()); // status

            // starts loading
            isUserMemberOfVo();

            // hides the loading box
            loadingBox.hide();
          }

          @Override
          public void onError(PerunError error) {
            // MAIN CONTENT

            bodySplitter.clear();
            bodySplitter.addSouth(getFooter(), 23);
            contentPanel.clear();
            contentPanel.setSize("100%", "100%");
            contentPanel.add(leftMenu.getContent());
            bodySplitter.add(contentPanel);

            // Append more GUI elements from UiElements class which are not part of splitted design
            // bodySplitter.getElement().appendChild(session.getUiElements().getStatus().getElement()); // status

            // starts loading
            isUserMemberOfVo();

            // hides the loading box
            loadingBox.hide();
          }
        };

    // load VO to check if exists
    loadVo(events);
  }
예제 #21
0
  public void showPopupMenu(ContextMenuEvent event) {
    final PopupPanel popupPanel = new PopupPanel(true);
    popupPanel.setAnimationEnabled(true);
    popupPanel.setStyleName("popup");
    MenuBar popupMenuBar = new MenuBar(true);

    MenuItem deleteItem =
        new MenuItem(
            "Delete Selected Items",
            true,
            new Command() {

              @Override
              public void execute() {
                popupPanel.hide();

                m_Container.doConfirm(
                    "Are you sure you wish to delete selected items?",
                    new ConfirmDialogBox.ConfirmCallBack() {

                      public void ok() {
                        JSONArray jsa =
                            Utils.extractIds(m_Container.getDragController().getDragContext());

                        m_Container.doJSONRequest(
                            G3Viewer.DELETE_ALL_URL + "?sourceids=" + jsa.toString(),
                            new HttpSuccessHandler() {
                              public void success(JSONValue aValue) {
                                final List<Widget> widgets =
                                    m_Container.getDragController().getSelectedWidgets();
                                Item i;
                                for (Widget widget : widgets) {
                                  i = (Item) widget;
                                  removeFromView(i);
                                  i.removeLinkedAlbum();
                                }
                              }
                            },
                            true,
                            true);
                      }
                    });
              }
            });
    deleteItem.addStyleName("popup-item");
    popupMenuBar.addItem(deleteItem);

    popupMenuBar.setVisible(true);
    popupPanel.add(popupMenuBar);

    MenuItem rotateAllCW =
        new MenuItem(
            "Rotate All Clockwise",
            true,
            new Command() {
              @Override
              public void execute() {
                // change all thumbs into loading
                final List<Widget> widgets = m_Container.getDragController().getSelectedWidgets();

                for (Widget widget : widgets) {
                  final Item i = ((Item) widget);
                  if (i.isPhoto()) {
                    i.setLoadingThumb();
                  }

                  m_Container.doJSONRequest(
                      G3Viewer.ROTATE_URL + i.getID() + "/cw",
                      new HttpSuccessHandler() {

                        public void success(JSONValue aValue) {
                          i.updateImages(aValue);
                        }
                      },
                      false,
                      true);
                }
                popupPanel.hide();
              }
            });

    rotateAllCW.addStyleName("popup-item");
    popupMenuBar.addItem(rotateAllCW);

    MenuItem rotateAllCCW =
        new MenuItem(
            "Rotate All Counter-Clockwise",
            true,
            new Command() {
              @Override
              public void execute() {
                // change all thumbs into loading
                final List<Widget> widgets = m_Container.getDragController().getSelectedWidgets();

                for (Widget widget : widgets) {
                  final Item i = ((Item) widget);
                  if (i.isPhoto()) {
                    i.setLoadingThumb();
                  }
                  m_Container.doJSONRequest(
                      G3Viewer.ROTATE_URL + i.getID() + "/cw",
                      new HttpSuccessHandler() {

                        public void success(JSONValue aValue) {
                          i.updateImages(aValue);
                        }
                      },
                      false,
                      true);
                }
                popupPanel.hide();
              }
            });

    rotateAllCW.addStyleName("popup-item");
    popupMenuBar.addItem(rotateAllCCW);

    int x = DOM.eventGetClientX((Event) event.getNativeEvent());
    int y = DOM.eventGetClientY((Event) event.getNativeEvent());
    popupPanel.setPopupPosition(x, y);

    popupPanel.show();
  }
예제 #22
0
 public void show() {
   popupPanel.center();
   popupPanel.show();
 }
예제 #23
0
 /** Shows the context menu. */
 public void show() {
   popupPanel.show();
 }
예제 #24
0
 @Override
 public void show() {
   super.show();
   toggleButton(true);
 }
예제 #25
0
  private void deployProject() {
    createdProjectName = deploymentOptionsPanel.getProjectName();

    ArrayList<String> paths = appBrowserPanel.getAppPaths();
    ArrayList<String> apptypes = appBrowserPanel.getAppTypes();
    ArrayList<String> appNames = appBrowserPanel.getAppNames();

    StringBuffer formBuilder = new StringBuffer();
    formBuilder.append("csrfmiddlewaretoken=");
    formBuilder.append(URL.encodeQueryString(jsVarHandler.getCSRFTokenURL()));

    formBuilder.append("&form-TOTAL_FORMS=");
    formBuilder.append(URL.encodeQueryString(String.valueOf(paths.size())));
    formBuilder.append("&form-INITIAL_FORMS=");
    formBuilder.append(URL.encodeQueryString(String.valueOf(0)));
    formBuilder.append("&form-MAX_NUM_FORMS=");

    for (int i = 0; i < paths.size(); i++) {
      formBuilder.append("&form-" + i + "-apptype=");
      formBuilder.append(apptypes.get(i));

      formBuilder.append("&form-" + i + "-apppath=");
      formBuilder.append(paths.get(i));

      formBuilder.append("&form-" + i + "-appname=");
      formBuilder.append(appNames.get(i));
    }

    formBuilder.append(deploymentOptionsPanel.getPostData());
    formBuilder.append(projectOptionsPanel.getPostData());
    formBuilder.append(databaseOptionsPanel.getPostData());

    RequestBuilder builder =
        new RequestBuilder(RequestBuilder.POST, "/deployments/" + createdProjectName + "/");
    builder.setHeader("Content-type", "application/x-www-form-urlencoded");
    // builder.setHeader(header, value);

    try {
      Request request =
          builder.sendRequest(
              formBuilder.toString(),
              new RequestCallback() {
                public void onError(Request request, Throwable exception) {
                  ErrorPanel ep = new ErrorPanel(clientFactory);
                  ep.errorHTML.setHTML("<p>Error Occured</p>");
                  deployerDeckPanel.add(ep);
                  deployerDeckPanel.showWidget(deployerDeckPanel.getWidgetIndex(ep));
                }

                public void onResponseReceived(Request request, Response response) {
                  if (response.getText().contains("Back to")) {
                    loadingPopup.hide();
                    eventBus.fireEvent(new AsyncRequestEvent("addProject", createdProjectName));
                  } else {
                    loadingPopup.hide();
                    ErrorPanel ep = new ErrorPanel(clientFactory);
                    ep.errorHTML.setHTML(response.getText());
                    deployerDeckPanel.add(ep);
                    deployerDeckPanel.showWidget(deployerDeckPanel.getWidgetIndex(ep));
                  }
                }
              });
    } catch (RequestException e) {

    }

    loadingPopup.setGlassEnabled(true);
    loadingPopup.setGlassStyleName(style.loadingGlass());
    loadingPopup.show();
    int left = (Window.getClientWidth() / 2) - 150;
    int top = (Window.getClientHeight() / 2) - 10;
    loadingPopup.setPopupPosition(left, top);
    loadingPopup.show();
  }
예제 #26
0
 public void show() {
   popup.show();
 }
예제 #27
0
  public void showPopupMenu(Event event) {
    m_Label.addStyleName("popped");
    final PopupPanel popupPanel = new PopupPanel(true);
    popupPanel.setAnimationEnabled(true);
    MenuBar popupMenuBar = new MenuBar(true);

    MenuItem editItem =
        new MenuItem(
            "Edit Album",
            true,
            new Command() {

              @Override
              public void execute() {
                m_Container.doDialog(
                    "index.php/form/edit/albums/" + m_ID,
                    new HttpDialogHandler() {
                      @Override
                      public void success(String aResult) {
                        refresh();
                      }
                    });
                popupPanel.hide();
              }
            });

    MenuItem addAlbum =
        new MenuItem(
            "Add Album",
            true,
            new Command() {

              @Override
              public void execute() {
                m_Container.doDialog(
                    "index.php/form/add/albums/" + m_ID + "?type=album",
                    new HttpDialogHandler() {
                      @Override
                      public void success(String aResult) {
                        expand();
                        m_View.getCurrentAlbum().select();
                      }
                    });

                popupPanel.hide();
              }
            });

    MenuItem userPermissions =
        new MenuItem(
            "User Permissions",
            true,
            new Command() {
              @Override
              public void execute() {
                m_Container.doDialog(
                    "index.php/permissions/browse/" + m_ID,
                    new HttpDialogHandler() {
                      @Override
                      public void success(String aResult) {}
                    });

                popupPanel.hide();
              }
            });

    popupPanel.setStyleName("popup");
    editItem.addStyleName("popup-item");
    addAlbum.addStyleName("popup-item");
    userPermissions.addStyleName("popup-item");

    if (m_Container.isUploadEnabled()) {
      MenuItem uploadPhotos =
          new MenuItem(
              "Upload Photos",
              true,
              new Command() {

                @Override
                public void execute() {
                  uploadFiles();
                  popupPanel.hide();
                }
              });
      uploadPhotos.addStyleName("popup-item");
      popupMenuBar.addItem(uploadPhotos);
    }

    popupMenuBar.addItem(editItem);
    popupMenuBar.addItem(addAlbum);
    popupMenuBar.addItem(userPermissions);

    popupMenuBar.setVisible(true);
    popupPanel.add(popupMenuBar);

    int x = DOM.eventGetClientX(event);
    int y = DOM.eventGetClientY(event);
    popupPanel.setPopupPosition(x, y);
    popupPanel.addCloseHandler(
        new CloseHandler<PopupPanel>() {

          @Override
          public void onClose(CloseEvent<PopupPanel> event) {

            m_Label.removeStyleName("popped");
          }
        });

    popupPanel.show();
  }
예제 #28
0
 public void onBrowserEvent(Event event) {
   // the id's which are set on these menu items must be set AFTER the items are added to their
   // menu
   // when an element is added to a menu an auto-generated id will be assigned, so we must override
   // this
   if (perspective != null) {
     if ((DOM.eventGetType(event) & Event.ONDBLCLICK) == Event.ONDBLCLICK) {
       openTabInNewWindow();
     } else if (DOM.eventGetButton(event) == Event.BUTTON_RIGHT) {
       int left = Window.getScrollLeft() + DOM.eventGetClientX(event);
       int top = Window.getScrollTop() + DOM.eventGetClientY(event);
       popupMenu.setPopupPosition(left, top);
       MenuBar menuBar = new MenuBar(true);
       menuBar.setAutoOpen(true);
       if (tabContent instanceof IFrameTabPanel) {
         MenuItem backMenuItem =
             new MenuItem(
                 Messages.getString("back"),
                 new TabCommand(TABCOMMANDTYPE.BACK, popupMenu)); // $NON-NLS-1$
         menuBar.addItem(backMenuItem);
         backMenuItem.getElement().setId("back"); // $NON-NLS-1$
         menuBar.addSeparator();
         MenuItem reloadTabMenuItem =
             new MenuItem(
                 Messages.getString("reloadTab"),
                 new TabCommand(TABCOMMANDTYPE.RELOAD, popupMenu)); // $NON-NLS-1$
         menuBar.addItem(reloadTabMenuItem);
         reloadTabMenuItem.getElement().setId("reloadTab"); // $NON-NLS-1$
       }
       if (tabPanel.getTabBar().getTabCount() > 1) {
         MenuItem reloadAllTabsMenuItem =
             new MenuItem(
                 Messages.getString("reloadAllTabs"),
                 new TabCommand(TABCOMMANDTYPE.RELOAD_ALL, popupMenu)); // $NON-NLS-1$
         menuBar.addItem(reloadAllTabsMenuItem);
         reloadAllTabsMenuItem.getElement().setId("reloadAllTabs"); // $NON-NLS-1$
       } else {
         MenuItem reloadAllTabsMenuItem =
             new MenuItem(Messages.getString("reloadAllTabs"), (Command) null); // $NON-NLS-1$
         menuBar.addItem(reloadAllTabsMenuItem);
         reloadAllTabsMenuItem.getElement().setId("reloadAllTabs"); // $NON-NLS-1$
         reloadAllTabsMenuItem.setStyleName("disabledMenuItem"); // $NON-NLS-1$
       }
       menuBar.addSeparator();
       if (tabContent instanceof IFrameTabPanel) {
         MenuItem openTabInNewWindowMenuItem =
             new MenuItem(
                 Messages.getString("openTabInNewWindow"),
                 new TabCommand(TABCOMMANDTYPE.NEW_WINDOW, popupMenu)); // $NON-NLS-1$
         menuBar.addItem(openTabInNewWindowMenuItem);
         openTabInNewWindowMenuItem.getElement().setId("openTabInNewWindow"); // $NON-NLS-1$
         MenuItem createDeepLinkMenuItem =
             new MenuItem(
                 Messages.getString("createDeepLink"),
                 new TabCommand(TABCOMMANDTYPE.CREATE_DEEP_LINK, popupMenu)); // $NON-NLS-1$
         menuBar.addItem(createDeepLinkMenuItem);
         createDeepLinkMenuItem.getElement().setId("deepLink"); // $NON-NLS-1$
         menuBar.addSeparator();
       }
       menuBar.addItem(
           new MenuItem(
               Messages.getString("closeTab"),
               new TabCommand(TABCOMMANDTYPE.CLOSE, popupMenu))); // $NON-NLS-1$
       if (tabPanel.getTabBar().getTabCount() > 1) {
         MenuItem closeOtherTabsMenuItem =
             new MenuItem(
                 Messages.getString("closeOtherTabs"),
                 new TabCommand(TABCOMMANDTYPE.CLOSE_OTHERS, popupMenu)); // $NON-NLS-1$
         menuBar.addItem(closeOtherTabsMenuItem);
         closeOtherTabsMenuItem.getElement().setId("closeOtherTabs"); // $NON-NLS-1$
         MenuItem closeAllTabsMenuItem =
             new MenuItem(
                 Messages.getString("closeAllTabs"),
                 new TabCommand(TABCOMMANDTYPE.CLOSE_ALL, popupMenu)); // $NON-NLS-1$
         menuBar.addItem(closeAllTabsMenuItem);
         closeAllTabsMenuItem.getElement().setId("closeAllTabs"); // $NON-NLS-1$
       } else {
         MenuItem closeOtherTabsMenuItem =
             new MenuItem(Messages.getString("closeOtherTabs"), (Command) null); // $NON-NLS-1$
         closeOtherTabsMenuItem.setStyleName("disabledMenuItem"); // $NON-NLS-1$
         MenuItem closeAllTabsMenuItem =
             new MenuItem(Messages.getString("closeAllTabs"), (Command) null); // $NON-NLS-1$
         closeAllTabsMenuItem.setStyleName("disabledMenuItem"); // $NON-NLS-1$
         menuBar.addItem(closeOtherTabsMenuItem);
         menuBar.addItem(closeAllTabsMenuItem);
         closeOtherTabsMenuItem.getElement().setId("closeOtherTabs"); // $NON-NLS-1$
         closeAllTabsMenuItem.getElement().setId("closeAllTabs"); // $NON-NLS-1$
       }
       popupMenu.setWidget(menuBar);
       popupMenu.hide();
       popupMenu.show();
     }
   }
   super.onBrowserEvent(event);
 }
예제 #29
0
파일: MenuBar.java 프로젝트: ZOKOISC/vaadin
  /*
   * Performs the action associated with the given menu item. If the item has
   * a popup associated with it, the popup will be shown. If it has a command
   * associated with it, and 'fireCommand' is true, then the command will be
   * fired. Popups associated with other items will be hidden.
   *
   * @param item the item whose popup is to be shown. @param fireCommand
   * <code>true</code> if the item's command should be fired,
   * <code>false</code> otherwise.
   */
  protected void doItemAction(final MenuItem item, boolean fireCommand) {
    // If the given item is already showing its menu, we're done.
    if ((shownChildMenu != null) && (item.getSubMenu() == shownChildMenu)) {
      return;
    }

    // If another item is showing its menu, then hide it.
    if (shownChildMenu != null) {
      shownChildMenu.onHide();
      popup.hide();
    }

    // If the item has no popup, optionally fire its command.
    if (item.getSubMenu() == null) {
      if (fireCommand) {
        // Close this menu and all of its parents.
        closeAllParents();

        // Fire the item's command.
        final Command cmd = item.getCommand();
        if (cmd != null) {
          Scheduler.get().scheduleDeferred(cmd);
        }
      }
      return;
    }

    // Ensure that the item is selected.
    selectItem(item);

    // Create a new popup for this item, and position it next to
    // the item (below if this is a horizontal menu bar, to the
    // right if it's a vertical bar).
    popup =
        new VOverlay(true) {
          {
            setWidget(item.getSubMenu());
            item.getSubMenu().onShow();
            setOwner(MenuBar.this);
          }

          @Override
          public boolean onEventPreview(Event event) {
            // Hook the popup panel's event preview. We use this to keep it
            // from
            // auto-hiding when the parent menu is clicked.
            switch (DOM.eventGetType(event)) {
              case Event.ONCLICK:
                // If the event target is part of the parent menu, suppress
                // the
                // event altogether.
                final Element target = DOM.eventGetTarget(event);
                final Element parentMenuElement = item.getParentMenu().getElement();
                if (DOM.isOrHasChild(parentMenuElement, target)) {
                  return false;
                }
                break;
            }

            return super.onEventPreview(event);
          }
        };
    popup.addPopupListener(this);

    if (vertical) {
      popup.setPopupPosition(item.getAbsoluteLeft() + item.getOffsetWidth(), item.getAbsoluteTop());
    } else {
      popup.setPopupPosition(
          item.getAbsoluteLeft(), item.getAbsoluteTop() + item.getOffsetHeight());
    }

    shownChildMenu = item.getSubMenu();
    item.getSubMenu().parentMenu = this;

    // Show the popup, ensuring that the menubar's event preview remains on
    // top
    // of the popup's.
    popup.show();
  }