GWT Spreadsheet

I am trying to reproduce the behavior of a spreadsheet cell using GWT. I was able to create a Composite widget called "Cell", which by default is a "Label" widget. When the user clicks on this widget, it becomes the TextBox widgets. In case of blur, the widget again becomes the Shortcut widget.

My question is about efficiency and rendering time. It would probably be easiest to make my “cell” “TextBox” and just change the look for the user via CSS (depending on whether they are included in the data or not). However, I think this will affect the rendering time, and therefore I will return to the Shortcut widget when input is not needed. The problem with this method, however, is that I basically create a new TextBox / Label every time the user needs to enter something into the "Cell".

Here is my pseudo code (since I'm not around the IDE) ...

public class Cell extends Composite {

private SimplePanel sp;

public Cell() {
    Label l = new Label("");
    sp.add(l);
}

private void switchMode() {
    Widget w = sp.getWidget();
    if (w instanceof Label) {
        // we have a Label, change it to a TextBox
        String text = ((Label) w).getText();
        sp.remove(w);
        sp.add(new TextBox(text));
        // force garbage collection
        w = null;
    } else {
        // we have a TextBox, change it to a Label
        String text = ((TextBox) w).getText();
        sp.remove(w);
        sp.add(new Label(text));
        // force garbage collection
        w = null;
    }
}

...

When onBlurEvent is present in the TextBox or when the onClick event is on the label, the switchMode () method is called. Critical code is welcome.

TextBox Label Cell, ?

+3
2

: , excel ( , ).

: : , innerHTML. , TextArea ( ), TextArea. OnBlur - , TextArea .

. TextArea .

. " GWT: Google Web Toolkit" http://code.google.com/events/io/2009/sessions/EffectiveGwt.html

+4

( simplePanel ) setVisable .

+2

Source: https://habr.com/ru/post/1729085/


All Articles