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

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

Introduction

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

Prototype

public void setSpacing(int spacing) 

Source Link

Document

Sets the amount of spacing between this panel's cells.

Usage

From source file:com.cognitivemedicine.metricsdashboard.client.dialogs.AuthenticationDialog.java

License:Apache License

/**
 * Creates a consistent sized panel for form elements
 * /*from   w  w  w . j av  a 2 s  .co m*/
 * @param fieldName
 * @param widget
 * @return
 */
private HorizontalPanel createFormPanel(String fieldName, FocusWidget widget) {
    HorizontalPanel panel = new HorizontalPanel();
    panel.setSpacing(4);
    HTML nameLabel = new HTML(fieldName + ": ");
    nameLabel.setWidth("115px");
    // Weird workaround - the PasswordTextBoxes render wider than the ListBoxes, even when set to
    // the same size
    if (widget instanceof ListBox) {
        widget.setWidth("325px");
    } else {
        widget.setWidth("315px");
    }

    panel.add(nameLabel);
    panel.add(widget);
    panel.setCellHorizontalAlignment(nameLabel, HasHorizontalAlignment.ALIGN_RIGHT);
    return panel;
}

From source file:com.cognitivemedicine.metricsdashboard.client.dialogs.CreateDashboardDialog.java

License:Apache License

private void init() {
    this.setWidth("375px");
    this.setText("Create New Dashboard");

    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.add(new HTML("<b>Name:</b>"));
    nameBox = new TextBox();
    nameBox.getElement().setId("createDashboardNameTextBox");
    nameBox.setWidth("290px");
    nameBox.addKeyUpHandler(new KeyUpHandler() {
        @Override/*w w  w .j  a  va 2 s .  co m*/
        public void onKeyUp(KeyUpEvent event) {
            createButton.setEnabled(nameBox.getValue().length() > 0);
        }
    });
    notesArea = new TextArea();
    notesArea.setWidth("290px");
    notesArea.getElement().setId("createDashboardNotesArea");
    dialogVPanel.add(nameBox);
    dialogVPanel.add(new HTML("<br><b>Dashboard Notes:</b>"));
    dialogVPanel.add(notesArea);
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
    // // Add a close button at the bottom of the dialog
    Image image = new Image(MdConstants.IMG_OK_CHECK);
    image.setSize(MdConstants.IMG_SIZE, MdConstants.IMG_SIZE);
    createButton = new PushButton(image);
    createButton.setEnabled(false);
    createButton.setSize(MdConstants.IMG_SIZE, MdConstants.IMG_SIZE);
    createButton.getElement().setId("createDashboardOkButton");
    createButton.setTitle("Create new dashboard");
    createButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            createButtonClicked();
        }
    });
    image = new Image(MdConstants.IMG_CANCEL_X);
    image.setSize(MdConstants.IMG_SIZE, MdConstants.IMG_SIZE);
    cancelButton = new PushButton(image);
    cancelButton.getElement().setId("createDashboardCancelButton");
    cancelButton.setSize(MdConstants.IMG_SIZE, MdConstants.IMG_SIZE);
    cancelButton.setTitle("Cancel");
    cancelButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            CreateDashboardDialog.this.hide();
        }
    });

    HorizontalPanel dialogButtonPanel = new HorizontalPanel();
    dialogButtonPanel.setSpacing(8);
    dialogButtonPanel.add(createButton);
    dialogButtonPanel.add(cancelButton);
    dialogVPanel.add(dialogButtonPanel);

    dialogVPanel.setSpacing(4);
    dialogVPanel.setCellHorizontalAlignment(dialogButtonPanel, HasHorizontalAlignment.ALIGN_CENTER);
    dialogVPanel.setCellVerticalAlignment(dialogButtonPanel, HasVerticalAlignment.ALIGN_MIDDLE);
    this.setWidget(dialogVPanel);
    this.setGlassEnabled(true);
    this.setModal(true);
    this.center();
    nameBox.setFocus(true);
}

From source file:com.cognitivemedicine.metricsdashboard.client.dialogs.DeleteDashboardDialog.java

License:Apache License

private void init() {
    this.setWidth("300px");
    this.setText("Delete Dashboard?");

    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.setWidth("300px");
    dialogVPanel.setSpacing(8);/*from w  w w  .  j  a  v  a  2s.c  o m*/
    dialogVPanel.add(new HTML("Are you sure you'ld like to delete this Dashboard?</br></br><b>"
            + dashboardListBox.getItemText(dashboardListBox.getSelectedIndex()) + "</b>"));
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    Image image = new Image(MdConstants.IMG_OK_CHECK);
    image.setSize(MdConstants.IMG_SIZE, MdConstants.IMG_SIZE);
    PushButton okButton = new PushButton(image);
    okButton.getElement().setId("deleteDashboardOkButton");
    okButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            String dashboardId = dashboardListBox.getValue(dashboardListBox.getSelectedIndex());
            parent.getController().deleteDashboard(dashboardId);
            DeleteDashboardDialog.this.hide();
        }
    });

    image = new Image(MdConstants.IMG_CANCEL_X);
    image.setSize(MdConstants.IMG_SIZE, MdConstants.IMG_SIZE);
    PushButton cancelButton = new PushButton(image);
    cancelButton.getElement().setId("deleteDashboardCancelButton");
    cancelButton.setTitle("Cancel");
    cancelButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            DeleteDashboardDialog.this.hide();
        }
    });

    HorizontalPanel dialogButtonPanel = new HorizontalPanel();
    dialogButtonPanel.setSpacing(4);
    dialogButtonPanel.add(okButton);
    dialogButtonPanel.add(cancelButton);
    dialogVPanel.add(dialogButtonPanel);

    this.setWidget(dialogVPanel);
    this.setModal(true);
    this.setGlassEnabled(true);
    this.center();
}

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

private ADKPanel buildBasicTab() {
    formPanel = new ADKPanel("basicPanel");

    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.setHeight("700");
    verticalPanel.setSpacing(2);//from   w  w w.  j  a  v  a 2  s .  c o m

    saveApplicationButton = new ADKButton("saveApplicationButton", "Save", new ADKButtonListener() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            super.componentSelected(ce);

            DriverMasterClientDto masterClientDto = getApplicationFormData();

            mediator.saveDriverApplication(masterClientDto);
        }
    });

    ToolBar toolBar = new ToolBar();
    // ADKCustomHelpList adkCustomHelpList =
    // new ADKCustomHelpList("driverApplicationHelpList", "Search Driver",
    // "car_rental", "driver_master", false, 100, 200);
    // toolBar.add(adkCustomHelpList);

    List<String> outputColumns = getDriverHelplistColumns();

    driverAppHelpList = new ADKCustomHelpList("driverApplicationHelpList", "Search Driver", "car_rental",
            "driver_master", "Driver_FullName", "Driver_FullName", outputColumns, false, 100, 200);

    ((ColumnConfig) driverAppHelpList.getColumnsConfigList().get(0)).setHidden(true);

    EventType specialEvent = new EventType(800);
    driverAppHelpList.setSpecialEventOnGridSelection(true, specialEvent);
    driverAppHelpList.getHelpList().addListener(specialEvent, new Listener<BaseEvent>() {

        public void handleEvent(BaseEvent be) {
            mediator.searchDriverApplication((Integer) driverAppHelpList.getModelValue().get("Driver_Id"));
        }
    });

    toolBar.add(driverAppHelpList);
    toolBar.add(new FillToolItem());
    toolBar.add(saveApplicationButton);
    // toolBar.add(new ToolButton(ToolButton.REFRESH));
    verticalPanel.add(toolBar);

    applicationNoTextField = new TextField();
    applicationDateField = new DateField();
    applicationStatusTextField = new TextField();
    applicationRemarksTextField = new TextArea();
    userTextField = new TextField();

    HorizontalPanel appPanel = new HorizontalPanel();
    appPanel.add(createTopFieldLabel(applicationNoTextField, "Application No"));
    appPanel.add(createTopFieldLabel(applicationDateField, "Application Date"));
    appPanel.add(createTopFieldLabel(applicationStatusTextField, "Application Status"));
    appPanel.add(createTopFieldLabel(applicationRemarksTextField, "Application Remarks"));
    appPanel.add(createTopFieldLabel(userTextField, "User"));

    FieldSet appFieldSet = new FieldSet();
    appFieldSet.setHeadingText("Application");
    appFieldSet.setCollapsible(true);
    appFieldSet.setWidth(850);
    appFieldSet.add(appPanel);

    verticalPanel.add(appFieldSet);

    fullNameTextField = new TextField<String>();
    primaryContactTextField = new TextField();
    currentAreaTextField = new TextField();
    genderTextField = new TextField();
    dobDateField = new DateField();

    appPanel = new HorizontalPanel();
    appPanel.setSpacing(10);
    appPanel.add(createTopFieldLabel(fullNameTextField, "Full Name"));
    appPanel.add(createTopFieldLabel(primaryContactTextField, "Primary Contact"));
    appPanel.add(createTopFieldLabel(currentAreaTextField, "Current Area"));
    // verticalPanel.add(appPanel);
    //
    // appPanel = new HorizontalPanel();
    // appPanel.setSpacing(5);
    appPanel.add(createTopFieldLabel(genderTextField, "Gender"));
    appPanel.add(createTopFieldLabel(dobDateField, "DOB"));

    basicFieldSet = new FieldSet();
    basicFieldSet.setHeadingText("Basic Details");
    basicFieldSet.setCollapsible(true);
    basicFieldSet.setWidth(1000);
    basicFieldSet.add(appPanel);

    verticalPanel.add(basicFieldSet);

    licenseNoTextField = new TextField();

    LicenseTypeProperties licenseTypeProperties = GWT.create(LicenseTypeProperties.class);
    ListStore store = new ListStore(licenseTypeProperties.value());
    store.add(new CarType("LMV", "LMV"));
    store.add(new CarType("HMV", "HMV"));
    licenseTypeCombo = new ComboBox(store, licenseTypeProperties.name());

    licenseExpiryDateField = new DateField();

    appPanel = new HorizontalPanel();
    appPanel.setSpacing(5);
    appPanel.add(createTopFieldLabel(licenseNoTextField, "License No"));
    appPanel.add(createTopFieldLabel(licenseTypeCombo, "License Type"));
    appPanel.add(createTopFieldLabel(licenseExpiryDateField, "License Expiry Date"));

    FieldSet licenseFieldSet = new FieldSet();
    licenseFieldSet.setHeadingText("License");
    // licenseFieldSet.setCollapsible(true);
    licenseFieldSet.setWidth(550);
    licenseFieldSet.setHeight(100);
    licenseFieldSet.add(appPanel);

    HorizontalPanel parentPanel = new HorizontalPanel();
    parentPanel.setSpacing(5);
    parentPanel.add(licenseFieldSet);

    HorizontalPanel jobPrefPanel = new HorizontalPanel();

    FieldSet indiFieldSet = new FieldSet();
    indiFieldSet.setHeadingText("Individual");
    indiFieldSet.add(buildJobPrefPanel());
    jobPrefPanel.add(indiFieldSet);

    FieldSet companyFieldSet = new FieldSet();
    companyFieldSet.setHeadingText("Company");
    companyFieldSet.add(buildJobPrefPanel());
    jobPrefPanel.add(companyFieldSet);

    FieldSet jobPrefFieldSet = new FieldSet();
    jobPrefFieldSet.setHeadingText("Job Preference");
    // jobPrefFieldSet.setCollapsible(true);
    jobPrefFieldSet.setWidth(600);
    jobPrefFieldSet.setHeight(100);
    jobPrefFieldSet.add(jobPrefPanel);

    parentPanel.add(jobPrefFieldSet);
    verticalPanel.add(parentPanel);

    TextField totalExpTextField = new TextField();
    TextField curSalTextField = new TextField();
    TextField expSalTextField = new TextField();

    appPanel = new HorizontalPanel();
    appPanel.setSpacing(5);
    appPanel.add(createTopFieldLabel(totalExpTextField, "Total Exp"));
    appPanel.add(createTopFieldLabel(curSalTextField, "Current Salary"));
    appPanel.add(createTopFieldLabel(expSalTextField, "Expected Salary"));
    // verticalPanel.add(appPanel);

    medicalHistoryTextArea = new TextArea();
    eyeSightTextArea = new TextArea();
    diabetesTextArea = new TextArea();
    accidentHistoryTextArea = new TextArea();

    // appPanel = new HorizontalPanel();
    // appPanel.setSpacing(5);
    appPanel.add(createTopFieldLabel(medicalHistoryTextArea, "Medical History"));
    appPanel.add(createTopFieldLabel(eyeSightTextArea, "Eye Sight"));
    appPanel.add(createTopFieldLabel(diabetesTextArea, "Diabetes"));
    appPanel.add(createTopFieldLabel(accidentHistoryTextArea, "Accident History"));
    verticalPanel.add(appPanel);

    TextField driverRefNameTextField = new TextField();
    TextField driverRefNoTextField = new TextField();

    HorizontalLayoutContainer driverReferencePanel = new HorizontalLayoutContainer();
    Margins margins = new Margins(0, 5, 0, 0);
    HorizontalLayoutData horizontalLayoutData = new HorizontalLayoutData(200, 100, margins);
    driverReferencePanel.add(createTopFieldLabel(driverRefNameTextField, "Driver Reference Name"),
            horizontalLayoutData);
    driverReferencePanel.add(createTopFieldLabel(driverRefNoTextField, "Driver Reference Number"),
            horizontalLayoutData);

    FieldSet driverReferenceFieldSet = new FieldSet();
    driverReferenceFieldSet.setSize("450", "80");
    driverReferenceFieldSet.setHeadingText("Driver Reference");
    driverReferenceFieldSet.setCollapsible(true);
    driverReferenceFieldSet.add(driverReferencePanel);

    parentPanel = new HorizontalPanel();
    parentPanel.setSpacing(5);
    parentPanel.add(buildCarType());
    parentPanel.add(driverReferenceFieldSet);

    verticalPanel.add(parentPanel);

    formPanel.add(verticalPanel);
    return formPanel;
}

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);
    Button okButton = createButton("OK", dialogBox, false, handler);
    buttonPanel.add(okButton);//from w  w w  . ja va  2s. c  om
    Button cancelButton = createButton("Cancel", dialogBox, true, handler);
    buttonPanel.add(cancelButton);
    handler.setupButtons(okButton, cancelButton);
    return buttonPanel;
}

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  ww  . j a v a  2s.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);
    Button okButton = createButton("OK", dialogBox, false, originalState);
    buttonPanel.add(okButton);/*from   w  w  w.j  a  v a 2  s.c  om*/
    Button cancelButton = createButton("Cancel", dialogBox, true, null);
    buttonPanel.add(cancelButton);
    return buttonPanel;
}

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   w  ww. j  a v a  2s.c  o 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;
}

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);
    panel.add(row);/*from  w w  w . j a  v a 2  s.  c o  m*/

    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   w  w w  .  j  ava  2s.  co m*/

    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;
}