Example usage for com.google.gwt.user.client.ui Button Button

List of usage examples for com.google.gwt.user.client.ui Button Button

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Button Button.

Prototype

public Button(String html, ClickHandler handler) 

Source Link

Document

Creates a button with the given HTML caption and click listener.

Usage

From source file:com.dimdim.conference.ui.common.client.util.CommonModalDialog.java

License:Open Source License

public void drawDialog() {
    this.defaultCloseListener = new ClickListener() {
        public void onClick(Widget sender) {
            hide();/*  w ww  .  java 2s  .co m*/
        }
    };
    closeButton = new Button(closeButtonText, this.defaultCloseListener);

    //      DomUtil.setId(this, "dialog-styled");
    vp = new VerticalPanel();
    //      setWidget(rp);

    vp.setStyleName("common-dialog-outer-panel");

    //       Window.alert("1");

    if (this.closeListener != null) {
        this.closeButton.addClickListener(this.closeListener);
    }
    closeButton.setStyleName("dm-popup-close-button");
    buttonPanel.add(closeButton, DockPanel.EAST);
    buttonPanel.setSpacing(0);
    HTML filler1 = new HTML(" ");
    buttonPanel.add(filler1, DockPanel.EAST);

    //       Window.alert("2");

    footerButtons = this.getFooterButtons();
    if (footerButtons != null) {
        int size = footerButtons.size();
        for (int i = 0; i < size; i++) {
            Button button = (Button) footerButtons.elementAt(i);
            buttonPanel.add(button, DockPanel.EAST);
            HTML filler2 = new HTML("&nbsp;");
            buttonPanel.add(filler2, DockPanel.EAST);
        }
    }

    //       Window.alert("3");

    this.messageLabel.setStyleName("common-text");
    this.messageLabel.addStyleName("dialog-message-label");
    buttonPanel.add(this.messageLabel, DockPanel.WEST);
    buttonPanel.setCellVerticalAlignment(this.messageLabel, VerticalPanel.ALIGN_MIDDLE);
    buttonPanel.setCellWidth(this.messageLabel, "100%");

    Widget c = getContent();

    if (this.dialogName != null) {
        //          Window.alert("4");

        //   Create a width adjustment panel.
        String widthStyle = this.dialogName + "-dialog-width";
        String heightStyle1 = this.dialogName + "-dialog-height-one";
        String heightStyle2 = this.dialogName + "-dialog-height-two";
        String contentWidthStyle = this.dialogName + "-dialog-content";

        c.addStyleName(contentWidthStyle);
        upperPanel = new HorizontalPanel();

        HTML upperLeftBar = new HTML("&nbsp;");
        upperLeftBar.setStyleName(heightStyle1);
        upperPanel.add(upperLeftBar);
        upperPanel.add(c);
        upperPanel.setCellWidth(c, "100%");
        upperPanel.setCellVerticalAlignment(c, VerticalPanel.ALIGN_MIDDLE);

        HorizontalPanel lowerPanel = new HorizontalPanel();
        lowerPanel.setStyleName(widthStyle);

        HTML lowerLeftBar = new HTML("&nbsp;");
        lowerLeftBar.setStyleName(heightStyle2);
        lowerPanel.add(lowerLeftBar);
        lowerPanel.add(buttonPanel);
        lowerPanel.setCellWidth(buttonPanel, "100%");
        lowerPanel.setCellHorizontalAlignment(buttonPanel, HorizontalPanel.ALIGN_RIGHT);
        lowerPanel.setCellVerticalAlignment(buttonPanel, VerticalPanel.ALIGN_MIDDLE);

        //          Window.alert("5");
        vp.add(upperPanel);
        vp.add(lowerPanel);
    } else {
        //          Window.alert("6");

        vp.add(c);
        vp.setCellWidth(c, "100%");

        vp.add(buttonPanel);
        vp.setCellWidth(buttonPanel, "100%");
        vp.setCellHorizontalAlignment(buttonPanel, HorizontalPanel.ALIGN_RIGHT);
        //          Window.alert("7");

    }
    //      RoundedPanel rp = new RoundedPanel(vp);
    //      rp.setStyleName("common-dialog-rounded-corner-panel");

    //      Window.alert("8");

    scrollPanel.add(vp);

    add(scrollPanel);

    /*
    FocusWidget fw = getFocusWidget();
    if (fw != null)
    {
       this.getFocusModel().add(fw);
    }
    else
    {
       Window.alert("No focus widget provided");
    }
    */
    this.setFocusModel(new FocusModel() {
        public HasFocus getFocusWidget() {
            return getDmFocusModel();
        }
    });

    DmGlassPanel dgp = new DmGlassPanel(this);
    dgp.show();
    //      show();
}

From source file:com.dimdim.conference.ui.envcheck.client.layout.CommonMessagePopup.java

License:Open Source License

protected void drawDialog() {
    vp = new VerticalPanel();
    RoundedPanel rp = new RoundedPanel(vp);

    vp.setStyleName("common-dialog-outer-panel");
    rp.setStyleName("common-dialog-rounded-corner-panel");

    DockPanel buttonPanel = new DockPanel();
    if (this.showCloseButton) {
        closeButton = new Button(closeButtonText, new ClickListener() {
            public void onClick(Widget sender) {
                hide();//from  w  w w . ja v  a2 s.  com
                History.back(); //   TODO move out into a listener.
            }
        });
        closeButton.setStyleName("dm-popup-close-button");
        buttonPanel.add(closeButton, DockPanel.EAST);
        buttonPanel.setSpacing(0);
        HTML filler1 = new HTML("&nbsp;");
        buttonPanel.add(filler1, DockPanel.EAST);
    }
    if (this.dialogName != null) {
        //   Create a width adjustment panel.
        String widthStyle = this.dialogName + "-dialog-width";
        String heightStyle1 = this.dialogName + "-dialog-height-one";
        String heightStyle2 = this.dialogName + "-dialog-height-two";
        String contentWidthStyle = this.dialogName + "-dialog-content";

        content.addStyleName(contentWidthStyle);
        HorizontalPanel upperPanel = new HorizontalPanel();

        HTML upperLeftBar = new HTML("&nbsp;");
        upperLeftBar.setStyleName(heightStyle1);
        upperPanel.add(upperLeftBar);
        upperPanel.add(content);
        upperPanel.setCellWidth(content, "100%");
        upperPanel.setCellVerticalAlignment(content, VerticalPanel.ALIGN_MIDDLE);

        HorizontalPanel lowerPanel = new HorizontalPanel();
        lowerPanel.setStyleName(widthStyle);

        HTML lowerLeftBar = new HTML("&nbsp;");
        lowerLeftBar.setStyleName(heightStyle2);
        lowerPanel.add(lowerLeftBar);
        lowerPanel.add(buttonPanel);
        lowerPanel.setCellWidth(buttonPanel, "100%");
        lowerPanel.setCellHorizontalAlignment(buttonPanel, HorizontalPanel.ALIGN_RIGHT);
        lowerPanel.setCellVerticalAlignment(buttonPanel, VerticalPanel.ALIGN_MIDDLE);

        vp.add(upperPanel);
        vp.add(lowerPanel);
        this.addStyleName(this.dialogName + "-dialog-size");
    } else {
        vp.add(content);
        vp.setCellWidth(content, "100%");

        vp.add(buttonPanel);
        vp.setCellWidth(buttonPanel, "100%");
        vp.setCellHorizontalAlignment(buttonPanel, HorizontalPanel.ALIGN_RIGHT);
    }
    this.addPopupListener(this);

    this.add(vp);
}

From source file:com.dingziran.effective.client.content.widgets.CwBasicButton.java

License:Apache License

/**
 * Constructor.//  ww w . j a v a  2s .co m
 *
 * @param constants the constants
 */
public CwBasicButton(CwConstants constants) {
    super(constants.cwBasicButtonName(), constants.cwBasicButtonDescription());
    this.constants = constants;
    view = new ContentWidgetView(hasMargins(), hasScrollableContent());
    view.setName(getName());
    view.setDescription(getDescription());
    setWidget(view);
    // Create a panel to align the widgets
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setSpacing(10);
    final String msg = constants.cwBasicButtonClickMessage();
    // Add a normal button
    Button normalButton = new Button(constants.cwBasicButtonNormal(), new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert(msg);
        }
    });
    normalButton.ensureDebugId("cwBasicButton-normal");
    hPanel.add(normalButton);

    // Add a disabled button
    Button disabledButton = new Button(constants.cwBasicButtonDisabled());
    disabledButton.ensureDebugId("cwBasicButton-disabled");
    disabledButton.setEnabled(false);
    hPanel.add(disabledButton);
    view.setExample(hPanel);
}

From source file:com.ephesoft.dcma.gwt.core.client.view.ExternalAppDialogBox.java

License:Open Source License

public ExternalAppDialogBox(String url, int xDimension, int yDimension, boolean showOkButton,
        boolean showCloseButton, boolean center, boolean isVisible) {
    setWidget(BINDER.createAndBindUi(this));
    addStyleName(CSS_CONFIGURABLE_DIALOG_BOX);
    setWidth(xDimension + "px");
    setHeight(yDimension + "px");
    frame = new Frame(url);
    frame.setWidth(xDimension + "px");
    frame.setHeight(yDimension + "px");
    okButton = new Button("Ok", new ClickHandler() {

        @Override//from www.j  av  a  2  s  . c o  m
        public void onClick(ClickEvent arg0) {
            listener.onOkClick();
            hide();
        }
    });
    okButton.setTitle("Ctrl+a");
    closeButton = new Button("Close", new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            listener.onCloseClick();
            hide();
        }
    });
    closeButton.setTitle("Ctrl+z");
    okButton.getElement().setAttribute("id", "okButtonElement");
    closeButton.getElement().setAttribute("id", "closeButtonElement");
    okButton.setVisible(showOkButton);
    closeButton.setVisible(showCloseButton);
    HorizontalPanel horizontalButtonPanel = new HorizontalPanel();
    horizontalButtonPanel.setSpacing(5);
    if (showOkButton) {
        horizontalButtonPanel.add(okButton);
        horizontalButtonPanel.setCellHorizontalAlignment(okButton, HasHorizontalAlignment.ALIGN_CENTER);
    }
    if (showCloseButton) {
        horizontalButtonPanel.add(closeButton);
        horizontalButtonPanel.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_CENTER);
    }
    verticalPanel.add(frame);
    verticalPanel.setCellHorizontalAlignment(frame, HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.setCellHorizontalAlignment(horizontalButtonPanel, HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.add(horizontalButtonPanel);
    setModal(true);
    setVisible(true);
    if (center) {
        center();
    }
    if (isVisible) {
        show();
    }
}

From source file:com.ephesoft.dcma.gwt.core.client.view.PopUpDialogBox.java

License:Open Source License

/**
 * Constructor.//from   w  ww.ja  v a 2  s  .  c om
 * 
 * @param showOkButton true if ok button is needed.
 * @param showCancelButton true if cancel button is needed.
 * @param center true if dialog box is to be center aligned.
 * @param isVisible true if dialog box is to be visible immediately on construction.
 */
public PopUpDialogBox(final boolean showOkButton, final boolean showCancelButton, final boolean center,
        final boolean isVisible) {
    super();
    setWidget(BINDER.createAndBindUi(this));
    addStyleName(CoreCommonConstants.CSS_DIALOG_BOX);
    okButton = new Button(LocaleDictionary.get().getConstantValue(LocaleCommonConstants.title_confirmation_ok),
            new ClickHandler() {

                @Override
                public void onClick(final ClickEvent clickEvent) {
                    listener.onOkClick();
                }
            });
    cancelButton = new Button(
            LocaleDictionary.get().getConstantValue(LocaleCommonConstants.title_confirmation_cancel),
            new ClickHandler() {

                @Override
                public void onClick(final ClickEvent clickEvent) {
                    listener.onCancelClick();
                }
            });
    okButton.setVisible(showOkButton);
    cancelButton.setVisible(showCancelButton);
    horizontalButtonPanel.setHeight(BUTTON_PANEL_HEIGHT);
    if (showOkButton) {
        horizontalButtonPanel.add(okButton);
        horizontalButtonPanel.setCellHorizontalAlignment(okButton, HasHorizontalAlignment.ALIGN_RIGHT);
        horizontalButtonPanel.setCellVerticalAlignment(okButton, HasVerticalAlignment.ALIGN_MIDDLE);
    }
    if (showCancelButton) {
        horizontalButtonPanel.add(cancelButton);
        horizontalButtonPanel.setCellHorizontalAlignment(cancelButton, HasHorizontalAlignment.ALIGN_LEFT);
        horizontalButtonPanel.setCellVerticalAlignment(cancelButton, HasVerticalAlignment.ALIGN_MIDDLE);
    }
    horizontalButtonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    setAnimationEnabled(true);
    setGlassEnabled(true);
    if (center) {
        center();
    }
    if (isVisible) {
        show();
    }
    listMainPanel.setVisible(true);
}

From source file:com.ephesoft.dcma.gwt.foldermanager.client.view.FolderTableView.java

License:Open Source License

public FolderTableView(Label footer) {
    super();/* ww w .j  a  v a 2 s  .  co  m*/
    initWidget(BINDER.createAndBindUi(this));
    folderDisplayTable.addStyleName(FolderManagementConstants.TABLE_BORDER_COLLAPSE);
    headers.addStyleName(FolderManagementConstants.TABLE_BORDER_COLLAPSE);
    folderScrollPanel.setAlwaysShowScrollBars(true);
    footerPanel.addStyleName(FolderManagementConstants.FE_FOOTER);
    footerPanel.setWidth(PERCENTAGE_HUNDRED);
    footerPanel.add(footer);
    footerPanel.setCellHorizontalAlignment(footer, HasHorizontalAlignment.ALIGN_RIGHT);
    this.folderTableRows = new ArrayList<FolderTableRow>();

    this.cut = new Button(LocaleDictionary.get().getConstantValue(FolderManagementConstants.CUT),
            new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    presenter.onCutClicked();
                }
            });
    this.createNewFolder = new Button(
            LocaleDictionary.get().getConstantValue(FolderManagementConstants.CREATE_NEW_FOLDER),
            new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    presenter.onNewFolderClicked();

                }
            });
    this.copy = new Button(LocaleDictionary.get().getConstantValue(FolderManagementConstants.COPY),
            new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    presenter.onCopyClicked();
                }
            });
    this.paste = new Button(LocaleDictionary.get().getConstantValue(FolderManagementConstants.PASTE),
            new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    presenter.onPasteClicked();
                }
            });
    this.deleteSelected = new Button(LocaleDictionary.get().getConstantValue(FolderManagementConstants.DELETE),
            new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    presenter.onDeleteClicked();
                }
            });
    this.refresh = new Button(LocaleDictionary.get().getConstantValue(FolderManagementConstants.REFRESH),
            new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    presenter.onRefreshClicked();
                }
            });

    this.folderUpButton = new Button(
            LocaleDictionary.get().getConstantValue(FolderManagementConstants.FOLDER_UP), new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    presenter.onFolderUpClicked();
                }
            });
    createTableHeader();
    sinkEvents(Event.ONCONTEXTMENU | Event.ONDBLCLICK);
    setPasteEnabled(false);
}

From source file:com.ephesoft.dcma.gwt.foldermanager.client.view.FolderTableView.java

License:Open Source License

private void performOperationsOnRename(final String fileName, final ContextMenuPanel contextMenu) {
    final DialogBox dialogBox = new DialogBox();
    dialogBox.addStyleName(FolderManagementConstants.CONFIGURABLE_DIALOG_BOX);
    dialogBox.setText(LocaleDictionary.get().getMessageValue(FolderManagementMessages.RENAME_TO));
    final TextBox renameTextBox = new TextBox();
    renameTextBox.setText(fileName);//w w w. j a v  a 2  s . c  om
    HorizontalPanel renameTextBoxPanel = new HorizontalPanel();
    renameTextBoxPanel.add(renameTextBox);
    HorizontalPanel buttonsPanel = new HorizontalPanel();
    Button okButton = new Button(LocaleDictionary.get().getConstantValue(FolderManagementConstants.OK_STRING),
            new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    dialogBox.hide();
                    final String newFileName = renameTextBox.getText();
                    presenter.onRename(fileName, newFileName);
                }
            });
    Button cancelButton = new Button(LocaleDictionary.get().getConstantValue(FolderManagementConstants.CANCEL),
            new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    dialogBox.hide();
                }
            });
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);
    VerticalPanel layoutPanel = new VerticalPanel();
    layoutPanel.add(renameTextBoxPanel);
    layoutPanel.add(buttonsPanel);
    dialogBox.add(layoutPanel);
    dialogBox.center();
    dialogBox.show();
    renameTextBox.setFocus(true);
    renameTextBox.selectAll();
    contextMenu.hide();
}

From source file:com.ephesoft.dcma.gwt.foldermanager.client.view.widget.DisplayDialogBox.java

License:Open Source License

public DisplayDialogBox(Map<Integer, String> fileIndexVsNameMap, final HandlerManager eventBus) {
    super();//www  . j  ava 2  s. c  o m
    setWidget(BINDER.createAndBindUi(this));
    this.eventBus = eventBus;
    final VerticalPanel labelPanel = new VerticalPanel();
    if (fileIndexVsNameMap != null && !fileIndexVsNameMap.isEmpty()) {
        for (final Entry<Integer, String> labelString : fileIndexVsNameMap.entrySet()) {
            totalCounter++;
            final HorizontalPanel horizontalPanel = new HorizontalPanel();
            HTML html = new HTML(FolderManagementConstants.REMOVE_ICON_FOLDER_GIF);
            Label label = new Label(labelString.getValue());
            horizontalPanel.add(html);
            horizontalPanel.add(label);
            horizontalPanel.setSpacing(3);
            labelPanel.add(horizontalPanel);
            html.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    labelPanel.remove(horizontalPanel);
                    if (--totalCounter == 0) {
                        addNoFilesLabel(labelPanel);
                    }
                    eventBus.fireEvent(new RemoveAttachmentEvent(labelString.getKey()));
                }

            });

        }
    } else {
        addNoFilesLabel(labelPanel);
    }
    addStyleName(FolderManagementConstants.CSS_CONFIGURABLE_DIALOG_BOX);
    Button closeButton = new Button(LocaleDictionary.get().getConstantValue(FolderManagementConstants.CLOSE),
            new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    hide();
                }
            });
    HorizontalPanel horizontalButtonPanel = new HorizontalPanel();
    horizontalButtonPanel.add(closeButton);
    horizontalButtonPanel.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_CENTER);
    ScrollPanel scrollPanel = new ScrollPanel();
    scrollPanel.add(labelPanel);
    scrollPanel.setWidth(_200PX);
    scrollPanel.setHeight(_200PX);
    scrollPanel.addStyleName(FolderManagementConstants.BORDER);
    setHeight(_100PX);
    verticalPanel.add(scrollPanel);
    verticalPanel.add(horizontalButtonPanel);
    verticalPanel.setCellHorizontalAlignment(horizontalButtonPanel, HasHorizontalAlignment.ALIGN_CENTER);
    setModal(true);
    setVisible(true);
    show();
    center();
    closeButton.setFocus(true);
}

From source file:com.ephesoft.dcma.gwt.rv.client.presenter.ReviewValidatePresenter.java

License:Open Source License

public void setCustomizedShortcutPanels() {
    if (document != null && (batchDTO.getBatchInstanceStatus().equals(BatchInstanceStatus.READY_FOR_REVIEW)
            || batchDTO.getBatchInstanceStatus().equals(BatchInstanceStatus.READY_FOR_VALIDATION))) {
        ScreenMaskUtility.maskScreen();//from   w w w .  j  av a 2 s .  c  o  m
        rpcService.getFunctionKeyDTOs(document.getType(), batchDTO.getBatch().getBatchInstanceIdentifier(),
                new EphesoftAsyncCallback<List<FunctionKeyDTO>>() {

                    @Override
                    public void customFailure(final Throwable arg0) {
                        ScreenMaskUtility.unmaskScreen();
                        ConfirmationDialogUtil.showConfirmationDialog(
                                LocaleDictionary.get().getConstantValue(ReviewValidateConstants.UNABLE_TO_FIND),
                                LocaleDictionary.get().getMessageValue(ReviewValidateMessages.ERROR_MESSAGE),
                                Boolean.TRUE);
                    }

                    @Override
                    public void onSuccess(final List<FunctionKeyDTO> functionKeyDTOs) {
                        ScreenMaskUtility.unmaskScreen();
                        view.getRvPanel().getFirstShortcutsPanel().clear();
                        view.getRvPanel().getLastShortcutsPanel().clear();
                        if (functionKeyDTOs != null && !functionKeyDTOs.isEmpty()) {
                            view.getRvPanel().getFunctionKeyLabel().setVisible(true);
                            int count = 0;
                            for (final FunctionKeyDTO functionKeyDTO : functionKeyDTOs) {
                                final Button button = new Button(functionKeyDTO.getShortcutKeyName(),
                                        new ClickHandler() {

                                            @Override
                                            public void onClick(final ClickEvent arg0) {
                                                executeScript(functionKeyDTO.getShortcutKeyName());
                                            }
                                        });
                                button.setVisible(true);
                                button.setSize("30px", "25px");
                                button.setTitle(functionKeyDTO.getMethodDescription());
                                count++;
                                if (count <= 6) {
                                    view.getRvPanel().getFirstShortcutsPanel().add(button);
                                } else {
                                    if (count == 7) {
                                        final Button nextButton = new Button(">", new ClickHandler() {

                                            @Override
                                            public void onClick(final ClickEvent arg0) {
                                                view.getRvPanel().getSlidingPanel()
                                                        .setWidget(view.getRvPanel().getLastShortcutsPanel());
                                                view.getRvPanel().getSlidingPanel().setVisible(true);
                                            }
                                        });
                                        nextButton.setVisible(true);
                                        nextButton.setHeight("25px");
                                        nextButton.setTitle("More Buttons");
                                        view.getRvPanel().getFirstShortcutsPanel().add(nextButton);
                                        final Button previousButton = new Button("<", new ClickHandler() {

                                            @Override
                                            public void onClick(final ClickEvent arg0) {
                                                view.getRvPanel().getSlidingPanel()
                                                        .setWidget(view.getRvPanel().getFirstShortcutsPanel());
                                                view.getRvPanel().getSlidingPanel().setVisible(true);
                                            }
                                        });
                                        previousButton.setVisible(true);
                                        previousButton.setHeight("25px");
                                        previousButton.setTitle("Previous Buttons");
                                        view.getRvPanel().getLastShortcutsPanel().add(previousButton);
                                    }
                                    view.getRvPanel().getLastShortcutsPanel().add(button);
                                }
                            }
                            view.getRvPanel().getSlidingPanel()
                                    .setWidget(view.getRvPanel().getFirstShortcutsPanel());
                            view.getRvPanel().getSlidingPanel().setVisible(true);
                            view.getRvPanel().getFunctionKeyLabel().setVisible(true);
                        } else {
                            view.getRvPanel().getFunctionKeyLabel().setVisible(false);
                        }
                    }

                });
    } else {
        view.getRvPanel().getFirstShortcutsPanel().clear();
        view.getRvPanel().getLastShortcutsPanel().clear();
        view.getRvPanel().getFunctionKeyLabel().setVisible(false);
    }
}

From source file:com.ephesoft.dcma.gwt.rv.client.view.ExternalAppDialogBox.java

License:Open Source License

public ExternalAppDialogBox(String url, java.util.Map<String, String> dimensionsOfPopUpMap) {
    super();//from   ww w. jav a 2  s .c  o  m
    setWidget(BINDER.createAndBindUi(this));
    addStyleName(ReviewValidateConstants.CONFIGURED_DIMENSIONS_DIALOG);
    int xDimension;
    int yDimension;

    try {
        xDimension = Integer.parseInt(dimensionsOfPopUpMap.get(ReviewValidateConstants.POP_UP_X_DIMENSION));
        if (xDimension < 0) {
            xDimension = DEFAULT_X_DIMENSION;
        }
    } catch (Exception e) {
        xDimension = DEFAULT_X_DIMENSION;
    }

    try {
        yDimension = Integer.parseInt(dimensionsOfPopUpMap.get(ReviewValidateConstants.POP_UP_Y_DIMENSION));
        if (yDimension < 0) {
            yDimension = DEFAULT_Y_DIMENSION;
        }
    } catch (Exception e) {
        yDimension = DEFAULT_Y_DIMENSION;
    }

    setWidth(xDimension + "px");
    setHeight(yDimension + "px");
    Frame frame = new Frame(url);
    frame.setWidth(xDimension + "px");
    frame.setHeight(yDimension + "px");
    okButton = new Button("Ok", new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            listener.onOkClick();
            hide();
        }
    });
    okButton.setTitle("Ctrl+a");
    closeButton = new Button("Close", new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            listener.onCloseClick();
            hide();
        }
    });
    closeButton.setTitle("Ctrl+z");
    okButton.getElement().setAttribute("id", "okButtonElement");
    closeButton.getElement().setAttribute("id", "closeButtonElement");
    okButton.setVisible(false);
    closeButton.setVisible(false);
    HorizontalPanel horizontalButtonPanel = new HorizontalPanel();
    horizontalButtonPanel.setSpacing(5);
    horizontalButtonPanel.add(okButton);
    horizontalButtonPanel.add(closeButton);
    horizontalButtonPanel.setCellHorizontalAlignment(okButton, HasHorizontalAlignment.ALIGN_CENTER);
    horizontalButtonPanel.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.add(frame);
    verticalPanel.setCellHorizontalAlignment(frame, HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.setCellHorizontalAlignment(horizontalButtonPanel, HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.add(horizontalButtonPanel);
    setModal(true);
    setVisible(true);
    show();
}