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

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

Introduction

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

Prototype

public HorizontalPanel() 

Source Link

Document

Creates an empty horizontal panel.

Usage

From source file:com.company.application.carrental.client.view.screens.DriverApplicationTab.java

private HorizontalPanel buildJobPrefPanel() {
    CheckBox temporaryCheckBox = new CheckBox();
    temporaryCheckBox.setBoxLabel("Temporary");

    CheckBox permanentCheckBox = new CheckBox();
    permanentCheckBox.setBoxLabel("Permanent");

    CheckBox adhocCheckBox = new CheckBox();
    adhocCheckBox.setBoxLabel("Adhoc");

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.add(temporaryCheckBox);
    horizontalPanel.add(permanentCheckBox);
    horizontalPanel.add(adhocCheckBox);/*from   w w  w . j ava 2 s  .co  m*/
    return horizontalPanel;
}

From source file:com.connoisseur.menuapp.client.Authenticate.java

/** This is essentially the main method for the menu app. */
public static void go() {
    storage.clear(); // uncomment to completely reset app

    final DialogBox startupBox = new DialogBox(); // movable box that contains widgets
    startupBox.setAnimationEnabled(true);
    final VerticalPanel startupPanel = new VerticalPanel(); // can contain other widgets
    startupPanel.addStyleName("marginPanel"); // interacts with Menuapp.css
    startupPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    // check to see if storage is supported
    if (storage != null) {

        // load viewer if license key and restID have been submitted before
        if (storage.getLength() > 0) {
            Viewer.loadViewer();//w w w .j  a v a 2  s .  co  m
        }

        // otherwise load authentication UI in order to receive input
        else {
            final Button submitButton = new Button("Submit"); // "Submit" appears on button
            submitButton.addStyleName("myButton"); // interacts with Menuapp.css
            final HorizontalPanel buttonPanel = new HorizontalPanel(); // used to center button
            buttonPanel.addStyleName("marginlessPanel");

            // license widgets
            final Label licenseErrorLabel = new Label(); // dynamic text
            licenseErrorLabel.addStyleName("errorLabel"); // interacts with Menuapp.css
            final TextBox submitLicense = new TextBox(); // user can input text using this
            submitLicense.setText("license key..."); // default text to be seen on load

            // restaurant ID widgets
            final Label restErrorLabel = new Label();
            restErrorLabel.addStyleName("errorLabel");
            final TextBox submitRestID = new TextBox();
            submitRestID.setText("restaurant ID...");

            // organize UI
            startupPanel.add(new HTML("Please enter your license key:"));
            startupPanel.add(submitLicense);
            startupPanel.add(licenseErrorLabel);
            startupPanel.add(new HTML("<br>Please enter your restaurant ID:"));
            startupPanel.add(submitRestID);
            startupPanel.add(restErrorLabel);
            startupPanel.add(new HTML("<br>"));
            buttonPanel.add(submitButton);
            startupPanel.add(buttonPanel);

            // setup startupBox, which is what will be seen by the user
            startupBox.setWidget(startupPanel); // connects the two widgets
            startupBox.center(); // also shows the box

            // focus the cursor on submitLicense when startupBox appears
            submitLicense.setFocus(true);
            submitLicense.selectAll();

            // create a handler for submitButton, submitLicense and submitRestID
            class MyHandler implements ClickHandler, KeyUpHandler {
                /** Fired when the user clicks submit. */
                public void onClick(ClickEvent event) {
                    submit();
                }

                /** Fired when the user presses Enter in a submit field. */
                public void onKeyUp(KeyUpEvent event) {
                    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
                        submit();
                }

                /** Checks the submitted license key and restaurant ID for validity. Loads Viewer if valid. */
                private void submit() {
                    String license = submitLicense.getText(); // unused for now
                    String restID = submitRestID.getText(); // not sure how to validate yet
                    int returnFlag = 0; // so that both tests can be done
                    licenseErrorLabel.setText("");
                    restErrorLabel.setText("");

                    // validate license
                    String result = FieldVerifier.isValidLicenseKey(license); // from FieldVerifier.java
                    if (!result.equals("")) { // error
                        licenseErrorLabel.setText("You submitted an invalid license key.");
                        submitLicense.selectAll();
                        returnFlag = 1;
                    }

                    // validate restID
                    result = FieldVerifier.isValidRestaurantID(restID);
                    if (!result.equals("")) { // error
                        restErrorLabel.setText("You submitted an invalid restaurant ID.");
                        submitRestID.selectAll();
                        returnFlag = 1;
                    }

                    // don't do anything until the errors are resolved
                    if (returnFlag == 1)
                        return;

                    // clean up
                    submitButton.setEnabled(false);
                    submitLicense.setEnabled(false);
                    submitRestID.setEnabled(false);
                    startupBox.hide();

                    // set up storage
                    storage.setItem("license", license); // secret key for security
                    storage.setItem("restID", restID); // used for almost every call to the backend

                    // show menu
                    Viewer.loadViewer();
                }
            } // MyHandler

            // attach the handler
            final MyHandler handler = new MyHandler();
            submitButton.addClickHandler(handler);
            submitLicense.addKeyUpHandler(handler);
            submitRestID.addKeyUpHandler(handler);
        } // else load authentication UI

    } // if storage supported

    // storage is not supported, so report error
    else {
        startupPanel.add(new HTML("<font color=red>The app will not function because local<br>"
                + "storage is not supported on this platform.</font>"));
        startupBox.setWidget(startupPanel);
        startupBox.center();
    }
}

From source file:com.controlj.addon.gwttree.client.Dialog.java

License:Open Source License

private static Widget createButtonPanel(DialogBox dialogBox, Handler handler) {
    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setSpacing(15);// w  w  w  .j  av a2 s.  c o  m
    Button okButton = createButton("OK", dialogBox, false, handler);
    buttonPanel.add(okButton);
    Button cancelButton = createButton("Cancel", dialogBox, true, handler);
    buttonPanel.add(cancelButton);
    handler.setupButtons(okButton, cancelButton);
    return buttonPanel;
}

From source file:com.controlj.addon.gwttree.client.TreeManager.java

License:Open Source License

/**<!====== createPanel ===================================================>
   Returns a panel that displays the tree.  When the tree options are changed,
   the panel is updated to hold the new tree, so this method does not need to
   be called more than once./*from w ww .j  a  v  a  2  s .  c o m*/
<!=======================================================================>*/
public Widget createPanel() {
    Panel treePanel = new VerticalPanel();
    treePanel.setStylePrimaryName("tree-treePanel");

    // create a panel for the resulting tree(s) now (it's used below)
    // but don't add it to the panel until the end (so it's at the bottom)
    resultPanel = new HorizontalPanel();

    Button optionsButton = new Button("Change Tree Options...");
    optionsButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            options.showDialog();
        }
    });
    treePanel.add(optionsButton);

    resetResultPanel("Getting tree root node...");
    requestTree();

    treePanel.add(resultPanel);
    return treePanel;
}

From source file:com.controlj.addon.gwttree.client.TreeOptions.java

License:Open Source License

public void showDialog() {
    VerticalPanel dialogContents = new VerticalPanel();
    dialogContents.setSpacing(4);/* w w w .j  ava2s .c om*/

    // Add the tree type radio buttons
    RadioButton dynamicChoice = createTreeChoice("treeTypeGroup", "Dynamic Tree", false);
    RadioButton staticChoice = createTreeChoice("treeTypeGroup", "Static Tree", true);
    if (state.isStaticTree)
        staticChoice.setValue(true);
    else
        dynamicChoice.setValue(true);
    dialogContents.add(dynamicChoice);
    dialogContents.add(staticChoice);

    // Add filtering support
    dialogContents.add(new Label("Filter by trend name (leave empty to not filter)"));
    HorizontalPanel sourcesPanel = new HorizontalPanel();
    sourcesPanel.setSpacing(10);
    final ListBox sourceListBox = new ListBox(true);
    sourceListBox.setSize("10em", "5em");
    for (String sourceName : state.sourceNames)
        sourceListBox.addItem(sourceName);
    sourcesPanel.add(sourceListBox);
    VerticalPanel sourcesButtonPanel = new VerticalPanel();
    sourcesButtonPanel.add(new Button("Add...", new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            final TextBox textBox = new TextBox();
            Dialog.showInputDialog("Add Filter", textBox, new Dialog.Handler() {
                @Override
                public void setupButtons(final Button ok, final Button cancel) {
                    textBox.addKeyPressHandler(new KeyPressHandler() {
                        @Override
                        public void onKeyPress(KeyPressEvent keyPressEvent) {
                            if (keyPressEvent.getCharCode() == (char) 13)
                                ok.click();
                            else if (keyPressEvent.getCharCode() == (char) 27)
                                cancel.click();
                        }
                    });
                }

                @Override
                public void dialogClosed(boolean wasCancelled) {
                    String name = textBox.getText().trim();
                    if (!wasCancelled && !name.isEmpty()) {
                        state.sourceNames.add(name);
                        sourceListBox.addItem(name);
                    }
                }
            });
            textBox.setFocus(true);
        }
    }));
    sourcesButtonPanel.add(new Button("Remove", new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            int count = sourceListBox.getItemCount();
            for (int i = count - 1; i >= 0; i--)
                if (sourceListBox.isItemSelected(i)) {
                    state.sourceNames.remove(sourceListBox.getItemText(i));
                    sourceListBox.removeItem(i);
                }
        }
    }));
    sourcesPanel.add(sourcesButtonPanel);
    dialogContents.add(sourcesPanel);

    final State originalState = state.copy();
    Dialog.showInputDialog("Tree Options", dialogContents, new Dialog.Handler() {
        @Override
        public void setupButtons(Button ok, Button cancel) {
        }

        @Override
        public void dialogClosed(boolean wasCancelled) {
            if (wasCancelled)
                state = originalState;
            else if (!state.equals(originalState))
                handler.optionsChanged(TreeOptions.this);
        }
    });
}

From source file:com.controlj.addon.gwttree.client.TreeOptions.java

License:Open Source License

private Widget createButtonPanel(DialogBox dialogBox, State originalState) {
    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setSpacing(15);//from   ww w  . j a  va  2s .co  m
    Button okButton = createButton("OK", dialogBox, false, originalState);
    buttonPanel.add(okButton);
    Button cancelButton = createButton("Cancel", dialogBox, true, null);
    buttonPanel.add(cancelButton);
    return buttonPanel;
}

From source file:com.cristal.storm.prototype.client.mvp.view.MainPageView.java

License:Apache License

@Inject
public MainPageView() {
    MCECell.Images images = GWT.create(MCECell.Images.class);

    MCECell textCell = new MCECell(images.icon());

    ProvidesKey<MCE> keyProvider = new ProvidesKey<MCE>() {
        public Object getKey(MCE item) {
            // Always do a null check.
            return (item == null) ? null : item.getURI();
        }/*from w ww.  j a  va 2s .c  o m*/
    };

    mceCollectionDraggable = new DragAndDropCellList<MCE>(textCell, DEFAULT_RESOURCES, keyProvider);

    mceSelectionModel = new SingleSelectionModel<MCE>(keyProvider);
    mceCollectionDraggable.setSelectionModel(mceSelectionModel);

    // mceCollectionDraggable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);

    widget = uiBinder.createAndBindUi(this);

    HorizontalPanel horzPanel = new HorizontalPanel();

    // Push the data into the widget.

    // TODO Remove this hardcoded definition of tags
    Set<String> mcetags1 = new TreeSet<String>();
    mcetags1.add("search");
    mcetags1.add("mail");
    mcetags1.add("travel");

    // TODO Remove this hardcoded definition of MCE
    MCE mce = new MCE("kayak.com", mcetags1);
    // MCE mce3 = new MCE("kayak.com", mcetags2);
    mceListVisible = new Vector<MCE>();
    mceListVisible.add(mce);
    mceCollectionDraggable.setRowData(0, mceListVisible);
    mceSelectionModel.setSelected(mce, true);

    // The cell of this CellList are only draggable
    mceCollectionDraggable.setCellDraggableOnly();

    // setup the drag operation
    DraggableOptions options = new DraggableOptions();
    // use a clone of the original cell as drag helper
    options.setHelper(HelperType.CLONE);
    // set the opacity of the drag helper
    options.setOpacity((float) 0.9);
    // append the drag helper to the body element
    options.setAppendTo("body");
    // configure the drag operations of the cell list with this options
    mceCollectionDraggable.setDraggableOptions(options);

    /**
     * Create a droppable CellList
     */
    final FlowPanel aGwtPanel = new FlowPanel();
    aGwtPanel.add(new Label("test"));
    DroppableWidget<FlowPanel> droppablePanel = new DroppableWidget<FlowPanel>(aGwtPanel);
    // configure the drop behaviour (see next paragraph)
    droppablePanel.setTolerance(DroppableTolerance.POINTER);

    droppablePanel.getOriginalWidget();

    droppablePanel.addDropHandler(new DropEventHandler() {

        public void onDrop(DropEvent event) {
            // retrieve the droppable widget
            DroppableWidget<FlowPanel> droppableLabel = (DroppableWidget<FlowPanel>) event.getDroppableWidget();

            // retrieve the dropped draggable widget (we assume it is a
            // draggable label)
            DraggableWidget<Label> draggableLabel = (DraggableWidget<Label>) event.getDraggableWidget();

            Label toto = (Label) (droppableLabel.getOriginalWidget().getWidget(0));
            Label toto2 = (Label) (droppableLabel.getOriginalWidget().getWidget(0));
            aGwtPanel.add(toto2);
            // toto.setText("Let's eat!!!!");

            // remove the draggabeLable
            // draggableLabel.removeFromParent();
            // aGwtPanel.add( new
            // Label(event.getDraggableWidget().toString()));
            // event.getDraggableWidget().removeFromParent();

            aGwtPanel.add(new Label("just dragged item1"));
            aGwtPanel.add(new Label("just dragged item2"));
        }
    });

    horzPanel.add(droppablePanel);

    centerAbsPanel.add(horzPanel);

}

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);/*ww w  .ja v  a2s  .  com*/
    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;
}

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

License:Open Source License

public static AsyncTaskHandler showWaitDialogBox(String title, String message) {

    VerticalPanel panel = new VerticalPanel();
    HorizontalPanel row = new HorizontalPanel();
    row.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    row.setSpacing(5);//from w  w  w .ja v a  2s.com
    panel.add(row);

    Image image = new Image("images/Progressbar.gif");
    image.setSize("64px", "16px");
    row.add(image);

    if (message != null) {
        Label label = new Label(message);
        row.add(label);
    }

    final DialogBox dialogBox = showDialogBox(title, panel, -1, null);

    return new AsyncTaskHandler() {

        @Override
        public void taskCompleted() {
            dialogBox.hide();
        }
    };

}

From source file:com.dawg6.gwt.client.widgets.AbstractSearchable.java

License:Open Source License

protected AbstractSearchable(ValueFactory<T> factory, Comparator<T> sorter) {

    captionPanel = new CaptionPanel("Caption");
    initWidget(captionPanel);/*from www . j ava2  s.com*/

    VerticalPanel verticalPanel_5 = new VerticalPanel();
    captionPanel.setContentWidget(verticalPanel_5);
    verticalPanel_5.setSize("5cm", "3cm");

    HorizontalPanel row = new HorizontalPanel();
    row.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    row.setSpacing(5);
    verticalPanel_5.add(row);

    Label label = new Label("Filter:");
    row.add(label);

    suggestBox = new TextBox();
    row.add(suggestBox);
    suggestBox.setVisibleLength(20);

    suggestBox.addKeyUpHandler(new KeyUpHandler() {

        @Override
        public void onKeyUp(KeyUpEvent event) {
            setFilter();
        }
    });

    Button button = new Button("Clear");
    row.add(button);
    button.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            suggestBox.setText("");
            setFilter();
        }
    });

    listBox = new CellList<T>(getCell());

    scroll = new ScrollPanel();
    scroll.setWidget(listBox);

    this.list = new Vector<T>();
    this.dataProvider = new ListDataProvider<T>();
    this.dataProvider.addDataDisplay(listBox);
    verticalPanel_5.add(scroll);
    listBox.setPageSize(Integer.MAX_VALUE);

    listBox.setSize("300px", "300px");
    selectionModel = new SingleSelectionModel<T>();
    listBox.setSelectionModel(selectionModel);

    selectionModel.addSelectionChangeHandler(new Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            selectionChanged(getSelectedValue());

        }
    });

    this.factory = factory;
    this.sorter = sorter;
}