Example usage for com.google.gwt.user.client.ui HorizontalPanel setHorizontalAlignment

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

Introduction

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

Prototype

public void setHorizontalAlignment(HorizontalAlignmentConstant align) 

Source Link

Document

Sets the default horizontal alignment to be used for widgets added to this panel.

Usage

From source file:com.Administration.client.Administration.java

License:Apache License

/**
 * ?   UI/*from  w w  w .j  a v a2s.  c o  m*/
 */
public void onModuleLoad() {

    label = new HTML(); //   ?  ?  
    label.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    loginLabel = new HTML(); //   ?  ?    
    loginLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    dialog = new PasswordDialog(); //   
    list = new LinkedList<>(); //  ? ? 

    ProvidesKey<LinkData> KEY_PROVIDER = new ProvidesKey<LinkData>() { //    -   ??   
        @Override
        public Object getKey(LinkData item) {
            return item == null ? null : item.getId();
        }
    };
    cellTable = new CellTable<>(KEY_PROVIDER); //  ? 

    dataProvider = new ListDataProvider<>(); //    
    dataProvider.addDataDisplay(cellTable); // ?,   ????   ? 

    sortHandler = new ListHandler<>(list); //  ?
    cellTable.addColumnSortHandler(sortHandler); //  ?   

    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    pager = new SimplePager(SimplePager.TextLocation.CENTER, pagerResources, false, 0, true); //  pager -  ?
    pager.setDisplay(cellTable); // ?,  pager ?  ? 

    initTable(); //   ? 
    cellTable.setWidth("100%");
    cellTable.setHeight("80%");
    cellTable.setAutoHeaderRefreshDisabled(true);
    cellTable.setAutoFooterRefreshDisabled(true);

    //  ?  
    VerticalPanel VP = new VerticalPanel();
    VP.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    VP.add(cellTable);
    VP.add(pager);

    logoutButton = new Button("Logout");

    //  ? 
    HorizontalPanel loginHP = new HorizontalPanel();
    loginHP.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    loginHP.setSpacing(5);
    loginHP.add(loginLabel);
    loginHP.add(logoutButton);

    logoutButton.addClickHandler(new ClickHandler() { //  
        @Override
        public void onClick(ClickEvent event) { //  

            Cookies.removeCookie(cookieName); // ?   

            //  ?  ???
            loginLabel.setHTML("");
            loginLabel.setVisible(false);
            label.setHTML("");
            cellTable.setVisible(false);
            pager.setVisible(false);
            logoutButton.setVisible(false);

            dataProvider.getList().clear(); // ? 

            dialog.show(); //   
            dialog.center();

        }
    });
    logoutButton.setVisible(false);

    //  
    RootPanel.get("Login").add(loginHP);
    RootPanel.get("Data").add(VP);
    RootPanel.get("Data").add(label);

    //    ? 
    cellTable.setVisible(false);
    pager.setVisible(false);

    dialog.Login();
}

From source file:com.algorithmstudy.visualizer.client.AlgorithmVisualizer.java

License:Open Source License

/**
 * This is the entry point method./* w  ww.jav  a2s.c o m*/
 */
public void onModuleLoad() {

    Label programName = new Label("Algorithm Visualizer (v0.2.0)");
    HTML algstudyDotCom = new HTML();
    algstudyDotCom.setHTML("<a href='http://www.algorithmstudy.com'>AlgorithmStudy.com</a>");

    HorizontalPanel titleBarPanel = new HorizontalPanel();
    titleBarPanel.setStyleName(STYLE_TOP_BARS);
    titleBarPanel.setWidth("100%");
    titleBarPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
    titleBarPanel.add(programName);
    titleBarPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
    titleBarPanel.add(algstudyDotCom);

    contentsPanel = new VerticalPanel();
    contentsPanel.setStyleName(STYLE_CONTENTS);
    contentsPanel.setHorizontalAlignment(VerticalPanel.ALIGN_LEFT);
    contentsPanel.setWidth("100%");
    contentsPanel.setHeight("450px");

    Panel algorithmSelectionPanel = new AlgorithmSelectionPanel(contentsPanel);
    algorithmSelectionPanel.setStyleName(STYLE_TOP_BARS);
    algorithmSelectionPanel.setWidth("100%");

    VerticalPanel containingPanel = new VerticalPanel();
    containingPanel.setWidth("850px");
    containingPanel.setStyleName(STYLE_SUPER_CONTAINER);
    containingPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    containingPanel.add(titleBarPanel);
    containingPanel.add(algorithmSelectionPanel);
    containingPanel.add(contentsPanel);

    RootPanel.get().add(containingPanel);
}

From source file:com.algorithmstudy.visualizer.client.sort.BarChartVisualizer.java

License:Open Source License

public BarChartVisualizer(int[] elements, boolean isSingle) {
    setStyleName(STYLE_BAR_CHART);//from w  ww. j  ava2  s  . co m

    HorizontalPanel timePanel = new HorizontalPanel();
    timePanel.setWidth("100%");
    timePanel.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);

    movesLabel = new Label();
    movesLabel.setStyleName(STYLE_MOVES_LABEL);
    movesLabel.setText(MOVES_BASE + "0");
    movesLabel.setWidth("8em");
    numberOfMoves = 0;

    timePanel.add(movesLabel);

    this.add(timePanel);

    chart = new Chart(elements, isSingle);
    this.add(chart);
}

From source file:com.algorithmstudy.visualizer.client.sort.SortingDisplayPanel.java

License:Open Source License

private void doReinitForTwo(SortAlgorithmType algorithm1, SortAlgorithmType algorithm2) {
    clearForReuse();/*from w  w w  .  jav a2s. c  om*/

    sortControls.doReset();

    setHorizontalAlignment(VerticalPanel.ALIGN_LEFT);

    sortControls.doSetNumElementsCB(VisualizerIndex.Second);
    this.add(sortControls);

    setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    visualizer1 = new BarChartVisualizer(valuesToSort, false);
    alg1 = algorithm1.getInstance();
    alg1.setVisualizer(visualizer1);
    alg1.setListToSort(cloneValuesToSort());
    visualizer1.setAlgorithm(alg1);
    timer.addVisualizer(visualizer1);

    alg1Type = algorithm1;

    visualizer2 = new BarChartVisualizer(valuesToSort, false);
    alg2 = algorithm2.getInstance();
    alg2.setVisualizer(visualizer2);
    alg2.setListToSort(cloneValuesToSort());
    visualizer2.setAlgorithm(alg2);
    timer.addVisualizer(visualizer2);

    alg2Type = algorithm2;

    HorizontalPanel visPanel = new HorizontalPanel();
    visPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);

    visPanel.add(visualizer1);
    visPanel.add(visualizer2);

    this.add(visPanel);
}

From source file:com.allen_sauer.gwt.log.client.DivLogger.java

License:Apache License

/**
 * @deprecated//w w  w.  j  a v a  2s.c o m
 */
@Deprecated
private FocusPanel makeHeader() {
    FocusPanel header;
    header = new FocusPanel();
    HorizontalPanel masterPanel = new HorizontalPanel();
    masterPanel.setWidth("100%");
    header.add(masterPanel);

    final Label titleLabel = new Label("gwt-log", false);
    titleLabel.setStylePrimaryName(LogClientBundle.INSTANCE.css().logTitle());

    HorizontalPanel buttonPanel = new HorizontalPanel();
    levelButtons = new Button[levels.length];
    for (int i = 0; i < levels.length; i++) {
        final int level = levels[i];
        levelButtons[i] = new Button(LogUtil.levelToString(level));
        buttonPanel.add(levelButtons[i]);
        levelButtons[i].addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                ((Button) event.getSource()).setFocus(false);
                Log.setCurrentLogLevel(level);
            }
        });
    }

    Button clearButton = new Button("Clear");
    clearButton.addStyleName(LogClientBundle.INSTANCE.css().logClearButton());
    DOM.setStyleAttribute(clearButton.getElement(), "color", "#00c");
    clearButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            ((Button) event.getSource()).setFocus(false);
            Log.clear();
        }
    });
    buttonPanel.add(clearButton);

    Button aboutButton = new Button("About");
    aboutButton.addStyleName(LogClientBundle.INSTANCE.css().logClearAbout());
    aboutButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            ((Button) event.getSource()).setFocus(false);

            Log.diagnostic("\n" //
                    + "gwt-log-" + Log.getVersion() //
                    + " - Runtime logging for your Google Web Toolkit projects\n" + //
            "Copyright 2007 Fred Sauer\n" + //
            "The original software is available from:\n" + //
            "\u00a0\u00a0\u00a0\u00a0http://allen-sauer.com/gwt/\n", null);
        }
    });

    Button closeButton = new Button("X");
    closeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            logDockPanel.removeFromParent();
        }
    });

    masterPanel.add(titleLabel);
    masterPanel.add(buttonPanel);
    masterPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    masterPanel.add(aboutButton);
    masterPanel.add(closeButton);

    masterPanel.setCellHeight(titleLabel, "100%");
    masterPanel.setCellWidth(titleLabel, "50%");
    masterPanel.setCellWidth(aboutButton, "50%");

    new MouseDragHandler(titleLabel);

    return header;
}

From source file:com.audata.client.AuDoc.java

License:Open Source License

/**
 * Builds the menu bar panel/*from   w  w  w  .j av  a  2 s  .  c o  m*/
 * @return HorizontalPanel containing the menu bar
 */
private HorizontalPanel buildMenu() {
    HorizontalPanel menu = new HorizontalPanel();
    menu.addStyleName("menu");
    menu.setWidth("100%");
    menu.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
    menu.setVerticalAlignment(HasAlignment.ALIGN_BOTTOM);
    menu.setSpacing(4);

    CaptionButton cb = new CaptionButton();
    cb.setImageUrl("images/48x48/home.gif");
    cb.setCaptionText(LANG.home_Text());
    cb.setOrientation(DockPanel.SOUTH);
    cb.addClickListener(new MenuClickListener(this, AuDoc.SECTION_HOME));
    cb.setTitle(LANG.home_title_Text());
    menu.add(cb);

    CaptionButton cb_1 = new CaptionButton();
    cb_1.setImageUrl("images/48x48/search.gif");
    cb_1.setCaptionText(LANG.search_Text());
    cb_1.setOrientation(DockPanel.SOUTH);
    cb_1.addClickListener(new MenuClickListener(this, AuDoc.SECTION_SEARCH));
    cb_1.setTitle(LANG.search_title_Text());
    menu.add(cb_1);

    CaptionButton cb_2 = new CaptionButton();
    cb_2.addCaptionStyleName("nowrap");
    cb_2.setOrientation(DockPanel.SOUTH);
    cb_2.setImageUrl("images/48x48/newrec.gif");
    cb_2.setCaptionText(LANG.newrec_Text());
    cb_2.addClickListener(new MenuClickListener(this, AuDoc.SECTION_NEW));
    cb_2.setTitle(LANG.newrec_title_Text());
    menu.add(cb_2);

    CaptionButton cb_3 = new CaptionButton();
    cb_3.setImageUrl("images/48x48/reports.gif");
    cb_3.setCaptionText(LANG.report_Text());
    cb_3.setOrientation(DockPanel.SOUTH);
    cb_3.addClickListener(new MenuClickListener(this, AuDoc.SECTION_REPORT));
    cb_3.setTitle(LANG.report_title_Text());
    menu.add(cb_3);

    CaptionButton cb_4 = new CaptionButton();
    cb_4.setImageUrl("images/48x48/checkout.gif");
    cb_4.setCaptionText(LANG.rapid_title_Text());
    cb_4.setOrientation(DockPanel.SOUTH);
    cb_4.addClickListener(new MenuClickListener(this, AuDoc.SECTION_RAPID));
    cb_4.setTitle(LANG.rapid_title_Text());
    menu.add(cb_4);

    this.adminButton = new CaptionButton();
    this.adminButton.setImageUrl("images/48x48/admin.gif");
    this.adminButton.setCaptionText(LANG.admin_Text());
    this.adminButton.setOrientation(DockPanel.SOUTH);
    this.adminButton.setVisible(false);
    this.adminButton.addClickListener(new MenuClickListener(this, AuDoc.SECTION_ADMIN));
    this.adminButton.setTitle(LANG.admin_title_Text());
    menu.add(this.adminButton);
    menu.setCellWidth(this.adminButton, "100%");
    menu.setCellHorizontalAlignment(this.adminButton, HasAlignment.ALIGN_RIGHT);

    return menu;
}

From source file:com.audata.client.feedback.SimpleDialog.java

License:Open Source License

private SimpleDialog(int type, String title, String message, ResponseListener listener) {
    this.listener = listener;
    this.type = type;
    this.setText(title);
    this.addStyleName("audoc-simpleDialog");

    DockPanel main = new DockPanel();

    main.setSpacing(4);/*from w ww  . ja v  a 2  s. c  om*/
    HorizontalPanel butPanel = new HorizontalPanel();
    butPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);
    butPanel.setSpacing(4);
    switch (type) {
    case SimpleDialog.TYPE_ERROR:
        main.add(new Image("images/48x48/error.gif"), DockPanel.WEST);
        this.close = new Button("Close");
        this.close.addClickListener(this);
        butPanel.add(this.close);
        break;
    case SimpleDialog.TYPE_MESSAGE:
        main.add(new Image("images/48x48/udf.gif"), DockPanel.WEST);
        this.close = new Button("Close");
        this.close.addClickListener(this);
        butPanel.add(this.close);
        break;
    case SimpleDialog.TYPE_QUERY:
        main.add(new Image("images/48x48/help.gif"), DockPanel.WEST);
        this.ok = new Button("Ok");
        this.ok.addClickListener(this);
        this.cancel = new Button("Cancel");
        this.cancel.addClickListener(this);
        butPanel.add(this.ok);
        butPanel.add(this.cancel);
        break;
    }
    VerticalPanel p = new VerticalPanel();
    p.setSpacing(15);
    p.add(new Label(message));
    p.add(butPanel);
    p.setCellHorizontalAlignment(butPanel, HasAlignment.ALIGN_RIGHT);
    main.add(p, DockPanel.EAST);
    this.setWidget(main);
    this.setPopupPosition(0, 0);
}

From source file:com.audata.client.rapidbooking.RapidBookingDialog.java

License:Open Source License

public RapidBookingDialog() {
    setText(CONSTANTS.rapid_title_Text());
    DockPanel outer = new DockPanel();
    outer.setSpacing(4);/* w ww  .java 2s  .  c  om*/

    outer.add(new Image("images/48x48/checkout.gif"), DockPanel.WEST);

    VerticalPanel form = new VerticalPanel();
    form.setSpacing(4);

    this.checkin = new RadioButton("ActionGroup", CONSTANTS.check_in_Text());
    this.checkin.addClickListener(this);
    this.checkin.setChecked(true);
    this.checkin.addStyleName("audoc-label");
    form.add(this.checkin);
    this.checkout = new RadioButton("ActionGroup", CONSTANTS.checkout_Text());
    this.checkout.addClickListener(this);
    this.checkout.addStyleName("audoc-label");
    form.add(this.checkout);

    this.userPanel = new HorizontalPanel();
    Label l = new Label(CONSTANTS.user_Text());
    l.addStyleName("audoc-label");
    userPanel.add(l);
    this.users = new ListBox();
    userPanel.add(this.users);
    userPanel.setCellWidth(l, "100px");
    this.userPanel.setVisible(false);
    form.add(this.userPanel);

    HorizontalPanel recnumPanel = new HorizontalPanel();
    Label r = new Label(CONSTANTS.rec_num_Text());
    r.addStyleName("audoc-label");
    recnumPanel.add(r);
    this.recnum = new TextBox();
    recnumPanel.add(this.recnum);
    recnumPanel.setCellWidth(r, "100px");
    form.add(recnumPanel);

    HorizontalPanel butPanel = new HorizontalPanel();
    butPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    butPanel.setSpacing(4);
    this.closeButton = new Button(CONSTANTS.close_Text());
    this.closeButton.addClickListener(this);
    butPanel.add(this.closeButton);

    this.okButton = new Button(CONSTANTS.ok_Text());
    this.okButton.addClickListener(this);
    butPanel.add(this.okButton);
    //       butPanel.setWidth("100%");
    form.add(butPanel);

    String template = "<span class=\"rapid_processed\">#0 #1</span>";
    this.processed = new HTMLButtonList("images/16x16/treerec.gif", template, false);
    this.processed.setWidth("100%");
    this.processed.setHeight("75px");
    form.add(this.processed);

    outer.add(form, DockPanel.NORTH);
    if (AuDoc.state.getItem("isAdmin") == "true") {
        this.getUsers();
    } else {
        String username = (String) AuDoc.state.getItem("username");
        String forename = (String) AuDoc.state.getItem("forename");
        String surname = (String) AuDoc.state.getItem("surname");
        this.users.addItem(surname + ", " + forename, username);
    }
    this.setWidget(outer);
}

From source file:com.audata.client.record.RecordListPanel.java

License:Open Source License

private Panel buildMenu() {
    HorizontalPanel menuContainer = new HorizontalPanel();
    menuContainer.addStyleName("audoc-commandPanel");
    menuContainer.setWidth("100%");
    HorizontalPanel menu = new HorizontalPanel();
    menuContainer.add(menu);//from   w ww .  jav  a2  s .  co m
    menu.setSpacing(4);
    //menu.addStyleName("audoc-commandPanel");
    //menu.setWidth("100%");
    menu.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);

    //add Refresh button
    //CaptionButton refreshButton = new CaptionButton("images/16x16/refresh.gif", "Refresh", CaptionButton.CAPTION_EAST);
    CaptionButton refreshButton = new CaptionButton();
    refreshButton.setCaptionText(LANG.refresh_Text());
    refreshButton.setImageUrl("images/16x16/refresh.gif");
    refreshButton.addClickListener(new CommandClickListener(this, CommandClickListener.COMMAND_REFRESH));
    refreshButton.setTitle(LANG.refresh_title_Text());
    menu.add(refreshButton);

    //add print button
    //CaptionButton printButton = new CaptionButton("images/16x16/print.gif", "Print", CaptionButton.CAPTION_EAST);
    CaptionButton printButton = new CaptionButton();
    printButton.setCaptionText(LANG.print_Text());
    printButton.setImageUrl("images/16x16/print.gif");
    printButton.addClickListener(new CommandClickListener(this, CommandClickListener.COMMAND_PRINT));
    printButton.setTitle(LANG.print_title_Text());
    menu.add(printButton);

    Label pagesLabel = new Label(LANG.page_Text() + ": ");
    pagesLabel.addStyleName("audoc-label");
    menu.add(pagesLabel);
    menu.setCellVerticalAlignment(pagesLabel, HasVerticalAlignment.ALIGN_MIDDLE);
    this.pages = new ListBox();
    this.pages.addChangeListener(this);
    menu.add(this.pages);
    menu.setCellVerticalAlignment(this.pages, HasVerticalAlignment.ALIGN_MIDDLE);
    return menuContainer;
}

From source file:com.dawg6.gwt.client.ApplicationPanel.java

License:Open Source License

public static DialogBox showDialogBox(String title, IsWidget component, int buttons,
        final DialogBoxResultHandler handler) {
    // Create the popup dialog box
    final DialogBox dialogBox = createDialogBox();
    dialogBox.setText(title);/*from ww  w . j a  v  a2s  .co m*/
    dialogBox.setAnimationEnabled(true);
    dialogBox.setModal(false);
    FlexTable table = new FlexTable();
    table.setWidget(0, 0, component);
    dialogBox.setWidget(table);

    HorizontalPanel row = new HorizontalPanel();
    row.setSpacing(5);
    row.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    row.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    table.setWidget(1, 0, row);

    boolean firstButton = true;

    if (buttons == 0)
        buttons = OK;

    for (final ButtonInfo b : allButtons) {
        if ((buttons > 0) && ((buttons & b.id) != 0)) {
            final Button button = createDialogBoxButton(b.label);

            button.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    dialogBox.hide();

                    if (handler != null)
                        handler.dialogBoxResult(b.id);
                }
            });
            row.add(button);

            if (firstButton) {
                button.setFocus(true);
                firstButton = false;
            }
        }
    }

    dialogBox.center();

    return dialogBox;
}