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

protected Button(com.google.gwt.dom.client.Element element) 

Source Link

Document

This constructor may be used by subclasses to explicitly use an existing element.

Usage

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

License:Apache License

/**
 * Constructor./*w  w w  .  ja va2  s  . co m*/
 *
 * @param constants the constants
 */
public CwFileUpload(CwConstants constants) {
    super(constants.cwFileUploadName(), constants.cwFileUploadDescription());
    this.constants = constants;
    view = new ContentWidgetView(hasMargins(), hasScrollableContent());
    view.setName(getName());
    view.setDescription(getDescription());
    setWidget(view);
    // Create a vertical panel to align the content
    VerticalPanel vPanel = new VerticalPanel();

    // Add a label
    vPanel.add(new HTML(constants.cwFileUploadSelectFile()));

    // Add a file upload widget
    final FileUpload fileUpload = new FileUpload();
    fileUpload.ensureDebugId("cwFileUpload");
    vPanel.add(fileUpload);
    final String msg1 = constants.cwFileUploadNoFileError();
    final String msg2 = constants.cwFileUploadSuccessful();

    // Add a button to upload the file
    Button uploadButton = new Button(constants.cwFileUploadButton());
    uploadButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            String filename = fileUpload.getFilename();
            if (filename.length() == 0) {
                Window.alert(msg1);
            } else {
                Window.alert(msg2);
            }
        }
    });
    vPanel.add(new HTML("<br>"));
    vPanel.add(uploadButton);

    view.setExample(vPanel);
}

From source file:com.dushyant.sample.ui.gwt.GwtRpcPortletEntryPoint.java

License:Apache License

/**
 * This method is invoked when GWT Module is loaded on the page
 *//*from   ww w  .  j  av a  2  s .  c  om*/
public void onModuleLoad() {
    // This is just a sample entry point method for this portlet. In real world you would probably use MVP
    // pattern with UiBinder files instead of adding stuff to a div like this and directly making RPC calls from
    // here.
    // The "gwtRpcPortlet" here is the ID of an empty div used in "view.jsp" file
    RootPanel mainPanel = RootPanel.get("gwtRpcPortlet");

    final TextBox inputName = new TextBox();
    mainPanel.add(inputName);

    Button serviceCallButton = new Button("Make GWT RPC Call");
    mainPanel.add(serviceCallButton);

    serviceCallButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            ServiceInput serviceInput = new ServiceInput(inputName.getText());
            // Making the RPC call here
            getGwtRpcService().doSomeStuff(serviceInput, new AsyncCallback<ServiceOutput>() {
                @Override
                public void onFailure(Throwable caught) {
                    Window.alert("Service call failed " + caught.getMessage());
                }

                @Override
                public void onSuccess(ServiceOutput result) {
                    Window.alert("Successfully called GWT RPC service. Server says ---- " + result);
                }
            });
        }
    });
}

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

License:Open Source License

public PageMovePanel(String selectedPageId, String selectedDocumentId, final List<String> listOfDocumentId,
        BatchDTO batchDTO, DialogBox confirmationDialog,
        final ReviewValidatePresenter reviewValidatePresenter) {
    super();/*from  w w w .j  a  v a  2  s .  co  m*/
    this.selectedPageId = selectedPageId;
    this.selectedDocumentId = selectedDocumentId;
    this.confirmationDialog = confirmationDialog;
    this.listOfDocumentId = listOfDocumentId;
    this.batchDTO = batchDTO;
    int selectedIndex = 0;
    listBox1 = new ListBox();
    listBox2 = new ListBox();

    for (String documentId : listOfDocumentId) {

        listBox1.addItem(documentId);

    }
    listBox1.setSelectedIndex(selectedIndex);
    String moveToDocumentId = PageMovePanel.this.listOfDocumentId.get(0);
    populateListOfPages(moveToDocumentId);
    listBox1.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            int selectedIndex = PageMovePanel.this.listBox1.getSelectedIndex();
            String selectedDocumentId = PageMovePanel.this.listOfDocumentId.get(selectedIndex);
            populateListOfPages(selectedDocumentId);
            listBox2.clear();

            for (Page currPage : listOfPages) {
                if (currPage.getIdentifier().equals(PageMovePanel.this.selectedPageId)) {
                    continue;
                }
                listBox2.addItem(
                        LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TITLE_MOVEPANEL_PAGE)
                                + " " + currPage.getIdentifier());
            }

            if (listBox2.getItemCount() == 0) {
                listBox2.setEnabled(false);
            } else {
                listBox2.setEnabled(true);
            }

        }

    });

    for (Page currPage : listOfPages) {
        if (currPage.getIdentifier().equals(PageMovePanel.this.selectedPageId)) {
            continue;
        }
        listBox2.addItem(LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TITLE_MOVEPANEL_PAGE)
                + " " + currPage.getIdentifier());
    }

    if (listBox2.getItemCount() == 0) {
        listBox2.setEnabled(false);
    } else {
        listBox2.setEnabled(true);
    }

    // listBox2.addClickHandler(new ClickHandler(){
    //
    // @Override
    // public void onClick(ClickEvent arg0) {
    // listBox2.clear();
    // listBox2.addItem("Select");
    // for(PageType currPage:listOfPages){
    // listBox2.addItem("Page "+currPage.getIdentifier());
    // }
    //            
    // }});
    rb0 = new RadioButton("myRadioGroup",
            LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TITLE_MOVEPANEL_MOVE_BEFORE));
    rb1 = new RadioButton("myRadioGroup",
            LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TITLE_MOVEPANEL_MOVE_AFTER));
    movePageButton = new Button(
            LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TITLE_MOVEPANEL_MOVE_PAGE));
    movePageButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {

            int moveToIndexDoc = PageMovePanel.this.listBox1.getSelectedIndex();
            final String moveToDocumentId1 = PageMovePanel.this.listOfDocumentId.get(moveToIndexDoc);
            PageMovePanel.this.setMoveToDocumentId(moveToDocumentId1);
            int moveToIndexPage = PageMovePanel.this.listBox2.getSelectedIndex();
            String moveToPageId1 = PageMovePanel.this.listOfPages.get(moveToIndexPage).getIdentifier();
            Boolean moveAfterchecked = PageMovePanel.this.rb1.getValue();

            Batch batch = PageMovePanel.this.batchDTO.getBatch();
            ScreenMaskUtility.maskScreen();
            rpcService.movePageOfDocument(batch, PageMovePanel.this.selectedPageId,
                    PageMovePanel.this.selectedDocumentId, moveToDocumentId1, moveToPageId1, moveAfterchecked,
                    new AsyncCallback<BatchDTO>() {

                        @Override
                        public void onFailure(Throwable arg0) {
                            ScreenMaskUtility.unmaskScreen();
                            if (!reviewValidatePresenter.displayErrorMessage(arg0)) {
                                ConfirmationDialogUtil.showConfirmationDialogError(LocaleDictionary.get()
                                        .getMessageValue(ReviewValidateMessages.MSG_MOVEPANEL_MOVE_ERROR,
                                                PageMovePanel.this.selectedPageId, moveToDocumentId1,
                                                arg0.getMessage()));
                            }
                        }

                        @Override
                        public void onSuccess(BatchDTO batchDTO) {
                            PageMovePanel.this.batchDTO = batchDTO;
                            listener.onOkClick();
                            PageMovePanel.this.confirmationDialog.hide();
                            ScreenMaskUtility.unmaskScreen();
                        }

                    });

        }

    });
    cancelButton = new Button(
            LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TITLE_MOVEPANEL_CANCEL_BUTTON));
    cancelButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            PageMovePanel.this.confirmationDialog.hide();
            if (reviewValidatePresenter != null) {
                reviewValidatePresenter.setFocus();
            }
        }
    });
    rb1.setChecked(true);
    horizontalPanel = new HorizontalPanel();
    Label labelDocument = new Label(
            LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TITLE_MOVEPANEL_DOCUMENT) + ":");
    this.add(labelDocument);
    this.add(listBox1);
    Label labelPage = new Label(
            LocaleDictionary.get().getConstantValue(ReviewValidateConstants.TITLE_MOVEPANEL_PAGE) + ":");
    this.add(labelPage);
    this.add(listBox2);
    this.add(rb0);
    this.add(rb1);
    horizontalPanel.add(movePageButton);
    horizontalPanel.add(cancelButton);
    horizontalPanel.setSpacing(5);
    this.add(horizontalPanel);

}

From source file:com.ephesoft.gxt.admin.client.view.tableinfo.TableInfoImportView.java

License:Open Source License

private void filesNotSupportedAction(List<String> filesNotSupported) {
    String filesNotImported = "<ol>";
    for (String unsupportedFileName : filesNotSupported) {
        filesNotImported = StringUtil.concatenate(filesNotImported, "<li>", unsupportedFileName, "<//li>");
    }//  ww  w. j  a va2s . c  o  m
    final String message = StringUtil.concatenate(
            LocaleDictionary.getMessageValue(BatchClassMessages.UNABLE_TO_UPLOAD), filesNotSupported.size(),
            LocaleDictionary.getMessageValue(BatchClassMessages.FILES_UNSUPPORTED_FORMAT));
    final MessageDialog dialog = new MessageDialog(LocaleDictionary.getConstantValue(BatchClassConstants.ERROR),
            message, DialogIcon.ERROR);
    Button showFileList = new Button(LocaleDictionary.getMessageValue(BatchClassMessages.SHOW_FILE_LIST));
    final String filesList = StringUtil.concatenate(filesNotImported, "<//ol>");
    showFileList.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            DialogUtil.showMessageDialog(
                    LocaleDictionary.getMessageValue(BatchClassMessages.UNSUPPORTED_FILE_LIST), filesList);
        }
    });
    dialog.addButton(showFileList);
    dialog.show();
    dialog.addDialogHideHandler(new DialogHideHandler() {

        @Override
        public void onDialogHide(DialogHideEvent event) {
            filesNotSupportedList.clear();
        }
    });
}

From source file:com.feller.picup.client.PickUp.java

License:Open Source License

public void onModuleLoad() {
    RootPanel rootPanel = RootPanel.get();

    tabPanel.setVisible(true);/*  w  w  w .j  av  a2s . co  m*/
    tabPanel.setAnimationEnabled(true);
    rootPanel.add(tabPanel, 0, 85);
    tabPanel.setSize("561px", "343px");
    tabPanel.add(Uploadpanel, "Upload Pics", false);
    Uploadpanel.setSize("296px", "290px");
    Uploadpanel.add(uploadLabel);
    Uploadpanel.add(fileUpload);
    fileUpload.setName("files[]");

    VerticalPanel generateQRPanel = new VerticalPanel();
    tabPanel.add(generateQRPanel, "Generate QR Code", false);
    tabPanel.selectTab(0);

    generateQRPanel.setSize("5cm", "3cm");

    HorizontalPanel ButtonslPanel = new HorizontalPanel();
    generateQRPanel.add(ButtonslPanel);
    ButtonslPanel.setSize("218px", "36px");

    Button getQRButton = new Button("get QR");
    getQRButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            getBucketURL();
        }
    });
    ButtonslPanel.add(getQRButton);

    Button btnSendToBucket = new Button("send to Bucket");
    btnSendToBucket.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            generateUploadFrame();
        }
    });
    ButtonslPanel.add(btnSendToBucket);

    ButtonslPanel.add(errorLabel);

    generateQRPanel.add(QRImagePanel);
    QRImagePanel.setWidth("197px");

    Image picupImage = new Image("images/picUp.png");
    rootPanel.add(picupImage, 7, 10);
    fileUpload.getElement().setId("files");

    if (!initQRcodeDecoderComponenets()) {
        uploadLabel.setText("your browser does not support html5 capabilities.\n " + "QR decoding won't work \n"
                + "try using FireFox or chrome browser");
    } else {
        uploadLabel.setText("html5 capabilites are supported");
    }

    initFileReaderCallbacks(this);
}

From source file:com.fountainhead.client.view.ErrorPageView.java

License:Open Source License

public ErrorPageView() {

    panel = new HTMLPanel(html);

    okButton = new Button("OK");

    panel.add(okButton, "okButtonContainer");

    bindCustomUiHandlers();/*from w  w  w  .ja v  a  2  s.co  m*/
}

From source file:com.fountainhead.client.view.SignInPageView.java

License:Open Source License

public SignInPageView() {

    panel = new HTMLPanel(html);
    errorLabel = new Label();
    userNameField = new TextBox();
    passwordField = new PasswordTextBox();
    signInButton = new Button("Sign in");

    userNameField.setText(DEFAULT_USER_NAME);

    // See FieldVerifier
    // Passwords must contain at least 8 characters with at least one digit,
    // one upper case letter, one lower case letter and one special symbol (@#$%).
    passwordField.setText(DEFAULT_PASSWORD);

    panel.add(userNameField, "userNameFieldContainer");
    panel.add(passwordField, "passwordFieldContainer");
    panel.add(signInButton, "signInButtonContainer");
    panel.add(errorLabel, "errorLabelContainer");

    bindCustomUiHandlers();//  w w  w  . j a va 2  s . c  om
}

From source file:com.fullmetalgalaxy.client.creation.WgtEditInitialHolds.java

License:Open Source License

public WgtEditInitialHolds() {
    m_panel.add(new Label(MAppGameCreation.s_messages.tipInitialHolds()));
    Button btnReinit = new Button(MAppGameCreation.s_messages.defaultValue());
    btnReinit.addClickHandler(new ClickHandler() {
        @Override/*  www  . j  av a  2s . co  m*/
        public void onClick(ClickEvent p_event) {
            // reset to default value
            GameEngine.model().getGame().setInitialHolds(null);
            onTabSelected();
        }
    });
    m_panel.add(btnReinit);

    m_panel.add(m_grid);

    initWidget(m_panel);
}

From source file:com.fullmetalgalaxy.client.creation.WgtEditReserve.java

License:Open Source License

public WgtEditReserve() {
    m_panel.add(new Label(MAppGameCreation.s_messages.tipReserve()));
    Button btnReinit = new Button(MAppGameCreation.s_messages.defaultValue());
    btnReinit.addClickHandler(new ClickHandler() {
        @Override//from   w w  w  . ja  v a2s  .co m
        public void onClick(ClickEvent p_event) {
            // reset to default value
            GameEngine.model().getGame().setConstructReserve(null);
            onTabSelected();
        }
    });
    m_panel.add(btnReinit);

    m_panel.add(m_grid);

    initWidget(m_panel);
}

From source file:com.garmin.gwt.communicator.testing.client.Showcase.java

License:Apache License

/**
 * Show basic controls to test functionality
 *///from www  .java  2 s  .  c o m
private void loadScreen() {
    HTML html = new HTML("Version Feature Tests<br/>");
    addWidget(html);

    console = new TextArea();
    addWidget(console);

    Button button = new Button("Plugin Version");
    button.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            String version = plugin.getPluginVersionString();
            displayToConsole("Installed plugin version: " + version);
        }
    });
    addWidget(button);

    button = new Button("Plugin Version XML");
    button.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            String version = plugin.getVersionXml();
            displayToConsole("Installed plugin version: " + version);
        }
    });
    addWidget(button);

    button = new Button("Plugin Version Array");
    button.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            int[] versions = plugin.getPluginVersion().toArray();
            String version = "[" + versions[0] + "," + versions[1] + "," + versions[2] + "," + versions[3]
                    + "]";
            displayToConsole(version);
        }
    });
    addWidget(button);

    button = new Button("Plugin Latest Version");
    button.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            displayToConsole(plugin.getLatestPluginVersion().toString());
        }
    });
    addWidget(button);

    button = new Button("Plugin Required Version");
    button.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            displayToConsole(plugin.getRequiredPluginVersion().toString());
        }
    });
    addWidget(button);

    button = new Button("Unlock");
    button.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            plugin.unlock(new KeyPair[] {});
            String message = (plugin.isUnlocked()) ? "Unlocked!" : "Still LOCKED!";
            displayToConsole(message);
        }
    });
    addWidget(button);

    HTML html2 = new HTML("<br/>Load Data Tests<br/>");
    addWidget(html2);

    button = new Button("Get Progress XML");
    button.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            displayToConsole(plugin.getProgressXml());
        }
    });
    addWidget(button);

    button = new Button("Get Progress");
    button.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            displayToConsole(plugin.getProgress().toString());
        }
    });
    addWidget(button);

    button = new Button("Device list XML");
    button.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            testReadFromDeviceXml();
        }
    });
    addWidget(button);

    button = new Button("Device descriptsion XML");
    button.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            testReadDeviceDescriptionXml();
        }
    });
    addWidget(button);

    button = new Button("Device list");
    button.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            testReadFromDevice();
        }
    });
    addWidget(button);

    button = new Button("Get Gps Data XML");
    button.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            testReadGpsData();
        }
    });
    addWidget(button);

    button = new Button("Get Fitness Data XML");
    button.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            testReadFitnessData();
        }
    });
    addWidget(button);

}