Example usage for com.google.gwt.user.client.ui HasVerticalAlignment ALIGN_MIDDLE

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

Introduction

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

Prototype

VerticalAlignmentConstant ALIGN_MIDDLE

To view the source code for com.google.gwt.user.client.ui HasVerticalAlignment ALIGN_MIDDLE.

Click Source Link

Document

Specifies that the widget's contents should be aligned in the middle.

Usage

From source file:org.freemedsoftware.gwt.client.screen.DashboardScreenNew.java

License:Open Source License

protected HorizontalPanel createHeaderPanel() {
    final HorizontalPanel headerHPanel = new HorizontalPanel();
    headerHPanel.setWidth("100%");
    //Adding quick text on top left corner

    final HorizontalPanel refreshDashBoardHPanel = new HorizontalPanel();
    refreshDashBoardHPanel.setWidth("100%");
    headerHPanel.add(refreshDashBoardHPanel);

    final HorizontalPanel refreshDashBoardSubHPanel = new HorizontalPanel();
    refreshDashBoardHPanel.add(refreshDashBoardSubHPanel);

    final Label lastUpdateLabel = new Label("Last updated on " + Util.getTodayDate());
    refreshDashBoardSubHPanel.add(lastUpdateLabel);
    refreshDashBoardSubHPanel.setCellVerticalAlignment(lastUpdateLabel, HasVerticalAlignment.ALIGN_MIDDLE);

    final CustomButton refreshDashBoardBtn = new CustomButton("Refresh", AppConstants.ICON_REFRESH);
    refreshDashBoardBtn.getElement().setAttribute("style", "float:right");
    refreshDashBoardSubHPanel.add(refreshDashBoardBtn);
    refreshDashBoardHPanel.setCellHorizontalAlignment(refreshDashBoardSubHPanel,
            HasHorizontalAlignment.ALIGN_RIGHT);

    refreshDashBoardBtn.addClickHandler(new ClickHandler() {

        @Override/*from  w w w  . j  a  v a 2  s.c o  m*/
        public void onClick(ClickEvent arg0) {
            // TODO Auto-generated method stub
            lastUpdateLabel.setText("Last updated on " + Util.getTodayDate());
            clearView();
            loadWidgets();
            reloadDashboard();
        }

    });

    return headerHPanel;
}

From source file:org.freemedsoftware.gwt.client.screen.MainScreen.java

License:Open Source License

private String getHeaderString(String text, AbstractImagePrototype image) {
    // Add the image and text to a horizontal panel
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setSpacing(0);//w ww  .  ja v  a  2 s.c  om
    hPanel.setWidth("100%");
    hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    hPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    if (image != null)
        hPanel.add(image.createImage());
    HTML headerText = new HTML(text);
    headerText.setStyleName("stackPanelHeader");
    hPanel.add(headerText);

    // Return the HTML string for the panel
    return hPanel.getElement().getString();
}

From source file:org.freemedsoftware.gwt.client.screen.patient.ClinicalOrdersEntry.java

License:Open Source License

/**
 * Panel "A" creation routine.//from w  ww.ja  v a2s .c o m
 * 
 * @return
 */
protected FlexTable createCategoryPanel() {
    FlexTable f = new FlexTable();
    f.setWidget(0, 0, new HTML("<em>" + _("Category") + "</em>"));

    int pos = 0;

    pos++;
    cConsult = new CustomButton(_("Consult"));
    cConsult.addClickHandler(this);
    f.setWidget(0, pos, cConsult);
    f.getFlexCellFormatter().setAlignment(0, pos, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    pos++;
    cRadiology = new CustomButton(_("Radiology"));
    cRadiology.addClickHandler(this);
    f.setWidget(0, pos, cRadiology);
    f.getFlexCellFormatter().setAlignment(0, pos, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    pos++;
    cLab = new CustomButton(_("Lab"));
    cLab.addClickHandler(this);
    f.setWidget(0, pos, cLab);
    f.getFlexCellFormatter().setAlignment(0, pos, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    pos++;
    cImmunization = new CustomButton(_("Immunization"));
    cImmunization.addClickHandler(this);
    f.setWidget(0, pos, cImmunization);
    f.getFlexCellFormatter().setAlignment(0, pos, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    pos++;
    cProcedure = new CustomButton(_("Procedure"));
    cProcedure.addClickHandler(this);
    f.setWidget(0, pos, cProcedure);
    f.getFlexCellFormatter().setAlignment(0, pos, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    pos++;
    cRx = new CustomButton(_("Prescription"));
    cRx.addClickHandler(this);
    f.setWidget(0, pos, cRx);
    f.getFlexCellFormatter().setAlignment(0, pos, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    pos++;
    cTemplates = new CustomButton(_("Templates"));
    cTemplates.addClickHandler(this);
    f.setWidget(0, pos, cTemplates);
    f.getFlexCellFormatter().setAlignment(0, pos, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);

    return f;
}

From source file:org.freemedsoftware.gwt.client.widget.AccordionPanel.java

License:Open Source License

public AccordionPanel(boolean horizontal) {
    if (horizontal) {
        aPanel = new HorizontalPanel();
        animField = "width";
        animBounds = "scrollWidth";
        ((HorizontalPanel) aPanel).setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    } else {/*w w w.  j  ava 2 s.  c  om*/
        aPanel = new VerticalPanel();
        animField = "height";
        animBounds = "scrollHeight";
        ((VerticalPanel) aPanel).setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    }
    initWidget(aPanel);
    // setStylePrimaryName("accordion");
    setStyleName("gwt-DecoratedStackPanel");
}

From source file:org.freemedsoftware.gwt.client.widget.AccordionPanel.java

License:Open Source License

public String getHeader(String title) {

    FlexTable flexTable = new FlexTable();
    flexTable.setWidth("100%");
    flexTable.setCellPadding(0);//  w w  w. java 2s .  c  o m
    flexTable.setCellSpacing(0);

    ///start creating top strip
    flexTable.getRowFormatter().setStyleName(0, "stackItemTop");
    HTML html = new HTML();
    html.setStyleName("stackItemTopLeftInner");
    flexTable.setWidget(0, 0, html);
    flexTable.getCellFormatter().setStyleName(0, 0, "stackItemTopLeft");
    html = new HTML();
    html.setStyleName("stackItemTopCenterInner");
    flexTable.setWidget(0, 1, html);
    flexTable.getCellFormatter().setStyleName(0, 1, "stackItemTopCenter");
    html = new HTML();
    html.setStyleName("stackItemTopRightInner");
    flexTable.setWidget(0, 2, html);
    flexTable.getCellFormatter().setStyleName(0, 2, "stackItemTopRight");

    ///stop creating top strip      

    //start creating main heading strip

    flexTable.getRowFormatter().setStyleName(0, "stackItemMiddle");
    html = new HTML();
    html.setStyleName("stackItemMiddleLeftInner");
    flexTable.setWidget(1, 0, html);
    flexTable.getCellFormatter().setStyleName(1, 0, "stackItemMiddleLeft");

    HorizontalPanel headerHPanel = new HorizontalPanel();
    headerHPanel.setWidth("100%");
    HTML innerHTML = new HTML(title);
    innerHTML.setStyleName("stackPanelHeader");
    headerHPanel.add(innerHTML);
    headerHPanel.setCellHorizontalAlignment(innerHTML, HasHorizontalAlignment.ALIGN_CENTER);
    headerHPanel.setCellVerticalAlignment(innerHTML, HasVerticalAlignment.ALIGN_MIDDLE);
    html = new HTML(headerHPanel.toString());
    html.setStyleName("stackItemMiddleCenterInner");
    flexTable.getCellFormatter().setStyleName(1, 1, "stackItemMiddleCenter");
    flexTable.setWidget(1, 1, html);

    html = new HTML();
    html.setStyleName("stackItemMiddleRightInner");
    flexTable.setWidget(1, 2, html);
    flexTable.getCellFormatter().setStyleName(1, 2, "stackItemMiddleRight");

    //stop creating main heading strip

    return flexTable.toString();
}

From source file:org.freemedsoftware.gwt.client.widget.CustomTable.java

License:Open Source License

public CustomTable() {
    VerticalPanel vPanel = new VerticalPanel();

    flexTable = new FlexTable();
    flexTable.setStyleName(TABLE_STYLE_NAME);
    flexTable.addClickHandler(this);
    vPanel.add(flexTable);//w ww .  j  a va  2  s  . c  om

    loadingImage = new Image(GWT.getHostPageBaseURL() + "resources/images/custom_table_loading.gif");
    loadingImage.setVisible(false);
    vPanel.add(loadingImage);
    vPanel.setCellHorizontalAlignment(loadingImage, HasHorizontalAlignment.ALIGN_CENTER);

    noItemFound = new Label(noItemsText);
    noItemFound.setVisible(false);
    noItemFound.setStyleName(AppConstants.STYLE_LABEL_NORMAL_ITALIC);
    vPanel.add(noItemFound);
    vPanel.setCellHorizontalAlignment(noItemFound, HasHorizontalAlignment.ALIGN_CENTER);

    nextBtn.addClickHandler(this);
    previousBtn.addClickHandler(this);

    Label perPageLb = new Label("Per Page:");
    perPageDefault = new HTML("25");
    perPage50 = new HTML("<a href=\"javascript:undefined;\">50</a>");
    perPage100 = new HTML("<a href=\"javascript:undefined;\">100</a>");
    perPageDefault.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            perPageDefault.setHTML("" + defaultRows);
            perPage50.setHTML("<a href=\"javascript:undefined;\">50</a>");
            perPage100.setHTML("<a href=\"javascript:undefined;\">100</a>");

            HashMap<String, String>[] tempDate = data;

            clearData();
            maximumRows = defaultRows;
            curMinRow = 0;
            loadData(tempDate, 0);
        }

    });
    perPage50.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            perPage50.setHTML("50");
            perPageDefault.setHTML("<a href=\"javascript:undefined;\">" + defaultRows + "</a>");
            perPage100.setHTML("<a href=\"javascript:undefined;\">100</a>");

            HashMap<String, String>[] tempDate = data;

            clearData();
            maximumRows = 50;
            curMinRow = 0;
            loadData(tempDate, 0);
        }

    });
    perPage100.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            perPage100.setHTML("100");
            perPageDefault.setHTML("<a href=\"javascript:undefined;\">" + defaultRows + "</a>");
            perPage50.setHTML("<a href=\"javascript:undefined;\">50</a>");

            HashMap<String, String>[] tempDate = data;
            clearData();
            maximumRows = 100;
            curMinRow = 0;
            loadData(tempDate, 0);
        }

    });
    // Build button container
    buttonContainer = new HorizontalPanel();
    buttonContainer.setSpacing(2);
    buttonContainer.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    buttonContainer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    buttonContainer.add(new HTML(""));
    buttonContainer.add(previousBtn);
    buttonContainer.add(bLabel);
    // buttonContainer.setCellVerticalAlignment(bLabel,
    // HasVerticalAlignment.ALIGN_MIDDLE);
    buttonContainer.add(nextBtn);
    buttonContainer.add(perPageLb);
    buttonContainer.add(perPageDefault);
    buttonContainer.add(perPage50);
    buttonContainer.add(perPage100);
    // Button container by default is not visible
    buttonContainer.setVisible(false);
    vPanel.add(buttonContainer);

    // Assign handlers to previous and next

    // Set header row information properly
    RowFormatter rowFormatter = flexTable.getRowFormatter();
    rowFormatter.setStyleName(0, TABLE_HEADER_STYLE);

    // Last thing to do, set the widget.
    initWidget(vPanel);
}

From source file:org.freemedsoftware.gwt.client.widget.CustomTable.java

License:Open Source License

/**
 * ` Format table with boiler plate./* w  ww. ja  v a2s. c  o  m*/
 * 
 * @param columnCount
 *            Number of columns present.
 */
public void formatTable(int rowCount) {
    {
        CellFormatter cellFormatter = flexTable.getCellFormatter();
        for (int colIndex = 0; colIndex < columns.size(); colIndex++) {
            cellFormatter.setStyleName(0, colIndex, "headerStyle");
            cellFormatter.setAlignment(0, colIndex, HasHorizontalAlignment.ALIGN_CENTER,
                    HasVerticalAlignment.ALIGN_MIDDLE);
        }
    }

    // Format all the data, if it exists
    try {
        if (rowCount > 0) {
            RowFormatter rowFormatter = flexTable.getRowFormatter();
            CellFormatter cellFormatter = flexTable.getCellFormatter();
            for (int rowIndex = 1; rowIndex <= rowCount; rowIndex++) {
                if (isRowSelected(rowIndex)) {
                    rowFormatter.setStyleName(rowIndex, "rowSelected");
                } else {
                    // Alternating rows
                    if (rowIndex % 2 == 0) {
                        rowFormatter.setStyleName(rowIndex, ALTERNATE_ROW_STYLE);
                    } else {
                        rowFormatter.setStyleName(rowIndex, rowStyle);
                    }
                }
                // Set column alignments and fonts
                for (int colIndex = 0; colIndex < columns.size(); colIndex++) {
                    cellFormatter.setStyleName(rowIndex, colIndex, "customFont");
                    cellFormatter.setAlignment(rowIndex, colIndex, HasHorizontalAlignment.ALIGN_LEFT,
                            HasVerticalAlignment.ALIGN_MIDDLE);
                }
            }
        }
    } catch (Exception e) {

    }
}

From source file:org.gatein.management.gadget.client.Application.java

License:Open Source License

/**
 * @param text/*  w ww . j a va2 s.co  m*/
 * @param image
 * @return
 */
private String getItemString(String text, ImageResource image) {
    // Add the image and text to a horizontal panel
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setSpacing(0);
    hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    hPanel.add(new Image(image));
    HTML headerText = new HTML(text);
    hPanel.add(headerText);
    // Return the HTML string for the panel
    return hPanel.getElement().getString();
}

From source file:org.geomajas.plugin.deskmanager.client.gwt.manager.datalayer.panels.UploadShapefileForm.java

License:Open Source License

public UploadShapefileForm() {
    form = new FormPanel();
    form.setAction(SERVICE_NAME);//from w  w  w.  jav  a2s .c o m
    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    form.setMethod(FormPanel.METHOD_POST);

    // Create a panel to hold all of the form widgets.
    VerticalPanel panel = new VerticalPanel();
    hiddenLayerName = new Hidden("layername");
    panel.add(hiddenLayerName);
    hiddenToken = new Hidden(URL_TOKEN);
    panel.add(hiddenToken);
    form.setWidget(panel);

    // Create a FileUpload widget.
    upload = new FileUpload();
    upload.setName("uploadFormElement");
    upload.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            for (ItemChangedHandler item : handlers) {
                ItemChangedEvent ice = new ItemChangedEvent(null);
                item.onItemChanged(ice);
            }
        }
    });
    HorizontalPanel hp = new HorizontalPanel();
    hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    hp.setSpacing(3);
    com.google.gwt.user.client.ui.Label lblUpload = new com.google.gwt.user.client.ui.Label(
            MESSAGES.uploadShapefileLabelText() + " : ");
    lblUpload.setStyleName("formTitle");
    hp.add(lblUpload);
    hp.add(upload);
    panel.add(hp);

    form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {

        public void onSubmitComplete(SubmitCompleteEvent event) {
            String res = event.getResults().trim();
            if (res.startsWith("<")) {
                int start = res.indexOf(">") + 1;
                int end = res.indexOf("<", start);
                res = res.substring(start, end);
            }
            uploadFinished(res);
        }
    });

    // -------------------------------------------------

    addMember(form);
}

From source file:org.geomajas.quickstart.gwt2.client.widget.layer.LayerLegend.java

License:Open Source License

/**
 * Get a fully build layer legend for a LayersModel.
 *
 * @param layerPopupPanelContent Original HTMLPanel
 * @param layersModel LayersModel of the map
 * @return HTMLPanel fully build legend.
 *//*from  w w w  .  ja  v  a2  s . c o  m*/
private HTMLPanel getLayersLegend(HTMLPanel layerPopupPanelContent, LayersModel layersModel) {

    for (int i = 0; i < mapPresenter.getLayersModel().getLayerCount(); i++) {

        HTMLPanel layer = new HTMLPanel("");
        CheckBox visible = new CheckBox();

        final int finalI = i;
        visible.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                if (mapPresenter.getLayersModel().getLayer(finalI).isMarkedAsVisible()) {
                    mapPresenter.getLayersModel().getLayer(finalI).setMarkedAsVisible(false);
                } else {
                    mapPresenter.getLayersModel().getLayer(finalI).setMarkedAsVisible(true);
                }
            }
        });

        if (mapPresenter.getLayersModel().getLayer(i).isMarkedAsVisible()) {
            visible.setValue(true);
        }

        InlineLabel layerName = new InlineLabel(mapPresenter.getLayersModel().getLayer(i).getTitle());

        layer.add(visible);
        layer.add(layerName);

        layerPopupPanelContent.add(layer);

        ////////////////////////////////
        // Add legend items
        ////////////////////////////////

        Layer legendLayer = mapPresenter.getLayersModel().getLayer(i);

        if (legendLayer instanceof VectorServerLayerImpl) {
            VectorServerLayerImpl serverLayer = (VectorServerLayerImpl) legendLayer;
            String legendUrl = GeomajasServerExtension.getInstance().getEndPointService().getLegendServiceUrl();

            NamedStyleInfo styleInfo = serverLayer.getLayerInfo().getNamedStyleInfo();
            String name = serverLayer.getLayerInfo().getNamedStyleInfo().getName();

            int x = 0;

            for (FeatureTypeStyleInfo sfi : styleInfo.getUserStyle().getFeatureTypeStyleList()) {
                for (RuleInfo rInfo : sfi.getRuleList()) {
                    UrlBuilder url = new UrlBuilder(legendUrl);
                    url.addPath(serverLayer.getServerLayerId());
                    url.addPath(name);
                    url.addPath(x + ".png");
                    x++;

                    HorizontalPanel layout = new HorizontalPanel();
                    layout.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
                    layout.add(new Image(url.toString()));
                    Label labelUi = new Label(rInfo.getName());
                    labelUi.getElement().getStyle().setMarginLeft(5, Style.Unit.PX);
                    layout.add(labelUi);

                    layout.getElement().getStyle().setMarginLeft(20, Style.Unit.PX);
                    layout.getElement().getStyle().setMarginTop(3, Style.Unit.PX);

                    layerPopupPanelContent.add(layout);
                }
            }

        } else if (legendLayer instanceof RasterServerLayerImpl) {
            RasterServerLayerImpl serverLayer = (RasterServerLayerImpl) legendLayer;

            String legendUrl = GeomajasServerExtension.getInstance().getEndPointService().getLegendServiceUrl();
            UrlBuilder url = new UrlBuilder(legendUrl);
            url.addPath(serverLayer.getServerLayerId() + ".png");

            HorizontalPanel layout = new HorizontalPanel();
            layout.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
            layout.add(new Image(url.toString()));
            Label labelUi = new Label("");
            labelUi.getElement().getStyle().setMarginLeft(5, Style.Unit.PX);
            layout.add(labelUi);

            layout.getElement().getStyle().setMarginLeft(20, Style.Unit.PX);
            layout.getElement().getStyle().setMarginTop(3, Style.Unit.PX);

            layerPopupPanelContent.add(layout);
        }

    }

    return layerPopupPanelContent;

}