All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.mapway.document.ui.client.main.EntryPanel Maven / Gradle / Ivy

There is a newer version: 2.3.0
Show newest version
package cn.mapway.document.ui.client.main;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.event.logical.shared.CloseHandler;
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.ui.*;
import cn.mapway.document.ui.client.component.Clients;
import cn.mapway.document.ui.client.module.Entry;
import cn.mapway.document.ui.client.resource.SysResource;
import cn.mapway.document.ui.client.test.TestPanel;


/**
 * The Class EntryPanel.
 */
public class EntryPanel extends Composite {

    /**
     * The ui binder.
     */
    private static EntryPanelUiBinder uiBinder = GWT.create(EntryPanelUiBinder.class);

    /**
     * The Interface EntryPanelUiBinder.
     */
    interface EntryPanelUiBinder extends UiBinder {
    }

    /**
     * Instantiates a new entry panel.
     */
    public EntryPanel() {
        initWidget(uiBinder.createAndBindUi(this));
        btnTest.setStyleName(SysResource.INSTANCE.getCss().btn());
    }

    /**
     * The m entry.
     */
    Entry mEntry;

    /**
     * Parses the.
     *
     * @param e the e
     */
    public void parse(Entry e) {
        mEntry = e;
        lbTITLE.setText(e.title());
        lbSUMMARY.setHTML(e.summary());
        lbURL.setText("接口网址:  " + Clients.getHostPort() + e.url());
        lbAUTHOR.setText("作者:" + e.author());

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < e.invokeMethods().length(); i++) {
            String invokeMethod = e.invokeMethods().get(i);
            if (sb.length() > 0) {
                sb.append(",");
            }
            sb.append(invokeMethod);
        }
        lbINVOKE.setText("调用方法:" + sb.toString());


        paraIn.parseEntry(e);

        paraOut.parse(e.output());

        String html = toJavaMethod(e);


        javaSource.setHTML(html);
    }

    /**
     * 返回调用Java Connector方法
     *
     * @param e
     * @return
     */
    private String toJavaMethod(Entry e) {
        String html = "

调用方法:" + e.methodName() + "

"; return html; } /** * @param e * @return */ private String toSourceInfo(Entry e) { String html = "

JAVA源码信息

"; html += ""; html += ""; if (e.input().length() > 0) { html += ""; } if (e.output() != null) { html += ""; } html += "
控制类" + e.parentClassName() + "
控制方法" + e.methodName() + "
输入参数 " + e.input().get(0).type() + "
输出参数" + e.output().type() + "
"; return html; } /** * The java source. */ @UiField HTML javaSource; /** * The lb TITLE. */ @UiField Label lbTITLE; /** * The lb SUMMARY. */ @UiField HTML lbSUMMARY; /** * The lb URL. */ @UiField Label lbURL; /** * The lb AUTHOR. */ @UiField Label lbAUTHOR; /** * The lb INVOKE. */ @UiField Label lbINVOKE; /** * The para in. */ @UiField InputParameterPanel paraIn; /** * The para out. */ @UiField OutputParameter paraOut; /** * The dlg. */ DialogBox dlg; /** * The test panel. */ TestPanel testPanel; /** * The btn test. */ @UiField Button btnTest; /** * On test. * * @param e the e */ @UiHandler("btnTest") void onTest(ClickEvent e) { if (dlg == null) { dlg = new DialogBox(); dlg.setText("接口测试"); testPanel = new TestPanel(); testPanel.addCloseHandler(new CloseHandler() { @Override public void onClose(CloseEvent event) { dlg.hide(); } }); dlg.setWidget(testPanel); dlg.setGlassEnabled(true); dlg.setAutoHideEnabled(false); dlg.setStyleName(SysResource.INSTANCE.getCss().dlg()); } dlg.show(); dlg.center(); testPanel.invoke(mEntry); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy