Example usage for com.google.gwt.user.client.ui FlexTable getFlexCellFormatter

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

Introduction

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

Prototype

public FlexCellFormatter getFlexCellFormatter() 

Source Link

Document

Explicitly gets the FlexCellFormatter .

Usage

From source file:org.pentaho.pat.client.ui.panels.windows.LoadMenuPanel.java

License:Open Source License

private Widget createRichListBoxCell(final QuerySaveModel item) {
    final FlexTable table = new FlexTable();
    final FlexCellFormatter cellFormatter = table.getFlexCellFormatter();

    table.setWidth("100%"); //$NON-NLS-1$
    table.setBorderWidth(0);//from  w  w w  . j a  va2  s  .  c  o  m
    table.setCellPadding(3);
    table.setCellSpacing(0);

    table.setWidget(0, 0, Pat.IMAGES.database_add().createImage());
    cellFormatter.setRowSpan(0, 0, 3);
    cellFormatter.setWidth(0, 0, "32px"); //$NON-NLS-1$

    table.setHTML(0, 1, "<b>" + item.getName() + "</b>"); //$NON-NLS-1$ //$NON-NLS-2$

    table.setText(1, 0, "Connection: " + item.getConnection().getName()); //$NON-NLS-1$
    table.setText(2, 0, "Last Updated: " + item.getSavedDate()); //$NON-NLS-1$

    return table;
}

From source file:org.pentaho.pat.client.util.colorpicker.ColorPicker.java

License:Artistic License

public ColorPicker() {
    // UI Drawing
    // ------------------

    hue = 0;//from w  ww. j  a  v  a2  s.  c  om
    saturation = 100;
    brightness = 100;
    red = 255;
    green = 0;
    blue = 0;

    HorizontalPanel panel = new HorizontalPanel();
    FlexTable table = new FlexTable();

    // Add the large slider map
    slidermap = new SliderMap(this);
    panel.add(slidermap);
    panel.setCellWidth(slidermap, "258px"); //$NON-NLS-1$
    panel.setCellHeight(slidermap, "258px"); //$NON-NLS-1$

    // Add the small slider bar
    sliderbar = new SliderBar(this);
    panel.add(sliderbar);
    panel.setCellWidth(sliderbar, "40px"); //$NON-NLS-1$
    panel.setCellHeight(sliderbar, "258px"); //$NON-NLS-1$

    // Define the Flextable's content
    // Color preview at the top
    colorpreview = new HTML(""); //$NON-NLS-1$
    colorpreview.setWidth("50px"); //$NON-NLS-1$
    colorpreview.setHeight("50px"); //$NON-NLS-1$
    DOM.setStyleAttribute(colorpreview.getElement(), "border", "1px solid black"); //$NON-NLS-1$ //$NON-NLS-2$

    // Radio buttons
    rbHue = new RadioButton("color", "H:"); //$NON-NLS-1$ //$NON-NLS-2$
    rbHue.addClickHandler(this);
    rbSaturation = new RadioButton("color", "S:"); //$NON-NLS-1$ //$NON-NLS-2$
    rbSaturation.addClickHandler(this);
    rbBrightness = new RadioButton("color", "V:"); //$NON-NLS-1$ //$NON-NLS-2$
    rbBrightness.addClickHandler(this);
    rbRed = new RadioButton("color", "R:"); //$NON-NLS-1$ //$NON-NLS-2$
    rbRed.addClickHandler(this);
    rbGreen = new RadioButton("color", "G:"); //$NON-NLS-1$ //$NON-NLS-2$
    rbGreen.addClickHandler(this);
    rbBlue = new RadioButton("color", "B:"); //$NON-NLS-1$ //$NON-NLS-2$
    rbBlue.addClickHandler(this);

    // Textboxes
    tbHue = new TextBox();
    tbHue.setText(new Integer(hue).toString());
    tbHue.setMaxLength(3);
    tbHue.setVisibleLength(4);
    tbHue.addKeyPressHandler(this);
    tbHue.addChangeHandler(this);
    tbSaturation = new TextBox();
    tbSaturation.setText(new Integer(saturation).toString());
    tbSaturation.setMaxLength(3);
    tbSaturation.setVisibleLength(4);
    tbHue.addKeyPressHandler(this);
    tbSaturation.addChangeHandler(this);
    tbBrightness = new TextBox();
    tbBrightness.setText(new Integer(brightness).toString());
    tbBrightness.setMaxLength(3);
    tbBrightness.setVisibleLength(4);
    tbHue.addKeyPressHandler(this);
    tbBrightness.addChangeHandler(this);
    tbRed = new TextBox();
    tbRed.setText(new Integer(red).toString());
    tbRed.setMaxLength(3);
    tbRed.setVisibleLength(4);
    tbHue.addKeyPressHandler(this);
    tbRed.addChangeHandler(this);
    tbGreen = new TextBox();
    tbGreen.setText(new Integer(green).toString());
    tbGreen.setMaxLength(3);
    tbGreen.setVisibleLength(4);
    tbHue.addKeyPressHandler(this);
    tbGreen.addChangeHandler(this);
    tbBlue = new TextBox();
    tbBlue.setText(Integer.valueOf(blue).toString());
    tbBlue.setMaxLength(3);
    tbBlue.setVisibleLength(4);
    tbHue.addKeyPressHandler(this);
    tbBlue.addChangeHandler(this);
    tbHexColor = new TextBox();
    tbHexColor.setText("ff0000"); //$NON-NLS-1$
    tbHexColor.setMaxLength(6);
    tbHexColor.setVisibleLength(6);
    tbHue.addKeyPressHandler(this);
    tbHexColor.addChangeHandler(this);

    // Put together the FlexTable
    table.setWidget(0, 0, colorpreview);
    table.getFlexCellFormatter().setColSpan(0, 0, 3);
    table.setWidget(1, 0, rbHue);
    table.setWidget(1, 1, tbHue);
    table.setWidget(1, 2, new HTML("&deg;")); //$NON-NLS-1$
    table.setWidget(2, 0, rbSaturation);
    table.setWidget(2, 1, tbSaturation);
    table.setText(2, 2, "%"); //$NON-NLS-1$
    table.setWidget(3, 0, rbBrightness);
    table.setWidget(3, 1, tbBrightness);
    table.setText(3, 2, "%"); //$NON-NLS-1$
    table.setWidget(4, 0, rbRed);
    table.setWidget(4, 1, tbRed);
    table.setWidget(5, 0, rbGreen);
    table.setWidget(5, 1, tbGreen);
    table.setWidget(6, 0, rbBlue);
    table.setWidget(6, 1, tbBlue);
    table.setText(7, 0, "#:"); //$NON-NLS-1$
    table.setWidget(7, 1, tbHexColor);
    table.getFlexCellFormatter().setColSpan(7, 1, 2);

    // Final setup
    panel.add(table);
    rbSaturation.setValue(true);
    setPreview("ff0000"); //$NON-NLS-1$
    DOM.setStyleAttribute(colorpreview.getElement(), "cursor", "default"); //$NON-NLS-1$ //$NON-NLS-2$

    // First event
    onClick2(rbSaturation);

    initWidget(panel);
}

From source file:org.pepstock.jem.gwt.client.commons.UITools.java

License:Open Source License

/**
 * Format FlexTable columns in order to make columns easy-readable  
 * @param t the FlexTable/*from   w w w  . j av a  2s .  c o  m*/
 * @param style Odd column style
 * @param skipFirstRow if <code>true</code> leave the first row as is (for table header)
 */
public static void setColumnKeyValueStyle(FlexTable t, String style, boolean skipFirstRow) {
    FlexCellFormatter cf = t.getFlexCellFormatter();
    int i = skipFirstRow ? 1 : 0;
    for (i = 0; i < t.getRowCount(); i++) {
        for (int j = 0; j < t.getCellCount(i); j++) {
            if (j % 2 == 0) {
                cf.addStyleName(i, j, style);
            }
        }
    }
}

From source file:org.pepstock.jem.gwt.client.commons.UITools.java

License:Open Source License

/**
 * Format FlexTable header in order to make header easy-readable  
 * @param t the FlexTable/*from w w  w . j  av  a  2  s .c  om*/
 * @param style Odd column style
 */
public static void setHeaderStyle(FlexTable t, String style) {
    FlexCellFormatter cf = t.getFlexCellFormatter();
    for (int i = 0; i < t.getCellCount(0); i++) {
        cf.addStyleName(0, i, style);
    }
}

From source file:org.pepstock.jem.gwt.client.SmallHeader.java

License:Open Source License

/**
 * Contrsucts all components//from w ww .  ja va 2s .com
 */
public SmallHeader() {
    /*
     *   -------------------------------------
     *  | LOGO | ENV INFO       | USER INFO |
     *  ------------------------------------- 
     */
    //1 row, 3 column
    super(1, 3);
    setWidth(Sizes.HUNDRED_PERCENT);
    addStyleName(Styles.INSTANCE.common().noWrap());
    getColumnFormatter().setWidth(1, "50%");
    getColumnFormatter().setWidth(2, "50%");
    getRowFormatter().setVerticalAlign(0, HasVerticalAlignment.ALIGN_MIDDLE);

    // load images. see Resources Bundle
    setWidget(0, 0, logoImage);

    // environment box
    environmentInfoBox.addStyleName(Styles.INSTANCE.header().infoBox());

    ColumnFormatter eibColumnFormatter = environmentInfoBox.getColumnFormatter();
    eibColumnFormatter.setWidth(0, "25%");
    eibColumnFormatter.setWidth(1, "25%");
    eibColumnFormatter.setWidth(2, "25%");
    eibColumnFormatter.setWidth(3, "25%");

    FlexCellFormatter eibCellFormatter = environmentInfoBox.getFlexCellFormatter();
    /*
     * --------------------------------------
     * | JEM Env Info:                  |
     * | Key0   Value0      Key1   Value1  |
     * | Key2    Value2      Key3   Value3   |
     * --------------------------------------   
     */
    eibCellFormatter.setColSpan(0, 0, 4);

    environmentInfoBox.setText(0, 0, "JEM environment overview: ");
    eibCellFormatter.addStyleName(0, 0, Styles.INSTANCE.header().infoBoxHeader());
    environmentInfoBox.setText(1, 0, "Name");
    environmentInfoBox.setText(1, 2, "Nodes");
    environmentInfoBox.setText(2, 0, "Jobs in execution");
    environmentInfoBox.setText(2, 2, "Uptime");
    UITools.setColumnKeyValueStyle(environmentInfoBox, Styles.INSTANCE.common().bold(), true);
    setWidget(0, 1, environmentInfoBox);

    // initial state
    //env name
    environmentInfoBox.setText(1, 1, JemConstants.UPDATING_BRACKETS);
    //node number (web)
    environmentInfoBox.setText(1, 3, JemConstants.UPDATING_BRACKETS);
    //job in execution
    environmentInfoBox.setText(2, 1, JemConstants.UPDATING_BRACKETS);
    //uptime
    environmentInfoBox.setText(2, 3, JemConstants.UPDATING_BRACKETS);

    // schedule the update timer
    envBoxUpdateTimer.run();
    envBoxUpdateTimer.scheduleRepeating(ENV_BOX_UPDATE_INTERVAL);

    // user info box (contains logout button)
    /* 
     * ----------------------------------------------
     * | User Info:                           |
     * | Key0   Value0      Key1    Value1   LOGOFF   |
     * | Key2   Value2      Key3   Value3  BUTTON   |
     * ----------------------------------------------
     */
    FlexTable userInfoBox = new FlexTable();
    userInfoBox.addStyleName(Styles.INSTANCE.header().infoBox());

    ColumnFormatter uibColumnFormatter = userInfoBox.getColumnFormatter();
    uibColumnFormatter.setWidth(0, "25%");
    uibColumnFormatter.setWidth(1, "25%");
    uibColumnFormatter.setWidth(2, "25%");
    uibColumnFormatter.setWidth(3, "25%");

    FlexCellFormatter uibCellFormatter = userInfoBox.getFlexCellFormatter();
    uibCellFormatter.setColSpan(0, 0, 5);
    uibCellFormatter.setRowSpan(0, 4, 3);
    uibCellFormatter.setAlignment(0, 4, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
    userInfoBox.setText(0, 0, "User information: ");
    uibCellFormatter.addStyleName(0, 0, Styles.INSTANCE.header().infoBoxHeader());
    LoggedUser user = CurrentUser.getInstance().getUser();
    userInfoBox.setText(1, 0, "ID");
    uibCellFormatter.addStyleName(1, 0, Styles.INSTANCE.common().bold());
    userInfoBox.setText(1, 1, user.getId());

    userInfoBox.setText(1, 2, "Org. Unit ID");
    uibCellFormatter.addStyleName(1, 2, Styles.INSTANCE.common().bold());
    userInfoBox.setText(2, 2, "Org. Unit Name");
    uibCellFormatter.addStyleName(2, 2, Styles.INSTANCE.common().bold());

    userInfoBox.setText(2, 0, "Name");
    uibCellFormatter.addStyleName(2, 0, Styles.INSTANCE.common().bold());
    userInfoBox.setText(2, 1, user.getName());

    String orgUnitId = JemConstants.NONE_BRACKETS;
    String orgUnitName = JemConstants.NONE_BRACKETS;
    if (user.getOrganizationalUnit() != null) {
        if (!(user.getOrganizationalUnit().getId() == null || user.getOrganizationalUnit().getId().isEmpty())) {
            orgUnitId = user.getOrganizationalUnit().getId();
        }
        if (!(user.getOrganizationalUnit().getName() == null
                || user.getOrganizationalUnit().getName().isEmpty())) {
            orgUnitName = user.getOrganizationalUnit().getName();
        }
    }
    userInfoBox.setText(1, 3, orgUnitId);
    userInfoBox.setText(2, 3, orgUnitName);

    // logoff button (and handler)
    btnLogout.addClickHandler(new LogoutClickHandler());
    userInfoBox.setWidget(0, 4, btnLogout);
    setWidget(0, 2, userInfoBox);
}

From source file:org.psystems.dicom.browser.client.component.StudyCard.java

License:Open Source License

/**
 * @param t//from   w  ww  .j a v  a  2 s. c  om
 * @param row
 * @param col
 * @param text
 */
private void createItemName(FlexTable t, int row, int col, String text) {
    Label l = new Label(text);
    l.setStyleName("DicomItemName");
    t.setWidget(row, col, l);
    t.getFlexCellFormatter().setAlignment(row, col, HorizontalPanel.ALIGN_RIGHT, HorizontalPanel.ALIGN_MIDDLE);
}

From source file:org.psystems.dicom.browser.client.component.StudyCard.java

License:Open Source License

/**
 * @param t//from   ww w.  j ava  2  s .  c om
 * @param row
 * @param col
 * @param text
 */
private Label createItemValue(FlexTable t, int row, int col, String text) {
    Label l = new Label(text);
    l.setStyleName("DicomItemValue");
    t.setWidget(row, col, l);
    t.getFlexCellFormatter().setAlignment(row, col, HorizontalPanel.ALIGN_LEFT, HorizontalPanel.ALIGN_MIDDLE);
    return l;
}

From source file:org.rebioma.client.UploadView.java

License:Apache License

private UploadView(View parent, UploadListener uListener) {
    super(parent, false);
    this.uploadListener = uListener;
    modelingBox.setName("modeling");
    final VerticalPanel uploadPanel = new VerticalPanel();
    uploadPanel.setStyleName("pupload");
    HorizontalPanel privateModelField = new HorizontalPanel();
    privateModelField.add(privateRadioButton);
    privateModelField.add(new HTML("&nbsp;("));
    privateModelField.add(modelingBox);/*from w  w  w  . j a  v a  2  s.co  m*/
    privateModelField.add(new HTML(")"));
    HorizontalPanel delimiterPanel = new HorizontalPanel();
    delimiterBox.addItem(constants.Comma(), ",");
    delimiterBox.addItem(constants.Semicolon(), ";");
    delimiterBox.setName("delimiter");
    delimiterPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    delimiterPanel.add(delimiterBox);
    delimiterPanel.add(new HTML("&nbsp;&nbsp;" + constants.CSVDelimiter()));

    fileUpload.setName("file_upload");
    //uploadForm.setAction(GWT.getModuleBaseURL() + "upload");
    //uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    //uploadForm.setMethod(FormPanel.METHOD_POST);
    //uploadPanel.add(fileUpload);
    uploadPanel.add(delimiterPanel);
    showEmailBox.setName("show_email");
    clearReviewCheckBox.setName("clear_review");
    clearReviewCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            if (event.getValue()) {
                MessageBox boxWarning = new MessageBox("Reset review state?", "");
                boxWarning.setPredefinedButtons(PredefinedButton.YES, PredefinedButton.CANCEL);
                boxWarning.setIcon(MessageBox.ICONS.warning());
                boxWarning.setWidth("415px");
                boxWarning.setMessage(
                        "You are resetting all the TRB's review on all occurrences. Would you like to continue?");
                boxWarning.addHideHandler(new HideHandler() {

                    @Override
                    public void onHide(HideEvent eventW) {
                        Dialog btnW = (Dialog) eventW.getSource();
                        if (!btnW.getHideButton().getText().equalsIgnoreCase("yes")) {
                            clearReviewCheckBox.setChecked(false);
                        }
                    }
                });

                boxWarning.show();
            }
        }
    });
    uploadPanel.add(clearReviewCheckBox);
    uploadPanel.add(showEmailBox);
    uploadPanel.add(privateModelField);
    uploadPanel.add(publicRadioButton);
    setClearReview(ApplicationView.getCurrentState() == ViewState.SUPERADMIN);
    UserQuery query = friendsTable.getQuery();
    query.setUsersCollaboratorsOnly(true);
    friendsTable.addCheckedListener(this);
    // TODO: fix resize
    // friendsTable.setSize("500px", "300px");
    friendsTable.resetTable();
    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(10);
    uploadPanel.add(hp);
    //HorizontalPanel buttonPanel = new HorizontalPanel();
    // buttonPanel.add(uploadButton);
    // buttonPanel.add(cancelButton);
    // buttonPanel.setSpacing(2);
    //uploadPanel.add(dataSharingAgreementLink);
    // uploadPanel.add(buttonPanel);
    hiddenSessionId.setValue(Cookies.getCookie(ApplicationView.SESSION_ID_NAME));
    uploadPanel.add(hiddenSessionId);
    uploadPanel.add(collaboratorsSharing);
    final VerticalPanel friendsPanel = new VerticalPanel();
    Label collaborator = new Label(constants.CollaboratorsOnUpload());
    collaborator.setStyleName("title1");
    friendsPanel.add(collaborator);
    friendsPanel.add(friendsTable);
    //HorizontalPanel friendUplodaHp = new HorizontalPanel();
    //friendUplodaHp.add(uploadPanel);
    //friendUplodaHp.add(friendsPanel);
    //friendUplodaHp.setSpacing(5);

    //uploadForm.setWidget(friendUplodaHp);
    /*mainSp.setWidget(uploadForm);
    initWidget(mainSp);*/

    final FlexTable grid = new FlexTable();
    grid.setStyleName("GWTUpld");
    final FormPanel form = new FormPanel() {
        public void add(Widget w) {
            grid.setWidget(grid.getRowCount(), 1, uploadPanel);
            grid.getFlexCellFormatter().setRowSpan(0, 2, 20);
            grid.setWidget(0, 2, new Label("   "));
            grid.getFlexCellFormatter().setStyleName(0, 2, "sep");
            grid.getFlexCellFormatter().setRowSpan(0, 3, 20);
            grid.setWidget(0, 3, friendsPanel);
            grid.setWidget(grid.getRowCount(), 1, dataSharingAgreementLink);
            grid.setWidget(grid.getRowCount(), 1, w);
            //grid.getFlexCellFormatter().setColSpan(grid.getRowCount()+1, 1, 2);
        }

        {
            super.add(grid);
        }
    };
    class MyFancyLookingSubmitButton extends Composite implements HasClickHandlers {
        DecoratorPanel widget = new DecoratorPanel();

        public MyFancyLookingSubmitButton() {
            Button widget = new Button(constants.AcceptDsaUpload());
            initWidget(widget);
        }

        public HandlerRegistration addClickHandler(ClickHandler handler) {
            return addDomHandler(handler, ClickEvent.getType());
        }

    }

    SingleUploader uploader = new SingleUploader(FileInputType.LABEL, new ModalUploadStatus(),
            new MyFancyLookingSubmitButton(), form);
    uploader.setServletPath("send.file");
    //mainSp.add(uploader);
    //grid.setText(5, 0, "Attachment:");
    mainSp.setWidget(uploader);
    uploader.getFileInput().setText(constants.chooseFileLabel());
    initWidget(mainSp);

    uploader.addOnFinishUploadHandler(new OnFinishUploaderHandler() {
        public void onFinish(IUploader uploader) {
            if (uploader.getStatus() == Status.SUCCESS) {
                Document doc = null;
                String displayMsg = null;
                try {
                    doc = XMLParser.parse(uploader.getServerResponse());
                    displayMsg = Utils.getXmlNodeValue(doc, "message");
                } catch (Exception e) {
                }

                //Window.alert("Server response: \n" + displayMsg);

                setUploadEnable(true);
                if (displayMsg != null) {
                    if (displayMsg.matches("<.+>.+<.+>")) {
                        displayMsg = displayMsg.substring(displayMsg.indexOf('>') + 1,
                                displayMsg.lastIndexOf('<'));
                    }
                    JSONObject serverMsg = JSONParser.parse(displayMsg).isObject();
                    if (serverMsg.get("onSuccess") != null) {
                        JSONValue successValue = serverMsg.get("onSuccess");
                        popupStatusMessage.showMessage(successValue);
                        popupStatusMessage.setWidth("300px");
                        //uploadForm.reset();
                    } else {
                        JSONObject error = serverMsg.get("onFailure").isObject();
                        String errorKey = error.keySet().iterator().next();
                        JSONValue jValue = error.get(errorKey);
                        if (errorKey.equals("No File")) {
                            Window.alert(constants.UploadFailedNoFile());
                        } else if (errorKey.equals("Invalid File")) {
                            Window.alert(constants.UploadFailedInvalidFile());
                        } else if (errorKey.equals("Missing Required Headers")) {
                            Window.alert(constants.MissingRequiredHeader() + jValue.isArray());
                        } else {
                            Window.alert(constants.UploadFailedException() + jValue.isString());
                        }
                    }
                }
                DataSwitch.get().clearCache(DataSwitch.OCCURRENCE_KEY);
                uploadListener.onUploadComplete();
                popupStatusMessage.checkAndResize();
                uploader.getFileInput().setText(constants.chooseFileLabel());
                uploader.getFileInput().setSize("200px", "auto");
                uploader.reset();
                form.reset();
            }
        }
    });

    initListeners();
    cancelButton.setEnabled(false);
    publicRadioButton.setValue(true);
    showEmailBox.setValue(true);

    // Adds upload form handlers
    //uploadForm.addSubmitHandler(new SubmitHandler() {

    /**
     * If the uploading file is empty display an error message and cancels the
     * submit event.
     * 
     * @see com.google.gwt.user.client.ui.FormPanel.SubmitHandler#onSubmit(com.google.gwt.user.client.ui.FormPanel.SubmitEvent)
     */
    /*public void onSubmit(SubmitEvent event) {
      if (fileUpload.getFilename().equals("")) {
     Window.alert(constants.FileCantBeEmpty());
     event.cancel();
      } else {
     uploadListener.onUploadStart();
     setUploadEnable(false);
      }
    }
            
    });*/

    //uploadForm.addSubmitCompleteHandler(new SubmitCompleteHandler() {
    /**
     * Notifies the user whether the upload was successful. Also clears the
     * DataSwitch cache since new records were uploaded.
     * 
     * @see com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler#onSubmitComplete(com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent)
     */
    /*public void onSubmitComplete(SubmitCompleteEvent event) {
        setUploadEnable(true);
        String displayMsg = event.getResults();
        // displayMsg =
        // "<something>{\"onFailure\": \"No file uploaded\"}</something>";
        if (displayMsg.matches("<.+>.+<.+>")) {
     displayMsg = displayMsg.substring(displayMsg.indexOf('>') + 1,
         displayMsg.lastIndexOf('<'));
        }
        JSONObject serverMsg = JSONParser.parse(displayMsg).isObject();
        if (serverMsg.get("onSuccess") != null) {
     JSONValue successValue = serverMsg.get("onSuccess");
     popupStatusMessage.showMessage(successValue);
     uploadForm.reset();
        } else {
     JSONObject error = serverMsg.get("onFailure").isObject();
     String errorKey = error.keySet().iterator().next();
     JSONValue jValue = error.get(errorKey);
     if (errorKey.equals("No File")) {
       Window.alert(constants.UploadFailedNoFile());
     } else if (errorKey.equals("Invalid File")) {
       Window.alert(constants.UploadFailedInvalidFile());
     } else if (errorKey.equals("Missing Required Headers")) {
       Window.alert(constants.MissingRequiredHeader() + jValue.isArray());
     } else {
       Window.alert(constants.UploadFailedException() + jValue.isString());
     }
        }
        DataSwitch.get().clearCache(DataSwitch.OCCURRENCE_KEY);
        uploadListener.onUploadComplete();
        popupStatusMessage.checkAndResize();
      }
    });*/

}

From source file:org.sigmah.client.page.login.LoginView.java

License:Open Source License

public LoginView() {
    final SimplePanel panel = new SimplePanel();
    panel.setStyleName("login-background");

    final Grid grid = new Grid(1, 2);
    grid.setStyleName("login-box");

    // Logo/*from  www . ja  v a  2s. c  o  m*/
    grid.setWidget(0, 0, new Image("image/login-logo.png"));

    // Form
    final FlexTable form = new FlexTable();
    form.setWidth("90%");

    int y = 0;

    // E-Mail field
    form.setText(y, 0, I18N.CONSTANTS.loginLoginField());
    form.getCellFormatter().setStyleName(y, 0, "login-box-form-label");

    final TextBox loginTextBox = new TextBox();
    loginTextBox.setWidth("100%");
    form.setWidget(y, 1, loginTextBox);
    form.getFlexCellFormatter().setColSpan(y, 1, 2);
    y++;

    // Separator
    for (int i = 0; i < 3; i++)
        form.getCellFormatter().setStyleName(y, i, "login-box-form-separator");
    y++;

    // Password field
    form.setText(y, 0, I18N.CONSTANTS.loginPasswordField());
    form.getCellFormatter().setStyleName(y, 0, "login-box-form-label");

    final PasswordTextBox passwordTextBox = new PasswordTextBox();
    passwordTextBox.setWidth("100%");
    form.setWidget(y, 1, passwordTextBox);
    form.getFlexCellFormatter().setColSpan(y, 1, 2);
    y++;

    // Separator
    for (int i = 0; i < 3; i++)
        form.getCellFormatter().setStyleName(y, i, "login-box-form-separator");
    y++;

    // Language field
    form.setText(y, 0, I18N.CONSTANTS.loginLanguageField());
    form.getCellFormatter().setStyleName(y, 0, "login-box-form-label");

    int selection = 0;
    final String currentLanguage = Cookies.getCookie(org.sigmah.shared.Cookies.LOCALE_COOKIE);

    final ListBox languageListBox = new ListBox(false);
    int index = 0;
    for (final Map.Entry<String, String> entry : languageMap.entrySet()) {
        languageListBox.addItem(entry.getKey(), entry.getValue());
        if (entry.getValue().equals(currentLanguage))
            selection = index;
        index++;
    }
    languageListBox.setSelectedIndex(selection);
    languageListBox.setWidth("100%");
    form.setWidget(y, 1, languageListBox);
    form.getFlexCellFormatter().setColSpan(y, 1, 2);
    y++;

    // Separator
    for (int i = 0; i < 3; i++)
        form.getCellFormatter().setStyleName(y, i, "login-box-form-separator");
    y++;

    // Password forgotten link
    final FlowPanel bottomPanel = new FlowPanel();
    bottomPanel.getElement().getStyle().setPosition(Position.RELATIVE);

    final Anchor label = new Anchor(I18N.CONSTANTS.loginPasswordForgotten());
    label.setStyleName("login-box-form-forgotten");
    label.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {

            MessageBox.prompt(I18N.CONSTANTS.loginPasswordForgotten(), I18N.CONSTANTS.loginLoginField(),
                    new Listener<MessageBoxEvent>() {

                        @Override
                        public void handleEvent(MessageBoxEvent be) {
                            // If the user clicked on "OK".
                            if (Dialog.OK.equals(be.getButtonClicked().getItemId())) {
                                final Dialog waitDialog = new Dialog();
                                waitDialog.setHeading(I18N.CONSTANTS.loginPasswordForgotten());
                                waitDialog.addText(I18N.CONSTANTS.loading());
                                waitDialog.setButtons("");
                                waitDialog.setModal(true);
                                waitDialog.setClosable(false);
                                waitDialog.show();

                                final String email = be.getValue();

                                final PasswordManagementServiceAsync service = GWT
                                        .create(PasswordManagementService.class);
                                service.forgotPassword(email,
                                        languageListBox.getValue(languageListBox.getSelectedIndex()),
                                        GWT.getModuleBaseURL(), new AsyncCallback<Void>() {

                                            @Override
                                            public void onFailure(Throwable caught) {
                                                waitDialog.hide();
                                                MessageBox.alert(I18N.CONSTANTS.loginPasswordForgotten(),
                                                        I18N.MESSAGES.loginRetrievePasswordBadLogin(email),
                                                        null);
                                            }

                                            @Override
                                            public void onSuccess(Void result) {
                                                waitDialog.hide();
                                                MessageBox.alert(I18N.CONSTANTS.loginPasswordForgotten(),
                                                        I18N.MESSAGES.loginResetPasswordSuccessfull(email),
                                                        null);
                                            }
                                        });
                            }
                        }
                    });
        }
    });
    bottomPanel.add(label);

    final Image loader = new Image("image/login-loader.gif");
    loader.getElement().getStyle().setVisibility(Visibility.HIDDEN);
    loader.getElement().getStyle().setMarginTop(-8, Unit.PX);
    loader.getElement().getStyle().setPosition(Position.ABSOLUTE);
    loader.getElement().getStyle().setTop(50, Unit.PCT);
    loader.getElement().getStyle().setRight(2, Unit.PX);
    bottomPanel.add(loader);

    form.setWidget(y, 0, bottomPanel);
    form.getFlexCellFormatter().setColSpan(y, 0, 2);

    // Login button
    final Button loginButton = new Button(I18N.CONSTANTS.loginConnectButton());
    loginButton.setWidth("120px");
    form.setWidget(y, 1, loginButton);
    form.getCellFormatter().setHorizontalAlignment(y, 1, HasHorizontalAlignment.ALIGN_RIGHT);
    y++;

    // Login actions
    loginButton.addListener(Events.Select, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(BaseEvent be) {
            Cookies.setCookie(org.sigmah.shared.Cookies.LOCALE_COOKIE,
                    languageListBox.getValue(languageListBox.getSelectedIndex()));
            doLogin(loginTextBox.getText(), passwordTextBox.getText(), loginButton, loader);
        }
    });

    final KeyDownHandler handler = new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                loginButton.fireEvent(Events.Select);
            }
        }
    };
    loginTextBox.addKeyDownHandler(handler);
    passwordTextBox.addKeyDownHandler(handler);

    // Adding the form to the orange box
    grid.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
    grid.setWidget(0, 1, form);

    // Styles
    grid.getCellFormatter().setStyleName(0, 0, "login-box-logo");
    grid.getCellFormatter().setStyleName(0, 1, "login-box-form");

    panel.add(grid);

    initWidget(panel);
}

From source file:org.sigmah.client.page.passwordreset.PasswordResetView.java

License:Open Source License

void showFailureMessage(final FlexTable form) {
    form.setText(0, 0, I18N.CONSTANTS.invalidLink());
    form.getFlexCellFormatter().setStyleName(0, 0, "update-form-message-title");

    form.setText(1, 0, I18N.CONSTANTS.invalidLinkDetail());
    form.getFlexCellFormatter().setStyleName(1, 0, "update-form-message-content");

    final Anchor loginPageLink = new Anchor(I18N.CONSTANTS.visitToLoginPage());
    loginPageLink.setStyleName("login-box-form-forgotten");
    loginPageLink.addClickHandler(new ClickHandler() {

        @Override//from   w ww  .  j a va2s. co  m
        public void onClick(ClickEvent arg0) {
            Window.Location.replace(GWT.getModuleBaseURL());

        }
    });
    form.setWidget(2, 0, loginPageLink);
    form.getFlexCellFormatter().setWidth(2, 0, "100%");
    form.getFlexCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);
}