将嵌入式链接粘贴到文本框

时间:2017-05-16 05:30:29

标签: java events gwt paste

我正在尝试将嵌入式链接粘贴到文本框中,只要我将链接粘贴到文本框中..我应该获取YouTube视频...我已经在一个html面板中获得了嵌入式链接。这是我的代码:

package com.edubot.client.lecture;

import gwt.material.design.client.ui.MaterialButton;
import gwt.material.design.client.ui.MaterialTextBox;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;

public class EmbeddedLink extends Composite  {

    private static EmbeddedLinkUiBinder uiBinder = GWT
            .create(EmbeddedLinkUiBinder.class);

    interface EmbeddedLinkUiBinder extends UiBinder<Widget, EmbeddedLink> {
    }

    @UiField MaterialButton buttonembedded;
    //  @UiField IFrameElement youtubevideo;
    @UiField HTMLPanel htmlpanel;
    @UiField MaterialTextBox textbox ;

    public EmbeddedLink() {
        super();
        sinkEvents( Event.ONPASTE );
        initWidget(uiBinder.createAndBindUi(this));
    }

    @Override
    public void onBrowserEvent(Event event) {
        super.onBrowserEvent(event);
        PastEvent(event);
    } 

    //  @UiHandler("buttonembedded")
    //  void onClick(ClickEvent e) {
        //  addYoutubeVideo();  
    //  }

    public String addEmbeddedLink() {
        String link=textbox.getText();
        return link;
    }

    private void addYoutubeVideo() {
        //      youtubevideo.setSrc(addEmbeddedLink());
        htmlpanel.getElement().setInnerHTML(addEmbeddedLink());
    }

    private void PastEvent(Event event) {
        switch (event.getTypeInt()) {
        case Event.ONPASTE:
            addYoutubeVideo();
            break;
        }
    }
}

enter code here

0 个答案:

没有答案