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.nanosim.client.content.other.CwAnimation.java

License:Apache License

/**
 * Initialize this example.//from  w ww  . j  a va 2 s  .c  om
 */
@NanosimSource
@Override
public Widget onInitialize() {
    // Create a new panel
    absolutePanel = new AbsolutePanel();
    absolutePanel.setSize("250px", "250px");
    absolutePanel.ensureDebugId("cwAbsolutePanel");

    // Add a widget that we will animate
    animateeTop = Nanosim.images.logo().createImage();
    animateeBottom = Nanosim.images.logo().createImage();
    animateeLeft = Nanosim.images.logo().createImage();
    animateeRight = Nanosim.images.logo().createImage();
    absolutePanel.add(animateeTop);
    absolutePanel.add(animateeBottom);
    absolutePanel.add(animateeLeft);
    absolutePanel.add(animateeRight);

    // Wrap the absolute panel in a DecoratorPanel
    DecoratorPanel absolutePanelWrapper = new DecoratorPanel();
    absolutePanelWrapper.setWidget(absolutePanel);

    // Create the options bar
    DecoratorPanel optionsWrapper = new DecoratorPanel();
    optionsWrapper.setWidget(createOptionsBar());

    // Add the components to a panel and return it
    HorizontalPanel mainLayout = new HorizontalPanel();
    mainLayout.setSpacing(10);
    mainLayout.add(optionsWrapper);
    mainLayout.add(absolutePanelWrapper);

    // Create the custom animation
    animation = new CustomAnimation();

    // Set the start position of the widgets
    animation.onComplete();

    // Return the layout
    return mainLayout;
}

From source file:com.nanosim.client.content.other.CwFrame.java

License:Apache License

/**
 * Initialize this example./*from   ww  w  .j a  v a  2 s. c o  m*/
 */
@NanosimSource
@Override
public Widget onInitialize() {
    // Create a new frame
    String url = GWT.getModuleBaseURL();
    final Frame frame = new Frame(url);
    frame.setSize("700px", "300px");
    frame.ensureDebugId("cwFrame");

    // Create a form to set the location of the frame
    final TextBox locationBox = new TextBox();
    locationBox.setText(url);
    Button setLocationButton = new Button(constants.cwFrameSetLocation());
    HorizontalPanel optionsPanel = new HorizontalPanel();
    optionsPanel.setSpacing(8);
    optionsPanel.add(locationBox);
    optionsPanel.add(setLocationButton);

    // Change the location when the user clicks the button
    setLocationButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            frame.setUrl(locationBox.getText());
        }
    });

    // Change the location when the user presses enter
    locationBox.addKeyDownHandler(new KeyDownHandler() {
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                frame.setUrl(locationBox.getText());
            }
        }

    });

    // Add everything to a panel and return it
    VerticalPanel vPanel = new VerticalPanel();
    vPanel.add(optionsPanel);
    vPanel.add(frame);
    return vPanel;
}

From source file:com.nitrous.gwt.earth.client.demo.FetchKmlInteractive.java

License:Apache License

/**
 * The Google earth API has loaded, start the application
 *///from w w w  .ja  v  a 2  s.c om
private void onApiLoaded() {
    // construct the UI widget
    earth = new GoogleEarthWidget();

    // register a listener to be notified when the earth plug-in has loaded
    earth.addPluginReadyListener(new GEPluginReadyListener() {
        public void pluginReady(GEPlugin ge) {
            // show map content once the plugin has loaded
            loadMapContent();
        }

        public void pluginInitFailure() {
            // failure!
            Window.alert("Failed to initialize Google Earth Plug-in");
        }
    });

    kmlUrlBox = new TextBox();
    kmlUrlBox.getElement().setAttribute("size", "70");
    kmlUrlBox.setValue("http://earth-api-samples.googlecode.com/svn/trunk/examples/static/red.kml");

    Button fetchKmlButton = new Button("Fetch KML!");
    fetchKmlButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            fetchKmlFromInput();
        }
    });

    HorizontalPanel urlPanel = new HorizontalPanel();
    urlPanel.setSpacing(5);
    urlPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    urlPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    urlPanel.add(new Label("Fetch KML at this URL:"));
    urlPanel.add(kmlUrlBox);
    urlPanel.add(fetchKmlButton);

    DockLayoutPanel layout = new DockLayoutPanel(Unit.PX);
    layout.addNorth(urlPanel, 40);
    layout.add(earth);
    // add the widget to the DOM
    RootLayoutPanel.get().add(layout);

    // begin loading the Google Earth Plug-in
    earth.init();
}

From source file:com.nitrous.gwt.earth.client.demo.FetchKmlInteractiveCheckboxes.java

License:Apache License

/**
 * The Google earth API has loaded, start the application
 *///from  w  ww.j  a v a  2  s. c  o m
private void onApiLoaded() {
    // construct the UI widget
    earth = new GoogleEarthWidget();

    // register a listener to be notified when the earth plug-in has loaded
    earth.addPluginReadyListener(new GEPluginReadyListener() {
        public void pluginReady(GEPlugin ge) {
            // show map content once the plugin has loaded
            loadMapContent();
        }

        public void pluginInitFailure() {
            // failure!
            Window.alert("Failed to initialize Google Earth Plug-in");
        }
    });

    currentKmlObjects = new HashMap<String, KmlObject>();

    checkBoxes = new HashMap<String, CheckBox>();
    red = new CheckBox("Red Placemarks");
    red.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            toggleKml("red");
        }
    });
    checkBoxes.put("red", red);

    yellow = new CheckBox("Yellow Placemarks");
    yellow.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            toggleKml("yellow");
        }
    });
    checkBoxes.put("yellow", yellow);

    green = new CheckBox("Green Placemarks");
    green.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            toggleKml("green");
        }
    });
    checkBoxes.put("green", green);

    HorizontalPanel header = new HorizontalPanel();
    header.setSpacing(5);
    header.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    header.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    header.add(new HTML("<H1>Toggle KML Files:</H1>"));

    VerticalPanel checkBoxes = new VerticalPanel();
    checkBoxes.setSpacing(5);
    checkBoxes.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    checkBoxes.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    checkBoxes.add(red);
    checkBoxes.add(yellow);
    checkBoxes.add(green);
    header.add(checkBoxes);

    DockLayoutPanel layout = new DockLayoutPanel(Unit.PX);
    layout.addNorth(header, 100);
    layout.add(earth);
    RootLayoutPanel.get().add(layout);

    // begin loading the Google Earth Plug-in
    earth.init();
}

From source file:com.nitrous.gwt.earth.client.demo.ParseKmlInteractive.java

License:Apache License

/**
 * The Google earth API has loaded, start the application
 *//* w ww  .  ja va  2s .co m*/
private void onApiLoaded() {
    // construct the UI widget
    earth = new GoogleEarthWidget();

    // register a listener to be notified when the earth plug-in has loaded
    earth.addPluginReadyListener(new GEPluginReadyListener() {
        public void pluginReady(GEPlugin ge) {
            // show map content once the plugin has loaded
            loadMapContent();
        }

        public void pluginInitFailure() {
            // failure!
            Window.alert("Failed to initialize Google Earth Plug-in");
        }
    });

    kmlBox = new TextArea();
    kmlBox.getElement().setAttribute("rows", "10");
    kmlBox.getElement().setAttribute("cols", "70");
    kmlBox.getElement().setAttribute("wrap", "off");
    kmlBox.getElement().setAttribute("style", "font-family: monospace; font-size: small");
    kmlBox.setValue(
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n"
                    + "  <Placemark>\n" + "    <name>Test Placemark</name>\n" + "    <Point>\n"
                    + "      <coordinates>\n" + "        -122,37,0\n" + "      </coordinates>\n"
                    + "    </Point>\n" + "  </Placemark>\n" + "</kml>");

    Button parseKmlButton = new Button("Parse and Add this KML!");
    parseKmlButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            parseKmlFromTextArea();
        }
    });

    HorizontalPanel textPanel = new HorizontalPanel();
    textPanel.setSpacing(5);
    textPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    textPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
    textPanel.add(kmlBox);
    textPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    textPanel.add(parseKmlButton);

    DockLayoutPanel layout = new DockLayoutPanel(Unit.PX);
    layout.addNorth(textPanel, 220);
    layout.add(earth);
    // add the widget to the DOM
    RootLayoutPanel.get().add(layout);

    // begin loading the Google Earth Plug-in
    earth.init();
}

From source file:com.objetdirect.tatami.demo.client.GfxDemo.java

License:Open Source License

/**
 * shows a popup to scale a graphical Object
 **//*  ww  w. j a va  2s  .co m*/
private void showPopupScaler(Widget sender) {
    if (current != null) {
        scaleFactor = 1;
        final PopupPanel popupScaler = new PopupPanel(true);
        popupScaler.addStyleName("GfxDemo-popup");
        final Slider scaler = new Slider(Slider.HORIZONTAL, -10, 10, 1, true);
        scaler.setRuleMarkBottom(6, "3px");
        HorizontalPanel scalePanel = new HorizontalPanel();
        scalePanel.setSpacing(5);

        final Label labelScaler = new Label();
        scalePanel.add(scaler);
        scalePanel.add(labelScaler);

        labelScaler.setText("x" + scaleFactor);

        ChangeListener scaleChange = new ChangeListener() {
            public void onChange(Widget sender) {
                int value = scaler.getValue();
                if (current != null && value != 0) {
                    if (value < 0) {
                        final float minus = (scaler.getMinimum() - value) * (-1);
                        float factor = (minus / (float) scaler.getMaximum()) / scaleFactor;
                        if (current.getGroup() != null) {
                            current.getGroup().scale(factor);
                        } else {
                            current.scale(factor);
                        }
                        scaleFactor = (minus / (float) scaler.getMaximum());

                    } else {
                        float factor = (float) value / scaleFactor;
                        if (current.getGroup() != null) {
                            current.getGroup().scale(factor);
                        } else {
                            current.scale(factor);
                        }
                        scaleFactor = (float) value;
                    }

                }
                labelScaler.setText("x" + scaleFactor);
            }
        };
        scaler.addChangeListener(scaleChange);
        popupScaler.add(scalePanel);
        popupScaler.setPopupPosition(sender.getAbsoluteLeft(), sender.getAbsoluteTop());
        popupScaler.show();
    }
}

From source file:com.objetdirect.tatami.demo.client.GfxDemo.java

License:Open Source License

/**
 * Show a popup with a <code>Slider</code> to
 * perform some rotation of the current <code>GraphicObject</code>
 *
 *//*from w  w  w . j a v  a 2  s  .  c  o  m*/
private void showPopupRotate(Widget sender) {
    if (current != null) {
        rotateDegree = 0;
        final PopupPanel popupRotate = new PopupPanel(true);
        popupRotate.addStyleName("GfxDemo-popup");
        final Slider rotate = new Slider(Slider.HORIZONTAL, 0, 360, 0, true);
        HorizontalPanel rotatePanel = new HorizontalPanel();
        rotatePanel.setSpacing(5);

        final Label label = new Label();
        rotatePanel.add(rotate);
        rotatePanel.add(label);
        label.setText("" + rotateDegree);
        ChangeListener rotateChange = new ChangeListener() {
            public void onChange(Widget sender) {
                int value = rotate.getValue();
                if (current != null && value != 0) {
                    int degree = value - rotateDegree;

                    if (current.getGroup() != null) {
                        current.getGroup().rotate(degree);
                    } else {
                        current.rotate(degree);
                    }

                    rotateDegree = value;
                }
                label.setText(rotateDegree + "");

            }
        };
        rotate.addChangeListener(rotateChange);
        popupRotate.add(rotatePanel);
        popupRotate.setPopupPosition(sender.getAbsoluteLeft(), sender.getAbsoluteTop());
        popupRotate.show();
    }
}

From source file:com.qualogy.qafe.gwt.client.component.QPagingScrollTableOperation.java

License:Apache License

/**
 * Constructor./*from  w  ww.j  a v a  2  s  . co m*/
 *
 * @param table
 *            the table being affected
 * @param images
 *            the images to use
 */
// CHECKSTYLE.OFF: CyclomaticComplexity
public QPagingScrollTableOperation(final QPagingScrollTable table, ScrollTableOperationImages images) {
    this.table = table;
    if (this.table instanceof QPagingScrollTable) {
        ((QPagingScrollTable) this.table).setScrollTableOperations(this);
    }

    // Create the main widget
    HorizontalPanel hPanel = new HorizontalPanel();
    initWidget(hPanel);
    hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    setStyleName(DEFAULT_STYLENAME);

    // Create the paging image buttons
    createPageButtons(images);

    // Create the error label
    errorLabel = new HTML();
    errorLabel.setStylePrimaryName("errorMessage");

    // Add the widgets to the panel
    hPanel.add(createSpacer());
    if (hasAddControl(table)) {
        hPanel.add(addImage);
        hPanel.add(createSpacer());
    }
    if (hasDeleteControl(table)) {
        hPanel.add(deleteImage);
        hPanel.add(createSpacer());
    }

    if (isEditableDatagrid(table) || hasDeleteControl(table) || hasAddControl(table)) {
        if (saveDatagrid(table)) {
            hPanel.add(saveImage);
            hPanel.add(createSpacer());
        }
        if (refreshDatagrid(table)) {
            hPanel.add(refreshImage);
            hPanel.add(createSpacer());
        }
        if (cancelDatagrid(table)) {
            hPanel.add(cancelImage);
            hPanel.add(createSpacer());
        }
    }

    hPanel.add(errorLabel);

    if (table.getSource().getImportEnabled() != null && table.getSource().getImportEnabled().booleanValue()) {
        final DisclosurePanel importPanel = new DisclosurePanel("Upload data");
        hPanel.add(importPanel);
        final FormPanel formPanel = new FormPanel();

        formPanel.setAction(GWT.getModuleBaseURL() + "/rpc.datagridupload");
        formPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
        formPanel.setMethod(FormPanel.METHOD_POST);

        FileUpload fileUploadComponent = new FileUpload();
        fileUploadComponent.setName("uploadElement");

        Button uploadButtonComponent = new Button("Upload");
        uploadButtonComponent.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                formPanel.submit();
            }
        });

        CheckBox isFirstLineHeader = new CheckBox("Is first row header ?");
        isFirstLineHeader.setName("isFirstLineHeader");
        isFirstLineHeader.setTitle(
                "Check wheter or not the first line of the uploaded file is a header/column definition");
        HorizontalPanel hp = new HorizontalPanel();

        Label label = new Label("Delimeter");
        final TextBox delimiter = new TextBox();
        delimiter.setValue(",");
        delimiter.setTitle("Insert the delimeter (can be any value, as long it's length 1)");
        delimiter.setName("delimiter");
        delimiter.setWidth("15px");
        hp.setSpacing(10);
        hp.add(label);
        hp.add(delimiter);

        Grid gridPanel = new Grid(2, 4);
        gridPanel.setWidget(0, 0, fileUploadComponent);
        gridPanel.setWidget(0, 1, uploadButtonComponent);
        gridPanel.setWidget(1, 0, isFirstLineHeader);
        gridPanel.setWidget(1, 1, hp);

        formPanel.add(gridPanel);

        formPanel.addSubmitHandler(new FormPanel.SubmitHandler() {

            public void onSubmit(SubmitEvent event) {
                // This event is fired just before the form is submitted. We can
                // take
                // this opportunity to perform validation.
                if (delimiter.getText().length() == 0 || delimiter.getText().length() > 1) {
                    ClientApplicationContext.getInstance().log("Ooops...Delimeter invalid",
                            "Make sure there is valid delimeter value.One character only (current value ='"
                                    + delimiter.getText() + "'",
                            true);
                    event.cancel();
                }
            }

        });

        formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() {

            public void onSubmitComplete(SubmitCompleteEvent event) {
                String uuId = event.getResults();
                if (uuId != null && uuId.indexOf("=") > 0) {
                    uuId = uuId.substring(uuId.indexOf("=") + 1);
                    processData(uuId);
                    importPanel.setOpen(false);
                } else {
                    ClientApplicationContext.getInstance().log("Upload failed", event.getResults(), true);
                }
            }
        });
        importPanel.add(formPanel);
    }

    if (table.getSource() != null && table.getSource().getExport() != null
            && table.getSource().getExport().booleanValue()) {

        createExportLabelsAndImages();

        final DisclosurePanel exportPanel = new DisclosurePanel("Export");
        String[] labels = getExportLabels(table.getSource().getExportFormats());
        Image[] exportImages = getExportImages(labels);

        FlexTable gridExportPanel = new FlexTable();
        hPanel.add(exportPanel);
        exportPanel.add(gridExportPanel);
        final Frame frame = new Frame();
        frame.setHeight("0");
        frame.setWidth("0");
        frame.setVisible(false);
        final String moduleRelativeURL = GWT.getModuleBaseURL() + "/rpc.export";
        gridExportPanel.setWidget(0, 0, frame);

        final CheckBox generateColumnHeaderBox = new CheckBox("Generate Column Header");
        gridExportPanel.getFlexCellFormatter().setColSpan(1, 1, 7);
        gridExportPanel.setWidget(2, 1, generateColumnHeaderBox);
        gridExportPanel.getFlexCellFormatter().setColSpan(2, 1, 6);

        for (int i = 0; i < labels.length; i++) {

            exportImages[i].setStylePrimaryName("datagridexportlabel");
            exportImages[i].setTitle(labels[i]);
            gridExportPanel.setWidget(0, i + 1, exportImages[i]);

            exportImages[i].addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    if (event.getSource() instanceof Image) {
                        Image image = (Image) (event.getSource());
                        final String exportCode = image.getTitle();
                        RPCServiceAsync service = MainFactoryActions.createService();
                        AsyncCallback<?> callback = new AsyncCallback<Object>() {
                            public void onSuccess(Object result) {
                                String uuid = (String) result;
                                // set frame
                                frame.setUrl(moduleRelativeURL + "?uuid=" + uuid);
                                ClientApplicationContext.getInstance().setBusy(false);
                            }

                            public void onFailure(Throwable caught) {

                                ClientApplicationContext.getInstance().log("Export failed",
                                        "Export failed for " + exportCode + " ", true, true, caught);
                                ClientApplicationContext.getInstance().setBusy(false);
                                FunctionsExecutor.setProcessedBuiltIn(true);
                            }
                        };
                        List<DataContainerGVO> dList = new ArrayList<DataContainerGVO>();
                        // following loop is to maintain the order of rows while exporting.
                        for (int i = 0; i < (table.getAbsoluteLastRowIndex() + 1); i++) {
                            dList.add(table.getRowValue(i));
                        }
                        service.prepareForExport(dList, exportCode, null,
                                generateColumnHeaderBox.getValue().booleanValue(), callback);
                    }
                }
            });
        }
    }
}

From source file:com.qualogy.qafe.gwt.client.ui.renderer.PanelRenderer.java

License:Apache License

private HorizontalPanel createDataPanelToolBar(PanelGVO root, String uuid, String parent) {
    HorizontalPanel tb = new HorizontalPanel();
    tb.setSpacing(5);
    tb.setStyleName("x-toolbar");
    if (root.getDataPanelControl() != null) {
        int index = 0;
        for (ComponentGVO componentGVO : root.getDataPanelControl()) {
            tb.add(createDataPanelToolBarButton(componentGVO, uuid, parent, index));
            index++;/*w ww  . j  a v a 2  s .c o m*/
        }
    }
    return tb;
}

From source file:com.qualogy.qafe.gwt.client.ui.renderer.WindowRenderer.java

License:Apache License

private HorizontalPanel createToolBar(ToolbarGVO component, String uuid, String parent) {
    HorizontalPanel tb = new HorizontalPanel();
    tb.setSpacing(5);
    RendererHelper.fillIn(component, tb, uuid, parent, component.getContext());
    if (component != null) {
        if (component.getToolbarItems() != null) {
            for (int i = 0; i < component.getToolbarItems().length; i++) {
                tb.add(createToolBarButton(component, component.getToolbarItems()[i].getImageLocation(),
                        component.getToolbarItems()[i].getTooltip(), component.getToolbarItems()[i], uuid,
                        parent));// www.  j  a v  a2  s  .  c o m
                toolbarHeight = (component.getItemHeight().replace("px", "")).trim();
            }
        }
    }
    return tb;
}