Search in sources :

Example 6 with PopupPanel

use of com.google.gwt.user.client.ui.PopupPanel in project gerrit by GerritCodeReview.

the class CreateChangeAction method call.

static void call(final Button b, final String project) {
    // TODO Replace CreateChangeDialog with a nicer looking display.
    b.setEnabled(false);
    new CreateChangeDialog(new Project.NameKey(project)) {

        {
            sendButton.setText(AdminConstants.I.buttonCreate());
            message.setText(AdminConstants.I.buttonCreateDescription());
        }

        @Override
        public void onSend() {
            ChangeApi.createChange(project, getDestinationBranch(), getDestinationTopic(), message.getText(), null, new GerritCallback<ChangeInfo>() {

                @Override
                public void onSuccess(ChangeInfo result) {
                    sent = true;
                    hide();
                    Gerrit.display(PageLinks.toChange(result.legacyId()));
                }

                @Override
                public void onFailure(Throwable caught) {
                    enableButtons(true);
                    super.onFailure(caught);
                }
            });
        }

        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
            super.onClose(event);
            b.setEnabled(true);
        }
    }.center();
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) ChangeInfo(com.google.gerrit.client.info.ChangeInfo) CreateChangeDialog(com.google.gerrit.client.ui.CreateChangeDialog) PopupPanel(com.google.gwt.user.client.ui.PopupPanel)

Example 7 with PopupPanel

use of com.google.gwt.user.client.ui.PopupPanel in project rstudio by rstudio.

the class PresentationPane method zoom.

@Override
public void zoom(String title, String url, final Command onClosed) {
    // create the titlebar (no title for now)
    HorizontalPanel titlePanel = new HorizontalPanel();
    ThemeStyles styles = ThemeResources.INSTANCE.themeStyles();
    Label titleLabel = new Label(title);
    titleLabel.addStyleName(styles.fullscreenCaptionLabel());
    titlePanel.add(titleLabel);
    // create the frame
    AnchorableFrame frame = new PresentationFrame(true);
    frame.setSize("100%", "100%");
    // create the popup panel & add close handler 
    activeZoomPanel_ = new FullscreenPopupPanel(titlePanel, frame, false);
    activeZoomPanel_.addCloseHandler(new CloseHandler<PopupPanel>() {

        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
            activeZoomPanel_ = null;
            onClosed.execute();
        }
    });
    // load the frame and show the zoom panel
    frame.navigate(url);
    activeZoomPanel_.center();
}
Also used : FullscreenPopupPanel(org.rstudio.core.client.widget.FullscreenPopupPanel) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) ThemeStyles(org.rstudio.core.client.theme.res.ThemeStyles) Label(com.google.gwt.user.client.ui.Label) PopupPanel(com.google.gwt.user.client.ui.PopupPanel) FullscreenPopupPanel(org.rstudio.core.client.widget.FullscreenPopupPanel) AnchorableFrame(org.rstudio.core.client.widget.AnchorableFrame)

Example 8 with PopupPanel

use of com.google.gwt.user.client.ui.PopupPanel in project pentaho-platform by pentaho.

the class NewDropdownCommand method performOperation.

protected void performOperation(boolean feedback) {
    final PopupPanel popup = new PopupPanel(true, false) {

        public void show() {
            // show glass pane
            super.show();
            if (pageBackground == null) {
                pageBackground = new FocusPanel() {

                    public void onBrowserEvent(Event event) {
                        int type = event.getTypeInt();
                        switch(type) {
                            case Event.ONKEYDOWN:
                                {
                                    if ((char) event.getKeyCode() == KeyCodes.KEY_ESCAPE) {
                                        event.stopPropagation();
                                        hide();
                                    }
                                    return;
                                }
                        }
                        super.onBrowserEvent(event);
                    }
                };
                pageBackground.addClickHandler(new ClickHandler() {

                    public void onClick(ClickEvent event) {
                        hide();
                        pageBackground.setVisible(false);
                        pageBackground.getElement().getStyle().setDisplay(Display.NONE);
                    }
                });
                RootPanel.get().add(pageBackground, 0, 0);
            }
            // $NON-NLS-1$ //$NON-NLS-2$
            pageBackground.setSize("100%", Window.getClientHeight() + Window.getScrollTop() + "px");
            pageBackground.setVisible(true);
            pageBackground.getElement().getStyle().setDisplay(Display.BLOCK);
            // hide <embeds>
            // TODO: migrate to GlassPane Listener
            FrameUtils.toggleEmbedVisibility(false);
            // Notify listeners that we're showing a dialog (hide PDFs, flash).
            GlassPane.getInstance().show();
        }

        public void hide(boolean autoClosed) {
            super.hide(autoClosed);
            pageBackground.setVisible(false);
            GlassPane.getInstance().hide();
        }

        protected void onPreviewNativeEvent(final NativePreviewEvent event) {
            // Switch on the event type
            int type = event.getTypeInt();
            switch(type) {
                case Event.ONKEYDOWN:
                    {
                        Event nativeEvent = Event.as(event.getNativeEvent());
                        if ((char) nativeEvent.getKeyCode() == KeyCodes.KEY_ESCAPE) {
                            event.cancel();
                            hide();
                        }
                        return;
                    }
            }
        }
    };
    if (popup.isShowing()) {
        popup.hide();
        return;
    }
    // $NON-NLS-1$
    String url = GWT.getHostPageBaseURL() + "api/plugin-manager/settings/new-toolbar-button";
    RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url);
    // $NON-NLS-1$//$NON-NLS-2$
    rb.setHeader("Content-Type", "text/plain");
    // $NON-NLS-1$//$NON-NLS-2$
    rb.setHeader("accept", "application/json");
    rb.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    try {
        rb.sendRequest(null, new RequestCallback() {

            @Override
            public void onError(Request request, Throwable exception) {
                MessageDialogBox dialogBox = new // $NON-NLS-1$ //$NON-NLS-2$
                MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
                Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$
                exception.getMessage(), false, false, true);
                dialogBox.center();
            }

            @Override
            public void onResponseReceived(Request request, Response response) {
                if (response.getStatusCode() == 200) {
                    JsArray<JsCreateNewConfig> jsarray = parseJson(JsonUtils.escapeJsonForEval(response.getText()));
                    final ArrayList<JsCreateNewConfig> sorted = new ArrayList<JsCreateNewConfig>();
                    for (int i = 0; i < jsarray.length(); i++) {
                        sorted.add(jsarray.get(i));
                    }
                    Collections.sort(sorted, new JsCreateNewConfigComparator());
                    popup.setStyleName("newToolbarDropdown");
                    VerticalPanel buttonPanel = new VerticalPanel();
                    popup.add(buttonPanel);
                    for (int i = 0; i < sorted.size(); i++) {
                        final int finali = i;
                        String enabledUrl = sorted.get(i).getEnabledUrl();
                        if (buttonEnabled(enabledUrl)) {
                            Button button = new Button(Messages.getString(sorted.get(i).getLabel()));
                            button.setStyleName("pentaho-button");
                            button.getElement().addClassName("newToolbarDropdownButton");
                            button.addClickHandler(new ClickHandler() {

                                public void onClick(ClickEvent event) {
                                    if (sorted.get(finali).getActionUrl().startsWith("javascript:")) {
                                        doEvalJS(sorted.get(finali).getActionUrl().substring("javascript:".length()));
                                    } else {
                                        SolutionBrowserPanel.getInstance().getContentTabPanel().showNewURLTab(Messages.getString(sorted.get(finali).getTabName()), Messages.getString(sorted.get(finali).getTabName()), sorted.get(finali).getActionUrl(), false);
                                    }
                                    popup.hide();
                                }
                            });
                            String name = sorted.get(i).getName();
                            if ("data-access".equals(name)) {
                                buttonPanel.add(new HTML("<hr style='color: #a7a7a7' />"));
                            }
                            buttonPanel.add(button);
                        }
                    }
                    popup.setPopupPosition(anchorWidget.getAbsoluteLeft(), anchorWidget.getAbsoluteTop() + anchorWidget.getOffsetHeight());
                    popup.show();
                } else {
                    MessageDialogBox dialogBox = new // $NON-NLS-1$ //$NON-NLS-2$
                    MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
                    Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$
                    Messages.getString("error"), false, false, true);
                    dialogBox.center();
                }
            }

            private boolean buttonEnabled(String enabledUrl) {
                if (enabledUrl == null || enabledUrl.isEmpty()) {
                    return true;
                } else {
                    Boolean enabled = false;
                    try {
                        enabled = Boolean.valueOf(sendRequest(enabledUrl));
                    } catch (Exception e) {
                    }
                    return enabled;
                }
            }
        });
    } catch (RequestException e) {
        MessageDialogBox dialogBox = new // $NON-NLS-1$ //$NON-NLS-2$
        MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
        Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$
        e.getMessage(), false, false, true);
        dialogBox.center();
    }
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) PopupPanel(com.google.gwt.user.client.ui.PopupPanel) ArrayList(java.util.ArrayList) HTML(com.google.gwt.user.client.ui.HTML) FocusPanel(com.google.gwt.user.client.ui.FocusPanel) RequestException(com.google.gwt.http.client.RequestException) Button(com.google.gwt.user.client.ui.Button) JsCreateNewConfigComparator(org.pentaho.mantle.client.objects.JsCreateNewConfigComparator) JsArray(com.google.gwt.core.client.JsArray) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) Request(com.google.gwt.http.client.Request) RequestException(com.google.gwt.http.client.RequestException) Response(com.google.gwt.http.client.Response) NativePreviewEvent(com.google.gwt.user.client.Event.NativePreviewEvent) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) RequestCallback(com.google.gwt.http.client.RequestCallback) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Event(com.google.gwt.user.client.Event) NativePreviewEvent(com.google.gwt.user.client.Event.NativePreviewEvent) JsCreateNewConfig(org.pentaho.mantle.client.objects.JsCreateNewConfig)

Example 9 with PopupPanel

use of com.google.gwt.user.client.ui.PopupPanel in project webprotege by protegeproject.

the class AboutBox method show.

public void show() {
    final PopupPanel popupPanel = new PopupPanel();
    popupPanel.setAutoHideEnabled(true);
    popupPanel.setGlassEnabled(true);
    popupPanel.setVisible(false);
    popupPanel.setGlassStyleName("glass");
    popupPanel.setWidget(new AboutBoxContent());
    popupPanel.show();
    popupPanel.addStyleName("glass-popup-shadow");
    Scheduler.get().scheduleDeferred(() -> {
        int left = (Window.getClientWidth() - popupPanel.getOffsetWidth()) / 2;
        int top = (Window.getClientHeight() - popupPanel.getOffsetHeight()) / 2;
        popupPanel.setPopupPosition(left, top);
        popupPanel.setVisible(true);
    });
}
Also used : PopupPanel(com.google.gwt.user.client.ui.PopupPanel)

Example 10 with PopupPanel

use of com.google.gwt.user.client.ui.PopupPanel in project gwt-test-utils by gwt-test-utils.

the class PopupPanelTest method autoHideEnabled.

@Test
public void autoHideEnabled() {
    // Given
    PopupPanel popupPanel = new PopupPanel(true);
    // Preconditions
    assertThat(popupPanel.isAutoHideEnabled()).isTrue();
    // When
    popupPanel.setAutoHideEnabled(false);
    // Then
    assertThat(popupPanel.isAutoHideEnabled()).isFalse();
}
Also used : PopupPanel(com.google.gwt.user.client.ui.PopupPanel) Test(org.junit.Test)

Aggregations

PopupPanel (com.google.gwt.user.client.ui.PopupPanel)28 Test (org.junit.Test)5 ChangeInfo (com.google.gerrit.client.info.ChangeInfo)4 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)4 PositionCallback (com.google.gwt.user.client.ui.PopupPanel.PositionCallback)4 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 Button (com.google.gwt.user.client.ui.Button)2 CherryPickDialog (com.google.gerrit.client.ui.CherryPickDialog)1 CreateChangeDialog (com.google.gerrit.client.ui.CreateChangeDialog)1 RebaseDialog (com.google.gerrit.client.ui.RebaseDialog)1 TextAreaActionDialog (com.google.gerrit.client.ui.TextAreaActionDialog)1 JsArray (com.google.gwt.core.client.JsArray)1 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 Style (com.google.gwt.dom.client.Style)1 FocusEvent (com.google.gwt.event.dom.client.FocusEvent)1 ResizeEvent (com.google.gwt.event.logical.shared.ResizeEvent)1 ResizeHandler (com.google.gwt.event.logical.shared.ResizeHandler)1 HandlerRegistration (com.google.gwt.event.shared.HandlerRegistration)1 Request (com.google.gwt.http.client.Request)1