Example usage for com.google.gwt.dom.client Style setProperty

List of usage examples for com.google.gwt.dom.client Style setProperty

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Style setProperty.

Prototype

public void setProperty(String name, String value) 

Source Link

Usage

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

License:Open Source License

/**
 * Create an canvas (at the right) and a toolbar containg some actions.
 * The actions are : creates a new gfx component, like <code>Rect</code>...,
 * changes the color, the width of the stroke, does some rotation, scaling.
 *
 *//*from   w  ww .  j  av a  2 s .  c  o m*/
private void initComponents() {

    palette = new FlowPanel();
    palette.setStylePrimaryName("GfxDemo-palette");
    canvas = new GraphicCanvas();
    canvas.setStylePrimaryName("GfxDemo-canvas");
    canvas.setDimensions(600, 600);
    popup.add(html);

    gridShape = new FlowPanel();
    gridShape.setStylePrimaryName("shapeButtons");
    gridTransform = new FlowPanel();
    gridTransform.setStylePrimaryName("transformButtons");

    fill = new HTML("&nbsp;&nbsp;&nbsp;");
    fill.setStylePrimaryName("fillProperty");
    Style fillStyle = fill.getElement().getStyle();
    fillStyle.setProperty("backgroundColor", currentFillColor.toHex());
    fillStyle.setProperty("border", "solid");
    fillStyle.setProperty("borderWidth", "thin");
    fillStyle.setProperty("borderColor", currentStrokeColor.toHex());

    addAction(fill, ACTION.APPLY_COLOR);

    palette.add(gridShape);
    palette.add(fill);

    strokeSize = new HTML[4];
    strokeSize[0] = this.createSrokeSize(1, ACTION.STROKE_1);
    strokeSize[1] = this.createSrokeSize(2, ACTION.STROKE_2);
    strokeSize[2] = this.createSrokeSize(3, ACTION.STROKE_3);
    strokeSize[3] = this.createSrokeSize(5, ACTION.STROKE_4);

    palette.add(gridTransform);

    opacity = new Slider(Slider.HORIZONTAL, 0, 100, 100, true);
    opacity.addChangeListener(this);

    addAction(gridShape, "Circle", "gfx/circle.gif", ACTION.DRAW_CIRCLE);
    addAction(gridShape, "Ellipse", "gfx/ellipse.gif", ACTION.DRAW_ELLIPSE);
    addAction(gridShape, "Rect", "gfx/rect.gif", ACTION.DRAW_RECT);
    addAction(gridShape, "Line", "gfx/line.gif", ACTION.DRAW_LINE);
    addAction(gridShape, "Polyline", "gfx/polyline.gif", ACTION.DRAW_POLYLINE);
    addAction(gridShape, "Text", "gfx/text.gif", ACTION.DRAW_TEXT);
    addAction(gridShape, "Image", "gfx/image.gif", ACTION.DRAW_IMAGE);
    addAction(gridShape, "Path", "gfx/path.GIF", ACTION.DRAW_PATH);
    addAction(gridShape, "Text Path", "gfx/textpath.gif", ACTION.DRAW_TEXT_PATH);
    addAction(gridShape, "Virtual", "gfx/group.gif", ACTION.DRAW_VIRTUAL_GROUP);
    addAction(gridShape, "Delete", "gfx/delete.gif", ACTION.DELETE);
    addAction(gridTransform, "set color", "gfx/color.gif", ACTION.APPLY_COLOR);
    addAction(gridTransform, "Scale", "gfx/scale.gif", ACTION.SCALE);
    addAction(gridTransform, "Rotate", "gfx/rotate.gif", ACTION.ROTATE);
    addAction(gridTransform, "Move to back", "gfx/back.gif", ACTION.GO_BACK);
    addAction(gridTransform, "Move to front", "gfx/front.gif", ACTION.GO_FRONT);
    addAction(gridTransform, "Properties", "gfx/properties.gif", ACTION.SHOW_PROPERTIES);

    add(new HTML(TatamiDemo.getMessages().paragraph_gfx()));

    add(palette);
    add(canvas);
    canvas.addGraphicObjectListener(this);

}

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

License:Open Source License

/**
 *
 * @param size/*  w  w w.  jav  a  2s. co m*/
 * @return
 */
private HTML createSrokeSize(int size, ACTION action) {
    HTML strokeSize = new HTML("&nbsp;&nbsp;&nbsp;");
    strokeSize.setStylePrimaryName("strokeProperty");
    strokeSize.setTitle("Size of stroke " + size);
    Style style = strokeSize.getElement().getStyle();
    style.setProperty("borderTop", "solid");
    style.setPropertyPx("borderWidth", size);
    palette.add(strokeSize);
    this.addAction(strokeSize, action);

    return strokeSize;
}

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

License:Open Source License

/**
 * Chooses a width for the stroke of the <code>GraphicObject</code>
 * @param index an index of the array <code>strokeSize</code>
 * @param size  the size to apply/*  w ww.ja v a2 s .c o  m*/
 */
private void chooseStrokeSize(int index, int size) {
    for (int i = 0; i < strokeSize.length; i++) {
        Style style = strokeSize[i].getElement().getStyle();
        if (i == index) {

            style.setProperty("borderColor", "red");
            currentStrokeSize = size;
        } else {
            style.setProperty("borderColor", "black");

        }
    }
}

From source file:com.sciencegadgets.client.algebra.edit.LinkPrompt_Equation.java

License:Open Source License

public LinkPrompt_Equation(final AlgebraActivity algebraActivity, EquationTree initialEquation) {
    super();// ww  w  . j ava 2  s.  c  o  m
    this.initialEquation = initialEquation;
    this.algebraActivity = algebraActivity;
    // params.add(easyToggle);

    if (initialEquation == null) {
        LinkedList<EquationNode> variables = algebraActivity.getEquationTree()
                .getNodesByType(TypeSGET.Variable);
        int varCount = variables.size();
        if (varCount == 0) {
            Window.alert("You should consider adding a variable in the equation");
        } else {

            //            final Button solveGoalButton = new Button("Solve Goal",
            //                  new ClickHandler() {
            //                     @Override
            //                     public void onClick(ClickEvent arg0) {
            //                        LinkPrompt_Equation.this.disappear();
            //                        Moderator.switchToAlgebra(
            //                              algebraActivity.getEquationTree(),
            //                              ActivityType.editsolvegoal, true);
            //                     }
            //                  });
            //            solveGoalButton
            //                  .setTitle("Faster and more accurate but can't use with random numbers");
            //            solveGoalButton.addStyleName(CSS.CREATE_GOAL_BUTTON);
            //            solveGoalButton.addStyleName(CSS.BORDER_RADIUS_SMALL);
            //            upperArea.add(solveGoalButton);
            //
            //            final Button createGoalButton = new Button("Edit Goal",
            //                  new ClickHandler() {
            //                     @Override
            //                     public void onClick(ClickEvent arg0) {
            //                        LinkPrompt_Equation.this.disappear();
            //                        Moderator.switchToAlgebra(
            //                              algebraActivity.getEquationTree(),
            //                              ActivityType.editcreategoal, true);
            //                     }
            //                  });
            //            createGoalButton
            //                  .setTitle("Can use with random numbers but prone to error!");
            //            createGoalButton.addStyleName(CSS.CREATE_GOAL_BUTTON);
            //            createGoalButton.addStyleName(CSS.BORDER_RADIUS_SMALL);
            //            upperArea.add(createGoalButton);
        }

        Unit[] units = Unit.values();
        ArrayList<String> unitStrings = new ArrayList<String>();
        for (Unit u : units) {
            unitStrings.add(u.toString());
        }
        widthUnits.setAcceptableValues(unitStrings);
        heightUnits.setAcceptableValues(unitStrings);

        SpecChangeHandler specChange = new SpecChangeHandler();
        KeyUpToSpecChange keyUp = new KeyUpToSpecChange();
        widthTextBox.addValueChangeHandler(specChange);
        widthUnits.addValueChangeHandler(specChange);
        heightTextBox.addValueChangeHandler(specChange);
        heightUnits.addValueChangeHandler(specChange);
        widthTextBox.addKeyUpHandler(keyUp);
        heightTextBox.addKeyUpHandler(keyUp);

        colorTextBox.addFocusHandler(new FocusHandler() {
            @Override
            public void onFocus(FocusEvent event) {
                setColor(colorTextBox.getValue());
            }
        });
        colorTextBox.addKeyUpHandler(new KeyUpHandler() {
            @Override
            public void onKeyUp(KeyUpEvent event) {
                setColor(colorTextBox.getValue());
            }
        });

        colorTextBox.getElement().setId("colorTextBox");
        Element colorInput = DOM.createElement("input");
        colorInput.setAttribute("type", "color");
        colorInput.setAttribute("value", initialColor);
        colorInput.setAttribute("id", "colorInputElement");
        colorInput.setAttribute("onchange",
                "colorTextBox.value=colorInputElement.value.replace('#', ''); colorTextBox.focus()");
        Style colorInputStyle = colorInput.getStyle();
        colorInputStyle.setProperty("border", "none");
        colorInputStyle.setPadding(0, Unit.PX);
        colorInputStyle.setWidth(100, Unit.PCT);
        colorInputArea.getElement().appendChild(colorInput);
    } else {
        setModal(true);
        setAutoHideEnabled(false);

        upperArea.add(new Label("Goal: "));
        upperArea.add(algebraActivity.getEquationTree().getDisplayClone());

        addOkHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent arg0) {
                Moderator.switchToAlgebra(algebraActivity.getEquationTree(), ActivityType.editequation, true);
            }
        });
    }

}

From source file:com.sciencegadgets.client.algebra.edit.ProblemSpecification.java

License:Open Source License

ImageUploadButton(final ProblemSpecification problemSpec) {
    super();/*from w  ww . ja v  a 2  s. c o  m*/
    addSubmitCompleteHandler(new SubmitCompleteHandler() {

        @Override
        public void onSubmitComplete(SubmitCompleteEvent event) {

            String imgurlstart = "<img src='";
            String imgurlmid = "' alt='";
            String imgurlend = "'>";

            String response = event.getResults().replace("\"", "'").replace("&lt;", "<").replace("&gt;", ">");
            if (!response.contains(imgurlstart) || !response.contains(imgurlmid)
                    || !response.contains(imgurlend)) {
                Window.alert("File must be an Image");
                problemSpec.leftPanel.add(new ImageUploadButton(problemSpec));
                ImageUploadButton.this.removeFromParent();
                return;
            }
            String imageURL = response.split(imgurlstart)[1].split(imgurlmid)[0];
            String imageBlobKey = response.split(imgurlmid)[1].split(imgurlend)[0];

            problemSpec.diagram = new Diagram(imageBlobKey, imageURL);

            problemSpec.imageContainer.setSize("100%", "100%");
            Style imageContStyle = problemSpec.imageContainer.getElement().getStyle();
            imageContStyle.setBackgroundImage("url('" + imageURL + "')");
            imageContStyle.setProperty("backgroundSize", "100% 100%");
            removeFromParent();
            problemSpec.leftPanel.add(problemSpec.imageContainer);
            problemSpec.leftPanel.getElement()
                    .setScrollTop(problemSpec.varIdPanel.getElement().getAbsoluteTop());
        }
    });
}

From source file:com.sciencegadgets.client.challenge.DiagramPanel.java

License:Open Source License

DiagramPanel() {
    setSize("100%", "100%");
    Style style = getElement().getStyle();
    style.setProperty("backgroundSize", "100% 100%");
    //         style.setProperty("backgroundSize", "contain");
    //         style.setProperty("backgroundRepeat", "no-repeat");
    //         style.setProperty("backgroundPosition", "center center");

}

From source file:com.sencha.gxt.chart.client.draw.engine.VML.java

License:sencha.com license

/**
 * Creates the DOM element of the passed {@link Sprite}.
 * //from  w  ww  . j a v  a  2  s .c om
 * @param sprite the sprite in need of element creation
 */
private XElement createSpriteElement(Sprite sprite) {
    final XElement element;

    if (sprite instanceof ImageSprite) {
        element = createNode("image");
    } else {
        if (!poolingEnabled || pool.length() == 0) {
            element = createNode("shape");
        } else {
            element = pool.shift();
            if (GXTLogConfiguration.loggingIsEnabled()) {
                logger.finest("reusing shape: " + element);
            }
            assert element.getTagName().equals("vml:shape") : element.getTagName();
        }
        XElement skew = createNode("skew");
        skew.setPropertyBoolean("on", true);
        element.appendChild(skew);
        element.setPropertyJSO("skew", skew);
    }

    element.setPropertyString("coordsize", zoom + " " + zoom);
    element.setPropertyString("coordorigin", "0 0");
    element.addClassName(css.spriteVmlClass());

    if (sprite instanceof TextSprite) {
        XElement path = createNode("path");
        path.setPropertyBoolean("textpathok", true);
        XElement textPath = createNode("textpath");
        textPath.setPropertyBoolean("on", true);
        element.appendChild(textPath);
        element.appendChild(path);
        Style textStyle = textPath.getStyle();
        textStyle.setProperty("lineHeight", "normal");
        textStyle.setProperty("fontVariant", "normal");
        textRenderedPoints.put(sprite, new PrecisePoint());
    }

    this.surfaceElement.appendChild(element);
    setElement(sprite, element);
    return element;
}

From source file:com.sencha.gxt.chart.client.draw.engine.VML.java

License:sencha.com license

/**
 * Applies the attributes of the passed {@link TextSprite} to its VML element.
 * /*  w  w  w  .j a  v  a2s .  c om*/
 * @param sprite the sprite whose attributes to use
 */
private void setTextAttributes(TextSprite sprite, XElement element) {
    Element textPath = element.childElement("textPath").cast();
    Style textStyle = textPath.getStyle();
    textBBoxCache.remove(sprite);

    if (sprite.isFontSizeDirty() || ignoreOptimizations) {
        if (sprite.getFontSize() > 0) {
            textStyle.setFontSize(sprite.getFontSize(), Unit.PX);
        } else {
            textStyle.clearFontSize();
        }
    }
    if (sprite.isFontStyleDirty() || ignoreOptimizations) {
        if (sprite.getFontStyle() != null) {
            textStyle.setFontStyle(sprite.getFontStyle());
        } else {
            textStyle.clearFontStyle();
        }
    }
    if (sprite.isFontWeightDirty() || ignoreOptimizations) {
        if (sprite.getFontWeight() != null) {
            textStyle.setFontWeight(sprite.getFontWeight());
        } else {
            textStyle.clearFontWeight();
        }
    }
    if (sprite.isFontDirty() || ignoreOptimizations) {
        if (sprite.getFont() != null) {
            textStyle.setProperty("fontFamily", sprite.getFont());
        } else {
            textStyle.clearProperty("fontFamily");
        }
    }

    // text-anchor emulation
    if (sprite.isTextAnchorDirty() || ignoreOptimizations) {
        if (sprite.getTextAnchor() == TextAnchor.MIDDLE) {
            setTextAlign(textStyle, "center");
        } else if (sprite.getTextAnchor() == TextAnchor.END) {
            setTextAlign(textStyle, "right");
        } else {
            setTextAlign(textStyle, "left");
        }
    }

    if (sprite.isTextDirty() || ignoreOptimizations) {
        if (sprite.getText() != null) {
            textPath.setPropertyString("string", sprite.getText());
        } else {
            textPath.setPropertyString("string", "");
        }
    }

    if (sprite.isTextBaselineDirty() || sprite.isXDirty() || sprite.isYDirty() || ignoreOptimizations) {
        double height = sprite.getFontSize();
        if (sprite.getTextBaseline() == TextBaseline.MIDDLE) {
            height = 0;
        } else if (sprite.getTextBaseline() == TextBaseline.BOTTOM) {
            height *= -1;
        }
        Element path = element.childElement("path").cast();
        path.setPropertyString("v",
                new StringBuilder().append("m").append(Math.round(sprite.getX() * zoom)).append(",")
                        .append(Math.round((sprite.getY() + (height / 2.0)) * zoom)).append(" l")
                        .append(Math.round(sprite.getX() * zoom) + 1).append(",")
                        .append(Math.round((sprite.getY() + (height / 2.0)) * zoom)).toString());
        textRenderedPoints.put(sprite, new PrecisePoint(sprite.getX(), sprite.getY()));
        textRenderedBaseline.put(sprite, sprite.getTextBaseline());
    }
}

From source file:com.sencha.gxt.chart.client.draw.engine.VML.java

License:sencha.com license

/**
 * Applies transformation to passed sprite
 * //from ww w. j  a  v a 2s  .c  om
 * @param sprite the sprite to be transformed
 */
private void transform(Sprite sprite) {
    double deltaDegrees = 0;
    double deltaScaleX = 1;
    double deltaScaleY = 1;
    Matrix matrix = new Matrix();
    Rotation rotation = sprite.getRotation();
    Scaling scaling = sprite.getScaling();
    Translation translation = sprite.getTranslation();
    sprite.transformMatrix();
    XElement element = getElement(sprite);
    Style style = element.getStyle();
    Element skew = element.getPropertyJSO("skew").cast();

    if (rotation != null) {
        matrix.rotate(rotation.getDegrees(), rotation.getX(), rotation.getY());
        deltaDegrees += rotation.getDegrees();
    }
    if (scaling != null) {
        matrix.scale(scaling.getX(), scaling.getY(), scaling.getCenterX(), scaling.getCenterY());
        deltaScaleX *= scaling.getX();
        deltaScaleY *= scaling.getY();
    }
    if (translation != null) {
        matrix.translate(translation.getX(), translation.getY());
    }
    if (viewBoxShift != null) {
        matrix.prepend(viewBoxShift.getX(), 0, 0, viewBoxShift.getX(),
                viewBoxShift.getCenterX() * viewBoxShift.getX(),
                viewBoxShift.getCenterY() * viewBoxShift.getX());
    }

    if (!(sprite instanceof ImageSprite) && skew != null) {
        // matrix transform via VML skew
        skew.setPropertyString("origin", "0,0");
        skew.setPropertyString("matrix",
                new StringBuilder().append(toFixed(matrix.get(0, 0), 4)).append(", ")
                        .append(toFixed(matrix.get(0, 1), 4)).append(", ").append(toFixed(matrix.get(1, 0), 4))
                        .append(", ").append(toFixed(matrix.get(1, 1), 4)).append(", 0, 0").toString());

        // ensure offset is less than or equal to 32767 and greater than or equal
        // to -32768, otherwise VMl crashes
        double offsetX = Math.max(Math.min(matrix.get(0, 2), 32767), -32768);
        double offsetY = Math.max(Math.min(matrix.get(1, 2), 32767), -32768);
        String offset = toFixed(offsetX, 4) + ", " + toFixed(offsetY, 4);
        skew.setPropertyString("offset", offset);
    } else {
        double deltaX = matrix.get(0, 2);
        double deltaY = matrix.get(1, 2);
        // Scale via coordsize property
        double zoomScaleX = zoom / deltaScaleX;
        double zoomScaleY = zoom / deltaScaleY;

        element.setPropertyString("coordsize", Math.abs(zoomScaleX) + " " + Math.abs(zoomScaleY));

        // Rotate via rotation property
        double newAngle = deltaDegrees * (deltaScaleX * ((deltaScaleY < 0) ? -1 : 1));
        if ((style.getProperty("rotation") == null && newAngle != 0)) {
            style.setProperty("rotation", String.valueOf(newAngle));
        } else if (style.getProperty("rotation") != null
                && newAngle != Double.valueOf(style.getProperty("rotation"))) {
            style.setProperty("rotation", String.valueOf(newAngle));
        }
        if (deltaDegrees != 0) {
            // Compensate x/y position due to rotation
            Matrix compMatrix = new Matrix();
            compMatrix.rotate(-deltaDegrees, deltaX, deltaY);
            deltaX = deltaX * compMatrix.get(0, 0) + deltaY * compMatrix.get(0, 1) + compMatrix.get(0, 2);
            deltaY = deltaX * compMatrix.get(1, 0) + deltaY * compMatrix.get(1, 1) + compMatrix.get(1, 2);
        }

        String flip = "";
        // Handle negative scaling via flipping
        if (deltaScaleX < 0) {
            flip += "x";
        }
        if (deltaScaleY < 0) {
            flip += " y";
        }
        if (!flip.equals("")) {
            style.setProperty("flip", flip);
        }

        // Translate via coordorigin property
        element.setPropertyString("coordorigin", (-zoomScaleX * (deltaX / ((ImageSprite) sprite).getWidth()))
                + " " + (-zoomScaleY * (deltaY / ((ImageSprite) sprite).getHeight())));
    }
}

From source file:com.sencha.gxt.explorer.client.grid.WordWrapGridExample.java

License:sencha.com license

@Override
public Widget asWidget() {

    if (fp == null) {
        fp = new FramedPanel();
        fp.setHeadingText("Word Wrap Grid");
        fp.getHeader().setIcon(ExampleImages.INSTANCE.table());
        fp.setPosition(10, 10);// w  w  w. j  a  va 2s .  com
        fp.setPixelSize(600, 400);
        new Resizable(fp, Dir.E, Dir.SE, Dir.S);

        ToolButton tb = new ToolButton(ToolButton.QUESTION);
        ToolTipConfig ttc = new ToolTipConfig("Example Info",
                "This example illustrates word wrap in grid headings and rows.");
        ttc.setMaxWidth(225);
        tb.setToolTipConfig(ttc);
        fp.addTool(tb);

        List<ColumnConfig<Row, ?>> ccs = new LinkedList<ColumnConfig<Row, ?>>();

        for (int i = 0; i < COLUMN_COUNT; i++) {
            ValueProvider<Row, String> cvp = rvp.getColumnValueProvider(i);
            SafeHtml sh = wrapString(createDummyText());
            ColumnConfig<Row, String> cc = new ColumnConfig<Row, String>(cvp, 200, sh);
            // Use a custom cell renderer to support word wrap in the grid's cells
            cc.setCell(new AbstractCell<String>() {
                @Override
                public void render(Context context, String value, SafeHtmlBuilder sb) {
                    if (value == null || value.isEmpty()) {
                        sb.appendHtmlConstant("&nbsp;");
                    } else {
                        sb.append(wrapString(value));
                    }
                }
            });
            ccs.add(cc);
        }

        final ColumnModel<Row> cm = new ColumnModel<Row>(ccs);

        final ListStore<Row> ls = new ListStore<Row>(new RowKeyProvider());
        ls.setAutoCommit(true);

        int columnCount = ccs.size();
        for (int i = 0; i < ROW_COUNT; i++) {
            Row row = new Row(columnCount);
            for (int j = 0; j < columnCount; j++) {
                row.setValue(j, createDummyText());
            }
            ls.add(row);
        }

        final Grid<Row> g = new Grid<Row>(ls, cm, new WordWrapGridView());
        g.getView().setColumnHeader(new WordWrapColumnHeader<Row>(g, cm));
        g.getView().setColumnLines(true);

        final GridInlineEditing<Row> gie = new GridInlineEditing<Row>(g) {
            protected void onScroll(ScrollEvent event) {
                // Suppress default action, which may result in canceling edit
            }
        };
        gie.setClicksToEdit(ClicksToEdit.TWO);
        gie.addStartEditHandler(new StartEditHandler<Row>() {
            @Override
            public void onStartEdit(StartEditEvent<Row> event) {
                GridCell cell = event.getEditCell();
                ColumnConfig<Row, ?> cc = cm.getColumn(cell.getCol());
                Field<Object> editor = (Field<Object>) gie.getEditor(cc);
                Element rowElement = g.getView().getRow(cell.getRow());
                // Resize the inline editor to the height of the row and style it to match the text
                int height = rowElement.getOffsetHeight() - 1;
                editor.setHeight(height);
                XElement cellElement = g.getView().getCell(cell.getRow(), cell.getCol()).cast();
                Style style = ((TextAreaAppearance) editor.getCell().getAppearance())
                        .getInputElement(editor.getElement()).getStyle();
                String fontSize = cellElement.getComputedStyle("fontSize");
                if (fontSize != null) {
                    style.setProperty("fontSize", fontSize);
                }
                String fontFamily = cellElement.getComputedStyle("fontFamily");
                if (fontFamily != null) {
                    style.setProperty("fontFamily", fontFamily);
                }
                style.setOverflow(Overflow.HIDDEN);
            }
        });

        for (ColumnConfig<Row, ?> cc : ccs) {
            @SuppressWarnings("unchecked")
            ColumnConfig<Row, String> scc = (ColumnConfig<Row, String>) cc;
            final TextArea ta = new TextArea();
            ta.setPreventScrollbars(true);
            ta.addKeyDownHandler(new KeyDownHandler() {
                @Override
                public void onKeyDown(KeyDownEvent event) {
                    // Allow the enter key to end grid inline editing
                    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                        Scheduler.get().scheduleFinally(new RepeatingCommand() {
                            @Override
                            public boolean execute() {
                                gie.completeEditing();
                                ta.clear();
                                return false;
                            }
                        });
                    }
                }
            });
            gie.addEditor(scc, ta);
        }

        g.addViewReadyHandler(new ViewReadyHandler() {
            @Override
            public void onViewReady(ViewReadyEvent event) {
                Info.display("onViewReady", "heading width=" + g.getView().getHeader().getOffsetWidth()
                        + ", height=" + g.getView().getHeader().getOffsetHeight());
                g.getView().getHeader().addResizeHandler(new ResizeHandler() {
                    @Override
                    public void onResize(ResizeEvent event) {
                        Info.display("onResize",
                                "heading width=" + event.getWidth() + ", height=" + event.getHeight());
                    }
                });
            }
        });

        fp.setWidget(g);

        fp.addButton(new TextButton("Set Heading Text", new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
                final Window w = new Window();
                w.setHeadingText("Set Heading Text");
                w.setPixelSize(300, 200);
                w.setResizable(false);
                w.setModal(true);
                VerticalLayoutContainer vlc = new VerticalLayoutContainer();
                w.setWidget(vlc);
                final IntegerSpinnerField index = new IntegerSpinnerField();
                index.setMinValue(0);
                index.setMaxValue(COLUMN_COUNT - 1);
                index.setValue(0);
                index.setAllowBlank(false);
                index.setSelectOnFocus(true);
                vlc.add(new FieldLabel(index, "Column Index"), new VerticalLayoutData(1, -1, M1));
                final TextArea text = new TextArea();
                vlc.add(new FieldLabel(text, "Heading Text"), new VerticalLayoutData(1, 1, M2));
                w.addButton(new TextButton("Cancel", new SelectHandler() {
                    @Override
                    public void onSelect(SelectEvent event) {
                        w.hide();
                    }
                }));
                w.addButton(new TextButton("OK", new SelectHandler() {
                    @Override
                    public void onSelect(SelectEvent event) {
                        if (index.validate()) {
                            w.hide();
                            SafeHtml newHeading;
                            String newText = text.getValue();
                            if (newText == null) {
                                newHeading = SafeHtmlUtils.fromSafeConstant("&nbsp;");
                            } else {
                                newHeading = wrapString(newText);
                            }
                            ColumnModel<Row> columnModel = g.getColumnModel();
                            columnModel.setColumnHeader(index.getValue(), newHeading);
                        }
                    }
                }));
                w.show();
                w.setFocusWidget(index);
            }
        }));

        fp.addButton(new TextButton("Set Cell Text", new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
                final Window w = new Window();
                w.setHeadingText("Set Cell Text");
                w.setPixelSize(300, 200);
                w.setResizable(false);
                w.setModal(true);
                VerticalLayoutContainer vlc = new VerticalLayoutContainer();
                w.setWidget(vlc);
                final IntegerSpinnerField rowIndex = new IntegerSpinnerField();
                rowIndex.setMinValue(0);
                rowIndex.setMaxValue(ROW_COUNT - 1);
                rowIndex.setValue(0);
                rowIndex.setAllowBlank(false);
                rowIndex.setSelectOnFocus(true);
                vlc.add(new FieldLabel(rowIndex, "Row Index"), new VerticalLayoutData(1, -1, M1));
                final IntegerSpinnerField columnIndex = new IntegerSpinnerField();
                columnIndex.setMinValue(0);
                columnIndex.setMaxValue(COLUMN_COUNT - 1);
                columnIndex.setValue(0);
                columnIndex.setAllowBlank(false);
                columnIndex.setSelectOnFocus(true);
                vlc.add(new FieldLabel(columnIndex, "Column Index"), new VerticalLayoutData(1, -1, M1));
                final TextArea text = new TextArea();
                vlc.add(new FieldLabel(text, "Cell Text"), new VerticalLayoutData(1, 1, M2));
                w.addButton(new TextButton("Cancel", new SelectHandler() {
                    @Override
                    public void onSelect(SelectEvent event) {
                        w.hide();
                    }
                }));
                w.addButton(new TextButton("OK", new SelectHandler() {
                    @Override
                    public void onSelect(SelectEvent event) {
                        if (rowIndex.validate() && columnIndex.validate()) {
                            w.hide();
                            String newText = text.getValue();
                            if (newText == null) {
                                newText = "";
                            }
                            Row row = ls.get(rowIndex.getValue());
                            row.setValue(columnIndex.getValue(), newText);
                            ls.update(row);
                        }
                    }
                }));
                w.show();
                w.setFocusWidget(rowIndex);
            }
        }));

        fp.addButton(new TextButton("Set Column Width", new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
                final Window w = new Window();
                w.setHeadingText("Set Column Width");
                w.setPixelSize(300, 150);
                w.setResizable(false);
                w.setModal(true);
                VerticalLayoutContainer vlc = new VerticalLayoutContainer();
                w.setWidget(vlc);
                final IntegerSpinnerField columnIndex = new IntegerSpinnerField();
                columnIndex.setMinValue(0);
                columnIndex.setMaxValue(COLUMN_COUNT - 1);
                columnIndex.setValue(0);
                columnIndex.setAllowBlank(false);
                columnIndex.setSelectOnFocus(true);
                vlc.add(new FieldLabel(columnIndex, "Column Index"), new VerticalLayoutData(1, -1, M1));
                final IntegerSpinnerField width = new IntegerSpinnerField();
                width.setMinValue(0);
                width.setValue(50);
                width.setAllowBlank(false);
                width.setSelectOnFocus(true);
                vlc.add(new FieldLabel(width, "Column Width"), new VerticalLayoutData(1, -1, M2));
                w.addButton(new TextButton("Cancel", new SelectHandler() {
                    @Override
                    public void onSelect(SelectEvent event) {
                        w.hide();
                    }
                }));
                w.addButton(new TextButton("OK", new SelectHandler() {
                    @Override
                    public void onSelect(SelectEvent event) {
                        if (columnIndex.validate() && width.validate()) {
                            w.hide();
                            g.getColumnModel().setColumnWidth(columnIndex.getValue(), width.getValue());
                        }
                    }
                }));
                w.show();
                w.setFocusWidget(columnIndex);
            }
        }));

        fp.addButton(new TextButton("Set Heading Height", new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
                final Window w = new Window();
                w.setHeadingText("Set Heading Height");
                w.setPixelSize(300, 250);
                w.setResizable(false);
                w.setModal(true);
                VerticalLayoutContainer vlc = new VerticalLayoutContainer();
                w.setWidget(vlc);
                vlc.add(new HTML(
                        "<span style='font: 12px tahoma,arial,verdana,sans-serif;'>Sets the size of the heading to a fixed height. If this height is less than the height of the heading text, the heading text will be truncated.<br><br>To restore automatic sizing, specify a value of -1.<br><br></span>"),
                        new VerticalLayoutData(1, -1, M1));
                final IntegerSpinnerField height = new IntegerSpinnerField();
                height.setMinValue(-1);
                height.setValue(50);
                height.setAllowBlank(false);
                height.setSelectOnFocus(true);
                vlc.add(new FieldLabel(height, "Heading Height"), new VerticalLayoutData(1, -1, M2));
                w.addButton(new TextButton("Cancel", new SelectHandler() {
                    @Override
                    public void onSelect(SelectEvent event) {
                        w.hide();
                    }
                }));
                w.addButton(new TextButton("OK", new SelectHandler() {
                    @Override
                    public void onSelect(SelectEvent event) {
                        if (height.validate()) {
                            w.hide();
                            g.getView().getHeader().setHeight(height.getValue());
                        }
                    }
                }));
                w.show();
                w.setFocusWidget(height);
            }
        }));

        fp.addButton(new TextButton("Get Heading Height", new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
                int headerHeight = g.getView().getHeader().getOffsetHeight();
                Info.display("getHeight", "height=" + headerHeight);
            }
        }));

        final ToggleButton fftb = new ToggleButton("Force Fit");
        fftb.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
            @Override
            public void onValueChange(ValueChangeEvent<Boolean> event) {
                if (fftb.getValue()) {
                    columnWidths.save(g);
                    g.getView().setForceFit(true);
                } else {
                    g.getView().setForceFit(false);
                    columnWidths.restore(g);
                }
                g.getView().layout();
            }
        });
        fp.addButton(fftb);

        fp.show();
    }

    return fp;
}