1. #1
    Sencha Premium Member
    Join Date
    Nov 2013
    Location
    Boston, MA
    Posts
    22
    Vote Rating
    0
    sbusch is on a distinguished road

      0  

    Default Answered: CheckBoxCell tooltip

    Answered: CheckBoxCell tooltip


    How do I generate a tooltip for a checkbox cell? Below does not work.

    Thanks
    Code:
    final CheckBoxCell checkboxCell = new CheckBoxCell() {
        @Override
        public boolean isDisabled() {
            return true;
        }
                
        @Override
        public void render(Context context, Boolean value, SafeHtmlBuilder sb) {
            super.render(context, value, sb);
            sb.appendHtmlConstant("<span style='display:block' qwidth='400' qtip='"
                    + getFormattedToolTipValue(context.getIndex()) + "'></span>");
        }
    };

  2. We're using version 3.0.6 too.
    I'm very sorry.
    I copied some of our code without realizing that TooltipCell and TooltipValueProvider are classes of our own.

    Here's the code:
    TooltipCell.java
    Code:
    import <your path>.PlainStringTooltipValueProvider;
    import <your path>.TooltipValueProvider;
    import com.google.gwt.cell.client.AbstractCell;
    import com.google.gwt.cell.client.Cell;
    import com.google.gwt.cell.client.ValueUpdater;
    import com.google.gwt.dom.client.Element;
    import com.google.gwt.dom.client.NativeEvent;
    import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
    import com.google.gwt.safehtml.shared.SafeHtmlUtils;
    
    import java.util.Set;
    
    /**
     * This class wraps a cell into a cell that adds a QTip
     *
     * @param <S>
     */
    public class TooltipCell<S> implements Cell<S> {
    
        private final Cell<S> realCell;
        private final TooltipValueProvider<S> tooltipValueProvider;
    
        /**
         * Wraps an existing cell into a QuickTip rendering cell.
         *
         * @param realCell if null, a fallback is used, simple doing a toString() on the data.
         */
        public TooltipCell(Cell<S> realCell) {
            this(realCell, new PlainStringTooltipValueProvider<S>());
        }
    
        public TooltipCell(Cell<S> realCell, TooltipValueProvider<S> tooltipValueProvider) {
            if (realCell == null) {
                this.realCell = new NullCell<S>();
            } else {
                this.realCell = realCell;
            }
            this.tooltipValueProvider = tooltipValueProvider;
        }
    
        @Override
        public boolean dependsOnSelection() {
            return realCell.dependsOnSelection();
        }
    
        @Override
        public Set<String> getConsumedEvents() {
            return realCell.getConsumedEvents();
        }
    
        @Override
        public boolean handlesSelection() {
            return realCell.handlesSelection();
        }
    
        @Override
        public boolean isEditing(Context context, Element element, S s) {
            return realCell.isEditing(context, element, s);
        }
    
        @Override
        public void onBrowserEvent(Context context, Element element, S s, NativeEvent nativeEvent, ValueUpdater<S> sValueUpdater) {
            realCell.onBrowserEvent(context, element, s, nativeEvent, sValueUpdater);
        }
    
        @Override
        public void render(Context context, S s, SafeHtmlBuilder safeHtmlBuilder) {
            if (s != null) {
                String tooltip = SafeHtmlUtils.htmlEscape(tooltipValueProvider.get(context, s, realCell));
                safeHtmlBuilder.appendHtmlConstant("<span qtip='" + tooltip + "'>");
            }
            realCell.render(context, s, safeHtmlBuilder);
            if (s != null) {
                safeHtmlBuilder.appendHtmlConstant("</span>");
            }
        }
    
        @Override
        public boolean resetFocus(Context context, Element element, S s) {
            return realCell.resetFocus(context, element, s);
        }
    
        @Override
        public void setValue(Context context, Element element, S s) {
            realCell.setValue(context, element, s);
        }
    
        private class NullCell<S> extends AbstractCell<S> {
    
            @Override
            public void render(Context context, S s, SafeHtmlBuilder safeHtmlBuilder) {
                if (s != null) {
                    safeHtmlBuilder.appendEscaped("" + s);
                } else {
                    safeHtmlBuilder.appendEscaped("");
                }
            }
    
        }
    
    }
    TooltipValueProvider is just an interface:
    Code:
    import com.google.gwt.cell.client.Cell;
    
    /**
     * Renders the value S into a String by using the Cell
     */
    public interface TooltipValueProvider<S> {
    
        String get(Cell.Context context, S s, Cell<S> cell);
    }
    PlainStringTooltipValueProvider.java:

    Code:
    import com.google.gwt.cell.client.Cell;
    import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
    
    /**
     * Makes a plain string out of an Object S by striping all HTML tags once the Cell has rendered the Object S
     */
    
    public class PlainStringTooltipValueProvider<S> implements TooltipValueProvider<S> {
    
        @Override
        public String get(Cell.Context context, S s, Cell<S> cell) {
            SafeHtmlBuilder builder = new SafeHtmlBuilder();
            cell.render(context, s, builder);
            return builder.toSafeHtml().asString().replaceAll("\\<.*?>", "");
        }
    }
    Given this classes and interface, you can write the code I posted earlier.
    I hope this makes more sense and helps you.

  3. #2
    Ext GWT Premium Member gdlm's Avatar
    Join Date
    Jan 2012
    Location
    Belgium
    Posts
    208
    Answers
    2
    Vote Rating
    4
    gdlm is on a distinguished road

      0  

    Default


    I do it kind of this way:

    Code:
    ColumnConfig yourColumnConfig = ... create it
    yourColumnConfig.setCell(new TooltipCell<String>(
           checkboxCell,
           new TooltipValueProvider<String>() {
               @Override
               public String get(Cell.Context context, String value, Cell<String> cell) {
                   return getFormattedToolTipValue(context.getIndex());
               }
          }
    ));

  4. #3
    Sencha Premium Member
    Join Date
    Nov 2013
    Location
    Boston, MA
    Posts
    22
    Vote Rating
    0
    sbusch is on a distinguished road

      0  

    Default


    I'll give it a try tomorrow. Thanks.

  5. #4
    Sencha Premium Member
    Join Date
    Nov 2013
    Location
    Boston, MA
    Posts
    22
    Vote Rating
    0
    sbusch is on a distinguished road

      0  

    Default


    I'm having problem with implementing your sample. For example, get(xxx) isn't a ValueProvider method (perhaps getValue(...)??). It looks like I need two more classes - one to extend/implement AbstractCell and one for ValueProvider, but I'm just not sure. A fuller explanation would be greatly appreciated. BTW, I'm using 3.0.6.

    Thank you.

    Steve

  6. #5
    Ext GWT Premium Member gdlm's Avatar
    Join Date
    Jan 2012
    Location
    Belgium
    Posts
    208
    Answers
    2
    Vote Rating
    4
    gdlm is on a distinguished road

      0  

    Default


    We're using version 3.0.6 too.
    I'm very sorry.
    I copied some of our code without realizing that TooltipCell and TooltipValueProvider are classes of our own.

    Here's the code:
    TooltipCell.java
    Code:
    import <your path>.PlainStringTooltipValueProvider;
    import <your path>.TooltipValueProvider;
    import com.google.gwt.cell.client.AbstractCell;
    import com.google.gwt.cell.client.Cell;
    import com.google.gwt.cell.client.ValueUpdater;
    import com.google.gwt.dom.client.Element;
    import com.google.gwt.dom.client.NativeEvent;
    import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
    import com.google.gwt.safehtml.shared.SafeHtmlUtils;
    
    import java.util.Set;
    
    /**
     * This class wraps a cell into a cell that adds a QTip
     *
     * @param <S>
     */
    public class TooltipCell<S> implements Cell<S> {
    
        private final Cell<S> realCell;
        private final TooltipValueProvider<S> tooltipValueProvider;
    
        /**
         * Wraps an existing cell into a QuickTip rendering cell.
         *
         * @param realCell if null, a fallback is used, simple doing a toString() on the data.
         */
        public TooltipCell(Cell<S> realCell) {
            this(realCell, new PlainStringTooltipValueProvider<S>());
        }
    
        public TooltipCell(Cell<S> realCell, TooltipValueProvider<S> tooltipValueProvider) {
            if (realCell == null) {
                this.realCell = new NullCell<S>();
            } else {
                this.realCell = realCell;
            }
            this.tooltipValueProvider = tooltipValueProvider;
        }
    
        @Override
        public boolean dependsOnSelection() {
            return realCell.dependsOnSelection();
        }
    
        @Override
        public Set<String> getConsumedEvents() {
            return realCell.getConsumedEvents();
        }
    
        @Override
        public boolean handlesSelection() {
            return realCell.handlesSelection();
        }
    
        @Override
        public boolean isEditing(Context context, Element element, S s) {
            return realCell.isEditing(context, element, s);
        }
    
        @Override
        public void onBrowserEvent(Context context, Element element, S s, NativeEvent nativeEvent, ValueUpdater<S> sValueUpdater) {
            realCell.onBrowserEvent(context, element, s, nativeEvent, sValueUpdater);
        }
    
        @Override
        public void render(Context context, S s, SafeHtmlBuilder safeHtmlBuilder) {
            if (s != null) {
                String tooltip = SafeHtmlUtils.htmlEscape(tooltipValueProvider.get(context, s, realCell));
                safeHtmlBuilder.appendHtmlConstant("<span qtip='" + tooltip + "'>");
            }
            realCell.render(context, s, safeHtmlBuilder);
            if (s != null) {
                safeHtmlBuilder.appendHtmlConstant("</span>");
            }
        }
    
        @Override
        public boolean resetFocus(Context context, Element element, S s) {
            return realCell.resetFocus(context, element, s);
        }
    
        @Override
        public void setValue(Context context, Element element, S s) {
            realCell.setValue(context, element, s);
        }
    
        private class NullCell<S> extends AbstractCell<S> {
    
            @Override
            public void render(Context context, S s, SafeHtmlBuilder safeHtmlBuilder) {
                if (s != null) {
                    safeHtmlBuilder.appendEscaped("" + s);
                } else {
                    safeHtmlBuilder.appendEscaped("");
                }
            }
    
        }
    
    }
    TooltipValueProvider is just an interface:
    Code:
    import com.google.gwt.cell.client.Cell;
    
    /**
     * Renders the value S into a String by using the Cell
     */
    public interface TooltipValueProvider<S> {
    
        String get(Cell.Context context, S s, Cell<S> cell);
    }
    PlainStringTooltipValueProvider.java:

    Code:
    import com.google.gwt.cell.client.Cell;
    import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
    
    /**
     * Makes a plain string out of an Object S by striping all HTML tags once the Cell has rendered the Object S
     */
    
    public class PlainStringTooltipValueProvider<S> implements TooltipValueProvider<S> {
    
        @Override
        public String get(Cell.Context context, S s, Cell<S> cell) {
            SafeHtmlBuilder builder = new SafeHtmlBuilder();
            cell.render(context, s, builder);
            return builder.toSafeHtml().asString().replaceAll("\\<.*?>", "");
        }
    }
    Given this classes and interface, you can write the code I posted earlier.
    I hope this makes more sense and helps you.

  7. #6
    Sencha Premium Member
    Join Date
    Nov 2013
    Location
    Boston, MA
    Posts
    22
    Vote Rating
    0
    sbusch is on a distinguished road

      0  

    Default


    dank u, danke, merci (and thank you!). I will try this out this weekend.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi