SmartGWT - 无法点击项目进入 windows 模态

SmartGWT - can't click into items into windows modal

我在使用 WindowsetIsModal(true) 时遇到一个问题。

我有这个代码:

@Override
public void onModuleLoad() {

    Button tester = new Button("Tester");

    tester.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final com.smartgwt.client.widgets.Window win = new com.smartgwt.client.widgets.Window();
            win.setTitle("Ventana Tester");
            win.setWidth(900);
            win.setHeight(600);
            win.setIsModal(true);
            win.setShowModalMask(true);
            win.centerInPage();
            win.setMinimized(false);

            win.addCloseClickHandler(new CloseClickHandler() {
                @Override
                public void onCloseClick(CloseClientEvent event) {
                    win.destroy();
                }
            });


            PlanBoard pb = new PlanBoard();
            win.addItem(pb);

            win.show();

        }
    });

    vlPrincipal.addMember(tester);

    RootPanel.get("main").add(vlPrincipal);
}

这是 PlanBoard class:

public class PlanBoard extends VLayout{


private CaptionPanel contentDetallePlan =  new CaptionPanel("DETALLES DEL PLAN");
private CaptionPanel contentAtributosPlan =  new CaptionPanel("ATRIBUTOS DE PLAN");
private CaptionPanel contentSeccionesPlan =  new CaptionPanel("SECCIONES");

public PlanBoard(){

    contentDetallePlan.setStyleName("estiloCaptionPanel");
    contentAtributosPlan.setStyleName("estiloCaptionPanel");

    addMember(contentDetallePlan);
    addMember(contentAtributosPlan);
    addMember(contentSeccionesPlan);


    preparaDetallePlan();
    preparaAtributosPlan();
}


private void preparaDetallePlan(){

    VLayout contenedorSeccion = new VLayout();

    FlexTable table1 = new FlexTable();
    FlexTable table2 = new FlexTable();
    FlexTable table3 = new FlexTable();

    Label np = new Label("Nombre de Plan:");
    Label npText = new Label("Plan B");

    Label tc = new Label("Tipo de Carta:");
    DynamicForm tcForm = new DynamicForm();
    ComboBoxItem tcBox =  new ComboBoxItem();
    tcBox.setWidth(250);
    tcBox.setShowTitle(false);
    tcForm.setItems(tcBox);

    Label pr = new Label("Periodo:");
    DynamicForm prForm = new DynamicForm();
    ComboBoxItem prBox =  new ComboBoxItem();
    prBox.setWidth(150);
    prBox.setShowTitle(false);
    prForm.setItems(prBox);


    Label dp = new Label("Descripcion:");
    DynamicForm dpForm = new DynamicForm();
    TextAreaItem dpText =  new TextAreaItem();
    dpText.setShowTitle(false);
    dpText.setWidth(600);
    dpForm.setItems(dpText);



    table1.setWidget(0, 0, np);
    table1.setWidget(0, 1, npText);

    table2.setWidget(0, 0, tc);
    table2.setWidget(0, 1, tcForm);
    table2.setWidget(0, 2, pr);
    table2.setWidget(0, 3, prForm);

    table3.setWidget(0, 1, dp);
    table3.setWidget(1, 1, dpForm);

    contenedorSeccion.addMember(table1);
    contenedorSeccion.addMember(table2);
    contenedorSeccion.addMember(table3);

    contentDetallePlan.add(contenedorSeccion);


}

private void preparaAtributosPlan(){

    VLayout contenedorSeccion = new VLayout(); 

    FlexTable table1 = new FlexTable();

    Label fe = new Label("Firma Electornica:");
    CheckboxItem feCheck = new CheckboxItem();
    DateItem feFechaIni = new DateItem();
    DateItem feFechaFin = new DateItem();

    feFechaIni.setUseTextField(true);

    feCheck.setShowTitle(false);

    DynamicForm feForm = new DynamicForm();
    feForm.setItems(feCheck,feFechaIni,feFechaFin);

    table1.setWidget(0, 0, fe);
    table1.setWidget(0, 1, feForm);

    contenedorSeccion.addMember(table1);

    contentAtributosPlan.add(contenedorSeccion);


}

问题是当我尝试单击 CheckBoxItemDateItem 时,我无法编辑它们,但当我不使用 setIsModal(true) 时,它工作正常。

我不知道如何将 Window 设置为 modal(true),并让这些项目在 window 上工作。

这是你的代码清理(一点点)和改进,以便你想要实现的(这是带有 selectable/actionable 控件的模态 window):

PlanBoard.java

import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.CheckboxItem;
import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
import com.smartgwt.client.widgets.form.fields.DateItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.form.fields.TextAreaItem;
import com.smartgwt.client.widgets.layout.VLayout;

public class PlanBoard extends VLayout {

    public PlanBoard(){
        preparaDetallePlan();
        preparaAtributosPlan();
        preparaSecciones();
    }


    private void preparaDetallePlan(){
        StaticTextItem np = new StaticTextItem("id2", "Nombre de Plan:");
        StaticTextItem npText = new StaticTextItem("id2", "Plan B");

        ComboBoxItem tcBox =  new ComboBoxItem();
        tcBox.setTitle("Tipo de Carta");
        tcBox.setWidth(250);

        ComboBoxItem prBox =  new ComboBoxItem();
        tcBox.setTitle("Periodo");
        prBox.setWidth(150);

        StaticTextItem dp = new StaticTextItem("id3", "Descripcion:");

        TextAreaItem dpText =  new TextAreaItem();
        dpText.setShowTitle(false);
        dpText.setWidth(600);
        dpText.setStartRow(true);
        dpText.setEndRow(true);
        dpText.setColSpan(2);

        DynamicForm form = new DynamicForm();
        form.setItems(np, npText, tcBox, prBox, dp, dpText);
        form.setIsGroup(true);
        form.setGroupTitle("DETALLES DE PLAN");

        addMember(form);
    }

    private void preparaAtributosPlan(){
        StaticTextItem fe = new StaticTextItem("id4", "Firma Electornica:");
        CheckboxItem feCheck = new CheckboxItem();
        feCheck.setShowTitle(false);

        DateItem feFechaIni = new DateItem();
        DateItem feFechaFin = new DateItem();
        feFechaIni.setUseTextField(true);

        DynamicForm form = new DynamicForm();
        form.setItems(fe, feCheck, feFechaIni, feFechaFin);
        form.setIsGroup(true);
        form.setGroupTitle("ATRIBUTOS DE PLAN");

        addMember(form);
    }

    private void preparaSecciones(){
        DynamicForm form = new DynamicForm();
        form.setIsGroup(true);
        form.setGroupTitle("SECCIONES");
        addMember(form);
    }
}

TestCases.java(重命名为您未指定的 EntryPoint class 名称):

import com.smartgwt.client.widgets.IButton;  
import com.smartgwt.client.widgets.Window;  
import com.smartgwt.client.widgets.events.ClickEvent;  
import com.smartgwt.client.widgets.events.ClickHandler;  
import com.smartgwt.client.widgets.events.CloseClickEvent;  
import com.smartgwt.client.widgets.events.CloseClickHandler;  
import com.smartgwt.client.widgets.layout.VLayout; 

import com.google.gwt.core.client.EntryPoint;

public class TestCases implements EntryPoint {  

    public void onModuleLoad() {  

         IButton tester = new IButton("Tester");
         tester.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                final Window win = new Window();
                win.setTitle("Ventana Tester");
                win.setWidth(900);
                win.setHeight(600);
                win.setIsModal(true);
                win.setShowModalMask(true);
                win.centerInPage();
                win.setMinimized(false);

                win.addCloseClickHandler(new CloseClickHandler() {
                    @Override
                    public void onCloseClick(CloseClickEvent event) {
                        win.destroy();
                    }
                });

                PlanBoard pb = new PlanBoard();
                win.addItem(pb);
                win.show();
            }
        });

        VLayout vlPrincipal = new VLayout();
        vlPrincipal.addMember(tester);
        vlPrincipal.draw();
    }  
}  

一些注意事项:

  • 不要混合使用 GWT 和 SmartGWT 小部件,除非绝对必要并且只有当您真正知道自己在做什么时(因为它会产生意想不到的结果,就像您正在经历的那样) ).在你的情况下,混合是不必要的!
  • 您可以将标题添加到您正在使用的不同控件中,它们将显示为标签。您可以指定标题标签是显示在每个控件的上方还是一侧。
  • 查看 this SmartGWT 演示,了解如何配置和使用不同类型的 DynamicForm 控件。许多你试图做的事情,你做的比必要的更困难。
  • 在 "stylistic" 方面,不要使用西班牙式英语编写代码。我说西班牙语,所以我能理解,但它会限制你得到的反馈,因为你的代码很难理解。使用英语(至少对于您打算在 SO 中 post 的代码)。